Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1550

 
законопослушный гражданин:

as I understand it, the author of the code suggested the following:

if owl opens a buy trade with stop and take, then his piece of code opens a sell trade at the same time in the same place (taking into account the spread) with stop and take instead of a buy trade.

thus the logic of search for an entry point of the EA does not change, and only the direction with spread taken into account changes.

this is exactly what i need

If you want to reverse all trades, just swap

vOrderOpenSell and vOrderOpenBuy


//+-----------------------------------------------------------------------------------------------+
void OnTick()
  {
// Получим значение индикатора
   dMA = iMA(Symbol(), 0, iPeriodMA, 0, MODE_SMA, PRICE_CLOSE, 0);

// Если нет открытых ордеров, то входим в условие
   if(bCheckOrders() == true)
     {
      // Если появился сигнал на покупку, то откроем ордер на покупку
      if(bSignalBuy() == true)
         vOrderOpenSell();

      // Если появился сигнал на продажу, то откроем ордер на продажу
      if(bSignalSell() == true)
         vOrderOpenBuy();
     }
  }
 
SGarnov:

First result. There is a conflict between currency pairs and EA has a conflict on pending order placement. For example, I have placed a pending order for EURUSD, EA has followed the algorithm (Buy at 1.18901, opened a trade, set stop at 1.18751, take profit at 1.19051 and a sell order at 1.18751) everything is ok as per plans.

But now it is time to open a deal at GBPUSD where the prices are different and the EA is doing everything right, except for setting a pending order. A Sell order at 1.39393 has triggered and the EA tried to open it, set a stop at 1.39633 and take 1.39153 but the buy order at 1.39633 is fully duplicated in EURUSD and a sell order at 1.18751)

I have just found another problem: a stop at 1.18751 and a sell pending order at 1.18901 and take 1.18595 were opened on EURUSD. The Expert Advisor didn't add the triggered stop to the take which is in the history.

These are the problems.

I have found a mistake on the orders and I am working on the additions

 
MakarFX:

If you need to reverse all trades, just swap here

vOrderOpenSell and vOrderOpenBuy


No, I don't need reversal but "mirroring" loss-making trades to another terminal while taking into account the spread.

but testers don't give such possibilities, i need owls in the tester to "mirror" trades with spread as if they are opened in another terminal but according to this owl's logic, say, through a rewrder copyer.

I need it to test the TS

 
Alexey Viktorov:

Makar correctly pointed to OrderMagicNumber(), but misunderstood the error. Read the documentation for the syntax of this function... it should be either an index in the order list or a ticket of a specific order, but not a magik. And OrderTicket() will not help here. Do not try to put it there.

It makes sense. I have compiled it and replaced it with OrdersHistoryTotal, and in the terminal settings I have made the history for the last three days. I will test it.

 
законопослушный гражданин:

I don't need reverse, but "mirroring" loss-making trades to another terminal, taking into account the spread, like in the subject of the code's author.

But testers don't provide such possibilities, for this I need owls in the tester to "mirror" trades with spread, as if they are opened in another terminal but according to this owl's logic, say, through a copyer with rewind.

I need it to check the TS

If the problem with market entry orders try to replace this

///////////////
if (cmd==OP_SELL) // Переворачиваем ордера OP_SELL
{
Ret=OrderSend (symbol,OP_BUY,volume,Ask,slippage,takeprofit-sprd,stoploss-sprd,comment,magic,expiration,arrow_color);
}
if (cmd==OP_BUY) // Переворачиваем ордера OP_BUY
{
Ret=OrderSend (symbol,OP_SELL,volume,Bid,slippage,takeprofit+sprd,stoploss+sprd,comment,magic,expiration,arrow_color);
}

And if the problem is with all orders, then check STOPLEVEL

 
MakarFX:

........................., and working with addition

I've come to the conclusion that it's difficult to implement, your code is much simpler, clearer and more logical, but ..... for some reason doesn't add either. The main thing is not to give up.

 
SGarnov:

I've come to the conclusion that it's difficult to implement, your code is much simpler, clearer and more logical, but ..... somehow doesn't add up either. The main thing is not to give up.

I serve the Soviet Union!
 
SGarnov:

I've come to the conclusion that it's difficult to implement, your code is much simpler, clearer and more logical, but ..... somehow doesn't add up either. The main thing is not to give up.

MakarFX:
I serve the Soviet Union!

Maybe you should also take into account the number of triggered stops. For example, the EA will find a stop in the history, and if there are two of them, it should add both three and four, it all depends on the external setting "number of stop losses".

 
SGarnov:

Maybe you should also take into account the number of stops triggered. For example, the EA will find a stop in the history, and if there are two, it should add them both three and four, it all depends on the external setting "number of stop losses".

There is an accounting of the number of triggered stops and if the "Number of losing orders" is higher than the specified in the settings, then the pending orders are not placed anymore (already checked).
 

Hello all, help please!

I have a problem like this. I bought a vpc from mql5 everything works fine, installed myself an expert, set up 8 charts and set up an expert. And i transferred the whole thing to vpc.

I had to uninstall metatrade from my computer because it was not mine.

And now when I go in from my computer.

Everything works, the expert. It works, but I cannot see it to make any changes in settings. How can I return the EA and schedules so that I can manage them from my computer?

Thank you!