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

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 Skifree, Today, 03:41 AM
          3 responses
          12 views
          0 likes
          Last Post Skifree
          by Skifree
           
          Started by traderqz, Yesterday, 09:06 AM
          5 responses
          32 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by guillembm, Today, 11:25 AM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by owensd, 04-21-2024, 11:34 PM
          9 responses
          34 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by trilliantrader, 04-10-2024, 09:33 PM
          7 responses
          25 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Working...
          X