I am facing some problem with MQL5 indicator code. Problem is that. i am draw line base on RSI Period = 14. So i want my indicator not draw last previous 14 candle. But when i code, my not draw from first. I think am doing something wrong. then code is below.
voidOnInit()
{
min_rates_total=int(RSI_Period)+1;
Rsi_Handle_Close=iRSI(NULL,0,RSI_Period,PRICE_CLOSE);
if(Rsi_Handle_Close==INVALID_HANDLE) Print(" Failed to get the indicator handle!");
SetIndexBuffer(0,Candle1Buffer1,INDICATOR_DATA);
ArraySetAsSeries(Candle1Buffer1,true);
//Define the number of color indexes, used for a graphic plotPlotIndexSetInteger(0,PLOT_COLOR_INDEXES,2);
//Set color for each indexPlotIndexSetInteger(0,PLOT_LINE_COLOR,0,Blue); //Zeroth index -> BluePlotIndexSetInteger(0,PLOT_LINE_COLOR,1,Red); //First index -> Orande
}
intOnCalculate(constint rates_total,
constint prev_calculated,
constdatetime &time[],
constdouble &open[],
constdouble &high[],
constdouble &low[],
constdouble &close[],
constlong &tick_volume[],
constlong &volume[],
constint &spread[])
{
if(rates_total<min_rates_total) return(RESET);
double RSI_Open[], RSI_High[],RSI_Low[], RSI_Close[];
int limit, bar, to_copy;
if(prev_calculated>rates_total || prev_calculated<=0)
{
limit=rates_total-min_rates_total-1;
}
else
{
limit=rates_total-prev_calculated;
}
to_copy = limit+2;
if(CopyBuffer(Rsi_Handle_Close,0,0,to_copy,RSI_Close)<=0) return(RESET);
if(CopyBuffer(Rsi_Handle_Open,0,0,to_copy,RSI_Open)<=0) return(RESET);
if(CopyBuffer(Rsi_Handle_High,0,0,to_copy,RSI_High)<=0) return(RESET);
if(CopyBuffer(Rsi_Handle_Low,0,0,to_copy,RSI_Low)<=0) return(RESET);
ArraySetAsSeries(RSI_Open,true);
ArraySetAsSeries(RSI_High,true);
ArraySetAsSeries(RSI_Low,true);
ArraySetAsSeries(RSI_Close,true);
for(bar=limit; bar>=0 && !IsStopped(); bar--)
{
Candle1Buffer1[bar]=RSI_Open[bar];
Candle1Buffer4[bar]=RSI_Close[bar];
if(RSI_Open[bar] > RSI_Close[bar]){
buffer_color_line[bar]=0;
Candle1Buffer2[bar]=RSI_High[bar];
Candle1Buffer3[bar]=RSI_Low[bar];
} else {
buffer_color_line[bar]=1;
Candle1Buffer2[bar]=RSI_Low[bar];
Candle1Buffer3[bar]=RSI_High[bar];
}
}
return(rates_total);
}
Dear Guys.
I am facing some problem with MQL5 indicator code. Problem is that. i am draw line base on RSI Period = 14. So i want my indicator not draw last previous 14 candle. But when i code, my not draw from first. I think am doing something wrong. then code is below.