New Money Management, increases position size by 1 for each 1000 profit, margin is constant at ~13% of funds.
Insane result, not for the faint hearted…
Correction: due to tiered margins, to keep the requirement at a constant % of funds, position size would have to peak at 55. Slightly less insane and probably better that way.
New improved recipe, now with added vitamins.
Long and short in one code or separated. Robustness tests for v3.5L and 3.5S are roughly similar as v3.3 – the long is a bit worse, the short is a bit better. WF is fine but I’ve only got 100k to work with so it could still be the mother of all curve-fits.
Most grateful if someone could run it on 200k to see if it doesn’t completely crash and burn.
// Definition of code parameters
DEFPARAM CumulateOrders = false // Cumulating positions deactivated
DEFPARAM preloadbars = 5000
//Money Management
MM = 0
if MM = 0 then //MM = 0 for optimization
positionsize=1
ENDIF
if MM = 1 then
ONCE startpositionsize = .4
ONCE factor = 10 // factor of 15 means margin increases/decreases @ 6.6% of strategy profit; 10 = 10% 20 = 5% etc — optimize for best result, profit vs drawdown
ONCE margin = (close*.005) // margin value of 1 contract in instrument currency
ONCE maxpositionsize = 55 // DOW €1 IG first tier margin limit
ONCE minpositionsize = .2 // enter minimum position allowed
IF Not OnMarket THEN
positionsize = startpositionsize + Strategyprofit/(factor*margin)
ENDIF
IF Not OnMarket THEN
if startpositionsize + Strategyprofit/(factor*margin) < minpositionsize THEN
positionsize = minpositionsize// keeps positionsize from going below allowed minimum
ENDIF
IF startpositionsize + Strategyprofit/(factor*margin) > maxpositionsize then
positionsize = maxpositionsize// keeps positionsize from going above IG first tier margin limit
ENDIF
ENDIF
ENDIF
TIMEFRAME(2 hours,updateonclose)
Period= 490
inner = 2*weightedaverage[round( Period/2)](typicalprice)-weightedaverage[Period](typicalprice)
HULL = weightedaverage[round(sqrt(Period))](inner)
c1 = HULL > HULL[1]
c2 = HULL < HULL[1]
indicator1 = SuperTrend[5,22]
c3 = (close > indicator1)
c4 = (close < indicator1)
indicator4 = CALL "Moving Average Slope"[52,1](close)
c11 = (indicator4 > 0)
c12 = (indicator4 < 0)
//PRC_Stochastic RSI | indicator
lengthRSI = 12 //RSI period
lengthStoch = 9 //Stochastic period
smoothK = 11 //Smooth signal of stochastic RSI
smoothD = 4 //Smooth signal of smoothed stochastic RSI
myRSI = RSI[lengthRSI](close)
MinRSI = lowest[lengthStoch](myrsi)
MaxRSI = highest[lengthStoch](myrsi)
StochRSI = (myRSI-MinRSI) / (MaxRSI-MinRSI)
K = average[smoothK](stochrsi)*100
D = average[smoothD](K)
c13 = K>D
c14 = K<D
TIMEFRAME(15 minutes,updateonclose)
indicator2 = Average[5](typicalPrice)
indicator3 = Average[7](typicalPrice)
c7 = (indicator2 > indicator3)
c8 = (indicator2 < indicator3)
Period2= 19
inner2 = 2*weightedaverage[round( Period2/2)](typicalprice)-weightedaverage[Period2](typicalprice)
HULL2 = weightedaverage[round(sqrt(Period2))](inner2)
c9 = HULL2 > HULL2[1]
c10 = HULL2 < HULL2[1]
TIMEFRAME(5 minutes)
Period3= 15
inner3 = 2*weightedaverage[round( Period3/2)](typicalprice)-weightedaverage[Period3](typicalprice)
HULL3 = weightedaverage[round(sqrt(Period3))](inner3)
c5 = HULL3 > HULL3[1]and HULL3[1]<HULL3[2]
c6 = HULL3 < HULL3[1]and HULL3[1]>HULL3[2]
// Conditions to enter long positions
IF c1 AND C3 AND C5 and c7 and c9 and c11 and c13 THEN
BUY positionsize CONTRACT AT MARKET
ENDIF
// Conditions to enter short positions
IF c2 AND C4 AND C6 and c8 and c10 and c12 and c14 THEN
SELLSHORT positionsize CONTRACT AT MARKET
ENDIF
SET STOP %LOSS 2.3
SET TARGET %PROFIT 1.7
//================== maximise les gains ==========
if longonmarket and C6 and c8 and close>positionprice then
sell at market
endif
If shortonmarket and C5 and c7 and close<positionprice then
exitshort at market
endif
//==============limite les pertes
if longonmarket AND c2 and c6 and close<positionprice then
sell at market
endif
If shortonmarket and c1 and c5 and close>positionprice then
exitshort at market
endif
//trailing stop function
trailingstart = 35 //trailing will start @trailinstart points profit
trailingstep = 3 //trailing step to move the "stoploss"
//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
newSL = tradeprice(1)+trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
newSL = newSL+trailingstep*pipsize
ENDIF
ENDIF
//manage short positions
IF SHORTONMARKET THEN
//first move (breakeven)
IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
newSL = tradeprice(1)-trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
newSL = newSL-trailingstep*pipsize
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF
//************************************************************************
ZigoParticipant
Master
I’d tried it but give an error in indicator 4 .
Therefore I have change it:
indicator4 = LinearRegressionslope[52](close)
Because I have not the call Indicator “Moving Average Slope[52,1](close)
The test in attachement
Thanks for that @Zigo. The OOS is not disastrous but with a 94% win rate it should make more money. The curve doesn’t really get going until late 2018, ie my optimization.
Might be better with the moving average slope, which is here if you’re interested:
Moving Average Slope
In order for the screenshots: 3.3, 3.5L,3.5S on 200k.
I think only 3.3 is acceptable in terms of OOS (also if the initial flat curve is synonymous of an high optimization on 100k as you said); but i tried a robustness test on it (results in attached) and it is not bad! I think it’s worth trying on demo for the next month.
Thanks Francesco — agree that it’s ‘not too bad’ but obviously I was hoping for a better curve. The long and short results are apparently with MM, so a bit misleading, but at least it’s not a bust. At this stage a bit of forward testing is the only thing for it. Thanks again.
If you tell me what variables are worth to optimize i can try to do that for 200k and show you the results 🙂
Problem is, there’s so many of them! — probably too many. My guess is that the exit variables — stop loss, target profit, trailing stop and step, might have a bigger effect than the entry variables. I’d try those first.
Tried to work on exit variables but nothing changed. I think the “problem” is on the entry ones, but they are too many as you said 🙁
Not to worry, I’ll leave it on Demo for a while, see what happens…
Hi…
Bearish and bullish MOD work perfectly.
I have modified them a little, they are incredible.
I would to Contact you vía email… I am sure they are not the only jewelry You have.
Im gain 7600 pips in Dow Jones in one month.
And im gain 1600 pips in dax un one month with muy versión of Vectorial Dax.
Thanks!!!
Hi Fran55, good to know it’s working for you. Here’s a couple of others I finally got around to for the DAX and SP (US500) — collect the whole set.
I haven’t forward tested either of them yet so let us know how you get on. Money Management is optional.
Really good strategy, great work @nonetheless and thanks to everyone else who contributed with good codes for MM, TS etc!
@nonetheless : DAX-5m-Mother.of_.Dragons-v1.itf with 200K candles, spread 2.6, MM=0