• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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 rickyblah12, Today, 09:17 PM
          2 responses
          4 views
          0 likes
          Last Post rickyblah12  
          Started by rickyblah12, Today, 08:27 PM
          0 responses
          3 views
          0 likes
          Last Post rickyblah12  
          Started by giogio1, Today, 06:55 PM
          0 responses
          3 views
          0 likes
          Last Post giogio1
          by giogio1
           
          Started by priceisking, Today, 06:39 PM
          0 responses
          2 views
          0 likes
          Last Post priceisking  
          Started by vivekniwas, Today, 05:59 PM
          0 responses
          1 view
          0 likes
          Last Post vivekniwas  
          Working...
          X