Carry Time Window Into Next Day

Questions about MultiCharts and user contributed studies.
AnotherTrader
Posts: 4
Joined: 14 Mar 2023

Carry Time Window Into Next Day

Postby AnotherTrader » 04 May 2023

Hi all,

I'm trying to carry a time window into the next day and am having difficulty. The idea is that around 10pm (22:00) a 4 hour trade window is created which extends into the next day until 2am. I can't seem to figure out how to carry this time window to 2am the next day. Everything I have tried ends at midnight.

Any help would be appreciated.
Thanks

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: Carry Time Window Into Next Day

Postby ABC » 04 May 2023

Hi AnotherTrader,

can you post the code you tried? In general, you just need to wrap your head around the following concept (if we are using Time or Time_s):

1. If a time window starts and ends on the same time you check that the bar time is later than your start time, but not later than your end time

If the time window spans across midnight, this will obviously not work, because your end time will be before your start time. No time will be later than your start time, but not later than your end time.

2. Therefore, you need to adjust the check in 1. and test if the bar time is later than your start time OR not later than your end time.

Regards,

ABC

AnotherTrader
Posts: 4
Joined: 14 Mar 2023

Re: Carry Time Window Into Next Day

Postby AnotherTrader » 04 May 2023

Hi AnotherTrader,

can you post the code you tried? In general, you just need to wrap your head around the following concept (if we are using Time or Time_s):

1. If a time window starts and ends on the same time you check that the bar time is later than your start time, but not later than your end time

If the time window spans across midnight, this will obviously not work, because your end time will be before your start time. No time will be later than your start time, but not later than your end time.

2. Therefore, you need to adjust the check in 1. and test if the bar time is later than your start time OR not later than your end time.

Regards,

ABC

Hi,

Thank you for the reply. I'm still trying to wrap my head around this. What I had originally done was quite simple.

Code: Select all

if time = 2200 and TradeCondition = true then begin CanTrade = true; end; if time >= 2200 and time <= 200 and CanTrade = true then begin buy order; end;
Of course, that didn't work. I will need to research time_s now

User avatar
Kate MultiCharts
Posts: 575
Joined: 21 Oct 2020
Has thanked: 7 times
Been thanked: 144 times

Re: Carry Time Window Into Next Day

Postby Kate MultiCharts » 11 May 2023

Hi AnotherTrader,

Here's a condition you could give a try to:

Code: Select all

if (time>=2200) and (time<=2359) or (time>=0) and (time<=0200) then ...


Return to “MultiCharts”