Slawa: TimeCurrent() in tester: EA vs. Indicator
But don't attach custom indicators with access to other symbol/period to avoid "visual mismatching"
This is my partial solution:
I make a special EA designed for running with the indicator under visual testing. I just modified a copy of "MACD Sample" and added this to its start()
if(IsTesting()) GlobalVariableSet("myEA_TimeCurrent",TimeCurrent());
and this to the deinit()
GlobalVariableDel("myEA_TimeCurrent");
Then the indicator checks:
if(GlobalVariableCheck("myEA_TimeCurrent")) timeToUse=GlobalVariableGet("myEA_TimeCurrent");
And then later it determines the shift of the other period.:
// in a loop where "i" is a given shift of the current chart, usually zero
if(timeToUse==0) otherPeriodZeroBar=0;
else
{
otherPeriodZeroBar=iBarShift(Symbol(),periodToUse,timeToUse,false);
}
shift=i+otherPeriodZeroBar;
So it is not perfect, of course you must use a special EA for the indicator to work in testing, and if testing is paused then any open online chart will be confused because of the global variable. But this is the best I have figured out so far.
Any other ideas would be great.
Thanks,
Read our articles. You can access to other symbols/periods data from EA under testing
I know this is the same situation you described in "Sasha: Prob with IsTesting() and IsVisualMode()" . But I need help working around this problem:
Problem: Under tester, TimeCurrent() returns tester time in EA but returns server time in indicator. I have an indicator that looks at data in other timeframes. Under tester it always sees most recent candle in other timeframes instead of the candle that matches the current candle in the tester. I cannot use TimeCurrent() and iBarShift() to get the correct candle because TimeCurrent() is not right in an indicator under tester.
I really need to be able to use the indicator in the tester. Do you have a solution? Please help, any ideas are great.
Thank you,
Christian