Useful features from KimIV - page 43

 
Tsyrus писал (а) >>

THIS IS ALL!!!!!

>> THANK YOU !

 

Igor, there is a good indicator that can combine several candles into one. But it only works on the hourly chart. Is it possible to make it universal?

I would like to thank you.

 

GetNearestDownFractal() function.

This function searches for the nearest bottom fractal and returns its price level. The peculiarity of this function is the possibility to set an arbitrary formula for the fractal. The standard, generally accepted fractal formula is 2-2. It means 2 bars on the left and 2 bars on the right. With this function, you can perform even very exotic fractals, such as 8-2 (8 bars on the left and 2 bars on the right) or 5-3 (5 bars on the left and 3 bars on the right) and so on. The function accepts the following optional parameters:

  • sy - Name of instrument. "" or NULL - current symbol. Default value is NULL.
  • tf - Timeframe. Default value 0 - current symbol.
  • nl - Number of bars on the left. Default value is 2.
  • nr - Number of bars on the right. The default setting is 2.
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 07.10.2006                                                     |
//|  Описание : Возвращает ценовой уровень ближайшего нижнего фрактала         |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   ("" или NULL - текущий символ)          |
//|    tf - таймфрейм                  (    0       - текущий таймфрейм)       |
//|    nl - количество баров слева                                             |
//|    nr - количество баров справа                                            |
//+----------------------------------------------------------------------------+
double GetNearestDownFractal(string sy="0", int tf=0, int nl=2, int nr=2) {
  bool f;
  int  fb, i, nb=-1;

  if (sy=="" || sy=="0") sy=Symbol();
  if (nl<1) nl=1;
  if (nr<1) nr=1;

  fb=nr;
  while (nb<0) {
    fb++;
    f=True;
    for (i=fb; i>fb-nr; i--) {
      if (iLow(sy, tf, i)>iLow(sy, tf, i-1)) { f=False; break; }
    }
    if (f) {
      for (i=fb; i<fb+nl; i++) {
        if (iLow(sy, tf, i)>iLow(sy, tf, i+1)) { f=False; break; }
      }
      if (f) { nb=fb; break; }
    }
  }

  return(iLow(sy, tf, nb));
}
 

Examples of how to use GetNearestDownFractal().

  • The price level of the nearest bottom fractal on the current chart. The fractal formula is 2-2 (standard).
    Message(GetNearestDownFractal());
  • The price level of the nearest lower fractal on the USDCAD H1 chart. The fractal formula is 4-2.
    Message(GetNearestDownFractal("USDCAD", PERIOD_H1, 4));
  • Draw a horizontal line through the price level of the nearest lower fractal 5-3 on the current chart.
    double p=GetNearestDownFractal(NULL, 0, 5, 3);
    SetHLine(Red, "", p);

PS. Attached is a script to test the function GetNearestDownFractal().

 
KimIV писал (а) >>

Examples of how to use GetNearestDownFractal().

  • The price level of the nearest lower fractal on the current chart. The fractal formula is 2-2 (standard).
  • Price level of the nearest lower fractal on USDCAD H1 chart. The formula of the fractal is 4-2.
  • Draw a horizontal line through the price level of the nearest lower fractal 5-3 on the current chart.

PS. Attached is a script to test the GetNearestDownFractal() function.

If only it were possible to search not only for the last fractal...................UH!!!

 
Tsyrus писал (а) >>

If only it were possible to search for more than just the last fractal...................UH!!!

Yeah. For example, mark (with a vertical line) all fractals (during last 9 bars) which have value >= 1 in relation to the coordinate of just formed fractal and display this value above the fractal. By way of help (I dare not even ask)....

 

I admire your general ability to write such things. I'm an underpatched lamer myself. Just starting to learn MQL.

Sorry for digressing from the subject!

I do not understand how to write:

1. Compare the Stochastic line for 1 and 2 bars and its signal function when a new 0 bar appears.

(roughly speaking, to evaluate the direction of line movement up and down and crossing them)

2. How to do it every hour/half an hour/15 minutes.

Please show me a simple example!?

Or give a link to something similar.

Thanks in advance, even if you ignore it!!!

 
Domynus писал (а) >>

1. Comparison of the Stochastic line for 1 and 2 bars and its same signal function when a new 0 bar is formed.

(roughly speaking, to assess the direction of line movement up and down and crossing them)

2. How to do it every hour/half an hour/15 minutes.

Please show me a simple example!?

Or give a link to something similar.

https://book.mql4.com/ru/samples/indicators
https://book.mql4.com/ru/build/conditions

 

Thanks for the Stochastic.

I just thought there was something else I could do.

And how to make a trade only once in a given time interval?

(e.g. signal investigation happens once every 15,30 or 60 minutes)

Interested in the function itself.

 

GetNearestUpFractal() function.

This function searches for the nearest upward fractal and returns its price level. The peculiarity of this function is the possibility to set an arbitrary formula for the fractal. The standard, generally accepted fractal formula is 2-2. It means 2 bars on the left and 2 bars on the right. With this function, you can perform even very exotic fractals, such as 8-2 (8 bars on the left and 2 bars on the right) or 5-3 (5 bars on the left and 3 bars on the right) and so on. The function accepts the following optional parameters:

  • sy - Name of instrument. "" or NULL - current symbol. Default value is NULL.
  • tf - Timeframe. Default value 0 - current symbol.
  • nl - Number of bars on the left. Default value is 2.
  • nr - Number of bars on the right. Default value - 2.
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 07.10.2006                                                     |
//|  Описание : Возвращает ближайший верхний фрактал                           |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   (NULL - текущий символ)                 |
//|    tf - таймфрейм                  ( 0 - текущий таймфрейм)                |
//|    nl - количество баров слева                                             |
//|    nr - количество баров справа                                            |
//+----------------------------------------------------------------------------+
double GetNearestUpFractal(string sy="0", int tf=0, int nl=2, int nr=2) {
  bool f;
  int  fb, i, nb=-1;

  if (sy=="" || sy=="0") sy=Symbol();
  if (nl<1) nl=1;
  if (nr<1) nr=1;

  fb=nr;
  while (nb<0) {
    fb++;
    f=True;
    for (i=fb; i>fb-nr; i--) {
      if (iHigh(sy, tf, i)<iHigh(sy, tf, i-1)) { f=False; break; }
    }
    if (f) {
      for (i=fb; i<fb+nl; i++) {
        if (iHigh(sy, tf, i)<iHigh(sy, tf, i+1)) { f=False; break; }
      }
      if (f) { nb=fb; break; }
    }
  }

  return(iHigh(sy, tf, nb));
}