- Need some help in controlling the no of open positions?
- How to only have one trade a day
- EA CODING ISSUE/HELP - closes trades and open new, on new bar
int start(){ //manage open orders here if (OrdersTotal() > 0){ return(0); } //open new orders here }
or a with a bit more control
int start(){ //manage open orders here if (getOpenOrders() > 0){ return(0); } //open new orders here } int getOpenOrders(){ int liOrders = 0; for (int i = 0; i < OrdersTotal(); i++){ if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == false){ continue; } if (OrderSymbol() != Symbol() || OrderMagicNumber() != /*your magic number*/){ continue; } liOrders++; } return(liOrders); }hth
@ Russell.....I can't figure out where to paste this code in my ea.Therefore,i am attaching my ea here.I would be very thankful if you paste this code in my ea and also test it whether it works or not.Also,please do provide me a brief description of where you pasted this code.Thanks alot....God Bless you :)
innovativebug:
you should start using Magicnumbers other then 0 like:
extern int MagicNumber = 34474212;
simpy copy&paste Russells code to the end of your code like here:
int getOpenOrders(){ int liOrders = 0; for (int i = 0; i < OrdersTotal(); i++){ if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == false){ continue; } if (OrderSymbol() != Symbol() || OrderMagicNumber() != MagicNumber){ continue; } liOrders++; } return(liOrders); }
and you must limit all ENTRY signals with getOpenOrders() function like:
//Buy if (Order == SIGNAL_BUY && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount))) && getOpenOrders()==0) {
//Sell if (Order == SIGNAL_SELL && ((EachTickMode && !TickCheck) || (!EachTickMode && (Bars != BarCount))) && getOpenOrders()==0) {
thats it
innovativebug:
- do you have multiple symbols on same EA?
- did you change MagicNumber as i mentioned?
Its impossible that it open a trade without closing previous if you have done it properly.
innovativebug:
- do you have multiple symbols on same EA?
- did you change MagicNumber as i mentioned?
Its impossible that it open a trade without closing previous if you have done it properly.
Mate, I am using own EA on multiple symbols... ex) GBPUSD, EURUSD, USDJPY etc..
How can I open only one trade ??
for example,
If my ea open trade on GBPUSD, stop open other multiple symbols until close the previous order(GBPUSD)
Mate, I am using own EA on multiple symbols... ex) GBPUSD, EURUSD, USDJPY etc..
How can I open only one trade ??
for example,
If my ea open trade on GBPUSD, stop open other multiple symbols until close the previous order(GBPUSD)
Why are you responding to a 10 year old thread?
The answer is simple. Don't open any trades when a trade of any symbol is already open.
if ( PositionsTotal()<1 )
{
Code goes here, e.g (place a buy/sell order);
}
Thanks and GOD bless, amen.
WE THANK THEE JESUS,MARY OUR GOD.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use