Hi,
Step one: detect Symbol() & Magic Number:
int CountSym(string sym) { int count=0; int i; int total=OrdersTotal(); for(i=0;i<total;i++) { OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderSymbol()!= sym) continue; if(OrderMagicNumber() != Magic) continue; count++; } return(count); }
Step two: CAll the Order function with sub function:
if(CountSym(sym)>0) OrdersList(); // Orders section with TS, BE and more. else { //OrderSend function BUY or SELL with specific magic }
S.T
for(pos = OrdersTotal()-1; pos >= 0 ; pos--) if ( OrderSelect(pos, SELECT_BY_POS) // Only my orders w/ && (OrderMagicNumber() == magic.number1 // my magic number ||OrderMagicNumber() == magic.number2) && OrderSymbol() == Symbol() ){ // and my pair.
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
Hi Guys,
how can I code an EA that can trade 4 pairs, but each two pairs were traded with a specific magic number in one EA.
EA:
1.) buy EURUSD / sell GBPUSD <-- both pairs get magic number 1234
2.) buy EURUSD / sell USDCHF <-- both pairs get magic number 5678
So EA check for both magic number:
- open positions
- profit of open positions
- close that pairs with that magic number which are in given profit
Who can help me?
Best regards,