Hello,
I have problem ......
Sorry, I didn't understand all your questions, but :
- Your understanding of magic number seems to be wrong.
-SELECT_BY_TICKET simply means select by ticket, you need to have a look at definition of ticket.
- int MagicNumber=OrderMagicNumber();
Plus,it doesn't seem to me that you need to take the magic number from another order in this EA, you simply need to define a global variable and call it Magic (or anything you want) and give it any number you want like:
int Magic = 435453;
Ticket=OrderSend("GBPJPY",OP_BUY,0.1,NormalizeDouble(Ask,3),20,0,0,"GBPJPY",MagicNumber);
You can't use Ask, because Ask is a giving you the Ask price of the chart on which your EA is running.
instead you need to use :
MarketInfo(_Symbol, MODE_ASK);
Also, you don't need to Normalize Ask or Bid.
for (int i=0;i<=OrdersTotal();i++) it counts 1 extra, and preferably use the decreasing loop.for (int i=OrdersTotal()-1;i>=0;i--)
My problem is open only one position per instrument. It is mean every function should open only one position.
Then you need to make a function which takes the name of symbol and give you back the number of orders of the same symbol (+ checking the magic number).
I cant understand what you were doing exactly,
But, while your loop is not finished its iterations, if any of orders get closed, your loop will skip some orders.
As you mentioned it is very important when closing orders, because you will see some orders left open for sure, but here in this codes, you may not able to see any problem because the problem happens rarely but happens.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello,
I have problem with part of code - sending order. Perhaps anyone has an any idea or suggestion.
Assumptation: 10 instruments, every instrument open from a specific function.
If I use in the loop OrdersTotal() SELECT_BY_POS and negation !="abc" there isn't open any order. If I use =="abc" break EA will open positions to the end of money on the account. This is logic. I noticed if I use in the loop after SELECT_BY_POS any info it is not conduct with the loop and terminal.
I'd like to open only one position per specific instrument with the specific condition, and after make actions with it. I know the problem is with limitation in every function to one open order. But I don't have any idea for it. If I use stop open position by limit OrdersTotal() I can't open next instrument from different function.
I know I can SELECT_BY_POS or SELECT_BY_TICKET only. BY position means 0,1,2 etc.... by ticket using magic number.
Thank you.