All I'm trying to do is paint/draw an arrow where the current candle has broken above/below the previous candle (on the 15minute charts)
NinjaTrader sometimes works, but usually doesnt.
I started to make a custom series but then thought I wouldnt need it.
What am I doing wrong?
Thanks
namespace NinjaTrader.NinjaScript.Strategies
{
public class JonsTheStratIndicatorStrategy : Strategy
{
private Series<double> Green;
private Series<double> Red;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"";
Name = "JonsTheStratIndicatorStrategy";
Calculate = Calculate.OnBarClose;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries;
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = false;
MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
OrderFillResolution = OrderFillResolution.Standard;
Slippage = 0;
StartBehavior = StartBehavior.WaitUntilFlat;
TimeInForce = TimeInForce.Day;
TraceOrders = false;
RealtimeErrorHandling = RealtimeErrorHandling.IgnoreAllErrors;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
BarsRequiredToTrade = 1;
// Disable this property for performance gains in Strategy Analyzer optimizations
// See the Help Guide for additional information
IsInstantiatedOnEachOptimizationIteration = true;
}
else if (State == State.Configure)
{
AddDataSeries(Data.BarsPeriodType.Minute, 15);
}
else if (State == State.DataLoaded)
{
Green = new Series<double>(this);
Red = new Series<double>(this);
}
}
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if (CurrentBars[1] < 1)
return;
[B] // Set 1
if (Closes[1][0] > Highs[1][1])
{
Green[0] = 0;
BarBrush = Brushes.DarkGreen;
}
// Set 2
if (Closes[1][0] < Lows[1][1])
{
BarBrush = Brushes.Maroon;
Red[0] = 0;[/B]
}
}
}
}

Comment