Prorealtime Code Library – VExit

This code uses a vectorial indicator on shorter time frame than the main signal to act as a plunge protection type stop, so far it has improved the profitability of all the swing type systems that I have tried it on

 

Variables to optimise = ang1 and ang2

Code:

timeframe(5minutes)
once periodea = 12
once nbchandeliera = 14
once periodeb = 20
once nbchandelierb = 33

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+lag](pente)
once lag = 5

// buy conditions
condbuy = angle >= ang1
condbuy = condbuy and (pente crosses over trigger) and (pente < 0)
condbuy = condbuy and average[20](totalprice)>average[20](totalprice)[1]
condbuy = condbuy and close>low

// short conditions
condsell = angle <= -ang2
condsell = condsell and (pente crosses under trigger) and (pente > -2)
condsell = condsell and average[35](totalprice)<average[35](totalprice)[1]
condsell = condsell and close<high

if longonmarket and condsell then
sell at market
endif
if shortonmarket and condbuy then
exitshort at market
endif

Leave a Comment