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

Sometimes Plots then does NOT PLOT

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

    Sometimes Plots then does NOT PLOT

    I have been able to get this indicator to plot...but then will not plot at all...definitely will not plot on a weekly or monthly chart.

    Code:
     protected override void Initialize()
            {
                Add(new Plot(Color.FromKnownColor(KnownColor.White), PlotStyle.Bar, "D"));
              
                
                
                
                AutoScale            = false;
                Overlay                = false;
                CalculateOnBarClose = true;
            }
            
            
            
            // FormatPriceMarker method of a custom indicator
                public override string FormatPriceMarker(double price)
            {
    
                // Formats price values to 1 decimal places
                    return price.ToString("N2");
            }           
     if (Bars == null)
     return; 
    
    if (High[0] > High[1])
    {
    DrawText("myDot"+CurrentBar, false, "·", -1, (High[0]*2) - High[1], 0, Color.Green, dotFont, StringAlignment.Center, Color.Transparent, Color.Transparent, 10); 
    }
    If u can see where I went wrong this would be appreciated very much.

    TX

    #2
    If it is not plotting, please check the log tab of the Control Center for any errors. It does not draw on the daily or higher time frames do the following error:

    Error on calling 'OnBarUpdate' method for indicator 'allTheTests' on bar 0: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
    To fix this, add the following above the condition you're checking:

    Code:
    if(CurrentBar < 1)
    return;
    You may need to increase the value from 1 to a higher value depending on how many bars back you're checking. Details on why this error happen can be found below:



    I've ran your method on my end and it is working, although it's hard to see as the value drawn is just a "-" which is pretty small depending on the scale of the chart.

    You might want to increase the font size to your dotFont, or replace the "-" with a larger character.
    MatthewNinjaTrader Product Management

    Comment


      #3
      Thank u very much!!! the
      Code:
      if(CurrentBar < 1)
      return;
      took care of my problem!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Jonafare, 12-06-2012, 03:48 PM
      5 responses
      3,984 views
      0 likes
      Last Post rene69851  
      Started by Fitspressorest, Today, 01:38 PM
      0 responses
      2 views
      0 likes
      Last Post Fitspressorest  
      Started by Jonker, Today, 01:19 PM
      0 responses
      2 views
      0 likes
      Last Post Jonker
      by Jonker
       
      Started by futtrader, Today, 01:16 PM
      0 responses
      6 views
      0 likes
      Last Post futtrader  
      Started by Segwin, 05-07-2018, 02:15 PM
      14 responses
      1,791 views
      0 likes
      Last Post aligator  
      Working...
      X