Questions from Beginners MQL5 MT5 MetaTrader 5 - page 963

 
the size of local variables is too large (more than 512 kb)

What does this compile-time error mean and how do I fix it? I have a class with about 80,000 lines. Do I have to make two classes out of it? This is nonsense. What is the sense of this 64-bit version if everything is limited in such a way?
 
Juer:
How can you tell what is causing the long compilation (over 10 minutes). The resulting ex5 file weighs about 12mb, not that much. How can I diagnose and fix the reasons that cause such a long compilation?

https://www.mql5.com/ru/forum/165399#comment_3968004

Optimize=0

I think I've got that sorted out.

Время компиляции
Время компиляции
  • 2017.01.02
  • www.mql5.com
Всем привет! Код компилируется очень долго (около минуты). Строк кода - около 4000. От чего зависит время и как можно ускорить...
 
When modifying an order, the order to which OrderGetDouble refers must be specified before point=
 
Ivan Ivanov:
When modifying an order, we should specify the order, to which OrderGetDouble refers, before point=

Thanks Ivan, I'm trying it out but it's not working for me.

I don't understand the logic itself, how to select an order for modification by type and not by ticket and then refer to its properties.

I don't understand the logic, because in the order modification itself the ticket is the obligatory field to fill and there is no order type.

m_trade.OrderModify(ticket,Bid-(SHAG_s*_Point),Ask+((SLL_s-SHAG_s) *_Point),Ask-((TPP_s+SHAG_s)*_Point),0,0,0);

In my case, there are two open orders: Buy_Stop and Sell_Stop. The sequence of their opening may be any.

The Ticket number is not of any help to me here.

In the check condition, I can find out whether Sell_Stop (for example) is among the open orders.

But I can't find out how I should address to this particular order Sell_Stop, so that whenOrderModify is called

to modify exactly Sell_Stop, and not something that happened to be under the ticket.

I have a feeling that the syntax of the language makes me go through all the orders in the ticket, just for the sake of filling in the ticket field inOrderModify.

This is where I got confused with order modification. I lost the logic of the process.

 

Is there a function for attaching to an EA chart? Like ChartIndicatorAdd().

Or how can I programmatically attach an EA to a given chart, if there is no template?

 

How do you translate to mql5?

OP_LOTS = (((AccountBalance() * _LosPercent) / 100) / MarketInfo(Symbol(), MODE_TICKVALUE)) / (pp);
        OP_LOTS = MathRound(OP_LOTS / MarketInfo(Symbol(), MODE_LOTSTEP)) * MarketInfo(Symbol(), MODE_LOTSTEP);
        OP_LOTS = MathMax(OP_LOTS, MarketInfo(Symbol(), MODE_MINLOT));
        OP_LOTS = MathMin(OP_LOTS, MarketInfo(Symbol(), MODE_MAXLOT));
 
Sprut112:

How do I translate to mql5?

double point = SymbolInfoDouble(_Symbol, SYMBOL_POINT);
double lotMax = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX);
double lotMin = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN);
double lotStep = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP);
int digits = (int)SymbolInfoInteger(_Symbol, SYMBOL_DIGITS);
Will work in both versions.
 

Please advise.

There is an example in help: General algorithm of work with orders.

  {
//--- получим общее количество ордеров
   int orders=OrdersTotal();
//--- пробежим по списку ордеров
   for(int i=0;i<orders;i++)
   {
   ResetLastError();
//--- скопируем в кэш ордер по его номеру в списке
   ulong ticket=OrderGetTicket(i);
   if(ticket!=0)// если ордер успешно скопирован в кэш, работаем с ним
   {
   double price_open   =OrderGetDouble(ORDER_PRICE_OPEN);
   datetime time_setup =OrderGetInteger(ORDER_TIME_SETUP);
   string symbol       =OrderGetString(ORDER_SYMBOL);
   long magic_number   =OrderGetInteger(ORDER_MAGIC);
   if(magic_number    ==m_magic)
   {
//  обработаем ордер с заданным ORDER_MAGIC
   }
   PrintFormat("Ордер #%d по %s был выставлен %s, ORDER_MAGIC=%d",ticket,symbol,TimeToString(time_setup),magic_number);
   }
   else  // вызов OrderGetTicket() завершился неудачно
   {
   PrintFormat("Ошибка при получении ордера из списка в кэш. Код ошибки: %d",GetLastError());
   }
   }
  }

At compilation I get a warning ondatetime type, apparently, there is a conflict of type conversion.

I do not understand what is the problem; according to Help,ORDER_TIME_SETUP hasdatetimetype.

What is the problem and how to fix it?

 
vladzeit:

Please advise.

There is an example in help: General algorithm of work with orders.

At compilation I get a warning ondatetime type, there must be a conflict of type conversion.

I do not understand what is the problem; according to Help,ORDER_TIME_SETUP hasdatetimetype.

What is the problem and how to fix it?

datetime time_setup =(datetime)OrderGetInteger(ORDER_TIME_SETUP);
//....
long magic_number   =(long)OrderGetInteger(ORDER_MAGIC);

OrderGetInteger should be converted to the correct type, same with INT

 
Konstantin Nikitin:

OrderGetInteger needs to be converted to the correct type, same with INT

Thanks for the example.

Please clarify... if I understood correctly.

with this=(datetime)OrderGetInteger. we are telling OrderGetInteger to adopt explicitdatetimetype.?

Does this rule apply to all functions that do not have an explicit type or do not match the type of the variable being assigned? Or is it just a special case?

I want to understand if this is a rule or just need to be remembered as a special case.