fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    Array Out Of Range

    Bug Reports
    3
    7
    695
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      Mantadiver last edited by

      I have started getting Array Out Of Range errors.

      The EA starts & runs for a while and then simply stops.

      To fix a bug you need to replicate I haven't yet managed to find a series of events to replicate it.

      The error always points to the same area of "core" fxdreema code:-

      datetime new_value = time[0];

      This code appears under the heading:- // "Once per bar" model

      Judging by the last message before the error occurs I believe it is happening immediately on the start of a new bar.

      Any thoughts please ?

      1 Reply Last reply Reply Quote 0
      • S
        sktsec last edited by

        A common error. No one can tell from your limited information

        1 Reply Last reply Reply Quote 0
        • M
          Mantadiver last edited by

          Yup, that's the issue, there doesn't appear to be a smoking gun. I've added a raft of logging messages to try and gain more insight when it happens again.

          S 1 Reply Last reply Reply Quote 0
          • S
            sktsec @Mantadiver last edited by sktsec

            @Mantadiver
            Sometimes it may be related to the customized indicators you used

            1 Reply Last reply Reply Quote 0
            • fxDreema
              fxDreema last edited by

              Today I investigated this error a little bit more. One user sent me his history data and I was able to get the error myself. At the end, I don't know how to fix the problem, but this is what I understood.

              Each candle has OHLC, Volume and also Time. "Once per bar" works by reading the Time from the candle, remembering that time and then when the time changes (when a new candle is added), it can pass again and remember the new time. Do this over and over and the block passes once per bar.

              To get the time I used a function called CopyTime. This function would read the data from just one candle, and then it would put the result in a dynamic array, which initially has size of 0. When the data is put into the array, its size would automatically change to 1. Then, that single value from the array would be read, which usually happens without problems. But when the function fails, the array doesn't change, its size remains 0 and that's why later it shows "array out of range".

              While the error says "array out of range", the problem comes from the inability to read that candle. And in the tests I did today, CopyTime wasn't able to read any candle.

              First I did a fix, so that when CopyTime fails, it won't even try to read the value from the array, it would just do nothing and "Once per bar" won't pass. Muted error, the EA just tried to do what it can.

              Then I tested iTime, which seems to be able to get the time from the previous candle somehow. However, then I realized that if lower timeframe is selected in "Once per bar", then iTime (and also CopyTime) could fail.

              So the whole situation happens because something in the history data is not right. But I don't really know how to fix the problem with these functions. I can mute the error so it won't appear, or print another more descriptive error.

              1 Reply Last reply Reply Quote 1
              • fxDreema
                fxDreema last edited by

                Possible solution would be to try to download the history data again. The data files are located in history/%TheNameOfYourBroker%. But if you are testing, also delete the files from tester/history - the .fxt files there are the generated ticks.

                Or maybe use another broker for the tests. Different files are downloaded from each broker.

                1 Reply Last reply Reply Quote 0
                • M
                  Mantadiver last edited by

                  Would it be possible to not use an array but use a simple integer instead ? When I build indicators I check for once per bar by populating an integer ThisBarStartTime = Time[0];

                  The BIG issue here is that when an EA is running live an array out of range error stops it dead in its tracks and no further actions can be taken. There is no way to create an alert, push, sms or Telegram meassage to the user because it has simply stopped working. Therefore it ends up with orphaned trades unless they can be identified and managed by reapplying the EA to the chart.

                  Instead of allow an array our of range error to occur, would it be possible to allow the code to continue and do further checks, i.e. look at the timeframe and check some other flag to see whether it has already been actioned yet on this bar. Then allow it to continue and maybe flag an alert to say there was an issue but at least the ea continues to run . . . . ?

                  Thanks for looking into it. Appreciated.

                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  • First post
                    Last post

                  Online Users

                  J
                  T
                  J
                  B

                  14
                  Online

                  146.7k
                  Users

                  22.4k
                  Topics

                  122.6k
                  Posts

                  Powered by NodeBB Forums | Contributors