-
manjuaav 15.04.2018Hi Burhay Vlad,
After lot of frustration of going through the code documentation and trying to understand the coding style, i am struck. Documentation is very poor and no proper usecase examples.
I am trying to use you HMA code and add multi timeframe data, Can you please help.
namespace HMAcolor
{
public enum TFPeriod
{
M1 = 1,
M5 = 5,
M15 = 15,
H1 = 60,
H4 = 240
}
public class HMA_MultiTimeframe : NETIndicator
{
[InputParameter("Timeframe", 6, new object[]
{
"1M", TFPeriod.M1,
"5M", TFPeriod.M5,
"15M", TFPeriod.M15,
"1H", TFPeriod.H1,
"4H", TFPeriod.H4
})]
public TFPeriod Timeframe = TFPeriod.M5;
[InputParameter("Period", 0, 3, 9999)]
public int period = 20;
[InputParameter("MA method", 1, new object[]
{
"EMA", MAMode.EMA,
"LWMA", MAMode.LWMA,
"SMA", MAMode.SMA,
"SMMA", MAMode.SMMA
}
)]
public MAMode method = MAMode.LWMA;
[InputParameter("Sources prices", 2, new object[]
{
"Close", PriceType.Close,
"Open", PriceType.Open,
"High", PriceType.High,
"Low", PriceType.Low,
"Typical", PriceType.Typical,
"Medium", PriceType.Medium,
"Weighted", PriceType.Weighted
}
)]
public PriceType price = PriceType.Close;
private Indicator MAfull, Mahalf, Mafinal;
HistoricalData hd;
public HMA_MultiTimeframe()
{
base.ProjectName = "HMA_MultiTimeframe";
base.SetIndicatorLine("Uptrend", Color.LimeGreen, 5, 0);
base.SeparateWindow = false;
}
public override void Init()
{
hd = ((int)Timeframe == CurrentData.Period) ? CurrentData : GetHistoricalData(new HistoricalDataRequest(Instruments.Current, (int)Timeframe));
IndicatorShortName("HMA_MTF(" + period + ")");
MAfull = Indicators.iMA(hd, period, method, 0, price);
Mahalf = Indicators.iMA(hd, period / 2, method, 0, price);
Mafinal = Indicators.iMA(x =>
{
if (Mahalf.Count < x + 1)
return 0;
return 2.0 * Mahalf.GetValue(0, x + 1) - MAfull.GetValue(0, x + 1);
}, (int)Math.Sqrt(period), method);
//Cuts tails
SetIndexDrawBegin(0, (int)(period * 1.2));
}
public override void Complete()
{
MAfull = null;
Mahalf = null;
Mafinal = null;
hd = null;
}
public override void OnQuote()
{
if (Mafinal != null && Mafinal.Count - 1 > 1)
{
SetValue(0, Mafinal.GetValue());
if (Mafinal.GetValue(0, 0) < Mafinal.GetValue(0, 1))
SetMarker(0, 1, Color.Red);
}
}
}
}
Contact
us