Pause system X time after Y losses
Forums › ProRealTime English forum › ProOrder support › Pause system X time after Y losses
- This topic has 5 replies, 2 voices, and was last updated 2 years ago by
robertogozzi.
Viewing 6 posts - 1 through 6 (of 6 total)
-
-
11/09/2022 at 12:50 PM #20385311/09/2022 at 1:03 PM #20385611/09/2022 at 4:50 PM #203866
This one did not work:
1234567891011121314151617181920212223242526272829303132333435positionperf2 = positionperf(1)graph positionperfgraph positionperf(1) coloured (255,0,0)if positionperf2<positionperf2[1] thenif (positionperf2 > 0) thenlossrunno = 0buysignal = barindexwinrunno = (winrunno + 1)endifif (positionperf2 < 0) thenwinrunno = 0lossrunno = (lossrunno + 1)endifendifif lossrunno=1 thendistancebuysignal=(Barindex-buysignal)endifif lossrunno=1 and (distancebuysignal > x) thenlossrunno=0endifif (lossrunno=0) thenIf MyConditionLong thenBuy PositionSize CONTRACTS AT MARKETSET STOP %LOSS sllENDIFIf MyConditionShort thensellshort PositionSize CONTRACTS AT MARKETSET STOP %LOSS slsENDIFendif11/09/2022 at 7:22 PM #203873There you go:
123456789101112131415161718192021222324252627ONCE MaxLosses = 2 //Y lossesONCE PauseBars = 30 //X bars to pauseONCE Losses = 0ONCE BarStart = 0MyLongConditions = close CROSSES OVER average[20,0](close) AND Not OnMarketMyShortConditions = close CROSSES UNDER average[20,0](close) AND Not OnMarketIF StrategyProfit > StrategyProfit[1] THENLosses = 0BarStart = 0ELSIF StrategyProfit < StrategyProfit[1] THENLosses = Losses + 1IF Losses = MaxLosses THENBarStart = BarIndexLosses = 0ENDIFENDIFIF (BarIndex - BarStart) >= PauseBars THENBarStart = 0ENDIFIF MyLongConditions AND BarStart = 0 THENBUY 1 CONTRACT AT MARKETENDIFIF MyShortConditions AND BarStart = 0 THENSELLSHORT 1 CONTRACT AT MARKETENDIFSET STOP pLOSS 100SET TARGET pPROFIT 3001 user thanked author for this post.
11/10/2022 at 7:22 AM #203896Thanks robberto. it seems to work on the trades of same direction but not the oposit direction:
See attached
123456789101112131415161718192021222324252627282930ONCE MaxLosses = 1 //Y lossesONCE PauseBars = x //X bars to pauseONCE Losses = 0ONCE BarStart = 0IF StrategyProfit > StrategyProfit[1] THENLosses = 0BarStart = 0ELSIF StrategyProfit < StrategyProfit[1] THENLosses = Losses + 1IF Losses = MaxLosses THENBarStart = BarIndexLosses = 0ENDIFENDIFIF (BarIndex - BarStart) >= PauseBars THENBarStart = 0ENDIFif BarStart =0 thenIf MyLongCond thenBuy PositionSize CONTRACTS AT MARKETSET STOP %LOSS sllENDIFIf MyShortCond thensellshort PositionSize CONTRACTS AT MARKETSET STOP %LOSS slsENDIFendifI even tried this:
12345678If MyLongCond and BarStart =0 thenBuy PositionSize CONTRACTS AT MARKETSET STOP %LOSS sllENDIFIf MyShortCond and BarStart =0 thensellshort PositionSize CONTRACTS AT MARKETSET STOP %LOSS slsENDIF11/12/2022 at 1:18 PM #204018This one works like a charm:
12345678910111213141516171819202122232425262728293031323334353637ONCE MaxLosses = 3 //Y lossesONCE PauseBars = 30 //X bars to pauseONCE Losses = 0ONCE BarStart = 0MyLongCond = close CROSSES OVER average[20,0](close) AND Not OnMarketMyShortCond = close CROSSES UNDER average[20,0](close) AND Not OnMarketIF StrategyProfit > StrategyProfit[1] THENLosses = 0BarStart = 0ELSIF StrategyProfit < StrategyProfit[1] THENLosses = Losses + 1IF Losses = MaxLosses THENBarStart = BarIndexLosses = 0ENDIFENDIFIF (BarIndex - BarStart) >= PauseBars THENBarStart = 0ENDIFif BarStart = 0 thenIf MyLongCond thenBuy 1 CONTRACTS AT MARKETSET STOP %LOSS 0.1ENDIFIf MyShortCond thensellshort 1 CONTRACTS AT MARKETSET STOP %LOSS 0.1ENDIFendifgraph Lossesgraph BarStartgraph StrategyProfit < StrategyProfit[1] coloured("Red")graph StrategyProfit > StrategyProfit[1] coloured("Green") -
AuthorPosts
Viewing 6 posts - 1 through 6 (of 6 total)
Find exclusive trading pro-tools on
Similar topics: