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.
-
-
08/31/2020 at 10:32 AM #143035
Dear Antonio
This is an english channel so please write again but in english
Cheers
1 user thanked author for this post.
08/31/2020 at 12:09 PM #143039DEFPARAM CumulateOrders = false DEFPARAM Preloadbars = 50000 //Money Management MM = 1 // = 0 for optimization if MM = 0 then positionsize=.5 ENDIF if MM = 1 then ONCE startpositionsize = .5 ONCE factor = 10 // factor of 10 means margin will increase/decrease @ 10% of strategy profit; factor 20 = 5% etc ONCE margin = (close*.005) // tier 1 margin value of 1 contract in instrument currency; change decimal according to available leverage ONCE margin2 = (close*.01)// tier 2 margin value of 1 contract in instrument currency; change decimal according to available leverage ONCE tier1 = 55 // IG first tier margin limit ONCE maxpositionsize = 550 // IG tier 2 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) > tier1 then positionsize = (((startpositionsize + (Strategyprofit/(factor*margin))-tier1)*(factor*margin))/(factor*margin2)) + tier1 //incorporating tier 2 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))-tier1)*(factor*margin))/(factor*margin2)) + tier1 > maxpositionsize then positionsize = maxpositionsize// keeps positionsize from going above IG tier 2 margin limit ENDIF ENDIF ENDIF ENDIF Ctime = time >= 010000 and time <= 230000 TIMEFRAME(2 hours) Period= 240 inner = 2*weightedaverage[round( Period/2)](typicalprice)-weightedaverage[Period](typicalprice) HULLa = weightedaverage[round(sqrt(Period))](inner) c9 = HULLa > HULLa[1] //c2 = HULLa < HULLa[1] TIMEFRAME(15 minutes) mx1 = average[16,1](close) c7 = mx1 > mx1[1] //c8 = mx1 < mx1[1] TIMEFRAME(10 minutes) mx2 = average[15,0](close) c5 = mx2 > mx2[1] //c6 = mx2 < mx2[1] //Stochastic RSI | indicator lengthRSI = 10//RSI period lengthStoch = 16//Stochastic period smoothK = 16 //Smooth signal of stochastic RSI smoothD = 3 //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) c3 = K>D //c4 = K indicator4) //c2 = (close < indicator4) //VECTEUR = CALCUL DE L’ANGLE ONCE PeriodeA = 5 ONCE nbChandelierA= 42 MMA = Exponentialaverage[PeriodeA](close) ADJASUROPPO = (MMA-MMA[nbchandelierA]*pipsize) / nbChandelierA ANGLE = (ATAN(ADJASUROPPO)) //FONCTION ARC TANGENTE CondBuy1 = ANGLE >= 31 //CondSell1 = ANGLE <= – 25 //VECTEUR = CALCUL DE LA PENTE ET SA MOYENNE MOBILE ONCE PeriodeB = 24 ONCE nbChandelierB= 50 lag = 4 MMB = Exponentialaverage[PeriodeB](close) pente = (MMB-MMB[nbchandelierB]*pipsize) / nbchandelierB trigger = Exponentialaverage[PeriodeB+lag](pente) CondBuy2 = (pente > trigger) AND (pente < 0) //CondSell2 = (pente CROSSES UNDER trigger) AND (pente > -1) //ENTREES EN POSITION CONDBUY = CondBuy1 and CondBuy2 and Ctime and c1 and c3 and c5 and c7 and c9 //CONDSELL = CondSell1 and CondSell2 and Ctime and c2 and c4 and c6 and c8 //POSITION LONGUE IF CONDBUY THEN buy positionsize contract at market SET STOP %LOSS 1.7 SET TARGET %PROFIT 2.1 ENDIF //POSITION COURTE //IF CONDSELL THEN //Sellshort positionsize contract at market //SET STOP %LOSS sls //SET TARGET %PROFIT tps //ENDIF //Break even once breakeven = 1//1 on – 0 off breakevenPercent = .22 PointsToKeep = 2 startBreakeven = tradeprice(1)*(breakevenpercent/100) //reset the breakevenLevel when no trade are on market if breakeven>0 then IF NOT ONMARKET THEN breakevenLevel=0 ENDIF // — BUY SIDE — //test if the price have moved favourably of “startBreakeven” points already IF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN //calculate the breakevenLevel breakevenLevel = tradeprice(1)+PointsToKeep*pipsize ENDIF //place the new stop orders on market at breakevenLevel IF breakevenLevel>0 THEN SELL AT breakevenLevel STOP ENDIF // — end of BUY SIDE — IF SHORTONMARKET AND tradeprice(1)-close>startBreakeven*pipsize THEN //calculate the breakevenLevel breakevenLevel = tradeprice(1)-PointsToKeep*pipsize ENDIF //place the new stop orders on market at breakevenLevel IF breakevenLevel>0 THEN EXITSHORT AT breakevenLevel STOP ENDIF endif //**************************************************************************************** // trailing atr stop II once trailingstoptype = 1 // trailing stop – 0 off, 1 on once tsincrements = 0 // set to 0 to ignore tsincrements once tsminatrdist = 2 once tsatrperiod = 14 // ts atr parameter once tsminstop = 12 // ts minimum stop distance once tssensitivity = 0 // [0]close;[1]high/low if trailingstoptype then if barindex=tradeindex then trailingstoplong = 9 // ts atr distance trailingstopshort = 9 // ts atr distance else if longonmarket then if tsnewsl>0 then if trailingstoplong>tsminatrdist then if tsnewsl>tsnewsl[1] then trailingstoplong=trailingstoplong else trailingstoplong=trailingstoplong-tsincrements endif else trailingstoplong=tsminatrdist endif endif endif if shortonmarket then if tsnewsl>0 then if trailingstopshort>tsminatrdist then if tsnewsl<tsnewsl[1] then=”” trailingstopshort=”trailingstopshort” else=”” endif=”” =”” tsatr=”averagetruerange[tsatrperiod]((close/10)*pipsize)/1000″ (forex)=”” tgl=”round(tsatr*trailingstoplong)” tgs=”round(tsatr*trailingstopshort)” if=”” not=”” onmarket=”” or=”” ((longonmarket=”” and=”” shortonmarket[1])=”” (longonmarket[1]=”” shortonmarket))=”” tsmaxprice=”0″ tsminprice=”close” tsnewsl=”0″ tssensitivity=”” tssensitivitylong=”high” tssensitivityshort=”low” longonmarket=”” tsmaxprice-tradeprice(1)=””>=tgl*pointsize then if tsmaxprice-tradeprice(1)>=tsminstop then tsnewsl=tsmaxprice-tgl*pointsize else tsnewsl=tsmaxprice-tsminstop*pointsize endif endif endif if shortonmarket then tsminprice=min(tsminprice,tssensitivityshort) if tradeprice(1)-tsminprice>=tgs*pointsize then if tradeprice(1)-tsminprice>=tsminstop then tsnewsl=tsminprice+tgs*pointsize else tsnewsl=tsminprice+tsminstop*pointsize endif endif endif if longonmarket then if tsnewsl>0 then sell at tsnewsl stop endif if tsnewsl>0 then if low crosses under tsnewsl then sell at market // when stop is rejected endif endif endif if shortonmarket then if tsnewsl>0 then exitshort at tsnewsl stop endif if tsnewsl>0 then if high crosses over tsnewsl then exitshort at market // when stop is rejected endif endif endif</tsnew
DEFPARAM CumulateOrders = false DEFPARAM Preloadbars = 50000 //Money Management MM = 1 // = 0 for optimization if MM = 0 then positionsize=.5 ENDIF if MM = 1 then ONCE startpositionsize = .5 ONCE factor = 10 // factor of 10 means margin will increase/decrease @ 10% of strategy profit; factor 20 = 5% etc ONCE margin = (close*.005) // tier 1 margin value of 1 contract in instrument currency; change decimal according to available leverage ONCE margin2 = (close*.01)// tier 2 margin value of 1 contract in instrument currency; change decimal according to available leverage ONCE tier1 = 55 // IG first tier margin limit ONCE maxpositionsize = 550 // IG tier 2 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) > tier1 then positionsize = (((startpositionsize + (Strategyprofit/(factor*margin))-tier1)*(factor*margin))/(factor*margin2)) + tier1 //incorporating tier 2 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))-tier1)*(factor*margin))/(factor*margin2)) + tier1 > maxpositionsize then positionsize = maxpositionsize// keeps positionsize from going above IG tier 2 margin limit ENDIF ENDIF ENDIF ENDIF Ctime = time >= 010000 and time <= 230000 TIMEFRAME(2 hours) Period= 240 inner = 2*weightedaverage[round( Period/2)](typicalprice)-weightedaverage[Period](typicalprice) HULLa = weightedaverage[round(sqrt(Period))](inner) c9 = HULLa > HULLa[1] //c2 = HULLa < HULLa[1] TIMEFRAME(15 minutes) mx1 = average[16,1](close) c7 = mx1 > mx1[1] //c8 = mx1 < mx1[1] TIMEFRAME(10 minutes) mx2 = average[15,0](close) c5 = mx2 > mx2[1] //c6 = mx2 < mx2[1] //Stochastic RSI | indicator lengthRSI = 10//RSI period lengthStoch = 16//Stochastic period smoothK = 16 //Smooth signal of stochastic RSI smoothD = 3 //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) c3 = K>D //c4 = K indicator4) //c2 = (close < indicator4) //VECTEUR = CALCUL DE L’ANGLE ONCE PeriodeA = 5 ONCE nbChandelierA= 42 MMA = Exponentialaverage[PeriodeA](close) ADJASUROPPO = (MMA-MMA[nbchandelierA]*pipsize) / nbChandelierA ANGLE = (ATAN(ADJASUROPPO)) //FONCTION ARC TANGENTE CondBuy1 = ANGLE >= 31 //CondSell1 = ANGLE <= – 25 //VECTEUR = CALCUL DE LA PENTE ET SA MOYENNE MOBILE ONCE PeriodeB = 24 ONCE nbChandelierB= 50 lag = 4 MMB = Exponentialaverage[PeriodeB](close) pente = (MMB-MMB[nbchandelierB]*pipsize) / nbchandelierB trigger = Exponentialaverage[PeriodeB+lag](pente) CondBuy2 = (pente > trigger) AND (pente < 0) //CondSell2 = (pente CROSSES UNDER trigger) AND (pente > -1) //ENTREES EN POSITION CONDBUY = CondBuy1 and CondBuy2 and Ctime and c1 and c3 and c5 and c7 and c9 //CONDSELL = CondSell1 and CondSell2 and Ctime and c2 and c4 and c6 and c8 //POSITION LONGUE IF CONDBUY THEN buy positionsize contract at market SET STOP %LOSS 1.7 SET TARGET %PROFIT 2.1 ENDIF //POSITION COURTE //IF CONDSELL THEN //Sellshort positionsize contract at market //SET STOP %LOSS sls //SET TARGET %PROFIT tps //ENDIF //Break even once breakeven = 1//1 on – 0 off breakevenPercent = .22 PointsToKeep = 2 startBreakeven = tradeprice(1)*(breakevenpercent/100) //reset the breakevenLevel when no trade are on market if breakeven>0 then IF NOT ONMARKET THEN breakevenLevel=0 ENDIF // — BUY SIDE — //test if the price have moved favourably of “startBreakeven” points already IF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN //calculate the breakevenLevel breakevenLevel = tradeprice(1)+PointsToKeep*pipsize ENDIF //place the new stop orders on market at breakevenLevel IF breakevenLevel>0 THEN SELL AT breakevenLevel STOP ENDIF // — end of BUY SIDE — IF SHORTONMARKET AND tradeprice(1)-close>startBreakeven*pipsize THEN //calculate the breakevenLevel breakevenLevel = tradeprice(1)-PointsToKeep*pipsize ENDIF //place the new stop orders on market at breakevenLevel IF breakevenLevel>0 THEN EXITSHORT AT breakevenLevel STOP ENDIF endif //**************************************************************************************** // trailing atr stop II once trailingstoptype = 1 // trailing stop – 0 off, 1 on once tsincrements = 0 // set to 0 to ignore tsincrements once tsminatrdist = 2 once tsatrperiod = 14 // ts atr parameter once tsminstop = 12 // ts minimum stop distance once tssensitivity = 0 // [0]close;[1]high/low if trailingstoptype then if barindex=tradeindex then trailingstoplong = 9 // ts atr distance trailingstopshort = 9 // ts atr distance else if longonmarket then if tsnewsl>0 then if trailingstoplong>tsminatrdist then if tsnewsl>tsnewsl[1] then trailingstoplong=trailingstoplong else trailingstoplong=trailingstoplong-tsincrements endif else trailingstoplong=tsminatrdist endif endif endif if shortonmarket then if tsnewsl>0 then if trailingstopshort>tsminatrdist then if tsnewsl<tsnewsl[1] then=”” trailingstopshort=”trailingstopshort” else=”” endif=”” =”” tsatr=”averagetruerange[tsatrperiod]((close/10)*pipsize)/1000″ (forex)=”” tgl=”round(tsatr*trailingstoplong)” tgs=”round(tsatr*trailingstopshort)” if=”” not=”” onmarket=”” or=”” ((longonmarket=”” and=”” shortonmarket[1])=”” (longonmarket[1]=”” shortonmarket))=”” tsmaxprice=”0″ tsminprice=”close” tsnewsl=”0″ tssensitivity=”” tssensitivitylong=”high” tssensitivityshort=”low” longonmarket=”” tsmaxprice-tradeprice(1)=””>=tgl*pointsize then if tsmaxprice-tradeprice(1)>=tsminstop then tsnewsl=tsmaxprice-tgl*pointsize else tsnewsl=tsmaxprice-tsminstop*pointsize endif endif endif if shortonmarket then tsminprice=min(tsminprice,tssensitivityshort) if tradeprice(1)-tsminprice>=tgs*pointsize then if tradeprice(1)-tsminprice>=tsminstop then tsnewsl=tsminprice+tgs*pointsize else tsnewsl=tsminprice+tsminstop*pointsize endif endif endif if longonmarket then if tsnewsl>0 then sell at tsnewsl stop endif if tsnewsl>0 then if low crosses under tsnewsl then sell at market // when stop is rejected endif endif endif if shortonmarket then if tsnewsl>0 then exitshort at tsnewsl stop endif if tsnewsl>0 then if high crosses over tsnewsl then exitshort at market // when stop is rejected endif endif endif</tsnewsl[1]>
Hi All,
I tested the 2 versions (Nonetheless and Grahal) with MM=0, spread2, tick by tick, 200K candles.
Cf attached results. We should perforam a WF analysis.
08/31/2020 at 12:35 PM #143041Please avoid to quote entire codes, you pollute the topic unnecessarily.
2 users thanked author for this post.
08/31/2020 at 12:40 PM #14304208/31/2020 at 1:33 PM #14304909/01/2020 at 3:26 PM #14313409/07/2020 at 3:56 PM #143556hello, 3min timeframe code can be improved, not by using pente > trigger, but using cross over, that together with pente setting > -xx and <xx as below and not using the breakeven.
12cb2 = (pente crosses over trigger) and (pente >-3 and pente < 4)cs2 = (pente crosses under trigger) and (pente >-4 and pente < 2)also for the atr trailing stop, I found a small bug which cause the trade to exit too early in a very few cases.
I replace the last part with this. (first row is the change).
12345678910111213141516171819202122if barindex-tradeindex>1 thenif longonmarket thenif tsnewsl>0 thensell at tsnewsl stopendifif tsnewsl>0 thenif low crosses under tsnewsl thensell at marketendifendifendifif shortonmarket thenif tsnewsl>0 thenexitshort at tsnewsl stopendifif tsnewsl>0 thenif high crosses over tsnewsl thenexitshort at marketendifendifendifendifhowever, using a % trailingstop works just as good, if not better.
1 user thanked author for this post.
09/08/2020 at 7:48 AM #143565Hello,
Vectorial DJI 3 minute
After some further testing I have found that by changing the below three variables as follows, you are able to increase the returns of the strategy by 17%
Variables:
tsatrperiod – change from 14 to 12
tsminstop – change from 12 to 10
tsincrements – change from 0.05 to 0.1
Testing Account Parameters:
Account – IG Spread Betting
Capital – 1,000
Position Size – 1
Original strategy on the left of the image, enhanced on the right.
Thank you again to Balmora74 for sharing, and to everyone else for the numerous updates along the way! Most enjoyable exercise.
09/08/2020 at 8:05 AM #14356709/08/2020 at 8:12 AM #143569Hi Paul
Would you be so kind as to share the section of code I should replace the mx/mx2 with the stochastic RSI please?
Thank you
09/08/2020 at 8:13 AM #143570sure
this is what I use
1234567891011121314151617181920//stochastic rsi | indicatorif stochasticrsi thenlengthrsi = 2 // 2 rsi periodlengthstoch = 6 // 6 stochastic periodsmoothk = 4 // 4 smooth signal of stochastic rsismoothd = 8 // 8 smooth signal of smoothed stochastic rsimyrsi = rsi[lengthrsi](totalprice)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<dcondbuy = condbuy and c13condsell= condsell and c14elsec13=c13c14=c14endifand the code below above the code above
123456789cb1 = angle >= 41cs1 = angle <= -34cb2 = (pente crosses over trigger) and (pente >-2 and pente < 4)cs2 = (pente crosses under trigger) and (pente >-4 and pente < 2)//entrees en positioncondbuy = cb1 and cb2 //and close<>high and high<>dhigh(0)condsell = cs1 and cs2 //and close<>low and low<>dlow(0)2 users thanked author for this post.
09/08/2020 at 8:21 AM #14357109/08/2020 at 8:25 AM #14357209/08/2020 at 8:29 AM #143573here are the changes above made in the original. On the other one I’am still working.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239// VECTORIAL MM - DJ 3mDEFPARAM CumulateOrders = falseDEFPARAM Preloadbars = 50000//Money ManagementMM = 0 // = 0 for optimizationif MM = 0 thenpositionsize=1ENDIFif MM = 1 thenONCE startpositionsize = .2ONCE 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 // IG first tier margin limitONCE maxpositionsize = 550 // IG tier 2 margin limitONCE minpositionsize = .2 // 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 limitENDIFENDIFENDIFENDIF//HORAIRES DE TRADINGCtime = time >= 050000 and time < 230000//STRATEGIE//VECTEUR = CALCUL DE L'ANGLEONCE PeriodeA = 2ONCE nbChandelierA= 30MMA = Exponentialaverage[PeriodeA](close)ADJASUROPPO = (MMA-MMA[nbchandelierA]*pipsize) / nbChandelierAANGLE = (ATAN(ADJASUROPPO)) //FONCTION ARC TANGENTECB1 = ANGLE >= 41CS1 = ANGLE <= - 34//VECTEUR = CALCUL DE LA PENTE ET SA MOYENNE MOBILEONCE PeriodeB = 29ONCE nbChandelierB= 41lag = 0MMB = Exponentialaverage[PeriodeB](close)pente = (MMB-MMB[nbchandelierB]*pipsize) / nbchandelierBtrigger = Exponentialaverage[PeriodeB+lag](pente)cb2 = (pente crosses over trigger) and (pente >-2 and pente < 4)cs2 = (pente crosses under trigger) and (pente >-4 and pente < 2)//ENTREES EN POSITIONCONDBUY = CB1 and CB2 and CTimeCONDSELL = CS1 and CS2 and Ctimeonce stochasticrsi = 1//stochastic rsi | indicatorif stochasticrsi thenlengthrsi = 2 // 2 rsi periodlengthstoch = 6 // 6 stochastic periodsmoothk = 4 // 4 smooth signal of stochastic rsismoothd = 8 // 8 smooth signal of smoothed stochastic rsimyrsi = rsi[lengthrsi](totalprice)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<dcondbuy = condbuy and c13condsell= condsell and c14elsec13=c13c14=c14endif//POSITION LONGUEIF CONDBUY THENbuy positionsize contract at marketSET STOP %LOSS 2ENDIF//POSITION COURTEIF CONDSELL THENSellshort positionsize contract at marketSET STOP %LOSS 2ENDIF//SET TARGET %PROFIT 2//Break evenbreakevenPercent = .13PointsToKeep = 1startBreakeven = tradeprice(1)*(breakevenpercent/100)once breakeven = 1//1 on - 0 off//reset the breakevenLevel when no trade are on marketif breakeven>0 thenIF NOT ONMARKET THENbreakevenLevel=0ENDIF// --- BUY SIDE ---//test if the price have moved favourably of "startBreakeven" points alreadyIF LONGONMARKET AND close-tradeprice(1)>=startBreakeven*pipsize THEN//calculate the breakevenLevelbreakevenLevel = tradeprice(1)+PointsToKeep*pipsizeENDIF//place the new stop orders on market at breakevenLevelIF breakevenLevel>0 THENSELL AT breakevenLevel STOPENDIF// --- end of BUY SIDE ---IF SHORTONMARKET AND tradeprice(1)-close>startBreakeven*pipsize THEN//calculate the breakevenLevelbreakevenLevel = tradeprice(1)-PointsToKeep*pipsizeENDIF//place the new stop orders on market at breakevenLevelIF breakevenLevel>0 THENEXITSHORT AT breakevenLevel STOPENDIFendif// trailing atr stoponce trailingstoptype = 1 // trailing stop - 0 off, 1 ononce tsincrements = .05 // set to 0 to ignore tsincrementsonce tsminatrdist = 3once tsatrperiod = 14 // ts atr parameteronce tsminstop = 12 // ts minimum stop distanceonce tssensitivity = 1 // [0]close;[1]high/lowif trailingstoptype thenif barindex=tradeindex thentrailingstoplong = 4 // ts atr distancetrailingstopshort = 4 // ts atr distanceelseif longonmarket thenif tsnewsl>0 thenif trailingstoplong>tsminatrdist thenif tsnewsl>tsnewsl[1] thentrailingstoplong=trailingstoplongelsetrailingstoplong=trailingstoplong-tsincrementsendifelsetrailingstoplong=tsminatrdistendifendifendifif shortonmarket thenif tsnewsl>0 thenif trailingstopshort>tsminatrdist thenif tsnewsl<tsnewsl[1] thentrailingstopshort=trailingstopshortelsetrailingstopshort=trailingstopshort-tsincrementsendifelsetrailingstopshort=tsminatrdistendifendifendifendiftsatr=averagetruerange[tsatrperiod]((close/10)*pipsize)/1000//tsatr=averagetruerange[tsatrperiod]((close/1)*pipsize) // (forex)tgl=round(tsatr*trailingstoplong)tgs=round(tsatr*trailingstopshort)if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) thentsmaxprice=0tsminprice=closetsnewsl=0endifif tssensitivity thentssensitivitylong=hightssensitivityshort=lowelsetssensitivitylong=closetssensitivityshort=closeendifif longonmarket thentsmaxprice=max(tsmaxprice,tssensitivitylong)if tsmaxprice-tradeprice(1)>=tgl*pointsize thenif tsmaxprice-tradeprice(1)>=tsminstop thentsnewsl=tsmaxprice-tgl*pointsizeelsetsnewsl=tsmaxprice-tsminstop*pointsizeendifendifendifif shortonmarket thentsminprice=min(tsminprice,tssensitivityshort)if tradeprice(1)-tsminprice>=tgs*pointsize thenif tradeprice(1)-tsminprice>=tsminstop thentsnewsl=tsminprice+tgs*pointsizeelsetsnewsl=tsminprice+tsminstop*pointsizeendifendifendifif longonmarket thenif tsnewsl>0 thensell at tsnewsl stopendifif tsnewsl>0 thenif low crosses under tsnewsl thensell at market // when stop is rejectedendifendifendifif shortonmarket thenif tsnewsl>0 thenexitshort at tsnewsl stopendifif tsnewsl>0 thenif high crosses over tsnewsl thenexitshort at market // when stop is rejectedendifendifendifendif09/08/2020 at 8:34 AM #143574Hi Paul,
Apologies, how do you define stochasticrsi please?
//stochastic rsi | indicator
if stochasticrsi then…….
Thank you
-
AuthorPosts
Find exclusive trading pro-tools on