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 alifarahani, Today, 09:40 AM
      4 responses
      21 views
      0 likes
      Last Post alifarahani  
      Started by gentlebenthebear, Today, 01:30 AM
      3 responses
      16 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by PhillT, Today, 02:16 PM
      2 responses
      7 views
      0 likes
      Last Post PhillT
      by PhillT
       
      Started by Kaledus, Today, 01:29 PM
      3 responses
      11 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by frankthearm, Yesterday, 09:08 AM
      14 responses
      47 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Working...
      X