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:	410
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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      57 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      78 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      39 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      101 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      61 views
      0 likes
      Last Post PaulMohn  
      Working...
      X