Useful features from KimIV - page 65

 
nord >> :

Igor Thanks for the features !!!

Is there by any chance no function to determine the loss of an open position..... or did I miss it

There is one:

double OrderProfit(  	)
Возвращает значение чистой прибыли ( без учёта свопов и комиссий) для выбранного ордера. 
Для открытых позиций это - текущая нереализованная прибыль. Для закрытых ордеров - зафиксированная прибыль.
Ордер должен быть предварительно выбран с помощью функции OrderSelect(). 

If you need profit/loss in pips, depending on which position (buy/sell) subtract:

OrderOpenPrice(...) - (Bid or Ask).

 

list of functions in the html file...

will open in a new window...

;) denjoy...

Files:
func2_1.zip  4 kb
 
Igor, if you don't mind, I have dug through everything, but I have not found, is there a function in the storeroom that would return the slope angle of the regression line, or the start and end price at a certain number of bars? I would be very grateful to you....
 
xrust писал(а) >>
Igor, if you don't mind, I have dug through everything, but I have not found it. Maybe there is a function in the storerooms that would return the slope angle of the regression line, or the start and end price at a certain number of bars ? I would be very grateful to you....

In the LR equation y(x)=a*x + b

the coefficients can be calculated using these formulas.

factor a

coefficient b

'Regression: what is it?'

 

Igor, thank you so much.

all found on your website

http://www.kimiv.ru/index.php?option=com_remository&Itemid=13&id=35&func=fileinfo
 

Igor, maybe you have some nice code that calculates the lot for a pending order or position at a specific price, taking into account open positions.


I need to put a pending order for X pips away from the current price but I have to figure out how to correctly calculate the lot, i.e. to make this pending order open 100%. Also I need to take into account swaps, commission, profit and loss of orders.


It would be great if you have time to write such a function.

 

Igor, can you give us a function to close overlapped orders here ? Maybe someone else would need it. If you are interested and have time for it, of course.

If it's not too much trouble, any tips on how to implement this function in your EA. I tried replacing your function "close profitable ones first" with closing by decreasing lot size. But it keeps getting errors when compiling.

Sincerely, Azer.

 
KimIV писал(а) >>

StringToArrayInt() function.

ZS. Attached is a script for testing the StringToArrayInt() function.

Experience shows that you may also need a function like StringToArrayStr() - if in your notation... :-)

 
Shu писал(а) >>

experience shows that sometimes you also need a function like StringToArrayStr() - if in your notation... :-)

In many programming languages this function is called StrSplit(). I didn't make it up... :-)

The StrSplit() function.

This function splits a string into its substringings so that each substring becomes a separate array element. The separator is defined by a parameter and may be arbitrary. The StrSplit() function returns the number of array elements and accepts the following parameters:

  • st - String with separators.
  • as - The array of elements of the string type.
  • de - Separator. Optional parameter. Default value is "," (comma).
//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 23.06.2008                                                     |
//|  Описание : Разбиение строки на массив элементов                           |
//+----------------------------------------------------------------------------+
//|  Возврат:                                                                  |
//|    Количество элементов в массиве                                          |
//|  Параметры:                                                                |
//|    st - строка с разделителями                                             |
//|    as - строковый массив                                                   |
//|    de - разделитель                                                        |
//+----------------------------------------------------------------------------+
int StrSplit(string st, string& as[], string de=",") { 
  int    i=0, np;
  string stp;

  ArrayResize( as, 0);
  while (StringLen( st)>0) {
    np=StringFind( st, ",");
    if ( np<0) {
      stp= st;
      st="";
    } else {
      stp=StringSubstr( st, 0, np);
      st=StringSubstr( st, np+1);
    }
    i++;
    ArrayResize( as, i);
    as[ i-1]= stp;
  }
  return(ArraySize( as));
}

SZU. Attached is a script to test StrSplit() function.

Files:
 
Prival писал(а) >>

In the LR equation y(x)=a*x + b

the coefficients can be calculated using these formulas.

factor a

coefficient b

'Regression: what is it?'

1. Regression analysis is the study of a process, an object based on a series of observation points about it.

2. Regression equation (regression) :

2.1 The researcher chooses the type of equation which in his opinion is appropriate to the physical nature of the object under study or which is easier to work with. A polynomial is most commonly used.

2.2 For initial studies, a first-degree polynomial, i.e., a straight line, is often used. This is called a linear regression.

2.3 Then, as you wrote, the parameters of this straight line are calculated. If there are more than 2 observation points, the most common method is the "method of least squares". The straight line is drawn so that the sum of the squares of the deviations of the points from the straight line is the smallest.

3. Here the regression refers to a linear regression equation and its graph.