Capturing the end of the candle

 

Hi,


Is it possible to perform some action exactly at the "end of the candle" tick? The problem is that my market is open from 8.30 till 16.09 exactly. I would like to decide at the latest time possible, should the order remain open or should I close it.


Now I'm checking it with TimeToStr() > "16:05" and it's working live, it's working on tester with timeframe M1 and with M5. The strategy is only performing actions at the beginning and at the end of a daily candle but I can't test it using D1 data because it misses the "end of the day" call.


Thanks !!!

 
is this too big of a challenge for you guys? come on ;)
 

No, not challenging at all. Quite boring, actually ;)


No, you cannot know "exactly" the end of candle tick. You have to use time, and give yourself some leeway as you appear to have already done.

 
blogzr3:

No, not challenging at all. Quite boring, actually ;)


No, you cannot know "exactly" the end of candle tick. You have to use time, and give yourself some leeway as you appear to have already done.

but as I wrote, it skips that condition when tested with a bigger TF, how to avoid it?

 
allerune:

but as I wrote, it skips that condition when tested with a bigger TF, how to avoid it?

Sorry, I have no idea what that means...

 

IMO it is impossible. You need to capture the last tick of that candle, but no-one knows which one will be the last.

Maybe you have to make a loop that examines the topical time (it would be independent from ticks).

 

Agreed, In my opinion, the way to capture what you need is either what you have or:

if ((TimeHour(TimeCurrent()) >= 16) && (TimeMinute(TimeCurrent()) >= 5)

And you'll need to use M1 granularity in the tester.


CB

 
And you'll need to use M1 granularity in the tester.


CB

Thanks CB but as I wrote above, I'm doing almost the same thing already.


Actually, the whole point of this topic was "how to be able to use D1 for the system that uses only daily open/high/low/close values?". The problem is that I have only 2008-2009 M1 data and 2005+ D1 data :-/


Ok. At least I know that it can't be easily done. Thanks guys !

 
I see. Is your market prone to gapping after close and before following open? CB
 
cloudbreaker:
I see. Is your market prone to gapping after close and before following open? CB

Unfortunately yes. I tried to use following day open price instead of last day close, but the difference in the results is too much.

Reason: