Useful features from KimIV - page 56

 
KimIV >> :

here

Thanks, it wasn't there yesterday or I missed it.

 
beginner писал(а) >>

Thanks, it wasn't there yesterday or I missed it.

>> it wasn't.

 

Yes, now this one.

#include "b-KimIV.mqh" // Additional function library

 

Dear KimIV, I would like to ask you to modify e-SOTrailing in the following way : (All tactics in this case is to place stop orders at some distance from the nearest fractal and to move them after the price). I guess it's not that difficult using your FindNearFractal function, maybe?

void TrailingOrders() {

......

pa=FindNearFractal(OrderSymbol(), 0, MODE_UPPER); //MarketInfo(OrderSymbol(), MODE_ASK);

......

pb=FindNearFractal(OrderSymbol(), 0, MODE_LOWER);//MarketInfo(OrderSymbol(), MODE_BID);

 
beginner писал(а) >>

Yes, now this one.

#include "b-KimIV.mqh" // Additional functions library

>> later on.

 
KimIV >> :

It's already impossible on the front page...

I'll post it here... If the post for the update gets blocked, I'll re-post it. So keep an eye on the thread :-)

Thank you - this is the one.

 

The ArrayZ() function.

This function calculates and returns the Z-count of the number series passed in the array by reference.

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 27.10.2008                                                     |
//|  Описание : Возвращает Z-счёт числового ряда.                              |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    arr - массив значений числового ряда                                    |
//+----------------------------------------------------------------------------+
double ArrayZ(double& arr[]) {
  double x, z;
  int    i, l=0, n=ArraySize( arr), r=1, w=0;

  for ( i=0; i< n; i++) {
    if ( i==0) r=1;
    else {
      if ( arr[ i-1]* arr[ i]<0) r++;
    }
    if ( arr[ i]>0) w++; else l++;
  }

  if ( n>2) {
    if ( w>0 && l>0) {
      x=2* w* l;
      if ( x!= n) z=( n*( r-0.5)- x)/MathSqrt( x*( x- n)/( n-1));
    } else {
      if ( l==0) z=100; else z=-100;
      Print("ArrayZ(): Нет чередования серий!");
    }
    return( z);
  } else {
    Print("ArrayZ(): В массиве недостаточно элементов!");
    return(0);
  }
}

ZS. Attached is a script for testing the ArrayZ() function. By the way, this script fills the array with data from Ralph Vince's book "The Mathematics of Capital Management".

ZZZ. I have updated the b-Array library on my website.

Files:
 

The ArrayDeleteInt() function

Executes the deletion of an array element with the given index. Returns the size of the new array or -1 if nothing was removed. The ArrayDeleteInt() function accepts the following mandatory parameters:

  • m - Array of elements.
  • i - Index of the array element.
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 31.10.2008                                                     |
//|  Описание : Выполняет удаление элемента массива с заданным индексом.       |
//|             Возвращает размер нового массива или -1,                       |
//|             если не удалось ничего удалить.                                |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    m - массив элементов                                                    |
//|    i - индекс элемента                                                     |
//+----------------------------------------------------------------------------+
int ArrayDeleteInt(int& m[], int i) {
  int j, k=ArraySize( m);

  if ( i>=0 && i< k) {
    for ( j= i; j< k; j++) m[ j]= m[ j+1];
    k=ArrayResize( m, k-1);
    return( k);
  } else Print("ArrayDeleteInt(): Неверный индекс элемента массива! i=", i);

  return(-1);
}
ZS. Attached is a script to test ArrayDeleteInt() function.
Files:
 

ArrayDeleteDouble() function

Performs the deletion of an array element with a given index. Returns the size of the new array or -1 if nothing was deleted. The ArrayDeleteDouble() function accepts the following mandatory parameters:

  • m - Array of elements of type double.
  • i - Index of the array element.
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 31.10.2008                                                     |
//|  Описание : Выполняет удаление элемента массива с заданным индексом.       |
//|             Возвращает размер нового массива или -1,                       |
//|             если не удалось ничего удалить.                                |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    m - массив элементов                                                    |
//|    i - индекс элемента                                                     |
//+----------------------------------------------------------------------------+
int ArrayDeleteDouble(double& m[], int i) {
  int j, k=ArraySize( m);

  if ( i>=0 && i< k) {
    for ( j= i; j< k; j++) m[ j]= m[ j+1];
    k=ArrayResize( m, k-1);
    return( k);
  } else Print("ArrayDeleteDouble(): Неверный индекс элемента массива! i=", i);

  return(-1);
}
P.S. Attached is a script to test the ArrayDeleteDouble() function.
 

The ArrayDeleteString() function

Executes the deletion of an array element with the given index. Returns the size of the new array or -1 if nothing could be removed. The ArrayDeleteString() function accepts the following mandatory parameters:

  • m - Array of elements of type string.
  • i - Index of the array element.
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 31.10.2008                                                     |
//|  Описание : Выполняет удаление элемента массива с заданным индексом.       |
//|             Возвращает размер нового массива или -1,                       |
//|             если не удалось ничего удалить.                                |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    m - массив элементов                                                    |
//|    i - индекс элемента                                                     |
//+----------------------------------------------------------------------------+
int ArrayDeleteString(string& m[], int i) {
  int j, k=ArraySize( m);

  if ( i>=0 && i< k) {
    for ( j= i; j< k; j++) m[ j]= m[ j+1];
    k=ArrayResize( m, k-1);
    return( k);
  } else Print("ArrayDeleteString(): Неверный индекс элемента массива! i=", i);

  return(-1);
}
ZS. Attached is a script to test the ArrayDeleteString() function.
Reason: