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
Carry Time Window Into Next Day
- ABC
- Posts: 721
- Joined: 16 Dec 2006
- Location: www.abctradinggroup.com
- Has thanked: 125 times
- Been thanked: 409 times
- Contact:
Re: Carry Time Window Into Next Day
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
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
-
- Posts: 4
- Joined: 14 Mar 2023
Re: Carry Time Window Into Next Day
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;
- Kate MultiCharts
- Posts: 597
- Joined: 21 Oct 2020
- Has thanked: 9 times
- Been thanked: 148 times
Re: Carry Time Window Into Next Day
Hi AnotherTrader,
Here's a condition you could give a try to:
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
...