Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Custom Indicator Plots are shown in DataBox, but not displayed on chart

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

    Custom Indicator Plots are shown in DataBox, but not displayed on chart

    Hi,

    I wrote an indicator with 2 timeframes (stf,htf). The indicator is calculating many objects (swing, trends, signals, signals setups) and reder them on chart using OnRender. I am using 3 EMAs values (2 of htf, and 1 of stf), they are set as plots with colors and external properties. I can see these 3 plots correct values in the DataBox, but there is no displayed plots, as you can see below (SlowMA0, FastMA1, SlowMA1 are shown with the colors, and correct & in range values in Data Box, but not on Chart):

    Click image for larger version

Name:	Screen Shot 2022-07-18 at 12.01.57 AM.png
Views:	400
Size:	1.51 MB
ID:	1208744

    Here is the relevant code:
    Code:
    public int AddChartPlot(Brush brush, string name)
    {
      AddPlot(brush, name);
      return Plots.Count()-1;
    }
    //...
    protected override void OnStateChange()
    {
      switch (State)
      {
      //...
      case State.Configure:
        plotSlowMA0 = AddChartPlot(Brushes.Goldenrod, "SlowMA0");
        plotFastMA1 = AddChartPlot(Brushes.White, "FastMA1");
        plotSlowMA1 = AddChartPlot(Brushes.Blue, "SlowMA1");
        //...
        break;
      //...
      }
    }
    
    protected override void OnBarUpdate()
    {
      int stf = 0;
      int htf = 1;
      if (CurrentBars[stf] <= BarsRequiredToPlot || CurrentBars[htf] <= BarsRequiredToPlot) return;
    
      if (BarsInProgress == stf || BarsInProgress == htf)
      {
        //...
        SlowMA0[0] = EMA(BarsArray[stf],maPeriod1)[0];
        FastMA1[0] = EMA(BarsArray[htf],maPeriod2)[0];
        SlowMA1[0] = EMA(BarsArray[htf],maPeriod1)[0];
        //...
      }
    
    protected override void OnRender(Gui.Chart.ChartControl chartControl, Gui.Chart.ChartScale chartScale)
    {
      if (!IsVisible || ChartBars.ToIndex < BarsRequiredToPlot) return;
      //...
    }
    
    [Browsable(false)][XmlIgnore()] public Series<double> SlowMA0 { get { return Values[plotSlowMA0]; } }
    [Browsable(false)][XmlIgnore()] public Series<double> FastMA1 { get { return Values[plotFastMA1]; } }
    [Browsable(false)][XmlIgnore()] public Series<double> SlowMA1 { get { return Values[plotSlowMA1]; } }

    #2
    Hello Shai Samuel,

    You used OnRender but did not call the base. If you want plots to be visible you still need to call the base.OnRender to have the platforms normal plotting logic happen.

    https://ninjatrader.com/support/help...htsub=onrender

    ns Calling the base.OnRender() method to ensure Plots are rendered along with custom render logic
    Code:
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    {
    // call the base.OnRender() to ensure standard Plots work as designed
    base.OnRender(chartControl, chartScale);
    
    // custom render logic
    }

    Comment


      #3
      Thank you

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      601 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      347 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      103 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      559 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      558 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X