Your opinion on this small code please
Hello,
Can you tell me your opinion on this piece of code please.
Its goal is to count the total number of active orders (op_buy and op_sell only, no pending) in progress on several EAs.
You have additional sets of ( ) that you don't need, but they won't hurt.
Hello,
Can you tell me your opinion on this piece of code please.
Also you could think about to have the code block in a function and passing the magic numbers within an array to it. You could fill the array with external values (magic numbers) and you would not need to change the code block(s) if the number of controled magic numbers do change.
Thank you,
RaptorUK, you do not count your answers, and our ignorance does not tire, a big thank you to you
| Your code | for(Position_Index = Total_Orders - 1; Position_Index >= 0 ; Position_Index --) { if ( ! OrderSelect(Position_Index, SELECT_BY_POS, MODE_TRADES)) continue; if ( ((OrderType() == OP_BUY) || (OrderType() == OP_SELL)) && ((OrderMagicNumber()==Magic_Number) || (OrderMagicNumber()==Other_EA_Magic_Num...) ) { Compteur = Compteur + 1; break; } } |
| Easier to Read | for(Position_Index = Total_Orders - 1; Position_Index >= 0 ; Position_Index --) if( OrderSelect(Position_Index, SELECT_BY_POS, MODE_TRADES) &&( OrderType() == OP_BUY || (OrderType() == OP_SELL // Or use OrderType() <= OP_SELL ) &&( OrderMagicNumber()==Magic_Number || (OrderMagicNumber()==Other_EA_Magic_Number_1 || (OrderMagicNumber()==Other_EA_Magic_Number_2 ) ){ Compteur = Compteur + 1; } // for |
Hello,
Can you tell me your opinion on this piece of code please.
Its goal is to count the total number of active orders (op_buy and op_sell only, no pending) in progress on several EAs.
Thanks, Emmanuel.