int total=OrdersTotal(); string open_order_symbols[]; ArrayResize(open_order_symbols,total); for(int x=total-1;x>=0;x--) { if(OrderSelect(x,SELECT_BY_POS) && OrderMagicNumber()==MagicNumber) //Assuming that your EA uses a magic number open_order_symbols[x]=OrderSymbol(); } //Code for checking conditions for symbol - using EURUSD as an example bool check_conditions=true; for(int x=total-1;x>=0;x--) { if(open_order_symbols[x]=="EURUSD") { check_conditions=false; break; } } if(check_conditions) { //CHECK FOR CONDITION TO OPEN AN ORDER FOR THIS SYMBOL AND OPEN IF TRUE }
Not Tested or compiled but may help you
Hey there!
Thanks for helping me but the problem is that I don't really know how to open a buy trade in all of the symbols (which reached the upper Bollinger Band) except for "EURUSD".. I have tried so many silly things like OrderSend (Symbol() - "EURUSD"....) but nothing really helped me..
Can you solve this one please?
You check conditions for each symbol individually
I believe that it is simplest to store the symbols in an array and then check each symbol in a loop
string symbol_array[]={"EURUSD","USDCAD","EURJPY"}; int array_size=ArraySize(symbol_array); int total=OrdersTotal(); string open_order_symbols[]; ArrayResize(open_order_symbols,total); for(int x=total-1;x>=0;x--) { if(OrderSelect(x,SELECT_BY_POS) && OrderMagicNumber()==MagicNumber) //Assuming that your EA uses a magic number open_order_symbols[x]=OrderSymbol(); } //Code for checking conditions for symbols for(int symbols=array_size-1;symbols>=0;symbols--) { bool check_conditions=true; for(int x=total-1;x>=0;x--) { if(open_order_symbols[x]==symbol_array[symbols]) { check_conditions=false; break; } } if(check_conditions) { //CHECK FOR CONDITION TO OPEN AN ORDER FOR THIS SYMBOL STORED IN symbol_array[symbols] //IF CONDITIONS ARE SATISFIED - OPEN A TRADE } }
Not tested
You are overly complicating everything. Trading other pairs mean you can not use any predefined variables and must pole all symbols for new ticks (onTick is called only for the current chart.)
Make your EA trade the current chart pair only. Then put it on multiple charts. Done.
You are overly complicating everything. Trading other pairs mean you can not use any predefined variables and must pole all symbols for new ticks (onTick is called only for the current chart.)
Make your EA trade the current chart pair only. Then put it on multiple charts. Done.
Well,this is very nice and I could have never thought about this idea alone but as you can surely see in your code,when an order equals to one of the symbols which are attached to the chart(the ones that we have chosen before),it stops the for loop(break;) and then continues and checks what if they are not equal,but I don't want it just to stop the for loop using break;,I want it to open an order in the symbols that touched the Upper Bollinger Band EXCEPT for the one which equals the order symbol.. even if it has touched the upper BB as well!
In other words,I don't want my program to place another if an order with the same symbol already exists..
Or,if you have already done that in your previous code,please tell me what to do to get exactly what I want..
Thanks in advance mate!!
Hoyeah: I don't want my program to place another if an order with the same symbol already exists..
| So change GumRai 's OrderSelect loop to only process your symbol. What's the problem? learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem. |
Hoyeah: Well,I can post my attempt if you wish...
| What part of "post your attempt and the nature of your problem" was unclear? |
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Well,I've made an Expert Advisor that is supposed to open an order once the current price reaches the upper Bollinger Band(it will check it every 30 minutes and in 9 symbols).
The problem is that if the current price reaches the upper Bollinger Band and after 30 minutes it reaches there again,it will open another order which is not what I wanted.
I have been trying for 4 days to avoid it but couldn't...
My main try was to check if an order with the same symbol already existed and then to open the new order in each symbol(only where the condition was true of course) except for the opened order symbol.
For example:
If the current price reached the the upper bollinger band in EURUSD,USDCAD and EURJPY but an order with EURUSD symbol already existed,it will open the order only in USDCAD and EURJPY.
Can someone help me please?
Thanks in advance!