All,
I am a newbie on AFL although I am an experienced trader. I am trying to get used to this language. In fact I wrote the following script and when I run it, I don't get the intended results. Can you please help me with this?
The idea of the code is to give Buy signal for all the Stocks / Futures whose EMA follows:
Buy - If latest value of 50 EMA > 50 EMA > 100 EMA
Sell - If latest value of 50 EMA < 50 EMA < 100 EMA
Code:
_SECTION_BEGIN("AFL Example");
LongMA = EMA( C, 100 );
MidMA = EMA( C, 50 );
ShortMA = EMA( C, 20 );
Buy = Cross( ShortMA, MidMA ) AND Cross(MidMA,LongMA);
Sell = Cross( LongMA, MidMA ) AND Cross(MidMA,ShortMA);
Filter=1;
AddTextColumn( FullName(), "Company Name" );
AddColumn( Buy, "Buy", 1 );
AddColumn( Sell, "Sell", 1 );
AddColumn( C, "Close", 1.3 );
AddColumn( H, "High", 1.3 );
AddColumn( ShortMA, "Short MA", 1,3 );
AddColumn( MidMA, "Mid MA", 1,3 );
AddColumn( LongMA, "Long MA", 1,3 );
_SECTION_END();
Please help.
Thanks,
Prash
I am a newbie on AFL although I am an experienced trader. I am trying to get used to this language. In fact I wrote the following script and when I run it, I don't get the intended results. Can you please help me with this?
The idea of the code is to give Buy signal for all the Stocks / Futures whose EMA follows:
Buy - If latest value of 50 EMA > 50 EMA > 100 EMA
Sell - If latest value of 50 EMA < 50 EMA < 100 EMA
Code:
_SECTION_BEGIN("AFL Example");
LongMA = EMA( C, 100 );
MidMA = EMA( C, 50 );
ShortMA = EMA( C, 20 );
Buy = Cross( ShortMA, MidMA ) AND Cross(MidMA,LongMA);
Sell = Cross( LongMA, MidMA ) AND Cross(MidMA,ShortMA);
Filter=1;
AddTextColumn( FullName(), "Company Name" );
AddColumn( Buy, "Buy", 1 );
AddColumn( Sell, "Sell", 1 );
AddColumn( C, "Close", 1.3 );
AddColumn( H, "High", 1.3 );
AddColumn( ShortMA, "Short MA", 1,3 );
AddColumn( MidMA, "Mid MA", 1,3 );
AddColumn( LongMA, "Long MA", 1,3 );
_SECTION_END();
Please help.
Thanks,
Prash