When to stop a strategy and money management code snippet
Forums › ProRealTime English forum › ProOrder support › When to stop a strategy and money management code snippet
- This topic has 21 replies, 3 voices, and was last updated 3 years ago by robertogozzi.
Tagged: money management, quit
-
-
08/03/2021 at 9:53 PM #174637
Wow, the drawdown code is good, but it hasn’t had the desired effect.
Another question:
If in the last 10 operations the winrate is higher than 80%, operate with the usual amount of € pip.
If in the last 10 trades the winrate is less than 80%, trade with half the usual amount of € pip.
I need code … thanks!
08/05/2021 at 5:24 PM #174768There you go:
123456789101112131415161718192021222324252627282930313233343536DEFPARAM CumulateOrders = falseONCE AllTrades = 0ONCE WinningTrades = 0ONCE InitialLots = 2ONCE LotSize = InitialLotsONCE Trades = 10 //10 trades in a row over 80%MyGain = StrategyProfit// tally each tradet1 = OnMarket AND Not OnMarket[1] //it's a new tradet2 = Not OnMarket AND Not OnMarket[1] AND MyGain <> MyGain[1] //detect any 1-bar tradet3 = ShortOnMarket AND LongOnMarket[1] //it's a new trade (S & R)t4 = ShortOnMarket[1] AND LongOnMarket //it's a new trade (S & R)AllTrades = AllTrades + ((t1 OR t2 OR t3 OR t4) AND IsLastBarUpdate)// tally winning tradesIF MyGain > MyGain[1] THENWinningTrades = WinningTrades + 1ENDIF// calculate % of winning tradesIF AllTrades > Trades THENWinPerCent = WinningTrades * 100 / AllTradesIF summation[Trades](WinPerCent > 80) = Trades THENLotSize = InitialLots //restore initial lotsizeELSELotSize = InitialLots * 0.5 //halve lotsizeENDIFENDIFONCE Periods = 10MyLongConditions = close crosses over average[Periods] AND Not OnMarketMyShortConditions = close crosses under average[Periods] AND Not OnMarketIF MyLongConditions THENBUY LotSize CONTRACTS AT MarketELSIF MyShortConditions THENSELLSHORT LotSize CONTRACTS AT MarketENDIFset target pprofit 200set stop ploss 200008/05/2021 at 8:46 PM #17478208/06/2021 at 7:27 AM #174801Link to Roberto code above added as Log 297 here …
1 user thanked author for this post.
08/07/2021 at 10:40 AM #17486108/07/2021 at 11:16 AM #17486408/07/2021 at 11:41 AM #174865It’s impossible to compare STRATEGYPROFIT to ATR, they are two different scales.
STRATEGYPROFIT can range from -100K to +100K (or even more), while ATR is a price range (could be from 0 to a few hundreds).
Even if applied to STRATEGYPROFIT, it can be compared to itself, as it normally cannot be compared to CLOSE. -
AuthorPosts
Find exclusive trading pro-tools on