Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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:	83
Size:	4.0 KB
ID:	1260021Seems like EMA has no access to the data.
    Click image for larger version

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

Name:	image.png
Views:	69
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:	72
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:	79
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.
      Emily C.NinjaTrader Customer Service

      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
          Emily C.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by alexstox, 10-16-2018, 03:29 PM
          11 responses
          342 views
          0 likes
          Last Post aligator  
          Started by ageeholdings, 05-01-2024, 05:22 AM
          6 responses
          43 views
          0 likes
          Last Post ageeholdings  
          Started by tony_28217, Today, 07:04 PM
          0 responses
          11 views
          0 likes
          Last Post tony_28217  
          Started by flybuzz, Today, 10:33 AM
          1 response
          9 views
          0 likes
          Last Post flybuzz
          by flybuzz
           
          Started by spencerp92, 10-10-2023, 09:56 AM
          4 responses
          310 views
          0 likes
          Last Post flybuzz
          by flybuzz
           
          Working...
          X