Announcement

Collapse
No announcement yet.

efs2 ALERT between 2 time periods

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

  • efs2 ALERT between 2 time periods

    Hi Alex
    Is it possible to set up an alert between a stochastic in 2 different time periods?
    For example
    efs 2 stochastic %K =2 in 5 minute mode and
    efs 2 stochastic %K =2 in 10 minute mode

    The alert would trigger at minutes 00,10,20,30,40,50
    when the two stochs diverge.
    ie one goes up and the other goes down.
    Many thanks
    Ian

  • #2
    Ian
    Yes it is possible. To do that you would use the getBarStateInterval() statement to check for the conditions only when a new 10 min bar is created.
    Assume that we have two Stochastic studies based on different intervals (you need to declare the variables StochK1 and StochK2 as global variables and set them to null)

    PHP Code:
    if(StochK1==nullStochK1 stochK(14,1,1,inv(5));
    if(
    StochK2==nullStochK2 stochK(14,1,1,inv(10)); 
    Then we can set up the conditions in the following way

    PHP Code:
    if(getBarStateInterval("10")==BARSTATE_NEWBAR){//when a new 10 minute bar is created
            
    if(StochK1.getValue(-1)>StochK1.getValue(-2)&&//if 5min stoch of prior bar > 5min stoch of 2 bars ago AND
               
    StochK2.getValue(-1)<StochK2.getValue(-2)||//10min stoch or prior bar < 10min stoch of 2 bars ago OR
               
    StochK1.getValue(-1)<StochK1.getValue(-2)&&//conditions opposite to the above
               
    StochK2.getValue(-1)>StochK2.getValue(-2)){
                   
    Alert.playSound("ding.wav");//play sound
            
    }
        } 
    Notice that I am using xxx.getValue(-x) in the conditions since I am evaluating historical values that are not going to change in real time.
    For the return statement instead you would return an array with getSeries(StochK1) and getSeries(StochK2) so as to maintain the syncronization of the plots.
    Alex

    Comment


    • #3
      Originally posted by Alexis C. Montenegro
      Ian
      Yes it is possible. To do that you would use the getBarStateInterval() statement to check for the conditions only when a new 10 min bar is created.
      Assume that we have two Stochastic studies based on different intervals (you need to declare the variables StochK1 and StochK2 as global variables and set them to null)

      PHP Code:
      if(StochK1==nullStochK1 stochK(14,1,1,inv(5));
      if(
      StochK2==nullStochK2 stochK(14,1,1,inv(10)); 
      Then we can set up the conditions in the following way

      PHP Code:
      if(getBarStateInterval("10")==BARSTATE_NEWBAR){//when a new 10 minute bar is created
              
      if(StochK1.getValue(-1)>StochK1.getValue(-2)&&//if 5min stoch of prior bar > 5min stoch of 2 bars ago AND
                 
      StochK2.getValue(-1)<StochK2.getValue(-2)||//10min stoch or prior bar < 10min stoch of 2 bars ago OR
                 
      StochK1.getValue(-1)<StochK1.getValue(-2)&&//conditions opposite to the above
                 
      StochK2.getValue(-1)>StochK2.getValue(-2)){
                     
      Alert.playSound("ding.wav");//play sound
              
      }
          } 
      Notice that I am using xxx.getValue(-x) in the conditions since I am evaluating historical values that are not going to change in real time.
      For the return statement instead you would return an array with getSeries(StochK1) and getSeries(StochK2) so as to maintain the syncronization of the plots.
      Alex
      Hi Alex, this is fantastic.
      However I am still too new to efs and too pre occupied with trading to know what to do with it.
      Is is possible to get the completed code?
      Many thanks
      Ian

      Comment


      • #4
        Hi Ian,

        get in touch... your email is bouncing. I did an efs for you in London.

        Rgds,
        -aria

        Comment

        Working...
        X