[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Complete AFL Code for Improved Trend Continuation Factor Indicator



PureBytes Links

Trading Reference Links

The TCF by M.H.Pee has appeared in a couple of TASC articles; one as 
recently as the 2005 bonus issue. The author tests the TCF on 15 
futures markets over a long time period and comes up with some very 
nice profits.  Only about 30% - 40% of trades are profitable but the 
profit ratio is generally above 2.5.  The AFL for TCF is in the AFL 
library and has been coded in by Dale Butkowski.

For those who are not familiar - here's the simple, simple 
explanation.  TCF looks at the INTER DAY DIFFERENCE in closing prices 
i.e., Close - Ref (Close, -1);  adds and subtracts differences and 
comes up with an indicator called +TCF and -TCF.
[You really have to read the articles to get a better idea :-)]

When +TCF > 0 (the green line) you go long and when -TCF > 0 (the red 
line) you go short.  If both TCF's go negative, then close out your 
positions.

I've made an improvement to the TCF by adding AN INTRA-DAY DIFFERENCE 
i.e., Close - ((H+L)/2);  the improvement is minor in the code but 
the difference in the indicator is immense.  Basically, it gets you 
in the long trade quicker and gets you out or in the short side 
quicker too - by as much as 20 days quicker (in some trades) !!!! (I 
checked it on IWM and QQQQ over 4 yrs).
[Note: in some trades - there was no difference between the old or 
the revised TCF]

To see for yourself - simply plot the original AFL library code (get 
it from the AFL library) next to mine (see below).  I've not tested 
any Buy/Sell rules with this indicator.  The Buy/Sell rules you see 
were in the original TASC article.

[By the way - the original article says that a length of 35 days 
should be taken.  You can change it to any length by changing the 2nd 
line of the code.  I personally prefer '13' but I've left it as '35']

******************************************

/*Trend Continuation Factor by M.H Pee
  MArch 2000 TAS&C Revision to code of
  Dale Butkowski by Dickie Paria*/

EnableScript("jscript");

Length=Optimize("Length",35,1,100,1);

Change= Close-Ref(Close,-1);
intraChange = Close - ((H+L)/2);
PlusChange=IIf(Change>0 AND intraChange>0,Change + intraChange,0);
MinusChange=IIf(Change<0 AND intraChange < 0,-Change - intraChange,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);

Plot(PlusTCF,"PlusTCF",colorGreen,1); //Plots PlusTCF line
Plot(MinusTCF,"MinusTCF",colorRed,1); //Plots MinusTCF line

PlotGrid(25,55); // shows white grid line for black background
PlotGrid(-25,-55); // same
Plot (0,"",colorBlue,styleNoLabel); // shows a blue line through 0

Buy=PlusTCF>0;
Sell=MinusTCF>0;
Short=Sell;
Cover=Buy;








------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/DldnlA/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/