Discussing the strategy VECTORIAL DAX (M5)
Forums › ProRealTime English forum › ProOrder support › Discussing the strategy VECTORIAL DAX (M5)
- This topic has 1,260 replies, 124 voices, and was last updated 1 month ago by Greger2346.
-
-
04/10/2019 at 10:53 AM #95931
Here is my version, with a different angle (WF).
Improvments and suggestions are welcome!
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166// ROBOT VECTORIAL DAX V.3// M5// SPREAD 1.5// by BALMORA 74 - FEBRUARY 2019 /// winnie version 10/04/12019DEFPARAM CumulateOrders = falseDEFPARAM Preloadbars = 50000//VARIABLESCtimeA = time >= 080000 and time <= 180000CtimeB = time >= 080000 and time <= 180000ONCE BarLong = 950 //EXIT ZOMBIE TRADE LONGONCE BarShort = 650 //EXIT ZOMBIE TRADE SHORTMoneyManagement = 2//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 = 1//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 = 10000MinBetSize = 1//MinBetSize = The minimum bet size allowed for the instrument.RiskLevel = 10//RiskLevel =A factor that changes how fast position size increases as profit increases. Only relevant if Risk Management is turned on.Equity = 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)// TAILLE DES POSITIONSPositionSizeLong = 1 * positionsizePositionSizeShort = 1 * 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 >= 20CondSell1 = ANGLE <= - 24//VECTEUR = CALCUL DE LA PENTE ET SA MOYENNE MOBILEONCE PeriodeB = 20ONCE nbChandelierB= 35lag = 1.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 STOP %LOSS 2ENDIF//POSITION COURTEIF CONDSELL THENSellshort PositionSizeShort contract at marketSET STOP %LOSS 2ENDIF//VARIABLES STOP SUIVEURONCE trailingStopType = 1 // Trailing Stop - 0 OFF, 1 ONONCE trailingstoplong = 4 // Trailing Stop Atr Relative DistanceONCE trailingstopshort = 4 // Trailing Stop Atr Relative DistanceONCE atrtrailingperiod = 14 // 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 MARKETENDIFENDIF04/10/2019 at 9:18 PM #96006Hi Winnie. Thanks for sharing your researchs
From my side I worked on an improved version based on Paul’s suggestions
I kept the values of original angles but I did a backtest using Walk Forward to optimize the variable “lag” and I’m OK like you for lag = 1.5.
Otherwise I added a 3rd condition for LONG and SHORT based on the orientation of a medium-term moving average :
CondBuy3 = average[100](close) > average[100](close)[1]
CondSell3 = average[20](close) < average[20](close)[1]
It gives less number of positions / less drawdown and a better profit factor.
Below are the results and the .ITF file.
It is quite possible that the algorithm is over fitted and over optimized. Reason why I put the code in account demo to observe its behavior over 6 months to 1 year…
I will it share it after….
VECTORIAL DAX v2 (WFE)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106// ROBOT VECTORIAL DAX v2// M5// SPREAD = 1// by BALMORA 74 - APRIL 2019DEFPARAM CumulateOrders = falseDEFPARAM Preloadbars = 50000//TRADING TIMECtimeA = time >= 080000 and time <= 180000CtimeB = time >= 080000 and time <= 180000//POSITION SIZEPositionSize = 1//STRATEGYONCE PeriodeA = 10ONCE nbChandelierA= 15ONCE PeriodeB = 20ONCE nbChandelierB= 35ONCE lag = 1.5MMA = Exponentialaverage[PeriodeA](close)ADJASUROPPO = (MMA-MMA[nbchandelierA]*pipsize) / nbChandelierAANGLE = (ATAN(ADJASUROPPO))CondBuy1 = ANGLE >= 35CondSell1 = ANGLE <= - 40MMB = Exponentialaverage[PeriodeB](close)pente = (MMB-MMB[nbchandelierB]*pipsize) / nbchandelierBtrigger = Exponentialaverage[PeriodeB+lag](pente)//BUY CONDITIONSCondBuy1 = ANGLE >= 35CondBuy2 = (pente > trigger) AND (pente < 0)CondBuy3 = average[100](close) > average[100](close)[1]CONDBUY = CondBuy1 and CondBuy2 and CondBuy3 and CTimeA//SHORT CONDITIONSCondSell1 = ANGLE <= - 40CondSell2 = (pente CROSSES UNDER trigger) AND (pente > -1)CondSell3 = average[20](close) < average[20](close)[1]CONDSELL = CondSell1 and CondSell2 and CondSell3 and CtimeB//POSITION LONGUEIF CONDBUY THENbuy PositionSize contract at marketSET STOP %LOSS 2ENDIF//POSITION COURTEIF CONDSELL THENSellshort PositionSize contract at marketSET STOP %LOSS 2ENDIF//TRAILING STOPONCE trailingStopType = 1 // Trailing Stop - 0 OFF, 1 ONONCE trailingstoplong = 4 // Trailing Stop Atr Relative DistanceONCE trailingstopshort = 4 // Trailing Stop Atr Relative DistanceONCE atrtrailingperiod = 14 // 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 STOPENDIFENDIF04/11/2019 at 10:03 AM #96042Is there redundant code in this strategy or can anybody offer a reason for the following please?
When I optimise the angles, it seems that almost any value gives the same figure for Gain … see attached.
Attached is related to the code version immediately above this post.
1 user thanked author for this post.
04/11/2019 at 10:06 AM #96044Hi Balmara74,
thanks for your improvment. I run it too. Another idea to improve tue strategy would be to include and test this part of code, very interesting…
https://www.prorealcode.com/blog/learning/how-to-improve-a-strategy-with-simulated-trades-1/
I tried to do it yesterday but i’m not a professionnal coder ;), so some difficulties and errors to do it. Could you try?
Did you test the strategy on 200K?
1 user thanked author for this post.
04/11/2019 at 12:27 PM #96069@Grahal
Maybe because you use a negative angle value for variable A28.
It could be interesting to use a value between 0 and +90 (knowing that the more one deviates from 45 and less positions we have).
EDIT POST – ERROR FOUND !!
I found a error on the code above !! Yes it’s redudant because LINES 27 and 28 are the same than LINES 34 and 40
So this is the good version of the code below (i have delete lines 27 and 28) :
VECTORIAL DAX v2 (WFE)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104// ROBOT VECTORIAL DAX v2// M5// SPREAD = 1// by BALMORA 74 - APRIL 2019DEFPARAM CumulateOrders = falseDEFPARAM Preloadbars = 50000//TRADING TIMECtimeA = time >= 080000 and time <= 180000CtimeB = time >= 080000 and time <= 180000//POSITION SIZEPositionSize = 1//STRATEGYONCE PeriodeA = 10ONCE nbChandelierA= 15ONCE PeriodeB = 20ONCE nbChandelierB= 35ONCE lag = 1.5MMA = Exponentialaverage[PeriodeA](close)ADJASUROPPO = (MMA-MMA[nbchandelierA]*pipsize) / nbChandelierAANGLE = (ATAN(ADJASUROPPO))MMB = Exponentialaverage[PeriodeB](close)pente = (MMB-MMB[nbchandelierB]*pipsize) / nbchandelierBtrigger = Exponentialaverage[PeriodeB+lag](pente)//BUY CONDITIONSCondBuy1 = ANGLE >= 35CondBuy2 = (pente > trigger) AND (pente < 0)CondBuy3 = average[100](close) > average[100](close)[1]CONDBUY = CondBuy1 and CondBuy2 and CondBuy3 and CTimeA//SHORT CONDITIONSCondSell1 = ANGLE <= - 40CondSell2 = (pente CROSSES UNDER trigger) AND (pente > -1)CondSell3 = average[20](close) < average[20](close)[1]CONDSELL = CondSell1 and CondSell2 and CondSell3 and CtimeB//POSITION LONGUEIF CONDBUY THENbuy PositionSize contract at marketSET STOP %LOSS 2ENDIF//POSITION COURTEIF CONDSELL THENSellshort PositionSize contract at marketSET STOP %LOSS 2ENDIF//TRAILING STOPONCE trailingStopType = 1 // Trailing Stop - 0 OFF, 1 ONONCE trailingstoplong = 4 // Trailing Stop Atr Relative DistanceONCE trailingstopshort = 4 // Trailing Stop Atr Relative DistanceONCE atrtrailingperiod = 14 // 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 STOPENDIFENDIF04/11/2019 at 1:02 PM #9607504/11/2019 at 1:14 PM #9608204/11/2019 at 1:34 PM #9608604/11/2019 at 1:41 PM #96089I currently have 5 algo live on dax. Unfortunately, they have gone bad at the same time and it is expensive. I am going to run them on demo now instead.
I would suggest always running any strategies in a lengthy live forward test in demo to confirm that they are not curve fitted. Yes it is a bit boring and not as exciting as going live but your patience will save you from losing an awful lot of money in the long run. I have strategies that have had on test for a year or more now. They are very profitable but the draw down was bigger than in the in sample test and would have sucked my real account dry if I had just gone live with them. Patience pays!
1 user thanked author for this post.
04/11/2019 at 1:57 PM #96091vonsai
True!!
I tested your code on nasdaq.
changed sl and tp and time.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104// ROBOT VECTORIAL DAX v2// M5// SPREAD = 1// by BALMORA 74 - APRIL 2019DEFPARAM CumulateOrders = falseDEFPARAM Preloadbars = 50000//TRADING TIMECtimeA = time >= 150000 and time <= 220000CtimeB = time >= 150000 and time <= 220000//POSITION SIZEPositionSize = 1//STRATEGYONCE PeriodeA = 10ONCE nbChandelierA= 15ONCE PeriodeB = 20ONCE nbChandelierB= 35ONCE lag = 1.5MMA = Exponentialaverage[PeriodeA](close)ADJASUROPPO = (MMA-MMA[nbchandelierA]*pipsize) / nbChandelierAANGLE = (ATAN(ADJASUROPPO))MMB = Exponentialaverage[PeriodeB](close)pente = (MMB-MMB[nbchandelierB]*pipsize) / nbchandelierBtrigger = Exponentialaverage[PeriodeB+lag](pente)//BUY CONDITIONSCondBuy1 = ANGLE >= 35CondBuy2 = (pente > trigger) AND (pente < 0)CondBuy3 = average[100](close) > average[100](close)[1]CONDBUY = CondBuy1 and CondBuy2 and CondBuy3 and CTimeA//SHORT CONDITIONSCondSell1 = ANGLE <= - 40CondSell2 = (pente CROSSES UNDER trigger) AND (pente > -1)CondSell3 = average[20](close) < average[20](close)[1]CONDSELL = CondSell1 and CondSell2 and CondSell3 and CtimeB//POSITION LONGUEIF CONDBUY THENbuy PositionSize contract at marketSET STOP %LOSS 2ENDIF//POSITION COURTEIF CONDSELL THENSellshort PositionSize contract at marketSET STOP %LOSS 2ENDIF//TRAILING STOPONCE trailingStopType = 1 // Trailing Stop - 0 OFF, 1 ONONCE trailingstoplong = 8 // Trailing Stop Atr Relative DistanceONCE trailingstopshort = 5 // Trailing Stop Atr Relative DistanceONCE atrtrailingperiod = 30 // 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 STOPENDIFENDIF04/11/2019 at 1:59 PM #96094I tested your code on nasdaq.
Not my code!
04/11/2019 at 2:22 PM #9610004/11/2019 at 2:24 PM #96101Balmora74, Vonasi and the others,
Could someone do this? Thanks 🙂
Another idea to improve tue strategy would be to include and test this part of code, very interesting…
https://www.prorealcode.com/blog/learning/how-to-improve-a-strategy-with-simulated-trades-1/
I tried to do it yesterday but i’m not a professionnal coder 😉
04/11/2019 at 2:34 PM #96103I’ve done a lot of coding with simulated trading ideas in the past but my conclusion after a lot of effort was that it wasn’t really worth the effort. Others may have a different point of view.
At the moment I am a bit busy with other projects and I don’t really enjoy converting other people’s codes (especially if a lot of the variable names are Italian!) so I’ll leave this one for someone else if that is OK.
1 user thanked author for this post.
04/11/2019 at 3:01 PM #96107Not my code!
Not even your name! 🙂
Couldn’t resist sorry … as you said Vonasi trading can be lonely and I do enjoy a laugh even if it me making myself laugh!
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on