check? How? I copied the code (the part with the distance variable) from the book of MQL4:
int start()// Special function 'start'{string Symb=Symbol();// Symboldouble Dist=1000000.0;// Presettingint Real_Order=-1;// No market orders yetdouble Win_Price=WindowPriceOnDropped();// The script is dropped here//-------------------------------------------------------------------------------- 2 --for(int i=1; i<=OrdersTotal(); i++)// Order searching cycle{if(OrderSelect(i-1,SELECT_BY_POS)==true)// If the next is available{// Order analysis://----------------------------------------------------------------------- 3 --if(OrderSymbol()!= Symb)continue;// Symbol is not oursint Tip=OrderType();// Order typeif(Tip>1)continue;// Pending order //----------------------------------------------------------------------- 4 --double Price=OrderOpenPrice();// Order priceif(NormalizeDouble(MathAbs(Price-Win_Price),Digits)<//SelectionNormalizeDouble(Dist,Digits))// of the closest order {
Dist=MathAbs(Price-Win_Price);// New value
Real_Order=Tip;// Market order availableint Ticket=OrderTicket();// Order ticketdouble Lot=OrderLots();// Amount of lots}//----------------------------------------------------------------------- 5 --}//End of order analysis}//End of order searching//-------------------------------------------------------------------------------- 6 --while(true)// Order closing cycle{if(Real_Order==-1)// If no market orders available{Alert("For ",Symb," no market orders available");break;// Exit closing cycle }//-------------------------------------------------------------------------- 7 --switch(Real_Order)// By order type{case0:double Price_Cls=Bid;// Order Buystring Text="Buy ";// Text for Buybreak;// Из switchcase1: Price_Cls=Ask;// Order Sell
Text="Sell ";// Text for Sell}Alert("Attempt to close ",Text," ",Ticket,". Awaiting response..");bool Ans=OrderClose(Ticket,Lot,Price_Cls,2);// Order closing
I need to select (and close) the order OP_BUY that has the lower openprice and this selection must start when there are 2 orders OP_BUY...the same thing for OP_SELL...is this so difficult to implement? I'm so confused...
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Please check "Dist" value
check? How? I copied the code (the part with the distance variable) from the book of MQL4:
see also: https://book.mql4.com/trading/orderclose1. Make sure that initial value of "Dist" is correct
2. Insert alert to check value of "Dist" in the beginning of cycle: "Alert ( " Dist = ", Dist ) ; "
is there any way to select the right order without using the variable "dist"?
Answer 1
Signs ">" and "<" in the samples are in different directions for the same expression
See line 22 of closeorder.mq4 and line 6 of previous sample
I think in the second sample it must be a mistake...what do you think?
Answer 2
Depends on meaning of "the right order"
I need to select (and close) the order OP_BUY that has the lower openprice and this selection must start when there are 2 orders OP_BUY...the same thing for OP_SELL...is this so difficult to implement? I'm so confused...
ordinary work
so what am I doing wrong? How would you select the OP_BUY with the lower openprice? I tried even without "Dist"...
What's the intention with the line " if (Price < Price), Digits) " ??
Looks nuts to me.
CB
What's the intention with the line " if (Price < Price), Digits) " ??
Looks nuts to me.
not only thats.
how could this compile errorfree, with a missing left bracket.
i am tired of this code-grabbing-null-insight-full-idiots-and-full-wasicus-and-not-want-to-pay-a-cent-asking-for-help-guys
all humans make mistakes
if (a_human_made_a_mistake==true)
{human_learn_next_lesson();}
else
{reincarnate_as_plant=true;}
{human_learn_next_lesson();}
If only we had MT5. Then we could do human->learnNextLesson() instead.
If only we had MT5. Then we could do human->learnNextLesson() instead.
i have never been familiar with OOP.
i hate that. too much hassle about nothing.
in such cases, i refuse to learn... ;-)
this->repeat->this->repeat->this->repeat->this->repeat->this->repeat->this->repeat->this->repeat->this;