How to get "typical" marketseries price from MA?
How to get "typical" marketseries price from MA?
13 May 2016, 00:09
Heya :)
I have a Moving Average problem:
I would like to get the "close" -marketseries price for the slowMA and "typical" -marketseries price for the fastMA.
Typical price is calculated: (High + Low + Close)/3
How to go about doing that? Do I need two different MA indicators? If so, how to link the typical-MA to the bot?
Thaks for your help!!
Replies
galafrin
13 May 2016, 21:44
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AutoRescale = false, AccessRights = AccessRights.None)]
public class SampleSMA : Indicator
{
[Parameter(DefaultValue = 14)]
public int Periods { get; set; }
[Output("Main", Color = Colors.Turquoise)]
public IndicatorDataSeries Result { get; set; }
double sum = 0 ;
public override void Calculate(int index)
{
for (int i = index - Periods + 1; i <= index; i++)
{
sum += ( MarketSeries.Close [i] + MarketSeries.High [i] + MarketSeries.Low [i] ) / 3.0 ;
}
Result[index] = sum / Periods;
}
}
}
@galafrin
GDPR-24_203122
14 May 2016, 11:54
RE:
galafrin said:
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AutoRescale = false, AccessRights = AccessRights.None)]
public class SampleSMA : Indicator
{
[Parameter(DefaultValue = 14)]
public int Periods { get; set; }
[Output("Main", Color = Colors.Turquoise)]
public IndicatorDataSeries Result { get; set; }double sum = 0 ;
public override void Calculate(int index)
{
for (int i = index - Periods + 1; i <= index; i++)
{
sum += ( MarketSeries.Close [i] + MarketSeries.High [i] + MarketSeries.Low [i] ) / 3.0 ;
}
Result[index] = sum / Periods;
}
}
}
Hello there and thak's a lot for the answer :)
galafrin
13 May 2016, 21:44
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AutoRescale = false, AccessRights = AccessRights.None)]
public class SampleSMA : Indicator
{
[Parameter(DefaultValue = 14)]
public int Periods { get; set; }
[Output("Main", Color = Colors.Turquoise)]
public IndicatorDataSeries Result { get; set; }
double sum = 0 ;
public override void Calculate(int index)
{
for (int i = index - Periods + 1; i <= index; i++)
{
sum += ( MarketSeries.Close [i] + MarketSeries.High [i] + MarketSeries.Low [i] ) / 3.0 ;
}
Result[index] = sum / Periods;
}
}
}
@galafrin