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
    Paul H.NinjaTrader Customer Service

    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 nicthe, 08-23-2023, 07:53 AM
      7 responses
      196 views
      0 likes
      Last Post nicthe
      by nicthe
       
      Started by nicthe, Today, 09:24 AM
      0 responses
      5 views
      0 likes
      Last Post nicthe
      by nicthe
       
      Started by stalt, 12-28-2015, 01:36 PM
      6 responses
      1,536 views
      0 likes
      Last Post giulyko00  
      Started by Tburg1073, Today, 08:36 AM
      0 responses
      7 views
      0 likes
      Last Post Tburg1073  
      Started by alexstox, 10-16-2018, 03:29 PM
      10 responses
      334 views
      0 likes
      Last Post Tburg1073  
      Working...
      X