Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1404

 

I hope the translation will be faithful, but obviously it won't be...

It is for this and other reasons that we do NOT need Global THREADS...

Otherwise, we wouldn't have Regional Forums...

Bizarre move...

:(

 
Hello! I have built a computer with 24 cores to speed up optimization and to be able to optimize strategy performance on small TFs, such as M1, M2, etc. When I start it up I see that the process occasionally freezes and hangs for a long time. I am attaching three pictures about it. On my old computer (8 cores) and nothing like this happens. Moreover, there is no benefit in using a powerful computer as a result of this stalling. Currently I can see that 8 cores gives faster result than 24x. And I wanted to get 10x speedup. Perhaps there is something I need to adjust somewhere? Please advise if anyone knows what it might be.
 

Hello.

I want to make a universal include file that can be included with any EA. And it should be limited to just one inclusion without any additional code.

The problem is that the file uses OnTimer() as input point.

What if EA (which my include file connects to) also uses OnTimer()? Is there any solution?

 

Good afternoon. I trade on the Moex stock market. Broker Otkritie. If there are open positions for several instruments, the robot confuses them when sending a request to partially close them (it can send a request with the price of Sberbank shares for Magnit shares, for example. I.e., the instrument in the request is specified for Magnit, but the prices are specified for Sberbank) or simply does not send the request. Code of closing algorithm for Long position (runs when price of instrument Price_Close_1_Buy is reached):

void Price_Close_1_Buy()
  {

   MqlTradeRequest arequest;
   MqlTradeResult aresult;
   ZeroMemory(arequest);
   ZeroMemory(aresult);

   for(int i=PositionsTotal()-1; i>=0; i--)
      {
       if(Symbol()==PositionGetSymbol(i))
      {
       arequest.action   = TRADE_ACTION_DEAL;
       arequest.position = PositionGetTicket(i);
       arequest.symbol   = Symbol();
       arequest.volume   = NormalizeDouble((Lots_Close_1/100*Lots_current()),0);
       arequest.price    = aposition.PriceCurrent();
       arequest.type_filling = ORDER_FILLING_FOK;
       arequest.type     = ORDER_TYPE_SELL;
       Price_Close_1_Buy_Request_Send = true;
      }
       OrderSend(arequest,aresult);
       Print("=================================================================================================== ");
       Print(asymbol.Name());
       Print("Price_Close_1_Buy_request() ",arequest.price);
       Print("Lots_Close_1_Buy_request() ",arequest.volume);
       Print("Result ", aresult.comment);
       Print("Retcode ",aresult.retcode);
      }
  }
 
leonerd #:

Hello.

I want to make a universal include file that can be included with any EA. And it should be limited to just one inclusion without any additional code.

The problem is that the file uses OnTimer() as input point.

What if EA (which my include file connects to) also uses OnTimer()? Is there a solution?

Don't ever do this.

Just a piece of advice. Not going to change my mind.

 
Manter84 there are open positions for several instruments, the robot confuses them when sending a request to partially close them (it can send a request with the price of Sberbank shares for Magnit shares, for example. I.e., the instrument in the request is specified for Magnit, but the prices are specified for Sberbank) or simply does not send the request. Code of closing algorithm for Long position (runs when price of instrument Price_Close_1_Buy is reached):
On the price issue - dig
aposition.PriceCurrent()
 
Koldun Zloy #:

Don't ever do that.

Just a piece of advice. I'm not going to change your mind.

These are the requirements of the project.

 

How do I override the default OrderSend()?

#define OrderSend(MqlTradeRequest,MqlTradeResult)  MyOrderSend(MqlTradeRequest,MqlTradeResult)

I added a line at the top.

In my MyOrderSend() I do some calculations and call OrderSend() again. I want to call native OrderSend(), but instead I get recursion and MyOrderSend() is called again.

And this call doesn't help either ::OrderSend()
 
leonerd I haveadded aline above.

In my MyOrderSend() I do some calculations and call OrderSend() again. I want to call the native OrderSend() function, but instead I get a recursion and MyOrderSend() is called again.

This doesn't work at all. #define replaces the first (the call) with the second in the program code, as OrderSend(..) is replaced with MyOrderSend(..) every time it occurs.

 
Carl Schreiber #:

This doesn't work at all. #define replaces the first (call) with the second in the program code, as OrderSend(...) is replaced by MyOrderSend(...) every time it happens.

yeah, and I've got it working... I #define just put it under my MyOrderSend().