[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 451

 
Vinin:

Why does the English proverb "great minds think alike" in Russian
correspond to the phrase "fools think alike"?

 
Vinin >>:

Наверно надо предварительно выбрать ордер.

I know, I've written before on page 445 but I still have a problem.


My problem is getting to a ridiculous point. Error in order closing function.

OrserClose(int tip){
if( tip==1){
for( i=0; i<OrdersTotal(); i++){
           if(true==OrderSelect( i, SELECT_BY_POS, MODE_TRADES)){
           if(OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderMagicNumber() == Magic){
           OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);
               }
           }
         }  
}

I got an error (in different terminals)

EURCHF,M5: OrderClose error 4107

EURCHF,M5: invalid price 1.48566000 for OrderClose function


if I do

OrderClose(OrderTicket(), OrderLots(),OrderClosePrice(),3, Violet);
OrderClose(OrderTicket(),OrderLots(),MarketInfo(Symbol(),MODE_BID),3,Violet);

the same error. But when I write OrderClose(...) not in a separate function, but in int start(), this error doesn't occur.

What is the problem and how to fix it?



 
Urain писал(а) >>

Why does the English proverb "great minds think alike" in Russian
correspond to "fools think alike"?

Then we're in luck.

 
T-G писал(а) >>

I know, I've written before on page 445 but I still have a problem.

My problem is getting to a ridiculous point. Error in order closing function.

I got an error (in different terminals)

EURCHF,M5: OrderClose error 4107

EURCHF,M5: invalid price 1.48566000 for OrderClose function

if I do

the same error. But when I write OrderClose(...) not in a separate function, but in int start(), this error doesn't occur.

What is the problem and how to fix it?

I don't know, I don't know. I always use my own function to close the order.

As an example, this one.

//+------------------------------------------------------------------+
//|                                         Функция закрытия ордеров |
//|                                Copyright © 2010, Victor Nicolaev |
//|                                            e-mail: vinin@mail.ru |
//+------------------------------------------------------------------+
//| void Order_Close(int lMagic, int lOP=-1);                        |
//+------------------------------------------------------------------+
void Order_Close(int lMagic, int lOP=-1){
   bool res;
   GetLastError();
   for(int i = OrdersTotal() - 1;  i >= 0;  i--) {
      if (!OrderSelect( i, SELECT_BY_POS, MODE_TRADES))   continue;
      if (OrderSymbol() != Symbol())                     continue;
      if (OrderMagicNumber() != lMagic)                   continue;
      if (OrderType()!= lOP && lOP!=-1)                     continue;
      
      RefreshRates();
      double _ask      =MarketInfo(Symbol(),MODE_ASK);
      double  _bid     =MarketInfo(Symbol(),MODE_BID);
      double  _point   =MarketInfo(Symbol(),MODE_POINT);
      double  _digits  =MarketInfo(Symbol(),MODE_DIGITS);

      double ClosePrice=NormalizeDouble( iif(OrderType()==OP_BUY,_bid, _ask),_digits);
      res=OrderClose(OrderTicket(), OrderLots(), ClosePrice, 3, iif(OrderType()==OP_BUY, clCloseBuy, clCloseSell));
      if (! res) {
         int err=GetLastError();
         Print("Error(", err,") delete order ", NameOP[ lOP],": ", ErrorDescription( err));
      }
   }
}

To use it you need more functions

//+------------------------------------------------------------------+
//|                                    Функция логического сравнения |
//|                                Copyright © 2010, Victor Nicolaev |
//|                                            e-mail: vinin@mail.ru |
//+------------------------------------------------------------------+
//| double iif(bool A, double B, double C);                          |
//+------------------------------------------------------------------+
double iif(bool A, double B, double C) {if( A) return( B); return( C); }
 

Help with the problem of controlling history holes. Please advise on a really working mechanism for the Expert Advisor to catch the 4066 error.

If there is no unambiguous control over the procedure of history data loading, trading using Expert Advisors makes no sense.

The risk of such trading simply tends to infinity, whatever trading strategy you use.


I was very surprised that the solution to this problem the user has to think out on his own and through one place.

I think the lack of clear support from the developer on this issue is a pure set up.

I think MetaQuotes could publish a set of recommended and tested solutions for common questions and problems.

 
MoneyJinn писал(а) >>

I think MetaQuotes could publish a set of recommended and tested solutions for standard common questions and tasks.

The article "Graphs without holes". might help... https://www.mql5.com/ru/articles/1407

 

The topic is called "any question" and not just about the code?

I have a question, or rather I want an opinion, where do you think the price will go?



 
T-G >>:

Тема же называется "любой вопрос" а не только по коду?

У меня вопрос, а точнее хочется узнать мнение, куда по вашему мнению двинется цена?

this is not a beginner's question :)

 
Help solve this problem.
If there is a function that divides an oversized lot into multiple orders, please share.

Thank you.




Reason: