AFL RSI Divergence Trading System & Indicator
Contents
Step 1: The Trading Idea
Buy when RSI shows a positive divergence with strong momentum
Step 2: Selecting Indicators for Divergence Trading System
A divergence is one of the most important concepts for finding trend reversals. Since the market goes up in price swings, a decrease in momentum is a sign of reversal of uptrend. A momentum indicator such as RSI shows negative divergence when prices start losing momentum.
To find a negative divergence, we compare consecutive highs of prices with consecutive highs in RSI. If prices make a higher high but RSI makes a lower high, a negative divergence is confirmed. Similarly the positive divergence is also calculated.
Algoji removes the tiring process of manually finding out divergence by providing an automatic divergence detection formula. The same classic divergence detection rules which are used manually, are also used by the AFL formula.
Step 3: Defining Clear Strategy Rules for Divergence Trading System
Buy: When RSI shows positive divergence and RSI value is more than 70
Sell: When prices show negative divergence OR RSI value is less than 30
Step 4: AFL Coding Guide
We modify the custom peak and trough functions in Amibroker to avoid a future looking formula. This is an advanced code which detects divergence but without looking at future prices.
Step 5: The Backtest
The strategy is significantly profitable in Bank Nifty current month futures. It generates a profit of 4762 points, or Rs. 3,57,150/ over two years on one lot (75 shares). The winner% is 45.9, which is good for a trend reversal system.
Related Article: Basics in Strategy Backtesting
- Scrip: Bank Nifty current month futures, 15-minute
- All trades executed at Close price of the bar on which signal is triggered
- Brokerage: 0.01% of Trade Value
- Data History: 01-01-2014 to 31-12-2015 (two years)
- Strategy Optimization: None
Step 6: Further Improvement
We leave it to the readers to suggest any improvement in Step 2 and Step 3 which can increase the profitability. We can introduce custom stoploss as well as profit targets to further maximize the profitability.
Download here Divergence Trading System
Click here to download the editable Amibroker Divergence Trading System AFL Strategy
Click here to download the RSI Divergence Indicator
Mohammad Hosein
Hi Saurabh Lohiya;
how good is that if you explain more about your codes.
1- you have told there is no “look to the future” in your code… but there is some ref(c,+4) in your code that exactly look to the future!
2- could you please explain your conditions for divergence? as I know there is only 2 condition: A:price is falling B:indicator is rising (or wise-versa) but in your code there are some conditions that none of them are this…
3- how did you detect peak and troughs? could you explain the code?
thanks for your work and for your sharing.
Mohammad Hosein
venu madhav
since the afl code is not available now,can you please post it here the afl code or mail me the code.this will really help so many people.
AlgoPro
Hi Hosein,
Thanks for your time to go into details.
These articles are not written by me. But since I took ownership of AlgoJi, it reflects my name. Anyways I have corrected the issue.
1. Look at the custom functions and how they are used. You will understand that AFL does not looks into future, because these functions are called over past data, and NOT on current candle. Moreover you can verify by bar-replay that any of the signals do not change value.
2. Again I suggest you to compare on chart, and you will find that both conditions of divergence are met. It is not a simple code, and cannot be explained in just one article.
3. It is not a simple code, and cannot be explained in just one article.
Thanks again
Mohammad Hosein
thanks for your reply
yuvraj
please give suggestion to apply this on mcx crudeoil segment.
VIKAS
Interested in Ur services
Vikas Bhatt
Not found RSI Divergence Indicator for download ….
please Share the Link
venu madhav
since the afl code is not available now,can you please post it here the afl code or mail me the code.this will really help so many people.
Rao
Sir, the download links are not working. Please provide the links. Thanks