I am a beginner with NinjaScript so hopefully my request will be a piece of cake
I am trying to create a custom EMA indicator: with a period of 5 and based on HIGH prices.
I thought I should use the existing NinjaScript code for default EMA and adapt it to my needs. So I have changed a period value successfully to 5. But couldn't think of how to code EMA so that it is based on HIGH prices.
Just for your information I paste my variable section here:
public class ema5 : Indicator
{
#region Variables
private int period = 5;
#endregion
/// <summary>
/// This method is used to configure the indicator and is called once before any bar data is loaded.
/// </summary>
protected override void Initialize()
{
Add(new Plot(Color.Blue, "ema5"));
Overlay = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
Value.Set(CurrentBar == 0 ? Input[0] : Input[0] * (2.0 / (1 + Period)) + (1 - (2.0 / (1 + Period))) * Value[1]);
}
Comment