Description
Intrinsic Tendency indicator Oscillator
For more info, please check original version: https://ctrader.com/algos/indicators/show/3808
// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © mfejza
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Levels(-1,0,+1)]
[Cloud("Level Tendence", "Level Zero", FirstColor = "Green", SecondColor = "Red", Opacity = 0.1)]
[Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class mIntrinsicTendencyOsc : Indicator
{
[Parameter("Period Fast (13)", DefaultValue = 13)]
public int inpPeriodFast { get; set; }
[Parameter("Period Slow (55)", DefaultValue = 55)]
public int inpPeriodSlow { get; set; }
[Output("Level Tendence", LineColor = "Black", PlotType = PlotType.Line, Thickness = 2)]
public IndicatorDataSeries outTendence { get; set; }
[Output("Level Zero", LineColor = "Transparent", PlotType = PlotType.Line, Thickness = 1)]
public IndicatorDataSeries outLevelZero { get; set; }
private IndicatorDataSeries _fasthh, _fastll, _slowhh, _slowll, _fastavg, _slowavg, _tendence;
protected override void Initialize()
{
_fasthh = CreateDataSeries();
_fastll = CreateDataSeries();
_slowhh = CreateDataSeries();
_slowll = CreateDataSeries();
_fastavg = CreateDataSeries();
_slowavg = CreateDataSeries();
_tendence = CreateDataSeries();
}
public override void Calculate(int i)
{
_fasthh[i] = i>inpPeriodFast ? Bars.HighPrices.Maximum(inpPeriodFast) : Bars.HighPrices[i];
_fastll[i] = i>inpPeriodFast ? Bars.LowPrices.Minimum(inpPeriodFast) : Bars.LowPrices[i];
_slowhh[i] = i>inpPeriodSlow ? Bars.HighPrices.Maximum(inpPeriodSlow) : Bars.HighPrices[i];
_slowll[i] = i>inpPeriodSlow ? Bars.LowPrices.Minimum(inpPeriodSlow) : Bars.LowPrices[i];
_fastavg[i] = (_fasthh[i] + _fastll[i]) / 2;
_slowavg[i] = (_slowhh[i] + _slowll[i]) / 2;
_tendence[i] = i>1 ? _tendence[i-1] : Bars.ClosePrices[i];
if(_fastavg[i] > _slowavg[i] && _fastavg[i-1] < _slowavg[i-1])
_tendence[i] = (_fastavg[i] + _slowavg[i]) / 2;
if(_fastavg[i] < _slowavg[i] && _fastavg[i-1] > _slowavg[i-1])
_tendence[i] = (_fastavg[i] + _slowavg[i]) / 2;
if(_fastavg[i] > _slowavg[i] && _fastavg[i-1] > _slowavg[i-1])
_tendence[i] = Math.Max((_fastavg[i] + _slowavg[i]) / 2, _tendence[i-1]);
if(_fastavg[i] < _slowavg[i] && _fastavg[i-1] < _slowavg[i-1])
_tendence[i] = Math.Min((_fastavg[i] + _slowavg[i]) / 2, _tendence[i-1]);
outTendence[i] = Bars.ClosePrices[i] > _tendence[i] ? +1 : Bars.ClosePrices[i] < _tendence[i] ? -1 : i>1 ? _tendence[i-1] : 0;
outLevelZero[i] = 0;
}
}
}
mfejza
Joined on 25.01.2022
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: mIntrinsicTendencyOsc.algo
- Rating: 5
- Installs: 458
- Modified: 09/12/2023 21:28
Note that publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section, please use the Copyright Infringement Notification form to submit a claim.
Comments
Log in to add a comment.
No comments found.