Questions from Beginners MQL5 MT5 MetaTrader 5 - page 321

 
C-4:

Once again (read carefully):

In MetaTrader4 you can close orders only sequentially: send an order to close an order, wait for its execution, move on to the next order, etc. For this reason the time to close a batch of orders in MetaTrader4 is substantial and cannot be reduced by trivial means. However, you can upload several Expert Advisors to your own charts and make them exchange information with each other and close orders by a common command. Each expert closes orders only at its symbol. Since there are several trade threads in MetaTrader4, they would not block each other and send orders to each other. However, the organization of such a pool of experts is complicated, and judging by your level of knowledge, I would not advise you anything like that.

If you still think I've written too many words, here's a brief summary:

1. The answer to your question is no, you cannot run a script from an Expert Advisor.

2. You cannot increase execution speed of trade orders in MetaTrader4 without using complex methods.

The only way to solve your question normally is the OrderSendAsync function, which does not exist in MetaTrader4.

Thank you very much for your detailed reply! If you don't mind, please share your thoughts on such an idea:

Add 2 parameters to the Expert Advisor which closes all orders at total profit, to sort orders:
(1 parameter - 1-sorting by mag in descending order or 2 - ascending order and 2 - 0-sell and buy, 1-sell orders, 2-buy orders)
Open 4 terminals with 1 account and 1 joint chart of the same pair, so that the ticks coincide and set different parameters like 1-1, 1-2, 2-1, 2-2
that will divide them into 4 flows: minimum magician sell, minimum magician buy, maximum magician sell, maximum magician buy

Or am I being stupid again? And yes, you are right about my level of knowledge!

 
Novikov:

Thank you very much for the detailed reply! If you don't mind, please share your thoughts on this idea:

Add 2 parameters to the Expert Advisor that closes all orders at total profit, to sort orders:
(1 parameter - 1-sorting by mag in descending order or 2 - ascending order and 2 - 0-sell and buy, 1-sell orders, 2-buy orders)
Open 4 terminals with 1 account and 1 joint chart of the same pair, so that the ticks coincide and set different parameters like 1-1, 1-2, 2-1, 2-2
that will divide them into 4 flows: minimum magician sell, minimum magician buy, maximum magician sell, maximum magician buy

Or am I being stupid again? And yes, you are right about my level of knowledge!

Yes, it can be done that way. But there is no need to run several terminals. Run one terminal, and it has 4 windows. Put one robot on each window. Use numbers as one of parameters of this robot: 1-4. In other words, you should assign the robot with parameter 1 to the first window, with parameter 2 to the second window and so on. When the time comes to close the orders, each of the robots will compare the magic number of the selected order with the magic number of the parameter and close it. Orders with other majicks will be given to other Expert Advisors to close.
 
C-4:
Yes, we can do this. But there is no need to run several terminals. You need to launch one terminal, and it has 4 windows. Put one robot on each window. Use numbers as one of parameters of this robot: 1-4. In other words, you should assign the robot with parameter 1 to the first window, with parameter 2 to the second window and so on. When the time comes to close the orders, each of the robots will compare the magic number of the selected order with the magic number of the parameter and close it. Orders with other majicks will be given to other Expert Advisors to close.

On the mt5 forum, when I initially considered 4 windows, as you suggest, one programmer answered: "The terminal is one. It means that there is only one "hole", i.e. there is only one small "hole" in the terminal for access to the server, the size of one request, which is used by all EAs and scripts, which are running in the terminal. No one can access the server until the single request is processed.

So, which is better and truer - 4 charts in 1 terminal or 4 terminals?

 
Novikov:

On the mt5 forum, when I initially considered 4 windows, as you suggest, one programmer answered: "The terminal is one. It means that there is only one "hole", i.e. there is only one small "hole" in the terminal for access to the server, the size of one request, which is used by all EAs and scripts, which are running in the terminal. As long as one request is not processed, no one else can access the server.

So, what will be better and truer - 4 charts in 1 terminal or 4 terminals?

Think about the answer of this "programmer" yourself. If it were so, it would be impossible to trade with several Expert Advisors in one terminal. They would constantly get context busy, i.e. they would block each other. Earlier in shaggy versions of MT4 there was indeed such an error and one could encounter it, but now, as far as I know, it has even been removed because it is no longer relevant. The multithreading of order execution in MT4 has been greatly extended and has been around for a long time.

In any case, you should follow my advice and, if something goes wrong, it will not be difficult to move some EAs to another terminal.

 
Novikov:

On the mt5 forum, when I initially considered 4 windows, as you suggest, one programmer answered: "The terminal is one. It means that there is only one "hole", i.e. there is only one small "hole" in the terminal for access to the server, the size of one request, which is used by all EAs and scripts, which are running in the terminal. No one can access the server until the single request is processed.

So, which is better and truer - 4 charts in 1 terminal or 4 terminals?

Where do you find such "programmers"?
 

Dear, one more question: Would the OrderCloseBy function help to speed up the closing of a large order stack?

For example: When a given profit is reached, open 1 more order on the pair(s) to equalize the lot size of buy and sell orders, and then run "close overlapped orders".

Quotes are 5 digits.

 

Guys, can you advise on this question, it may be of an organisational nature. I can't show you the code of the indicator. It's written competently, everything has been tested before.

Started the question from here: https://www.mql5.com/ru/forum/6343/page323

Installed the terminal from the MQ website - it offered an Alp demo server by default. Ended up running the test on eurobucks:

My understanding is that it's waiting for data from the pound-dollar. No trades are opening anywhere.

Next, when running on the pound-bucks it says:

pending data for USDJPY.

 

And only when running on USDJPY - there is no data waiting - but still no trades open.

I didn't explicitly specify a pair to open trades in the code, i.e. for example

All for any symbol _Symbol. And it's not a question of opening orders... What could be the reason? Thanks.

 for(int i=0;i<10;i++)
     {
      volume=NormalizeDouble(volume,1);
      if(volume<=0) break;
      if(Type==POSITION_TYPE_SELL)
        {
         request.type=ORDER_TYPE_SELL;
         request.price=SymbolInfoDouble(_Symbol,SYMBOL_BID);
         if(TP!=0) takeprofit = request.price-TP*_Point;
         if(SL!=0) stoploss = request.price+SL*_Point;
        }
      if(Type==POSITION_TYPE_BUY)
        {
         request.type=ORDER_TYPE_BUY;
         request.price=SymbolInfoDouble(_Symbol,SYMBOL_ASK);
         if(TP!=0) takeprofit = request.price+TP*_Point;
         if(SL!=0) stoploss = request.price-SL*_Point;
        }
      request.action = TRADE_ACTION_DEAL;
      request.symbol = _Symbol;
      request.volume = MathMin(volume,SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MAX));
      request.sl = stoploss;
      request.tp = takeprofit;
      request.deviation=SymbolInfoInteger(_Symbol,SYMBOL_SPREAD);
      request.type_filling=ORDER_FILLING_FOK;
      request.comment=" ";//DoubleToString(Money,2)+"$";
      if(!OrderCheck(request,check))
        {
         if(check.margin_level<100) volume-=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP);
 

The indicator assigns weights to each instrument, which results in a kind of cluster analysis. It does not want to work in the tester. What may be the reason? I thank you.

And the agents work fine, everything is charged and ready to go...


 
R0MAN:

The indicator assigns weights to each instrument, which results in a kind of cluster analysis. It does not want to work in the tester. What may be the reason? I thank you.

And the agents work fine, everything is charged and ready to go...


Write to servicedesk. They'll have to give you the code, though.
Reason: