On a 5 minute timeframe, I need to detect quick, momentum moves (on either side) away from Moving Average, as and when they happen.
Here is an example of the trade setup:
I learned a little bit of AFL, and below is what I came up with.
TimeFrameSet(in5Minute);
Momentum = RSI(10);
x = MA(C, 9);
y = GetRTData("Last"); // To get the last traded price of a security.
z = MA(C, 9) - Close;
Q = 0;
Short = x+2<=y;
Buy =x-2>=y;
AlertIf(Short AND Momentum>=75, "SOUND C:\\Users\\SHAILI-PC\\Downloads\\SELL.wav", "Upside Move on" + FullName(), 0, 15, 1);
AlertIf(Buy AND Momentum<=25, "SOUND C:\\Users\\SHAILI-PC\\Downloads\\BUY.wav", "Upside Move on" + FullName(), 0, 15, 1);
AddColumn(z, "Move", 1.2);
AddColumn(C, "Close", 1.2);
AddColumn (y, "LTP", 1.2);
Then I saved the code, sent it to analysis window where I set up Auto-Repeat of the Scan with the interval of 15 seconds.
But I don't think the code is working. It gets results only when I use Close for y instead of Latest Price as coded above.
Any help related to this setup would be deeply appreciated!