System Stopped – Array Problem

Forums ProRealTime English forum ProOrder support System Stopped – Array Problem

Viewing 15 posts - 1 through 15 (of 35 total)
  • #235380

    Has anybody used Arrays and their Algo was Stopped with the following error message?

                    The trading system was stopped because the code tries to : – define or access an invalid index in an array : Valid indexes are any strictly positive integer less than 1000000 : [1, 2 ,3, …, 1000000] –

                       or access an index that has not been previously set in the array : You can check if an index has previously been set using the “IsSet” function : “IsSet($MyArray[MyIndex])”

    Please NOTE: My Array does NOT contain either of the 2 errors above, I checked as follows …

    1.   My Array Indexes are 0 to 16
    2.   Indexes 0 to 16 all show a value … proven / seen by using GRAPH  IsSet($Fib[0])  GRAPH  IsSet($Fib[1]) GRAPH  IsSet($Fib[2]) … etc up to GRAPH  IsSet($Fib[16])

    It would appear the above error message is another ‘error fudge message’ i.e. does not directly apply / relate to the cause of the Stoppage??

    Any thoughts / comments / ideas to try and solve appreciated.

    #235384

    Hi GraHal,

    Can it be that you did not use more elements than 1M all right, but that you accidentally used index numbers which exceed 1M ?

     

    1 user thanked author for this post.
    #235387

    Thanks, but No … I used only 17 elements with index numbers o to 16.

    #235395

    Does it still work with 15 ?

    1 user thanked author for this post.
    #235400

    Fight fire with fire, trying to use logic against the logic!

    On the assumption that the error message is right and there was an invalid index…

    To be invalid it must have been one of…

    . undefined, not a integer, negative, > 9999999.

    To be undefined, if index is a variable, then index = undefined, but you maybe would expect undefined var error message.

    Or, the index has been increased to a value which exceeds the current defined array elements.

    To be negative , some calculation of the index resulted in a negative value,  16-17=-1.

    (array index)  – (array element count)  = -1

    Similar, calculation turning integer into decimal.

    To exceed 1 million elements, then array would have to keep increasing in size in background, however only a small amount of elements are used.

    When max reached , error message.

    I would think if the error appears random and not repeatable, then it could be an edge case in the code, eventually triggering 1 of the above.

    It may not be possible to see the error using graph because, when the error is hit in back test it may show up as undefined and not an error message.

    Where by in algo it error’s, and stops bot.

    A few tests with an array in back test didn’t through error if index undefined directly or indirectly on undefined element.

    Using trial and error, with code validating index is not one of the above may help track down

    Does the element exist and index  fall within require range.

    If  isset(index) and index >= 0 and index <= 16 then       /// index valid

    I think in summary, how can a index  be invalid or become invalid.

    By not being set, by calculating, being out of sequence with defined elements,

    or by inadvertently increasingly defining elements, though not using them.

    Now moving beyond that, is the array were looking at the right array!

    Is there additional code, external code , like average[]() type commands etc., or called code with possible arrays.

    I’m sure that, when you look at the code version from the proOrder window it includes all the code used, no sure to what depth though for sum.

    Could run two versions in demo, 1 normal, 1 with a check 0n the validity of the index to see in both or one errors.

    If you can catch the error and avoid algo stopping, you might be able to encode a number of error conditions within the contract size and then quit, if it comes to that, since there no graph in algo.

    Any way that’s what I’m thinking.

     

     

    1 user thanked author for this post.
    #235402

    Wow that’s a ‘few things’ for me to explore!
    Thanks for helping druby

    #235406

    That was a data dump straight out of brain, just pressed print…

    You could look at your code from a couple of points  of view.

    Is the code doing what I think its doing,  have I only got 17 elements,  are all my elements defined, does my index stay within range…

    Or, is code making more element than I think, is my index moving out of range or invalid….

    And then figure out how you can prove it.

    Hopefully, you find the answer, but worse case you know what it’s not and then focus on new idea’s.

    1 user thanked author for this post.
    #235414

    Valid indexes are any strictly positive integer less than 1000000 : [1, 2 ,3, …, 1000000] –

     

    My Array Indexes are 0 to 16

    does not comply to what’s in the first quote. That suggests the Arrays are 0 based (I don’t know or forgot). So if your text in the second quote is literal, you are using element 0. -error-

    1 user thanked author for this post.
    #235463

    From array link, @Nicolas started, info implies, that an array index includes zero,’0′ as a valid index.

    https://www.prorealcode.com/topic/array-variables-availability-in-prorealtime/

    Though, where [n] is commonly used in other situations, using zero can throw ‘positive integer’ error along with being negative.

    ex, average[0], higher[0]

    Another common one is, barindex[var], where var takes barindex negative when its size gets greater than barindex.

    ex. barindex =100, var = 101, barindex[var] = -1

    However, average[10000] , barindex[10000],works even though bars maybe only be 1000, just stays undefined or not able to see the result since out of range of display.

    Also these others can exceed 1,000,000.

    Then there’s others  where zero is ok , close[0], barindex[0].

    However, when you do get an error message, there usually some indication what keyword statement caused error.

    So, depending on custom code, its possible to use a variable who’s value may work in one situation but fail in another.

    The failure may be random or time delayed since a conditional edge case may have to be met to execute the code for failure.

    And since, indicators, back test and algo’s, can, or appear to do different things, you can’t assume an error in one equates to the error in other.

    Or probably a better way of thinking is that an error in one may ‘not’ error in the other.

    This may be to the different platform code doing checking,  which is not on the other stages.

    I suppose it would be very time consuming to test every keyword statement in all modules and situations to be able to identify the limits of the code in general.

    Only way is to come up with a testing strategy, and/or code snippets to verify the code stays within requirements  and  known limits.

    Code is like hydrogen, simple, only being 1 atom in size, it’s very useful in certain applications,  however trying to contain a load of it in one place is quite difficult, it finds ways of leaking out!

     

    1 user thanked author for this post.
    #235465

    @PeterSt, didn’t get straight away what you were referring to, we’ll spotted.

    The error message, doesn’t explicitly state ‘zero’ as an index, where array info does.

    And zero is not a positive integer.

    Not sure what this means…

    Is it an oversight and you can use zero as an array index, which it appears you can.

    Or, you can use zero but not in algo. There could be an inconsistence if you use it.

     

    1 user thanked author for this post.
    #235475

    I fixed Algo1 that prompted me to ask for help … I had 8 array elements listed then a few lines of code then the other 8 elements listed.  I amended so all 16 array elements were listed consecutively (no code between element 8 and 16 etc) and it worked / no Stoppage  / no error message.

    For reference / info re index 0 :
    I still got the stoppage (with error as I posted above) if my elements started at 0 or started at 1.

    As you have both been so helpful and clearly are more knowledgeable than me re coding, attached is (a completely different) Algo2 which works fine in backtest, but gets Stopped when runing on Live data with the following error message …

     The trading system was stopped because the code tries to : – define or access an invalid index in an array : Valid indexes are any strictly positive integer less than 1000000 : [1, 2 ,3, …, 1000000] –

                       or access an index that has not been previously set in the array : You can check if an index has previously been set using the “IsSet” function : “IsSet($MyArray[MyIndex])”

    Instrument, TF etc are in the Algo title. In order to fault find quickly, I ran it Live on 1 min TF as that saved waiting 5 mins between each tweak!

    I even got ChatGPT on this one a few weeks back, but despite about 4 versions of AI revised code (all looking logical etc) the problem remained.

    The version attached is the original version with no AI amendments.  I could post the AI amended version if you wish?

    #235478

    @JC_Bywan, Do you perhaps recognize anything of this ?

    #235479

    It was Ivan that coded the ACS Indicator; a link to the original post is at the top of the code / Algo / .itf I posted above.

    #235482

    As Ivan’s post was in French, we can’t link to the post so if we enter 234082 in the PRT search box then we can get to the original post, then change language to English on the translator at top of page.

    #235483

    It is not about Iván’s post, unless he used it on Live; JC knows about general issues with arrays on Live vs them working in the same situation on Backtest.

    1 user thanked author for this post.
Viewing 15 posts - 1 through 15 (of 35 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login