Download MetaTrader 5

Can`t close all order in terminal

To add comments, please log in or register
Have you discovered something really important? Write an article and receive 200 USD!
Repions
100
Repions 2014.12.02 19:00 

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;
  }
Carl Schreiber
6592
Carl Schreiber 2014.12.02 21:16  
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 :(

whroeder1
14519
whroeder1 2014.12.02 21:55  
  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
Repions
100
Repions 2014.12.03 04:16  
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..

Repions
100
Repions 2014.12.03 04:29  
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, 


whroeder1
14519
whroeder1 2014.12.03 13:16  
Repions: Is there is "not selectable order?"
That is why you must count down Loops and Closing or Deleting Orders - MQL4 forum
Repions
100
Repions 2014.12.03 16:27  
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..

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.12.03 17:20  
OrderSymbol()==Symbol()

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

Repions
100
Repions 2014.12.03 17:59  
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

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2014.12.03 18:07  
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.
Repions
100
Repions 2014.12.03 19:33  

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..

12
To add comments, please log in or register