たんもん - ページ 2

 
Ais:

Dist "の値をご確認ください。

チェック?どのように?MQL4の本からコード(distance変数がある部分)をコピーしてきました。

int start()                                     // Special function 'start'
  {
   string Symb=Symbol();                        // Symbol
   double Dist=1000000.0;                       // Presetting
   int Real_Order=-1;                           // No market orders yet
   double 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 ours
         int Tip=OrderType();                   // Order type
         if ( Tip>1) continue;                   // Pending order  
         //----------------------------------------------------------------------- 4 --
         double Price=OrderOpenPrice();         // Order price
         if (NormalizeDouble(MathAbs( Price- Win_Price),Digits)< //Selection
            NormalizeDouble( Dist,Digits))       // of the closest order       
           {
            Dist=MathAbs( Price- Win_Price);      // New value
            Real_Order= Tip;                     // Market order available
            int Ticket=OrderTicket();           // Order ticket
            double 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
        {
         case 0: double Price_Cls=Bid;          // Order Buy
            string Text="Buy ";                 // Text for Buy
            break;                              // Из switch
         case 1: 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
see also: https://book.mql4.com/trading/orderclose
 
Ais:

1.Dist "の初期値が正しいことを確認します。

2.サイクルの最初に "Dist "の値をチェックするアラートを挿入する: "Alert ( " Dist = ", Dist ) ; "

は、変数 "Dist "を使用せずに正しい順序を選択する方法はありますか?

 
Ais:

回答1

サンプル内の符号「>」と「<」は、同じ式でも方向が違う

closeorder.mq 4の22行目と前回のサンプルの6行目を参照ください。

2番目のサンプルでは、間違いだと思うのですが、どうでしょうか?

 
Ais:

回答2

"正しい注文 "の意味によって異なります。

OP_BUYの注文が2つあるときに、OP_BUYのうちopenpriceの低いほうを選択して(決済して)、この選択を開始しなければならないのですが、OP_SELLについても同様です。これはそんなに難しい実装なのでしょうか?とても困っています...。

 
Ais:

普通の仕事

ということで、何が間違っているのでしょうか?OP_BUYでopenpriceが低いものはどのように選択するのでしょうか?Dist "なしでも試しましたが...。


if ( CheckFirstOP(OP_BUY) > 1) {      
      for(int i = OrdersTotal() - 1; i >= 0; i--) {
          OrderSelect( i, SELECT_BY_POS, MODE_TRADES);
          if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber || OrderType() != OP_BUY) continue;     
          double Price = OrderOpenPrice();
          if ( Price < Price), Digits) {                                            
             int Ticket = OrderTicket();           
             double Lot = OrderLots();                          
             OrderClose( Ticket, Lot, OrderClosePrice(), 3); 
         }    
      }   
   }
without any results
 

if (Price < Price), Digits) " という行は、どういう意図なのでしょうか?

どう考えてもおかしいだろ


CB

 
cloudbreaker:

if (Price < Price), Digits) " という行は、どういう意図なのでしょうか?

どう考えてもおかしい。

それだけではありません。

左括弧が抜けているのに、どうしてエラーなくコンパイルできるのでしょう。

もううんざりだ コード泥棒で無知で馬鹿でワシカスで金払いの悪い奴等だ

 
Ais:

すべての人間は間違いを犯す

if (a_human_made_a_mistake==true)

{human_learn_next_lesson();}.

さもなくば

{植物に生まれ変わる=true;}。

 
meikel:

{human_learn_next_lesson();}。

MT5があれば。そうすれば、human->learnNextLesson()で代用できるのに。

 
jjc:

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