help code walmal scalp-method
Forums › ProRealTime English forum › ProOrder support › help code walmal scalp-method
- This topic has 8 replies, 3 voices, and was last updated 3 years ago by robertogozzi.
-
-
04/13/2021 at 10:28 AM #166932
There is a know forextrader called the rumpleone. He has been around for along time. On his youtube chanel he and a friend of his trades this strategy on mt4. They are both only trading using statistics and have been for last 20+ years. Would like to get some help coding it for PRT. In theory it seems supereffective. Want to see how it tests back in time over a big sample.
Attached a picture on the template they use in mt4. Red and Green lines are the breakout lines where stop-orders should be +-1 pip
Rules:
- SL 10 pips
- Only trade in direction of hourly candle
- Only trade from 8.00 to 16.00 GMT, this is when ex GBPUSD range always is bigger then 10, therefor in theory price has to break out between 00, 10, 20, 30, 40, 50, 60, 70, 80, 90 lines
- Every new hour, take a trade when price breaks 00, 10, 20, 30, 40, 50, 60, 70, 80, 90 line (ex. 1.37400) example in the picture, price opened between 1.37500 and 1.37600. Set a sellstop at 1.37500 -1 pip and a buystop at 1.37600 +1 pip
- When price moved 1 pips in my favor. Move SL to -7.
- When price moved 5 pips move SL to BE+1
- No fixed TP, trailstop keep locking in for every 5 pip gain. So at 10 pips profit, move SL to +5. at 15 move to 10 etc.
if trailstop/BE function is not possible. Just trailstop every 5 pip.
04/13/2021 at 10:30 AM #16693304/13/2021 at 7:15 PM #166979There you go:
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758// Rumpleone//DEFPARAM CumulateOrders = FALSEcTime = Time >= 100000 AND Time <= 180000cDay = OpenDayOfWeek >= 1 AND OpenDayOfWeek <= 5SL = 10 * PipSizeOffset = 1 * PipSizeLossPips = 7 * PipSizeTSstep = 5Hundred = 1 * PipSize * 10FirstPip = 1 * PipSizeIF Not OnMarket THENNewSL = 0ENDIFBullish = close > openBearish = close < openPlevel = round((close * 1000) - 0.5) / 1000IF close <> Plevel THENIF Bullish AND Not OnMarket THENBUY 1 CONTRACT AT Plevel + Hundred + Offset STOPELSIF Bearish AND Not OnMarket THENSELLSHORT 1 CONTRACT AT Plevel - Offset STOPENDIFSET STOP LOSS SLSET TARGET PROFIT SL * 3ENDIFPips = (TradePrice * PositionPerf) / PipSizeIF Pips >= TSstep THENIF LongOnMarket THENIF (NewSL < TradePrice) OR (NewSL = 0) THENNewSL = TradePrice + FirstPipELSENewSL = max(NewSL,NewSL + TSstep * PipSize)ENDIFELSIF ShortOnMarket THENIF (NewSL > TradePrice) OR (NewSL = 0) THENNewSL = TradePrice - FirstPipELSENewSL = min(NewSL,NewSL - TSstep * PipSize)ENDIFENDIFELSIF (Pips >= (FirstPip / PipSize)) AND (NewSL = 0) THEN //1 pip gainIF LongOnMarket THENNewSL = TradePrice - LossPipsELSENewSL = TradePrice + LossPipsENDIFENDIFIF NewSL > 0 THENSELL AT NewSL STOPEXITSHORT AT NewSL STOPENDIF////graph Pips//graphonprice Plevel coloured(0,0,255,255) AS "Plevel"//graphonprice Plevel + Hundred + Offset coloured(0,255,0,255) AS "Long"//graphonprice Plevel - Offset coloured(255,0,0,255) AS "Short"//graphonprice NewSL coloured(0,0,0,255) AS "SL"I think this code will exit quite soon when running, because most of times the entry price is too close to the current price so it is likely not to meet the broker’s minimum distance requirements for pending orders.
04/13/2021 at 8:20 PM #16699004/13/2021 at 11:58 PM #167007My fault, I forgot to add cTime and cDay to the conditions to enter a trade.
Replace line 18 with this one:
1IF close <> Plevel AND cTime AND cDay THENMoreover, I added line 25 for a TP to better test the code. You did not want it, so you can comment it out.
04/14/2021 at 8:27 AM #16701504/14/2021 at 9:53 AM #167026I forgot to answer your question about the max. number of trades per hour.
I modified the code using MTF support so that I can use the 1-hour TF to accomplish that limitation.
Of course you cannot use TF’s higher than 1 hour and the 1-hour TF must be multiple of the one you are using on your chart (you cannot use a 7-minute TF because 1 hour, or 60 minutes, is not a multiple of 7).
Set MaxTrades to any integer number.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677// Rumpleone//DEFPARAM CumulateOrders = FALSETimeFrame(1h,UpdateOnClose)ThisHour1 = OpenTime//TimeFrame(default)ONCE Tally = 0// determine whether a trade has been closed in the last candlez1 = OnMarket[1] AND Not OnMarketz2 = LongOnMarket AND ShortOnMarket[1]z3 = ShortOnMarket AND LongOnMarket[1]z4 = (Not OnMarket[1] AND Not OnMarket) AND (StrategyProfit <> StrategyProfit[1])Traded = z1 OR z2 OR z3 OR z4 //OR 1Tally = Tally + Traded// clear the counter each hourThisHour2 = ThisHour1IF (ThisHour2 <> ThisHour2[1]) THENTally = 0ENDIF//cTime = Time >= 100000 AND Time <= 180000cDay = OpenDayOfWeek >= 1 AND OpenDayOfWeek <= 5SL = 10 * PipSizeOffset = 1 * PipSizeLossPips = 7 * PipSizeTSstep = 5Hundred = 1 * PipSize * 10FirstPip = 1 * PipSizeMaxTrades = 1IF Not OnMarket THENNewSL = 0ENDIFBullish = close > openBearish = close < openPlevel = round((close * 1000) - 0.5) / 1000IF close <> Plevel AND cTime AND cDay AND (Tally < MaxTrades) THENIF Bullish AND Not OnMarket THENBUY 1 CONTRACT AT Plevel + Hundred + Offset STOPELSIF Bearish AND Not OnMarket THENSELLSHORT 1 CONTRACT AT Plevel - Offset STOPENDIFSET STOP LOSS SLSET TARGET PROFIT SL * 3ENDIFPips = (TradePrice * PositionPerf) / PipSizeIF Pips >= TSstep THENIF LongOnMarket THENIF (NewSL < TradePrice) OR (NewSL = 0) THENNewSL = TradePrice + FirstPipELSENewSL = max(NewSL,NewSL + TSstep * PipSize)ENDIFELSIF ShortOnMarket THENIF (NewSL > TradePrice) OR (NewSL = 0) THENNewSL = TradePrice - FirstPipELSENewSL = min(NewSL,NewSL - TSstep * PipSize)ENDIFENDIFELSIF (Pips >= (FirstPip / PipSize)) AND (NewSL = 0) THEN //1 pip gainIF LongOnMarket THENNewSL = TradePrice - LossPipsELSENewSL = TradePrice + LossPipsENDIFENDIFIF NewSL > 0 THENSELL AT NewSL STOPEXITSHORT AT NewSL STOPENDIF////graph Pips//graphonprice Plevel coloured(0,0,255,255) AS "Plevel"//graphonprice Plevel + Hundred + Offset coloured(0,255,0,255) AS "Long"//graphonprice Plevel - Offset coloured(255,0,0,255) AS "Short"//graphonprice NewSL coloured(0,0,0,255) AS "SL"2 users thanked author for this post.
04/14/2021 at 5:51 PM #167081Made a backtest on GBPEUR and it looked amazing as in Holy Smokes-amazing… until I saw I forgot to put in the spread 😉
Still very good job though, Robert!
04/14/2021 at 7:32 PM #167095That’s backtest.
As I said, when you let it run on your account (demo or real makes no difference), the pending orders will, most of the time, be rejected being too close to the current price (and the strategy is most likely to be shut down).
Whenever you deal with small SL’s and TP’s using pending orders… bad things may happen!
This LONG exit will work, even though the current price is quite at the same leve lthan the current price:
1234MyProfitPips = PositionPrice * PositionPerf / PipSizeIF MyProfitPips >= 0 THEN //exit at breakeven immediately at marketSELL AT MARKETENDIFthis is likely not to work (unless a spike earned you a bunch of more than 2 pips):
1234MyProfitPips = PositionPrice * PositionPerf / PipSizeIF MyProfitPips >= 2 THENSELL AT PositionPrice STOP //exit at breakeven using a pending orderENDIF -
AuthorPosts