EA will not run on multiple pairs, need help - page 4

 
whroeder1 2016.12.14 03:35 | 74.162.37.113 ban   EN
Keith Watford: loop through the open orders and only count trades that have the EA's magic number and chart symbol
Exactly, and that is not what your last post does.
 
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
 
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?
 

   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.

 
  1. You now have an OrderSelect loop that filters on MN and symbol.
  2. Now what MN do you open trades with?
 
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.

Does each EA have a different magic number?

Show your loops that you are using now.

 
Keith Watford:

Does each EA have a different magic number?

Show your loops that you are using now.

for(int i=OrdersTotal();i<=0;i--)
      {
      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.
 
First you have
      if(OrderSelect(i,SELECT_BY_POS) && OrderMagicNumber()==MagicNumber && OrderSymbol()==Symbol())
which is correct
But you have
         ticket = OrderSend(Symbol(),OP_BUY,Lots,Ask,10,0,0,"",0,0,Blue);
Which was not. And you ignored my question.


Then you quietly change the send to
         if(OrderSend(Symbol(),OP_BUY,Lots,Ask,10,0,0,"",MagicNumber,0,Blue))
Which is now correct.
But you quietly break the select loop.
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true) break;
      if(OrderMagicNumber()==MagicNumber || OrderSymbol()==Symbol()) continue;
Which is not.

In the presence of multiple orders (one EA multiple charts, multiple EA's, manual trading)
 
whroeder1:
First you have
      if(OrderSelect(i,SELECT_BY_POS) && OrderMagicNumber()==MagicNumber && OrderSymbol()==Symbol())
which is correct
But you have
         ticket = OrderSend(Symbol(),OP_BUY,Lots,Ask,10,0,0,"",0,0,Blue);
Which was not.

Then you quietly change the send to
         if(OrderSend(Symbol(),OP_BUY,Lots,Ask,10,0,0,"",MagicNumber,0,Blue))
Which is correct
And break the select loop.
 
      if(OrderMagicNumber()==MagicNumber || OrderSymbol()==Symbol()) continue;
Which is not.
So should I not have a Continue or Break in the loop at all?