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

 
137 Matrix #:

I already showed it to you - I don't know why it doesn't work for you - it works for me on both mt4 and mt5.

\\\\\\\\\\\\\\\\\\\\

you can also change the colour of the charts

Sasha, you can't think of anything worse than using examples from the documentation or tumblr examples. And you've also lost the flag of forced termination of while loop somewhere. All in all ... no words.
 
DanilaMactep #:
This option does nothing at all - I release the script on the chart and nothing happens.

Sorry lost the logical negation sign !

void OnStart()
 {
  long prevChart = ChartFirst();
  while(prevChart >= 0 && !IsStopped())
   {
    //if(ChartPeriod(prevChart) != PERIOD_H1)
      ChartSetSymbolPeriod(prevChart, ChartSymbol(prevChart), PERIOD_H1);// или PERIOD_D1
      ChartApplyTemplate(prevChart, tplName);
    prevChart = ChartNext(prevChart);
   }
 }/******************************************************************/
/*****************************End program****************************/
 
Alexey Viktorov #:
Sasha, you can't think of anything worse than using examples from documentation or tumblr examples. Oh, and somewhere he lost the flag of forced termination of while loop. Well ... no words.

For example, my task is to find a function that satisfies my task, I search for it and if it fits my task - no matter how many lines it has - I use it.

The main thing is that the function works the way I want it to.

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

I do it for self-development and nothing more, purely for me. I don't think I have to write anything to anyone.

 
137 Matrix #:

For example, my task is to find a function that satisfies my task, I search for it and if it fits my task - no matter how many lines it has - I use it.

The main thing is that the function works the way I want it to.

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

I do it for self-development and nothing more, purely for me. I don't think I'm writing anything to anyone.

When you give advice to someone, it's not for you.

Especially with such mistakes... What is PERIOD_CURRENT and what is the result in the condition

      if(TimeFrame != PERIOD_CURRENT)
 
Alexey Viktorov #:

When you give advice to someone else, it's not for yourself.

Especially with such mistakes... What is PERIOD_CURRENT and what is the result in the condition

I don't know, it works!

It switches the chart by the period restored in the settings .

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

When someone asks a question, I try to get in his shoes and achieve the required result.

If you have not noticed, I have completed this task as best I could and posted the ready-made script - it may not be correct - but it fulfills its purpose.

 
Alexey Viktorov #:

When you give advice to someone else, it's no longer for yourself.

Especially with such mistakes... What is PERIOD_CURRENT and what is the result in the condition

 if(TimeFrame != PERIOD_CURRENT)

I don't see any error here.

 
Alekseu Fedotov #:

I don't see the error here.

if(TimeFrame != PERIOD_CURRENT)

same thing

if(TimeFrame != 0)
 
Alekseu Fedotov #:

I don't see an error here.

PERIOD_CURRENT is 0 - the magic constant

It should be _Period (the period of the current chart) at least and it is always not 0

 
Alekseu Fedotov #:

I don't see an error here.

Where this piece of code is taken, there is also an input parameter

sinput ENUM_TIMEFRAMES TimeFrame = PERIOD_CURRENT; // Период

Correspondingly, we get the condition if 0 is not equal to 0.

But if we replace PERIOD_CURRENT with any other period in the input parameter, the condition will hold regardless of the chart period. What is the point of this condition then?

 
Alexey Viktorov #:

Where this piece of code is taken, there is also an input parameter

Correspondingly, we get the condition if 0 is not equal to 0

But if we replace PERIOD_CURRENT with any other period in the input parameter, the condition will hold regardless of the chart period. So what is the point of this condition then?

It makes sense only one time, so that the ChartSetSymbolPeriod() function doesn't bother you too much;

Reason: