Simple Lunchtime Breakout Strategy
Forums › ProRealTime English forum › ProOrder support › Simple Lunchtime Breakout Strategy
- This topic has 7 replies, 2 voices, and was last updated 1 year ago by robertogozzi.
-
-
02/07/2023 at 10:18 AM #209284
morning chaps,
I am attempting to put together a very simple breakout strategy of a range formed over a certain period of time. I have pieced together something that is fairly amateur and I am not capable of really adding the ‘complexity’ (it’s very simple) I need. For some reason, although I have only stipulated that it not trades on a Sunday (something I will apply to more days when it actually works), it doesn’t seem to place trades every day.
Is there anyone that could cast an eye and help with the below?
The time of the range is 11:00am – 12:00pm
The range is from high to the low of the last hour from 12:00pm and the trade is made on the breakout
On a long, the range low is the stop loss and vice versa for a short
Target is 1.5 x the range
Once it hits 1:1 RRR the stoploss moves to breakeven
This is a very simple but fairly robust strategy if anyone could support it, I think it would take you about two minutes to solve
Breakout code Lunchtime1Breakout Strategy1234567891011121314151617181920212223242526272829303132333435363738394041defparam cumulateorders = FALSEDEFPARAM FLATAFTER = 153000daysForbiddenEntry = OpenDayOfWeek = 0noEntryBeforeTime = 115500timeEnterBefore = time >= noEntryBeforeTimenoEntryAfterTime = 120500timeEnterAfter = time < noEntryAfterTime// --- parametersSize = 1 //position sizeStopLossLong = lowest[LookbackPeriod](low)StopLossShort = highest[LookbackPeriod](high)LookbackPeriod = 12 //lookback period to find highest high and lowest low (price range)PointsDistance = 5 //distance in points to add/substract from highest high or lowest low to put the pending stop orders// ------------if not onmarket AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry thenBUY Size CONTRACTS AT highest[LookbackPeriod](high)+PointsDistance*pointsize STOPSTOPLOSSLONG = lowest[LookbackPeriod](low[1])TARGETLONG = highest[LookbackPeriod](high[1])+(1.5*(highest[LookbackPeriod](high[1])-lowest[LookbackPeriod](low[1])))endifif onmarket AND LONGONMARKET thensell at STOPLOSSLONG stopsell at TARGETLONG limitendifif not onmarket AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry thenSELLSHORT Size CONTRACTS AT lowest[LookbackPeriod](low)-PointsDistance*pointsize STOPSTOPLOSSSHORT = highest[LookbackPeriod](high[1.5])TARGETSHORT = lowest[LookbackPeriod](low[1])-1*(highest[LookbackPeriod](high[1]-lowest[LookbackPeriod](low[1])))endifif onmarket AND SHORTONMARKET thenexitshort at STOPLOSSSHORT stopexitshort at TARGETSHORT limitendif02/07/2023 at 12:37 PM #209297That seems fine, but to make the SL and TP active from the entry candle you should also copy lines 28 and 29 between lines 24 and 25 for LONG trades and copy lines 39-40 between lines 35 and 36 for SHORT trades.
It will trade every time conditions are met, not everyday.
Pending orders only last 1 bar, then they are cancelled automatically. So they are placed only within the specified time range.
1 user thanked author for this post.
02/07/2023 at 12:52 PM #209298Hi Roberto,
Thanks for coming back so quickly! and it’s good to hear I haven’t completely messed this up… I will amend the lines you have referenced.
Although there are conditions, they are only to trade within a certain time and not on a Sunday – shouldn’t it, therefore, be able to trade each day? I apologise if I am being short-sighted…
In addition, is it possible to outline how to move stop loss to breakeven on reaching a rrr of 1:1? Or perhaps there is a similar/previous post that I can reference so not to take too much time.
best, Tom
02/07/2023 at 1:02 PM #20929902/07/2023 at 1:49 PM #209301Hi, i have made the amendments but unfortunately, the stop loss and profit aren’t activating (at least how I would like them to) – for instance on a short trade that instantly whipsaws long, it doesn’t exit the trade for quite a while, which points to the stop loss not being in place at the high of the range of the last 12 candles. Is the algo looking back 12 periods on each new candle? if so, how do I fix the stoploss in place on the execution of the trade?
02/07/2023 at 2:25 PM #209303Please post the current code you are using.
02/07/2023 at 2:41 PM #209305Just to confirm this is to be traded on USDJPY 5min
Latest code1234567891011121314151617181920212223242526272829303132333435defparam cumulateorders = FALSEDEFPARAM FLATAFTER = 173000daysForbiddenEntry = OpenDayOfWeek = 0 OR OpenDayOfWeek = 5 OR OpenDayOfWeek = 6noEntryBeforeTime = 115500timeEnterBefore = time >= noEntryBeforeTimenoEntryAfterTime = 140000timeEnterAfter = time < noEntryAfterTime// --- parametersSize = 3 //position sizeStopLossLong = lowest[LookbackPeriod](low)StopLossShort = highest[LookbackPeriod](high)LookbackPeriod = 12 //lookback period to find highest high and lowest low (price range)PointsDistance = 0 //distance in points to add/substract from highest high or lowest low to put the pending stop orders// ------------if not onmarket AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry thenBUY Size CONTRACTS AT highest[LookbackPeriod](high)+PointsDistance*pointsize STOPSTOPLOSSLONG = lowest[LookbackPeriod](low)TARGETLONG = highest[LookbackPeriod](high[1])+(1.5*(highest[LookbackPeriod](high[1])-lowest[LookbackPeriod](low[1])))sell at STOPLOSSLONG stopsell at TARGETLONG limitendifif not onmarket AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry thenSELLSHORT Size CONTRACTS AT lowest[LookbackPeriod](low)-PointsDistance*pointsize STOPSTOPLOSSSHORT = highest[LookbackPeriod](high)TARGETSHORT = lowest[LookbackPeriod](low[1])-(1.5*(highest[LookbackPeriod](high[1]-lowest[LookbackPeriod](low[1]))))exitshort at STOPLOSSSHORT stopexitshort at TARGETSHORT limitendif02/08/2023 at 1:33 PM #209354To make it Stop & Reverse, just replace Not OnMarket in line 21 with Not LongOnMarket and Not OnMarket in line 29 with Not ShortOnMarket.
You shouldn’t have removed the original lines 27-30 and 38-41. Restore them into their place.
-
AuthorPosts
Find exclusive trading pro-tools on