Error in fnd=Name() coding

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.

Please use code tags when inserting code!

That's incorrect use of Name function. Name function does not have any function arguments.
Simply assign "SPY" to index variable and "FDRXX" to fnd variable.

Both symbols have to exist in your database. Do they?
Do they have same up-to-date data?

// 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 = "FDRXX";// FDRXX is money market fund, so the //comparison is done with cash.
ind = "SPY"; 
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;

Alternatively you may do this

fnd = Name();// "FDRXX";// FDRXX is money market fund, so the //comparison is done with cash.
ind = "SPY"; 
fund = C;//Foreign(fnd, "Close");
index = Foreign(ind, "Close");

// .. rest of code below

And as chart symbol you select your fund.


BTW, this one

RawAT = EMA((EMA(ROC(fund,1), slow) - EMA(ROC(index,1),slow)),fast);

can be simplified to

RawAT = EMA((EMA(ROC(fund,1)-ROC(index,1),slow)),fast);


There is not any red line plot in the posted code but just blue one.

Cross of which two? Again there is just single plot in "your" code (I guess it is a copy from somewhere but no link posted). It plots single line. So of course there can't be a cross with other line that is not there (except for chart grid).

30

2 Likes

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.