Reset Trailing Stop |
Post Reply |
Author | |
kmuntz
Newbie Joined: 07 Jan 2007 Location: Australia Posts: 4 |
Post Options
Quote Reply
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
|
|
maximo
BullCharts Guru Joined: 02 Sep 2006 Location: Australia Posts: 232 |
Post Options Quote Reply 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 |
|
maximo
BullCharts Guru Joined: 02 Sep 2006 Location: Australia Posts: 232 |
Post Options Quote Reply 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 |
|
kmuntz
Newbie Joined: 07 Jan 2007 Location: Australia Posts: 4 |
Post Options Quote Reply 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)); |
|
Post Reply |
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |