|
Sydney
Experience: Intermediate
Platform: Multichart
Trading: Gold
Posts: 26 since Aug 2016
Thanks Given: 22
Thanks Received: 4
|
Hola
does anyone know how to Easy language a research strategy where its entry at every single bar and then followed by a ATR trailing stop? Long only. And short only.
I think code below is a start... But I don't understand what ts is??
Kind regards
Loop
Inputs: Price(Close),atrPeriod(14),atrMult(1.75);
Vars:
atr(0), ts(0), shstp(0), lgstp(0), trend(0), TriggerPrice(0), dir(0);
atr = AvgTrueRange(AtrPeriod);
lgstp = Price - atr * atrMult;
shstp = Price + atr * atrMult;
TriggerPrice = close;
if TriggerPrice >= ts[1] then
trend = 1
else if TriggerPrice < ts[1] then
trend = -1;
if trend > 0 then
if trend[1] < 0 then ts=lgstp[0]
else if lgstp >= ts[1] then ts=lgstp[0]
else ts=ts[1];
if trend < 0 then
if trend[1] > 0 then ts=shstp[0]
else if shstp <= ts[1] then ts=shstp[0]
else ts=ts[1];
if trend[1] < 0 and trend >= 0 then buy next bar at market;
if trend[1] > 0 and trend < 0 then sellshort next bar at market;
|