Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 7/25/2005(UTC) Posts: 1,042
Was thanked: 57 time(s) in 54 post(s)
|
Hi Joy55
There are a couple of common ways to incorporate an indicator into an exploration.
If you want to include the entire indicator code into an exploration column (or filter) you must remove the Input () functions and replace them with a constant (while using the original variable name).
{Super Trend}
Factor:=Input("Factor",1.00,10.00,3.00);
Pd:=Input("ATR Periods",1,100,10);
Up:=MP()+(Factor*ATR(Pd));
Dn:=MP()-(Factor*ATR(Pd));
Td:=If(Cross(C,LLV(Up,13)),1,If(Cross(HHV(Dn,13),C ),-1,PREV));
Dnx:=If(Dn=HighestSince(1,Cross(Td,0),Dn),Dn,PREV) ;
Upx:=If(Up=LowestSince(1,Cross(0,Td),Up),Up,PREV);
ST:=If(Td=1,Dnx,If(Td=-1,Upx,PREV));
ST;
This formula should be changed to...
{Column A}
{Super Trend}
Factor:=3;
Pd:=10;
Up:=MP()+(Factor*ATR(Pd));
Dn:=MP()-(Factor*ATR(Pd));
Td:=If(Cross(C,LLV(Up,13)),1,If(Cross(HHV(Dn,13),C ),-1,PREV));
Dnx:=If(Dn=HighestSince(1,Cross(Td,0),Dn),Dn,PREV) ;
Upx:=If(Up=LowestSince(1,Cross(0,Td),Up),Up,PREV);
ST:=If(Td=1,Dnx,If(Td=-1,Upx,PREV));
ST;
However you do not need to use the entire formula in your exploration. Instead you can use the Fml() fuction to call the indicator. The exploration will then use the default values of any Input() function in the indicator. See below.
{Column A}
Fml("Super Trend").
Be aware that comments are placed inside braces {}. Also be aware that your version of Super Trend has 4 PREV functions, and this means that it will run quite slow as an exploration. A much faster version with PREV eliminated is shown below.
{Super Trend}
Factor:=Input("Factor",1,10,3);
Pd:=Input("ATR Periods",1,200,10);
Up:=MP()+(factor*ATR(Pd));
Dn:=MP()-(factor*ATR(Pd));
Cu:=Cross(C,LLV(Up,13));
Cd:=Cross(HHV(Dn,13),C);
I:=Cum(IsDefined(Cd+Cu))=1;
Td:=ValueWhen(1,Cu+Cd+I,Cu-Cd);
I:=Cum(IsDefined(Cd+Cu))=2;
Hs:=Dn=HighestSince(1,I+Cross(Td,0),Dn);
Ls:=Up=LowestSince(1,I+Cross(0,Td),Up);
Dnx:=ValueWhen(1,Hs,Dn);
Upx:=ValueWhen(1,Ls,Up);
SuperTrend:=If(Td=1,Dnx,Upx);
SuperTrend;
Hope this helps.
Roy
|