Mother of Dragons trading strategy…
Forums › ProRealTime English forum › ProOrder support › Mother of Dragons trading strategy…
- This topic has 522 replies, 50 voices, and was last updated 3 years ago by LaurentBZH35.
-
-
11/17/2020 at 6:01 PM #15080811/17/2020 at 9:16 PM #15083411/17/2020 at 10:49 PM #150848
You’ve got the wrong itf, that’s a robustness test algo.
Click ‘View all attachments’ and look through the list for DJ 5m MoD v5.1
1 user thanked author for this post.
11/25/2020 at 11:00 AM #151508Hi All,
Firstly, can I send my thanks to all that have developed this Algo – the results look really exciting. @Nonetheless so far, it looks to be a fairly robust strategy! Cracking name too… 😀
So much so… I’d like to start trading with it – 0.2 contracts. I’ve made the amendments, and have gone live, it starts, but minutes later (potentially 5 mins) I get a notification that it’s no longer trading and has stopped.
What am I missing? The only areas I have amended are the leverage to .5, and the start position to .2
Any ideas?
Best,
Tom
11/25/2020 at 11:16 AM #151514I have amended are the leverage to .5
In the UK this should be .05, although I can’t see why that should stop it from running. Are you in demo or live?
1 user thanked author for this post.
11/25/2020 at 11:20 AM #151516Hi All,
Firstly, can I send my thanks to all that have developed this Algo – the results look really exciting. @Nonetheless so far, it looks to be a fairly robust strategy! Cracking name too… 😀
So much so… I’d like to start trading with it – 0.2 contracts. I’ve made the amendments, and have gone live, it starts, but minutes later (potentially 5 mins) I get a notification that it’s no longer trading and has stopped.
What am I missing? The only areas I have amended are the leverage to .5, and the start position to .2
Any ideas?
Best,
Tom
Hi Mitchy,
First you have to check if your broker accept a 0.2 size of position. Next you should check the necessary margin for trading this index.
1 user thanked author for this post.
11/25/2020 at 12:18 PM #15153011/25/2020 at 12:20 PM #15153211/25/2020 at 12:31 PM #151538Sorry chaps – still not running (even on one contract). I’ve added the code below. I must admit, it’s like asking my math teacher to check for mistakes :/
First one to point out the ridiculously embarrassing mistake wins… 😀
No need to check beyond line 26 – nothing else was tweaked.
Also got this error message…
The trading system was stopped because an indicator received a negative or zero parameter ex:(-10). You can modify your code to to prevent negative parameters then backtest the system to check the correction.
Best,
Tom
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396----------------------------------------------------------------------// Main code : DJ 5m MoD v5.1 xtest//-------------------------------------------------------------------------// Definition of code parametersDEFPARAM CumulateOrders = true // Cumulating positions deactivatedDEFPARAM preloadbars = 5000// cumulative positions are added when reenter is 2/3/4, the stoploss, profittarget & trailingstep and other exit criteria are all based on the first opened position mainly on the purpose of backtesting.// reenter [1] (default) no action on same signals until closed// reenter [2] action on same signals when in position// reenter [3] action on same signals when position is in loss// reenter [4] action on same signals when position is in profitreenter=1//Money Management DOWMM = 0 // = 0 for optimizationif MM = 0 thenpositionsize=1ENDIFif MM = 1 thenONCE startpositionsize = 1ONCE factor = 10 // factor of 10 means margin will increase/decrease @ 10% of strategy profit; factor 20 = 5% etcONCE margin = (close*.05) // tier 1 margin value of 1 contract in instrument currency; change decimal according to available leverageONCE margin2 = (close*.05)// tier 2 margin value of 1 contract in instrument currency; change decimal according to available leverageONCE tier1 = 55 // DOW €1 IG first tier margin limitONCE maxpositionsize = 550 // DOW €1 IG tier 2 margin limitONCE minpositionsize = 1 // enter minimum position allowedIF Not OnMarket THENpositionsize = startpositionsize + Strategyprofit/(factor*margin)ENDIFIF Not OnMarket THENIF startpositionsize + Strategyprofit/(factor*margin) > tier1 thenpositionsize = (((startpositionsize + (Strategyprofit/(factor*margin))-tier1)*(factor*margin))/(factor*margin2)) + tier1 //incorporating tier 2 marginENDIFIF Not OnMarket THENif startpositionsize + Strategyprofit/(factor*margin) < minpositionsize THENpositionsize = minpositionsize //keeps positionsize from going below allowed minimumENDIFIF (((startpositionsize + (Strategyprofit/(factor*margin))-tier1)*(factor*margin))/(factor*margin2)) + tier1 > maxpositionsize thenpositionsize = maxpositionsize// keeps positionsize from going above IG tier 2 margin limitENDIFENDIFENDIFENDIFTIMEFRAME(2 hours,updateonclose)Period= 490inner = 2*weightedaverage[round( Period/2)](typicalprice)-weightedaverage[Period](typicalprice)HULLa = weightedaverage[round(sqrt(Period))](inner)c1 = HULLa > HULLa[1]c2 = HULLa < HULLa[1]indicator1 = SuperTrend[8,4]c3 = (close > indicator1)c4 = (close < indicator1)ma = average[60,3](close)c11 = ma > ma[1]c12 = ma < ma[1]//Stochastic RSI | indicatorlengthRSI = 15 //RSI periodlengthStoch = 9 //Stochastic periodsmoothK = 10 //Smooth signal of stochastic RSIsmoothD = 5 //Smooth signal of smoothed stochastic RSImyRSI = RSI[lengthRSI](close)MinRSI = lowest[lengthStoch](myrsi)MaxRSI = highest[lengthStoch](myrsi)StochRSI = (myRSI-MinRSI) / (MaxRSI-MinRSI)K = average[smoothK](stochrsi)*100D = average[smoothD](K)c13 = K>Dc14 = K<DTIMEFRAME(30 minutes,updateonclose)indicator5 = Average[3](typicalPrice)indicator6 = Average[7](typicalPrice)c15 = (indicator5 > indicator6)c16 = (indicator5 < indicator6)TIMEFRAME(15 minutes,updateonclose)indicator2 = Average[4](typicalPrice)indicator3 = Average[8](typicalPrice)c7 = (indicator2 > indicator3)c8 = (indicator2 < indicator3)Periodc= 22innerc = 2*weightedaverage[round( Periodc/2)](typicalprice)-weightedaverage[Periodc](typicalprice)HULLc = weightedaverage[round(sqrt(Periodc))](innerc)c9 = HULLc > HULLc[1]c10 = HULLc < HULLc[1]TIMEFRAME(10 minutes)indicator4 = SuperTrend[2,6]indicator4a = SAR[0.02,0.03,0.2]c19 = (close > indicator4) or (close > indicator4a)c20 = (close < indicator4) or (close < indicator4a)TIMEFRAME(5 minutes)//Stochastic RSI | indicatorlengthRSIa = 3 //RSI periodlengthStocha = 6 //Stochastic periodsmoothKa = 9 //Smooth signal of stochastic RSIsmoothDa = 3 //Smooth signal of smoothed stochastic RSImyRSIa = RSI[lengthRSIa](close)MinRSIa = lowest[lengthStocha](myrsia)MaxRSIa = highest[lengthStocha](myrsia)StochRSIa = (myRSIa-MinRSIa) / (MaxRSIa-MinRSIa)Ka = average[smoothKa](stochrsia)*100Da = average[smoothDa](Ka)c23 = Ka>Dac24 = Ka<Dama3 = average[15,3](typicalPrice)c21 = ma3 > ma3[1]c22 = ma3 < ma3[1]Periodb= 15innerb = 2*weightedaverage[round( Periodb/2)](typicalprice)-weightedaverage[Periodb](typicalprice)HULLb = weightedaverage[round(sqrt(Periodb))](innerb)c5 = HULLb > HULLb[1]and HULLb[1]<HULLb[2]c6 = HULLb < HULLb[1]and HULLb[1]>HULLb[2]once sll = 1.5 // stoploss longonce sls = 2 // stoploss shortonce ptl = 2.6 // profit target longonce pts = 2 // profit target short// Conditions to enter long positionsIF (not onmarket or shortonmarket[1]) and dhigh(0)-high<250 and c1 AND C3 AND C5 and c7 and c9 and c11 and c13 and c15 and c19 and c21 and c23 THENBUY positionsize CONTRACT AT MARKETENDIFif longonmarket and dhigh(0)-high<250 and c1 AND C3 AND C5 and c7 and c9 and c11 and c13 and c15 and c19 and c21 and c23 THENif reenter=1 thenpositionperformance=0elsif reenter=2 thenpositionperformance=1elsif reenter=3 thenpositionperformance=positionperf(0)<0elsif reenter=4 thenpositionperformance=positionperf(0)>0endifif positionperformance thenbuy positionsize contract at marketendifendif// Conditions to enter short positionsIF (not onmarket or longonmarket[1]) and low-dlow(0)<600 and c2 AND C4 AND C6 and c8 and c10 and c12 and c14 and c16 and c20 and c22 and c24 THENSELLSHORT positionsize CONTRACT AT MARKETENDIFif shortonmarket and low-dlow(0)<600 and c2 AND C4 AND C6 and c8 and c10 and c12 and c14 and c16 and c20 and c22 and c24 THENif reenter=1 thenpositionperformance=0elsif reenter=2 thenpositionperformance=1elsif reenter=3 thenpositionperformance=positionperf(0)<0elsif reenter=4 thenpositionperformance=positionperf(0)>0endifif positionperformance thensellshort positionsize contract at marketendifendifcountpos=abs(countofposition)//================== exit in profitif longonmarket and C6 and c8 and close>tradeprice(countpos) thensell at marketendifIf shortonmarket and C5 and c7 and close<tradeprice(countpos) thenexitshort at marketendif//==============exit at lossif longonmarket AND c2 and c6 and close<tradeprice(countpos) thensell at marketendifIf shortonmarket and c1 and c5 and close>tradeprice(countpos) thenexitshort at marketendif//%trailing stop functiontrailingpercentlong = 0.26 // %trailingpercentshort = 0.31 // %stepPercentlong = 0.026stepPercentshort = 0.013sensitivity = (low+high+close)/3if onmarket thentrailingstartlong = tradeprice(countpos)*(trailingpercentlong/100) //trailing will start @trailingstart points profittrailingstartshort = tradeprice(countpos)*(trailingpercentshort/100) //trailing will start @trailingstart points profittrailingsteplong = tradeprice(countpos)*(stepPercentlong/100) //% step to move the stoplosstrailingstepshort = tradeprice(countpos)*(stepPercentshort/100) //% step to move the stoplossendif//reset the stoploss valueIF NOT ONMARKET THENnewSL=0ENDIF//manage long positionsIF LONGONMARKET THEN//first move (breakeven)IF newSL=0 AND sensitivity-tradeprice(countpos)>=trailingstartlong THENnewSL = tradeprice(countpos)+trailingsteplongENDIF//next movesIF newSL>0 AND sensitivity-newSL>trailingsteplong THENnewSL = newSL+trailingsteplongENDIFENDIF//manage short positionsIF SHORTONMARKET THEN//first move (breakeven)IF newSL=0 AND tradeprice(countpos)-sensitivity>=trailingstartshort THENnewSL = tradeprice(countpos)-trailingstepshortENDIF//next movesIF newSL>0 AND newSL-sensitivity>trailingstepshort THENnewSL = newSL-trailingstepshortENDIFENDIF//stop order to exit the positionsIF newSL>0 THENSELL AT newSL STOPEXITSHORT AT newSL STOPENDIF//****************************************************************************************IF longonmarket and barindex-tradeindex>1880 and close<tradeprice(countpos) thensell at marketendifIF shortonmarket and barindex-tradeindex>560 and close>tradeprice(countpos) thenexitshort at marketendif//=============================================if longonmarket and abs(open-close)<1 and high[1]>high and close>tradeprice(countpos) and high-close>11 thensell at marketendifif shortonmarket and abs(open-close)<1 and low[1]>low and close-low>11 and close<tradeprice(countpos) thenexitshort at marketendif//===================================myrsiM5=rsi[14](close)//if myrsiM5<30 and barindex-tradeindex>1 and longonmarket and close>tradeprice(countpos) thensell at marketendifif myrsiM5>70 and barindex-tradeindex>1 and shortonmarket and close<tradeprice(countpos) thenexitshort at marketendif// --------- US DAY LIGHT SAVINGS MONTHS ---------------- //mar = month = 3 // MONTH STARTnov = month = 11 // MONTH ENDIF (month > 3 AND month < 11) OR (mar AND day>14) OR (mar AND day-dayofweek>7) OR (nov AND day<=dayofweek AND day<7) THENUSDLS=010000ELSEUSDLS=0ENDIFonce shortStep = 0once longStep = 0once openStrongLong = 0once openStrongShort = 0if not onmarket or (time <= 143000 - USDLS and time >= 210000 - USDLS) thenshortStep = 0longStep = 0openStrongLong = 0openStrongShort = 0endif//detect strong direction for market openonce rangeOK = 45once tradeMin = 500IF (time >= 144000 - USDLS) AND (time <= 144000 + tradeMin - USDLS) THENopenStrongLong = close > open AND close - open > rangeOKopenStrongShort = close < open AND open - close > rangeOKENDIFonce bollperiod = 20once bollMAType = 1once s = 2once BollLevel = 90once BollSR = 50bollMA = average[bollperiod, bollMAType](close)STDDEV = STD[bollperiod]bollUP = bollMA + s * STDDEVbollDOWN = bollMA - s * STDDEVIF bollUP = bollDOWN THENbollPercent = 50ELSEbollPercent = 100 * (close - bollDOWN) / (bollUP - bollDOWN)ENDIF//Market spike upIF shortonmarket AND shortStep = 0 AND bollPercent > BollLevel THENshortStep = 1ENDIF//Market slowly come downIF shortonmarket AND shortStep = 1 AND bollPercent < 100 - BollLevel THENshortStep = 2ENDIF//Market still go back to bullish and supported after strong bull open, exitIF shortonmarket AND shortStep = 2 AND bollPercent > BollSR AND openStrongLong THENexitshort at marketENDIF//Market shoot downIF longonmarket AND longStep = 0 AND bollPercent < 100 - BollLevel THENlongStep = 1ENDIF//Market slowly go back upIF longonmarket AND longStep = 1 AND bollPercent > BollLevel THENlongStep = 2ENDIF//Market still go back to bearish and resisted after strong bear open, exitIF longonmarket AND longStep = 2 AND bollPercent < 100 - BollSR AND openStrongShort THENsell at marketENDIFonce trendPeriod = 70once trendPeriodResume = 30once trendGap = 3once trendResumeGap = 6if not onmarket thenfullySupported = 0fullyResisteded = 0endif//Market supported in the wrong directionIF shortonmarket AND fullySupported = 0 AND summation[trendPeriod](bollPercent > 50) >= trendPeriod - trendGap THENfullySupported = 1ENDIF//Market pull back but continue to be supportedIF shortonmarket AND fullySupported = 1 AND bollPercent[trendPeriodResume + 1] < 0 AND summation[trendPeriodResume](bollPercent > 50) >= trendPeriodResume - trendResumeGap THENexitshort at marketENDIF//Market resisted in wrong directionIF longonmarket AND fullyResisteded = 0 AND summation[trendPeriod](bollPercent < 50) >= trendPeriod - trendGap THENfullyResisteded = 1ENDIF//Market pull back but continue to be resistedIF longonmarket AND fullyResisteded = 1 AND bollPercent[trendPeriodResume + 1] > 100 AND summation[trendPeriodResume](bollPercent < 50) >= trendPeriodResume - trendResumeGap THENsell at marketENDIF//Started real wrong directiononce strongTrend = 70once strongPeriod = 6IF shortonmarket and openStrongLong and barindex - tradeindex < 12 and summation[strongPeriod](bollPercent > strongTrend) = strongPeriod thenexitshort at marketENDIFIF longonmarket and openStrongShort and barindex - tradeindex < 12 and summation[strongPeriod](bollPercent < 100 - strongTrend) = strongPeriod thensell at marketENDIFif not onmarket thenflag1=0flag2=0endifif longonmarket and (not onmarket[1] or shortonmarket)[1] thenflag1=1flag2=0endifif flag1=1 thensell at tradeprice(countpos)-(tradeprice(countpos)*(sll/100)) stopsell at tradeprice(countpos)+(tradeprice(countpos)*(ptl/100)) limitendifif shortonmarket and (not onmarket[1] or longonmarket[1]) thenflag1=0flag2=1endifif flag2=1 thenexitshort at tradeprice(abs(countpos))+(tradeprice(abs(countpos))*(sls)/100) stopexitshort at tradeprice(abs(countpos))-(tradeprice(abs(countpos))*(pts)/100) limitendif11/25/2020 at 1:38 PM #151553You’ve got the wrong itf, that’s a robustness test algo.
Click ‘View all attachments’ and look through the list for DJ 5m MoD v5.1
11/25/2020 at 1:42 PM #15155411/26/2020 at 5:54 PM #15179411/26/2020 at 6:49 PM #151801The backtest runs OK, so no reason it shouldn’t run in V11 demo.
11/26/2020 at 8:53 PM #151817@Nonetheless thanks I will check it.
11/26/2020 at 10:53 PM #151831 -
AuthorPosts
Find exclusive trading pro-tools on