Errors, bugs, questions - page 803

 
Karlson:
Different servers, different 500 pp.
What does this have to do with different servers? These are two tests by the same person. Only the currency pair specified in the tester differs
 
ilunga:
What does this have to do with different servers? These are two tests by the same person. Only the currency pair specified in the tester differs
Update your terminal/tester and maybe everything will work, I have the 687 build and everything works.
 
fyords:

I have everything correct, demo MK server.

Then please explain, what is the value in brackets when you open an order and why in one case it is (1.29565 / 1.29654) and in the other (1.29443 / 1.29479 / 1.29443)

(I mean your test results.

fyords:
Update your terminal/tester and maybe everything will work, I have a 687 build and everything works.

Exactly the same error "pops up" when sending the EA to the championship (in their automatic tests), so the update will only partially help


What's more. It comes up only 1 time (the very first attempt to place an order on a currency pair other than "your")

 
ilunga:
What does this have to do with different servers? These are two tests by the same person. Only currency pair specified in the tester differs.

Have a look at the articles about the tester:

Prices do not need to be the same when testing on another currency pair

 
Rosh:

Have a look at the articles about the tester:

Prices do not have to match when tested on another currency pair

So, ran some more tests. Really a problem with the "current price".

Code:

#include <Trade\SymbolInfo.mqh>
#include <Trade\Trade.mqh>

CSymbolInfo       m_sym;
CTrade            m_trade;

double bar_info[2];
bool a;

int OnInit()
{
   SymbolSelect("EURUSD", true);
   SymbolSelect("GBPUSD", true);
   m_sym.Name("EURUSD");
   a = false;
   return(0);
}

void OnTick()
{
   if (a) return;
   a = true;
   m_sym.Refresh();
   m_sym.RefreshRates();
   CopyHigh("EURUSD", PERIOD_D1, 0, 2, bar_info);
   Print("Текущая цена Ask:" + DoubleToString(m_sym.Ask()));
   Print("Текущая цена Bid:" + DoubleToString(m_sym.Bid()));
   Print("Цена открытия:" + DoubleToString(bar_info[1] + 5000*_Point));
   BUY_pending("EURUSD");
   Print("Текущая цена Ask:" + DoubleToString(m_sym.Ask()));
   Print("Текущая цена Bid:" + DoubleToString(m_sym.Bid()));
}

uint BUY_pending(string symbol)
{
   CopyHigh(symbol, PERIOD_D1, 0, 2, bar_info);
   // готовим запрос
   MqlTradeRequest request = {0};
   ZeroMemory(request);
   request.action = TRADE_ACTION_PENDING;
   request.magic  = 0;
   request.symbol = symbol;
   request.volume = 1;
   request.price  = m_sym.Ask() + 1;
   request.sl     = 0;
   request.tp     = 0;
   request.deviation = 10;
   request.type   = ORDER_TYPE_BUY_STOP; 
   request.type_filling = ORDER_FILLING_FOK;
   MqlTradeResult result;
   OrderSend(request,result);
   Print(IntegerToString(result.retcode));
   return (result.retcode);
}

Note, I open at Ask symbol price plus 1 (with a huge margin). At the same time before and after I print the current Ask and Bid.


Results (when testing on GBPUSD):

GR      0       test (GBPUSD,H1)        11:49:40        2012.01.02 09:00:00   Текущая цена Ask:1.29241000
LH      0       test (GBPUSD,H1)        11:49:40        2012.01.02 09:00:00   Текущая цена Bid:1.29220000
QL      0       test (GBPUSD,H1)        11:49:40        2012.01.02 09:00:00   Цена открытия:1.34220000
GD      0       Trade   11:49:40        2012.01.02 09:00:00   buy stop 1.00 EURUSD at 2.29241 (1.29709 / 1.29722)
IG      0       test (GBPUSD,H1)        11:49:40        2012.01.02 09:00:00   10009
CP      0       test (GBPUSD,H1)        11:49:40        2012.01.02 09:00:00   Текущая цена Ask:1.29241000
HG      0       test (GBPUSD,H1)        11:49:40        2012.01.02 09:00:00   Текущая цена Bid:1.29220000

The price 1.29241 is printed before and after the order is placed. In the meantime, in brackets (when the order is placed), the price is 1.29722. HOW? Or am I obtaining the current price incorrectly?


And secondly, if there was an error with the price, then why the error 10016 (stops)?

 
ilunga:

But the error still exists in the cutscene.

To be honest, I do not quite understand how error 10016 can be in case of no stops

I don't know what and how you are doing it, the problem is probably really in SL.

My version works without problems. The call, however, threw in the initialization block, not to bother with checks (although the presence of the order before setting it would be worth checking).

bool BUY_pending(string symbol,ENUM_TIMEFRAMES period,double volume,ulong magic = 0)
{
//----------------------------------------------------------------------------//
//Work variables
double price = 0, sl = 0, tp = 0; //Prices: Open, Sell stop, Take profit
int ResCopy = -1; //Result of copying the data into an array
int Dig     = 0;  //Digits

bool Result = true; //Returned importance
//----------------------------------------------------------------------------//

ResetLastError();

//Checking the signal to stopping the trading system
  if(IsStopped()) return(false);
//Preparation of structures
ZeroMemory(TradeRequest);
ZeroMemory(TradeResult);
ZeroMemory(CheckResult);
//Copying the data into an array
ResCopy = CopyHigh(symbol,period,0,2,bar_info);

  if(ResCopy==-1)return(false); 
//Calculations
Dig   = (int)SymbolInfoInteger(symbol,SYMBOL_DIGITS);

price = NormalizeDouble(bar_info[1] + 500*_Point,Dig);
sl    = NormalizeDouble(price - 200*_Point,Dig);
tp    = NormalizeDouble(price + 1000*_Point,Dig);
//Preparation of request
TradeRequest.type_filling = ORDER_FILLING_FOK;
TradeRequest.action       = TRADE_ACTION_PENDING;
TradeRequest.type         = ORDER_TYPE_BUY_STOP; 
TradeRequest.deviation    = 10;
TradeRequest.symbol = symbol;
TradeRequest.magic  = magic;
TradeRequest.volume = volume;
TradeRequest.price  = price;
TradeRequest.sl     = sl;
TradeRequest.tp     = tp;
//Checking
Result = OrderCheck(TradeRequest,CheckResult);
  if((!Result)||(CheckResult.retcode!=0))return(false);
//OrderSend
Result = OrderSend(TradeRequest,TradeResult);
//Checking for presence of the errors
  if(_LastError!=0){Result = false;}
//----------------------------------------------------------------------------//
return(Result);
//----------------------------------------------------------------------------//
}
Files:
 
Interesting:

I don't know what or how you're doing it, the problem is probably really with SL.

My version works without problems. The call is true, but I threw the call to the initialization block, not to bother with the checks (although the presence of the order before setting it would be worth checking).

A small request. Can you correct the code, so that it would output the current price of the symbol before OrderSend?
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров - Документация по MQL5
 
ilunga:
A small request. Can you tweak the code so that before OrderSend it outputs the current price of the instrument on which we open?

Try it this way:

   MqlTradeResult result;
   if(!OrderSend(request,result))
     {
      PrintFormat("retcode=%d price=%G  Ask=%G  Bid=%G Comment=%s",
                  result.retcode,result.price,result.ask,result.bid,result.comment);
      //---
      PrintFormat("%s %s at %G Ask=%G  Bid=%G  ",
                  EnumToString(request.type),symbol,request.price,SymbolInfoDouble(symbol,SYMBOL_ASK),
                  SymbolInfoDouble(symbol,SYMBOL_BID));
      Print("------------");
     }
 
ilunga:
Small request. Can you correct the code, that it would output the current price on that tool before OrderSend?

A price spritzer? I don't see the need for that, you can add a message about the success/failure of the check and the setting of the order.

In principle you can do it yourself, should not be difficult (by idea).

Rosh:

Try it this way:

For debugging it will do quite well, in working code it will be superfluous (at least a bit of a snaggy solution)

And it's better to place order after OrderCheck, so that in case of error it won't go to OrderSend.

PS

I forgot to add, based on the example bar_info could be placed in a function without problems.

 
Interesting:

A price spritzer? I don't see the need for that, you can add a message about the success/failure of the check and the setting of the order.

In principle, you can do it yourself, it should not be difficult (in idea).

It may be good enough for debugging, but in production code it will be superfluous (at least it's a bit of a crooked solution).

And it would be better to place order after OrderCheck, so that in case of error we won't get to OrderSend.

PS

I forgot to add, based on the example bar_info could also be placed in a function without any problems.

It is funny. In your example, I have removed BUYSTOP for GBP, only EURUSD is left.

After filling the fields in the request, I have outputted the price of pending order.

1) You have variant - pending order is placed in the Inite

2012.01.01 00:00:00 price = 1.30487000

2) I commented out the init, moved it to OnTick. I put a condition to trigger only on the first tick.

2012.01.02 09:00:00 price = 1.29720000


P.S. I understand correctly that in my (and your) code bar_info[1] is the maximum of the current bar?

Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров - Документация по MQL5
Reason: