different back-test-results of TimeCurrent() and iTime() in EA and indicator???

 

Hi,

someone else asked how does an indicator gets the correct time!

Just try to create an indicator to show only the time.

So this prints the correct open time of the bar during a back-test (e.g. 2011.01.03 07:00):

        if(ObjectFind("time") != 0) ObjectDelete("time");       
        ObjectCreate("time", OBJ_TEXT, 0, Time[0], 1.03*High[0]); 
        ObjectSetText("time", TimeToStr(Time[0]), 10, "Arial Black", White); 

But this prints the the last server-time of the real quotes (today Sa. evening: 2013.02.22 22:59):

        if(ObjectFind("time") != 0) ObjectDelete("time");       
        ObjectCreate("time", OBJ_TEXT, 0, Time[0], 1.03*High[0]); 
        ObjectSetText("time", TimeToStr(TimeCurrent()), 10, "Arial Black", White);

Even this:

        ObjectSetText("time", TimeToStr(iTime(Symbol(),PERIOD_M1,0)), 10, "Arial Black", White);

shows the real-quote-server-time and not the back-test-time :((

Within an EA on the other hand this:

Comment(TimeToString(TimeCurrent()));

show the correct back-test-time: 2011.01.01 07:34

Any idea how to get the correct back-test-time 'into' an indicator?

Thanks in advance,
Gooly

 

No idea how to pass correct time to the indicator.

IMHO I think it never worked. I never found it mentioned in MQL documentation.

Similarly Bid differs from Close[0], test orders are missing, while candle arrays are as you expect. 

 

Wow.


What do you mean: "Bid differs from Close[0]" - which one is correct or better?

And what do you mean test orders are missing? Can you give an example?

Thanks in advance,
Gooly

 
gooly:

Wow.


What do you mean: "Bid differs from Close[0]" - which one is correct or better?

And what do you mean test orders are missing? Can you give an example?

Thanks in advance,
Gooly

The Strategy tester is designed to test strategies, i.e. EAs not Indicators,  some things don't work correctly for Indicators in the Strategy tester,  see here:  https://www.mql5.com/en/forum/143310/page2#753302
 

https://docs.mql4.com/runtime/start

Custom indicators work in the main interface thread. If a custom indicator has been called with the iCustom() function, this indicator works in the thread of the program that has called it.

Any idea how to get the correct back-test-time 'into' an indicator? Try having the EA write TimeCurrent() to GlobalVariableSet() and indicator read the time from that. You can also use File. Also, lets not forget iCustom().

 

Indicator's don't need correct time. They should only be look in O/H/L/C/T [0]

In EAs, Bid == Close[0] always. In indicators, in the tester, Bid and timeCurrent is not modeled correctly.

 

Thanks for your answers!


But how do you call TimeCurrent() or iTime() or even MarketInfo() by iCutsom()?

Whatever I tried:

      iCustom(Symbol(),Period(),   "TimeCurrent",                                         0,0);
      iCustom(Symbol(),Period(),   "MarketInfo",Symbol(), MODE_TIME,     0,0);
      iCustom(Symbol(),Period(),   "iTime",Symbol(),PERIOD_M1,0,             0,0);
     ...

I only get 1970.01.01 00:00 while the directs calls give the expected - even not desired - values?
(Rem.: double d =MarketInfo(Symbol(),MODE_TIME);string s=TimeToStr(d); works, it shows online-server-time)

Gooly

 
gooly:

Thanks for your answers!

But how do you call TimeCurrent() or iTime() or even MarketInfo() by iCutsom()?

You don't,  iCustom() is to access data in an Indicator's buffers,  iTime(), MarketInfo() etc are functions.
 
RaptorUK:
You don't,  iCustom() is to access data in an Indicator's buffers,  iTime(), MarketInfo() etc are functions.

ok, but how has paulepanke  ( https://www.mql5.com/en/forum/143310/page2#753302 ) got his values via iCustom as he said?

Gooly

 
gooly:
ok, but how has paulepanke  ( https://www.mql5.com/en/forum/143310/page2#753302 ) got his values via iCustom as he said?

Gooly


You will have to ask him,  but I assume he coded an Indicator which printed,  for example, MarketInfor(Symbol(), MODE_TIME) and others,   and then called this Indicator from an EA running in the Strategy Tester using iCustom(),  how else would he do it ?
 
RaptorUK:

You will have to ask him,  but I assume he coded an Indicator which printed,  for example, MarketInfor(Symbol(), MODE_TIME) and others,   and then called this Indicator from an EA running in the Strategy Tester using iCustom(),  how else would he do it ?

ok, that might be, thanks again.


May the pips be with you :)
Gooly

Reason: