// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
//variables
positionsize=2
fastMA=50
slowMA=100
DonchOpen=50
// Conditions to enter long positions
C1 = close > Highest[DonchOpen](high[1])
indicator1 = ExponentialAverage[fastMA](close)
indicator2 = ExponentialAverage[slowMA](close)
C2 = (indicator1 > indicator2)
if C1 and C2 then
BUY positionsize PERPOINT AT MARKET
endif
// Conditions to exit long positions
highpoint=max(tradeprice,Highest[DonchOpen](high[1]))
atr = averagetruerange[100]*3
SL1 = highpoint - atr
if longonmarket then
sell at SL1 stop
endif
// Conditions to enter short positions
C4 = close < lowest[DonchOpen](low[1])
indicator1 = ExponentialAverage[fastMA](close)
indicator2 = ExponentialAverage[slowMA](close)
c5 = (indicator1 < indicator2)
if c4 and c5 then
sellshort positionsize PERPOINT AT MARKET
endif
// Conditions to exit short positions
lowpoint=min(tradeprice,lowest[DonchOpen](low[1]))
atr = averagetruerange[100]*3
SL2 = lowpoint + atr
if shortonmarket then
sell at SL2 stop
endif