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
Dist "の値をご確認ください。
チェック?どのように?MQL4の本からコード(distance変数がある部分)をコピーしてきました。
see also: https://book.mql4.com/trading/orderclose
1.Dist "の初期値が正しいことを確認します。
2.サイクルの最初に "Dist "の値をチェックするアラートを挿入する: "Alert ( " Dist = ", Dist ) ; "
は、変数 "Dist "を使用せずに正しい順序を選択する方法はありますか?
回答1
サンプル内の符号「>」と「<」は、同じ式でも方向が違う
closeorder.mq 4の22行目と前回のサンプルの6行目を参照ください。
2番目のサンプルでは、間違いだと思うのですが、どうでしょうか?
回答2
"正しい注文 "の意味によって異なります。
OP_BUYの注文が2つあるときに、OP_BUYのうちopenpriceの低いほうを選択して(決済して)、この選択を開始しなければならないのですが、OP_SELLについても同様です。これはそんなに難しい実装なのでしょうか?とても困っています...。
普通の仕事
ということで、何が間違っているのでしょうか?OP_BUYでopenpriceが低いものはどのように選択するのでしょうか?Dist "なしでも試しましたが...。
if (Price < Price), Digits) " という行は、どういう意図なのでしょうか?
どう考えてもおかしいだろ
CB
if (Price < Price), Digits) " という行は、どういう意図なのでしょうか?
どう考えてもおかしい。
それだけではありません。
左括弧が抜けているのに、どうしてエラーなくコンパイルできるのでしょう。
もううんざりだ コード泥棒で無知で馬鹿でワシカスで金払いの悪い奴等だ
すべての人間は間違いを犯す
if (a_human_made_a_mistake==true)
{human_learn_next_lesson();}.
さもなくば
{植物に生まれ変わる=true;}。
{human_learn_next_lesson();}。
MT5があれば。そうすれば、human->learnNextLesson()で代用できるのに。
MT5があれば。そうすれば、human->learnNextLesson()で代用できるのに。
私はOOPをよく知らない。
面倒くさがりなので。
こういうときは勉強しないことにしている...。)
this->repeat->this->repeat->this->repeat->this->repeat->this->repeat->this->this->repeat->this.this->repeat->this->this->repeat->this->this->this->repeat->this->this->this->repeat->this->this->repeat->this->this->this