Announcement

Collapse
No announcement yet.

question for Alexis

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

  • question for Alexis

    Hi Alexis, could you please let me know what do I need to do in order to combine two existing scripts. One for say "new" Moving Average and the other script for the condition on this moving average. For example the script for the MA would end something like this:
    Average = c1 * xe6.getValue(0) + c2 * xe5.getValue(0) + c3 * xe4.getValue(0) + c4 * xe3.getValue(0);

    return Average;

    then the second (added) script I wrote like this):

    if (close > Average){

    setPriceBarColor(Color.RGB(0,255,0),Color.RGB(115, 115,117),true,false);

    } if (close < Average){
    setPriceBarColor(Color.RGB(0,155,0),Color.RGB(0,15 5,0),true,false);

    return;
    }
    }
    }

    However, the script does not recognize the "Average" from the first script. First script works just fine, however, when I add these conditions it does not work. What am I missing?

    Thank you Alexis!!!

  • #2
    Re: question for Alexis

    Originally posted by mzafka
    Hi Alexis, could you please let me know what do I need to do in order to combine two existing scripts. One for say "new" Moving Average and the other script for the condition on this moving average. For example the script for the MA would end something like this:
    Average = c1 * xe6.getValue(0) + c2 * xe5.getValue(0) + c3 * xe4.getValue(0) + c4 * xe3.getValue(0);

    return Average;

    then the second (added) script I wrote like this):

    if (close > Average){

    setPriceBarColor(Color.RGB(0,255,0),Color.RGB(115, 115,117),true,false);

    } if (close < Average){
    setPriceBarColor(Color.RGB(0,155,0),Color.RGB(0,15 5,0),true,false);

    return;
    }
    }
    }

    However, the script does not recognize the "Average" from the first script. First script works just fine, however, when I add these conditions it does not work. What am I missing?

    Thank you Alexis!!!
    It looks to me like you should move the "return Average;" statement to the bottom and get rid of the second return statement
    ....Mike

    Comment

    Working...
    X