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
I have deleted your other topic as it was the same subject as this one. I have copied WHRoeder's comment and pasted it here before deleting it
int buy_count=0;
int sell_count=0;
for(int i=OrdersTotal()-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS) && OrderMagicNumber()==MagicNumber && OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY)
{
buy_count++;
}
if(OrderType()==OP_SELL)
{
sell_count++;
}
}
}
Something like that
I always count down unless I have a specific reason not to.
Okay that's fine, So for the loop, should it be framed similar to the one have for the closeorder, and if so should I have the program count up or down the orders?
So I now have a loop function on both my order close function and ordersend function, but it is still not trading independently. Although it is still opening trades and closing on the parameters set, as I can see in the strategy tester, although it will not work on multiple charts in a live demo.
Does each EA have a different magic number?
Show your loops that you are using now.
Does each EA have a different magic number?
Show your loops that you are using now.
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true) break;
if(OrderMagicNumber()==MagicNumber || OrderSymbol()==Symbol()) continue;
//--- Check for buy order
if(fastma > slowma)
{
if(OrderSend(Symbol(),OP_BUY,Lots,Ask,10,0,0,"",MagicNumber,0,Blue))
Print("Buy order opened :", OrderOpenPrice());
else
Print("Order failed to open : ", GetLastError());
return(0);
}
//--- Check for sell order
if(fastma < slowma)
{
if(OrderSend(Symbol(),OP_SELL,Lots,Bid,10,0,0,"",MagicNumber,0,Red))
Print("Order opened : ", OrderOpenPrice());
else
Print("Order failed to open : ", GetLastError());
return(0);
}
break;
}
Here is the ordersend loop
As wll as I have the MN as an external int, so I can change it on every chart I put the EA on.if(OrderMagicNumber()==MagicNumber || OrderSymbol()==Symbol()) continue;
In the presence of multiple orders (one EA multiple charts, multiple EA's, manual trading)