I used the Cross function on the daily chart it shows Buy/Sell signal. But in 5 minutes chart it doesn't show. Also, the AFL Functions document mentioned that "AFL Function Reference - CROSS Gives a "1" or true on the day that ARRAY1 crosses above ARRAY2"
Buy = Cross(EMA(Ref(C,-1),50),EMA(Ref(C,-1),200));
Sell = Cross(EMA(Ref(C,-1),200),EMA(Ref(C,-1),50));
It works with EVERY time interval.
To get better understanding of what is happening in your code and how functions work, use advice given here: How do I debug my formula?
The code must be crystal clear, avoid repetition, use variables to increase clarity and readability like this:
PC = Ref( C, -1 ); // previous bar close
ma50 = MA( PC , 50 );
ma200 = MA( PC , 200 );
// much clearer code using variables
Buy = Cross( ma50, ma200 );
Sell = Cross( ma200, ma50 );
// for exploration (debugging so you understand what is happening)
Filter = 1;
AddColumn( ma50, "ma50" );
AddColumn( ma200, "ma200" );
AddColumn( Buy, "Buy" );
AddColumn( Sell, "Sell");
The code using variables runs faster even if it is longer.
This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.