Sorry for my english i am french
I would like to develop an indicator as an histogram in green and it says to buy and red when it says to sell
it is based on the mme 10 and 20, the crossover of them
is this code correct ? because i dont arrive to compile it in ninjascript editor, there are error messages
thank you
namespace NinjaTrader.NinjaScript.Indicators
{
public class MMECrossHistogram : Indicator
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = "Histogram for EMA 10 and EMA 20 Crossings";
Name = "MMECrossHistogram";
Calculate = Calculate.OnEachTick;
IsOverlay = false;
DisplayInDataBox = true;
}
else if (State == State.DataLoaded)
{
AddPlot(new Stroke(Brushes.Transparent, 2), PlotStyle.Histogram, "Histogram");
}
}
protected override void OnBarUpdate()
{
double ema10 = EMA(Close, 10)[0];
double ema20 = EMA(Close, 20)[0];
if (CrossAbove(ema10, ema20, 1))
{
PlotBrushes[0][0] = Brushes.Green;
PlotValues[0][0] = ema10 - ema20;
}
else if (CrossBelow(ema10, ema20, 1))
{
PlotBrushes[0][0] = Brushes.Red;
PlotValues[0][0] = ema10 - ema20;
}
else
{
PlotBrushes[0][0] = Brushes.Transparent;
PlotValues[0][0] = 0;
}
}
}
}
Comment