Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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:	244
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
    }
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by DJ888, Yesterday, 10:57 PM
      0 responses
      6 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by MacDad, 02-25-2024, 11:48 PM
      7 responses
      158 views
      0 likes
      Last Post loganjarosz123  
      Started by Belfortbucks, Yesterday, 09:29 PM
      0 responses
      7 views
      0 likes
      Last Post Belfortbucks  
      Started by zstheorist, Yesterday, 07:52 PM
      0 responses
      7 views
      0 likes
      Last Post zstheorist  
      Started by pmachiraju, 11-01-2023, 04:46 AM
      8 responses
      151 views
      0 likes
      Last Post rehmans
      by rehmans
       
      Working...
      X