Range Breakout 5min
Forums › ProRealTime English forum › ProOrder support › Range Breakout 5min
- This topic has 5 replies, 2 voices, and was last updated 6 years ago by Nicolas.
-
-
02/07/2017 at 2:49 PM #24219
Hello All,
I am new here and that is my first post. I am going through a lot of blogs and strategies for the last week and I am very impressed by the effort you guys put in this platform. I see you are are very dedicated to find profitable strategies, effective indicators, screeners etc. and help one another.
Quickly to myself. I have a demo account at IG and do some manual and automatic trading there. I want to test one of my strategies with backtest but due to my limited coding abilities, I stuck at several points. I hope some of you guys can help me.Now to a part of my little strategy:
I want to trade the breakout of a range (usually on a 5min chart).
Rangetime: 7am-8am UK time (I have already problems to set the range constant, used a method by nicolas but unforunately works only as an indicator)
Breakout: at toplevel +10% of Range or lowlevel – 10% of range
Stoploss: Range/2
Take profit: RangeThe first advice I need is to set the Range constant in the period 7am to 8am without having to call my own little created indicator.
Second advice I need is, instead of taking profit, do a trailing stop. In case we are Long, set stop on previous low. In case we are short, set stop on previous high.Thank you in advance
Oliver
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051// Open Range Breakout DAX 5 MinONCE Start = 070000ONCE End = 080000// trading windowONCE BuyTime = 080000ONCE SellTime = 163000// money managementCapital = 10000Risk = 0.01equity = Capital + StrategyProfitmaxrisk = round(equity*Risk)Distance=0.1PositionSize = abs(round((maxrisk/RR)/PointValue)*pipsize)// calculate high/low and sl/tpif time >= start and time <=end or intradaybarindex =0 thenDAYSTARTINDEX = INTRADAYBARINDEXHIGHLEVEL = HIGHEST[INTRADAYBARINDEX - DAYSTARTINDEX+12](HIGH)LOWLEVEL = LOWEST [INTRADAYBARINDEX - DAYSTARTINDEX+12](LOW)Area=highlevel-lowlevelTP=area-area*distanceRR=area/2+area*distanceendif// position managementIF Time >= BuyTime AND Time <= SellTime THEN// LongIF Not longonmarket and not shortonmarket THENIF close < highlevel and close > lowlevel THENBUY PositionSize CONTRACT AT highlevel+area*distance stopENDIFENDIF// shortIF Not shortonmarket and not longonmarket THENIF close < highlevel and close > lowlevel THENSELLSHORT PositionSize CONTRACT AT lowlevel-area*distance StopENDIFENDIF// close positionsIF Time = SellTime THENIF LONGONMARKET THENSELL AT MARKETENDIFIF SHORTONMARKET AND Time = SellTime THENEXITSHORT AT MARKETENDIFendifset target profit TPset stop loss RRENDIFSorry for my code, I dont know why the syntax colors are not shown.
Just for your information: here the indicator code I used to set the range top and bottom level.123456789start=70000end=80000if time >= start and time <=end or intradaybarindex =0 thenDAYSTARTINDEX = INTRADAYBARINDEXHIGHLEVEL = HIGHEST[INTRADAYBARINDEX - DAYSTARTINDEX+12](HIGH)LOWLEVEL = LOWEST [INTRADAYBARINDEX - DAYSTARTINDEX+12](LOW)endifreturn highlevel, lowlevel02/07/2017 at 4:27 PM #24231What is the code of mine you tried to find the highest/lowest values of the range?
Did you try to GRAPH your variables to see how they were calculated and to find if they are correct?
There are a lot of nested conditions, I think it could be reduce to less lines, there may be some conditions not correctly tested somewhere.
02/07/2017 at 5:22 PM #24242Hi Nicolas,
Yes I want to find the highest/lowest in the range.
I think I managed what I planned to do. But I had to use the function highest high and lowest low for the last 12 bars in a 5min chart.
I think there is a smarter idea with intradaybarindex, where you can test the strategy throughout all timeframes without changing the code. That is why I tried to use your code unfortunately without success.I mangaged to reduce the code as well a bit.
Here my new code.
12345678910111213141516171819202122232425262728293031323334353637// Open Range Breakout DAX 5 MinONCE Start = 070000ONCE End = 080000// trading windowONCE BuyTime = 080000ONCE SellTime = 163000// money management//Capital = 10000//Risk = 0.01//equity = Capital + StrategyProfit//maxrisk = round(equity*Risk)//PositionSize = abs(round((maxrisk/RR)/PointValue)*pipsize)positionsize=1Distance=0.1// calculate high/low and sl/tpif time >= start and time <=end thentop= highest[12](high)bottom= lowest[12](low)Area=top-bottomTP=area-area*distanceRR=area/2+area*distanceendif// position managementIF Time >= BuyTime AND Time <= SellTime THEN// LongIF Not onmarket and close < top THENBUY PositionSize CONTRACT AT top+area*distance stopENDIF// shortIF Not onmarket and close >bottom THENSELLSHORT PositionSize CONTRACT AT bottom-area*distance StopENDIFset target profit TPset stop loss RRENDIF02/07/2017 at 5:58 PM #24252I modify the code with my own breakout box code, seems to work correctly I think. Please review it.
123456789101112131415161718192021222324252627282930313233343536373839// Open Range Breakout DAX 5 MinONCE Start = 070000ONCE End = 080000// trading windowONCE BuyTime = 080000ONCE SellTime = 163000positionsize=1Distance=0.1if intradaybarindex=0 thentop=0bottom=close*100endiftcondition = time>Start and time<=Endif tcondition thentop = max(top,high)bottom = min(bottom,low)Area=top-bottomTP=area-area*distanceRR=area/2+area*distanceendif// position managementIF Time >= BuyTime AND Time <= SellTime THEN// LongIF Not onmarket and close < top THENBUY PositionSize CONTRACT AT top+area*distance stopENDIF// shortIF Not onmarket and close >bottom THENSELLSHORT PositionSize CONTRACT AT bottom-area*distance StopENDIFset target profit TPset stop loss RRENDIF08/03/2018 at 3:28 PM #77478Hello guys,
I picked up my old topic as I had some time.
For the range breakout before the official trading hours I used now a trailing stop approach which got posted once by Nicolas.
Furthermore I skipped the hours around lunch and included a ADX indicator.It looks not as bad as I expected actually.
If you have time, let me know what you are thinking and whether you have some ideas of improvement.
Kind regards
08/07/2018 at 10:31 AM #77703 -
AuthorPosts
Find exclusive trading pro-tools on