Any stop that requires a reference to the entry, is basically a self-referencing formula.
A simple alternative to using Richard Dale's excellent
Advanced Trailing Stop plug-in, would be a (slow) PREV-based latch such as used in this indicator:
[code:1:b584ca1244]
{ EntryPrice/ATR reference, stoploss code
example for use in EntryPrice-related exit.
©Copyright 2004~2006 Jose Silva
For personal use only.
http://www.metastocktools.com }
{ User inputs }
multi:=Input("ATR stop multiplier",0,10,2);
plot:=Input("[1]ATR Stop, [2]System signals",1,2,1);
{ Sample system Entry & Exit signals }
entry:=Cross(C,Mov(C,21,E));
exit:=Cross(Mov(C,10,E),C);
{ ATR }
ATRstop:=ATR(10)*multi;
{ Reference ATR at system entry,
and apply to exit as a stoploss }
trade:=If(PREV=0,If(entry,C,0),
If(exit OR C<PREV-ATRstop,0,PREV));
{ New entry signal }
NuEntry:=trade>0 AND Alert(trade=0,2);
{ New exit signal }
NuExit:=trade=0 AND Alert(trade>0,2);
{ True entry ATR stop }
EntryATR:=ValueWhen(1,NuEntry,C-ATRstop);
{ Plot on price chart }
If(plot=1,EntryATR,NuEntry-NuExit)
[/code:1:b584ca1244]
jose '-)