i try that but what happen is i only get either the buy orders or sell orders ( whatever i put in the code first, in this case i put buy orders first)
int start() { int ticket; // sending long Orders ticket = OrderSend(BUY); if (ticket > 0) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("open buy order : ", OrderOpenPrice()); } else Print("error opening buy order : ", GetLastError()); return(0); ticket = OrderSend(SELL); if (ticket == 1) { if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("open sell order : ", OrderOpenPrice()); } else Print("error opening sell order : ", GetLastError()); return(0); return(0); }
let's say per bar:
int totalBars; int start() { if(Bars > totalBars){ if(OrdersTotal() == 0){ OrderSend(Symbol(), OP_BUY, 0.01, Ask, 3, 15 * Point, 15 * Point, "", 0, 0, Blue); OrderSend(Symbol(), OP_SELL, 0.01, Bid, 3, 15 * Point, 15 * Point, "", 0, 0, Red); totalBars = Bars; } } return(0); }
Terminal is single threaded
It will only ever do ONE Trade Operation at a time.
look at Editor documentation in following order...
- refer to: MQL4 Reference - Checkup
- refer to: MQL4 Reference - Trading functions
Have you read the MQL4 Book????
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
how can i open a long and short position together at the same time, like i want to open a position for eur/usd long at the same time i want to open a position for short