Define open of a candle - page 2

 
MPFX1 #:

Thx, Ive searched lots, but the lead on CopyOpen might help me big time..  Like I said, I self taught myself MT4 over 15 years ago, but I like MT5 platform far more.. So the leaning curve is starting all over again. MT5 is not as user friendly, but totally get its a far more powerful code to use..  Thanks again for your help

This line will not give you the 16h open, but the open of the hour 16 hours in the past from right now.

   int copied=CopyOpen(Symbol(),PERIOD_H1,15,1,ratesM);

16h candles have an issue. Because they do not fit into 24hrs, you have a continuous shift.

A forex week has 5*24 hours. That's 120 hours, you cannot divide 120/16 without remainder.

So first you must define where you start.
Let's say your first 16h candle begins at Monday 0.00h, then you need that opening time and price.

So first you need to calculate in which 16h candle of the week you are at the moment. Then you can get the appropriate open time and price.

I'll leave it up to you to figure out how to calculate that, but you need the hour distance from now to Monday 0.00h. for that you should use MqlDatetime with TimeToStruct.




 
Dominik Egert #:
This line will not give you the 16h open, but the open of the hour 16 hours in the past from right now.


16h candles have an issue. Because they do not fit into 24hrs, you have a continuous shift.

A forex week has 5*24 hours. That's 120 hours, you cannot divide 120/16 without remainder.

So first you must define where you start.
Let's say your first 16h candle begins at Monday 0.00h, then you need that opening time and price.

So first you need to calculate in which 16h candle of the week you are at the moment. Then you can get the appropriate open time and price.

I'll leave it up to you to figure out how to calculate that, but you need the hour distance from now to Monday 0.00h. for that you should use MqlDatetime with TimeToStruct.




Thank you so much for reply, I will do some more work on it from the info you supplied..