Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
mq5 or mql5??
bentuk codingnya MQL5 bos.. / Procedure MQL5 nya
Hello everyone..
can u help me, how script to make Target Daily Profit for MQL5
Thank U..
Regard..
void CloseCheck()
{
int totalOrder = OrdersTotal();
for(int i=totalOrder-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS);
int type = OrderType();
bool result = false;
if (OrderProfit >= 100) // 100 pip
switch(type)
{
//Close opened long positions
case OP_BUY : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
break;
//Close opened short positions
case OP_SELL : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );
}
if(result == false)
{
Alert("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() );
Sleep(3000);
}
}
}
Forum on trading, automated trading systems and testing trading strategies
When you post code please use the CODE button (Alt-S)!
Thank you.
void CloseCheck()
{
int totalOrder = OrdersTotal();
for(int i=totalOrder-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS);
int type = OrderType();
bool result = false;
if (OrderProfit >= 100) // 100 pip
switch(type)
{
//Close opened long positions
case OP_BUY : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
break;
//Close opened short positions
case OP_SELL : result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );
}
if(result == false)
{
Alert("Order " , OrderTicket() , " failed to close. Error:" , GetLastError() );
Sleep(3000);
}
}
}
Is this MQL5 or MQL4? If I got this code right, it closes profitable orders, not based on daily profit...
I happen to do similar type of coding by checking the trade history for losses and stop trading and continue the next day.
You will need to iterate your trade history and sum up the profit until $10, then stop for the day.
This code fragment is for checking losses. You can modify it to check for profit.
Check the canTradeToday condition to see if you want to open another trade.
I would suggest you use this code fragment as a small exercise and try coding on your own.
Otherwise you would have to send your request to the freelance service.
bentuk codingnya MQL5 bos.. / Procedure MQL5 nya