English

Pip distance from MA coding problem.

 44 mickeyferrari 2016.03.25 19:41   ```#property strict #property indicator_chart_window #property indicator_buffers 5 //---Indicator Colours #property indicator_color1 clrGreen//UpArrow #property indicator_color2 clrRed//DownArrow #property indicator_color3 clrRed//EMA50 #property indicator_color4 clrBlue//EMA120 //---Indicator Width #property indicator_width1 2 #property indicator_width2 2 #include double pips; extern bool show=true;//Show Indicators? extern int PipRange=0; double UpArrow[]; double DownArrow[]; double EMA50[]; double EMA120[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function                         | //+------------------------------------------------------------------+ int OnInit()   {    pips=Point; //.00001 or .0001. .001 .01.    if(Digits==3 || Digits==5)       pips*=10; //--- indicator buffers mapping    SetIndexBuffer(0,UpArrow);    SetIndexStyle(0,DRAW_ARROW);    SetIndexArrow(0,233);    SetIndexLabel(0,"Buy Signal."); //---    SetIndexBuffer(1,DownArrow);    SetIndexStyle(1,DRAW_ARROW);    SetIndexArrow(1,234);    SetIndexLabel(1,"Sell Signal."); //---      SetIndexBuffer(2,EMA50);    SetIndexStyle(2,DRAW_LINE);    SetIndexLabel(2,"EMA50."); //---    SetIndexBuffer(3,EMA120);    SetIndexStyle(3,DRAW_LINE);    SetIndexLabel(3,"EMA120.");    return(INIT_SUCCEEDED);   } //+------------------------------------------------------------------+ //| Custom indicator iteration function                              | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total,                 const int prev_calculated,                 const datetime &time[],                 const double &open[],                 const double &high[],                 const double &low[],                 const double &close[],                 const long &tick_volume[],                 const long &volume[],                 const int &spread[])   { //---for loop    int counted_bars=IndicatorCounted();    int limit= Bars-counted_bars;    for(int i=1;iMA120)          if((PriceHigh-PipRange*pips)70)            {             DownArrow[i]=Open[i];            }      } //--- return value of prev_calculated for next call    return(rates_total);   } //+------------------------------------------------------------------+ ```
 44 mickeyferrari 2016.03.25 19:41 #   `if((PriceHigh-PipRange*pips)
 44 mickeyferrari 2016.03.25 19:43 #   I am trying to simply get an up arrow to draw if the price high of the bar is below MA120 by n pips. However I do not get the results I wish for !!Can somebody please suggest a coding fix?Regards Mickey.
12985
WHRoeder 2016.03.25 19:56 #

mickeyferrariif the price high of the bar is below MA120 by n pips. However I do not get the results I wish for !!
`if((PriceHigh-PipRange*pips)<MA120)`
 You have high is below MA + n pips `if(PriceHigh < MA120 + PipRange*pips) // rewritten.` Code it exactly how you stated ` if(PriceHigh < MA120 -PipRange*pips) // high is below n pips`

 44 mickeyferrari 2016.03.25 20:01 #   Thanks WH I see the logic !! Happy Easter:)