Logic is correct apparently but wrong result (only buy orders showed)

 

I create a function for open orders as below and shows only buy orders.

The EA allows both buy and sell orders and others remains no difference. 

However, if I remove the words in red (i.e.  orderType == OP_BUY and  orderType == OP_SELL), both buy and sell orders are open. 

Any advice why such problem happens? Much Thanks!

...

Improperly formatted code removed by moderator. Please EDIT your post and use the CODE button (Alt-S) when inserting code.

Code button in editor

Hover your mouse over your post and select "edit" ... 

...

 
Tyrone Chan:

I create a function for open orders as below and shows only buy orders.

The EA allows both buy and sell orders and others remains no difference. 

However, if I remove the words in red (i.e.  orderType == OP_BUY and  orderType == OP_SELL), both buy and sell orders are open. 

Any advice why such problem happens? Much Thanks!


You should update your post and use the code button </> or Alt-s to post the code properly.

if this is for MT4 then it should have been posted in the MT4 section, if it is for MT5 then the ordertypes are wrong see the documentation.

orderType is defined as an int when passed in your function, that may work ok but you should really call it what it is an enumuration .

you don't show and therefore we cannot see what you are passing in as orderType so make sure that is correct 

 
Your topic has been moved to the section: MQL4 and MetaTrader 4
Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 
Tyrone Chan:

I create a function for open orders as below and shows only buy orders.

The EA allows both buy and sell orders and others remains no difference. 

However, if I remove the words in red (i.e.  orderType == OP_BUY and  orderType == OP_SELL), both buy and sell orders are open. 

Any advice why such problem happens? Much Thanks!

...

Improperly formatted code removed by moderator. Please EDIT your post and use the CODE button (Alt-S) when inserting code.

Hover your mouse over your post and select "edit" ... 

...

Dont use EA Generators, Learn to code, or paste the code you have so we can have a look. We wont be able to answer you based on what you have given us. if we can see that you tried, we will help you to fix your problem, if we can. Remember, no coder will code for free, unless the topic is interesting enough, and we can see you have really tried doing it yourself. If you use generators, we will see it, if you are struggling to learn the MQL language, you may ask someone to code it for you by creating a job in the Freelance section.