• 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 zweistein, 11-14-2017, 03:24 PM
      2 responses
      1,476 views
      0 likes
      Last Post woodie1
      by woodie1
       
      Started by Newtrader101, Today, 04:50 AM
      3 responses
      18 views
      0 likes
      Last Post NinjaTrader_ChrisL  
      Started by utilizator, Today, 06:31 AM
      3 responses
      13 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by digibob, Today, 01:13 AM
      3 responses
      14 views
      0 likes
      Last Post digibob
      by digibob
       
      Started by calebsandfort, Yesterday, 05:16 PM
      2 responses
      11 views
      0 likes
      Last Post NinjaTrader_PaulH  
      Working...
      X