Also, I believe there is a logic error inside the FOR loop...what happens after OrderSelect() returns false (assuming for the moment it does) and the error message is printed to the log? The very next statement is an IF statement which uses OrderSymbol() and OrderMagicNumber(), but those functions may not return the correct information because the OrderSelect() failed...
I mean no disrespect, but I disagree. The statement:
is inefficient coding. The FOR loop works without it, so why use that code? Also, I believe there is a logic error inside the FOR loop...what happens after OrderSelect() returns false (assuming for the moment it does) and the error message is printed to the log? The very next statement is an IF statement which uses OrderSymbol() and OrderMagicNumber(), but those functions may not return the correct information because the OrderSelect() failed. You may be able to correct that logic error by adding the Continue operator after printing the error message to the log or by rewriting the contents of the FOR loop without the logical negation NOT. For example:
Wow, you do want to help !
Thanks. That is indeed more efficient (less words same output).
So here we are, first post is better than nothing, your example more efficient. I guess some people will find what we did useful, don't you?
You are trying to address your code to newbies, right ? My opinion is that for a newbie in programming it's sufficient to learn how to use and check one log. As you know there two logs available when you are running a code attached to a live chart. So, as your code have some controls on what is output to Experts log and not to Journal log, it's more easy to use the Experts log, for verbose (description) output and for error number output.
Also, I suggest you to calm down, as most of your posts in this thread, seems too much aggressive or hostile. We are all trying to help and/or learn.
I can see your point about the logs. If by any chance you've taken the " Care to explain " as sarcasm, it wasn't intended that way, just asking to explain the point further.
Thanks for doing so.
About that "seems too much aggressive or hostile" thing, I don't really think I was attacking anyone out of the blue and if my views happen to match yours or Jimdandy for that matter isn't because I'm hostile . Are you ?
But that's a matter of opinion. I know you've been long enough on this forum to understand things and if people don't find a nice and friendly environment, they won't stay and won't come back.
Would you like this place to be better ? I would. Are you happy having people jumping on you for no reason ? I don't .
Do you like it when people, nice and polite, state their view, explain it and post code to help ? I do. So, no problem here mate, as calm as I can be.
You, as moderators have the power to make or break this forum. If you care about outsider's opinion, sometimes it doesn't look very friendly.
Somehow I get the feeling that there are people out there waiting for a new post to jump on it and ruin it . Maybe it's just me. And Jimdandy. And others.
Let me now when you finished reading this so I can delete it . This forum isn't for things like that.
I had a quick look over some of your comments and I missed the unprovoked attacks. Can you please post a link ?
Just kidding !
Would you care to quickly look, whenever you've got a moment, at this sample here ?
I'm sure there's a lot that can be improved on it.
And it seems like quite a number of people are looking forward to learn about the new stuff .
And yeah, If you ask me, I agree whit what you said but I would put " almost " more like towards the front of the first sentence not the end of it, but that's just me. Just for accuracy's sake. ; )
As an example, the following is my current trade count function (for build 509):
My function isn't perfect...but it works for me at the moment. It will be interesting to see how I can improve it when I rewrite it for build 600+.
That doesn't look right. Shouldn't it be.
count = c_buy + c_sell // total trades
count = c_buy + c_sell - c_pending; // total open trades
. . .
count = c_buy + c_sell; // total open trades
That code is correct because count holds the total of all market/pending trades for currency pair. The EA, from where the code originated, doesn't need a count of only market orders (i.e., only OP_BUY and OP_SELL); rather, it needs (1) a count of total open (market and pending) trades, (2) a separate count of only buy trades and of only sell trades, and (3) a count of only pending trades. I use those counts in the EA to control various other functions--for example, to determine when the EA should place a trade and in which direction or to determine if the EA needs to delete all pending trades at a specific time or after a specific event.
In the event the EA did need to know the total number of open market orders, count - count would provide that value (which, due to the constraints designed into the EA and broker rules, would be either 0 or 1), so there is no need to include that in CountOpenTrades(). In this example, I'm using the variable name "count", but it would actually be the variable passed by reference to CountOpenTrades().
Hope that explanation helps.