Errors, bugs, questions - page 2411

 
Aleksey Sergan:



Please run this code:Multicurrency iMA Trend 2.

Specify "EURUSD,GBPUSD" in the settings ( Symbols parameter).

On my configuration

MetaTrader 5 x64 build 2009 started (MetaQuotes Software Corp.)
Windows 10 (build 17763) x64, IE 11, UAC, Intel Core i3-3120 M  @ 2.50 GHz, Memory: 3518 / 8077 Mb, Disk: 86 / 415 Gb, GMT+2
C:\Users\barab\AppData\Roaming\MetaQuotes\Terminal\D0E8209F77C8CF37AD8BF550E51FF075

all SLs closed at their symbol prices. That is, there is no price overlap error.

 
Vladimir Karputov:

Please run this code:Multicurrency iMA Trend 2.

Specify "EURUSD,GBPUSD" in the settings ( Symbols parameter).

On my configuration

all SLs closed at their symbol prices. That is, there is no price overlap error.

Thank you, the error has been localized. Post below.

 
Andrey Barinov:

there are two mistakes.

№1. Your mistake. Somewhere in the code. You are setting SL for EURUSD position using GBPUSD price. The terminal should have nothing against it.

№2. Bug in the terminal. If this SL is triggered at a price that does not exist at the time in the EURUSD flow, using the GBPUSD price.

Andrey Barinov:

https://www.mql5.com/ru/docs/constants/structures/mqltraderequest

Apparently when sending a modification request, the position field has priority over symbol. Printreq.position

Yes, you turned out to be right, my mistake is logical:

in the structure:

MqlTradeRequest m_request;

m_request.position = #3

m_request.symbol = GBPUSD

m_request.sl = 1.60704

actual position number for GBPUSD #4

when OrderSend is executed, the tester sets a stop for the symbol corresponding to position #3, which is eurusd.

Tester bugs:

- fails to check if m_request.position and m_request.symbol match;

- sets a stop at 1.60704 for the buy position, the symbol eurusd, which has a current price of 1.30935;

- on the next tick sets a stop at 1.60704, although the actual price is 1.30935.

Thank you all. I hope the platform developers will see the post.

 
Aleksey Sergan:

Yes, you turned out to be right, my mistake is logical:

In the structure:

MqlTradeRequest m_request;

m_request.position = #3

m_request.symbol = GBPUSD

m_request.sl = 1.60704

actual position number for GBPUSD #4

when OrderSend is executed, the tester sets a stop for the symbol corresponding to position #3, which is eurusd.

Tester bugs:

- fails to check if m_request.position and m_request.symbol match;

- sets a stop at 1.60704 for the buy position, the symbol eurusd, which has a current price of 1.30935;

- on the next tick sets a stop at 1.60704, although the actual price is 1.30935.

Thank you all. I hope the platform developers will see the post.

Execution of a stop for a buy position at 1.60704 at the current price 1.30935 is not an error. But setting a buy stop to the level of 1.60704 at the current price of 1.30935 is an error.

 

Build 2007

Function:

bool GetDialLastProfit (string symbol, datetime startDate, datetime endDate, long magic, double &profit, double &lot)
{
  HistorySelect (startDate, endDate);
  int deals = HistoryDealsTotal ();
  ulong ticket;

  for (int i = deals - 1; i >= 0; i--)
  //for (int i = 0; i < deals; i++)
  {
    ticket = HistoryDealGetTicket (i);
    if (ticket != 0)
    {
      if (HistoryDealGetInteger(ticket, DEAL_MAGIC) == magic)
      {
        profit = HistoryDealGetDouble (ticket, DEAL_PROFIT);
        
        //if (!HistoryDealGetDouble(ticket, DEAL_PROFIT, profit))
        //  return false;
        
        lot    = HistoryDealGetDouble (ticket, DEAL_VOLUME);
        
        return (true);
      }
    }
  }

  return (false);
}

is supposed to output the financial result of the transaction into the profit variable, but it always turns out to be 0.0, and the value in the lot variable is always correct.

Is there an error? - Or I'm doing something wrong?

 
Andrey Dik:

Build 2007

Function:

is supposed to output the financial result of the transaction into the profit variable, but it always turns out to be 0.0, and the value in the lot variable is always correct.

Is there an error? - Or I'm doing something wrong?

DEAL_ENTRY_OUT or INOUT should be checked. The _IN trades have a profit of 0

 
Andrey Barinov:

DEAL_ENTRY_OUT or INOUT should be watched. The _IN trades have a profit of 0

Well, the first from the end of the list is taken, it should be OUT

 
Andrey Dik:

Well it's the first from the end of the list, it should be OUT

If you pass TimeCurrent() in the endDate, replace it with TimeCurrent()+60 or something like that. That should help.

 
Andrey Barinov:

If you pass TimeCurrent() in endDate, replace it with TimeCurrent()+60 or something like that. This should help.

No, it's still 0.0.

 
Andrey Dik:

No, it's still 0.0.

Then debug it. Print transaction tickets and see in the tester what is actually selected there. Add a filter by trade type.