VST (custom ver.) "Clear method" strategy.



To view a short video on setting-up the "Clear method" click here.



This is another way to use indicators with the VST Custom Strategy.

Copy/paste the formula below in to the MetaStock “Indicator Builder”.

Name the indicator “Clear method” without the quotation marks.


{Clear swing method based on S&C article "Getting Clear With Short-Term Swings":
http://www.traders.com/Documentation/FEEDbk_docs/2010/09/Black.html
Note that the MetaStock "Clear" code as provided by Equis at www.traders.com is incorrect.

Code adapted from VSTpro original code.
http://www.metastocktools.com/vst

Coded by Jose Silva at
http://www.metastocktools.com }


{ ----------- Start of custom code ----------- }

{User inputs}
swUp:=Input("Signals: Minimum UpSwing change %",0,25,0);
swDw:=Input("Signals: Minimum DwSwing change %",0,25,0);
rev:=Input("Reverse trade signals? [1]Yes [0]No",0,1,0);
display:=Input("Display: [1]'Clear' swing line [2]Signals",1,2,2);

{Ignore inside bars, avoid up/dw same-bar clash}
insideBar:=L>Ref(L,-1) AND H<Ref(H,-1);

{Clean price direction signals}
up:=H>Ref(H,-1) AND insideBar=0;
upSignal:=up AND Alert(up=0,2);
dw:=L<Ref(L,-1) AND insideBar=0;
dwSignal:=dw AND Alert(dw=0,2);
init:=Cum(IsDefined(upSignal+dwSignal))=1;
bin:=ValueWhen(1,upSignal-dwSignal<>0 OR init,
upSignal);
up:=bin*(Alert(bin=0,2)
OR upSignal*Cum(upSignal)=1);
dw:=(bin=0)*(Cum(bin)>0)*(Alert(bin,2)
OR dwSignal*Cum(dwSignal)=1);

{Clear Long/Short signals, swing line}
ClearUp:=Cross(L,ValueWhen(1,up,Ref(H,-1)))
AND insideBar=0;
ClearDw:=Cross(ValueWhen(1,dw,Ref(L,-1)),H)
AND insideBar=0;
init:=Cum(IsDefined(ClearUp+ClearDw))=1;
bin:=
ValueWhen(1,ClearUp-ClearDw<>0 OR init,ClearUp);
Clear:=If(bin,HighestSince(1,ClearUp,L),
LowestSince(1,ClearDw,H));

{Swing signals}
entry:=Clear>Ref(Clear,-1)*(1+swUp/100);
exit:=Clear<Ref(Clear,-1)*(1-swDw/100);


{ ------------ End of custom code ------------ }

{Reverse signals choice}
entry1:=entry;
entry:=If(rev,exit,entry1);
exit:=If(rev,entry1,exit);

{Display on price chart}
If(display=1,Clear,entry-exit)

{---------------End of copy/paste-----------}


Now that the indicator has been added to the ” Indicator Quick List” open any chart and apply the “VST Custom Strategy” template.

By using the " Formula Call [fml()] " function to calculate the value of another formula the user is able to reference the "Clear method" indicator without placing the complete indicator in to the VST Custom Strategy.

Open the “VST Custom Strategy” indicator and enter the code below.

{ ------------------------------------------ }

entry:=Fml("Clear method")>0;

exit:=Fml("Clear method")<0;

entry-exit

{ ------------------------------------------ }

Close the "VST Custom Strategy" indicator and click refresh chart, now the chart will display the
"Clear method" signals.

View the video for full details.

2 comments:

Anonymous said...

HI,

I tried to use this in an Explorer and sometimes I get results that say "N/A" or "0".

Could you please tell me why I may get the above signals instead of the default (1,-1)?

Thanks for putting this up.

Alex

--jjstein said...

Alex,

1. Under EXPLORER .. OPTIONS, you should have at least 3024 records loaded. (Also, I suggest you set CHART .. OPEN .. LOAD OPTIONS to the same value.)

2. Since you said "sometimes", I'll guess that this only happens with a few symbols -- so, see if the "problem" symbols have a short history (number of bars), as there may not be enough history to perform all VST calculations.


--Johnathan

Post a Comment

 
Design Credit Best Blogger Tips | Best Blogger Templates | Best Social Icons