And this was done at length not so long ago...
if my memory doesn't trick me this is the official "blocking" i have/ should have learnd ;)
int start(){ //+------------------------------------------------++------------------------------------------------+ //+------------------------------------------------++------------------------------------------------+ int Ticket; for(int i=OrdersHistoryTotal()-1; i>=0; i--){ if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true){ if(OrderProfit() - (OrderCommission()+OrderSwap()) < 0){ Ticket=OrderTicket(); break; } } } //+------------------------------------------------++------------------------------------------------+ //+------------------------------------------------++------------------------------------------------+ return(Ticket); }
but i also do not follow it. i like
int start() { //+------------------------------------------------++------------------------------------------------+ //+------------------------------------------------++------------------------------------------------+ int Ticket; for(int i=OrdersHistoryTotal()-1; i>=0; i--) { if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==true) { if(OrderProfit() - (OrderCommission()+OrderSwap()) < 0) { Ticket=OrderTicket(); break; } } } //+------------------------------------------------++------------------------------------------------+ //+------------------------------------------------++------------------------------------------------+ return(Ticket); }
why? because i can see clearly where a new block starts and end's. also in mql i sugest to never declare a variable inside a for loop. in your example,
instead of
for(int i=OrdersHistoryTotal()-1; i>=0; i--)
i use:
int i=0; for(i=OrdersHistoryTotal()-1; i>=0; i--)
in my opinion this is necesary because mql declares this "i" variable outside of the block, which is in from my point of view a bug.
// added:
here i think is it more usefull to you if you find a blocking style which is ok for you. shure when you work on larger projects, with more people working on the same code its necesarry to keep a standart blocking format, but as mostly of the code is only viewed edited by you its more important that you can easyly read your code..
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Ok, everybody here knows I'm not a computer science student. I was wondering about the proper Braces format (say the industry standards) if there's such a thing. I'm getting more favored with my personal format below. To me/myself/personally, I think the block format looks better then say the S-style indents. Does my style make it harder for other programmers to work with?
Examples of other styles I've seen:
And: