using another indicator as a data source
using another indicator as a data source
12 Feb 2013, 11:36
Hi guys,
I actually don't know anything about the coding and needs some help.
There's an option for the source like close, high, etc...when we insert some indicators.
I want to use below indicator as a source for the simple moving average indicator.
I tried to put two indicator on cAlgo but failed. So for now, I insert midrange indicator first and then insery SMA and select the source data using midrange. I just want to have one indicator file for these steps.
Below is the coding for the indicator called midrange and I want to smooth this indicator by using source data for the simple moving average indicator.
Please help me on this project ^^
Thank you.
p.s: by the way, i alread set the period as 34....
using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
namespace cAlgo.Indicators
{
[Indicator(IsOverlay = true)]
public class midrange : Indicator
{
[Output("Center", Color = Colors.Black, Thickness = 0, LineStyle = LineStyle.Dots )]
public IndicatorDataSeries Center { get; set; }
public override void Calculate(int index)
{
double upper = double.MinValue;
double lower = double.MaxValue;
for (int i = index - 34; i <= index - 1; i++)
{
upper = Math.Max(MarketSeries.High[i], upper);
lower = Math.Min(MarketSeries.Low[i], lower);
}
Center[index] = (upper + lower) / 2;
}
}
}
admin
13 Feb 2013, 16:58
You may create another indicator that references the midrange indicator you created:
@admin