Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Drawing on panel 2 from strategy

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

    Drawing on panel 2 from strategy

    Hi there!

    I am attempting to draw some lines on the second panel in my strategy, currently attempting this with OnRender as I was unable with regular drawing tools. The second panel is a different instrument to my first panel.
    When I run the following code from one of your help guides:
    Code:
    [COLOR=#0000ff]protected[/COLOR][COLOR=#ffffff] [/COLOR][COLOR=#0000ff]override[/COLOR][COLOR=#ffffff] [/COLOR][COLOR=#0000ff]void[/COLOR][COLOR=#ffffff] [/COLOR]OnRender(ChartControl[COLOR=#ffffff] [/COLOR]chartControl,[COLOR=#ffffff] [/COLOR]ChartScale[COLOR=#ffffff] [/COLOR]chartScale)
    {
    [COLOR=#ffffff]  [/COLOR][COLOR=#008000]// Print the number of panels currently displayed on the chart[/COLOR]
    [COLOR=#ffffff]  [/COLOR]Print(String.Format([COLOR=#800000]"There are {0} panels on the chart"[/COLOR],[COLOR=#ffffff] [/COLOR]chartControl.ChartPanels.Count));[COLOR=#ffffff]  [/COLOR]
    }
    ​
    I am able to display that that I have 2 panels loaded.
    I assumed that I would be able to run the following code to draw on each panel respectively according to their chart index:
    Code:
     if (this.ChartPanel.PanelIndex == 0) // NQ Panel
     {
         RenderTarget.DrawLine(startHighNQ, endHighNQ, brushNQ, 2); // High NQ
         RenderTarget.DrawLine(startLowNQ, endLowNQ, brushNQ, 2); // Low NQ
     }
     if (this.ChartPanel.PanelIndex == 1) // ES Panel
     {
         RenderTarget.DrawLine(startHighES, endHighES, brushES, 2); // High ES
         RenderTarget.DrawLine(startLowES, endLowES, brushES, 2); // Low ES
     }​
    However, this is not the case. Is there another way I can approach accessing PanelIndex 1?

    Thanks in advance

    #2
    Hello kanjy,

    Drawing into multiple panels is not something the strategies OnRender can do, that applies to its panel only. You would have to have a indicator added to the chart into the second panel and then that indicator could draw there. You can find a sample of a strategy that uses indicators for the purpose of drawing in multiple panels here: https://ninjatrader.com/support/help..._a_ninjasc.htm

    Comment


      #3
      Hey Jesse,
      Cool, appreciate the response.
      Cheers,

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      43 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      20 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      29 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      46 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      38 views
      0 likes
      Last Post CarlTrading  
      Working...
      X