Description
Good Morning.
This is a volatility study based on a simple average, highs and lows.
The oscillator in the image can be easily represented by referencing the price and the bands to the simple average, work that I leave as an exercise.
As allways, the risk is in follow trends when market ranges or follow mean reversion when market trends.
Knowledge is equal opportunities. I have a lot to learn, thank you.
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class SmaCloseBandWidthOverlay : Indicator
{
[Parameter(DefaultValue = 15)]
public int Periods { get; set; }
[Output("Result1", LineColor = "Red")]
public IndicatorDataSeries Result1 { get; set; }
[Output("Result2", LineColor = "Green")]
public IndicatorDataSeries Result2 { get; set; }
[Output("Result3", LineColor = "Aqua")]
public IndicatorDataSeries Result3 { get; set; }
private SimpleMovingAverage sma;
private double hband, lband;
protected override void Initialize()
{
sma = Indicators.SimpleMovingAverage(Bars.ClosePrices, Periods);
}
public override void Calculate(int index)
{
if (Bars.ClosePrices[index] == Bars.ClosePrices.Maximum(Periods))
hband = Bars.ClosePrices.Maximum(Periods) - sma.Result[index];
if (Bars.ClosePrices[index] == Bars.ClosePrices.Minimum(Periods))
lband = Bars.ClosePrices.Minimum(Periods) - sma.Result[index];
Result1[index] = sma.Result[index] + hband;
Result2[index] = sma.Result[index] + lband;
Result3[index] = sma.Result[index];
}
}
}
srm_bcn
Joined on 01.09.2019
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: SmaCloseBandWidthOverlay.algo
- Rating: 0
- Installs: 1447
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.