-
datetime buyOrderTime=TimeCurrent(); ⋮ if(OrderOpenTime()<buyOrderTime)
That if will always be true.
-
double OpenPriceLong=NormalizeDouble(OrderOpenPrice(),Digits);
Prices you get from the terminal are always normalized.
-
if(secondBuyOrder == secondBuyOrder+1)
When will that if ever be true?
-
Get your values, then work with them. When working with multiple values, arrays and structs are your friend.
struct Order{ datetime time; double lots; double price; int ticket; }; Order buys[]; int count=0; for(int i=0;i<OrdersTotal();i++) if( OrderSelect(i,SELECT_BY_POS) && OrderMagicNumber() == Magic) && OrderType() == OP_BUY) && OrderSymbol() == Symbol() ){ ArrayResize(buys, count+1); buys[count].time = Ordertime(); buys[count].lots = OrderLots(); buys[count].price = Orderprice(); buys[count].ticket = OrderTicket(); ++count; } if(count >= 3) // thirdBuyLot is buys[2].lot
-
That if will always be true.
-
Prices you get from the terminal are always normalized.
-
When will that if ever be true?
-
Get your values, then work with them. When working with multiple values, arrays and structs are your friend.
thanks for reply but i cannot get wanted value , counting continue and only get 1st order values and cannot get next order values
datetime buyOrderTime=TimeCurrent(); for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==Symbol() && OrderMagicNumber()==Magic) { if(OrderType()==OP_BUY) { ArrayResize(buys, count+1); buys[count].time = OrderOpenTime(); buys[count].lots = OrderLots(); buys[count].price = OrderOpenPrice(); buys[count].ticket = OrderTicket(); ++count; } } }
2022.10.21 21:01:17.865 2021.02.04 19:20:00 testgridorderticket EURUSDm,H1: 2nd2021.02.03 12:20:00 2022.10.21 21:01:17.865 2021.02.04 19:20:00 testgridorderticket EURUSDm,H1: 1st2021.02.03 12:20:00
if(count>=1){buys[1].lots} if(count>=2){buys[2].lots}
they are same values , buy[2].lots cannot get 2nd order value.
how can i fix that
- LONNV #:, counting continue and only get 1st order values and cannot get next order values
The loop gets all matching orders.
Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
Code debugging - Developing programs - MetaEditor Help
Error Handling and Logging in MQL5 - MQL5 Articles (2015)
Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010) - LONNV #: , buy[2].lots cannot get 2nd order value.
buy[2] is not the second order, it is the third.
- You showed prints but not the code that makes them; your error is there.
-
The loop gets all matching orders.
Use the debugger or print out your variables, including _LastError and prices and find out why. Do you really expect us to debug your code for you?
Code debugging - Developing programs - MetaEditor Help
Error Handling and Logging in MQL5 - MQL5 Articles (2015)
Tracing, Debugging and Structural Analysis of Source Code - MQL5 Articles (2011)
Introduction to MQL5: How to write simple Expert Advisor and Custom Indicator - MQL5 Articles (2010) -
buy[2] is not the second order, it is the third.
- You showed prints but not the code that makes them; your error is there.
i will show you count variable value.it couting more than actual open order ,i mean open order is only one but it still counting over 1
2022.10.22 03:25:49.563 2021.03.08 20:42:30 testgridorderticket EURUSDm,H1: counting6995
you see , it count 6995 .open order is only two.
this make non sense, what wrong in for looping?
for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==Symbol() && OrderMagicNumber()==Magic) { if(OrderType()==OP_BUY) { ArrayResize(buys, count+1); buys[count].time = OrderOpenTime(); buys[count].lots = OrderLots(); buys[count].price = OrderOpenPrice(); buys[count].ticket = OrderTicket(); count++; } } } Print("counting"+count+""); if(count>=1){ Print("time"+ buys[0].time+""); Print("lot"+ buys[0].lots+""); Print("price"+ buys[0].price+""); Print("ticket"+ buys[0].ticket+""); } if(count>=2){ Print("2nd time"+ buys[1].time+""); Print("2nd lot"+ buys[1].lots+""); Print("2nd price"+ buys[1].price+""); Print("2nd ticket"+ buys[1].ticket+""); }
counting is not correct ,so if(count>= ) condition are not correct anymore.
Nothing is wrong in the for loop.
Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button) or attach the source file.
How To Ask Questions The Smart Way. (2004)
Be precise and informative about your problem
We can't see your broken code. Where do you initialize count to zero?
Nothing is wrong in the for loop.
Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button) or attach the source file.
How To Ask Questions The Smart Way. (2004)
Be precise and informative about your problem
We can't see your broken code. Where do you initialize count to zero?
- If you used strict, variables have no initial value.
- Counting filtered orders has nothing to do with the for loop position index.
for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==Symbol() && OrderMagicNumber()==Magic) ⋮ buys[count].ticket = OrderTicket(); count++;
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
i have grid order
example
i want to get their informations
i tried as follow ,but not work , can get only first order information
how can i get 2nd 3rd order info ,
plz help me