Time = Suspending trades based upon time of day...

 

I have written some basic code to incorporate into my EA, where by, if the server time is out of my trading time frame, no trades will searched for, let alone any positions be placed.

I have a few questions around this:

1) Can this be properly analysed via Strategy Tester, or is that impossible because it will not give you the time using "Hour"? (as this is a live server time, right?)

2) Let's say it was safe to trade due to time of day, my EA spits out a pending order, but then the pending order does not get triggered and the time has now moved into a "non trading time" - I want to cancel this pending order. Then all of a sudden we have moved back into a "Ok trading time"; is it possible to re-instate the exact same trade because I stored the trades pending order details? (I find this logic quite tough to get down in code?)

I do have some additional questions regarding the code - but probably better to start simple first :)

Thanks!

 
DomGilberto:

I have written some basic code to incorporate into my EA, where by, if the server time is out of my trading time frame, no trades will searched for, let alone any positions be placed.

I have a few questions around this:

1) Can this be properly analysed via Strategy Tester, or is that impossible because it will not give you the time using "Hour"? (as this is a live server time, right?)

Yes it can, use the time functions TimeXxxx() with TimeCurrent() "Note: At the testing, the last known server time is modelled."

DomGilberto:


2) Let's say it was safe to trade due to time of day, my EA spits out a pending order, but then the pending order does not get triggered and the time has now moved into a "non trading time" - I want to cancel this pending order. Then all of a sudden we have moved back into a "Ok trading time"; is it possible to re-instate the exact same trade because I stored the trades pending order details? (I find this logic quite tough to get down in code?)

You can get the pending order details from the History and use them to place the trade again . . .
 
DomGilberto:


1) Can this be properly analysed via Strategy Tester, or is that impossible because it will not give you the time using "Hour"? (as this is a live server time, right?)


Hour() can be used in the strategy tester with no problems
 
When I use ST, what is the time set to? The imported data I use, the MT4 platform's generic GMT time? How is the time worked out? (Is it a standard time that the daily bars close? If so, what time is the relative to my local time?)
 
DomGilberto:
When I use ST, what is the time set to? The imported data I use, the MT4 platform's generic GMT time? How is the time worked out? (Is it a standard time that the daily bars close? If so, what time is the relative to my local time?)

The time comes from the History data you are using . . . your local time is not relevant, if you are testing data from 2011 the time in 2013 is irrelevant. TimeLocal(), I think, is the same as TimeCurrent() in the ST. From the Documentation . . . "Note: At the testing, local time is modelled and is the same as the modelled last known server time."

RaptorUK:

Yes it can, use the time functions TimeXxxx() with TimeCurrent() "Note: At the testing, the last known server time is modelled."

 
Ok thanks! Ill have a play about! :)
Reason: