[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 104
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
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.