I am trying to get the Accutrack indicator coding which is in the Amibroker list of afl formulae to run correctly. Here is the code:
// AccuTrack Compares performance of two securities
// The basic idea is to switch between the two securities
// AccuTrack was developed by FastTrack (http://fasttrack.net)
// Following is the Indicator Builder Formula
fnd = Name();
ind = "FDRXX"; // FDRXX is money market fund, so the //comparison is done with cash.
fund = Foreign(fnd, "Close");
index = Foreign(ind, "Close");
fast = 6;
slow = 24;
RawAT = EMA((EMA(ROC(fund,1), slow) - EMA(ROC(index,1),slow)),fast);
tradeAccuTrack = RawAT * 265;
Plot(tradeAccuTrack, "tradeAccuTrack", colorBlue, styleLine);
Title = Date()
+ " Trade AccuTrack of "
+ fnd
+" / "
+ ind
+ " = " + WriteVal(tradeAccuTrack, 1.2) + " ";
GraphXSpace = 2;
I first tried to add "SPY" to the function fnd = Name("SPY");
That didn't work. I followed the AFL Functions Reference instructions for the Name function to insert the fund name inside Name () but where this variable is used it's expecting an array and I don't see how the fund name returns an array and it returns an error on debugging.
Then I tried to simply define the fund as a variable by adding the line:
fnd= "SPY";
I know you can't identify the same variable twice so I then commented out the line:
fnd= Name();.
With these changes I get the red line but no blue line and of course, no cross of the two.
Where am I going wrong, please.