int count_trades=0; for (int i==OrdersTotal()-1;i>=0; i--) if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) count_trades++;Use a Magic Number in your EA to make sure that you are only counting trades placed by the EA on the chart symbol
Use a Magic Number in your EA to make sure that you are only counting trades placed by the EA on the chart symbol
Thanks !!
Can I ask, would the order counted this way get reset if i close the program for maintenance?
Would the computer slow down tremendously if not shut down for half a year?
Or is there a way to shut down and resume the EA where it started?
Thanks !!
Can I ask, would the order counted this way get reset if i close the program for maintenance?
Would the computer slow down tremendously if not shut down for half a year?
Or is there a way to shut down and resume the EA where it started?
It counts the orders at the time, nothing is reset, if there are 2 orders and another order opens between calls then it will count 3
My computer slows down if I don't have a clear out every 3 days, I don't know about yours.
You cannot resume an EA from where it started, only from where it processed the last tick it received
It counts the orders at the time, nothing is reset, if there are 2 orders and another order opens between calls then it will count 3
My computer slows down if I don't have a clear out every 3 days, I don't know about yours.
You cannot resume an EA from where it started, only from where it processed the last tick it received
Thanks !!
But how do i use it?
//--- If No Order/Position if(OrdersTotal()==0) { //--- Buystop and Sellstop int ticket=OrderSend(Symbol(),OP_SELLSTOP,LotSize,OfferOpen,3,OfferStopLoss,OfferTakeProfit,"SELLSTOP",0,0,clrGreen); int ticket2=OrderSend(Symbol(),OP_BUYSTOP,LotSize,BidOpen,3,BidStopLoss,BidTakeProfit,"BUYSTOP",0,0,clrGreen); } else //--- If 1 Order if(OrdersTotal()==1) { for (int i=1; i<=OrdersTotal(); i++) //Cycle for all orders.. { //--- Selecting of Open Order if(OrderSelect(i-1,SELECT_BY_POS,MODE_TRADES)==true) { //--- If a buystop was triggered if(OrderType()==OP_SELLSTOP)
This is my current program now. So if i incorporate what you have taught me, I still get undeclared identifier for MagicNumber and i. Also "semicolon expected" but i suspect it is the same issue as the previous. How could i solve this?
Do i include int i=0; int MagicNumber=0; into the program or are there other ways?
int count_trades=0; for (int i==OrdersTotal()-1;i>=0; i--) if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) count_trades++; //--- If No Order/Position if(count_trades ==0) { //--- Buystop and Sellstop int ticket=OrderSend(Symbol(),OP_SELLSTOP,LotSize,OfferOpen,3,OfferStopLoss,OfferTakeProfit,"SELLSTOP",0,0,clrGreen); int ticket2=OrderSend(Symbol(),OP_BUYSTOP,LotSize,BidOpen,3,BidStopLoss,BidTakeProfit,"BUYSTOP",0,0,clrGreen); } else //--- If 1 Order if(count_trades==1) { for (int i==OrdersTotal()-1;i>=0; i--) //Cycle for all orders.. { //--- Selecting of Open Order if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) && OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber) { //--- If a buystop was triggered if(OrderType()==OP_SELLSTOP)
Thanks !!
But how do i use it?
This is my current program now. So if i incorporate what you have taught me, I still get undeclared identifier for MagicNumber and i. Also "semicolon expected" but i suspect it is the same issue as the previous. How could i solve this?
Do i include int i=0; int MagicNumber=0; into the program or are there other ways?
- 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 have been back testing my EA for a while now and would like to trade it live.
However, when I run it live, 3 different pairs for example, I realised that that the orderstotal() was interfering with one another.
Is there a way for the OrdersTotal() to count only those of its pair?
I also use this in the later part of the codes. Would it affect?