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 xxzbill, Today, 08:30 PM
      0 responses
      1 view
      0 likes
      Last Post xxzbill
      by xxzbill
       
      Started by fercho, Yesterday, 09:28 AM
      3 responses
      29 views
      0 likes
      Last Post fercho
      by fercho
       
      Started by omololu, Today, 07:10 PM
      4 responses
      12 views
      0 likes
      Last Post omololu
      by omololu
       
      Started by Amedeus, Today, 06:28 PM
      0 responses
      2 views
      0 likes
      Last Post Amedeus
      by Amedeus
       
      Started by xxzbill, Today, 04:43 PM
      0 responses
      14 views
      0 likes
      Last Post xxzbill
      by xxzbill
       
      Working...
      X