Description
The 'Intrinsic Tendency' is a custom indicator.
This indicator is used to calculate the near tendency price value based on the past price average of higher highs and lower lows.
The difference between the 'Intrinsic Tendency' indicator component and the price shows the zone of trade based on momentum volatility and the indicator component. When the price is above the 'Intrinsic Tendency' component, the long zone is traded (green shadow color), and when it is below, the short zone is traded (red shadow color).
For further study and trade zone confirmation confluence, use this indicator in different lookback periods (see fig.2).
// 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
{
[Cloud("Level Close", "Level Tendence", FirstColor = "Green", SecondColor = "Red", Opacity = 0.1)]
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class mIntrinsicTendency : 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 Close", LineColor = "Transparent", PlotType = PlotType.Line, Thickness = 1)]
public IndicatorDataSeries outClose { get; set; }
[Output("Level Fast", LineColor = "Transparent", PlotType = PlotType.Line, Thickness = 1)]
public IndicatorDataSeries outLevelFast { get; set; }
[Output("Level Slow", LineColor = "Transparent", PlotType = PlotType.Line, Thickness = 1)]
public IndicatorDataSeries outLevelSlow { 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]);
outLevelFast[i] = _fastavg[i];
outLevelSlow[i] = _slowavg[i];
outTendence[i] = _tendence[i];
outClose[i] = Bars.ClosePrices[i];
}
}
}
// 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
{
[Cloud("Level Close", "Level Tendence", FirstColor = "Green", SecondColor = "Red", Opacity = 0.1)]
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class mIntrinsicTendency : 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 Close", LineColor = "Transparent", PlotType = PlotType.Line, Thickness = 1)]
public IndicatorDataSeries outClose { get; set; }
[Output("Level Fast", LineColor = "Transparent", PlotType = PlotType.Line, Thickness = 1)]
public IndicatorDataSeries outLevelFast { get; set; }
[Output("Level Slow", LineColor = "Transparent", PlotType = PlotType.Line, Thickness = 1)]
public IndicatorDataSeries outLevelSlow { 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]);
outLevelFast[i] = _fastavg[i];
outLevelSlow[i] = _slowavg[i];
outTendence[i] = _tendence[i];
outClose[i] = Bars.ClosePrices[i];
}
}
}
mfejza
Joined on 25.01.2022
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: mIntrinsicTendency.algo
- Rating: 5
- Installs: 503
- Modified: 09/12/2023 21:20
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.
Bel lavoro…