MADMEN trading strategy
02/11/2020 at 11:28 PM #119362
Here’s a nice simply strategy for the SP 1h, long only. WF is good, robustness reasonably good. 4 year backtest with MM is v nice.
Position size is €9, comparable margin to €1 on the DJ.
All suggestions welcome…123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111// Definition of code parametersDEFPARAM CumulateOrders = false // Cumulating positions deactivatedDEFPARAM preloadbars = 5000Capital = 10000MinSize = 9 //The minimum position size allowed for the instrument.MM1stType = 0 //Starting type of moneymanagement. Set to 0 for level stakes. Set to 1 for increasing stake size as profits increase and decreasing stake size as profits decrease. Set to 2 for increasing stake size as profits increase with stake size never being decreased.MM2ndType = 1 //Type of money management to switch to after TradesQtyForSwitch number of trades and ProfitNeededForSwitch profit has occurredTradesQtyForSwitch = 5 //Quantity of trades required before switching to second money management choice.ProfitNeededForSwitch = 2 //% profit needed before allowing a money management type change to MM2ndType.DrawdownNeededToSwitch = 8 //% draw down from max equity needed before money management type is changed back to MM1stType.DrawdownNeededToQuit = 25 //% draw down from max equity needed to stop strategyOnce MoneyManagement = MM1stTypeEquity = Capital + StrategyProfitmaxequity = max(equity,maxequity)if equity < maxequity * (1 - (DrawdownNeededToSwitch/100)) thenenoughtrades = 0tradecount = 0moneymanagement = MM1stTypeendifif equity < maxequity * (1 - (DrawdownNeededToQuit/100)) thenquitendifif not EnoughTrades thenif abs(countofposition) > abs(countofposition) thentradecount = tradecount + 1endifif tradecount > TradesQtyForSwitch and maxequity >= Capital * (1 + (ProfitNeededForSwitch/100)) thenEnoughTrades = 1MoneyManagement = MM2ndTypeendifendifIF MoneyManagement = 1 THENPositionSize = Max(MinSize, Equity * (MinSize/Capital))ENDIFIF MoneyManagement = 2 THENPositionSize = Max(LastSize, Equity * (MinSize/Capital))LastSize = PositionSizeENDIFIF MoneyManagement <> 1 and MoneyManagement <> 2 THENPositionSize = MinSizeENDIFPositionSize = Round(PositionSize*100)PositionSize = PositionSize/100// Size of POSITIONSPositionSizeLong = 1 * positionsizeTIMEFRAME(240minutes,updateonclose)indicator2 = Average(typicalPrice)indicator3 = Average(typicalPrice)c1 = (indicator2 > indicator3)TIMEFRAME(60 minutes,updateonclose)indicator1 = SuperTrend[6,15]c2 = (close > indicator1)// Conditions to enter long positionsIF c1 and c2 THENBUY PositionSizeLong CONTRACT AT MARKETENDIFSET STOP %LOSS 2.2SET TARGET %PROFIT 1.6//trailing stop functiontrailingstart = 30 //trailing will start @trailinstart points profittrailingstep = 1 //trailing step to move the "stoploss"//reset the stoploss valueIF NOT ONMARKET THENnewSL=0ENDIF//manage long positionsIF LONGONMARKET THEN//first move (breakeven)IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THENnewSL = tradeprice(1)+trailingstep*pipsizeENDIF//next movesIF newSL>0 AND close-newSL>=trailingstep*pipsize THENnewSL = newSL+trailingstep*pipsizeENDIFENDIF//manage short positionsIF SHORTONMARKET THEN//first move (breakeven)IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THENnewSL = tradeprice(1)-trailingstep*pipsizeENDIF//next movesIF newSL>0 AND newSL-close>=trailingstep*pipsize THENnewSL = newSL-trailingstep*pipsizeENDIFENDIF//stop order to exit the positionsIF newSL>0 THENSELL AT newSL STOPEXITSHORT AT newSL STOPENDIF
1 user thanked author for this post.02/11/2020 at 11:49 PM #119369
Did you do the robustness test and walk forward test with money management on? If so then turn it off and robustness test and walk forward test again. All testing should be done with level stakes – we should only turn money management on once we are happy that a strategy can make money on level stakes and it is robust and not curve fitted. Money management just clouds the picture.02/12/2020 at 6:37 AM #11937902/12/2020 at 8:02 AM #11938002/12/2020 at 9:28 AM #119388
That would be great. 100k is all I have to work with so even with 1h TF it’s not a lot to go on.
May well flop if looking further back, but the logic of it is so simple and (to me) intuitively sensible that hopefully it will just mean minor adjustments.02/12/2020 at 9:58 AM #119389
200K test with MM (had to adjust “max drawdown before quit” because it got stopped out (-25% drawdown) during 2008 crash
Do you want me to test with different MM? Send me the code/post code here, ill apply it to a 200K test02/12/2020 at 10:12 AM #11939102/12/2020 at 10:48 AM #119394
the graph of the underlying product and the system are remarkably similar without money management, did you use a position size of one as it looks like the system under performed the underlying asset in the image without MM
Ruark02/12/2020 at 11:16 AM #119395
For me there are two factors that a strategy must achieve:
- Make more money than buy and hold.
- Have less drawdown than buy and hold.
I don’t mind if it only does one of these and not both of them as they are a balance of risk and reward. To beat the market I think more risk is necessary which leads to more draw down which is fine if you can afford it. Making less money than buy and hold is fine too as long as the drawdown is minimal and so the risk of going bust minimal.
That 200k equity curve fails to hit the mark on either point for me.02/12/2020 at 11:57 AM #119401
Thanks @jebus89 for the 200k test. Did not handle the 2008 crash at all well, but this is mostly because the 25% panic button had been removed. If that were set to, say 15% or whatever you feel comfortable with in case of a crash, then most of it would have been avoided – it is a part of the code and it’s there for a reason! Even without that though, in real life, any sensible person would have gone to cash before it truly tanked, it’s not as if no one knew there was a crash going on. Better would be if the algo handled reversals more effectively than just buying on every bounce and getting stopped out for 2.2% over and over…
Good news is that once the recovery took hold it does make money from 2013, 3 years OOS from the data I had to work with. The 100k optimization beats a buy and hold over that period by about 25%.02/12/2020 at 12:30 PM #119406
That 200k equity curve fails to hit the mark on either point for me.
Are we looking at the same graph? In 2009 the buy and hold line is way below the system line, ie greater drawdown. From 2006 to date, the SP moved 2118 points; the system made 2096 points. Not much in it, esp considering we’re looking at 10 years OOS. And, to repeat what I’ve said above, the ‘% drawdown to quit’ had been disabled. In the real world it would have done exactly what it was there for.
Hmm, I wonder if we know who wrote that part of the Money Management? 😉02/12/2020 at 1:25 PM #119420
Yes – draw down for both B and H and the strategy is terrible and it does not make more money than B and H and was under performing the B and H for most of the back test so in my mind you might as well just buy an ETF of the index. Your capital will be far safer than spread betting with it.
Yes a fuse would help – but then you have to decide when it is a good idea to go back in and start trading again. So in reality B and H of an ETF would be far easier and result in a better return.
A strategy has got to good to go live not do almost the same thing as the index!
Yes – the creator of that money management snippet was clearly a very clever chap – possibly very good looking too I would guess.02/12/2020 at 3:13 PM #11942902/12/2020 at 4:28 PM #11944502/12/2020 at 4:46 PM #119448