Questions from a "dummy" - page 40

 

Please explain why none of the EAs in MetaTrader 5 are tested in the strategy tester. I press start and nothing happens. Please explain.

 
PATRIOT:

Please explain why none of the EAs in MetaTrader 5 are tested in the strategy tester. I press start and nothing happens. Please explain.

Look in the logbook (for starters).
 

Cannot retrieve data from predefined structures in created functions. For example:

void OnTick()
{
//--- Объявляем структуру
 MqlRates rates[];
 ArraySetAsSeries(rates,true);

//--- Скопировать необходимое количество значений в массив
 if(CopyRates(NULL,0,0,4,rates) < 0) { Print(ErrorDescription(GetLastError())); return; }
...
}

Then when trying to retrieve values in a created function:

void Trailing_Stop_Loss(ENUM_POSITION_TYPE Type, double Trailing_Stop)
{
 string Val_Time = TimeToString(rates[1].time,TIME_DATE|TIME_MINUTES);

...
}

We get an error message:

How do I declare structures so that they are available in all parts of the program?

Документация по MQL5: Стандартные константы, перечисления и структуры / Коды ошибок и предупреждений / Ошибки компиляции
Документация по MQL5: Стандартные константы, перечисления и структуры / Коды ошибок и предупреждений / Ошибки компиляции
  • www.mql5.com
Стандартные константы, перечисления и структуры / Коды ошибок и предупреждений / Ошибки компиляции - Документация по MQL5
 
tol64:

Cannot retrieve data from predefined structures in created functions. For example:

Then when trying to retrieve values in a created function:

We get an error message:

How do I declare structures so that they are available in all parts of the program?

In the global scope. Outside the function.
 
What functions can be used to check if a trade thread is free for performing a trade operation? In MQL4, functions IsTradeAllowed() and IsTradeContextBusy() were intended for this purpose.

The CAccountInfo class of the standard library has the TradeAllowed() function. It is written in the help that it means:"Trading is allowed/forbidden for this account". I didn't find an error code in the trade server's return codes, which means the trade stream may be busy. Is this check now in the trading terminal itself? Please clarify.


 
tol64:
What functions can be used to check if a trade thread is free for performing a trade operation? In MQL4, functions IsTradeAllowed() and IsTradeContextBusy() were intended for this purpose.

The CAccountInfo class of the standard library has the TradeAllowed() function. It is written in the help that it means:"Trading is allowed/forbidden for this account". I didn't find an error code in the trade server's return codes, which means the trade flow may be busy. Is this check now in the trading terminal itself? Please clarify.

In MT5, the trade thread is never busy because trade operations are asynchronous. Rejoice.
 
tol64:
What functions can be used to check if a trade thread is free for performing a trade operation? In MQL4, functions IsTradeAllowed() and IsTradeContextBusy() were intended for this purpose.

The CAccountInfo class of the standard library has the TradeAllowed() function. It is written in the help that it means:"Trading is allowed/forbidden for this account ". I didn't find an error code in the trade server's return codes, which means the trade flow may be busy. Is this check now in the trading terminal itself? Please explain.


In MetaTrader5 there is no such a thing as a busy trade thread, while MT4 could process only one trader's order, in MT5 a lot of orders are processed in parallel. Return codes from the server for any order can be obtained in the OnTrade() function.
 
uncleVic:

You just need to set the price.

If no price is set (default is 0.0) or if the market price is set, CExpertTrade is prompted from CExpert to open a position on the market.

If the price is set better than the market (below the current price to buy and above the current price to sell), CExpertTrade will place a limit order (if the margin is respected).

If the price is below the market (above the current bid and below the current ask), CExpertTrade will place a stop order (if the margin is respected).

bool Chhhh::OpenLongParams(double& price, double& sl, double& tp, datetime& expiration)
{
   printf("11111111");
   if(2+2==4)
   {
      price=1.5;
      sl=0;
      tp=0;
      expiration=0;
      return(true);
   }
   else
   {
      return(false);
   }
}

int Chhhh::LongCondition()
{
  printf("222222222");
  return(60);
}
OpenLongParams doesn't work at all, it won't even return "1111111111",
and LongCondition will return "2222222" and open an order,
is it something wrong or is it set differently?
 
sergeev:

The specific type is set when the order is placed. OrderSend
What does OrderSend have to do with it ?
 
Lodar:
OpenLongParams doesn't execute at all, it doesn't even write "1111111111",
but LongCondition will write "222222222" and open an order,
am I doing something wrong or is it set differently ?

In principle, things are much simpler. In 99 per cent of cases, the input level can be adjusted using an input parameter:

input double Inp_Signal_PriceLevel    =0.0;

The value is set in "large" pips (i.e. 2/4 digits).

Value = 0 - market entry.

Value > 0 - entry by limit order.

Value < 0 - entry by stop order.

The parameter relates to the main signal (in which signals selected in the Wizard are collected for voting). The algorithm of price levels setting is already implemented in the CExpertSignal base class (the instance of which is the main signal).

But if you want to use an algorithm that differs from the implemented one... But that's for later, when it will be interesting.