Discussing the strategy VECTORIAL DAX (M5)

Viewing 15 posts - 826 through 840 (of 1,264 total)
  • Author
    Posts
  • #143035 quote
    Artemois
    Participant
    Average

    Dear Antonio

    This is an english channel so please write again but in english

    Cheers

    robertogozzi thanked this post
    #143039 quote
    Léo
    Participant
    Average

    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</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.

    NoneVectMoD-DJI-M5.png NoneVectMoD-DJI-M5.png
    #143041 quote
    Francesco
    Participant
    Veteran

    Please avoid to quote entire codes, you pollute the topic unnecessarily.

    robertogozzi and GraHal thanked this post
    #143042 quote
    Léo
    Participant
    Average

    Hi Francesco,

    Yes, sorry for this – first time I quote someone. I was expecting that only the text would be copied.

    I tried to update my post but could not. Sorry Again.

    Alex.

    #143049 quote
    danistuta
    Participant
    Senior

    Could you attach the two .itf files? 🙂

    Thank you very much.

    #143134 quote
    Léo
    Participant
    Average
    #143556 quote
    Paul
    Participant
    Master

    hello, 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.

    cb2 = (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).

    if barindex-tradeindex>1 then
    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
    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
    endif
    endif
    endif
    endif

    however, using a % trailingstop works just as good, if not better.

    GraHal thanked this post
    #143565 quote
    deletedaccount051022
    Participant
    New

    Hello,

    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.

    #143567 quote
    Paul
    Participant
    Master

    tips are always nice

    here’s an other one, don’t use the mx/mx2 averages but use stochastic rsi | indicator

    curve is the same with 1% or 2% stoploss

    thanked this post
    Screenshot-2020-09-08-at-09.04.02.jpg Screenshot-2020-09-08-at-09.04.02.jpg
    #143569 quote
    deletedaccount051022
    Participant
    New

    Hi 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

    #143570 quote
    Paul
    Participant
    Master

    sure

    this is what I use

    //stochastic rsi | indicator
    if stochasticrsi then
    lengthrsi   = 2 // 2 rsi period
    lengthstoch = 6 // 6 stochastic period
    smoothk     = 4 // 4 smooth signal of stochastic rsi
    smoothd     = 8 // 8 smooth signal of smoothed stochastic rsi
    myrsi  = rsi[lengthrsi](totalprice)
    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
    condbuy = condbuy  and c13
    condsell= condsell and c14
    else
    c13=c13
    c14=c14
    endif

    and the code below above the code above

    cb1 = angle >= 41
    cs1 = angle <= -34
    
    cb2 = (pente crosses over  trigger) and (pente >-2 and pente < 4)
    cs2 = (pente crosses under trigger) and (pente >-4 and pente < 2)
    
    //entrees en position
    condbuy  = cb1 and cb2 //and close<>high and high<>dhigh(0)
    condsell = cs1 and cs2 //and close<>low and low<>dlow(0)
    javi cano and thanked this post
    #143571 quote
    danistuta
    Participant
    Senior

    Hi Paul, could you post your last .ITF file please? Thank you very much.

    javi cano thanked this post
    #143572 quote
    Paul
    Participant
    Master

    and change nbchandelierb 40 to 41 and it looks better

    #143573 quote
    Paul
    Participant
    Master

    here are the changes above made in the original. On the other one I’am still working.

    // VECTORIAL MM - DJ 3m
    DEFPARAM CumulateOrders = false
    DEFPARAM Preloadbars = 50000
    //Money Management
    MM = 0 // = 0 for optimization
    if MM = 0 then
    positionsize=1
    ENDIF
    if MM = 1 then
    ONCE startpositionsize = .2
    ONCE factor = 10 // factor of 10 means margin will increase/decrease @ 10% of strategy profit; factor 20 = 5% etc
    ONCE margin = (close*.05) // tier 1 margin value of 1 contract in instrument currency; change decimal according to available leverage
    ONCE margin2 = (close*.05)// 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
    
    
    //HORAIRES DE TRADING
    Ctime = time >= 050000 and time < 230000
    
    
    //STRATEGIE
    //VECTEUR = CALCUL DE L'ANGLE
    ONCE PeriodeA = 2
    ONCE nbChandelierA= 30
    MMA = Exponentialaverage[PeriodeA](close)
    ADJASUROPPO = (MMA-MMA[nbchandelierA]*pipsize) / nbChandelierA
    ANGLE = (ATAN(ADJASUROPPO)) //FONCTION ARC TANGENTE
    CB1 = ANGLE >= 41
    CS1 = ANGLE <= - 34
    
    
    //VECTEUR = CALCUL DE LA PENTE ET SA MOYENNE MOBILE
    ONCE PeriodeB = 29
    ONCE nbChandelierB= 41
    lag = 0
    MMB = Exponentialaverage[PeriodeB](close)
    pente = (MMB-MMB[nbchandelierB]*pipsize) / nbchandelierB
    trigger = 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 POSITION
    CONDBUY = CB1 and CB2 and  CTime
    CONDSELL = CS1 and CS2 and  Ctime
    
    once stochasticrsi = 1
    
    //stochastic rsi | indicator
    if stochasticrsi then
    lengthrsi   = 2 // 2 rsi period
    lengthstoch = 6 // 6 stochastic period
    smoothk     = 4 // 4 smooth signal of stochastic rsi
    smoothd     = 8 // 8 smooth signal of smoothed stochastic rsi
    myrsi  = rsi[lengthrsi](totalprice)
    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
    condbuy = condbuy  and c13
    condsell= condsell and c14
    else
    c13=c13
    c14=c14
    endif
    
    //POSITION LONGUE
    IF CONDBUY THEN
    buy positionsize contract at market
    SET STOP %LOSS 2
    ENDIF
    
    //POSITION COURTE
    IF CONDSELL THEN
    Sellshort positionsize contract at market
    SET STOP %LOSS 2
    ENDIF
    
    //SET TARGET %PROFIT 2
    
    //Break even
    breakevenPercent = .13
    PointsToKeep = 1
    startBreakeven = tradeprice(1)*(breakevenpercent/100)
    
    once breakeven = 1//1 on - 0 off
    //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
    once trailingstoptype     = 1    // trailing stop - 0 off, 1 on
    
    once tsincrements = .05         // set to 0 to ignore tsincrements
    once tsminatrdist = 3
    
    once tsatrperiod    = 14         // ts atr parameter
    once tsminstop      = 12         // ts minimum stop distance
    
    once tssensitivity        = 1    // [0]close;[1]high/low
    
    if trailingstoptype then
    if barindex=tradeindex then
    trailingstoplong     = 4   // ts atr distance
    trailingstopshort    = 4   // 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
    trailingstopshort=trailingstopshort-tsincrements
    endif
    else
    trailingstopshort=tsminatrdist
    endif
    endif
    endif
    endif
    tsatr=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)) then
    tsmaxprice=0
    tsminprice=close
    tsnewsl=0
    endif
    if tssensitivity then
    tssensitivitylong=high
    tssensitivityshort=low
    else
    tssensitivitylong=close
    tssensitivityshort=close
    endif
    if longonmarket then
    tsmaxprice=max(tsmaxprice,tssensitivitylong)
    if 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
    endif
    boonet, javi cano and Balmora74 thanked this post
    #143574 quote
    deletedaccount051022
    Participant
    New

    Hi Paul,

    Apologies, how do you define stochasticrsi please?

    //stochastic rsi | indicator
    if stochasticrsi then

    …….

     

    Thank you

Viewing 15 posts - 826 through 840 (of 1,264 total)
  • You must be logged in to reply to this topic.

Discussing the strategy VECTORIAL DAX (M5)


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Balmora74 @balmora74 Participant
Summary

This topic contains 1,263 replies,
has 125 voices, and was last updated by VinzentVega
1 year ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/24/2019
Status: Active
Attachments: 470 files
Logo Logo
Loading...