How I can check if order day is today? I found quite ugly way . Should more elegant solution
I don't know if this way is less ugly but you can try it:
if (OrderSelect(trade, SELECT_BY_POS, MODE_HISTORY) == true && OrderSymbol() == Symbol() && OrderOpenTime()>=TimeCurrent()-TimeCurrent()%86400)
I don't know if this way is less ugly but you can try it:
It would be less ugly by declaring a "today" variable outside the loop, instead of calculating it each time.
You are right as usual. But it was just an example and I used in that example only condition without the loop. But I can write the whole code for you.
BTW "OrderSelect(trade, SELECT_BY_POS, MODE_HISTORY) == true" is ugly too.
datetime today=TimeCurrent()-TimeCurrent()%86400; for(int trade=OrdersHistoryTotal()-1;trade>-1;trade--) if(OrderSelect(trade,SELECT_BY_POS,MODE_HISTORY) && OrderSymbol()==Symbol() && OrderOpenTime()>=today) { }
You are right as usual. But it was just an example and I used in that example only condition without the loop. But I can write the whole code for you.
BTW "OrderSelect(trade, SELECT_BY_POS, MODE_HISTORY) == true" is ugly too.
datetime today=TimeCurrent()-TimeCurrent()%86400;
Using 2 times the same function in a row is ugly too
Using 2 times the same function in a row is ugly too
datetime today=TimeCurrent(); today-=today%86400; for(int trade=OrdersHistoryTotal()-1;trade>-1;trade--) if(OrderSelect(trade,SELECT_BY_POS,MODE_HISTORY) && OrderSymbol()==Symbol() && OrderOpenTime()>=today) { }
Because of you, I won't have lunch. Hope you're satisfied.
Well, as we are talking about ugliness, I am wondering why >=0 became >-1 ? ;-)
Well, as we are talking about ugliness, I am wondering why >=0 became >-1 ? ;-)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
How I can check if order day is today? I found quite ugly way . Should more elegant solution