Questions from Beginners MQL5 MT5 MetaTrader 5 - page 803

 

A simple question.

Is it possible to exit the cycle in this way ? Or is such simplicity not free ?

while(1)
{
 .........
 if(............ ) return;
 ..........
}
 

One more question.

There is a MqlTick structure with the following field

longtime_msc;// Time of the last price update in milliseconds

As far as I understand, time_msc stores the number of milliseconds since 1970.

The CopyTick function has the following parameter

ulongfrom=0,//date since which the ticks are requested

In the help, it is specified that it is "Date from which tick s are requested. Specified in milliseconds since 01.01.1970".

Attention question.

Why different data types are used in MqlTick structure and in parameter of function CopyTick ? After all, they both store the time since 1970.

 
pivomoe:

One more question.

There is a MqlTick structure with the following field

longtime_msc;// Time of the last price update in milliseconds

As far as I understand, time_msc stores the number of milliseconds since 1970.

The CopyTick function has the following parameter

ulongfrom=0,//date since which the ticks are requested

In the help, it is specified that it is "Date from which tick s are requested. Specified in milliseconds since 01.01.1970".

Attention question.

Why different data types are used in MqlTick structure and in parameter of function CopyTick ? After all, they both store the time since 1970.

ulong - unsigned long type

 
I know that. Why is a signed type used in one case and an unsigned type in the other? The cases are similar.
 
pivomoe:

A simple question.

Is it possible to exit the cycle in this way ? Or is such simplicity not free ?

What's the concern ? Termination by condition. Only if you just want to exit the loop, not return but break

 
Alexey Viktorov:

What's bothering you? Ending execution by condition. Only if you just want to exit the loop, not return but break

I don't understand the memory consumption after such returnom loop exits or not ?
 
pivomoe:
I do not understand the memory consumption after such a returnom exit or not ?

Why should I? Don't get your head in a bunch of nonsense. This kind of exit will work fast.

 

How can I give up a free utility (indicator) downloaded via the market in the terminal. Uninstalling it does not help. I keep getting messages about updating the product, although it has been uninstalled for a long time.

 

Gentlemen, help me to understand the situation, in the Strategy Tester everything goes without errors and problems on a demo account, too, but when I load an EA in the Market, Autotester says:

2016.04.01 00:00:12 failed instant sell 0.10 EURUSD at 1.13780 sl: 1.14030 tp: 1.13030 [Invalid volume]
2016.04.01 00:00:24 failed instant sell 0.10 EURUSD at 1.13779 sl: 1.14029 tp: 1.13029 [Invalid volume]
2016.04.01 00:00:59 failed instant sell 0.10 EURUSD at 1.13782 sl: 1.14032 tp: 1.13032 [Invalid volume]
2016.04.01 00:01:00 failed instant sell 0.10 EURUSD at 1.13793 sl: 1.14043 tp: 1.13043 [Invalid volume]
2016.04.01 00:01:08 failed instant sell 0.10 EURUSD at 1.13783 sl: 1.14033 tp: 1.13033 [Invalid volume]
2016.04.01 00:01:17 failed instant sell 0.10 EURUSD at 1.13784 sl: 1.14034 tp: 1.13034 [Invalid volume]
2016.04.01 00:01:25 failed instant sell 0.10 EURUSD at 1.13774 sl: 1.14024 tp: 1.13024 [Invalid volume]
2016.04.01 00:01:34 failed instant sell 0.10 EURUSD at 1.13776 sl: 1.14026 tp: 1.13026 [Invalid volume]
2016.04.01 00:01:59 failed instant sell 0.10 EURUSD at 1.13778 sl: 1.14028 tp: 1.13028 [Invalid volume]
2016.04.01 00:02:00 failed instant sell 0.10 EURUSD at 1.13778 sl: 1.14028 tp: 1.13028 [Invalid volume]
2016.04.01 00:02:08 failed instant sell 0.10 EURUSD at 1.13776 sl: 1.14026 tp: 1.13026 [Invalid volume]

function code below:

OpenPos(NormalizeDouble(Lot,2), NormalizeDouble(Bid,_Digits), NormalizeDouble(_sl,_Digits),NormalizeDouble(_tp,_Digits),ORDER_TYPE_SELL,MagicSell,Comm);
void OpenPos(const double volume,const double price, const double stop, const double take, const ENUM_ORDER_TYPE o_type, const int magic,const string coment=NULL)
{
   MqlTradeRequest request={0};
   MqlTradeResult result={0};
   
   string t=(o_type==ORDER_TYPE_BUY)?"Buy":"Sell";
   
   ZeroMemory(request);
   ZeroMemory(result);
   
   request.action=TRADE_ACTION_DEAL;
   request.symbol=Symbol();
   request.volume=volume;
   request.type=o_type;
   request.magic=magic;
   request.price=price;
   request.sl=stop;
   request.tp=take;
   request.comment=coment;
   
   if(IsFillingTypeAllowed(Symbol(),SYMBOL_FILLING_FOK))
      request.type_filling=ORDER_FILLING_FOK;
   else if(IsFillingTypeAllowed(Symbol(),SYMBOL_FILLING_IOC))
      request.type_filling=ORDER_FILLING_IOC;
   else
      request.type_filling=ORDER_FILLING_RETURN;
   
   if(!OrderSend(request,result))
      PrintFormat("Can't open position %s error %i",t,GetLastError());
}
 
Andrii Djola:

Please help me to understand this situation, in the Strategy Tester my EA runs without any error or problem, I also have no problems when I load it on a demo account, but when I load an EA in the Market, the Autotester writes:

Print the result of OrderCheck and its full structure. Do the same with OrderSend.

Set up demo accounts on ten different trading servers. And try your code there. Most often some particular feature of the trading server is not taken into account, which is reproduced when checking in the Market.

And don't forget to output LastError. All this together will very quickly allow you to get to the bottom of the causes of the error.

Reason: