Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help with Custom Render

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

    Help with Custom Render

    The attached NinjaScript is attempting to Print() the x position of each bar from inside of OnRender() to confirm I can locate it before doing other things with it. Here is a screenshot of my errors. Thanks for the help.
    Attached Files

    #2
    Hello swcooke,

    Thanks for your post.

    Your errors are reporting to line 55. The first error is telling you that GetXByBarIndex has some invalid arguments and the second error reports that a Bars object cannot be converted to a ChartBars object.

    To troubleshoot these compiler errors, I recommend looking up these items in the help guide to see the proper syntax. Also, I see that you are creating a ChartBars object "chartBars" that does not have any context. "ChartBars" should be used.

    I suggest using the SampleCustomRender indicator as a working example to reference as you are experimenting with custom rendering. It may be useful to clone this example and reduce it to get a better idea on how you can create your own rendering syntax.


    The information linked above is publicly available.

    Please let us know if you have any additional questions.

    Comment


      #3
      Just a suggestion you can try...

      Add the following at the start of OnRender():
      Code:
      if(Bars == null || ChartBars.Bars == null || Bars.Instrument == null || CurrentBar < 1) { return; }
      base.OnRender(chartControl, chartScale);
      Remove:
      Code:
      ChartBars chartBars;
      And use:
      Code:
      for (int idx = ChartBars.FromIndex; idx <= ChartBars.ToIndex; idx++)
                              {
                                      int x = chartControl.GetXByBarIndex(ChartBars, idx);
                                      Print(x);
                              }
      Hope this helps.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      71 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      152 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      162 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      100 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      288 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X