BullCharts Forum Homepage
Forum Home Forum Home > BullCharts > BullScript
  New Posts New Posts RSS Feed: Reset Trailing Stop
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Reset Trailing Stop

 Post Reply Post Reply
Author
Message Reverse Sort Order / View First Unread Post
kmuntz View Drop Down
Newbie
Newbie
Avatar

Joined: 07 Jan 2007
Location: Australia
Posts: 4
Post Options Post Options   Quote kmuntz Quote  Post ReplyReply Direct Link To This Post Topic: Reset Trailing Stop
    Posted: 23 Dec 2009 at 3:28pm
I only just discovered this reply - many thanks it works well.  I was having trouble coming to grips with the "prev" function at the time
Back to Top
maximo View Drop Down
BullCharts Guru
BullCharts Guru
Avatar

Joined: 02 Sep 2006
Location: Australia
Posts: 232
Post Options Post Options   Quote maximo Quote  Post ReplyReply Direct Link To This Post Posted: 06 Dec 2009 at 6:03pm
A simple more efficient version.
 
 

Mult:=Input("ATR Multiplier",2,1);

Nb:=Input("Nb Periods",14,1);

HH := Close-Mult*ATR(Nb);

[target=price; color=black; linestyle=solid;]

if(HH<prev and close>prev,prev,HH);



Edited by maximo - 10 Dec 2009 at 2:33am
Back to Top
maximo View Drop Down
BullCharts Guru
BullCharts Guru
Avatar

Joined: 02 Sep 2006
Location: Australia
Posts: 232
Post Options Post Options   Quote maximo Quote  Post ReplyReply Direct Link To This Post Posted: 22 Sep 2009 at 11:59pm
Hi kmuntz and welcome to the Forum.  I have modified it to do that, though left the previous non retreating line in dotted, so both levels are visible.  You can simply remove
the last 2 lines of code if you only want the (close < stop value) line.
 

[target=price]

TDate:=InputDate("Date of trend", date(2009,2,10));

Value1:=Input("ATR Range X",3,1);

Value2:=Input("ATR Periods",20,3);

HoldingDays:=BarsSince(OnOrSkipped(TDate));

Stop:=CLOSE-(Value1*ATR(Value2));

ValueB := If(Stop>PREV(undefined),Stop,If(Stop<=PREV(undefined),PREV(undefined),Stop*Holdingdays));

if(Close<ValueB or LLV(C,2)<ValueB,LLV(Stop,8),ValueB);

[linestyle=dotted]

ValueB;



Edited by maximo - 23 Sep 2009 at 11:55am
Back to Top
kmuntz View Drop Down
Newbie
Newbie
Avatar

Joined: 07 Jan 2007
Location: Australia
Posts: 4
Post Options Post Options   Quote kmuntz Quote  Post ReplyReply Direct Link To This Post Posted: 22 Sep 2009 at 9:28pm
I am using the BullCharts indicator ATR Inital Stop (by Leon Wilson). This stop is a specified number of ATRs below the close. It can only rise, not fall ie. if today's calculation is less than the previous calculation then the previous calculation is used.  I would like to modify this indicator so that when the stop is hit (close < stop value)  the indicator resets - it recalculates to today's value.  In other words it's as if the start date starts from the day the stop was hit.  Does anyone have any idea how to do this in BullScript?

Here is the code (slightly simplified) that I want to modify:
TDate:=InputDate("Date of trend", date(2004,6,25));
Value1:=Input("ATR Range  X",4.5,1);
Value2:=Input("ATR Periods",20,3);

HoldingDays:=BarsSince(OnOrSkipped(TDate));
Stop:=CLOSE-(Value1*ATR(Value2));
ValueB := If(Stop>PREV(undefined),Stop,If(Stop<=PREV(undefined),PREV(undefined),Stop*Holdingdays));


Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.69
Copyright ©2001-2010 Web Wiz