NexusFi: Find Your Edge


Home Menu

 





Need Plot code help


Discussion in NinjaTrader

Updated
    1. trending_up 470 views
    2. thumb_up 7 thanks given
    3. group 3 followers
    1. forum 4 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 ndakotan 
Minot, North Dakota, USA
 
Experience: Beginner
Platform: Ninja Trader, AMT AutoTra
Trading: ES Mini
Posts: 26 since May 2019
Thanks Given: 14
Thanks Received: 12

I have an indicator working the way I want it except for 1 detail:

I want to be able to handle Dash Style in this line if possible

Plots[7].PlotStyle = PlotStyle.Square; Plots[7].Width = 2;

For instance I would like Dash (Square) line. At this point, Dash Style can only be set in the parameters when using the indicator. Since there are a few lines, I'd like to be able to pre-set some to Dash, or Dash Dot.

I keep getting pointed toward DashStyleHelper for the Dash Style, which rarely (if ever) works for me. Any hints on how to get DashStyleHelper to work in 8.1+?

Someone suggested I add an opacity setting for each line. if that can be set in the line I'd be interested in that as well. if not, that can somewhat be handled by picking lighter colors.


Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Al Arabiya: US-Iran Draft Deal Within Hours Contains Hor …
Prediction Markets & Event Contracts
CME Expands 24/7 Trading to WTI Crude Oil and Gold -- We …
Commodities
El Clasico Draws $9.2M in Prediction Market Action -- Bi …
Prediction Markets & Event Contracts
Wood Mackenzie Drops $200 Oil Forecast -- Airspace Expir …
Prediction Markets & Event Contracts
More Than Capable: Hegseths War Warning Validates $114M …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
8 thanks
Darmok and Jalad at Tanagra
1 thanks
  #2 (permalink)
 
DavidHP's Avatar
 DavidHP 
Isla Mujeres, MX
Legendary Market Wizard
 
Experience: Advanced
Platform: NinjaTrader
Broker: Ninjatrader / Optimus Futures / AmpFutures
Trading: NQ / ES / 6E / 6B / CL
Frequency: Every few days
Duration: Minutes
Posts: 1,816 since Aug 2009
Thanks Given: 11,765
Thanks Received: 3,043


ndakotan View Post
I have an indicator working the way I want it except for 1 detail:

I want to be able to handle Dash Style in this line if possible

Plots[7].PlotStyle = PlotStyle.Square; Plots[7].Width = 2;

For instance I would like Dash (Square) line. At this point, Dash Style can only be set in the parameters when using the indicator. Since there are a few lines, I'd like to be able to pre-set some to Dash, or Dash Dot.

I keep getting pointed toward DashStyleHelper for the Dash Style, which rarely (if ever) works for me. Any hints on how to get DashStyleHelper to work in 8.1+?

Someone suggested I add an opacity setting for each line. if that can be set in the line I'd be interested in that as well. if not, that can somewhat be handled by picking lighter colors.

I'm AFK but if no one replies I will post the code when I'm not on my tablet


Rejoice in the Thunderstorms of Life . . .
Knowing it's not about Clouds or Wind. . .
But Learning to Dance in the Rain ! ! !
Follow me on X Reply With Quote
Thanked by:
  #3 (permalink)
 
DavidHP's Avatar
 DavidHP 
Isla Mujeres, MX
Legendary Market Wizard
 
Experience: Advanced
Platform: NinjaTrader
Broker: Ninjatrader / Optimus Futures / AmpFutures
Trading: NQ / ES / 6E / 6B / CL
Frequency: Every few days
Duration: Minutes
Posts: 1,816 since Aug 2009
Thanks Given: 11,765
Thanks Received: 3,043



ndakotan View Post
I have an indicator working the way I want it except for 1 detail:

I want to be able to handle Dash Style in this line if possible

Plots[7].PlotStyle = PlotStyle.Square; Plots[7].Width = 2;

For instance I would like Dash (Square) line. At this point, Dash Style can only be set in the parameters when using the indicator. Since there are a few lines, I'd like to be able to pre-set some to Dash, or Dash Dot.

I keep getting pointed toward DashStyleHelper for the Dash Style, which rarely (if ever) works for me. Any hints on how to get DashStyleHelper to work in 8.1+?

