Announcement

Collapse
No announcement yet.

Alert on Oscillator cross over

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

  • Alert on Oscillator cross over

    Could someone please help in assisting me in writing the alert language for a text and sound alert when the following attached Oscillator crosses the 0 line from up to down and vice versa.

    Thank you.

    Richard
    Attached Files

  • #2
    Richard
    Open the efs with the Editor and add the following block of code just above the return statement
    PHP Code:
    if(getBarState()==BARSTATE_NEWBAR){
            if(
    xOsc.getValue(-2)<&& xOsc.getValue(-1)>||
               
    xOsc.getValue(-2)>&& xOsc.getValue(-1)<0){
                   
    Alert.playSound("ding.wav");
                   
    Alert.addToList(getSymbol(),"Crossing 0",Color.black,Color.red);
            }
        } 
    This will trigger a sound and a popup alert when the oscillator has crossed the 0 line on a completed bar.
    If you intend to run the efs using an external interval (ie an interval that is different from the one being charted) then in the block of code shown above replace
    PHP Code:
    if(getBarState()==BARSTATE_NEWBAR){ 
    with
    PHP Code:
    if(getBarStateInterval(Interval+"")==BARSTATE_NEWBAR){ 
    which will ensure that the condition is evaluated only on a new bar of the external interval
    Alex

    Comment

    Working...
    X