Force strategy to 1h (close as possible)

Posted By: danatrader

Force strategy to 1h (close as possible) - 12/16/20 08:51

Any ideas how to "force" a Barperiod = 60; strategy script as close as possible to the full hour Barzone = ET; ???
Assets are currencies only.
Posted By: AndrewAMD

Re: Force strategy to 1h (close as possible) - 12/16/20 13:03

Can you give an example of what you are trying to accomplish?
Posted By: danatrader

Re: Force strategy to 1h (close as possible) - 12/20/20 08:52

I see trades are opened not at the full hour, I want to make sure run function runs at the full hour to open the trades.
I just enter trades with run function, not with a TMF.

I assumed using some basic sttings like below would put the strategy to the full hour?

StartWeek = 10000;
EndWeek = 52200;
BarPeriod = 60;
BarZone = ET;
Posted By: AndrewAMD

Re: Force strategy to 1h (close as possible) - 12/21/20 21:12

But if your BarPeriod is 60, your default BarOffset is 0, which means your bars start at the beginning of any given hour. Unless you're changing BarOffset or using NumSampleCycles , I'm not sure how you are getting any other behavior.
Quote
BarOffset
Bar start/end time offset in minutes; 0 or a positive number smaller than BarPeriod. Bars and frames normally start at a date/time boundary; f.i. 60-minute bars start at every full hour, and daily bars normally start at UTC midnight. This can be changed with BarOffset. For daily bars, BarOffset can be used to shift the bar begin to a certain number of hours and minutes after midnight. This is normally used to trade at a certain time using daily bars. BarOffset is also automatically set up by NumSampleCycles by dividing a bar into equal time intervals and decreasing the offset by one interval per cycle; on the last cycle, BarOffset is 0. By default, BarOffset is 940 with daily bars, and 0 on any smaller bar period.

What time are your run() functions occurring? Maybe record the time in a log.
Posted By: Zheka

Re: Force strategy to 1h (close as possible) - 12/23/20 17:09

BTW:
- StartWeek/EndWeek are times in the BarZone time (if it is set). So, set it in ET: 71800 and 51701.
- EndWeek=52200 will EXCLUDE the 2200 bar from the week (ask jcl for the rationale)....You have to set it to >2200 , say, 52201 to get the commonly expected behavior.
© 2024 lite-C Forums