Hi all,
I’m trying to program a strategy whereby if a condition for the previous week is true, then I want the system to buy at the market as soon as the current week crosses above the high of the previous week.
For instance:
Week #23 = Signal is true
System buys during week #24, as soon as prices trade above the high of week #23. See attached picture to describe what I mean.
Currently, the code is buying at market on Week #25. I suspect this is because it only confirms that the high of W#24 is higher than the high of W#23 once W#24 itself is finished, which is too late for what I want.
Any ideas?
Thank you.
Post your topic in the correct forum:
_ ProRealTime Platform Support: only platform related issues.
_ ProOrder: only strategy topics.
_ ProBuilder: only indicator topics.
_ ProScreener: only screener topics
_ General Discussion: any other topics.
_ Welcome New Members: for new forum members to introduce themselves.
I moved it from ProBuilder.
Thank you 🙂
If you are using a weekly TF, the strategy can only verify that week #24 has broken the prior high (week #23) when week #24 closes, so the trade will open at the beginning of week #25.
You need to use the MTF (Multiple Time Frame) support to use your strategy on a lower TF, such as daily or hourly. In such case the strategy will still be run at the closing of a bar, but closing daily or hourly (or even less), thus not having to wait a whole week.
If you search this forum for the word MTF you will be returned many links to code snippets and info on that topic.
You can use something like this. The second timeframe can be anything you want (as Roberto said), then just add the rest of your strategy.
timeframe(weekly, updateonclose)
HW = high
LW = Low
timeframe(15 minutes)
cb1 = close crosses over HW
cs1 = close crosses under LW