You would have to use a drawing object like a horizontal line instead of a plot if you wanted to have it span a different area. The plots correspond to the bars on the chart, if there is no data such as before the session then the plot wont plot in that area.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Plotting two days ago OHLC
Collapse
X
-
Thanks for your response. Not a programmer, but changed the PlotStlye to "HLine" and nothing changed:
Code:AddPlot(new Stroke(Brushes.SteelBlue, DashStyleHelper.Dash, 2), PlotStyle.HLine, NinjaTrader.Custom.Resource.PriorDayOHLCOpen); AddPlot(new Stroke(Brushes.DarkCyan, 2), PlotStyle.HLine, NinjaTrader.Custom.Resource.PriorDayOHLCHigh); AddPlot(new Stroke(Brushes.Crimson, 2), PlotStyle.HLine, NinjaTrader.Custom.Resource.PriorDayOHLCLow); AddPlot(new Stroke(Brushes.SlateBlue, DashStyleHelper.Dash, 2), PlotStyle.HLine, NinjaTrader.Custom.Resource.PriorDayOHLCClose); } else if (State == State.Configure) { AddDataSeries(BarsPeriodType.Minute, 1440); }}
I suppose I should completely get rid of the "AddPlot" and use a different script. Any advice on how to do that?
Thanks!Last edited by rezamerik; 10-28-2022, 11:10 AM.
Comment
-
Hello rezamerik,
That is not a drawing tool that is just the style of the plot. The plot cannot show up outside of the session because there are no bars there. You could use a drawing tool horizontal line for that purpose.
I would suggest to try adding the drawing object rather than removing parts of the currently working script. Once you have the general result you are looking for you could start removing parts if needed.
- Likes 1
Comment
-
NinjaTrader_Jesse So I read the instructions and added this:
Code:Draw.HorizontalLine(this, "PreviousDayOHLC", 50, Brushes.Black);
under the AddPlot() in the code, but nothing changed:
Code:if (State == State.SetDefaults) { Description = ""; Name = "PreviousDayOHLC"; IsAutoScale = false; IsOverlay = true; IsSuspendedWhileInactive = true; DrawOnPricePanel = false; ShowClose = true; ShowLow = true; ShowHigh = true; ShowOpen = true; AddPlot(new Stroke(Brushes.SteelBlue, DashStyleHelper.Dash, 2), PlotStyle.Hash, NinjaTrader.Custom.Resource.PriorDayOHLCOpen); AddPlot(new Stroke(Brushes.DarkCyan, 2), PlotStyle.Hash, NinjaTrader.Custom.Resource.PriorDayOHLCHigh); AddPlot(new Stroke(Brushes.Crimson, 2), PlotStyle.Hash, NinjaTrader.Custom.Resource.PriorDayOHLCLow); AddPlot(new Stroke(Brushes.SlateBlue, DashStyleHelper.Dash, 2), PlotStyle.Hash, NinjaTrader.Custom.Resource.PriorDayOHLCClose); Draw.HorizontalLine(this, "PreviousDayOHLC", 50, Brushes.Black); } else if (State == State.Configure) { AddDataSeries(BarsPeriodType.Minute, 1440); } }
If there is a sample or something that you could share with me to make this work, I would highly appreciate that!
Thank you!
Comment
-
Hello rezamerik,
The OnStateChange override would not be used for drawing objects, that is the area where the script is initially configured. Drawing objects would need to go in the OnBarUpdate override.
If you are looking for a line that is constant at a value of 50 like you have defined you can instead use AddLine which would go where you defined the plots. That type of line does not change and has a pre configured value. Drawing objects used from OnBarUpdate can be redrawn with new values and changed/removed as needed.
- Likes 1
Comment
-
Thank you for clarification NinjaTrader_Jesse. I tried to use AddLine and Draw.HorizantalLine based on the guidelines, and I put them under the OnBarUpdate as you advised. Still, it does not plot the extended lines!! What else do you think I might be missing?
Appreciate your help with this.
Reza
Comment
-
Hello rezamerik,
AddLine would not go in OnBarUpdate, that goes in OnStateChange like AddPlot. You an see a sample here:https://ninjatrader.com/support/help...ml?addline.htm
- Likes 1
Comment
-
Thanks for the clarification NinjaTrader_Jesse. How can I assign the OHLC values calculated in the script as the value parameter to the AddLine()? Based on the instructions, it seems the value for AddLine() has to be a constant number (like "30" in the example below):
Thank you!Code:AddLine(Brushes.Gray, 30, "Previous Day Close")
Last edited by rezamerik; 10-31-2022, 12:56 PM.
Comment
-
Hello rezamerik,
You can't, thats what I had mentioned in post 21. If you need a constant not changing value like you had used with a value of 50 you can use AddLine, that makes a constant line that doesn't change. The sample you had provided just has the value of 50 which is never changing so that would be a use for AddLine. If you need a changing value you can use Draw.HorizontalLine from OnBarUpdate instead.
Draw.HorizontalLine(this, "tag1", PriorClose[0], Brushes.Black);
- Likes 1
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
579 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
334 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
554 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment