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

Drawing to Chart from Strategy

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

    Drawing to Chart from Strategy

    Hello,

    I'm looking to add drawing functionality into my strategy, but struggling to get anything to appear on my charts. So, I have multiple BarsArrays in my strategy and I always have multiple charts open with those different timeframes. When I put in a basic DrawLine command (something generic using the "Insert Action" feature), for example, unfortunately I can't see it drawn anywhere. I figure that I need to specify which BarsArray it draws to? I'm also unable to see anything drawn on any open chart with any other Draw commands.

    Thanks!

    #2
    Hello nickslad,

    Thanks for your post.

    You would want to draw to the chart bars, BarsArray[0] or BarsInProgress 0.
    Make sure any draw method uses unique tag names. If you use the same tag name then only the latest object would be drawn (and perhaps this is what you want).
    Make sure you specify the correct Y location. Y location is basically the price scale so to see the object it would need to be within the chart's scale.

    Here is an example of a drawing code you could add to your script to test out:

    if (BarsInProgress == 0 && Close[0] > Open[0])
    {
    DrawTriangleUp("TagName"+CurrentBar, true, 0, Low[0] - 5 * TickSize, Color.Blue);
    }


    On every up bar (green bar if using candlesticks), it will draw blue triangle up, 5 ticks below the low of the up bar. The name of the object will be "TagNameXXXX" where XXXX would be the bar number where the object is drawn, which makes for a unique tag name per bar.



    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi Paul,

      Thanks for your reply.

      I'm actually still having trouble getting anything to plot. I inserted your code at the top of my conditions in OnBarUpdate and did not see anything when testing the strategy back in Market Replay. I'm not seeing anything on the chart for the main timeframe (5 seconds) nor on charts for any other BarsArrays I have referenced.

      I tried taking the code to a separate strategy. I've also tried DrawHorizontalLine, for example, to try other conditions, but didn't get it to work.

      Unfortunately, I feel like I'm missing something!

      Comment


        #4
        Hello nickslad,

        Thanks for your post.

        Please make sure that you are "enabling" the strategy when you apply it to the chart.

        If you are enabling it and are not seeing any drawing objects and are not seeing any errors in the "log" tab of the control center, please post your code. If you prefer to not post your code you are welcome to write into PlatformSupport[at]NinjaTrader[dot]Com, mark the subject Atten: Paul and include a link to this thread and a copy of your code file (.CS type)
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Hello nickslad,

          Thank for your e-mail.

          The inability to draw on the chart, in this case, was caused by applying the strategy in the strategy tab and not on the chart itself. When a strategy is created in the strategy tab it is not assigned to any chart and any graphics it produces would not be displayed. Once you applied the strategy to a chart, it displayed the expected drawings.
          Paul H.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by RookieTrader, Today, 09:37 AM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by alifarahani, Today, 09:40 AM
          0 responses
          2 views
          0 likes
          Last Post alifarahani  
          Started by Gerik, Today, 09:40 AM
          0 responses
          1 view
          0 likes
          Last Post Gerik
          by Gerik
           
          Started by KennyK, 05-29-2017, 02:02 AM
          3 responses
          1,282 views
          0 likes
          Last Post NinjaTrader_Clayton  
          Started by AttiM, 02-14-2024, 05:20 PM
          11 responses
          184 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X