Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy method not valid

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

    Strategy method not valid

    Hello All,

    Im having trouble with an error when compiling a strategy.
    'NinjaTrader.NinjaScript.Strategies.Strategy.Posit ion()' is a 'method', which is not valid in the given context.

    Ive simulated the error by copying from the help file.



    protected override void OnBarUpdate()
    {
    //Add your custom strategy logic here.

    // If not flat print our open PnL
    if (Position.MarketPosition != MarketPosition.Flat)
    Print("Open PnL: " + Position.GetUnrealizedProfitLoss(PerformanceUnit.P oints, Close[0]));


    }

    #2
    Hello Rastus,

    Thanks for your post.

    I've copied your example, compiled it into a new strategy, and applied it to a live chart. I see no error here.

    When you compile, check that the left column (Ninjscript file) on the error message(s) is showing the error of the file you are working with. Note that the compiler will report an error from any file.

    Reference: https://ninjatrader.com/support/help...ile_errors.htm

    Comment


      #3
      Hello Rastus,

      Thanks for your post.

      I've copied your example, compiled it into a new strategy, and applied it to a live chart. I see no error here.

      When you compile, check that the left column (Ninjscript file) on the error message(s) is showing the error of the file you are working with. Note that the compiler will report an error from any file.

      Reference: https://ninjatrader.com/support/help...ile_errors.htm
      Thanks Paul,
      I think i will try a fresh install on the weekend.
      The strategy has been tested on another system, so it looks like the problem is with mine.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      85 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      47 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      29 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      32 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      67 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X