# 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

Currently, there are 0 users and 1 guest visiting this topic.
View all attachments
Viewing 1 post (of 1 total)
• #193145 Report

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

defparam cumulateorders = false

once tradetype = 1 // long/short long 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)

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)

//
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
condsell= condsell and c14
else
c13=c13
c14=c14
endif

// entry criteria
if ctime then
if not longonmarket and condbuy then
set stop %loss sll
set target %profit ptl
endif
endif
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
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

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

if not onmarket or ((longonmarket and shortonmarket) or (longonmarket 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
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
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))
if barcount mod barnumber = 0 then
profitpercentL = profitpercentL + barpercent
endif
profitpercentL = max(profitpercentL,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))
if barcount mod barnumber = 0 then
profitpercentS = profitpercentS + barpercent
endif
profitpercentS = max(profitpercentS,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. GraHal
Viewing 1 post (of 1 total)