PureBytes Links
Trading Reference Links
|
Chorlton,
Here are two versions:
X:=Close;
BStop:=X-ATR(10)*2.5;
If(Bstop> Ref(Bstop,-1) and
X>Ref(X,-1),Bstop,Ref(BStop,-1));
X:=Close;
BStop:=X-ATR(10)*2.5;
If(Bstop> Ref(Bstop,-1) and
X>REF(X,-1),Bstop,PREV);
This can be simplified further by removing the Bstop> Ref(Bstop,-1)
statement. It plots the same without it. The only real difference in
the posted code is how the buy stop is treated in the event of a
close being less than ref(close,-1).
Hope this helps,
Preston
--- In equismetastock@xxxxxxxxxxxxxxx, "chorlton_c_hardy"
<micro_dot_uk@xxx> wrote:
>
>
> Hello All,
>
> I have some code for a trailing stop which I have written in
another
> language for another of my software applications.
>
> However, I am now trying to convert this code to MS but am having
> some serious difficulties :-(
>
> The code:
>
> Factor= AverageTrueRange[10](close)*2.5
>
> BuyStop = CLOSE - Factor
>
> IF BuyStop > BuyStop[1] THEN
>
> IF CLOSE > CLOSE[1] THEN
>
> BuyStop = CLOSE - Factor
>
> ELSE
>
> BuyStop = BuyStop[1]
>
> ENDIF
>
> ELSE
>
> IF CLOSE > BuyStop[1] THEN
>
> BuyStop = BuyStop[1]
>
> ELSE
>
> BuyStop = CLOSE - Factor
>
> ENDIF
>
> ENDIF
>
> RETURN BuyStop
>
>
> Basically, what I want to achieve is as follows:
>
> - As the price closes higher the stop moves up and remains
at "close-
> AverageTrueRange[10](close)*2.5" distance below current bar.
> - If the price fails to make new highs but remains above
yesterdays
> stop level, then the stop moves horizontal for the next period ie.
> Remains at same level as yesterday
> - Once the closing price drops below the current stop level, the
stop
> resets itself at the next bar to "close-AverageTrueRange[10](close)
> *2.5"
>
>
> Any Help much appreciated....
>
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/equismetastock/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/equismetastock/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:equismetastock-digest@xxxxxxxxxxxxxxx
mailto:equismetastock-fullfeatured@xxxxxxxxxxxxxxx
<*> To unsubscribe from this group, send an email to:
equismetastock-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|