Have a read of this thread, I think it's the same issue . .
Thank you very much guys!
I was mixing apples and oranges!
Have a read of this thread, I think it's the same issue . .
On the base of that thread, I have created a new custom indicator and the main part is this:
//+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int i,Counted_bars; //---------------------------------------------------------------------- Counted_bars=IndicatorCounted(); //---- if(Bars<=Lenght_SlowMean) return(0); if(Counted_bars<1) for(i=1;i<=Lenght_SlowMean;i++) { SlowMean[Bars-i]=EMPTY_VALUE; SlowClose[Bars-i]=EMPTY_VALUE; } //---- the last calculated bar will be recalculated if(Counted_bars > 0) Counted_bars--; int limit = Bars - Counted_bars - 1; //---- the main cycle for(int iChart = limit; iChart >= 0; iChart--) { int iDay = iBarShift(NULL,TimeFrameSlow,Time[iChart],false); SlowClose[iChart]=iClose(NULL,TimeFrameSlow,iDay); SlowMean[iChart]=iMA(NULL,TimeFrameSlow,Lenght_SlowMean,0,MODE_SMA,PRICE_CLOSE,iDay); } return(0); } //+------------------------------------------------------------------+\\
I use this indicator with a timeframe slower than the chart ("TimeFrameSlow").
When I drop this indicator on a chart, "SlowClose" e "SlowMean" are correct.
I don't understand why, when I use this indicator in a EA, during the back testing, "SlowMean" give correct values (a SMA on slower timeframe) but SlowClose give close values that aren't of the slower timeframe.
Can you give me any Suggestion about this problem?
Thanks.
I don't understand why, when I use this indicator in a EA, during the back testing,
You can NOT get bar zero data for other timeframes in the tester. you can't use the indicator with shifts where iBarShift(...,shift) == 0

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi guys, I need help.
I have created a simple custom indicator for using functions such as iRSI, iADX,...in some EAs.
I noted if I use for the custom indicator the same or smaller ( for exemple 60 min, 30 min) timeframe than the one of the chart (for exemple 240 min) where I use it, there isn't problems;
but if I use for the custom indicators a time frame bigger (for exemple daily) than the one of the chart (for exemple 240 min), the values of the indicators are 0.
Here I report the main part of the custom indicator:
//+------------------------------------------------------------------+
int start()
{
int i,
Counted_bars;
//---------------------------------------
Counted_bars=IndicatorCounted();
if(Bars<=Lenght_RSI) return(0);
i=Bars-Lenght_RSI+1;
if(Counted_bars>Lenght_RSI-1) i=Bars-Counted_bars-1;
//----
while(i>=0)
{
RSI[i]=iRSI(NULL,TimeFrameSlow,Lenght_RSI,PRICE_CLOSE,i);
OverSoldLevel[i]=OverSold;
OverBoughtLevel[i]=OverBought;
i--;
}
return(0);
}
//+------------------------------------------------------------------+\\
Someone can give me a solution for this trouble?
Thanks