Please edit your post . . . please use the SRC button to post code: How to use the SRC button.
Excuse me. Done
Excuse me. Done
Hi,
I am stuck for a week on this problem:
I have the same EA (can easily give it different magic nr's) on like 7 pairs. I do not want the ea open a position when there is already a position open on that particulair pair.
I searched a lot on orderstotal, bools, magicnr's et etc. Finally I get stuck here.
I added the function Orderstotal just before the OrderSend parts: if(OrdersTotal()<1)
The only problem is that it now counts total open orders in the account and not on the pair/chart/magic nr. Al three would work.
In your first loop . . .
for (int i=j;i>=0;i--)
. . add a variable, EAOrdersTotal, that you use to keep a running count of the order than meet your criteria of magic number and Symbol and then instead of . . .
if(OrdersTotal()<1)
. . . use . .
if(EAOrdersTotal < 1)
You wan to create your own function. Something which filters your Magic#, Symbol...etc. Then it returns a count. Also, you can try using a for(loop) doing the count within the loop and using the count like OrdersTotal. Something like below.... You need to fix.
j=OrdersTotal()-1; int Count=0; for (i=j;i>=0;i--) { OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderType()==OP_SELL && OrderMagicNumber()==magic && OrderSymbol()==Symbol() ){ Count=Count+1; //Count++ } } if( Count==0 ){ do_something; }
Dear RaptorUK,
Many thanks for your quick response. Sorry, but I still don't get it.
if(OrderMagicNumber()==magic && OrderSymbol()==Symbol())
Checks for magic number already (and all ea's have different magic nr)
Do I have to change the word symbol for a specific Pair here?
Furthermore I do not know how to add the variable.
Trying just give me invalid codes *#&^$
I am sorry I am so noob on this ;-)
Dear RaptorUK,
Many thanks for your quick response. Sorry, but I still don't get it.
Checks for magic number already (and all ea's have different magic nr)
Do I have to change the word symbol for a specific Pair here?
Furthermore I do not know how to add the variable.
Trying just give me invalid codes *#&^$
If you want help then that is OK, I'll help . . . if you want someone to write code for you then go here: Jobs
if(OrderMagicNumber()==magic && OrderSymbol()==Symbol()) EAOrdersTotal++; // increment the running total of orders for this EA
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I am stuck for a week on this problem:
I have the same EA (can easily give it different magic nr's) on like 7 pairs. I do not want the ea open a position when there is already a position open on that particulair pair.
I searched a lot on orderstotal, bools, magicnr's et etc. Finally I get stuck here.
I added the function Orderstotal just before the OrderSend parts: if(OrdersTotal()<1)
The only problem is that it now counts total open orders in the account and not on the pair/chart/magic nr. Al three would work.
Could somebody show me which adaption I should make?
Thanks a lot!
I know that there were some threads before and there is where I got my first attempts from but as I am not a coder it did not brought me further than this. And I really really tried. I am not lazy, just got stuck!
Thanks a million!
----------------------------------------------