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

Indicator will not load

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

    Indicator will not load

    I have a new indicator that is giving me a few issues where it is failing to load if there are less than 18 bars displayed and it is causing Ninja to crash. I would have thought that it should load even if there are only 2 bars available??? I can't figure it out and being new makes it even harder.

    That is the first issue. The second is that every time I update this indicator by changing a variable or, reloading the indicator, NinjaTrader goes into meltdown. It stops responding for several seconds. Maybe there is some optimization I need to do to the code. I have a feeling that the problem may be that I am doing 2 things with this indicator. One is to display the current efficiency while the candle is forming and; the other is to display triangles on previous candles that were efficient. One is relying on current data and the other is relying on historical data.

    My indicator is attached. I would appreciate any help.
    Attached Files

    #2
    Hello Kaiviti57,

    Thanks for your post.

    When a script is not performing as expected, always check the "Log" tab of the NinjaTrader7 Control center for any related error messages.

    In this case you will see an error message advising on OnBarUpdate() error, accessing an index that is invalid. Even though the code shows a CurrentBar check the prevent processing on the first 2 bars (bars 0 & 1), your code is accessing [2] before the 3rd bar is actually loaded. You need only change the CurrentBar check from <1 to <2.

    Regarding the second issue, I do not see that here. I made small changes, recompiled and reloaded the indicator however this was on a chart with only 5 days of data. The indicator appears to draw a lot of triangles and the number of draw objects can impact performance. You may want to use a limited number of draw objects to help improve performance. One way to do this would be to use a counter instead of Time[0] to create a unique tag name. By using a counter and resetting the counter every x counts you will then limit the draw objects to that x amount. When a new object is drawn and it uses a previous tag name, the old object is removed. You may want to test performance by using 100 to 500 or 1000 objects. You can also may this a variable that the user can set in the parameters.

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks Paul. I have made the change and I am sure that will solve the first problem. The second problem may be more related to the fact that I have several windows open and each one has several indicators attached. It may a bit too much of a draw on the resources. Is there some way to limit the number of bars back that an indicator draws so that it is not calculating for every bar loaded? Obviously, the user would still want to see the results of the indicator if he scrolls back several days.

      Comment


        #4
        Hello Kaiviti57,

        Thanks for your reply.

        Sorry, I forgot this was NinjaTrader7 forum so I removed my reply in this post which was to direct you to use OnRender() but that is not available for NinjaTrader7.

        I can only suggest that you reduce the data or provide an option to change the counter selection I suggested in my first reply. For example, you could set the counter or provide the last 100 bars by default or if you enter a specific number such as 999 then you can code to draw every object so this would be one way to allow the user to look at all the objects when they specify.
        Last edited by NinjaTrader_PaulH; 09-03-2020, 09:12 AM. Reason: Removed NinjaTrader8 reply.
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by burtoninlondon, Today, 12:38 AM
        0 responses
        5 views
        0 likes
        Last Post burtoninlondon  
        Started by AaronKoRn, Yesterday, 09:49 PM
        0 responses
        14 views
        0 likes
        Last Post AaronKoRn  
        Started by carnitron, Yesterday, 08:42 PM
        0 responses
        11 views
        0 likes
        Last Post carnitron  
        Started by strategist007, Yesterday, 07:51 PM
        0 responses
        13 views
        0 likes
        Last Post strategist007  
        Started by StockTrader88, 03-06-2021, 08:58 AM
        44 responses
        3,983 views
        3 likes
        Last Post jhudas88  
        Working...
        X