The two-day problem

Created at 19 Oct 2024, 15:12
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
VIZAINT's avatar

VIZAINT

Joined 18.09.2024

The two-day problem
19 Oct 2024, 15:12


 

 

In the Forex market the trading time is from Sunday to Friday
I am trying to get that if Friday comes the rectangles do not stop at the last hour if they are not at the starting point in this case index + offset, but the length of the rectangle depends on the value that is calculated.
When drawing a rectangle I can use index or time, in case of time so that the rectangles appear at the end of index + offset I have to add 2880 minutes which is two days, but on weekdays it does not work for me.
If I set the timeframe more than 4 hours for Forex there is no problem as for Crypto, the problem is with the timeframe 1 hour and less.
There is a possibility that the starting point is index + offset and the end point is time, maybe put pixels or another value that is used in WPF.
I leave you some images if something is not clear do not hesitate to ask.

Crypto

Forex 1hours and less

Forex 4 hours and more

 

The code:

 bool isMore = TimeFrame > TimeFrame.Hour;
            int Mo;
            Mo = isMore ? 2880 : 0;
            var rec = Chart.DrawRectangle("rec" + ib,
            //ind + Offset,
            Bars.OpenTimes[ind].AddMinutes(newOffset + Mo),
            currPrice + topbx,
            //ind + Offset + 5,
            Bars.OpenTimes[ind].AddMinutes(newOffset + Mo + sum),
            currPrice + btmbx,
            Color.FromArgb(TranspBox, newColor));
            rec.IsFilled = true;


@VIZAINT