This plots only on the condition bar:
namespace NinjaTrader.NinjaScript.Indicators
{
public class _plotlineplus4Bars : Indicator
{
int cBar;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Indicator here.";
Name = "_plotlineplus4Bars";
Calculate = Calculate.OnEachTick;
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;
// Adds a blue Dash-Line style plot with 5pixel width and 70% opacity
AddPlot(new Stroke(Brushes.Cyan, DashStyleHelper.Dash, 5, 70), PlotStyle.Hash, "MyPlot1");
}
else if (State == State.Configure)
{
}
}
protected override void OnBarUpdate()
{
if (CurrentBar <21) return;
if (Open[0] < Close[0])
{
cBar = CurrentBar;
Print(" ");
Print("cBar : " + cBar);
Print("cBar+5 : " + (cBar+5) + " " + Time[0]);
for (int i = cBar; i < (cBar+5) ; i++)
{
MyPlot1[0] = High[0];
}
}
}
#region Properties
[Browsable(false)]
[XmlIgnore]
public Series<double> MyPlot1
{
get { return Values[0]; }
}
#endregion
}
}
...
cBar : 57268
cBar+5 : 57273 10/07/2024 07:44:59
cBar : 57269
cBar+5 : 57274 10/07/2024 07:45:00
cBar : 57270
cBar+5 : 57275 10/07/2024 07:45:32
I need this done with addPlot, not with drawings.
The plot needs to start plotting from the initial condition bar (Open[0] < Close[0]) forward on each bar for 4 bars,
not from the 4th bar past the condition bar displays.

Comment