Category Oscilators  Published on 03/04/2023

IMO indicator

Description

The purpose of the Impulse Momentum Oscillator (IMO) is to identify fresh momentum.

The general recommendation is to trade in the direction of the intersection between the oscillator line and the range line. Two "anticipating" range lines provide signals when they crossover, although with a break in the new sentiment. In other words, when the upper range increases by following the main line, a long momentum occurs, and when the lower range decreases by following the main line, a short momentum occurs.


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

namespace cAlgo
{
    [Levels(0)]
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class mIMO : Indicator
    {
        [Parameter("Data Source (open)", DefaultValue = enumPriceTypes.Open)]
        public enumPriceTypes inpPriceType { get; set; }
        [Parameter("Range Periods (25)", DefaultValue = 25)]
        public int inpRangePeriods { get; set; }

        [Output("IMO", LineColor = "Black", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 2)]
        public IndicatorDataSeries outIMO { get; set; }
        [Output("IMO Range Max", LineColor = "Red", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outIMOmax { get; set; }
        [Output("IMO Range Min", LineColor = "Red", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outIMOmin { get; set; }

        private MovingAverage _ma;
        private IndicatorDataSeries _price, _pr, _raw, _rangemin, _rangemax;               

        protected override void Initialize()
        {
            _price = CreateDataSeries();
            _pr = CreateDataSeries();
            _raw = CreateDataSeries();
            _ma = Indicators.MovingAverage(_price, 1, MovingAverageType.Simple);
            _rangemin = CreateDataSeries();
            _rangemax = CreateDataSeries();
        }

        public override void Calculate(int i)
        {
            switch (inpPriceType)
            {
                case enumPriceTypes.Open:
                    _price[i] = Bars.OpenPrices[i];
                    break;
                case enumPriceTypes.Close:
                    _price[i] = Bars.ClosePrices[i];
                    break;
                case enumPriceTypes.High:
                    _price[i] = Bars.HighPrices[i];
                    break;
                case enumPriceTypes.Low:
                    _price[i] = Bars.LowPrices[i];
                    break;
                case enumPriceTypes.Median:
                    _price[i] = Bars.MedianPrices[i];
                    break;
                case enumPriceTypes.Typical:
                    _price[i] = Bars.TypicalPrices[i];
                    break;
                case enumPriceTypes.Weighted:
                    _price[i] = Bars.WeightedPrices[i];
                    break;
                default:
                    _price[i] = Bars.ClosePrices[i];
                    break;
            }
            _pr[i] = _ma.Result[i];
            _raw[i] = i>10 ? _pr[i] - (10 * _pr[i] + 55 * _pr[i-1] + 165 * _pr[i-2] + 330 * _pr[i-3] + 462 * _pr[i-4] + 462 * _pr[i-5] + 330 * _pr[i-6] + 165 * _pr[i-7] + 55 * _pr[i-8] + 11 * _pr[i-9] + _pr[i-10]) / 2046 : _pr[i];
            _rangemin[i] = i>inpRangePeriods ? _raw.Minimum(inpRangePeriods) : _raw[i];
            _rangemax[i] = i>inpRangePeriods ? _raw.Maximum(inpRangePeriods) : _raw[i];
                          
            outIMO[i] = _raw[i];
            outIMOmax[i] = _rangemax[i];
            outIMOmin[i] = _rangemin[i];
        }
    }
    
    public enum enumPriceTypes
    {
        Open,
        Close,
        High,
        Low,
        Median,
        Typical,
        Weighted
    }
}

mfejza's avatar
mfejza

Joined on 25.01.2022

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: mIMO.algo
  • Rating: 0
  • Installs: 443
Comments
Log in to add a comment.
No comments found.