Zone Recovery Trading Algo, How to Turn ALL Your Losing Trades into Winners
Forums › ProRealTime English forum › ProBuilder support › Zone Recovery Trading Algo, How to Turn ALL Your Losing Trades into Winners
- This topic has 7 replies, 3 voices, and was last updated 5 years ago by Nicolas.
-
-
09/20/2019 at 10:51 PM #108103
Is this feasable:
https://www.youtube.com/watch?v=DJz4E7VyeSw @41 mins and 30 seconds Joseph Nemeth introduces his “Zone Recovery” Trading Algorithm. The idea is you never take a loss because the algo Martingales it’s trade size to always stay ahead in the number of positive ticks for the trade – pls see the image below. Nemeth states he backtested the system using a 200 pip Zone and on 10 Lots and with 20 moves back and forth through the Recovery Zone the most it cost him was 3,600 pips drawdown (from 124 mins), tha tsound like a lot…
At around 125 mins he states that — in relation to how many times the algo has crossed up and down through the Zone Recovery area — “the market can stay there all it wants (ranging market) it won’t be there (long)… the most I’ve seen it was 6 (not sure if he means 3 longs and 3 shorts or 6 pairs of long/shorts through the Recovery Zone) in the last 36 months.”
Zone Recovery Hedging:
1st Long
Enter £1.00/tick long at 1.2950 with profit target of 1.3100 (150 ticks).
1st Short
If market falls to 1.2900 enter short at £1.40 tick to target 1.2750.Zone Recovery between:
1.2950 and 1.29002nd Long
Enter £1.00/tick long at 1.2950 with profit target of 1.3100 (150 ticks).
2nd Short
If market falls to 1.2900 enter short at £1.40/tick to target 1.2750.3rd Long
If market fails to hit 1.2750 enter £1.90/tick long at 1.2950 with profit target of 1.3100 (150 ticks).
3rd Short
If market fails to hit 1.3100 and falls to 1.2900 enter short at £2.50/tick to target 1.2750.I was wondering what the code would look like for that and jotted out a outline here:
Everything written in parentheses () is were I came unstuck in proreal language coding or am unsure if the outline is stated in the correct terms.
What do you think? Too good to be true? Hit a long term ranging market and run out of margin!?
Cheers
BardZone Recovery123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263// Definition of code parametersDEFPARAM CumulateOrders = TRUE // Cumulating positions deactivated// Conditions to enter non holidays daysIF (Month = 5 AND Day = 1) OR (Month = 12 AND (Day = 24 OR Day = 25 OR Day = 26 OR Day = 30 OR Day = 31)) THENTradingDay = 0ELSETradingDay = 1ENDIF//——————————————————————————————————//// Conditions to enter FIRST LONG POSITIONIF TradingDay =1 THENBUY 1.00 PERPOINT AT MARKETENDIF//set profit target of FIRST LONG POSITION at +150 pointsSET TARGET PROFIT 150// Conditions to enter FIRST SHORT HEDGEIf OnMarket and Tradeprice - Close = -50 ticks (not sure this is right way to expressthis but entry needs to be after market crosses under 50 ticks from the first long entrypoint) then SELLSHORT 1.40 PERPOINT AT MARKETENDIF//set profit target of FIRST SHORT positions at 150 pointsSET TARGET PROFIT 150 (minus -150?)//——————————————————————————————————//// Conditions to enter SECOND LONG POSITIONIF TradingDay =1 and OnMarket (and Tradeprice crosses over first long entry price) THENBUY 1.00 PERPOINT AT MARKETENDIF//set profit target of FIRST LONG POSITION at +150 pointsSET TARGET PROFIT +150// Conditions to enter SECOND SHORT HEDGEIf OnMarket and Tradeprice - Close = -50 (see comment on first short entry) thenSELLSHORT 1.40 PERPOINT AT MARKETENDIF//set profit target of SECOND SHORT positions at 150 pointsSET TARGET PROFIT 150//——————————————————————————————————//// Conditions to enter THIRD LONG POSITIONIF TradingDay =1 and OnMarket (and Tradeprice crosses over first long entry price) THENBUY 1.90 PERPOINT AT MARKETENDIF//set profit target of THIRD LONG POSITION at +150 pointsSET TARGET PROFIT 150// Conditions to enter THIRD SHORT HEDGEIf Tradeprice - Close = -50 (see comment on first short entry) then SELLSHORT 2.50 PERPOINT AT MARKETENDIF//set profit target of THIRD SHORT positions at 150 pointsSET TARGET PROFIT 15009/21/2019 at 8:59 AM #10810709/21/2019 at 9:13 AM #108108Coded that many times before.
Not in ProRealCode I’m guessing unless you coded separate long and short strategies as it is not possible to be long and short at the same time in a strategy?
09/21/2019 at 11:40 AM #10811009/24/2019 at 8:50 PM #108389Hi @Nicolas,
If you had a wide Zone Recovery Area (200 or 300 ticks for example) then you could be tied up in position hedges for possibly weeks until a break out occurred. My intention though was to a use R Squared strength in an attempt to avoid those flat periods and take no more than 3 longs and 3 shorts as per the code above – as you say time is finite and tying up capital for weeks wasn’t my goal!
I understand that there would need to be two systems but am not sure how to code it. I have put together the basics below of what I thought it might look like (but it would need separating).
My question is how to code the two systems so that it knows how many trades are active at any one time and therefore it knows when to take the individual 3 long trades and 3 shorts. It will also need to know if a long trade or a short trade has been taken first because of the different position sizes needed depending on whether the first trade is long or short trade.I’m using a variation of count of positions, although I never got that idea executed with this code below, despite spending hours on it: https://www.prorealcode.com/topic/increase-number-of-position-based-on-30-tic-moves/
I’ve see lots of different examples on PRC and attempted to incorporate those code ideas into this code. The bulk of the idea was written by Maz here: https://www.prorealcode.com/topic/hedging-strategy/
I’m trying to figure out how the two systems would be coded: A long system with a first long trade size of 1 perpoint and last short trade of 2.5 perpoint and code to monitor the long entries and short entries and then another system that is the short system who’s first trade will be 1 perpoint short (instead of 1.4) and who’s last trade will be a long trade at 2.5 perpoint. I was curious to see if this could be an effective strategy?
Cheers
BardZone Recovery Hedging123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135// Definition of code parametersDEFPARAM CumulateOrders = TRUE // Cumulating positions deactivated// Conditions to enter on non holidays daysIF (Month = 5 AND Day = 1) OR (Month = 12 AND (Day = 24 OR Day = 25 OR Day = 26 OR Day = 30 OR Day = 31)) THENTradingDay = 0ELSETradingDay = 1ENDIFperiod=3stdev=STD[period](close)//Profit ObjectiveLongTradeTarget = open + 150ShortTradeTarget = open + 150// Position Sizing when Long is First TradeFirstLongPositionSize = 1.0SecondLongPositionSize = 1.0ThirdLongPositionSize = 1.9FirstShortPositionSize = 1.4SecondShortPositionSize = 1.4ThirdShortPositionSize = 2.5// Position Sizing when Short is First Trade for Second System//FirstShortPositionSize = 1.0//SecondShortPositionSize = 1.0//ThirdShortPositionSize = 1.9//FirstLongPositionSize = 1.4//SecondLongPositionSize = 1.4//ThirdLongPositionSize = 2.5// Zone Recovery Area DepthZRA = 50if (stdev[0]+stdev[1]+stdev[2]+stdev[3]+stdev[4]) < (stdev[1]+stdev[2]+stdev[3]+stdev[4]+stdev[5]) thenZRABUY=1ENDIF// Conditions to enter long and short positionsRSqr = R2[30](close)c1 = (RSqr >= 0.3)if (stdev[0]+stdev[1]+stdev[2]+stdev[3]+stdev[4]) > (stdev[1]+stdev[2]+stdev[3]+stdev[4]+stdev[5]) thenZRASELL=1ENDIFLong1 = TradingDay = 1 and not onMarketLong1 = Long1 and TradesPlaced = 0Long1 = Long1 and ZRABUY=1 and c1Short1 = TradingDay = 1 and not onMarketShort1 = Short1 and TradesPlaced = 0Short1 = Short1 and ZRASELL=1 and c1Long2 = longOnMarket and shortOnMarket and TradingDay = 1 and TradesPlaced = 2 // Not sure how to express the fact that a long and a short trade are active in the marketLong2 = Long2 and not Long1 and abs(countOfPosition) = SecondLongPositionSizeShort2 = shortOnMarket and longOnMarket and TradingDay = 1 and TradesPlaced = 3Short2 = Short2 and not Short1 and abs(countOfPosition) = SecondShortPositionSizeLong3 = longOnMarket and shortOnMarket and TradingDay = 1 and TradesPlaced = 4Long3 = Long3 and not Long1 and not Long2 and abs(countOfPosition) = ThirdLongPositionSizeShort3 = shortOnMarket and longOnMarket and TradingDay = 1 and TradesPlaced = 5Short3 = Short3 and not Short1 and not Short2 and abs(countOfPosition) = ThirdShortPositionSizeif Long1 thenOrderSize = FirstLongPositionSizeBuyOrderLevel = Open // Or is it Tradeprice(1)-ZRA? I wasn't sure how to express this level after the StDev and R Squared have triggered a trade.StopTarget = LongTradeTargetendifif Short1 thenOrderSize = FirstShortPositionSize // Currently 1.4 but the "FirstShortPositionSize" has to be 1 perpoint if it's the first trade.SellOrderLevel = Open-ZRAStopTarget = ShortTradeTargetendifif Long2 thenOrderSize = SecondLongPositionSizeStopTarget = LongTradeTargetBuyOrderLevel = Openendifif Short2 thenOrderSize = SecondShortPositionSizeStopTarget = ShortTradeTargetSellOrderLevel = Open-ZRAendifif Long3 thenOrderSize = ThirdLongPositionSizeStopTarget = LongTradeTargetBuyOrderLevel = Openendifif Short3 thenOrderSize = ThirdShortPositionSizeStopTarget = ShortTradeTargetSellOrderLevel = Open-ZRAendif// Order Placingif Long1 or Long2 or Long3 thenbuy orderSize perpoint at BuyOrderLevel stopendifif Short1 or Short2 or Short2 thensellShort orderSize perpoint at SellOrderLevel stopendifif Long1 or Short1 or Long2 or Short2 or Long3 or Short3 thenset Target pProfit StopTargetendif// Keep Track of Open Tradesif onMarket thenif not onMarket[1] thenTradesPlaced = 1elsif countOfPosition = FirstShortPositionSize thenTradesPlaced = 2elsif countOfPosition = SecondLongPositionSize thenTradesPlaced = 3elsif countOfPosition = SecondShortPositionSize thenTradesPlaced = 4elsif countOfPosition = ThirdLongPositionSize thenTradesPlaced = 5elsif countOfPosition = ThirdLongPositionSize thenTradesPlaced = 6endifendifWhen I tried a different entry using Heiken Ashi is red flagged the code: IF XClose >= XOpen THEN ZRABUY=1 endif and also IF XClose <= XOpen THEN ZRASELL=1 endif, although it’s no different code layout wise style to using stdev[0] > stdev[1] etc as an entry?
Heiken Ashi Entry123456789101112131415161718192021// Zone Recovery Area DepthZRA = 50IF XClose >= XOpen THEN ZRABUY=1IF PreviousStatus <> 1 THENPreviousStatus = 1ENDIFELSEIF PreviousStatus <> -1 THENPreviousStatus = -1ENDIFENDIFIF XClose >= XOpen THEN ZRABUY=1endifIF XClose <= XOpen THEN ZRASELL=1endif// Conditions to enter long and short positionsRSqr = R2[30](close)c1 = (RSqr >= 0.3)09/25/2019 at 8:11 AM #108406I don’t recommenced to use 2 strategies to simulate hedging as a desync might happen between the 2 systems and the result could be catastrophic. The main problem is that even if we simulate fake opposite order in both strategy, it doesn’t give you the information that the order was validated by the broker or not and effectively been put on market.
09/25/2019 at 9:42 AM #10841409/25/2019 at 11:41 AM #108420ProBacktest was not designed in the first place to do that. Hedging is not a “normal” or “logic” situation in trading/investment, not a natural way, that’s why I think it was not considered, back at the beginning of the 2000’s when ProBacktest was created.
1 user thanked author for this post.
-
AuthorPosts