The number of the day of the month is added to the order comment. How can I calculate how many orders (closed) there were during the day with this day's comment?
I don't know how to do it.
comment = Day();
int OpenOrdersDayHistory(string symbol, int type, int magic, string comment) { int n; int f = 0; int total = OrdersHistoryTotal(); for (n = total - 1; n >= 0; n--) { OrderSelect(n,SELECT_BY_POS,MODE_HISTORY); if (OrderSymbol() == symbol && OrderType() == type && OrderMagicNumber() == magic && OrderComment() == comment) { f++; } } Print("order count = ",f,"); return(f); }
The number of the day of the month is added to the order comment. How can I calculate how many orders (closed) there were during the day with this day's comment?
I don't know how to do it.
comment = Day();
int OpenOrdersDayHistory(string symbol, int type, int magic, string comment) { int n; int f = 0; int total = OrdersHistoryTotal(); for (n = total - 1; n >= 0; n--) { OrderSelect(n,SELECT_BY_POS,MODE_HISTORY); if (OrderSymbol() == symbol && OrderType() == type && OrderMagicNumber() == magic && OrderComment() == comment) { f++; } } Print("order quantity = ",f,"); return(f); }
int OpenOrdersDayHistory(string symbol, int type, int magic, string comment) { int n; int f = 0; int total = OrdersHistoryTotal(); for (n = total - 1; n >= 0; n--) { OrderSelect(n,SELECT_BY_POS,MODE_HISTORY); if (OrderSymbol() == symbol && OrderType() == type && OrderMagicNumber() == magic && OrderComment() == comment) { f++; } } Print("order count = ",f,"); return(f); }
Here you try it. It doesn't read orders in history.
I have not managed to properly "score" opening of pending orders in my code. I have read the tutorial, help and other stuff. The answer is probably there, but I just can't figure it out...
Here's the problem. I have a period of time during which I look for the max and min price and assign these values to two global variables. Then we need to open a pending order at that price. I cannot decide the price point. I want to correctly specify the interval of the current price.
1.Question - how does the price function of the current bar look like, for example, at 6 am?
2 How do I specify the ticket parameter in order to close the order?
Or another way to close one of the two previously opened orders?
I have to try it this way...
for (int i=1; i<=OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS)==true)
{
int T=OrderTicket();
int Cur_Hour2=Hour(); // server time in hours
double Cur_Min2=Minute(); // Server time in minutes
double Cur_time2=Cur_Hour2 + Cur_Min2/100; // Server time
int start(){string comment =TimeDay(TimeCurrent());if( OpenOrdersDayHistory(Symbol(),OP_BUY,123, comment)<3){
UseTF =true;Print("Yes");}else{
UseTF =false;Print("No");}if( UseTF ==true){int ticket =OrderSend(Symbol(),OP_BUY,0.1,Ask,3,0,Ask+100*Point, comment,123,0,Green);}return(0);}int OpenOrdersDayHistory(string symbol,int type,int magic,string comment){int n;int f =0;int total =OrdersHistoryTotal();for( n = total -1; n >=0; n--){OrderSelect( n, SELECT_BY_POS, MODE_HISTORY);Print(OrderSymbol()== symbol &&OrderType()== type &&OrderMagicNumber()== magic," ",StringFind(OrderComment(), comment,0)>=0);if(OrderSymbol()== symbol &&OrderType()== type &&OrderMagicNumber()== magic &&StringFind(OrderComment(), comment,0)>=0)
f++;}Print("колл-во ордеров = ", f,"");return( f);}
Can you suggest an EA that closes all positions (and unprofitable ones too) when a certain profit is reached and removes all unperformed pending orders ?
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.
The number of the day of the month is added to the order comment. How can I calculate how many orders (closed) there were during the day with this day's comment?
I don't know how to do it.
comment = Day();
int OpenOrdersDayHistory(string symbol, int type, int magic, string comment)
{
int n;
int f = 0;
int total = OrdersHistoryTotal();
for (n = total - 1; n >= 0; n--)
{
OrderSelect(n,SELECT_BY_POS,MODE_HISTORY);
if (OrderSymbol() == symbol && OrderType() == type && OrderMagicNumber() == magic && OrderComment() == comment)
{
f++;
}
}
Print("order count = ",f,");
return(f);
}
The number of the day of the month is added to the order comment. How can I calculate how many orders (closed) there were during the day with this day's comment?
I don't know how to do it.
comment = Day();
int OpenOrdersDayHistory(string symbol, int type, int magic, string comment)
{
int n;
int f = 0;
int total = OrdersHistoryTotal();
for (n = total - 1; n >= 0; n--)
{
OrderSelect(n,SELECT_BY_POS,MODE_HISTORY);
if (OrderSymbol() == symbol && OrderType() == type && OrderMagicNumber() == magic && OrderComment() == comment)
{
f++;
}
}
Print("order quantity = ",f,");
return(f);
}
And the same when sending orders!
>> It's better this way:
It's faster, easier and more reliable.bool UseTF = true;
int start()
{
string comment = TimeDay(TimeCurrent());
if (OpenOrdersDayHistory(Symbol(), OP_SELL, 123, comment) > 0)
{
UseTF = false;
Print("No");
}
else
{
UseTF = true;
Print("Yes");
}
if (UseTF == true)
{
int ticket = OrderSend(Symbol(), OP_BUY, 0.1, Ask, 3, 0, Ask+10*Point, comment, 123, 0, Green);
}
return(0);
}
int OpenOrdersDayHistory(string symbol, int type, int magic, string comment)
{
int n;
int f = 0;
int total = OrdersHistoryTotal();
for (n = total - 1; n >= 0; n--)
{
OrderSelect(n,SELECT_BY_POS,MODE_HISTORY);
if (OrderSymbol() == symbol && OrderType() == type && OrderMagicNumber() == magic && OrderComment() == comment)
{
f++;
}
}
Print("order count = ",f,");
return(f);
}
Here you try it. It doesn't read orders in history.
Good afternoon to all.
I have not managed to properly "score" opening of pending orders in my code. I have read the tutorial, help and other stuff. The answer is probably there, but I just can't figure it out...
Here's the problem. I have a period of time during which I look for the max and min price and assign these values to two global variables. Then we need to open a pending order at that price. I cannot decide the price point. I want to correctly specify the interval of the current price.
1.Question - how does the price function of the current bar look like, for example, at 6 am?
2 How do I specify the ticket parameter in order to close the order?
Or another way to close one of the two previously opened orders?
I have to try it this way...
for (int i=1; i<=OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS)==true)
{
int T=OrderTicket();
int Cur_Hour2=Hour(); // server time in hours
double Cur_Min2=Minute(); // Server time in minutes
double Cur_time2=Cur_Hour2 + Cur_Min2/100; // Server time
Alert(Cur_time2);
if (Cur_time2>=Time_of_buy_sell_2)
OrderClose(T,1,Ask,3,Red);
}
return; // Exit from start()
Please don't judge strictly:)
It's better this way:
And quicker, and easier, and more reliable.I agree, but my emphasis was more on the other.
Try this. It doesn't read orders in history.
It reads everything normally. Check what comment you have after closing. Some brokers add their own entries to the comment when an order is closed.