Can`t close all order in terminal

 

What wrong with this code..!!

call -->  CloseButton(-9,-9,-9);

only order Symbol on active chart  closed .. order ...in other Symbol & chart NOT.closed ....!

any clue..?

void CloseButton(int bs,int magic,int loosprofit)
  {
   for(int i=OrdersTotal()-1; i>=0; i--)
     { 
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==false) continue;
      if(bs==-9 && magic==-9 && loosprofit==-9) {CloseTicket(OrderTicket()); continue;} // Global all at Terminal  <<<--- at this not working. command--> CloseButton(-9,-9,-9); 
      if(OrderSymbol()==Symbol() && (OrderMagicNumber()==magic ||  magic==-1))

        {
         if(bs==-1 && loosprofit==0) {CloseTicket(OrderTicket()); continue;}  //  all in chart   <<--- did the job command--> CloseButton(-1,-1,0); 
         if(bs>=2 && OrderType()==bs) {CloseTicket(OrderTicket()); continue;} // pending oeder    <<--- did the job command--> CloseButton(3,-1,0); / CloseButton(4,-1,0);
         if(bs<=1 && OrderType()==bs)
           {
            double hasil=(OrderProfit()+OrderSwap()+OrderCommission());
            if(loosprofit==0) {CloseTicket(OrderTicket()); continue;}
            if(loosprofit==1 && hasil>=0) {CloseTicket(OrderTicket()); continue;}// close profit     <<--- did the job command--> CloseButton( 0,-1,1); / CloseButton(-1,-1,1); 
            if(loosprofit==-1 && hasil<=0) {CloseTicket(OrderTicket()); continue;}// close loos      <<--- did the job command--> CloseButton( 1,-1,-1); /  CloseButton(-1,-1,-1);
           }
        }
     }
   return;
  }
 
Repions:

What wrong with this code..!!

only order Symbol on active chart  closed .. order ...in other Symbol & chart NOT.closed ....!

any clue..?

1) you return after the first not selectable order? I would write continue instead?

2) is this is not working:

if(bs==-9 && magic==-9 && loosprofit==-9) {CloseTicket(OrderTicket()); continue;} // Global all at Terminal  <<<--- at this not working

a) check the Errors, b) it could be a logic problem of bs && magic && loosprofit or c) your function


CloseTicket

might have a problem - but nothing for us to look at :(

 
  1. Problem is likely in CloseTicket that you didn't bother to show. Since you aren't selecting only the current chart pair, that had better not be using any predefined variables.
  2. Check your return codes (OrderSelect) What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
 
gooly:

1) you return after the first not selectable order? I would write continue instead?

2) is this is not working:

a) check the Errors, b) it could be a logic problem of bs && magic && loosprofit or c) your function


might have a problem - but nothing for us to look at :(

Is there is  "not selectable order?"

thereis No error at all at jurnal & expert

thanks..

 
WHRoeder:
  1. Problem is likely in CloseTicket that you didn't bother to show. Since you aren't selecting only the current chart pair, that had better not be using any predefined variables.
  2. Check your return codes (OrderSelect) What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles


1. CloseTicket  working good at other call .... 
CloseButton(0,-1,-1);  CloseButton(1,-1,1); ..etc   except CloseButton(-9,-9,-9);
2. no return Value, 


 
Repions: Is there is "not selectable order?"
That is why you must count down Loops and Closing or Deleting Orders - MQL4 forum
 
WHRoeder:
Repions: Is there is "not selectable order?"
That is why you must count down Loops and Closing or Deleting Orders - MQL4 forum


I NEED TO DELETE ALL ORDER IN ALL DEFERENT SYMBOLES  FROM EA IN ACTIVE CHART

For example :

I have 4 order Buy EURUSD , 4 orderSell in GBPUSD & 2 order Buy & 2 sel in USDJPY,.. My EA in active chart with USDJPY need to close all  12 order in 3 deferent symbols..

WE CAN DO THAT ? IS THERE AN EXAMPLE WHICH CAN BE SEEN..? ANY LINK..PLEASE..!!

my func CloseButton()  can do all job in active chart only.    thanks all..

 
OrderSymbol()==Symbol()

This is what limits the EA to the current symbol only. The rest you need to figure it out.

 
deysmacro:

This is what limits the EA to the current symbol only. The rest you need to figure it out.

yes i knew that... if u look my code  i had do before
OrderSymbol()==Symbol()

soo in theory will do the job .. but nothing happen with other symbols order..the only closed is only order in active chart. And my EA interface frezz about 2 minute before back in normale state

 
Seems that I need to say it directly. What I am trying to say on the previous post, remove the limits. Might as well remove the magic number too.
 

PROBLEM SOLVED


The problem is in CloseTicket(), i use  Close Price with ask / bid...

after replaced with OrderClosePrice() ...did the job.  Previously I thought OrderClosePrice()  just for  MODE_HISTORY..


Thank all of your Time ..Bless You..

Reason: