Description
Adaptive moving average converted from Tradingview by LuxAlgo. Can be use like every other moving average. See link below for more information.
// Trend Regularity Adaptive Moving Average by LuxAlgo
// https://www.tradingview.com/script/p8wGCPi6-Trend-Regularity-Adaptive-Moving-Average-LUX/
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
namespace cAlgo.Indicators
{
[Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
public class TRAMA : Indicator
{
[Output("TRAMA", LineColor = "Aqua", Thickness = 2)]
public IndicatorDataSeries Result { get; set; }
[Parameter("Source", DefaultValue = "Close")]
public DataSeries Source { get; set; }
[Parameter(DefaultValue = 100)]
public int Length { get; set; }
private IndicatorDataSeries high, low, hl;
private SimpleMovingAverage sma;
protected override void Initialize()
{
high = CreateDataSeries();
low = CreateDataSeries();
hl = CreateDataSeries();
sma = Indicators.SimpleMovingAverage(hl, Length);
}
public override void Calculate(int index)
{
high[index] = Bars.HighPrices.Maximum(Length);
low[index] = Bars.LowPrices.Minimum(Length);
bool hh = high[index] - high[index - 1] > 0 ? true : false;
bool ll = low[index - 1] - low[index] > 0 ? true : false;
hl[index] = hh | ll ? 1.0 : 0.0;
double tc = Math.Pow(sma.Result[index], 2);
if (double.IsNaN(Result[index - 1]))
{
Result[index] = Source[index];
}
else
{
Result[index] = Result[index - 1] + tc * (Source[index] - Result[index - 1]);
}
}
}
}
CW
cW22Trader
Joined on 16.03.2021
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: TRAMA.algo
- Rating: 0
- Installs: 1678
- Modified: 13/10/2021 09:54
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.
GA
Thanks for uploading your code, At first sight it is remainder of ADX volatility , in fact it is quiet near at double the period but with a simpler code.
Chartshot http://spotware.ctrader.com/c/SwS3n