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

 
ax00071: The log shows an attempt to close buy2, unknown ticket for orderclose function. Code from memory as I'm at work

Ah. Writing from memory as I'm also at work. Try: and Ticket compare with the one in the orderclose report. In the tester it seems to be 0, 1, 2, 3, ....

RefreshRates(); // Это обязательно ДО OrderSelect() и лучше в таком виде: while (! RefreshRates()) ;
for(int i=OrdersTotal()-1; i>=0; i--)
  if (! OrderSelect(i,SELECT_BY_POS)) continue;
  Ticket=OrderTicket(); 
  Lot   =OrderLots();

  // Сообщение о попытке следует выдавать ДО ее осуществления, т.к. попытка может что-то изменить
  Alert ("Попытка закрыть Buy Ticket=",Ticket, "  Lot=",Lot);  // Кажется Alert в тестере бестолкова, попробуйте Print
  Ans=OrderClose(Ticket,Lot,OrderClosePrice() ... );
}

 
novikov433:

I want to learn how to make an EA. Maybe the market will change and I will have to pay more, for example, to change the algorithm a bit?

I don't know if I can really make a TS in any owl constructor, but I'd rather understand the basic functions like making a stop in a certain place or order an order to trade on certain days.

I have no idea what to do with 1,2,3 etc. even in the constructor, and why it's important to connect everything in this order with arrows. Who delivers mql 4 training from A to Z and not like Internet warriors who create courses that explain nothing in detail why it happens this way, in words, you won't make anything new by yourself, you will just have to copy their code .... I mean, they know what order is responsible for what, and they didn't just point at random ..... Well, let the professionals do pyramiding, dynamic lot, smart stop; my task is different - to download the required filters and understand the essence of trend formation. Thanks for your help!

You only need documentation, which is available, and you need to be able to read and understand what you have read. If you have not succeeded in understanding it from the first time, read several times and preferably at a slower pace, so that your brain has time to recognize the meaning of what you have read.

And after that, the imagination has a free hand.

I want to open an order on condition Open the "Trade Functions" section of the documentation and find the function that opens the order and write it according to the syntax...

Oh, yeah... you have to meet the condition... ...open the "Operators" section, read"Conditional if-else statement" and write the necessary condition.

When that's done, you read the documentation from start to finish to figure out what's in the language, what you can get.

Торговые функции - Справочник MQL4
Торговые функции - Справочник MQL4
  • docs.mql4.com
Торговые функции - Справочник MQL4
 
me again :)
Wrote a function that allows no more than n orders to open in 1 day.
Now the function is draining the deposit - i.e. orders open on every tick.

Where did I screw up again?)

int OrderMax = 3; // maximum number of orders that can be opened during 1 day.
void OpenOrders()
{
for (int i = 1; i <= 5; i++)
{
if (DayOfWeek() == i)
{
int count_max = 0;
if (count_max <= OrderMax)
{
for(int cn = OrdersTotal()-1; cn>=0; cn--)
{
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) && OrderType() == OP_BUY)
count_max++;
}
}
}
}
}
 
Guys, is it possible to open orders on other pairs with one EA? For example, an EA only stands on EURAUD and on condition of opening a trade on EURAUD and GBPUSD pairs. What should be the condition if possible?
 
ivan-baaton:
Me again:)
I have written a function which allows to open not more than n orders in 1 day.
Now this function is losing the deposit, i.e. orders are opened on every tick.

Where did I screw up again?)

int OrderMax = 3; // maximum number of orders that can be opened during 1 day.
void OpenOrders()
{
for (int i = 1; i <= 5; i++)
{
if (DayOfWeek() == i)
{
int count_max = 0;
if (count_max <= OrderMax)
{
for(int cn = OrdersTotal()-1; cn>=0; cn--)
{
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) && OrderType() == OP_BUY)
count_max++;
}
}
}
}
}

In my opinion, the approach is not logical at all. Why define the day of the week? What difference does it make what day it is, if the condition should say "do not open more than xxx orders today"?

It seems more reasonable to me to count orders opened today and place an appropriate condition in the condition.

                     if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) && OrderType() == OP_BUY)
                     count_max++; 
missing the definition of the opening date of the order.
 

Rustam Bikbulatov:
Ребята, можно ли с помощью одного советника открывать ордера на других парах? Например Советник только стоит на паре EURAUD и при условии открытии открывается сделка на парах EURAUD и GBPUSD. Какое должно быть условие если будет возможность?

It can.

Only in the tester it doesn't work.

int  OrderSend(
   string   symbol,              // символ
   int      cmd,                 // торговая операция
   double   volume,              // количество лотов
   double   price,               // цена
   int      slippage,            // проскальзывание
   double   stoploss,            // stop loss
   double   takeprofit,          // take profit
   string   comment=NULL,        // комментарий
   int      magic=0,             // идентификатор
   datetime expiration=0,        // срок истечения ордера
   color    arrow_color=clrNONE  // цвет
   );
 
Alexey Viktorov:
Yes, it does.

Only in the tester it doesn't work.


How do you list them, comma or &&?
 
Rustam Bikbulatov:

How do you list them? comma or &&?

Theirs is a what? a list of characters or what?

Each OrderSend has its own single character. No commas or other stuff...

 
Alexey Viktorov:

Theirs is a what? a list of characters or what?

Each OrderSend has its own single character. No commas or other stuff...


list pairs
 
LRA:

Ah. Writing from memory as I am also at work. Try: and Ticket compare with what the order has in the report. In the tester it seems to be 0, 1, 2, 3, ....

Thanks for the heads up )) I am a sucker ... ... at closing I had the condition to close the deal at 22:00 on Friday, without any additional conditions to check the deal type. The deal itself closed a couple of hours earlier. So, when 22:00 p.m. came, the Expert Advisor started sending orders to close an order that was already closed ...
Reason: