Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Drawing Objects From the Strategy

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

    Drawing Objects From the Strategy


    Hi Ninja Experts, I need some help.

    I am building a custom strategy that will ultimately place trades in the market. But before trade placement, an important objective of the strategy is to draw (based on a logic scheme) some objects like arrows on the main price panel and some other objects like rectangles in a new panel.

    I have used AddChartIndicator() method to add a dummy indicator to the strategy. The IsOverlay property of the dummy indicator is set to true. The IsOverlay property of the strategy is set to false. All this setting gives me a new panel on the chart when the strategy is applied/activated. The purpose of adding a chart indicator is nothing but to get a new/separate panel on the chart for drawing objects. That is why I call it a dummy indicator.

    Now in OnBarUpdate(), I use

    Draw.ArrowUp(,,,,bool drawOnPricePanel = true) and Draw.Rectangle(,,,,bool drawOnPricePanel = false).

    I am expecting the arrows on the price panel and rectangles on the new panel. But the output I am getting is that both are being plotted on the new panel. A very interesting observation here is that when I activate the strategy from Ninja Control Center, the arrows get plotted on the main price panel, but with in a second or a blink of eye, they transfer on to the new panel where rectangles are already drawn. Is this something related to rendering etc.

    Please guide me how can I make things work. Any other alternative feasible approach is also welcome.

    #2
    Hello Mubeen Haider,

    In general what you are describing could be accomplished with a strategy and an indicator. To use the overload you used you would have to place the strategy in the primary panel and then have the indicator use IsOverlay = false. Inside the indicators OnBarUpdate you can then use the drawing code to draw in the indicator panel or the price panel.

    You can see the following example which demonstrates using indicators to draw on the chart based on strategy data. This would be the suggested way to have a strategy condition drawn, the indicators reference data inside the parent strategy to draw it. In your use case you could either move the logic for drawing directly into the indicator or expose a value for the indicator to read to know what to draw. https://ninjatrader.com/support/help..._a_ninjasc.htm



    Comment


      #3
      As always, thanks Jesse! You people are champions. I followed your advice and got promising results within one day. Thanks you

      Comment


        #4
        The approach described at https://forum.ninjatrader.com/forum/...rom-a-strategy
        might be suitable as well

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        23 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        120 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        63 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        41 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        45 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X