Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

switching and reloading tabs consecutively index error

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

    switching and reloading tabs consecutively index error


    title : switching and reloading tabs consecutively index error

    Hello everyone, happy new year and best wishes, may the markets listen to you this time,

    I have 2 tabs on the same window with the same indicator working almost as desired, if it were not for :

    when switching tabs and reloading multiple times consecutively, there is a System.ArgumentOutOfRangeException of this kind :

    // for the below code line we get the following error :
    Code:
    double someDouble = Ypct(myCustomIndicator[1][1]);
    // where myCustomIndicator[1] is one indicator in an array of the same indicator for multiple frames, initialized dynamically
    // (would there be here a subtlety which would interfere with initialization when tab switch while reload consecutively ?).
    // System.ArgumentOutOfRangeException
    // HResult=0x80131502
    // Message=Index was out of range. Must be non-negative and less than the size of the collection.
    // Parameter name: index
    // Source=mscorlib
    // StackTrace:
    // at System.ThrowHelper.ThrowArgumentOutOfRangeExceptio n(ExceptionArgument argument, ExceptionResource resource)
    // at NinjaTrader.NinjaScript.Series`1.get_Item(Int32 barsAgo)
    // at NinjaTrader.NinjaScript.NinjaScriptBase.get_Item(I nt32 barsAgo)
    // at NinjaTrader.NinjaScript.Indicators.A00indicators.A 03Analyzer.<OnBarUpdate>g__OBU_ini_coreFlagLists|6 6_1() in C:\Users\myUserName\Documents\NinjaTrader 8\bin\Custom\Indicators\A00indicators\A03Analyzer. cs:line 585
    // at NinjaTrader.NinjaScript.Indicators.A00indicators.A 03Analyzer.OnBarUpdate() in C:\Users\myUserName\Documents\NinjaTrader 8\bin\Custom\Indicators\A00indicators\A03Analyzer. cs:line 521
    // at NinjaTrader.NinjaScript.NinjaScriptBase.Update(Int 32 idx, Int32 bip)
    CurrentBars[i] checks are in place.
    the switching of tabs cause no issue if each tab is reloaded once the other has finished loading.

    has anyone a clue about non-frenetically tab switchable-while-reloading script issues ?
    Last edited by Amedeus; 01-01-2025, 08:28 AM.

    #2
    the sample attached illustrates the issue.
    Code:
    double issueCall = ks[1][1];
    // System.ArgumentOutOfRangeException
    // HResult=0x80131502
    // Message=Index was out of range. Must be non-negative and less than the size of the collection.
    // Parameter name: index
    // Source=mscorlib
    // StackTrace:
    // at System.ThrowHelper.ThrowArgumentOutOfRangeExceptio n(ExceptionArgument argument, ExceptionResource resource)
    // at NinjaTrader.NinjaScript.Series`1.get_Item(Int32 barsAgo)
    // at NinjaTrader.NinjaScript.NinjaScriptBase.get_Item(I nt32 barsAgo)
    // at NinjaTrader.NinjaScript.Indicators.A00indicators.SampleTestTabSwitcReloadhError.OnBarUpdate() in C:\Users\myUserName\Documents\NinjaTrader 8\bin\Custom\Indicators\A00indicators\A000SampleTe stTabSwitcReloadhError.cs:line 115
    // at NinjaTrader.NinjaScript.NinjaScriptBase.Update(Int 32 idx, Int32 bip)
    How come ?
    Attached Files
    Last edited by Amedeus; 01-01-2025, 10:21 AM.

    Comment


      #3
      Hello Amedeus,

      In the sample you are using a static variable which would cause issues running multiple instances of the indicator, do you still have a problem if you only use a private variable without the static modifier?

      Comment


        #4
        hey Jesse ! thank you very much.

        I don't find any issue anymore once the static modifier removed.

        have great day.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        558 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        324 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        545 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        547 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X