Need some support with code. I want to find number of all buy orders in history for start with.
Have been looking for number of samples but they do not make sense for me as I am still in learning curve.
Below is my sample for finding latest orders with magic number. Want to add here code for finding all buy orders in history
So why aren't you checking what the OrderType() is ? that will tell you if it's a Buy or Sell.
OK, so check for . . .
perfect and thanks for support
here code with piece I missed. So now I can see how many buy or sell orders there were in history with magic number.
//---- int iTotal=OrdersHistoryTotal(); int i; int ticket; int ticket2; int ticket3; int buyCount=0; int sellCount=0; int buyCount2=0; for(i=0;i<iTotal;i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true) { if(OrderMagicNumber()==111) { ticket=OrderTicket(); } if(OrderMagicNumber()==222) { ticket2=OrderTicket(); } if(OrderMagicNumber()==333) { ticket3=OrderTicket(); } if(OrderType()==OP_BUY && OrderMagicNumber()==111) { buyCount++; } if(OrderType()==OP_SELL && OrderMagicNumber()==222) { sellCount++; } if(OrderType()==OP_BUY && OrderMagicNumber()==333) { buyCount2++; } } } int total=OrdersTotal(); if(total==0) { if(iTotal<=10) { OrderSend(Symbol(),OP_BUY,0.01,Ask,3,Ask-7*Point,Ask+7*Point,NULL,111,0,CLR_NONE); } else { OrderSend(Symbol(),OP_SELL,0.02,Bid,3,Bid+7*Point,Bid-7*Point,NULL,222,0,CLR_NONE); if(iTotal>=201) { OrderSend(Symbol(),OP_BUY,0.01,Ask,3,Ask-7*Point,Ask+7*Point,NULL,333,0,CLR_NONE); } } } else { Print("no reason to trade"); } //---- Comment ("\n| i | ",i, "\n| Total open | ",total, "\n| ticket | ",ticket, "\n| ticket2 | ",ticket2, "\n| ticket3 | ",ticket3, "\n| hst buy orders with magic 111 ",buyCount, "\n| hst buy orders with magic 333 ",buyCount2, "\n| hst sell orders with magic 222 ",sellCount); return(0); } //+------------------------------------------------------------------+
hope this sample will help others and save some time
perfect and thanks for support
here code with piece I missed. So now I can see how many buy or sell orders there were in history with magic number.
hope this sample will help others and save some time
hope they don't do it this way.....
what good is it what you do with finding OrderTicket()
it is not needed for what you ask and the only one you comment can be every type
int total=OrdersTotal(); if(total==0)
you can't use other system this way on your account
if(iTotal<=10) { OrderSend(Symbol(),OP_BUY,0.01,Ask,3,Ask-7*Point,Ask+7*Point,NULL,111,0,CLR_NONE); }
will fail on ECN accounts
if not ecn and 5 digit account closeprice that small it is within the spread .....
make it work for 4 and 5 digit account
-------------
if you have used this system one time on your account you have to stop it can't work again
hope they don't do it this way.....
what good is it what you do with finding OrderTicket()
it is not needed for what you ask and the only one you comment can be every type
you can't use other system this way on your account
will fail on ECN accounts
if not ecn and 5 digit account closeprice that small it is within the spread .....
make it work for 4 and 5 digit account
-------------
if you have used this system one time on your account you have to stop it can't work again
Than you for clearing some things for me as I am learning to code. It will take some time until I get done with (safe) EA code that can be used on real account

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Need some support with code. I want to find number of all buy orders in history for start with.
Have been looking for number of samples but they do not make sense for me as I am still in learning curve.
Below is my sample for finding latest orders with magic number. Want to add here code for finding all buy orders in history