Can anybody help me with this indicator? What is missing?
//ArrayGetAsSeries(BBBuffer); //ArrayGetAsSeries(MABuffer); ArraySetAsSeries(BuyArrow,true); ArraySetAsSeries(SellArrow,true); ArraySetAsSeries(MABuffer,true); ArraySetAsSeries(BBBuffer,true);
if(rates_total<MA_Period) return(0); ArraySetAsSeries(high,true); ArraySetAsSeries(low,true); int calculated=BarsCalculated(MAHandle);
if(prev_calculated==0) limit=rates_total - MA_Period; else limit=rates_total - prev_calculated+1; for(int i=limit ;i>=0 && !IsStopped();i--){ BuyArrow[i]= EMPTY_VALUE; SellArrow[i]= EMPTY_VALUE; if(MABuffer[i]<BBBuffer[i] ) BuyArrow[i]=low[i]; if(MABuffer[i]>BBBuffer[i]) SellArrow[i]=high[i]; }
Ok Thank you I will try your solution , but I have solve it with this solution
int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,BuyArrow,INDICATOR_DATA); SetIndexBuffer(1,SellArrow,INDICATOR_DATA); SetIndexBuffer(2,BBBuffer,INDICATOR_CALCULATIONS); SetIndexBuffer(3,MABuffer,INDICATOR_CALCULATIONS); PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_ARROW); PlotIndexSetInteger(0,PLOT_ARROW,233); PlotIndexSetInteger(1,PLOT_DRAW_TYPE,DRAW_ARROW); PlotIndexSetInteger(1,PLOT_ARROW,234); PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE); PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,EMPTY_VALUE); ArraySetAsSeries(BuyArrow,true); ArraySetAsSeries(SellArrow,true); ArraySetAsSeries(MABuffer,true); ArraySetAsSeries(BBBuffer,true); BBHandle = iBands(NULL,PERIOD_CURRENT,BB_Period,BB_Shift,BB_Deviation,PRICE_CLOSE); MAHandle = iMA(NULL,PERIOD_CURRENT,MA_Period,0,MA_Method,PRICE_CLOSE); 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[]) { //--- int limit; if(rates_total<MA_Period) return(0); limit=rates_total - prev_calculated-1; for(int x=limit;x>=0;x--) { CopyBuffer(MAHandle,0,x,limit,MABuffer); CopyBuffer(BBHandle,0,x,limit,BBBuffer); } for(int i=1; i<rates_total ;i++){ if(MABuffer[i]<BBBuffer[i] && MABuffer[i-1]>BBBuffer[i-1]){ BuyArrow[i]=low[i]; if(Enable_Alert) Alert("Buy Signal "+_Symbol); } if(MABuffer[i]>BBBuffer[i] && MABuffer[i-1]<BBBuffer[i-1]){ SellArrow[i]=high[i]; if(Enable_Alert) Alert("Sell Signal "+_Symbol); } } //--- return value of prev_calculated for next call return(rates_total); }
Hello and Thanks for your time to look at my post.
I have tried a lot of different approaches to plot a simple arrow when bb middle line is above ma 200 and vice versa but It did not work or even plots.
I hope you help figure out what I am missing
Thanks