Announcement

Collapse
No announcement yet.

How to set an alert to go off only once per bar?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to set an alert to go off only once per bar?

    I have a visual and audio alert that goes off when a certain condition is met. However, when the criteria are met it goes off evey tick. I only need this to go off once when the criteria is met. Below is what I attempted to do in order to accoplish this. This did not work, any suggestions would be appreciated.

    var LastRawtime;
    nVol1 = volume(0);
    nVol2 = volume(-1);

    nDif = ( nVol1-nVol2 ) / nVol2;
    if(getValue("rawtime",0)!=LastRawtime){
    if ( nDif >= nPct ) {

    setDefaultBarFgColor( fColor1, 0 );
    Alert.playSound("laser2.wav");
    Alert.addToList(getSymbol(), "BLUE VOLUME BAR - LOOK FOR TRADE !!",Color.black, Color.RGB(0,0,255));
    LastRawtime = getValue ("rawtime",0);


    -Nick
    " If a man didn't make mistakes he'd own the world in a month. But if he didn't profit from his mistakes, he wouldn't own a blessed thing."
    -Jesse Livermore

  • #2
    Hello Nick,

    Please review the AlertOncePerBar.efs formula example in our EFS Library.
    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation

    Comment


    • #3
      Jason,
      I added what I saw in that EFS, but still no luck. I enclosed a condensed version of my code. Any ideas??

      PHP Code:
      function preMain() {
      var 
      vFlagfalse;


      nDif = ( nVol1-nVol2 ) / nVol2;
      if ( 
      nDif >= nPct && vFlag == false ) {
      setDefaultBarFgColorfColor1); 
      Alert.addToList(getSymbol(), "BLUE VOLUME BAR - LOOK FOR    
             TRADE !!"
      ,Color.blackColor.RGB(0,0,255));
      vFlag true
      Thanks in advance
      Nick
      " If a man didn't make mistakes he'd own the world in a month. But if he didn't profit from his mistakes, he wouldn't own a blessed thing."
      -Jesse Livermore

      Comment


      • #4
        Hello Nick,

        The code you have posted is incomplete. You don't have a main() function for starters. I would suggest you start with the code example I pointed you to and then add your alert to that code. Give that a shot and if you still have trouble, post your complete formula here.
        Jason K.
        Project Manager
        eSignal - an Interactive Data company

        EFS KnowledgeBase
        JavaScript for EFS Video Series
        EFS Beginner Tutorial Series
        EFS Glossary
        Custom EFS Development Policy

        New User Orientation

        Comment


        • #5
          Jason,
          Sorry, I thought only posting the part I was trying to modify would be easier. I have attached my code below. I tried everything I could think of, but still not working. Any help is appreciated.

          Thanks,
          Nick
          " If a man didn't make mistakes he'd own the world in a month. But if he didn't profit from his mistakes, he wouldn't own a blessed thing."
          -Jesse Livermore

          Comment


          • #6
            Nick
            FWIW I ran the efs you posted and as far as I can see it is triggering the alert only once per bar.
            Alex

            Comment


            • #7
              After seein gyour message Alex, I decided to restart esignal and the EFS seems to be working how i thought it would. Thank you Jason and Alex for your help.


              -Nick
              " If a man didn't make mistakes he'd own the world in a month. But if he didn't profit from his mistakes, he wouldn't own a blessed thing."
              -Jesse Livermore

              Comment

              Working...
              X