Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Rendering a Hosted Indicator

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

    Rendering a Hosted Indicator

    If I'm utilising an indicator within another indicator - is there any way to make the hosted indicator render as normal?

    Until now I have been adding a copy of the indicator to my chart separately to check the rendering, but have just realised that the bug I've been chasing for 2 days wasn't actually a bug; but that the version of the indicator I added to the chart had different parameters to the one that was hosted within another indicator.

    I tried adding this, but it didn't do anything:

    Code:
    		protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    		{
    			_hostedIndicator.Render(RenderTarget, chartControl, chartScale);
    		}

    #2
    Thank you for your question reach4thelasers. The strategy I would use would be to call a public method from your hosted Indicator's OnRender, e.g.

    Code:
    public void OnRenderPublic(ChartControl chartControl, ChartScale chartScale)
    {
        // do your actual OnRender work here
    }
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    {
        OnRenderPublic(chartControl, chartScale);
    }
    This will guarantee that when your hosted indicator is by itself, it will work the same way that it works hosted. This will also give your strategy a way to pass its own chartControl and chartScale to your hosted indicator easily.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the response Jessica. The indicator I'm using within my strategy doesn't actually have an OnRender method of its own. Its just has various Draw() calls dotted throughout the OnBarUpdate.

      These drawing calls don't take effect - I did wonder if I could force it by calling OnRender manually, but it didn't do anything.

      Comment


        #4
        Thanks for the added information reach4thelasers. The same paradigm can be applied to your draw calls, so that your strategy is doing the drawing when your indicator is hosted, e.g.

        In your indicator,

        Code:
        [FONT=Courier New]
        public static void DoTheDraw(NinjaScriptBase self)
        {
            self.Draw.Dot(self, "Tag" + self.CurrentBar, true, self.Time[0], self.Close[0], Brushes.ForestGreen);
        }
        protected override void OnBarUpdate()
        {
            this.DoTheDraw(this);
        }[/FONT]
        And then, from your strategy,

        Code:
        [FONT=Courier New]
        myIndicator.DoTheDraw(this);[/FONT]
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          Hey Jessica... I like your idea but its a very complex third party indicator and the calls to Draw() are all over the place. Unless I can think of a better solution I'm going to have to just redraw what I need manually.

          Thanks for your help!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          648 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          369 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          572 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          574 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X