Announcement

Collapse
No announcement yet.

How to set up Aroon Cross Alert?

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

  • How to set up Aroon Cross Alert?

    Hello,

    I would like an efs to use that will indicate when the Aroon Up crosses over the Aroon Down..I have something "similar" ie a MA crossover,, and would like to modify it to use for Aroons instead.. can you help me with that?

    WIll paste the MA one below:
    (I see the line numbers didn't get copied, if you need to see that just let me know how to get that copied)

    Study(5, 0, "Close" , MAStudy.EXPONENTIAL);

    var vMA2 = new MAStudy(20, 0, "Close" , MAStudy.SIMPLE);

    var fp6 = new FunctionParameter("Background", FunctionParameter.STRING);
    fp6.addOption("On");
    fp6.addOption("Off");
    fp6.setDefault("On"); //Edit this value to set a new default

    function preMain() {

    setPriceStudy(true);

    setStudyTitle("MAx5over20(one alert, use on 60min)");

    setCursorLabelName("MA1", 0);

    setCursorLabelName("MA2", 1);

    setDefaultBarFgColor(Color.blue, 0);

    setDefaultBarFgColor(Color.red, 1);
    setDefaultChartBG(Color.black);

    }



    var vFlag1 = 0;

    var vFlag2 = 0;



    function main() {



    //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("cowbell.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("drip.wav");

    vFlag2 = -1;

    }

    if(vMA1.getValue(MAStudy.MA) > vMA2.getValue(MAStudy.MA) && vFlag2 == -1){

    vFlag2 = 1;

    }
    }

    if(Background=="On"){
    if(vMA1.getValue(MAStudy.MA) > vMA2.getValue(MAStudy.MA) && vFlag2 == -1){
    setChartBG(Color.khaki);
    }
    else if(vMA1.getValue(MAStudy.MA) < vMA2.getValue(MAStudy.MA) && vFlag2 == 1){
    setChartBG(Color.darkgrey);
    }
    else{
    setChartBG(Color.black);
    }
    }




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

    }

  • #2
    TraderJen
    The easiest way to do that is to use the same logic of the ArnOsc.efs which is in the Library folder and set your conditions based on the difference between ArnUp and ArnDn crossing above or below 0.
    In the Aroon.efs first create a global variable called for example AlertTriggered and set it initially to 0 eg
    var AlertTriggered = 0;
    Then in the main function insert the code enclosed below
    Alex

    PHP Code:
    if(ArnUp-ArnDn>0){
            if(
    AlertTriggered!=1Alert.playSound("ding.wav");
            
    AlertTriggered 1;
        }
        if(
    ArnUp-ArnDn<0){
            if(
    AlertTriggered!=2Alert.playSound("buzz.wav");
            
    AlertTriggered 2;
        } 

    Comment


    • #3
      Alexis, thank you I will try that..
      so this phrase
      "s based on the difference between ArnUp and ArnDn crossing above or below 0."

      does that infer that ArnUp crosses over ArnDn and visa versa?

      (Sorry for basic question, I don't usually program)

      Comment


      • #4
        TraderJen
        Calculating the difference between ArnUp and ArnDn and then evaluating when this difference crosses above/below 0 is the same as evaluating when the ArnUp crosses above/below ArnDn
        As an example see the image enclosed below where I show two averages and an oscillator (ie the difference between those two averages). As you can see the points in which the oscillator crosses the 0 line correspond to the same points in which the two averages cross.
        Hope this helps
        Alex

        Comment

        Working...
        X