Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Best way to aquire ChartScale object before OnRender() triggers

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

    Best way to aquire ChartScale object before OnRender() triggers

    Hi folks,
    I'm wondering if there is a "better" or more direct way to acquire an indicator's ChartScale object after State.DataLoaded?

    This is how I'm getting the CS object, and it appears to work fine, but it seems like there should be a more direct way.
    Code:
    [COLOR=#000000]if(State == State.Transition)
    {[/COLOR][INDENT][FONT=Arial][COLOR=#000000]// [/COLOR][COLOR=#4e5f70][I]Indicator runs on the primary bars panel.[/I][/COLOR][/FONT][/INDENT][INDENT][COLOR=#000000]ScaleJustification sj = ChartBars.Properties.ScaleJustification;
    
    foreach (ChartScale scale in this.ChartPanel.Scales) // _chartPanel.Scales)
    {[/COLOR][/INDENT][INDENT=2][COLOR=#000000]if (scale.ScaleJustification == sj)
    {[/COLOR][/INDENT][INDENT=3][COLOR=#000000][B]chartScale = scale;[/B]
    
    // Print(" - FloatingChart: maxPrice = "+chartScale.MaxValue+" \tminPrice = "+chartScale.MinValue );
    // Print(" - FloatingChart cScale size = W: "+chartScale.Width+" \tH: "+chartScale.Height );[/COLOR][/INDENT][INDENT=2][COLOR=#000000]}[/COLOR][/INDENT][INDENT][COLOR=#000000]}[/COLOR][/INDENT]
     
    [COLOR=#000000]}[/COLOR]
    Thanks.

    PS, an example code should be added to the ChartScale documentation page at... https://ninjatrader.com/support/help...chartscale.htm

    #2
    Hello zacharydw00,

    The best way to access the ChartScale object would be from OnRender. The way you have found may work initially however from a scripts context the most direct and expected way to access its scale would be from OnRender. The ChartScale object is heavily tied to OnRender and a lot of different concepts surrounding rendering, having an accurate ChartScale variable for rendering purposes would require using the passed in variable and would also be more efficient if its run many times .

    If you need the scale earlier for some use case you could use a combination of what you found to work along with OnRender for a more complete solution.

    Please let me know if I may be of additional assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    566 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    330 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
    547 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    548 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X