Ayuda para saber como poner y mover stop profit y poner y mover stop loss.Gracia

Forums ProRealTime foro Español Soporte ProOrder Ayuda para saber como poner y mover stop profit y poner y mover stop loss.Gracia

  • This topic has 0 replies, 1 voice, and was last updated 1 year ago by avatarwally.
Viewing 1 post (of 1 total)
  • #193145

    // based on Balmora74 vectorial dax
    // based on Nonetheless 3m dow

    defparam cumulateorders = false
    defparam preloadbars = 2000

    once tradetype = 1 // [1]long/short [2]long [3]short

    once stochasticrsi = 1

    once sll = 2 // stoploss long
    once sls = 2 // stoploss short

    once ptl = undefined // profit target long
    once pts = undefined // profit target short

    once overnightposition = 1
    once weekendposition = 1

    once positionsize=1

    once starttime = 044500
    once endtime1 = 223000 //no overnight/weekend
    once endtime2 = 230000 //normal tradingtime

    once closetime = 215400 //no overnight/weekend

    if overnightposition and weekendposition then
    ctime = (time>=starttime and time<endtime2)
    elsif not overnightposition then
    ctime = (time>=starttime and time<endtime1)
    elsif overnightposition and not weekendposition then
    ctime = ((dayofweek<5 and time>=starttime and time<endtime2) or (dayofweek=5 and time>=starttime and time<endtime1))
    endif

    //
    once periodea = 2 //2
    once nbchandeliera = 30 //30
    once periodeb = 29 //29
    once nbchandelierb = 41 //41

    mma = exponentialaverage[periodea](close)
    adjasuroppo = (mma-mma[nbchandeliera]*pipsize) / nbchandeliera
    angle = (atan(adjasuroppo))

    mmb = exponentialaverage[periodeb](close)
    pente = (mmb-mmb[nbchandelierb]*pipsize) / nbchandelierb
    trigger = exponentialaverage[periodeb](pente)

    cb1 = angle >= 41 //41
    cs1 = angle <= -35 //34->35

    cb2 = (pente crosses over trigger) and (pente >-2 and pente < 4)
    cs2 = (pente crosses under trigger) and (pente >-4 and pente < 2)

    //
    condbuy = cb1 and cb2
    condsell = cs1 and cs2

    // stochastic rsi indicator
    if stochasticrsi then
    lengthrsi = 2 // rsi period
    lengthstoch = 6 // stochastic period
    smoothk = 4// 4smooth signal of stochastic a
    smoothd = 8 // 8smooth 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

    // entry criteria
    if ctime then
    if (tradetype=1 or tradetype=2) then
    if not longonmarket and condbuy then
    buy positionsize contract at market
    set stop %loss sll
    set target %profit ptl
    endif
    endif
    if (tradetype=1 or tradetype=3) then
    if not shortonmarket and condsell then
    sellshort positionsize contract at market
    set stop %loss sls
    set target %profit pts
    endif
    endif
    else
    if longonmarket and condsell then
    sell at market
    endif
    if shortonmarket and condbuy then
    exitshort at market
    endif
    endif

    once trailingstop=1
    once useDonchian =0 // if breakeven is not triggered

    if trailingstop then

    if ts2sensitivity=1 then
    ts2sensitivitylong=close
    ts2sensitivityshort=close
    elsif ts2sensitivity=2 then
    ts2sensitivitylong=high
    ts2sensitivityshort=low
    endif

    once hdp1=close
    once ldp1=close
    once hdp2=close
    once ldp2=close
    once hdp3=close
    once ldp3=close

    // below; 0 = disable minimumdistance critera
    mdist=((tradeprice(1)/100)*1)
    mdist2=((tradeprice(1)/100)*1)

    if longonmarket and (shortonmarket[1] or not onmarket[1]) or shortonmarket and (longonmarket[1] or not onmarket[1]) then
    once flag=0
    zz1=10
    zz2=zz1*3
    zz3=zz1*6
    hdp1=highest[zz1](high)[1]
    ldp1=lowest[zz1](low)[1]
    hdp2=highest[zz2](high)[1]
    ldp2=lowest[zz2](low)[1]
    hdp3=highest[zz3](high)[1]
    ldp3=lowest[zz3](low)[1]
    maxrun=max(hdp1,hdp2)
    maxrun2=max(maxrun,hdp3)
    minrun=min(ldp1,ldp2)
    minrun2=min(minrun,ldp3)
    endif

    if not onmarket or ((longonmarket and shortonmarket[1]) or (longonmarket[1] and shortonmarket)) then
    trailstart2L = 0.6 //% start trailing profits from this point
    trailstart2S = 0.3 //% start trailing profits from this point
    basepercentL = 1.8 //20.0% profit percentage to keep when setting berakeven
    basepercentS = 1.5
    stepsize = 2 //10 pip chunks to increase percentage
    percentinc = 0.4 //10.0% percent increment after each stepsize chunk
    barnumber = 10 //10 add further % so trades don’t keep running too long
    barpercent = 0.2 //10% add this additional percentage every barnumber bars
    roundto = 0 //-0.5 rounds lower, +0.4 higher, 0 defaults prt behaviour
    pricedistance = 10 * pipsize //7 minimun distance from current price
    y1 = 0 //reset to 0
    y2 = 0 //reset to 0
    profitpercentL = basepercentL //reset to desired default value
    profitpercentS = basepercentS
    tradebar = barindex
    trailstartL = ((close/100)*trailstart2L)
    trailstartS = ((close/100)*trailstart2S)
    ts2sensitivity= 1
    elsif longonmarket then
    if ts2sensitivitylong > (tradeprice(1) + (y1 * pipsize)) then
    x1 = (ts2sensitivitylong – tradeprice(1)) / pipsize
    if x1 >= trailstartL then
    diff1 = abs(trailstartL – x1)
    chunks1 = max(0,round((diff1 / stepsize) + roundto))
    profitpercentL = basepercentL + (basepercentL * (chunks1 * percentinc))
    barcount = barindex – tradebar
    if barcount mod barnumber = 0 then
    profitpercentL = profitpercentL + barpercent
    endif
    profitpercentL = max(profitpercentL[1],min(100,profitpercentL))
    y1 = max(x1 * profitpercentL, y1)
    endif
    else
    if useDonchian then
    if (tradeprice(1)-ldp1)>mdist and close crosses under ldp1 then
    sell at market
    endif
    if (tradeprice(1)-ldp2)>mdist and close crosses under ldp2 then
    sell at market
    endif
    if (tradeprice(1)-ldp3)>mdist and close crosses under ldp3 then
    sell at market
    endif

    if high crosses over maxrun2 then
    flag=1
    endif
    if flag=1 and low crosses under minrun2 and maxrun2-minrun2>mdist2 then
    sell at market
    endif
    endif
    endif
    elsif shortonmarket then
    if ts2sensitivityshort < (tradeprice(1) – (y2 * pipsize)) then
    x2 = (tradeprice(1) – ts2sensitivityshort) / pipsize
    if x2 >= trailstartS then
    diff2 = abs(trailstartS – x2)
    chunks2 = max(0,round((diff2 / stepsize) + roundto))
    profitpercentS = basepercentS + (basepercentS * (chunks2 * percentinc))
    barcount = barindex – tradebar
    if barcount mod barnumber = 0 then
    profitpercentS = profitpercentS + barpercent
    endif
    profitpercentS = max(profitpercentS[1],min(100,profitpercentS))
    y2 = max(x2 * profitpercentS, y2)
    endif
    else
    if useDonchian then
    if hdp1-tradeprice(1)>mdist and close crosses over hdp1 then
    exitshort at market
    endif
    if hdp2-tradeprice(1)>mdist and close crosses over hdp2 then
    exitshort at market
    endif
    if hdp3-tradeprice(1)>mdist and close crosses over hdp3 then
    exitshort at market
    endif

    if low crosses under minrun2 then
    flag=1
    endif
    if flag=1 and high crosses over maxrun2 and maxrun2-minrun2>mdist2 then
    exitshort at market
    endif
    endif
    endif
    endif
    if y1 then
    sellprice = tradeprice(1) + (y1 * pipsize)
    if abs(ts2sensitivitylong – sellprice) > pricedistance then
    if ts2sensitivitylong >= sellprice then
    sell at sellprice stop
    else
    sell at sellprice limit
    endif
    else
    sell at market
    endif
    endif
    if y2 then
    exitprice = tradeprice(1) – (y2 * pipsize)
    if abs(ts2sensitivityshort – exitprice) > pricedistance then
    if ts2sensitivityshort <= exitprice then
    exitshort at exitprice stop
    else
    exitshort at exitprice limit
    endif
    else
    exitshort at market
    endif
    endif
    endif

    if not overnightposition then
    if time>=closetime then
    sell at market
    exitshort at market
    endif
    endif

    if not weekendposition then
    if (dayofweek=5 and time>=closetime) then
    exitshort at market
    sell at market
    endif
    endif

    //graphonprice hdp1
    //graphonprice ldp1

    //graphonprice hdp2
    //graphonprice ldp2

    //graphonprice hdp3
    //graphonprice ldp3

    1 user thanked author for this post.
Viewing 1 post (of 1 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login