ALI AMRIOUI:
this cod give the Last Order Info but i wana to get the First Order Info
int order=0; datetime first=0; double FirstOrderInfo(string Info,int type =-1) { for(int i =OrdersTotal() -1 ; i>=0; i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber && (OrderType()==type ||type==-1)) if(first==0 || OrderOpenTime()<first) { first=OrderOpenTime(); order=OrderTicket(); if(Info=="Type" ) return (OrderType()); if(Info=="Price" ) return (OrderOpenPrice()); } } return (0); } and if i do that .. then what worong ??
-
if(first==0 || OrderOpenTime()<first)
This works, but you can simplify by just setting first to the maximum possible and removing the first test.
#define MAX_DATETIME D'3000.12.31 23:59:59' #define MIN_DATETIME 0 // Thu, 01 Jan 1970 00:00:00 GMT
-
Go through your loop, and find the earliest order.
- Finally, after you have exited the loop and now know the earliest, you can return your value.
William Roeder #:
-
This works, but you can simplify by just setting first to the maximum possible and removing the first test.
-
Go through your loop, and find the earliest order.
- Finally, after you have exited the loop and now know the earliest, you can return your value.
how i can use this code???
#define MAX_DATETIME D'3000.12.31 23:59:59' #define MIN_DATETIME 0 // Thu, 01 Jan 1970 00:00:00 GMT
What part of "setting first to the maximum possible" was unclear?
William Roeder #:
What part of "setting first to the maximum possible" was unclear?
What part of "setting first to the maximum possible" was unclear?
#define MAX_DATETIME D'3000.12.31 23:59:59' #define MIN_DATETIME 0 // Thu, 01 Jan 1970 00:00:00 GMT int order=MIN_DATETIME; double FirstOrderInfo(string Info,int type =-1) { for(int i =OrdersTotal() -1 ; i>=0; i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber && (OrderType()==type ||type==-1)) if( order==OrderTicket() && OrderOpenTime()< MAX_DATETIME ) { if(Info=="Type" ) return (OrderType()); if(Info=="Price" ) return (OrderOpenPrice()); } } return (0); } like that .. but still dont work
-
Of course, that doesn't work. Order is not a datetime, and OrderOpenTime will always be less than MAX_DATETIME.
-
datetime first=0;
What part of "setting first to the maximum possible" was unclear?
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