Can anyone help me to code using the AFL Coding in Amibroker? The strategy is given below:-

BUY -> When MA(Close,15) > Price on 5 Min, 15 Min and 1 Hour Chart AND also MACD (Red line) crosses above the Signal (Blue Line) on 5 Min, 15 Min and 1 Hour Chart.

SELL -> When the RSI > 79 on 5 Min Chart.

Based on this up and down arrows has to be plotted on the chart.

You will need to define your position size and execution price variables.And you will need to test it on 5 minute bars.

TimeFrameSet(3*in5Minute);
Condition1=Cross(MACD(12,26),Signal(12,26,9) );
TimeFrameRestore();

TimeFrameSet(inHourly);
Condition2=Cross(MACD(12,26),Signal(12,26,9) );
TimeFrameRestore();

Buy=MA(Close,15)>Close AND MA(TimeFrameGetPrice(“Close”,3in5Minute),15)>Close AND
MA(TimeFrameGetPrice(“Close”,inHourly),15)>Close AND Cross(MACD(12,26),Signal(12,26,9)) AND
TimeFrameExpand(Condition1,3
in5Minute) AND TimeFrameExpand(Condition2,inHourly);

Sell=RSI(14)>79;

2 Likes

Thank You very much Akshay. Well Done. I don’t know much about coding just recently using Amibroker. I will run the code and if any problems i face will get back to you… I also want the RSI to work in the 5 Min timeframe. and also the 15 min timeframe is not set in the code. Just clarify on this ok. Akshay one more thing how can i learn all the coding stuff in Amibroker. Is it possible for me to learn. Just tell me some good sites and books to refer me…

Well Akshay i have tested and this is not working perfectly fine. This is giving a bunch of “SELL” signals.
A buy condition has to be met when all the conditions has to be satisfied like MA(Close,15) > than the live price on the 5Min, 15Min and 1 Hour chart as well as the MACD (Redline) crosses above the Signal (Blueline) on the 5Min, 15Min and 1 Hour chart.
For Sell: The RSI > 79 on the 5 Min chart.
Please do the corrections in the formula and waiting for your reply