I am trying to create a very simple indicator to draw arrows under a certain condition.
Something very strange (to me) is happening. It will work on most minute based time frames, except the 5 minute, which is the one I trade against.
I used the indicator wizard to generate the code below and just added the one line of code (in Blue).
Does anyone have an idea what I am doing wrong?
Thanks.
namespace NinjaTrader.NinjaScript.Indicators.MyIndicators
{
public class MyThreeBarReversal : Indicator
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Indicator here.";
Name = "MyThreeBarReversal";
Calculate = Calculate.OnBarClose;
IsOverlay = true;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
PaintPriceMarkers = true;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
//Disable this property if your indicator requires custom values that cumulate with each new market data event.
//See Help Guide for additional information.
IsSuspendedWhileInactive = true;
}
else if (State == State.Configure)
{
}
}
protected override void OnBarUpdate()
{
//Add your custom indicator logic here.
if(High[2] > High[3]) Draw.ArrowDown(this, CurrentBar.ToString(),true,0, High[0] + TickSize, Brushes.Salmon);
}
}
}
#region NinjaScript generated code. Neither change nor remove.
namespace NinjaTrader.NinjaScript.Indicators
{
public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
{
private MyIndicators.MyThreeBarReversal[] cacheMyThreeBarReversal;
public MyIndicators.MyThreeBarReversal MyThreeBarReversal()
{
return MyThreeBarReversal(Input);
}
public MyIndicators.MyThreeBarReversal MyThreeBarReversal(ISeries<double> input)
{
if (cacheMyThreeBarReversal != null)
for (int idx = 0; idx < cacheMyThreeBarReversal.Length; idx++)
if (cacheMyThreeBarReversal[idx] != null && cacheMyThreeBarReversal[idx].EqualsInput(input))
return cacheMyThreeBarReversal[idx];
return CacheIndicator<MyIndicators.MyThreeBarReversal>(ne w MyIndicators.MyThreeBarReversal(), input, ref cacheMyThreeBarReversal);
}
}
}
namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
{
public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
{
public Indicators.MyIndicators.MyThreeBarReversal MyThreeBarReversal()
{
return indicator.MyThreeBarReversal(Input);
}
public Indicators.MyIndicators.MyThreeBarReversal MyThreeBarReversal(ISeries<double> input )
{
return indicator.MyThreeBarReversal(input);
}
}
}
namespace NinjaTrader.NinjaScript.Strategies
{
public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
{
public Indicators.MyIndicators.MyThreeBarReversal MyThreeBarReversal()
{
return indicator.MyThreeBarReversal(Input);
}
public Indicators.MyIndicators.MyThreeBarReversal MyThreeBarReversal(ISeries<double> input )
{
return indicator.MyThreeBarReversal(input);
}
}
}
#endregion

Comment