Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw.Line requires NinjaScriptBase. What objects implement that?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Draw.Line requires NinjaScriptBase. What objects implement that?

    Hello,

    I'm simply trying to draw a line. I'm doing so from within a custom class I've created, so obviously that class doesn't implement NinjaScriptBase, and passing in "this" doesn't work. I've been unable to find a suitable object I can pass in that does.

    Draw.Line(NinjaScriptBase owner, string tag, int startBarsAgo, double startY, int endBarsAgo, double endY, Brush brush)

    Thank you,

    Ryan

    #2
    Hello gripload, and thank you for your question. You will need a handle to the Indicator you intend to use to draw the line on a chart. In a pinch, you can include

    Code:
    [FONT=Courier New]using NinjaTrader.NinjaScript.Indicators;[/FONT]
    and then call

    Code:
    [FONT=Courier New]Indicator example = new SMA();[/FONT]
    to create a suitable object.

    Please note that generally speaking, you need an indicator or strategy, attached to a chart, with an active window handle. As such, any context in which an indicator's "this" method is not accessible is likely a context where you will run into errors. Indicators need to be initialized in real time and have state driven logic.

    With this in mind, I would highly encourage you to create a "helper" indicator that your code which does not implement NinjaScript base in turn calls, and to let it handle drawing lines on itself.

    If you would prefer avoiding NinjaScript entirely, NinjaTrader uses the WPF, and there is more information regarding using this to draw lines at this publicly available MSDN link.

    Jessica P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    557 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    324 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    545 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    547 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X