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.

    Enhance your user interface with ready-to-use shapes and several layers of rendering services in Windows Presentation Foundation (WPF).
    Jessica P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by sjsj2732, Yesterday, 04:31 AM
    0 responses
    27 views
    0 likes
    Last Post sjsj2732  
    Started by NullPointStrategies, 03-13-2026, 05:17 AM
    0 responses
    284 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    280 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    132 views
    1 like
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    90 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Working...
    X