Instead, this indicator attempts to show whether a stop loss based on the settings for a number of ATRs is more conservative than a % stop set by the user. It is interesting as once set the more conservative solution changes from time to time as shown by the colour fills and some markers. A variable requires the indicator to be set for Longs or shorts.
[target
=Price;]
n :=
input("Time periods for highest high",15);
type :=
input("Is this Stop for 1 Long or 2 Short",1);
sl :=
input("percent for Stop Loss",6);
LongPercent:=
If(type=1,Highest(h,n)-((sl/100)*C),undefined);
[color
=Dark Gray; linestyle=Dotted; width=2;]
LongPercent;
S2 :=
input("No. of ATRs for Stop Loss",2);
LongATR:=
If(type=1,Highest(h,n)-(atr(n)*s2),undefined);
[color
= Dark Purple; linestyle=Dotted; width=2;]
LongATR;
{ Fill }
[name
=Fill; linestyle=fill; visible=false]
[color
= Dark Gray] LongPercent;
[color
= Dark Purple] LongATR;
[name
=% Set more conservative; linestyle=marker; marker=type1; visible=no] [tooltip="% Set more conservative"]
cross
(LongPercent, LongATR);
[name
=ATR set more conservative; linestyle=marker; marker=type1; visible=no] [tooltip="ATR set more conservative"]
cross
(LongATR, LongPercent);
shortPercent:=
If(type=2,Lowest(l,n)+((sl/100)*C),undefined);
[color
=Dark Gray; linestyle=Dotted; width=2;]
ShortPercent;
ShortATR:=
If(type=2,Lowest(h,n)+(atr(n)*s2),undefined);
[color
= Dark Purple; linestyle=Dotted; width=2;]
ShortATR;
{ Fill }
[name
=Fill; linestyle=fill; visible=false]
[color
= Dark Gray] ShortPercent;
[color
= Dark Purple] ShortATR;
[name
=% set more conservative; linestyle=marker; marker=type1; visible=no] [tooltip="% set more conservative"]
cross
(ShortPercent, ShortATR);
[name
=ATR set more conservative; linestyle=marker; marker=type1; visible=no] [tooltip="ATR set more conservative"]
cross
(ShortATR, ShortPercent);