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