Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 algospoke, Yesterday, 06:40 PM
    2 responses
    19 views
    0 likes
    Last Post algospoke  
    Started by ghoul, Today, 06:02 PM
    3 responses
    14 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by jeronymite, 04-12-2024, 04:26 PM
    3 responses
    45 views
    0 likes
    Last Post jeronymite  
    Started by Barry Milan, Yesterday, 10:35 PM
    7 responses
    20 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by AttiM, 02-14-2024, 05:20 PM
    10 responses
    181 views
    0 likes
    Last Post jeronymite  
    Working...
    X