Questions from Beginners MQL5 MT5 MetaTrader 5 - page 28

 
Thank you. Just what I need. Made a script and... ...measured it. TERMINAL_MEMORY_TOTAL and TERMINAL_MEMORY_AVAILABLE error in the documentation, never understood what they give out and in what measurements, but it seems not what is intended.
 
paladin800:

Please advise how to check the conditions in the code, e.g:

Cumulatively 1 is the most normal.
 
I am using the standard library to get the current bid:

CSymbolInfo m_symbol;

m_symbol.Bid()


In the tester (All ticks, M1) I get that it is not the current bid but the opening price of the bar. Maybe I missed something? How do I correctly check price on ticks to get correct results in the tester?

Документация по MQL5: Стандартная библиотека
Документация по MQL5: Стандартная библиотека
  • www.mql5.com
Стандартная библиотека - Документация по MQL5
 
tyun:
I am using the standard library to get the current bid:

CSymbolInfo m_symbol;

m_symbol.Bid()


In the tester (All ticks, M1) I get that it is not the current bid but the opening price of the bar. Maybe I missed something? How do I correctly check price on ticks to get correct results in the tester?

https://www.mql5.com/ru/docs/standardlibrary/tradeclasses/csymbolinfo/csymbolinforefreshrates
Документация по MQL5: Стандартная библиотека / Торговые классы / CSymbolInfo / RefreshRates
Документация по MQL5: Стандартная библиотека / Торговые классы / CSymbolInfo / RefreshRates
  • www.mql5.com
Стандартная библиотека / Торговые классы / CSymbolInfo / RefreshRates - Документация по MQL5
 

I open a trade using CTrade with a stop loss.

And how can I catch the moment of closing a deal by Stop Loss in OnTrade or OnTransactionTrade method?

I know the ticket, I know the dial, but they are always different in OnTransactionTrade (although I understand why)

 
WiND:

I open a trade using CTrade with a stop loss.

And how can I catch the moment of closing a deal by Stop Loss in OnTrade or OnTransactionTrade method?

I know the ticket, I know the dial, but they are always different in OnTransactionTrade (although I understand why)

From the comment you can find out if the position was closed by Stop Loss/TakeProfit. For Stop Loss check the sl in the comment and for Take Profit tp.
 
tol64:
According to the comment we can find out if the position has been closed by Stop Loss/TakeProfit. For Stop Loss check the comment sl, and for Take Profit check the tp.

I thought about the comment, but as far as I remember the comments can be changed by the server.

In general, I don't care if it is closed by stoploss, takeprofit or manually.

The main thing is to identify the moment of closing of a certain order.

 
WiND:

I thought about the comment, but as far as I remember the comments can be changed by the server.

In general, I don't care if it is closed by stoploss, takeprofit or manually.

The main thing is to identify the moment of closing of a certain order.

You can also use identifier DEAL_ENTRY_OUT from enumeration ENUM_DEAL_ENTRY to understand that the position has been closed.

Reference: Properties of trades.

 

Hello!

I have an EA in MQl4 which needs to be converted to MQL5. Please help me to understand CopyBuffer() function.

In MQl4, the code looks like this:

....
int start()
{ 
   induk_real1 = iCustom(NULL, PERIOD_H1, "Laguerre", gamma, 950, 0, 0);
   induk1 = NormalizeDouble(induk_real1,2);
 
   if(OrdersTotal( )<1){
  
   if(induk1==1) {

......
}}}

In MQL5 it looks like this. The 'CopyBuffer' error - no one of the overloads can be applied to the function call.

....
int OnInit()
  {
   SymbolSelect(_Symbol,true);
   induk_handle = iCustom(NULL,PERIOD_H1,"Laguerre",gamma); 
   return(0);
  }
void OnDeinit(const int reason)
  {
  }
void OnTick()
  {
   CopyBuffer(induk_handle,0,1,2,induk_real1);
   induk1 = NormalizeDouble(induk_real1,2);
   
    if(OrdersTotal()<1){
    if(induk1==1) {
    ......
     }}}   
 
Aid:

Hello!

I have an EA in MQl4 which needs to be converted to MQL5. Please help me to understand CopyBuffer() function.

In MQl4, the code looks like this:

In MQL5 it looks like this. The 'CopyBuffer' error - no one of the overloads can be applied to the function call.

induk_real1 - there should be an array.