As you don't show any code, how can we know?
//--- double orders1=0;//first order open price double orders2=0;//second order open price double orders3=0;//third order open price double orders4=0;//fourth order open price double orders5=0;// etc etc etc etc { for(int i=0; i<OrdersTotal(); i++) if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) { if(orders1==0){orders1=OrderOpenPrice();}// my open price is 1.13104 if(orders2==0){orders2=OrderOpenPrice();}// my open price is 1.13053 if(orders3==0){orders3=OrderOpenPrice();}// my open price is 1.13105 if(orders4==0){orders4=OrderOpenPrice();}// my open price is 1.13032 if(orders5==0){orders5=OrderOpenPrice();}// my open price is 1.13075 } } Print("orders1 --> ",orders1);// here is my problem all the variable have the same value?? Print("orders2 --> ",orders2); Print("orders3 --> ",orders3); Print("orders4 --> ",orders4); Print("orders5 --> ",orders5);
2016.04.27 02:30:56.399 Script loop #ENM6,M5: removed
2016.04.27 02:30:56.399 loop #ENM6,M5: uninit reason 0
2016.04.27 02:30:56.399 loop #ENM6,M5: orders5 --> 1.12981
2016.04.27 02:30:56.399 loop #ENM6,M5: orders4 --> 1.12981
2016.04.27 02:30:56.399 loop #ENM6,M5: orders3 --> 1.12981
2016.04.27 02:30:56.399 loop #ENM6,M5: orders2 --> 1.12981
2016.04.27 02:30:56.399 loop #ENM6,M5: orders1 --> 1.12981
thank you for any help
if(orders1==0) { orders1=OrderOpenPrice(); continue; }
and do the same for every if in the loop
thank you very much it works
I'm a little confused with the "continue" method,
how to do without the "continue" if possible?
thank you all
how to do without the "continue" if possible?
thank you all
itriad: how to do without the "continue" if possible?
if( orders1==0){orders1=OrderOpenPrice();}// my open price is 1.13104 else if(orders2==0){orders2=OrderOpenPrice();}// my open price is 1.13053 else if(orders3==0){orders3=OrderOpenPrice();}// my open price is 1.13105 else if(orders4==0){orders4=OrderOpenPrice();}// my open price is 1.13032 else if(orders5==0){orders5=OrderOpenPrice();}// my open price is 1.13075
- Or handle the general case
double orders{]; int nOrders=0 for(int i=0; i<OrdersTotal(); i++) if( OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) // See note { ArrayResize(orders, nOrders + 1); orders[nOrders++] = OrderOpenPrice(); } Print("orders1 --> ",orders[1); Print("orders2 --> ",orders[2]; Print("orders3 --> ",orders[3]; Print("orders4 --> ",orders[4]; Print("orders5 --> ",orders[5];
Note: No filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.) Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 forum
it works, a big thank you especially to WHroeder and Gumrai
double orders[]; int nOrders=0; for(int i=0; i<OrdersTotal(); i++) if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) // See note { ArrayResize(orders,nOrders+1); orders[nOrders++]=OrderOpenPrice(); } Print("orders1 --> ",orders[0]);// <--- 1 if i start to 1, i have array out of range in 'loop.mq4' (26,31) Print("orders2 --> ",orders[1]);// <--- 2 Print("orders3 --> ",orders[2]);// <--- 3 Print("orders4 --> ",orders[3]);// <--- 4 Print("orders5 --> ",orders[4]);// <--- 5 }it works perfectly thanks again
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
my script gives the same value to 5 different variables
Where is the problem??? thank you for any help