Someone suggested I add an opacity setting for each line. if that can be set in the line I'd be interested in that as well. if not, that can somewhat be handled by picking lighter colors.

You did not post all of the line code so it is a little difficult to know what would work best for your needs
But here a the way to plot the line.

AddPlot(new Stroke(Brushes.PeachPuff, DashStyleHelper.Dot, 3), PlotStyle.Line, "Line Name");

If you want to assign those settings separately you could use:

AddPlot(Brushes.Chartreuse, "Line Name");
Plots[0].Width = 3;
Plots[0].DashStyleHelper.DashDotDot;


If you want to change the DashStyleHelper to a different choice, let NTScript fill in the options for you.
To do that type:
Plots[0].DashStyleHelper
When you add the DOT after the "DashStyleHelper" NT script will popup a box showing what options are available. Select what you want and hit enter.

*******
TIp: Open other indicators in the NT Editor and you can see the code and options for other coding methods when you get stuck.


Rejoice in the Thunderstorms of Life . . .
Knowing it's not about Clouds or Wind. . .
But Learning to Dance in the Rain ! ! !
Follow me on X Reply With Quote
Thanked by:
  #4 (permalink)
 ndakotan 
Minot, North Dakota, USA
 
Experience: Beginner
Platform: Ninja Trader, AMT AutoTra
Trading: ES Mini
Posts: 26 since May 2019
Thanks Given: 14
Thanks Received: 12


DavidHP View Post
You did not post all of the line code so it is a little difficult to know what would work best for your needs
But here a the way to plot the line.

AddPlot(new Stroke(Brushes.PeachPuff, DashStyleHelper.Dot, 3), PlotStyle.Line, "Line Name");

If you want to assign those settings separately you could use:

AddPlot(Brushes.Chartreuse, "Line Name");
Plots[0].Width = 3;
Plots[0].DashStyleHelper.DashDotDot;


If you want to change the DashStyleHelper to a different choice, let NTScript fill in the options for you.
To do that type:
Plots[0].DashStyleHelper
When you add the DOT after the "DashStyleHelper" NT script will popup a box showing what options are available. Select what you want and hit enter.

*******
TIp: Open other indicators in the NT Editor and you can see the code and options for other coding methods when you get stuck.

thank you


Started this thread Reply With Quote
Thanked by:
  #5 (permalink)
Leonardo Llaneza
Miami Florida
 
Posts: 5 since Jul 2026
Thanks Given: 0
Thanks Received: 1


ndakotan View Post
I have an indicator working the way I want it except for 1 detail:

I want to be able to handle Dash Style in this line if possible

Plots[7].PlotStyle = PlotStyle.Square; Plots[7].Width = 2;

For instance I would like Dash (Square) line. At this point, Dash Style can only be set in the parameters when using the indicator. Since there are a few lines, I'd like to be able to pre-set some to Dash, or Dash Dot.

I keep getting pointed toward DashStyleHelper for the Dash Style, which rarely (if ever) works for me. Any hints on how to get DashStyleHelper to work in 8.1+?

Someone suggested I add an opacity setting for each line. if that can be set in the line I'd be interested in that as well. if not, that can somewhat be handled by picking lighter colors.

On the DashStyleHelper issue — it usually comes down to where it's set. If it's being applied after the initial AddPlot() call (e.g., later in state changes) rather than directly in the Stroke passed into AddPlot(), it often won't stick. Setting it right in the constructor is what tends to work reliably in 8.1+:
csharpAddPlot(new Stroke(Brushes.Blue, DashStyleHelper.Dot, 2), PlotStyle.Line, "MyPlot");
For opacity, there's no direct property on Stroke, but you can get the same effect using a semi-transparent brush instead of a solid one:
csharpBrush transparentBrush = new SolidColorBrush(Colors.Blue) { Opacity = 0.5 };
transparentBrush.Freeze();

AddPlot(new Stroke(transparentBrush, DashStyleHelper.Dot, 2), PlotStyle.Line, "MyPlot");
The .Freeze() matters — NinjaScript brushes generally need to be frozen. That combo should get you both the dash style and the transparency per line.


Reply With Quote




Last Updated on July 16, 2026


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts