Who can help me?
I would like an indicator with three exponential moving averages. What is wrong in your code? (I see only one!)
This is the code:
[Description()]
publicclass EMAs3 : Indicator
{
#region Variables
privateint fast = 7; // Default setting for Fast
privateint average = 14; // Default setting for Average
privateint slow = 21; // Default setting for Slow
#endregion
protectedoverridevoid Initialize()
{
Add(new Plot(Color.Red, "EMA Fast"));
Add(new Plot(Color.DarkViolet, "EMA Average"));
Add(new Plot(Color.Blue, "EMA Slow"));
Overlay = true;
PriceTypeSupported = true;
}
protectedoverridevoid OnBarUpdate()
{
Value.Set(CurrentBar == 0 ? Input[0] : Input[0] * (2.0 / (1 + Fast)) + (1 - (2.0 / (1 + Fast))) * Value[1]);
Value.Set(CurrentBar == 0 ? Input[0] : Input[0] * (2.0 / (1 + Average)) + (1 - (2.0 / (1 + Average))) * Value[1]);
Value.Set(CurrentBar == 0 ? Input[0] : Input[0] * (2.0 / (1 + Slow)) + (1 - (2.0 / (1 + Slow))) * Value[1]);
}
Thank you for your help
germano
Comment