fxDreema

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

    OnTick critical error when change broker

    Questions & Answers
    2
    2
    936
    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.
    • E
      eklonsousa last edited by eklonsousa

      Hi, guys!

      I've build an EA which works fine in most of forex brokers. I'm trying to run the same EA with a brazillian broker and local market. But only with these local brokers I've got the "Array out of range"error in the following segment :

      MT5 Error0_1562093801157_Screen Shot 2019-07-02 at 15.55.59.png

      public: /* The main method */
      virtual void _execute_()
      {
      	// this is static for speed reasons
      	
      	bool next    = false;
      	string token = Symbol + IntegerToString(Period);
      	int index    = ArraySearch(tokens, token);
      	
      	if (index == -1)
      	{
      		index = ArraySize(tokens);
      		
      		ArrayResize(tokens, index + 1);
      		ArrayResize(old_values, index + 1);
      		ArrayResize(passes, index + 1);
      		/*.This is the 685 line. The error happens right here on this line*/
      		tokens[index] = token;
      		passes[index] = 0;
      		old_values[index] = 0;
      	}
      	
      	if (PassMaxTimes > 0)
      	{
      		CopyTime(Symbol, Period, 1, 1, time);
      		datetime new_value = time[0];
      	
      		if (new_value > old_values[index])
      		{
      			passes[index]++;
      	
      			if (passes[index] >= PassMaxTimes)
      			{
      				old_values[index]  = new_value;
      				passes[index] = 0;
      			}
      	
      			next = true;
      		}
      	} 
      

      What can cause this error in one broker and not to others?

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

        I don't know. It doesn't look like brokers' fault, but I wonder why a problem would happen in this block at this place. If you put Print(token) at this place, what will be printed in the logs? Or Print(index)

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

        Online Users

        P
        M

        13
        Online

        146.7k
        Users

        22.4k
        Topics

        122.6k
        Posts

        Powered by NodeBB Forums | Contributors