Help me learn how to program. - page 6

 
Dmitry Fedoseev:

You can't write three lines at once. One line will have three mistakes.

Even an algorithm you have in mind is not always exactly what you need. It would be such a pain to "write" a well-thought-out code in one's mind so that you could write it correctly in the editor the first time. What are you saying to whom?

I don't really care.

I just wouldn't advise an uninformed person who'd come up with a particular question to write anything at all.
I would just give him/her a working code and if I had any questions I would answer them. Since I'd decided to start helping.

You don't need to get the code polished right away. You need to read the documentation and look at examples of code right away.

That's all you need)))


Well, while you are proving me wrong, I've written an excellent Expert Advisor that solved the issue of using PositionsTotal() in loops for me personally.


Attention!
Ladies and Gentlemen! I would like to present to your attention! It is the first in the history of disputes and cholivars about how to use PositionsTotal() in loops! It is the only one of its kind(maybe). Wonderful! Brilliant! It is written according to the best MQL Forum's tutorials!

It will advise you how to use thePositionsTotal() functionin loops, and will leave no doubt in your rightness to write the code as you like !!!

The developers must have provided and optimized resource consumption of this function! They did it! WELL DONE! Kudos to them for that!


So pay attention! Code!!!!

enum T {
   loop1, loop2, loop3
  };

input T tt = loop1;


int OnInit()
  {
   return(INIT_SUCCEEDED);
  }
void OnDeinit(const int reason){}
  
void OnTick()
  {
      uint timeInit = GetTickCount();
      int index;
      switch(tt)  {
         case loop1: 
            for(index=PositionsTotal()-1; index>=0; index--) { /* тело цикла */ }
            break;
         case loop2: 
            for(index=0; index<PositionsTotal(); index++) { /* тело цикла */ }
            break;
         case loop3: 
            index = PositionsTotal();
            while (index-- > 0) { /* тело цикла */ }
            break;   
      }

      PrintFormat("%s - %d ms", EnumToString(tt), GetTickCount() - timeInit);
  }
  
  
  

Thanks for the heads up)

 
Alexey Viktorov:

Well, I have no right to prevent you from getting lost. Just think what a novice programmer can write if he/she is interested only in beauty and brevity of code... I think he/she will get tired of writing code without seeing the result and will quit this ungodly occupation.

I am writing about understanding while developing. First study - then action.

On the contrary, you write: first action, then thinking and combing.

It seems to be the same thing. But why do they write code samples and documentation?) Is it so that people would do less harm? I think that's exactly the reason. What do you think?

 
Dmitry Fedoseev:

What's also very funny is that everyone is getting so worked up - oh what a wrong code I wrote as a newbie... and everyone keeps telling me about it... instead of just writing it right... What an interesting paradox! So worried about him that they immediately forgot about him (or never remembered at all).

You can't get so worked up over three or five lines. You guys must be so productive that even a line of code is the greatest event for you?

Why doesn't anybody bother that I don't do anything at zero? I can answer for you, because it is beyond your understanding. Your pontifications are at a kindergarten level.

Look at yourself. You don't have an ounce of constructive, creative, or just work ethic. You are able to discuss only one and the same line of code, this topic about the for function is older than the forum itself, but you are still discussing it, still start new threads about it. By the way, I wrote about it in the article about arrays 8 years ago. But you're still discussing it... And the amazing thing is you're opening my eyes to the world. Awesome!

P****z. 8 years you already know the answer and can't just write it like it is. I guess you don't know after all)

 
Nikolay Mitrofanov:

I don't really care.

I just wouldn't advise an ignorant person who came with a specific question to write anything.
I would just give him a working code and if the questions came up, I would answer them. Since I'd decided to start helping.

You don't need to get the code polished right away. You need to read the documentation and look at examples of code right away.

That's all you need)))


Well, while you are proving me wrong, I've written an excellent Expert Advisor that solved the issue of using PositionsTotal() in loops for me personally.


Attention!
Ladies and Gentlemen! I would like to present to your attention! It is the first in the history of disputes and cholivars about how to use PositionsTotal() in loops! It is the only one of its kind(maybe). Wonderful! Brilliant! It is written according to the best manuals of the MQL Forum!

It will advise you how to use thePositionsTotal() functionin loops, and will leave no doubt in your rightness to write the code as you like !!!

The developers must have provided and optimized resource consumption of this function! They did it! WELL DONE! Kudos to them for that!


So pay attention! Code!!!!

Thank you for your attention)

So you can't read either, to read and understand what the question at the beginning of this thread was about?

I would have given... Why didn't you?

How many years have you been on the forum? More than three, a bunch of junk in the marketplace and just today you learned how to properly use PositionsTotal()? Amazing! But I want to disappoint you, your experiment will most likely be useless because nothing is executed in loops, they will most likely be thrown out at compilation. So you are measuring the size of a spherical horse in a vacuum.

 
Nikolay Mitrofanov:

P****z. For 8 years you've known the answer and can't just write it as it is. Probably don't know after all)

Yep, 8 years ago I wrote it, but I don't know. Masterpiece of thought! I'm gonna freeze my ears off to spite my grandmother!

 
Dmitry Fedoseev:

Yeah, eight years ago I wrote it, but I don't know. Masterpiece of thought.

You're so stuffy.

 
Nikolay Mitrofanov:

You're so stuffy.

Let's have another sob.

 
Dmitry Fedoseev:

So you can't read either, to read and understand what the question at the beginning of this thread was about?

I would have given... Why didn't you?

How many years have you been on the forum? More than three, a bunch of junk in the marketplace and only today did you learn how to use PositionsTotal() properly? Amazing! But I want to disappoint you, your experiment will most likely be useless because nothing is executed in loops, they will most likely be thrown out at compilation. So you're measuring the size of a spherical horse in a vacuum.

Hum. I'm no match for your 10 bucks worth of junk. You take quantity? Oh, I see.)

And if you don't have enough action in cycles, put something in there that's worth 10 quid, like you like to do.

Yes. And why give something else if you've already answered the seeker?!

You wrote him a code example, and when asked about the loop you got bogged down, but you keep arguing. You're even rude.

Your experiment will most likely be worthless , because loops don't execute anything, they will most likely be thrown away when you compile
.

OMG, who am I wasting my time with...


So you're probably measuring the size of a spherical horse in a vacuum.
Lol))
 

What a load of crap...

Yes, Dmitry's cycle call is not the most elegant, but he wrote an interesting code for getting the number of the week from the date. When I use it, I always think of it with a kind word.

But, Dimitri, you have to be nicer to people.
 
Aleksei Stepanenko:

What a load of crap...

Yes, Dmitry's cycle call is not the most elegant, but he wrote an interesting code for getting the number of the week from the date. When I use it, I always think of it with a kind word.

Oh, can I see that?

Reason: