Simple MACD crossover strategy

What you are saying is incorrect.
E.g. MACD() is equal to MACD(12, 26) because default values of MACD function are 12 and 26. So both arguments of that function are untouched in upper code and that one tells AmiBroker engine to use those default values. It won't use random values in such case but always the same ones.

Hover with your mouse over a function and you will see whether it has arguments and what's their default parameters.

5

But also the manual tells you whether a function has any arguments and what are default values of a function. E.g. look up MACD().


Apparently you have set trade delay setting of Trades tab of analysis setting to larger than zero and entry/exit prices being Open.

Either change trade tab setting to close and zero delay

5

or add this one to your code (as it will override analysis settings).

SetTradeDelays(0,0,0,0);

BuyPrice = SellPrice = Close;

Buy = Cross( MACD(), SIGNAL() );
Sell = Cross( Signal(), MACD() );
AlertIF(Buy,"Test01","Simple text alert",4);
Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );

Filter = Cross( MACD(12,26), SIGNAL(12,26,9) );
AddColumn (MACD(), "MACD");
AddColumn (Signal(), "Signal");

And last but not least... @av.ragavan, it is mandatory rule here to use code tags if adding code to a post.
Please read here.

(below animation copied from that thread)
pastecode3