Questions from Beginners MQL4 MT4 MetaTrader 4 - page 144

 
Ihor Herasko:

Yes, of course. The function is universally written. If we address it on every tick, the loop goes through the entire account history. And the account history can be quite deep (I have encountered cases where there were more than 100 000 orders). To speed up the execution, you don't need to run the loop on the entire history every time. It is enough to do it only once at the very beginning and remember the index of the last order processed. The next time you need to go through the loop only for the orders that have an index greater than the stored index. After that, remember the index of the last order again, and so on.

Thank you for the detailed explanation. Now I know which way to look so to speak. By the way, the demo account worked well with 5 EAs, I mean they repeat all my trades opened within the same date and there was no delay in opening all 5 positions.
 
Vitaly Muzichenko:

The floating spread is to blame.

I also thought that at first, but it is also true for pairs with fixed spread (like DAX30) and for nets consisting of orders in one direction (including one order) - in this case the spread is irrelevant (one price determines profit - either only Bid or only Ask).

Vitaly, I understood from your reply that there is no obvious error in the formulas?

 
Igor Zakharov:

I also thought that at first, but it is also true for pairs with fixed spread (like DAX30) and for nets consisting of orders in one direction (including one order) - in this case the spread is irrelevant (one price defines profit - either only Bid or only Ask).

Vitaliy, I understood from your reply that there is no obvious error in the formulas?

Here is the formula from the worker:

 double poi=SymbolInfoDouble(mSymbol,SYMBOL_POINT);
 int dig=(int)SymbolInfoInteger(mSymbol,SYMBOL_DIGITS);
 double TickValue=SymbolInfoDouble(mSymbol,SYMBOL_TRADE_TICK_VALUE);

 double BuyAwerage=0,SellAwerage=0;
  if(_GetP.Buy._Lots>0)  BuyAwerage= NormalizeDouble(bid-(_GetP.Buy._AllProfit/( TickValue*_GetP.Buy._Lots ))*poi,dig);
  if(_GetP.Sell._Lots>0) SellAwerage=NormalizeDouble(ask+(_GetP.Sell._AllProfit/(TickValue*_GetP.Sell._Lots))*poi,dig);
 
Vitaly Muzichenko:

Here's the formula from the worker:

That is, the full analogue. My formula is even slightly more universal - in general the tick size may not be equal to one point (often found on indices).

Thanks.

 

Hello.

Maybe someone has also encountered the following glitch in MT4.

I'm testing a trading system consisting of several robots for one demo account.

But periodically 1-2 times a day there is a situation that the robot sets a buy stop or sell stop order which does not work. This order is highlighted in yellow and if you try to delete it you will see a warning about disabled parameters.

The robot that set it according to the algorithm should continue its work but it only does this for a price which is better than that set in an incorrect order, i.e., a Sell Stop for orders above and a Buy Stop only for orders below.

If I delete all other orders (thanks to my demo account) and switch off the terminal for a while, this order is activated as required and is either closed at program command or manually.

Please advise whether this has to do with the demo account or because there are several robots attached to different windows.

This kind of binding increases the quality of the whole system, because the terminal reacts much better to commands from individual robots than when all commands are combined in one Expert Advisor. The gain in terminal's reaction time is very significant and timeliness of execution of commands is much better and optimal, if all trading system logic is spread among several robots.

However, I face the problem of freezing of one or two orders.

Perhaps someone has faced this problem or suggest a cause of incorrect operation and a way to fix it.

Thanks in advance.

 

in the picture is green, which is not in the terminal settings.

where can i see the colours that are set by the numbers?

ssb

 
Pavel Ipatov:

But from time to time 1-2 times a day the robot sets a buy or sell order which does not work. It is highlighted in yellow and when you try to delete it, the window shows an inscription about disabled parameters.

This has happened, and more than once. In my case, it was always the broker's fault, not the robot's - if you contact support, they will forcibly remove it. If it's a demo, I'd open a new one with a different broker.

 
Artsem:

in the picture is green, which is not in the terminal settings.

where can i see the colours that are set by the numbers?

ssb

Uh... photoshop.

 
Artsem:

in the picture is green, which is not in the terminal settings.

where can i see the colours that are set by the numbers?

ssb

  1. Click on the drop-down list arrow.
  2. Select Custom.
  3. You will see a window like this.

In the palette you select the colour you want, or you can even manually specify numerical values: red, green, blue.

 
Ihor Herasko:

  1. Click on the drop-down list arrow.
  2. Select Custom.
  3. A window like this will appear.

In the palette, select the colour you want or you can even manually specify numerical values: red, green, blue.

Yes, I did not notice the custom button.

I can't change the colour to "numeric" in your panel.


Reason: