Announcement

Collapse
No announcement yet.

Alert one time on current bar

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

  • Alert one time on current bar

    Can someone from eSignal make a routine or command that will fire either/or a popup or audio alert at the time the alert is called for without firing on every tick or using the "ComputeOnClose()" command?? This should work for "ALLBARS, NEWBAR, CURRENTBAR"

    I feel that this extremely important in that it would allow one to hear or see an alert precisely when they occur and not on the next bar..This would really be helpful when trading on longer chart periods allowing one to get into a trade on that bar..

    What I find as being strange is that if you set a BGColor to change on these changes, and you can not do the same with the alert function.

    Also, the alert should reset itself to catch any reverses on a current bar..

    My eyes are hurting from looking and trying the routines in file share..

    Thanks to anyone that can help.

    Racer

  • #2
    Racer
    The enclosed efs will trigger a single alert every time the faster average crosses the slower one. The alerts will reset if during the same bar the averages uncross.
    Alex


    PHP Code:
    //Alexis C. Montenegro © March 2006                         
    //Please include the above line when modifying this code

    function preMain() {
        
    setPriceStudy(true);
        
    setStudyTitle("MAx2(one alert)");
        
    setCursorLabelName("MA1"0);
        
    setCursorLabelName("MA2"1);
        
    setDefaultBarFgColor(Color.blue0);
        
    setDefaultBarFgColor(Color.red1);  
    }

    var 
    vMA1 null;
    var 
    vMA2 null;
    var 
    vFlag1 0;
    var 
    vFlag2 0;

    function 
    main(MALength1MALength2) {

        if(
    MALength1==nullMALength1 5; else MALength1 MALength1;
        if(
    MALength2==nullMALength2 10; else MALength2 MALength2;

        if(
    getBarState()==BARSTATE_ALLBARS){
            
    vMA1 = new MAStudy(MALength10"Close" MAStudy.SIMPLE);
            
    vMA2 = new MAStudy(MALength20"Close" MAStudy.SIMPLE);
        }
        
        if(
    vMA1.getValue(MAStudy.MA,-1) ==null || vMA2.getValue(MAStudy.MA,-1) == null) return;

        
    //this section determines the relative position of the averages at the prior bar
        //and sets the Flags accordingly
        
    if(getBarState() == BARSTATE_NEWBAR){
            if(
    vMA1.getValue(MAStudy.MA,-1) > vMA2.getValue(MAStudy.MA,-1)){
                
    vFlag1 1;
                
    vFlag2 1;
                }    
            if(
    vMA1.getValue(MAStudy.MA,-1) < vMA2.getValue(MAStudy.MA,-1)){
                
    vFlag1 = -1;
                
    vFlag2 = -1;
            }
        }    
        
        
    //the following section triggers alerts only in the direction determined by the code above
        
        //if crossing over
        
    if(vFlag1 == -1){
            if(
    vMA1.getValue(MAStudy.MA) > vMA2.getValue(MAStudy.MA) && vFlag2 == -1){
                
    Alert.playSound("ding.wav");
                
    vFlag2 1;
            }
            if(
    vMA1.getValue(MAStudy.MA) < vMA2.getValue(MAStudy.MA) && vFlag2 == 1){
                
    vFlag2 = -1;
            }
        }
        
    //if crossing under
        
    if(vFlag1 == 1){
            if(
    vMA1.getValue(MAStudy.MA) < vMA2.getValue(MAStudy.MA) && vFlag2 == 1){
                
    Alert.playSound("buzz.wav");
                
    vFlag2 = -1;
            }
            if(
    vMA1.getValue(MAStudy.MA) > vMA2.getValue(MAStudy.MA) && vFlag2 == -1){
                
    vFlag2 1;
            }
        }

      
        return new Array (
    vMA1.getValue(MAStudy.MA),vMA2.getValue(MAStudy.MA)); 

    Comment


    • #3
      Question on this formula

      Can you tell me where I would enter the numbers to change so it alerts when price crosses (or touches) the MA50?
      Also, is there a global filter for this, so I would get an audible alert and sound alert for any stock on my charts (and on my quote list? Don't know if that's possible also)
      Thanks

      Comment


      • #4
        Can't remove this alert from charts

        When I go to 'remove' and select this alert, it won't remove.
        Is there something in the formula that precludes that function? Please advise.

        Comment


        • #5
          TraderJen

          Can you tell me where I would enter the numbers to change so it alerts when price crosses (or touches) the MA50?

          This efs does not actually trigger alerts when prices cross an average rather when two averages cross each other.
          However since a 1 period average of the Close is a proxy of the Close you can use the efs for your purpose.
          To do that change the following lines from
          if(MALength1==null) MALength1 = 5; else MALength1 = MALength1;
          if(MALength2==null) MALength2 = 10; else MALength2 = MALength2;

          to
          if(MALength1==null) MALength1 = 1; else MALength1 = MALength1;
          if(MALength2==null) MALength2 = 50; else MALength2 = MALength2;


          Also, is there a global filter for this, so I would get an audible alert and sound alert for any stock on my charts (and on my quote list? Don't know if that's possible also)

          At this time efs cannot be used in Quote Windows so to get the alerts you want you will need to have a chart open for each security you wish to follow and this efs loaded in each chart.
          Alex

          Comment


          • #6
            TraderJen

            When I go to 'remove' and select this alert, it won't remove

            The Remove command removes the efs from a chart not the alerts.

            Is there something in the formula that precludes that function? Please advise

            Not sure what you are asking.
            Alex

            Comment


            • #7
              Yes, when I click remove and select the efs from the list, it doesn't work...it still remains on the chart... I had to resort to closing the chart without saving it and reopening it.
              Can you test that function on your end and see if it works?

              Comment


              • #8
                TraderJen
                FWIW there is nothing in the efs itself that can affect the Remove command.
                Anyhow I can apply the efs to a chart and Remove it at will.
                Alex

                Comment

                Working...
                X