Description
The well konow Rainbow technical indicator.
To test with different zoom levels and periods.
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 Rainbow : Indicator
{
[Parameter(DefaultValue = 5)]
public int Periods { get; set; }
[Output("Result1", LineColor = "DimGray")]
public IndicatorDataSeries Result1 { get; set; }
[Output("Result2", LineColor = "DimGray")]
public IndicatorDataSeries Result2 { get; set; }
[Output("Result3", LineColor = "DimGray")]
public IndicatorDataSeries Result3 { get; set; }
[Output("Result4", LineColor = "DimGray")]
public IndicatorDataSeries Result4 { get; set; }
[Output("Result5", LineColor = "DimGray")]
public IndicatorDataSeries Result5 { get; set; }
[Output("Result6", LineColor = "DimGray")]
public IndicatorDataSeries Result6 { get; set; }
[Output("Result7", LineColor = "DimGray")]
public IndicatorDataSeries Result7 { get; set; }
[Output("Result8", LineColor = "DimGray")]
public IndicatorDataSeries Result8 { get; set; }
[Output("Result9", LineColor = "DimGray")]
public IndicatorDataSeries Result9 { get; set; }
[Output("Result10", LineColor = "DimGray")]
public IndicatorDataSeries Result10 { get; set; }
private SimpleMovingAverage sma1;
private SimpleMovingAverage sma2;
private SimpleMovingAverage sma3;
private SimpleMovingAverage sma4;
private SimpleMovingAverage sma5;
private SimpleMovingAverage sma6;
private SimpleMovingAverage sma7;
private SimpleMovingAverage sma8;
private SimpleMovingAverage sma9;
private SimpleMovingAverage sma10;
protected override void Initialize()
{
sma1 = Indicators.SimpleMovingAverage(Bars.ClosePrices, Periods);
sma2 = Indicators.SimpleMovingAverage(sma1.Result, Periods);
sma3 = Indicators.SimpleMovingAverage(sma2.Result, Periods);
sma4 = Indicators.SimpleMovingAverage(sma3.Result, Periods);
sma5 = Indicators.SimpleMovingAverage(sma4.Result, Periods);
sma6 = Indicators.SimpleMovingAverage(sma5.Result, Periods);
sma7 = Indicators.SimpleMovingAverage(sma6.Result, Periods);
sma8 = Indicators.SimpleMovingAverage(sma7.Result, Periods);
sma9 = Indicators.SimpleMovingAverage(sma8.Result, Periods);
sma10 = Indicators.SimpleMovingAverage(sma9.Result, Periods);
}
public override void Calculate(int index)
{
Result1[index] = sma1.Result[index];
Result2[index] = sma2.Result[index];
Result3[index] = sma3.Result[index];
Result4[index] = sma4.Result[index];
Result5[index] = sma5.Result[index];
Result6[index] = sma6.Result[index];
Result7[index] = sma7.Result[index];
Result8[index] = sma8.Result[index];
Result9[index] = sma9.Result[index];
Result10[index] = sma10.Result[index];
}
}
}
srm_bcn
Joined on 01.09.2019
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: Rainbow.algo
- Rating: 5
- Installs: 1255
- 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.