Testing a % stop-go indicator with the VST Custom Strategy.
Recently I noticed a bookmarked web page,
http://stocata.org/metastock/stop_trail_perc.html and decided to test the formula with the VST Custom Strategy. The website has several other
MetaStock formula that could be tested with the VST.
As with many indicators they work fine when the chart is trending nicely up or down but perform
poorly on choppy or sideways movement.
I needed to use this indicator with the VST and it will not plot +1/-1 so I used the Cross
function in MetaStock create the +1/-1 plot.
I have posted several chart to
My VST Charts blog, and I now have the VSTPro so I am able to post both VST Custom and VSTPro charts.
Original code.....
perc:=Input("Trailing Loss % :",0,100,14);
loss:=C*perc/100;
trail:=
If(C>PREV AND Ref(C,-1)>PREV,
Max(PREV,C-loss),
If(C<PREV AND Ref(C,-1)<PREV,
Min(PREV,C+loss),
If(C>PREV,C-loss,C+loss)));
Trail
Below is updated code sent from Jose Silva @
metastocktools.comAs for the stop code, the formula below plots identically and faster (for explorations) with two of the seven PREV functions taken out:
---8<----------------------------------
perc:=Input("Trailing Loss %",0,100,14);
loss:=C*perc/100;
trail:=
If(LLV(C,2)>PREV,Max(PREV,C-loss),
If(HHV(C,2)<PREV,Min(PREV,C+loss),
If(C>PREV,C-loss,C+loss)));
entry:=Cross(C,trail);
exit:=Cross(trail,C);
entry-exit
---8<----------------------------------
This formula is even faster with three PREV functions taken out:
---8<----------------------------------
{Input}
perc:=Input("Trailing Loss %",0,100,14);
{Stops}
loss:=C*perc/100;
stopLong:=If(C<PREV,C-loss,Max(C-loss,PREV));
stopShort:=If(C>PREV,C+loss,Min(C+loss,PREV));
{Signals}
In:=Cross(C,Ref(stopShort,-1));
Out:=Cross(Ref(stopLong,-1),C);
Init:=Cum(In+Out>-1)=1;
InInit:=Cum(In)=1;
flag:=BarsSince(Init OR In)
< BarsSince(Init OR Out)+InInit;
signals:=(InInit AND Alert(InInit=0,2)
OR flag AND Alert(flag=0,2))
-(flag=0 AND Alert(flag,2));
{Display}
signals
---8<----------------------------------