Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 917

 
leonerd:


How to go through all chart IDs in terminal? current_chart_id in my code is 1662429437, first_chart_id is 1859831371. ChartNext() already returns -1. So what is ChartFirst()?

What does it mean first? Opened first? Why is its ID greater than that of the current chart (opened later, by the way)?

Apparently it's because of long -> int conversion.

 
Artyom Trishkin:

Thank you, yes it used to be like that.

 
Who knows how to create for while loops etc. I would like to create a loop using my technology, what can I learn?
 
leonerd:

Apparently it's because of the long -> int conversion.

there is no such logic, see example from helphttps://www.mql5.com/ru/docs/chart_operations/chartnext

Chart ID numbers have no logic in their formation, maybe they are Windows handles or some other numbers, to look through all the chart IDs in the terminal, the example from the help is enough, I've posted in kodobase indicator that builds second TF, I used an example from the help - everything works like clockwork - I find my custom chart - I remember its chart ID and generate ticks on it


Seric29:
Who knows how loops for while etc. are created I would like to create a loop using my technology, what can I learn?

hmm, see your question for a few days, what answer do you want to hear? - these are language operators, they work as defined by the developers and this is indicated in the help. in no programming language are language operators described "as they are" - language operators are always "provided as is" - no more and no less

here are MQL4 language operatorshttps://docs.mql4.com/ru/basis/operators- they are "just like this" - this isthe basis of any programming language

 
Igor Makanu:

hmm, several days I see your question, and what answer do you want to hear? - these are language operators, they work as defined by the developers, which is indicated in the help, language operators are not described "as arranged" in any programming language - language operators are always "provided as is" - no more and no less

here are MQL4 language operatorshttps://docs.mql4.com/ru/basis/operators- they are "just like this" - this is the basis of any programming language

So it's bad that they are not described that half of the necessary information is hidden. I'm interested in how they are structured. I want to create my own loops, and as it turned out there are at least 3 loops in mql that exist in c++ and pascal, and these loops could also ease the work to reduce the number of checks and initialization of unnecessary flags and variables, but I want to create my own, but I can not understand how these iterations occur, how it is done in any code block, you can write a loop and open braces, that also contain code. Very interesting guys if anyone will what to write plz.

 
Seric29:

Also, as it turned out, mql has at least 3 loops that are in c++ and pascal

I studied both Pascal and C++ at university and it's still there:

C++ : for , while , do...while

Pascal : for , while , repeat

MQL: for , while , do...while

????


Seric29:

So it's bad that they aren't described and half of the necessary information is hidden. I wonder how they work.

I don't even know how to explain the absurdity of your question, but I will try anyway:

You: - "I'm studying Russian and I need to know how the alphabet works"

Me: "The alphabet has no structure, it's just letters and they form words"(in MQL there are about a dozen operators and they form the program)https://docs.mql4.com/ru/basis/operators

You : "no way! I know the letters of the alphabet in Zimbabwean mean a lot of things!"

Me: "Unfortunately, I do not know the language, but in Russian a letter means just that it is a letter, you can of course make a phonetic analysis, but that will not stop a letter from being an elementary element of the word.

You go, "Hmm, strange, but in Zimbabwean, if you say 'a' it's a letter, and if you say 'A' it means peace to your house, and if you say 'aaaaaaah!'" - it means I've got the biggest willy!" - there's no way you can't see how letters are arranged in the russian language! - there's hidden technology in there....


well that's about how i see our dialogue, sorry about my english - i can't do it any other way

)))

 
Igor Makanu:

there is no such logic there, look at the help examplehttps://www.mql5.com/ru/docs/chart_operations/chartnext

Chart ID numbers have no logic in their formation, maybe they are Windows handles or some other numbers. To search for all chart IDs in the terminal, the example from the help is enough, I used an indicator for building sec-tFs in kodobase.

ChartFirst() returns the smallest ID of the open chart?

 
leonerd:

ChartFirst() returns the smallest ID from the open charts?

again no! - the numeric value of ChartFirst() makes no sense

PZS: ......maybe wrong, but I read somewhere that ChartFirst() returns the ID of the chart that was opened first, not the one that is first in your chart sequence (you can move it), but the one that was opened first in the client terminal - well, I'm not sure I'm right about this


ChartFirst() gives you a starting point from which you can scroll through the charts with ChartNext(). It looks like this: get the first ChartFirst() ID - memorize the value and transmit this value to ChartNext() - and so on, until the first ChartFirst() value is repeated - which means that you have scrolled through all possible charts,

here's the code from my indicator in KB - I found it in the help, checked it and use it to find my chart:

//+------------------------------------------------------------------+
//| поиск  идентификатора графика                                    |
//+------------------------------------------------------------------+
long CheckChart(string sym,int period,int &wh)
  {
   long result=0,id=ChartFirst();
   while(id>=0)
     {
      if(ChartSymbol(id)==sym && ChartPeriod(id)==period && ChartGetInteger(id,CHART_IS_OFFLINE))
        {
         result=id;
         ChartSetInteger(id,CHART_AUTOSCROLL,true);
         ChartSetInteger(id,CHART_SHIFT,true);
         ChartNavigate(id,CHART_END);
         ChartRedraw(id);
         wh=WindowHandle(sym,period);
         PrintFormat("Найдено окно графика: [%s,%d]",sym,period);
         break;
        }
      id=ChartNext(id);
     }
   return(result);
  }
//+------------------------------------------------------------------+
 
Igor Makanu:

again no! - The numeric value of ChartFirst() makes no sense

SZY: ......maybe wrong, but I read somewhere that ChartFirst() returns the ID of the chart which was opened first, not the first chart in your chart sequence (you can move it), but the one that was opened first in the client terminal - in general, I'm not sure I'm right about this


ChartFirst() gives you a starting point from which you can scroll through the charts with ChartNext(). It looks like this: get the first ChartFirst() ID - memorize the value and transmit this value to ChartNext() - and so on, until the first ChartFirst() value is repeated- which means that you have scrolled through all possible charts,

here's the code from my indicator in KB - I found it in the help, checked it and use it to find my chart:

Strange. It doesn't say anything in help about "until the first ChartFirst() value is repeated". At the end of the chart list, it returns -1

Returned value

The chart's identifier. If the chart list is over, the function returns -1.

Документация по MQL5: Операции с графиками / ChartNext
Документация по MQL5: Операции с графиками / ChartNext
  • www.mql5.com
Операции с графиками / ChartNext - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Artyom Trishkin:

Strange. The help doesn't say anything about "until the first ChartFirst() value is repeated". When chart list ends, it returns -1

I'm sorry - I am a sinner! I didn't read it, I was drunk when writing on this forum!

Reason: