Discussing the strategy VECTORIAL DAX (M5)
03/03/2019 at 1:01 PM #9275203/04/2019 at 8:58 AM #92785
I am a bit disappointed with my last tests because I have only good results with dax index in 5TF, nothing good on nasdaq or cac and results are not strong on doji.
Angle input does not seem to be adaptable ….easly
Tof03/06/2019 at 10:15 AM #92938
Quick question as I’m pretty new to this:
It seems like the only way the current position is closed is either via trailing stop (position is already in profit) or stop loss. However, I do get also smaller losses in the backtest which I can’t really pin to any part of the code. I’ve tried the modified version including Pauls suggestions.03/06/2019 at 12:44 PM #92968
Hi Zebra. There is a other possibility for a position to be closed automatically. This is when the code detects a reverse position at the current position. Then the current position is closed and a other position is opened in the opposite direction. This can explain what you see in the backtest.
1 user thanked author for this post.03/06/2019 at 12:47 PM #9296903/06/2019 at 2:24 PM #9298503/11/2019 at 8:52 PM #9339403/11/2019 at 10:33 PM #93399
Hello, How could the strategy code be modified to have increasing lots taking into account reinvested profits? Thanks!
Type ‘Money management’ in the search box and plenty of coding ideas will be available or try some of the Lot Size code snippets that can be found here:03/11/2019 at 11:23 PM #9340303/11/2019 at 11:35 PM #9340403/14/2019 at 4:46 PM #9365703/20/2019 at 3:13 PM #9416603/20/2019 at 5:13 PM #94176
I just don’t know how to code it… Could someone could add this to the paul version? Thanks
Here you go. It has three forms of position sizing and also a risk based position size multiplier that means size is increased more rapidly as profits increase. You can select all this by changing settings in lines 10 to 14.
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.
RiskManagement = 0 = risk management off and 1 = risk management on. I do not recommend using this it can blow up your account very easily!
Capital = Starting capital
MinBetSize = The minimum bet size allowed for the instrument.
RiskLevel = A factor that changes how fast position size increases as profit increases. Only relevant if Risk Management is turned on.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153//ROBOT VECTORIAL DAX// M5// SPREAD 1.5// by BALMORA 74 - FEBRUARY 2019//Money Management added by VonasiDEFPARAM CumulateOrders = falseDEFPARAM Preloadbars = 50000MoneyManagement = 2RiskManagement = 0Capital = 10000MinBetSize = 1RiskLevel = 20Equity = Capital + StrategyProfitIF MoneyManagement = 1 THENPositionSize = Max(MinBetSize, Equity * (MinBetSize/Capital))ENDIFIF MoneyManagement = 2 THENPositionSize = Max(LastSize, Equity * (MinBetSize/Capital))LastSize = PositionSizeENDIFIF MoneyManagement <> 1 and MoneyManagement <> 2 THENPositionSize = MinBetSizeENDIFIF RiskManagement THENIF Equity > Capital THENRiskMultiple = ((Equity/Capital) / RiskLevel)PositionSize = PositionSize * (1 + RiskMultiple)ENDIFENDIFPositionSize = Round(PositionSize*100)PositionSize = PositionSize/100//VARIABLESCtimeA = time >= 080000 and time <= 220000CtimeB = time >= 080000 and time <= 220000ONCE BarLong = 950 //EXIT ZOMBIE TRADE LONGONCE BarShort = 650 //EXIT ZOMBIE TRADE SHORT// TAILLE DES POSITIONSPositionSizeLong = 1 * positionsizePositionSizeShort = 2 * positionsize//STRATEGIE//VECTEUR = CALCUL DE L'ANGLEONCE PeriodeA = 10ONCE nbChandelierA= 15MMA = Exponentialaverage[PeriodeA](close)ADJASUROPPO = (MMA-MMA[nbchandelierA]*pipsize) / nbChandelierAANGLE = (ATAN(ADJASUROPPO)) //FONCTION ARC TANGENTECondBuy1 = ANGLE >= 45CondSell1 = ANGLE <= - 37//VECTEUR = CALCUL DE LA PENTE ET SA MOYENNE MOBILEONCE PeriodeB = 20ONCE nbChandelierB= 35lag = 5MMB = Exponentialaverage[PeriodeB](close)pente = (MMB-MMB[nbchandelierB]*pipsize) / nbchandelierBtrigger = Exponentialaverage[PeriodeB+lag](pente)CondBuy2 = (pente > trigger) AND (pente < 0)CondSell2 = (pente CROSSES UNDER trigger) AND (pente > -1)//ENTREES EN POSITIONCONDBUY = CondBuy1 and CondBuy2 and CTimeACONDSELL = CondSell1 and CondSell2 and CtimeB//POSITION LONGUEIF CONDBUY THENbuy PositionSizeLong contract at marketSET TARGET %PROFIT 4.25ENDIF//POSITION COURTEIF CONDSELL THENSellshort PositionSizeShort contract at marketSET TARGET %PROFIT 1.25ENDIF//VARIABLES STOP SUIVEURONCE trailingStopType = 1 // Trailing Stop - 0 OFF, 1 ONONCE trailingstoplong = 7.5 // Trailing Stop Atr Relative DistanceONCE trailingstopshort = 4 // Trailing Stop Atr Relative DistanceONCE atrtrailingperiod = 25 // Atr parameter ValueONCE minstop = 0 // Minimum Trailing Stop Distance// TRAILINGSTOP//----------------------------------------------atrtrail = AverageTrueRange[atrtrailingperiod]((close/10)*pipsize)/1000trailingstartl = round(atrtrail*trailingstoplong)trailingstartS = round(atrtrail*trailingstopshort)if trailingStopType = 1 THENTGL =trailingstartlTGS=trailingstartsif not onmarket thenMAXPRICE = 0MINPRICE = closePREZZOUSCITA = 0ENDIFif longonmarket thenMAXPRICE = MAX(MAXPRICE,close)if MAXPRICE-tradeprice(1)>=TGL*pointsize thenif MAXPRICE-tradeprice(1)>=MINSTOP thenPREZZOUSCITA = MAXPRICE-TGL*pointsizeELSEPREZZOUSCITA = MAXPRICE - MINSTOP*pointsizeENDIFENDIFENDIFif shortonmarket thenMINPRICE = MIN(MINPRICE,close)if tradeprice(1)-MINPRICE>=TGS*pointsize thenif tradeprice(1)-MINPRICE>=MINSTOP thenPREZZOUSCITA = MINPRICE+TGS*pointsizeELSEPREZZOUSCITA = MINPRICE + MINSTOP*pointsizeENDIFENDIFENDIFif onmarket and PREZZOUSCITA>0 thenEXITSHORT AT PREZZOUSCITA STOPSELL AT PREZZOUSCITA STOPENDIFENDIF//EXIT ZOMBIE TRADEIF POSITIONPERF<0 THENIF shortOnMarket AND BARINDEX-TRADEINDEX(1)>= barshort THENEXITSHORT AT MARKETENDIFENDIFIF POSITIONPERF<0 THENIF LongOnMarket AND BARINDEX-TRADEINDEX(1)>= barlong THENSELL AT MARKETENDIFENDIF
1 user thanked author for this post.03/20/2019 at 8:22 PM #94190
I hadn’t looked at this strategy much until I added my money management code to it in the last post. Whilst doing this it became obvious that there is one massive curve fit that makes performance look better than it is – and that is doubling the position size for short trades compared to long trades. The last 100K bars show that on the DAX there has been a definite down trend so this doubling of position size fits these bars just right but imagine what could happen if the next 100K bars have a definite up trend. You would be losing twice as much as you are winning. I would personally remove this position size doubling from the code.
You must be logged in to access attached files.03/20/2019 at 8:25 PM #94193