Category Oscilators  Published on 11/09/2023

RSI of Gann HiLo Activator

An update for this algorithm is currently pending moderation. Please revisit this page shortly to access the algorithm's latest version.
Description

Replacing the input price values of the Gann HiLo Activator indicator with the output of the Relative Strength Index (RSI), you would essentially be using the RSI as a trend filter or confirmation tool for your trading strategy. The RSI is a momentum oscillator that measures the speed and change of price movements, and it can provide additional insight into the strength of a trend. Here's how you might use the RSI in combination with the Gann HiLo Activator:

1. Using RSI as a Trend Filter:

Trend Following with Gann HiLo Activator: You can continue to use the Gann HiLo Activator indicator as described in the previous answer to identify potential entry and exit points based on its trendline. However, you can add an RSI filter to your strategy. For example, you might consider entering a long trade when the Gann HiLo Activator shows an uptrend (green trendline) and the RSI is above a certain threshold (e.g., RSI > 70 for overbought conditions). This can help you confirm that the price is not only in an uptrend but also potentially overbought, which might affect your decision to enter.

Trend Reversal with Gann HiLo Activator: Similarly, when using the Gann HiLo Activator to identify downtrends (red trendline), you might consider entering a short trade when the RSI is below a certain threshold (e.g., RSI < 30 for oversold conditions) to confirm potential weakness in the trend.

2. Setting Stop Loss and Take Profit:

Regardless of whether you use the Gann HiLo Activator or RSI as your primary indicator, always set appropriate stop-loss and take-profit levels based on your risk management strategy.
3. Practice and Backtesting:

As mentioned earlier, it's essential to practice and backtest your strategy when combining indicators. This helps you understand how the Gann HiLo Activator and RSI work together and how they perform in different market conditions.
4. Be Aware of Divergence:

One additional aspect to consider is RSI divergence. Divergence occurs when the RSI and price move in opposite directions. For example, if the RSI is making lower highs while the price is making higher highs, it might signal potential weakness in the trend. You can use this information in conjunction with the Gann HiLo Activator to make more informed trading decisions.
Remember that trading involves risk, and no combination of indicators can guarantee profitable trades. It's crucial to have a well-thought-out trading plan, manage risk effectively, and adapt your strategy based on market conditions. Additionally, consider using a demo account or paper trading to test your strategy before trading with real capital.

 

using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo
{
    [Levels(30,50,70)]
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class mRSIofGHLA : Indicator
    {
        [Parameter("Range Period (10)", DefaultValue = 10, MinValue = 1)]
        public int inpRangePeriod { get; set; }
        [Parameter("Period RSI (9)", DefaultValue = 9)]
        public int inpPeriodRSI { get; set; }

        [Output("Gann HiLo Activator", LineColor = "Black", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outGHLA { get; set; }
        [Output("Gann HiLo Activator Bullish", LineColor = "Green", PlotType = PlotType.DiscontinuousLine, LineStyle = LineStyle.Solid, Thickness = 2)]
        public IndicatorDataSeries outGHLAbull { get; set; }
        [Output("Gann HiLo Activator Bearish", LineColor = "Red", PlotType = PlotType.DiscontinuousLine, LineStyle = LineStyle.Solid, Thickness = 2)]
        public IndicatorDataSeries outGHLAbear { get; set; }
        
        private RelativeStrengthIndex _rsih, _rsil, _rsic;
        private MovingAverage _ragehigh, _ragelow;
        private IndicatorDataSeries _trend, _ghla, _bulls, _bears;


        protected override void Initialize()
        {
            _rsih = Indicators.RelativeStrengthIndex(Bars.HighPrices, inpPeriodRSI);
            _rsil = Indicators.RelativeStrengthIndex(Bars.LowPrices, inpPeriodRSI);
            _rsic = Indicators.RelativeStrengthIndex(Bars.ClosePrices, inpPeriodRSI);
            _ragehigh = Indicators.MovingAverage(_rsih.Result, inpRangePeriod, MovingAverageType.Simple);
            _ragelow = Indicators.MovingAverage(_rsil.Result, inpRangePeriod, MovingAverageType.Simple);
            _ghla = CreateDataSeries();
            _trend = CreateDataSeries();
            _bulls = CreateDataSeries();
            _bears = CreateDataSeries();
        }

        public override void Calculate(int i)
        {
            _trend[i] = _rsic.Result[i] > _ragehigh.Result[i] ? +1 : _rsic.Result[i] < _ragelow.Result[i] ? -1 : (i>1 ? _trend[i-1] : +1);
            _ghla[i] = _trend[i] < 0 ? _ragehigh.Result[i] : _ragelow.Result[i];
            _bulls[i] = _trend[i] < 0 ? double.NaN : _ragelow.Result[i];
            _bears[i] = _trend[i] < 0 ? _ragehigh.Result[i] : double.NaN; 
            
            outGHLA[i] = _ghla[i];
            outGHLAbull[i] = _bulls[i];
            outGHLAbear[i] = _bears[i]; 
        }
    }
}



mfejza's avatar
mfejza

Joined on 25.01.2022

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: mRSIofGHLA.algo
  • Rating: 5
  • Installs: 569
  • Modified: 11/09/2023 07:59
Comments
Log in to add a comment.
No comments found.