Keith Watford: 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
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?
Matt_Townsend: 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.
Matt_Townsend: 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.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
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)