Announcement

Collapse
No announcement yet.

Alerts

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

  • Alerts

    I have written an efs with the wizard. When a bar is open that meets these conditions the efs sets the bar color as expected, flickering in an out as conditions change.

    When I apply a sound alert...the alert goes off every tick. This is not very nice and I have figured out how to have an alert go off when this bar closes by using the getnew bar state...newbarstate commands. This way i get a sound once after the bar has closed. My question is...is there a way to get the sound alert once while the bar is open the first time it has met conditons...and not repeat the sound every tick.

    Thank You

  • #2
    here is your solution. You need to setup a variable to handle when the condition is met and when it is not. This will allow the alert to fire on every instance the condition is met, but not over and over when it has already been met.

    PHP Code:
    var vAlertCondition false;


    function 
    main() {

     if (
    vAlertCondition == false) {
        
    //  This fires your alerts when the condition is true and prevents it from firing over and over.
          
    if (Your_Condition == true) {
             
    vAlertCondition true;
             ..  
    fire the alerts here
          
    }

     } else if (
    vAlertCondition == true) {
        
    //  this reset the vAlertCondition trigger to FALSE
          
    if (Your_Condition == false) {
             
    vAlertCondition false;
          }

     }




    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      thank you for the reply. i see that you are a 'developer.' what does this mean and how may i contact you? i can see that i will not be able to accomplish this on my own.

      Thank you and break out your snow shovel!

      Comment


      • #4
        barner
        You should be able to accomplish what you want using just the Formula Wizard.
        To do this you would set the first condition (ie Set1) to simply check for getBarState() to be equal to BARSTATE_NEWBAR (see following screenshot)



        Then create a Set for each subsequent condition and in each make sure that the alert commands are located in the "while the following will happen only the first time" section. As an example see the following two screenshots where the conditions are set to sound an alert if the Close is greater than the previous bar's High (Set2) or if the Close is below the previous bar's Low (Set3)





        These alerts will be triggered only once per bar
        If you then review the code generated by the Formula Wizard you will see that the onAction1() function which is called by Set1 only on the first tick of every new bar will set the value of the variable vLastAlert (which is created by the Formula Wizard) to a value of 1.
        The onAction2() function called by the condition in Set2 will check if the variable vLastAlert is not equal to 2 and if that is the case will sound the alert and set vLastAlert to 2 thereby preventing any further alerts from being triggered on that same bar for that condition.
        Similarly the onAction3() function - that is called by the condition in Set3 - will check if vLastAlert is not equal to 3 in which case it will sound the alert and set vLastAlert to a value of 3 thereby preventing any further alerts from being triggered on the same bar for that condition.
        Then on the first tick of every new bar vLastAlert is again reset to 1 thereby allowing any new alerts to be triggered for that bar and so on and so forth.
        Hope this helps
        Alex


        Originally posted by barner
        I have written an efs with the wizard. When a bar is open that meets these conditions the efs sets the bar color as expected, flickering in an out as conditions change.

        When I apply a sound alert...the alert goes off every tick. This is not very nice and I have figured out how to have an alert go off when this bar closes by using the getnew bar state...newbarstate commands. This way i get a sound once after the bar has closed. My question is...is there a way to get the sound alert once while the bar is open the first time it has met conditons...and not repeat the sound every tick.

        Thank You

        Comment

        Working...
        X