Useful features from KimIV - page 105

 
zennon:
The MovingInWL() function just goes through all open positions regardless of input filters sy,op,mn. This is also true for the attached example EA (page 55).
It goes through what for?! to reset the stoploss and sends everything to the Modiforder function
 

Help for the unintelligent.

Also "Very useful functions from KimIV", though not from this thread - reading INI files.

Fragment (enough to compile but not all for readability) of KimIV inluder

//+------------------------------------------------------------------+
//|                                                     IniFiles.mqh |
//|                                           Ким Игорь В. aka KimIV |
//|                                              http://www.kimiv.ru |
//|   25.04.2006  Библиотека функций для работы с INI-файлами.       |
//+------------------------------------------------------------------+
#property library
#import "kernel32.dll"
  int GetPrivateProfileStringA
      ( string SectionName,    // Наименование секции
        string KeyName,        // Наименование параметра
        string Default,        // Значение по умолчанию
        string ReturnedString, // Возвращаемое значение параметра
        int    nSize,          // Размер буфера под значение параметра
        string FileName);      // Полное имя файла
  int WritePrivateProfileStringA
      ( string SectionName,    // Наименование секции
        string KeyName,        // Наименование параметра
        string sString,        // Записываемое значение параметра
        string FileName);      // Полное имя файла
#import
//+------------------------------------------------------------------+
//| Параметры:                                                       |
//|   FileName    - полное имя файла                                 |
//|   SectionName - наименование секции                              |
//|   KeyName     - наименование параметра                           |
//|   Default     - значение параметра по умолчанию                  |
//+------------------------------------------------------------------+
string ReadIniString(string FileName, string SectionName, string KeyName, 
                     string Default = "")
  {
   string ReturnedString = "";
   int nValue = GetPrivateProfileStringA(SectionName, KeyName, Default, 
                                          ReturnedString, 255, FileName);
   if(nValue > 0)
       return(ReturnedString);
   else 
       return(Default);
  }

The script that calls the function to read an INI file

#include <IniFiles.mqh>
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
  string strPair = "";
  string strTradeType = "";
  string Path = "C:\\TestIni";
  string Section = "TestSection";
  string strAction = ReadIniString(Path, Section, "Action");
  if(strAction == "Open")
  {
   strPair = ReadIniString(Path, Section, "Pair", "");
   Print(
         "Пара =   ", strPair
         );
   strTradeType = ReadIniString(Path, Section, "TradeType", "");
   Print("Акция ",
         "Пара =   ", strPair,
         "Тип =    ", strTradeType
         );
  }
  else
   Print("Действо не найдено");
   
//----
   return(0);
  }

INI file itself

[TestSection]
Action=Open
Pair=EURUSD
TradeType=Buy
Volume=-0.06

What we do not like is a fragment of the log

12:49:14 Test IniFiles AUDUSD,H1: Пара =   EURUSD
12:49:14 Test IniFiles AUDUSD,H1: Акция Пара =   BuyТип =    Buy

The question is why? Functions seem to be described correctly. When I read (after all calls) and then print double (Volume), all variables become equal to-0.06.

Bild 225.

 
KimIV:

The ArrayAvg() function.

This function returns the average arithmetic of the array elements.

    for (i=0; i<k; i++) s+=x[i];
    if (k>0) s/=k;
    • x - An array of elements of type double.
    why not use iMA?
     
    KimIV:

    CorrectTF() function.

    Fits the input parameter to the nearest valid timeframe and returns its value.
      if (TimeFrame>=PERIOD_M5  && TimeFrame<PERIOD_M15) return(PERIOD_M5);
      if (TimeFrame>=PERIOD_M15 && TimeFrame<PERIOD_M30) return(PERIOD_M15);

    Isn't 14 closer to 15 than 5?

    For example, I entered 50 for clock instead of 60. Well... I kind of missed.

    and the function will return 30. cool:)

     
    eddy:

    isn't 14 closer to 15 than 5? and the function will return 30. cool:)

    It works by a clear rule: anything between TFs is replaced by the value of the smaller TF.
    If you don't like it, post your rule and your code.
     
    I understand the rule in the code, but the code description has a different rule
     
    KimIV:

    GetExtremumZZZPrice() function.

    This function searches for an extremum of the standard custom ZigZag indicator and returns its price level. The function accepts the following optional parameters:

    • sy - Name of the instrument. "" or NULL - current symbol. Default value is NULL.
    • tf - Timeframe. Default value 0 - current symbol.
    • ne - Extreme number. 0 - last, 1 - previous, 2 - previous, etc.
    • dp, dv, bs - ZigZaga parameters: ExtDepth, ExtDeviation, ExtBackstep.


    I wanted to use this function but ran across the following situation: when a new extremum appears, the price level does not change immediately but stays the same for some time. It disturbs me during testing. How to fix it?

     
    Please tell me where is the list of all the functions, I think there is a function for calculating consecutive losing-closedpositions - you need it for martingale.
     
    eddy:
    I understand the rule in the code, but the code description has a different rule
    Thank you! I corrected the description... (in my place...) Who cares, correct it too)))