Questions from a "dummy" - page 117

 
meneo:

How can this be? (see calculation of variable k and values of all variables in debug mode)

It's very simple. lparam is long type (integer), wdpix is int type (integer). lparam/wdpix is private long type (integer). Since lparam < wdpix, lparam/wdpix ==0.

See MQL5 Reference / Language Basics / Data types / Type conversion

 
meneo:

How do you account for the gaps between adjacent bars on the chart?

If you see it, please notify Service Desk about the error.
 
Thank you all! )
 
Can you tell which expert is running in another window?
 
meneo:
Can you tell which Expert Advisor is running in another window?
It seems to be impossible (if I have not missed anything). But it is possible to "distinguish" one's own from the "others". If there are several programs in the project, you can specify their protocol of exchange of courtesies through custom messages. They should say hello, take off their hat, turn out their pockets, etc.
 

Is it also possible to do an enumeration by enumeration

like this?

for (int i = PERIOD_M1;i<=PERIOD_D;i++)

Документация по MQL5: Стандартные константы, перечисления и структуры / Константы графиков / Периоды графиков
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы графиков / Периоды графиков
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы графиков / Периоды графиков - Документация по MQL5
 
meneo:

Is it also possible to do an enumeration by enumeration

like this?

for (int i = PERIOD_M1;i<=PERIOD_D;i++)

This will not work.

About this - I should try it.

for (ENUM_TIMEFRAMES i = PERIOD_M1;i<=PERIOD_D;i++) {}

Somehow I suspect that will not work, although "theoretically" have a chance. :)

 

Well, I tried it.

void OnStart()
  {
//---
   for (ENUM_TIMEFRAMES i = PERIOD_M1;i<=PERIOD_D;i++) { Print(EnumToString(i));}
  }
//+------------------------------------------------------------------+

Doesn't even want to compile.

'ForEnum.mq5' ForEnum.mq5 1 1
'i' - unexpected token ForEnum.mq5 15 25
'i' - undeclared identifier ForEnum.mq5 15 25
'PERIOD_D' - undeclared identifier ForEnum.mq5 15 42
'i' - parameter for EnumToString must be an enumeration ForEnum.mq5 15 77
4 error(s), 0 warning(s) 5 1

But it seems there is nothing illegal about it.

 
MetaDriver:

I tried it.

The programmer does not even want to compile.

And there seems to be nothing illegal about it.


To work with enum, you should probably add at least such functions as

enum::GetName and enum::GetValue

and foreach language construct

Then the enumeration will be automated by MQL

 

This, of course, works.

#property script_show_inputs

input  ENUM_TIMEFRAMES P = PERIOD_D1;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   for (int i = PERIOD_M1;i<=P;i++)  // { Print(EnumToString(ENUM_TIMEFRAMES(i)));}
    {
      string S=EnumToString(ENUM_TIMEFRAMES(i));
      if (StringGetCharacter(S,0)=='P')   

        {{{{ Print(S);  }}}}

    }

  }

And what's great - it doesn't say that P is an unexpected token or undeclared identifier

And on the contrary, as a regular client it provides all the conveniences



Strange ..... ;)