Questions from Beginners MQL5 MT5 MetaTrader 5 - page 861

 
Artyom Trishkin:

View the trades belonging to the position and see their volume.

Just unpin all the position trades found (properties of each) - figure out what you need to search for there.

Thank you.

 

I need help in creating a file, in particular, specifying the correct location for its storage.

I use portable version of MT5 and I need the file to be created in folder MT5\MQL5\Files, but it is created in MT5\Tester/Agent-127.0.0.1-3000\MQL5\Files during initialization in the Strategy Tester.

   filename = (Dir=="" ? filename : Dir+"\\"+filename)+".csv";
   handle= Common ? FileOpen(filename,FILE_CSV|FILE_COMMON|FILE_READ|FILE_WRITE|FILE_SHARE_READ) :
                        FileOpen(filename,FILE_CSV|FILE_READ|FILE_WRITE|FILE_SHARE_READ);
 
Aleksey Vyazmikin:

I need help in creating a file, in particular, specifying the correct location for its storage.

I use portable version of MT5 and I need the file to be created in folder MT5\MQL5\Files during initialization in the Strategy Tester, but it is created in MT5\Tester/Agent-127.0.0.1-3000\MQL5\Files.

There is no solution in pure MQL. You have to use WinAPI. Or by hand)))

The way the files are distributed was specially made for security reasons.

 
Ihor Herasko:

There is no solution in pure MQL. Only by using WinAPI. Or by hand)))

This distribution of files was done for security reasons.

The optimizer stores data not in the folder of agents, but in the folderMT5\MQL5\Files - it is not logical.

 
if(crossed==1)
     {
      double sl=(InpStopLoss==0)?0.0:m_symbol.Bid()+ExtStopLoss;
      double tp=(InpTakeProfit==0)?0.0:m_symbol.Bid()-ExtTakeProfit;
      m_trade.Sell(InpLots,m_symbol.Name(),m_symbol.Bid(),
                   m_symbol.NormalizePrice(sl),
                   m_symbol.NormalizePrice(tp));
      datetime time=TimeCurrent();
      for(int i=0;i<4;i++)
        {

How do I set a different magic number to the order to be placed in this code? Different from this generic one -

int OnInit()
//---
   m_trade.SetExpertMagicNumber(m_magic);
//---
 
ilyav:

How do I set a different magic number to the order to be placed in this code? Different from this generic one -

Before sending an opening order with a different magician, execute this line with the desired magician. Next, return the magician to its place.
 
Please advise how to make a function for setting the required number of orders! for example, to open a specified number of orders without more. in mql4
 
This is the last parameter of the OrderSend function in MQL-4:

arrow_color=clrNONE[in] The colour of the opening arrow on the chart. If CLR_NONE - there is no arrow. In MT5, the arrow is always displayed - there is no corresponding parameter in the MqlTradeRequest structure. How do you deal with it? It is easy to do it on your chart. However, if another chart is opened for the symbol, you have to try again...


 
Лауреат:
Please advise how to make a function that sets the right number of orders! for example, I want it to open the orders we have specified but no more than that. in mql4
if(OrdersTotal() < OrdersMax) OrderSend(...); else Alert("The required number of orders is opened");
 
Artyom Trishkin:
Before sending an order to open with another magician, execute this line with the desired magician. Next, return the magician to its place.


if(crossed==1)
     {
      m_trade.SetExpertMagicNumber(m_magic2); // меняем мэджик на новый
      double sl=(InpStopLoss==0)?0.0:m_symbol.Bid()+ExtStopLoss;
      double tp=(InpTakeProfit==0)?0.0:m_symbol.Bid()-ExtTakeProfit;
      m_trade.Sell(InpLots,m_symbol.Name(),m_symbol.Bid(),
                   m_symbol.NormalizePrice(sl),
                   m_symbol.NormalizePrice(tp));
      m_trade.SetExpertMagicNumber(m_magic);  // меняем мэджик на оригинал
      datetime time=TimeCurrent();
      for(int i=0;i<4;i++)
        {
Is that correct ? Thank you
Reason: