Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Historical vs Realtime confusion

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

    Historical vs Realtime confusion

    I'm using OnRender to draw swing high/low lines. For Historical bars, I want the line to stop at the bar, which is endTime. It does when I set pad = 0; But for Realtime bars I want the line to extend past the current endTime. I tried the code below so I would have a different pad for Historical bars and Realtime. But the historical bars also use the pad = 2 * barSpacingP.

    What am I doing wrong? It seems pretty simple.

    HTML Code:
            private void RenderSwingHL(List<SwingHL> myList, ChartControl chartControl, ChartScale chartScale)
            {
                for (int index = myList.Count - 1; index >= 0 ; index--)
                {
                    int pad         = State == State.Historical ? 0 : 2 * barSpacingP;
                    int price         = chartScale.GetYByValue(myList[index].price);
                    int startTime     = chartControl.GetXByTime(myList[index].startTime);
                    int endTime     = chartControl.GetXByTime(myList[index].endTime);// + pad;
                    int eqhl        = myList[index].eqhlCount;
                
                    DxVector1     = new SharpDX.Vector2(startTime, price);
                    DxVector2     = new SharpDX.Vector2(endTime, price);
                    
                    if (eqhl >= 3)            RenderTarget.DrawLine(DxVector1, DxVector2, DxBrushAzure, 2);
                    else if (eqhl == 2)        RenderTarget.DrawLine(DxVector1, DxVector2, DxBrushAzure, 1);
                    else                    RenderTarget.DrawLine(DxVector1, DxVector2, DxBrushDimGray, 1, DxLineDash);
                }
            }
    ​

    Click image for larger version

Name:	image.png
Views:	120
Size:	7.9 KB
ID:	1304045Click image for larger version

Name:	image.png
Views:	71
Size:	8.6 KB
ID:	1304046​​

    #2
    Hello cre8able,

    To start there is no concept of realtime or historical in OnRender. That is a realtime only override, the script needs to have processed and started working before anything will be rendered.

    The general concept of using OnRender is to take data that you have pre processed from OnBarUpdate, for example plot data, and then render what you want. It is generally expected that you use a loop in OnRender to render only the data for the currently visible bars, you can see an example of that loop here: https://ninjatrader.com/support/help...tsub=fromindex

    If you wanted to use different rendering for historical bars vs the realtime bar you would have to know the Count of the series and then also make sure the bar index you are using for rendering matches the Count - 1.

    Comment


      #3
      Got it.. thank you

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      557 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      324 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      545 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      547 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X