Yeni başlayanlardan sorular MQL5 MT5 MetaTrader 5 - sayfa 672

 
fxsaber :
Teşekkürler!!!
 

Martingale üzerine çalışan bir danışman yazıyorum.

Bir döviz çiftinde puan olarak izin verilen maksimum kayba ulaştığında, açtığı tüm emirleri kapatmaya nasıl zorlanır?

 
RichLux :

Martingale üzerine çalışan bir danışman yazıyorum.

Bir döviz çiftinde puan olarak izin verilen maksimum kayba ulaştığında, açtığı tüm emirleri kapatmaya nasıl zorlanır?


double GetProfitinCurrency( string order_symbol= "" , int order_type=- 1 , int order_magic=- 1 )
  {
   double profit= 0 ;
   int     i,k= OrdersTotal ();

   if (order_symbol== "0" ) order_symbol= Symbol ();
   for (i= 0 ; i<k; i++)
     {
       if ( OrderSelect (i, SELECT_BY_POS , MODE_TRADES ))
        {
         if (( OrderSymbol ()==order_symbol || order_symbol== "" ) && (order_type< 0 || OrderType ()==order_type))
           {
             if ( OrderType ()== OP_BUY || OrderType ()== OP_SELL )
              {
               if (order_magic< 0 || OrderMagicNumber ()==order_magic)
                 {
                  profit+= OrderProfit ()+ OrderCommission ()+ OrderSwap ();
                 }
              }
           }
        }
     }
   return (profit);
  }


işlev, açık pozlarda karı döndürür, sembol, tür, sihir ile filtreleyebilirsiniz

Tüm pozisyonları kapat

void CPD( string order_symbol= "" , int order_type=- 1 , int order_magic=- 1 )
  {
   int i,k= OrdersTotal ();

   if (order_symbol== "0" ) order_symbol= Symbol ();
   for (i=k- 1 ; i>= 0 ; i--)
     {
       if ( OrderSelect (i, SELECT_BY_POS , MODE_TRADES ))
        {
         if (( OrderSymbol ()==order_symbol || order_symbol== "" ) && (order_type< 0 || OrderType ()==order_type))
           {
             if ( OrderType ()== OP_BUY || OrderType ()== OP_SELL )
              {
               if (order_magic< 0 || OrderMagicNumber ()==order_magic) OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),1,CLR_GREEN);
              }
           }
        }
     }
  }
 
Vladislav Andruschenko :

...

işlev, açık pozlarda karı döndürür, sembol, tür, sihir ile filtreleyebilirsiniz

Tüm pozisyonları kapat

Teşekkürler, ama zararına kapatmakla ilgileniyorum. Bu nasıl uygulanabilir?
 

Yani, sana yukarıda her şeyi verdim,

Buna göre kâr genel bir kavramdır.

-20, -20'dir

if( GetProfitinCurrency( Symbol() ,-1,-1)<-20 )CPD(Symbol(),-1,-1);

 
Vladislav Andruschenko :

double GetProfitinCurrency( string order_symbol= "" , int order_type=- 1 , int order_magic=- 1 )
  {
   double profit= 0 ;
   int     i,k= OrdersTotal ();

   if (order_symbol== "0" ) order_symbol= Symbol ();
   for (i= 0 ; i<k; i++)
     {
       if ( OrderSelect (i, SELECT_BY_POS , MODE_TRADES ))
        {
         if (( OrderSymbol ()==order_symbol || order_symbol== "" ) && (order_type< 0 || OrderType ()==order_type))
           {
             if ( OrderType ()== OP_BUY || OrderType ()== OP_SELL )
              {
               if (order_magic< 0 || OrderMagicNumber ()==order_magic)
                 {
                  profit+= OrderProfit ()+ OrderCommission ()+ OrderSwap ();
                 }
              }
           }
        }
     }
   return (profit);
  }

Teşekkürler, şimdi anladım.

Şu nokta kodda henüz net değil: (order_type< 0 || OrderType ()==order_type) BU "ve bir satış veya satın alma emri" gibi bir şey okunabilir mi?

 
RichLux :

evet order_type = OP_BUY OP_SELL -1

 

derleyici hala ClosePosBySelect'e yemin ediyor.

Bu fonksiyon ayrı yazılmalı mı?

 
Bu konu ile ilgili olmayan yorumlar " Şu anki zaman çizildi " bölümüne taşınmıştır.
 

Vladislav Andruschenko

RichLux :

derleyici hala ClosePosBySelect'e yemin ediyor.

Bu fonksiyon ayrı yazılmalı mı?

void CPD( string order_symbol= "" , int order_type=- 1 , int order_magic=- 1 )
  {
   int i,k= OrdersTotal ();

   if (order_symbol== "0" ) order_symbol= Symbol ();
   for (i=k- 1 ; i>= 0 ; i--)
     {
       if ( OrderSelect (i, SELECT_BY_POS , MODE_TRADES ))
        {
         if (( OrderSymbol ()==order_symbol || order_symbol== "" ) && (order_type< 0 || OrderType ()==order_type))
           {
             if ( OrderType ()== OP_BUY || OrderType ()== OP_SELL )
              {
               if (order_magic< 0 || OrderMagicNumber ()==order_magic) OrderClose ( OrderTicket (), OrderLots (), OrderClosePrice (), 1 ,CLR_GREEN);
              }
           }
        }
     }
  }