DISCLAIMER: Most formulas present in AFL on-line library are submitted
by the users and are provided here on an "as is" and "as available" basis.
AmiBroker.com
makes no representations or warranties of any kind to the contents or the operation
of material presented here. We do not maintain nor provide technical support
for 3rd party formulas. Description:
System to identify trend and its direction.
Formula:
/*Trend Continuation Factor
MArch 2000 TAS&C */
EnableScript("jscript");
Length=Optimize("Length",35,1,100,1);
Change= Close-Ref(Close,-1);
PlusChange=IIf(Change>0,Change,0);
MinusChange=IIf(Change<0,-Change,0);
<%
PlusChange=VBArray(AFL("PlusChange")).toArray();
MinusChange=
VBArray(AFL("MinusChange")).toArray();
/*Make two new arrays*/
var PlusCF=new Array ();
var MinusCF=new Array();
/*fill array "PlusCF"*/
for (i=0; i<PlusChange.length; i++ )
{
if (PlusChange[i]==0) {
PlusCF[i]=0;
}
else {
PlusCF[i]=PlusChange[i]+PlusCF[i-1];
}
}
/*Fill array "MinusCF*/
for (i=0; i<MinusChange.length; i++ )
{
if (MinusChange[i]==0) {
MinusCF[i]=0;
}
else {
MinusCF[i]=MinusChange[i]+MinusCF[i-1];
}
}
/*Convert to AFL variables*/
AFL("PlusCF")=PlusCF;
AFL("MinusCF")=MinusCF;
%>
PlusTCF=
Sum(PlusChange-MinusCF,Length);
MinusTCF=
Sum(MinusChange-PlusCF,Length);
Buy=PlusTCF>0;
Sell=MinusTCF>0;
Short=Sell;
Cover=Buy;
/*This is optional*/
ApplyStop(2,1,Optimize("Stop Loss",12,1,15,1),1);
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
Cover=ExRem(Cover,Short);
Short=ExRem(Short,Cover);
Comments:
Willem Jan w.j.a.struyck [at] worldonline.nl 2002-04-29 06:45:14
Probably making a mistake I have not find a high level of reliability playing with this system. I check this by the following procedure: optimizing at 175 days, place parameters found, backtest 120 days, optimize at 120 days, check outcome with previous backtest for 120 days, change parameters with newly found ones, backtest for 90 days, optimize at 90 days, check outcome with prevoius backtest for 90 dyas, etc.
If you see a constant pattern of net profits and parameters I reckon the system is reliable, if it changes for optimization to optimization and the net profit changes all the time I coinsier the system not very reliable.
Curious to hear your views on this approach.
WillemmJan