Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Print from a Method or Function

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

    Print from a Method or Function

    Hello Group,

    I am trying to pass an array by referance to a method (funtction). I placed a print statement inside of the method but get an error message from the print line (CS0120). This error message says:
    An object reference is required for the nonstatic field, method, or property 'member'
    In order to use a non-static field, method, or property, you must first create an object instance.

    I belive that the method does not reconize that the print() statement belongs to the using NinjaTrader.Strategy Class. I think that I need a private or public in front of the static but that did not work?
    How do I fix this. I am using the print statement to test that the array is being passed to the method.

    Here is my code below.

    staticdouble ProbLast50(refdouble[] array_ClosePrice)
    {
    double P_ProbLast50 = 0;
    int[] LongORShort = newint[50];
    int i;

    for (i = 0; i < 50; i++)
    {
    LongORShort[i] =
    0;
    Print(
    "ClosePrice["+ i.ToString("00")+ "] " + array_ClosePrice[i].ToString("00.00"));
    }
    return P_ProbLast50;

    }
    // End of ProbLast500


    Thanks for your help,

    Bayes

    #2
    Bayes, welcome to our forums - Print() is unfortunately not available in this context, as it's part of the indicator base class. You might want to use a helper class to make that available, or use another form of debug aid, such as writing the info needed to external files for example.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    647 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    367 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    108 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    571 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    573 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X