Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1356

 
Vladimir I know the rule of comparison. So it can't be done without any additional conditions?
 
Oleg Kolesov #:
Vladimir, I know the rule of comparison. So you can't do it without conditions?

What are the extras?


Can you do even better than that, without comparison:

      //---------------------------------------------+
      levelcol1[i]=1.0;
      if(level1[i]>level1[i+PeriodSh])
        {
         levelcol1[i]=0.0;
         continue;
        }
      /*if(CompareDoubles(level1[i],level1[i+PeriodSh]))
        {
         levelcol1[i]=1.0;
         continue;
        }*/
      if(level1[i]<level1[i+PeriodSh])
        {
         levelcol1[i]=2.0;
         continue;
        }
     }  //--- Возвращаемое значение prev_calculated для следующего вызова
 
Thank you for your help.
 
Vladimir Karputov #:

What are the extras?


And you can do even better, without comparison:

The same is true if you compare on an equal basis without normalisation.

 
The main question remains unresolved. How to colour the buffer with two colours. >= Blue to <= Red.
 
Oleg Kolesov #:
The main question remains unsolved. How to colour the buffer with two colours. >= Blue to <= Red.

And in the case of equal, how do you know whether it is more or equal or less or equal? That's the challenge, isn't it?)

 
Oleg Kolesov #:
What's the task? Loop?ArrayBsearch? ArraySort? By what means?

Hussars silence!

This is the apocalypse.

The mind must be treated.

 
I'll take a break. Thank you.
 

Please help with removing an indicator from the main window.

For example, several Custom MA indicators are placed, each is called by iCustom(handleMA,...,...).

Thus, a dozen of moving averages are displayed on the chart.

Then these indicators must be recalculated using a timer.

The order is as follows - the timer triggers, the old indicators are removed, calculation and drawing of new moving averages takes place.

Now, the very problem: old lines remain on the chart at each new iteration.

I have tried to remove them in two ways:

Graph_MA[i] = iCustom(_Symbol,Timeframe,"MA", /*параметры индикатора*/);   
for(int i=0; i < kol_Lines; i++) 
     {
      res = IndicatorRelease(Graph_MA[i]);
     }

In this case res variable is equal to True each time, but extra indicators are not removed from the chart.

The second way:

name_MA[i]=StringFormat("MA_Line # %d", i);
IndicatorSetString(INDICATOR_SHORTNAME,name_MA[i]);
res = ChartIndicatorDelete(0, 0, name_MA[i]);

To no avail: res is always false.

 
qadexys #:

Please help with removing an indicator from the main window.

For example, several Custom MA indicators are placed, each is called by iCustom(handleMA,...,...).

Thus, a dozen of moving averages are displayed on the chart.

Then these indicators must be recalculated using a timer.

The order is as follows - the timer triggers, the old indicators are removed, calculation and drawing of new moving averages takes place.

Now, the very problem: old lines remain on the chart at each new iteration.

I have tried to remove them in two ways:

In this case res variable is equal to True each time, but extra indicators are not removed from the chart.

The second way:

To no avail: res is always false.

These are the features of IndicatorRelease() - it's not deletion of an indicator, but it is the notification of the terminal that the indicator is not needed anymore. Further the terminal decides itself when to remove it. Usually, it does it after some seconds.

Maybe there are some tricks - I don't know. Maybe try to switch the chart.

Reason: