Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Setting indicator margin programatically

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

    Setting indicator margin programatically

    Hi, I would like to set a margin of 30 Percent automatically in my indicator code. My code is like so:

    Code:
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    {
    
    chartScale.Properties.AutoScaleMarginType = AutoScaleMarginType.Percent;
    chartScale.Properties.AutoScaleMarginUpper = 30;
    chartScale.Properties.AutoScaleMarginLower = 30;
    
    }
    This code does not generate any errors in the log, but it also prevents my plots from rendering. I just get an empty indicator panel. Did I do it wrong, or is this still not really a supported method? If so, are there any work-arounds to get the same end result? I thought of adding an extra plot above and below that are transparent, but I would rather not have extra plots if possible.

    #2
    Hello torch2k,

    Thank you for your reply.

    Since you're overriding the regular functions of OnRender() with this code, you will need to call the base OnRender() prior to your custom logic so that the plots also render along with your modifications.

    Code:
    protected override void OnRender(ChartControl char tControl, ChartScale chartScale)
    {
      // call the base.OnRender() to ensure standard Plots work as designed
      base.OnRender(chartControl, chartScale);
    
      // custom render logic
    }


    Please let us know if we may be of further assistance to you.

    Comment


      #3
      perfect, thank you!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      81 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      42 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      64 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      68 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      55 views
      0 likes
      Last Post CarlTrading  
      Working...
      X