Announcement

Collapse
No announcement yet.

MACD Crossover alert

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • MACD Crossover alert

    On the MACD crossover EFS, I added an audio alert to the EFS that dings when MACD and signal line cross. However, I would like to hear the ding only on close, not intra-bar. Any suggestions?
    The code I used for the alert was "
    alert.playsound("ding.wav"); // play sound file

  • #2
    Re: MACD Crossover alert

    davidjrjr
    You can do that by adding the following lines of code in the main function before the return statement
    Alex

    PHP Code:
    if(getBarState()==BARSTATE_NEWBAR){//on the first tick of a new bar
        
    if(study.getValue(MACDStudy.MACD,-2) <= study.getValue(MACDStudy.SIGNAL,-2) && //IF MACD of two bars ago is less than Signal of two bars ago AND
           
    study.getValue(MACDStudy.MACD,-1) > study.getValue(MACDStudy.SIGNAL,-1){ //MACD at prior bar is greater than Signal at p[rior bar THEN
                
    Alert.playSound("ding.wav");//sound alert
        
    }
        
    //same as above but with reversed operators for crossing down


    Originally posted by davidjrjr
    On the MACD crossover EFS, I added an audio alert to the EFS that dings when MACD and signal line cross. However, I would like to hear the ding only on close, not intra-bar. Any suggestions?
    The code I used for the alert was "
    alert.playsound("ding.wav"); // play sound file

    Comment


    • #3
      Thanks Alexis

      Comment


      • #4
        davidjrjr
        My pleasure
        Alex


        Originally posted by davidjrjr
        Thanks Alexis

        Comment

        Working...
        X