Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Mro

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

    Mro

    The documentation on MRO shows the following,
    "int barsAgo = MRO(delegate {return Close[0] > Open[0];}, 1, 9);
    if (barsAgo > -1)

    I used this in the variables section:
    int barsAgoUp = MRO(delegate {return HeikenAshi().HAClose[0] > HeikenAshi().HAOpen[0];}, 1, 4);
    and also
    int barsAgoDown = MRO(delegate {return HeikenAshi().HAClose[0] <= HeikenAshi().HAOpen[0];}, 1, 4);

    In the On Bar Update section, I used:
    if (barsAgoUp > -1) as part of the code for the long entry
    and then
    if (barsAgoDown > -1) as part of the code for the short entry

    The error I am getting reads: An object reference is required for the non-static field...

    Can anyone please help me with this?

    #2
    Hello birdjaguar,

    I've tested using the HeikenAshi() from the code you have posted in an indicator but I am finding this appears to work without error.

    Are you getting an error when testing this script on your end?
    Attached Files
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I am trying to use this code in a strategy and yes I am getting the error message I mentioned on the two lines in the variables section. I am not able to import the file you attached. I get a message that says I have to resolve the programming errors I have before I can import a NinjaScript archive file. Any advice on where I can go from here?

      Comment


        #4
        Hello birdjaguar,

        Thank you for your patience.

        Please attach a screenshot of the error message in the NinjaScript Editor with the Name and Description fields clearly readable.
        You can also double click on the message to have the NinjaScript Editor take you directly to the line that is generating the message.

        To send a screenshot with Windows 7 or newer I would recommend using Window's Snipping Tool.

        Click here for instructions

        Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save as a jpeg file and attach the file to your response.

        Click here for detailed instruction

        Comment


          #5
          Well, I did learn that I cannot import a file if I have any programming errors in any file in my strategies. I have to actually delete that strategy in order to import. Thank you Patrick for your response, but I have moved on to a lookback statement instead. I still don't know why the MRO code did not work, but I will cross this bridge if I need it at a later time. Thanks again.

          Comment

          Latest Posts

          Collapse

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