Hi,
I am having trouble coding AFL using the explore function to scan for
MA Crosses depending on the settings in a .txt file.
My text file is: [name to match symbol name],short MA, long MA
eg:
AAPL,20,50
I would like to explore all symbols in the database, and if the name
matches the current symbol being explored:
a) Output "2" to an exploration column if short MA has crossed long
MA for that symbol today
b) Output "0" to the same column if symbol not found in .txt file, or
no cross today
My code is like this so far, but it isn't working:
cnt = 1;
gg = 0;
fh = fopen( "C:\\test.txt", "r");
if( fh )
{
while( ! feof( fh ) )
{
a = fgets( fh );
nm = strextract(a,0);
if (nm == name())
{
shortma = strtonum(strextract(a,1));
longma = strtonum(strextract(a,2));
gg[cnt] = Iif(Cross(shortma,longma),2,0);
}
else
{
gg[cnt] = 0;
}
cnt = cnt + 1;
}
}
fclose( fh );
filter = 1;
AddColumn(gg,"CROSS SIGNAL?");
Any help to correct the code would be great - thanks!