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 Impeesa, Today, 03:17 AM
      0 responses
      6 views
      0 likes
      Last Post Impeesa
      by Impeesa
       
      Started by Impeesa, Today, 12:53 AM
      0 responses
      12 views
      0 likes
      Last Post Impeesa
      by Impeesa
       
      Started by Gaterz, Yesterday, 06:52 PM
      1 response
      13 views
      0 likes
      Last Post NinjaTrader_Marco  
      Started by dmelleady, Yesterday, 10:18 PM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_ChrisSch  
      Started by arangocj, Yesterday, 09:46 PM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Working...
      X