Questions from Beginners MQL5 MT5 MetaTrader 5 - page 806

 
User_mt5:

Vitaly, Vitaly!))
You have no idea how grateful to you!

That's a lot to take in. Of course, everything needs to be tried out now, but that's the little things.

I had no idea that happiness can be so close!)) Thank you! How is it... I'm here for you, I'm here for you!

F1 often solves many problems faster than the forum.
 
Artyom Trishkin:
F1 often solves many problems faster than the forum.
I can't find the answer to my question with F1.
 
DCodec:
I can't find the answer to my question with F1.

Well because it is a single indicator which has two lines. Use Moving Average with the same parameters as Envelopes to draw only one MA line. Only add Deviation*Point() for the upper line to the MA value, and subtract Deviation*Point() for the lower line

 
Artyom Trishkin:
F1 often solves many problems faster than the forum.

You see the thing is... The smart ones are sent to the smart ones...
I've been dragged through the vast expanse of forex... Now I'm in this forum.

F1 is a button, isn't it? Thanks for the tip. I'll give it a try.

 
IgorM М:

Greetings all! searched the forum for 30 minutes for"new bar", I was sad to find that the search on the forum works in its own way...

If i'm interested, what is the latest build of mql5 in terms of finding a new bar for the indicator that works on one timeframe, what code anyone uses now?

ZS: i searchedTimeframesFlags ... it's a cumbersome solution, but universal

thanks in advance!


https://www.mql5.com/ru/articles/159

Обработчик события "новый бар"
Обработчик события "новый бар"
  • 2010.10.04
  • Konstantin Gruzdev
  • www.mql5.com
Для создателей индикаторов и экспертов всегда был актуален вопрос написания экономичного кода с точки зрения времени выполнения. Можно подойти к решению этой задачи с разных сторон. Из этой обширной темы в данной статье будет затронут, казалось бы уже решенный вопрос: проверка появления нового бара. Это достаточно популярный способ ограничения...
 
Artyom Trishkin:

Well, because it is one indicator that has two lines. Use Moving Average with the same parameters as for Envelopes to draw only one MA line. Only add Deviation*Point() for the upper line to the MA value and subtract Deviation*Point() for the lower line

Interesting solution, thank you!

But if it is not Envelopes but Bollinger Bands - should I add a formula for calculating standard deviation? Yes, of course, but is there no simple solution in MQL4?

iEnvelopes

Возвращает значение технического индикатора Envelopes.

double  iEnvelopes(
   string       symbol,           // имя символа
   int          timeframe,        // таймфрейм
   int          ma_period,        // период
   int          ma_method,        // метод усреднения
   int          ma_shift,         // сдвиг средней
   int          applied_price,    // тип цены
   double       deviation,        // отклонение (в процентах)
   int          mode,             // индекс линии
   int          shift             // сдвиг
   );

I.e. parameter

int          mode,             // индекс линии
sets the line number.


 
DCodec:

...



How about this indicatorCustom Moving Average Levels?

A moving average indicator which can be set to two levels from MQL5 code:

Custom Moving Average Levels

 
Vladimir Karputov:

Would aCustom Moving Average Levels indicator like this work for you?

The Moving Average indicator that has two levels can be set from MQL5 code:

Thank you very much for your help, but I am in the process of learning MQL5. That's why I am trying to use iCustom to "pull" the required values from already built in indicators that have several indicator lines.

I can't do it yet, but I guess it's as simple as that.

 
DCodec:

Thanks a lot for the help, but I'm in the process of learning MQL5. And that is why I am trying to "pull" the required values from the already built-in indicators that have several indicator lines using iCustom.

I can't do it yet, but I guess it's kind of simple.


Everything is very simple with iCustom. Here is an example right away: in theCustom Moving Average Levels code there is

An example of how to create this indicator (it is located in the "terminal data directory"\MQL5\Indicators\MyInd\):

...
int            handle_iMA_Custom;            // variable for storing the handle of the iMA indicator 
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
...
//--- create handle of the Custom indicator "Custom Moving Average Levels"
   handle_iMA_Custom=iCustom(Symbol(),Period(),"MyInd\\Custom Moving Average Levels",
                             ma_period,
                             ma_shift,
                             ma_method,
                             100,
                             -100);
//--- if the handle is not created 
   if(handle_iMA_Custom==INVALID_HANDLE)
     {
      //--- tell about the failure and output the error code 
      PrintFormat("Failed to create handle of the iMA indicator for the symbol %s/%s, error code %d",
                  Symbol(),
                  EnumToString(Period()),
                  GetLastError());
      //--- the indicator is stopped early 
      return(INIT_FAILED);
     }
   ChartIndicatorAdd(0,0,handle_iMA_Custom);
//---
   return(INIT_SUCCEEDED);
  }
First we create an indicator handle (remember, the handle should be created ONE time at OnInit()) through iCustom: Symbol, Period, Path, probably Parameters
 
Vladimir Karputov:

With iCustom, it's very simple. Here is an example right away: in theCustom Moving Average Levels code there is

An example of how to create this indicator (it is located in "terminal data directory"\MQL5\Indicators\MyInd\):

We create an indicator handle first (remember, the handle is created ONE time in OnInit()) through iCustom: Symbol, Period, Path, maybe Parameters - we create a handle for the indicator.

Honestly, I don't understand anything. I need the values of the indicator top line at Close[2], Close[1] and that's it.

How to get these values from ANY indicator without "getting into" the code of the indicator.

Reason: