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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    67 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    36 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    59 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    62 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X