Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnRender with multiple DataSeries and multiple Panels

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

    OnRender with multiple DataSeries and multiple Panels

    I wrote an indicator that renders very well when it is added to the the main Data Series.
    When adding another Data Series, to be shown on a different panel, the rendering shows nothing.

    I am using ChartBars.FromIndex,ChartBars.ToIndex,chartControl ,chartScale to calculate what needs to be rendered and rendering using Direct2D1 drawing objects.

    Is there an example of multiple timeframes rendered over multiple panels?

    #2
    Most likely the issue here could be that you're accessing the ChartBars series and it's not as simple as when there is only one data series on the chart. For instance, if you have 100-tick bars and 1-minute bars on the same chart, some are in between the others, and the charting has to account for each of those. Perhaps support has an example to share that demonstrates how to do this safely.
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      Hello Shai Samuel,

      Thanks for your post.

      Indicators are only able to render on the panel that they are applied to.

      You would need to use another indicator (or another instance of the same indicator) in the other panel to have the indicator rendered on the other panel.

      Please let me know if I may further assist.
      <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

      Comment


        #4
        Thank you Brandon,

        I've added a second timeframe to the same chart and added 2 indicators to each chart. One indicator is just a plot (EMA) and the other is my indicator with no plot, but rendering as you can see on the upper timeframe. The rendering on the second timeframe panel doesn't happen. As you can see, each panel has its own set of indicators.

        My guess is there is a missing set panel or so missing... Can you help?

        Click image for larger version

Name:	Screenshot 2023-04-10 at 22.27.04.png
Views:	335
Size:	52.3 KB
ID:	1245534Click image for larger version

Name:	Screenshot 2023-04-10 at 22.29.34.png
Views:	350
Size:	998.0 KB
ID:	1245535
        Attached Files

        Comment


          #5
          Hello Shai Samuel,

          Thanks for your note.

          Do you see any error messages in the Log tab of the Control Center?

          If so, what exactly does the error message report?

          Please send me a reduced exported copy of the script so that I may investigate this further.

          To export a NinjaScript, go to Tools > Export > NinjaScript AddOn.

          Note that a reduced copy refers to a copy of the script that contains the minimum amount of code needed to reproduce the issue. All other code is commented out or removed.

          To create a copy of your script to modify, open a New > NinjaScript Editor, select your script, right-click in the Editor, select 'Save as', name the script, and click OK.​

          I look forward to assisting further.
          <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

          Comment


            #6
            Hello Brandon,

            1. Even after I have created many compiled exports of my software, I don't know how to handle the export error of missing strategy.cs which is only mentioned in the NT generated script:
            Click image for larger version

Name:	Screenshot 2023-04-11 at 12.13.33.png
Views:	328
Size:	201.5 KB
ID:	1245593

            2. So instead I'm attaching a very small piece of new code to demo the issue. The code simply renders a line from the first bar high to the last bar high using OnRender(). Open a chart. Add a second Data Series to the same chart. Then add 2 copies of this indicator and assign the second one to the second Data Series. You should get something like this:

            Click image for larger version

Name:	Screenshot 2023-04-11 at 12.09.38.png
Views:	415
Size:	837.8 KB
ID:	1245592

            Code:
            namespace NinjaTrader.NinjaScript.Indicators
            {
                public class RenderingIssueExample : Indicator
                {
                    protected override void OnStateChange()
                    {
                        if (State == State.SetDefaults)
                        {
                            Description                                = @"Demo code to show rendering issues when added to a second data series to the same chart";
                            Name                                        = "RenderingIssueExample";
                            Calculate                                    = Calculate.OnBarClose;
                            IsOverlay                                    = true;
                            DisplayInDataBox                    = true;
                            DrawOnPricePanel                    = true;
                            DrawHorizontalGridLines        = true;
                            DrawVerticalGridLines                = true;
                            PaintPriceMarkers                    = true;
                            ScaleJustification                        = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                            IsSuspendedWhileInactive        = true;
                        }
                        else if (State == State.Configure)
                        {
                        }
                    }
            
                    protected override void OnBarUpdate()
                    {
                        //Add your custom indicator logic here.
                    }
                    protected override void OnRender(Gui.Chart.ChartControl chartControl, Gui.Chart.ChartScale chartScale)
                    {
                        int fromBar = ChartBars.FromIndex;        
                        int toBar = ChartBars.ToIndex;                        
                        Point p1 = new Point(BarToX(fromBar, chartControl), PriceToY(High.GetValueAt(fromBar), chartScale));
                        Point p2 = new Point(BarToX(toBar, chartControl), PriceToY(High.GetValueAt(toBar), chartScale));
            
                        RenderTarget.DrawLine(p1.ToVector2(), p2.ToVector2(), Brushes.Blue.ToDxBrush(RenderTarget), 2);
                    }
            
                    protected double BarToX(int bars, Gui.Chart.ChartControl chartControl, bool atMiddle = false)
                    {
                        return chartControl.GetXByBarIndex(chartControl.BarsArray[0], bars)
                            - (atMiddle ? (chartControl.Properties.BarDistance / 2) : 0);
                    }
            
                    protected double PriceToY(double val, Gui.Chart.ChartScale chartScale, bool useWpf = false)
                    {            
                        return (useWpf?chartScale.GetYByValueWpf(val):chartScale.GetYByValue(val));
                    }
                }
            }
            ​

            Comment


              #7
              Hello Shai Samuel,

              Thanks for that information.

              In regard to the export error message, this indicates that you have a compile error on your platform. If you open a New > NinjaScript Editor window and run a compile do you see error messages appear?

              Please run a repair using the steps below to try resolving this error.
              1. Shut down NinjaTrader
              2. Navigate to Add/Remove Programs within the user's PC's Control Panel.
              3. Click "NinjaTrader 8" in the list of installed programs to select it.
              4. Click "Repair".
              5. Finally, restart NinjaTrader and recompile.
              As for the code you shared, I added this code to an indicator script and tested it on my end and see the behavior you are reporting. The behavior is likely caused by some code in your script. as I am not able to reproduce the behavior with the SampleCustomRender script that comes default with NinjaTrader or with the script in the forum thread linked below.



              You may consider using the RenderScrollableObjectExample script found in the forum thread linked above as a base for your script and then add your code to the script.

              Please let me know if I may assist further.
              <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

              Comment

              Latest Posts

              Collapse

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