Description
TMAG is an oscillator based on three moving averages and the +DI and -DI lines of the DMS (Directional Movement System) indicator.
It indicates the market state as uptrend, downtrend, or flat.
The trade signal, with confirmation based on this indicator, is when the cross happens above (for long) and below (for short).
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 mTMAG : Indicator
{
[Parameter("DMS Periods (14)", DefaultValue =14)]
public int inpPeriodDMS { get; set; }
[Parameter("Fast Periods (8)", DefaultValue =8)]
public int inpPeriodFast { get; set; }
[Parameter("Middle Periods (16)", DefaultValue =16)]
public int inpPeriodMiddle { get; set; }
[Parameter("Slow Periods (25)", DefaultValue =25)]
public int inpPeriodSlow { get; set; }
[Parameter("Smooth Fast Period (3)", DefaultValue =3)]
public int inpPeriodSmoothFast{ get; set; }
[Parameter("Smooth Slow Period (8)", DefaultValue =8)]
public int inpPeriodSmoothSlow{ get; set; }
[Parameter("Range Bands Period: (200)", DefaultValue = 200)]
public int inpBandsPeriod { get; set; }
[Parameter("Range Bands Deviation: (1.1618)", DefaultValue = 0.618)]
public double inpBandsStdDev { get; set; }
[Output("TMSAG", LineColor = "Black", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
public IndicatorDataSeries outTMSAG { get; set; }
[Output("Signal", LineColor = "Red", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
public IndicatorDataSeries outSignal { get; set; }
[Output("Range Up", LineColor = "Magenta", PlotType = PlotType.Line, Thickness = 1)]
public IndicatorDataSeries outBBrangeup { get; set; }
[Output("Range Down", LineColor = "Magenta", PlotType = PlotType.Line, Thickness = 1)]
public IndicatorDataSeries outBBrangedn { get; set; }
private DirectionalMovementSystem _dms;
private MovingAverage _mafast, _mamiddle, _maslow, _smoothfast, _smoothslow;
private IndicatorDataSeries _raw;
private BollingerBands _bbrange;
protected override void Initialize()
{
_dms = Indicators.DirectionalMovementSystem(inpPeriodDMS);
_mafast = Indicators.MovingAverage(Bars.ClosePrices, inpPeriodFast, MovingAverageType.Simple);
_mamiddle = Indicators.MovingAverage(Bars.ClosePrices, inpPeriodMiddle, MovingAverageType.Simple);
_maslow = Indicators.MovingAverage(Bars.ClosePrices, inpPeriodSlow, MovingAverageType.Simple);
_raw = CreateDataSeries();
_smoothfast = Indicators.MovingAverage(_raw, inpPeriodSmoothFast, MovingAverageType.Simple);
_smoothslow = Indicators.MovingAverage(_raw, inpPeriodSmoothSlow, MovingAverageType.Weighted);
_bbrange = Indicators.BollingerBands(_raw, inpBandsPeriod, inpBandsStdDev, MovingAverageType.Simple);
}
public override void Calculate(int i)
{
_raw[i] = (Math.Abs(_mafast.Result[i] - _mamiddle.Result[i]) + Math.Abs(_mafast.Result[i] - _maslow.Result[i]) + Math.Abs(_mamiddle.Result[i] - _maslow.Result[i])) * (_dms.DIPlus[i] - _dms.DIMinus[i]);
outTMSAG[i] = _smoothfast.Result[i];
outSignal[i] = _smoothslow.Result[i];
outBBrangeup[i] = _bbrange.Top[i];
outBBrangedn[i] = _bbrange.Bottom[i];
}
}
}
mfejza
Joined on 25.01.2022
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: mTMAG.algo
- Rating: 5
- Installs: 555
- Modified: 08/05/2023 20:53
Comments
usually, the best sounding ringtones are coming from paid ringtone donwload sites“become a payment processor
We are a bunch of volunteers and starting a new scheme in our community. Your web site provided us with valuable information to work on. You have done a formidable activity and our entire neighborhood will be thankful to you.how to sell credit card processing
Nice post. I find out some thing much harder on various blogs everyday. Most commonly it is stimulating to see content off their writers and exercise a little something from their store. I’d would prefer to apply certain while using content in this little weblog whether or not you do not mind. Natually I’ll provide a link on your own web weblog. Thank you sharing.Packers and Movers Kolkata to Ahmedabad
wide-web website together with your website will undoubtedly be one in every of my fresh favorite types. I’m keen on this amazing website given and has nowhow to become a credit card processor