MTF buy previous weeks high
Forums › ProRealTime English forum › ProOrder support › MTF buy previous weeks high
- This topic has 4 replies, 2 voices, and was last updated 6 years ago by
sjtp47.
-
-
02/07/2019 at 11:02 PM #90793
I’m trying to use MTF to buy a breakout of the previous weeks high. The variable for last weeks high (hh) is correct as I have used the graph command to check it. If I set the default timeframe to 15 minutes the majority of trades are opened on a Friday @ 21:30, if I set the default timeframe to 1 hour it opens the majority to trades on a Sunday night @ 23:00. These entries are not when the previous weeks high was broken (breakout), can anyone help ? Code is below
1234567891011121314151617181920DEFPARAM CumulateOrders = Falsetimeframe(weekly)hh = high[1]timeframe(default)if close > hh thenbuy at marketendifIF DayOfWeek = 5 AND time = 210000 THENSELL AT MARKETEXITSHORT AT MARKETENDIFgraph hh coloured (255,0,0) AS "High"02/08/2019 at 12:04 AM #90800Try replacing line 3 with:
1timeframe(weekly, updateonclose)Moreover, are you using end-of-day data?
02/08/2019 at 9:12 AM #90822Hi Roberto,
Thanks for the reply, I’ve changed line 3 as per your recommendation which does change the results, however the entries still aren’t as expected. There’s still a lot of entries on a Sunday @ 23:00 which is when the market opens and not when the previous weeks high is broken.
Not sure what you mean by end-of -day data. I launch PRT through the IG platform.
As I mentioned the hh variable which is set in the weekly timeframe is picking up the correct price, i.e Wall St high last week (Jan 27th – Feb 1st) was 25191, yet a trade has been opened on Sunday 3rd Feb @ 23:00 @ 25004 which isn’t higher than 25191.
02/08/2019 at 11:45 AM #90837Your line 3 retrieves the previous week’s HIGH, so the trade entered un Sunday 3rd (my test entered it on Friday at 21:15 utc+1), but that week’s HIGH was 24863,7 (24864) and it correctly entered a new trade because the trade before had already been closed at 210000 on that Friday.
There are 2 points you have to correct/watch:
- since you close on Friday at 210000, if conditions in line 9 are still valid on next bar (which will be late Friday or the first bar of the next week) it will open a new trade. You may define a trading time to stop on Friday which does not just close open trades but also prevents further trading till Monday
- HIGH[1] retrieves data from the previous bar, while HIGH from the current week, so if UPDATEONCLOSE is used then that data will refer to the previous bar of the last weekly bar closed (currently, as of this writing, the bar closed on Jan. 25th) while using it as you did HH will retrieve data from just the bar previously closed being this week the current one (the week closed on Fab. 1st)
This is almost the same code as yours with a trading time end and without UPDATEONCLOSE (which is likely to be what you want):
123456789101112131415161718DEFPARAM CumulateOrders = Falsetimeframe(default)IF IntraDayBarIndex = 0 THEN //reenable trading on a new dayNoTrading = 0ENDIFEndTime = 210000NoTrading = (dayofweek = 5 AND time >= EndTime) //disable tradingtimeframe(weekly)//,updateonclose)hh = high[1]timeframe(default)if close > hh AND Not OnMarket AND NoTrading = 0 thenbuy at marketendifIF DayOfWeek = 5 AND time >= EndTime AND OnMarket THENSELL AT MARKETEXITSHORT AT MARKETENDIFgraph hh coloured (255,0,0) AS "High"don’t worry about TIMEFRAME(default) duplicated, you can enter it as many times you want. I added it for clarity, since when no TF is showed, the DEFAULT one is assumed.
Give me some feedback after testing it.
02/08/2019 at 10:11 PM #90911Hi Roberto,
I’ve tested your code above and it does exactly as I want, it’s now buying the breakout of the previous weeks high. I just need to work out the best timeframe to run the strategy on as the results differ depending on the time selected (5 min, 15 min, 30 min).
Thanks for your quick response and help, much appreciated.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on