I'm trying to write a strategy where the TP/SL is defined by the ATR at entry price. But how can I specify that I need the ATR at that specific time and that it shouldnt change?
Code: Select all
variables:
numbShares(200);
//Take Profit
if marketposition = 1 and (entryprice + averagetruerange(14)*1) < close then begin
sell ("Take Profit") numbShares/2 contracts this bar at close;
end;
//Stop Loss
if marketposition = 1 and (entryprice - averagetruerange(14)*1.5) > close then begin
sell ("Stop Loss") numbShares contracts this bar at close;
end;