Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EMA throws error if used AddChartIndicator

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

    EMA throws error if used AddChartIndicator

    Hello,

    I get errors and the strategy closes when I use AddChartIndicator.
    This happens unpredictably not on every PC not every time. But if happened it will persist.
    Click image for larger version

Name:	image.png
Views:	115
Size:	4.0 KB
ID:	1260021Seems like EMA has no access to the data.
    Click image for larger version

Name:	image.png
Views:	98
Size:	15.5 KB
ID:	1260024
    Click image for larger version

Name:	image.png
Views:	107
Size:	169.1 KB
ID:	1260022​​
    It happens outside of the strategy, so I can't even skip it.
    Click image for larger version

Name:	image.png
Views:	102
Size:	9.1 KB
ID:	1260023

    #2
    And here is an example of how an EMA added through AddChartIndicator is different from one added manually. Shift and bump. Why is it happening?
    Click image for larger version

Name:	image.png
Views:	111
Size:	7.7 KB
ID:	1260027

    Comment


      #3
      Hello frslvr,

      Thank you for your post.

      The error "You are accessing an index with a value that is invalid since itis out-of-range" error may be prevented by adding checks to make sure you have enough bars in the series you are accessing. This is explained on the following help guide page:


      For example, you could add a condition to check that the CurrentBar is greater than the period for the EMA prior to accessing the EMA values in the script. If you are getting unexpected values, like what you are showing in your second post, I suggest adding print statements to your script to better understand its behavior. You should also consider what settings you have for the indicator added manually and compare that to the indicator added programmatically to double-check if there are any differences between the two.

      For more information on using prints to debug your scripts:


      Please let us know if we may be of further assistance.

      Comment


        #4
        Hi Emily,

        Thank you for your reply.
        Please let me repeat myself. It happens inside the @EMA and outside of the strategy. Please see the screenshot of the Call stack.

        Comment


          #5
          Hello frslvr,

          Thank you for your reply.

          I was not able to reproduce this behavior with the attached test strategy. I understand you mentioned that, "This happens unpredictably not on every PC not every time. But if happened it will persist." Please test the attached strategy to see if you are able to reproduce the behavior; if there is a particular PC where it is happening and persisting with your strategy that adds the EMA, I am curious if then trying to use the AddEMAStrategyTest strategy would also result in the error. If you are able to reproduce this behavior with the attached test strategy, please send the diagnostic files for that installation of NinjaTrader to our support team for further investigation. You can do this by going to the Control Center-> Help-> Email Support. Ensuring 'Log and Trace Files' is checked will include these files. This is checked by default.

          Please feel free to reach out with any additional questions or concerns.​
          Attached Files

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          70 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          143 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          76 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          47 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          51 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X