Description
Well, this time, exploring relations between open and close.
Have fun!
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 SmoothedOpenCloseOverlay : Indicator
{
[Parameter("Periods", DefaultValue = 20)]
public int Periods { get; set; }
[Output("Result1", LineColor = "Tomato")]
public IndicatorDataSeries Result1 { get; set; }
[Output("Result2", LineColor = "LightGreen")]
public IndicatorDataSeries Result2 { get; set; }
[Output("Result3", LineColor = "Red")]
public IndicatorDataSeries Result3 { get; set; }
[Output("Result4", LineColor = "Green")]
public IndicatorDataSeries Result4 { get; set; }
private double maxOpen, minOpen;
private double maxClose, minClose;
protected override void Initialize()
{
}
public override void Calculate(int index)
{
maxOpen = 0;
minOpen = 0;
maxClose = 0;
minClose = 0;
for (int i = 1; i <= Periods; i++)
{
maxOpen += Bars.OpenPrices.Maximum(i);
minOpen += Bars.OpenPrices.Minimum(i);
maxClose += Bars.ClosePrices.Maximum(i);
minClose += Bars.ClosePrices.Minimum(i);
}
maxOpen = maxOpen / Periods;
minOpen = minOpen / Periods;
maxClose = maxClose / Periods;
minClose = minClose / Periods;
Result1[index] = maxOpen;
Result2[index] = minOpen;
Result3[index] = maxClose;
Result4[index] = minClose;
}
}
}
srm_bcn
Joined on 01.09.2019
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: SmoothedOpenCloseOverlay.algo
- Rating: 0
- Installs: 1439
- 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.
No comments found.