John McClark:
Post the code if you want coding help.
Can someone help me with a code that closes all orders when orders hit certain % of DD
thanks
Alain Verleyen:
Post the code if you want coding help.
Or apply for a new job
Post the code if you want coding help.
Mohammad Soubra:
Or apply for a new job
I just need the if sentence...what is it?
Or apply for a new job
if(AccountFreeMargin()<X)
{
}
There is already some free market or code base.
Hello sir,
I programmed it,
Thank you .
//------------------------ DD Close orders ------------------------------// // Header files for the errors description: #include <stderror.mqh> #include <stdlib.mqh> void Check_Close(int Check_Number) // check close order { if(Check_Number<0)Print("OrderClose failed with error: ", ErrorDescription(GetLastError())); else Close_All_V = false ; } //------- void Close_All ( int M_N ) { int Loop = 0 ; for ( int i = 0 ; Loop < OrdersTotal ( ) ; i++ ) if ( OrderSelect ( i , SELECT_BY_POS , MODE_TRADES ) ) { Loop++ ; if ( OrderMagicNumber ( ) == M_N && OrderSymbol ( ) == Symbol ( ) ) { if ( OrderType ( ) == OP_BUY ) Check_Close ( OrderClose ( OrderTicket ( ) , OrderLots ( ) , Bid , 100 , clrNONE ) ) ; if ( OrderType ( ) == OP_SELL ) Check_Close ( OrderClose ( OrderTicket ( ) , OrderLots ( ) , Ask , 100 , clrNONE ) ) ; } } } //------- double Loss ( int M_N ) { double re = 0 ; int Loop = 0 ; for ( int i = 0 ; Loop < OrdersTotal ( ) ; i++ ) if ( OrderSelect ( i , SELECT_BY_POS , MODE_TRADES ) ) { Loop++ ; if ( OrderMagicNumber ( ) == M_N && OrderSymbol ( ) == Symbol ( ) ) re = re + OrderProfit ( ) ; } return re * -1 ; } //------- double DD ( int M_N ) { return ( 100 / AccountBalance ( ) ) * Loss ( M_N ) ; } //------- bool Close_All_V ; void OnInit ( ) { Close_All_V = false ; } //------- void DD_close ( int DD , int Magic_Number ) { // DD: Here it is the DD persantge, 100 means never close any order . // Magic_Number: Your EA magic number . if ( DD ( Magic_Number ) >= DD ) Close_All_V = true ; if ( Close_All_V ) Close_All ( Magic_Number ) ; } // To use this option, just you need to call the function : DD_close //------------------------ DD Close orders end ------------------------------//
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Can someone help me with a code that closes all orders when orders hit certain % of DD
thanks