Libraries: MT4Orders - page 4

 

I have an issue, could you please give me some hints on how to work around it?

"critical runtime error 502 in OnTester function (array out of range, module Experts\ea.ex5, file MT4Orders.mqh, line 626, col 40)"

It seems like this.Tickets's size only gets increased over time. I assume therefore it is meant to contain information on closed trades. Could you confirm this?

In case this is not necessary, is there a way to turn it off?

 
pcdeni #:

I have an issue, could you please give me some hints on how to work around it?

It seems like this.Tickets's size only gets increased over time. I assume therefore it is meant to contain information on closed trades. Could you confirm this?

In case this is not necessary, is there a way to turn it off?

Try the latest version. Copy-Paste.

 
fxsaber #:

Try the latest version. Copy-Paste.

Thank you fxsaber. It will take me some time to confirm, but so far the memory usage doesn't seem to be lower.

Out of curiosity, where is OrderSwap() defined? I can't seem to find it in the code.

 
pcdeni #:

so far the memory usage doesn't seem to be lower.

Need data to reproduce problem. Laconic code and investment access to the trading account where the problem occurs. Maybe in private messages.

Out of curiosity, where is OrderSwap() defined? I can't seem to find it in the code.

MT4_ORDERFUNCTION(Swap, double, ::PositionGetDouble(POSITION_SWAP), 0, true)
 
Hello, I got weird issue.  I've been using this library for some time now, I want to say HUGE THANKS , its incredible help,

So I never got any problems with including this library/code in EAs for years. 

Now when I'm compiling MT5 EA, it returns 3 errors from this code, they are all basically about 1 line: ( see code bellow )
'=' - unexpected token MT4Orders.mqh 192 25
')' - unexpected token MT4Orders.mqh 192 68
'*=' - name expected MT4Orders.mqh 194 13

in my EA I'm also including:

#include <stderror.mqh>
#include <stdlib_mq5.mqh>
#import   "kernel32.dll"

Do you have any idea what could be happening here ?

Library alone compiles without errors, no problems, as usual. Only when trying to compile EA, it throws those errors.

#define ORDER_SELECT (-2)

   static int GetDigits( double Price )
  {
    int Res = 0;

    while ((bool)(Price = ::NormalizeDouble(Price - (int)Price, 8)))   // <- LINE 192 so this is apparently a problem "= :: "
    {
      Price *= 10; // LINE 194

      Res++;
    }

    return(Res);
  }

I found something suspicions in my EA :
union Price
  {
   uchar             buffer[8];
   double            close;
  };

 so this union Price name overwrites the Price name in the GetDigits function ? this could be the problem ?
 
Filip Valkovic #:
I found something suspicions in my EA :
 so this union Price name overwrites the Price name in the GetDigits function ? this could be the problem ?

This is the reason.

 

Hi,

Look like have a bug on OrderTicket()

It's not correct ticket from MT5's history


This is my code:

bool isCopyHistory2(string u_symbol, int master_ticket)
  {

   int ticket_copy;

   bool is_exists = false;

// retrieving info from trade history

   for(int i = 0; i < OrdersHistoryTotal(); i++)
     {
      //---- check selection result

      if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) == false)
        {
         Print("Access to history failed with error (", GetLastError(), ")");
         continue;
        }

      // some work with order

      ticket_copy = (int)extract_master_ticket(OrderComment());

      if(ticket_copy == master_ticket)
        {
	//print-for-debug
        Print("c ticket: ", OrderTicket());  // ==> this is not correct ticket on MT5
         is_exists = true;
         break;
        }

     }

//---

   if(!is_exists)

      Print("New Signal #" + (string)master_ticket);

   return(is_exists);

  }

 
Cuong Le Van #:

Look like have a bug on OrderTicket()

It's not correct ticket from MT5's history

Apparently you want to get it.

// List of changes:
// 13.03.2019
//   Add: Added OrderTicketID() - PositionID of an MT5 transaction or MT5 position, and the ticket of a pending MT4 order.

The reasons are detailed here.

 
fxsaber #:

Apparently you want to get it.


The reasons are detailed here.

Thanks you very much.

It's ok with 

OrderTicketID()
 

Is it possible there is a memory leak or a more than necessary memory use? Maybe in this.tickets or in this.amount (::ArrayResize) or maybe somewhere else?

The size of the arrays only get increased over time. Is this a must? Is it possible to empty them or perhaps don't load all the previous trades?