Yeni başlayanlardan sorular MQL5 MT5 MetaTrader 5 - sayfa 672
Ticaret fırsatlarını kaçırıyorsunuz:
- Ücretsiz ticaret uygulamaları
- İşlem kopyalama için 8.000'den fazla sinyal
- Finansal piyasaları keşfetmek için ekonomik haberler
Kayıt
Giriş yap
Gizlilik ve Veri Koruma Politikasını ve MQL5.com Kullanım Şartlarını kabul edersiniz
Hesabınız yoksa, lütfen kaydolun
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?
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
{
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);
}
}
}
}
}
...
işlev, açık pozlarda karı döndürür, sembol, tür, sihir ile filtreleyebilirsiniz
Tüm pozisyonları kapat
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);
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?
evet order_type = OP_BUY OP_SELL -1
derleyici hala ClosePosBySelect'e yemin ediyor.
Bu fonksiyon ayrı yazılmalı mı?
Vladislav Andruschenko
RichLux :
derleyici hala ClosePosBySelect'e yemin ediyor.
Bu fonksiyon ayrı yazılmalı mı?
{
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);
}
}
}
}
}