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 kempotrader, Today, 08:56 AM
      0 responses
      6 views
      0 likes
      Last Post kempotrader  
      Started by kempotrader, Today, 08:54 AM
      0 responses
      4 views
      0 likes
      Last Post kempotrader  
      Started by mmenigma, Today, 08:54 AM
      0 responses
      2 views
      0 likes
      Last Post mmenigma  
      Started by halgo_boulder, Today, 08:44 AM
      0 responses
      1 view
      0 likes
      Last Post halgo_boulder  
      Started by drewski1980, Today, 08:24 AM
      0 responses
      3 views
      0 likes
      Last Post drewski1980  
      Working...
      X