• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error enabling strategy in particular instrument timeframe

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

    Error enabling strategy in particular instrument timeframe

    Hello, I am have developed a strategy and I am trying to enable on sim account to trade forex.

    It enables fine on daily and intradaily on all instruments I have tried - except for EURUSD in minute intervals where I get the folliowing error in the logs:

    " Error on calling 'OnBarUpdate' method on bar 643: You are accessing an index with an index that is invalid since it is out-of-range.I.E.accesing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart "

    It enables on EURUSD daily.

    Any help is appreciated.

    #2
    Problem solved.

    I have located the code line creating the error.

    if (SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1].ProfitCurrency > 0) qty = 1;

    Checking for winning trade after submitting an ExitLong() order causes an error.

    Comment


      #3
      Hello im1`97,

      Welcome to the forums! I am also happy to hear the matter is resolved.

      An order method will take time to submit the order and receive an execution, so the trade likely would not be complete immediately after calling the Exit method in OnBarUpdate. The code could be protected by checking if SystemPerformance.AllTrades.Count is greater or equal to 1 so the reference will be made when the trade exists in the collection.

      If you have any other NinjaScript related inquiries, please don't hesitate to open a new thread.
      JimNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by JTizz, Today, 04:56 PM
      0 responses
      6 views
      0 likes
      Last Post JTizz
      by JTizz
       
      Started by Dan_D_Trader, Today, 03:29 PM
      0 responses
      4 views
      0 likes
      Last Post Dan_D_Trader  
      Started by Bsmckm, Today, 02:02 PM
      0 responses
      9 views
      0 likes
      Last Post Bsmckm
      by Bsmckm
       
      Started by markyb0y, Today, 01:55 PM
      0 responses
      4 views
      0 likes
      Last Post markyb0y  
      Started by SlickRick, Today, 11:07 AM
      2 responses
      11 views
      0 likes
      Last Post NinjaTrader_ShawnB  
      Working...
      X