Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Failed to call method 'Initialize'

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

    Failed to call method 'Initialize'

    I downloaded an indicator from a forum which appears to work just fine. the code is open and I can look at it. However, I keep getting the following message in the log file:

    "Failed to call method 'Initialize' for indicator BTAutoPivots.' Object reference not set to an instance of an object."

    What kind of thing should I be looking for in the code that might cause this kind of message? It doesn't seem to be affecting the performance of the indicator itself but how would I know. other than it doesn't work at all?

    I'm adding the first part of the code and it clearly does have an initialization section.

    Thanks
    DaveN
    #region Variables
    // Wizard generated variables
    private string contractExpDate = "SEP10"; // Default setting for ContractExpDate
    private int numDecimals = 2;
    // User defined variables (add any user defined variables below)
    private SolidBrush[] brushes =
    { new SolidBrush(Color.Black), new SolidBrush(Color.Black), new SolidBrush(Color.Black), new SolidBrush(Color.Black),
    new SolidBrush(Color.Black), new SolidBrush(Color.Black), new SolidBrush(Color.Black), new SolidBrush(Color.Black),
    new SolidBrush(Color.Black), new SolidBrush(Color.Black), new SolidBrush(Color.Black), new SolidBrush(Color.Black)
    };
    private StringFormat stringFormatFar = new StringFormat();
    private StringFormat stringFormatNear = new StringFormat();
    private SolidBrush textBrush = new SolidBrush(Color.Black);
    private Font textFont = new Font("Arial", 30);
    private string errorData = "Insufficient historical data to calculate pivots. Increase chart look back period (days back).";
    private float errorTextWidth = 0;
    private float errorTextHeight = 0;
    private int width = 20;
    double pp, yopen, yclose, yhigh, ylow, s1, s2, s3, s4, r1, r2, r3, r4;
    #endregion

    /// <summary>
    /// This method is used to configure the indicator and is called once before any bar data is loaded.
    /// </summary>
    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Gold), PlotStyle.Line, "PP"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Violet), PlotStyle.Line, "Y_High"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Violet), PlotStyle.Line, "Y_Low"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Cyan), PlotStyle.Line, "Y_Close"));
    Add(new Plot(Color.FromKnownColor(KnownColor.DarkCyan), PlotStyle.Line, "S1"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Chartreuse), PlotStyle.Line, "S2"));
    Add(new Plot(Color.FromKnownColor(KnownColor.DarkRed), PlotStyle.Line, "S3"));
    Add(new Plot(Color.FromKnownColor(KnownColor.DarkViolet), PlotStyle.Line, "S4"));
    Add(new Plot(Color.FromKnownColor(KnownColor.DarkCyan), PlotStyle.Line, "R1"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Chartreuse), PlotStyle.Line, "R2"));
    Add(new Plot(Color.FromKnownColor(KnownColor.DarkRed), PlotStyle.Line, "R3"));
    Add(new Plot(Color.FromKnownColor(KnownColor.DarkViolet), PlotStyle.Line, "R4"));

    Plots[0].Pen = new Pen(Color.Gold, 2); Plots[0].Pen.DashStyle = DashStyle.Solid;
    Plots[1].Pen = new Pen(Color.Violet, 2); Plots[1].Pen.DashStyle = DashStyle.Dash;
    Plots[2].Pen = new Pen(Color.Violet, 2); Plots[2].Pen.DashStyle = DashStyle.Dash;
    Plots[3].Pen = new Pen(Color.Cyan, 2); Plots[3].Pen.DashStyle = DashStyle.Dash;
    Plots[4].Pen = new Pen(Color.DarkCyan, 2); Plots[4].Pen.DashStyle = DashStyle.Solid;
    Plots[5].Pen = new Pen(Color.Chartreuse, 2); Plots[5].Pen.DashStyle = DashStyle.Solid;
    Plots[6].Pen = new Pen(Color.DarkRed, 2); Plots[6].Pen.DashStyle = DashStyle.Solid;
    Plots[7].Pen = new Pen(Color.DarkViolet, 2); Plots[7].Pen.DashStyle = DashStyle.Solid;
    Plots[8].Pen = new Pen(Color.DarkCyan, 2); Plots[8].Pen.DashStyle = DashStyle.Solid;
    Plots[9].Pen = new Pen(Color.Chartreuse, 2); Plots[9].Pen.DashStyle = DashStyle.Solid;
    Plots[10].Pen = new Pen(Color.DarkRed, 2); Plots[10].Pen.DashStyle = DashStyle.Solid;
    Plots[11].Pen = new Pen(Color.DarkViolet, 2); Plots[11].Pen.DashStyle = DashStyle.Solid;

    CalculateOnBarClose = true;
    Overlay = true;
    PriceTypeSupported = false;
    AutoScale = false;
    stringFormatFar.Alignment = StringAlignment.Far;

    #2
    Dave, the Initialize() you posted looks ok to me - is this part of any chart template / workspace? Can you please try if you see the same error in the log if you load the indicator in a fresh workspace and on a fresh chart?

    Thanks
    BertrandNinjaTrader Customer Service

    Comment


      #3
      I will try that later today and see what happens.
      Thanks

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by frslvr, 04-11-2024, 07:26 AM
      9 responses
      123 views
      1 like
      Last Post caryc123  
      Started by rocketman7, Today, 09:41 AM
      4 responses
      15 views
      0 likes
      Last Post rocketman7  
      Started by selu72, Today, 02:01 PM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_Zachary  
      Started by WHICKED, Today, 02:02 PM
      2 responses
      16 views
      0 likes
      Last Post WHICKED
      by WHICKED
       
      Started by f.saeidi, Today, 12:14 PM
      8 responses
      21 views
      0 likes
      Last Post f.saeidi  
      Working...
      X