Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 5/13/2005(UTC) Posts: 715 Location: Midwest, USA
Was thanked: 1 time(s) in 1 post(s)
|
Andrew -- OK, got something for you. Only part I could not work in is that 2nd day low (yet). In brief:
1. Trailing Low
2. Entry Day Low plus % Entry Day Close (your original request)
3. Entry Day Low plus Trailing ATR
They all use a break by the LOW, and the Trailing ATR hangs off the CLOSE; these elements are easily adjusted.
--Johnathan Code:
{_Test}
{*******************************}
{ Use trailing low only }
{*******************************}
Buy:=C>Ref(C,-1) AND V>Ref(V,-1);
Trade:=if(PREV=0, { no trade }
if(Buy,Low,PREV), { Set initial stop to low of buy bar or 0 if no buy signal }
if(L<PREV,0, { Stop hit, SELL, reset latch }
Max(Low,PREV) { otherwise raise (trail) stop to next higher low }
));
Season:=if(Trade>0,1,-1);
Signal:=If(Season<>Ref(Season,-1),Season,0);
{ Plot }
Trade;
Code:
{_Test} {*******************************} { Use low of entry bar, then % of Entry-day Close & Low off current close } {*******************************} Buy:=C>Ref(C,-1) AND V>Ref(V,-1);
{ Stores value of stop } Trade:=if(PREV<=0, { no trade } if(Buy,Low,PREV), { Enter trade, set initial stop to low of buy bar } { Stop hit if below % or entry day Low } { otherwise raise (trail) stop to next higher low } { If entry % based stop hit, SELL, reset latch } if(L<Max(C*(1-(ValueWhen(1,PREV=0,C)-ValueWhen(1,PREV=0,L))/ValueWhen(1,PREV=0,C)),PREV),0,PREV) );
Season:=if(Trade>0,1,-1); Signal:=If(Season<>Ref(Season,-1),Season,0);
{ Plot } Trade;
Code:
{_Test}
{*******************************}
{ Use low of entry bar, then trailing ATR off highest close }
{*******************************}
A:=Input("ATR",1,10,3); { multiplier }
X:=Input("Periods",1,20,3); { periods }
Buy:=C>Ref(C,-1) AND V>Ref(V,-1);
{ Stores value of stop }
Trade:=if(PREV<=0, { no trade }
if(Buy,Low,PREV), { Enter trade, set initial stop to low of buy bar }
{ Entry % based stop hit, SELL, reset latch }
{ otherwise raise (trail) stop to next ATR }
if(L<Max(HighestSince(1,PREV=0,C)-A*ATR(X),PREV),0,PREV)
);
Season:=if(Trade>0,1,-1);
Signal:=If(Season<>Ref(Season,-1),Season,0);
{ Plot }
Trade;
|