Block 1
Block 2
I think that both are doing the same thing.
Can some one explain please?
No. Block 1 return count of BUY and SELL trades
Block 2 return only "type" passed in parameters. (BUY or SELL)
int trades_count(int type=WRONG_VALUE){ int n=0; for(int i=OrdersTotal()-1; i >= 0; --i) if( OrderSelect(i,SELECT_BY_POS) && OrderMagicNumber() == MagicNumber){ && (type == WRONG_VALUE || type == OrderType() ) && OrderSymbol() == Symbol() ) ++n; return n; }
They could be combined and simplified.
What should I do if I want to use the code (you provided) directly in OnTick function instead of creating a separate function and calling it. I mean how I will handle the type variable for checking total opened orders, total opened buy orders and total opened sell orders?
- www.mql5.com
You should step away from the keyboard, take a programming class or at least read the book Programming for Dummies. Why would you want to make OnTick harder to understand?
You should step away from the keyboard, take a programming class or at least read the book Programming for Dummies.
I was not expecting this from you. Whenever I asked about something here, I always waited for your comment because most of the times it was you, who got exactly what was in my mind and you pointed me to the right direction. (Is it someone else/new using THIS account now?)
Why would you want to make OnTick harder to understand?.
With your help and guidance in this forum, I wrote a program two years ago. Then someone stole my laptop and (...)
Lets just say that writing "harder to understand OnTick" at least once after a long gap will help me in not to do this again.
Will you please guide me as you always did?
PS: Please check the code you shared.
int trades_count(int type=WRONG_VALUE){ int n=0; for(int i=OrdersTotal()-1; i >= 0; --i) if( OrderSelect(i,SELECT_BY_POS) // && OrderMagicNumber() == MagicNumber){ && (OrderMagicNumber() == MagicNumber) && (type == WRONG_VALUE || type == OrderType() ) && OrderSymbol() == Symbol() ) ++n; return n; }
Qæs:
Lets just say that writing "harder to understand OnTick" at least once after a long gap will help me in not to do this again.
Will you please guide me as you always did?
PS: Please check the code you shared.
-
You could write a thousand line function, repeating the (almost) same thing over and over. Do you really think you could get it to work? Do you really think you could understand it when it doesn't? Do you really expect to understand a month from now why two loops are almost the same but aren't and why?
-
int nTrades = trades_count(); int nBuys = trades_count(OP_BUY);
Do you think you could understand those two lines, what they do, why they are different?
-
Check it for what?
-
You could write a thousand line function, repeating the (almost) same thing over and over. Do you really think you could get it to work? Do you really think you could understand it when it doesn't? Do you really expect to understand a month from now why two loops are almost the same but aren't and why?
-
Do you think you could understand those two lines, what they do, why they are different?
-
Check it for what?
I actually was stuck in "Why someone used the same loop again and again for the same one result which can be obtained using one loop?".
@remcous told that its not one result. but "Why two loops?" was still in my mind, and then you solved the puzzle.
I was in the middle of mixing everything when I came here again and saw your comment.
I thought to mix the solution that you shared, too. So I asked you all those things.
Thanks God I was not in front of you.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Block 1
Block 2
I think that both are doing the same thing.
Can some one explain please?