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

NT8 Draw Objects on Panel Indicator

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

    NT8 Draw Objects on Panel Indicator

    Hi, I would like to know how can I draw objects on indicator and price panel in Ninjatrader 8 from an Indicator or Strategy.

    I know that in NT7 the way to do this is for example SMA(20).DrawArrowUp(....)

    Thanks in advance.

    #2
    Hello ricardo88,

    Thank you for the post.

    In this case due to how the Draw system has been changed this would not work as you are expecting.

    In NT8 it would be suggested to instead duplicate said indicator and program it to draw rather than trying to chain the drawing call through the indicator like this.

    While It is possible to pass an indicator to a Draw. method as the "this" argument, the object would stay on the price panel. That indicator would still need to be programmed to be in a separate panel and also have DrawOnPricePanel set to false. Because the indicator would need modifying for this to work it would be advisable to just make a duplicate indicator that does what you want it to do.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks for the fast reply.

      I would like to know in a Draw method in NT8, how can I change Draw.Line(this, ... ) to refer to the Indicator Panel, for example something like Draw.Line(SMA(20), ... ) or Draw.Line(Panel(1), ... ) or similar.

      Comment


        #4
        Hello ricardo88,

        As noted in the last reply, the indicator would need to be modified for it to draw in the indicators panel.
        In your current example using the SMA, this indicator does not define DrawOnPricePanel = false and also does not define IsOverlay = false. This means that even if you do pass the indicator to the draw method like you are trying, the object will draw on the main price panel.

        The suggested approach for what you are trying to do would be to make a duplicate SMA that draws the object its self and defines the correct properties to be both displayed in a second panel and to have objects draw in its panel. The way you were drawing in NT7 would not be something I would suggest as this is not an intended way to draw objects.

        The standard approach to having an indicator display objects would require that the indicator defines:
        IsOverlay = false;
        DrawOnPricePanel = false;

        By doing this, that indicator can now draw in its own panel. You could at this point also supply this indicator to the draw method as the "this" parameter but I really wouldn't suggest that. Generally, the indicator should just draw its own objects based on its own logic.

        Please let me know if I may be of additional assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Final Solution

          Hi all, and thanks for the Help.

          I post the final solution for anyone having the same problem.

          OnStateChange() you need to add this

          Code:
          if (State == State.DataLoaded)
          			{
          				AddChartIndicator(SMA(20));
          				SMA(20).DrawOnPricePanel = false;
          				SMA(20).IsOverlay = false;
          }
          OnBarUpdate() you Draw on the indicator panel by this way:

          Code:
          Draw.Line(SMA(20),"YourCustomTag",false,Time[10],SMA(20)[10],Time[1],SMA(20)[1],Brushes.White,DashStyleHelper.Solid,2);
          This will work from a Strategy. Attached an example
          Attached Files

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Waxavi, Today, 02:10 AM
          0 responses
          3 views
          0 likes
          Last Post Waxavi
          by Waxavi
           
          Started by TradeForge, Today, 02:09 AM
          0 responses
          8 views
          0 likes
          Last Post TradeForge  
          Started by Waxavi, Today, 02:00 AM
          0 responses
          2 views
          0 likes
          Last Post Waxavi
          by Waxavi
           
          Started by elirion, Today, 01:36 AM
          0 responses
          4 views
          0 likes
          Last Post elirion
          by elirion
           
          Started by gentlebenthebear, Today, 01:30 AM
          0 responses
          4 views
          0 likes
          Last Post gentlebenthebear  
          Working...
          X