Useful features from KimIV - page 108

 
Frankly speaking, I'm very glad to see a legendary man with his own features back in the active forum, although I don't understand much about them personally due to my ignorance of the basics of programming in this language. But the fact itself is amazing, I welcome KimIV with all my being!
 
 

Hello, I'm looking for a function, do you have one ready?

I need a file to be created at the end of the test, which would contain data on the drawdown of each order. Preferably, this file would not be created during the test, but at the end of the one-time processing of the trades history...

 
I don't have such a function, but in the near future I plan to publish a function that calculates the maximum drawdown in pips of currently open positions. This function analyses order passing by bars. Timeframe is one of the parameters. The smaller is the timeframe, the more accurate is the calculation of the maximal drawdown. I think you will be able to do what you need based on this function.
 
KimIV:
I do not have such a function but I am planning to publish the function calculating the maximal drawdown of the current open positions in the nearest future. This function analyzes order passing by bars. Timeframe is one of the parameters. The smaller is the timeframe, the more accurate is the calculation of the maximal drawdown. I think you will be able to do what you need based on this function.

If the function also has a record in the file - that would be great...

But I don't see any particular need to calculate the drawdown for current positions. I think this function is more useful for a tester (analysis of system's work) ....

 
renoshnik:

If there's also writing to a file in the function, that would be great...

But I don't see any particular need to calculate the drawdown for current positions. I think this function is more useful for a tester (system analysis) ....

There is no difference between "calculate the drawdown of each order in real time and send all data to a file" and "calculate the drawdown of each order and send the data to a file at the end of the test". Except for the fact that the first option is quite easy to be extremely accurate, and the second option is only accurate if we remember the tick history for each order.
 
renoshnik:

Hello, I'm looking for a function, do you have one ready?

I need a file to be created at the end of the test, which would contain data on the drawdown of each order. Preferably, this file would not be created during the test, but at the end of the one-time processing of the trades history...

Yuri, I hastily pulled out the code from an old Expert Advisor...
Checked it and it seems to be working correctly.
Add code from deinit() to your owls and copy three functions below deinit, one of them is Igor's ))
.......
The code is loose... But as long as Igor makes it beautiful, I think you'll have enough to experiment.
 
lasso:
Yuri, I hastily pulled the code from an old EA...
Checked it, seems to be working correctly.
Add code from deinit() to your owls and copy three functions below deinit, one of them is Igor's ))
.......
The code is loose... But as long as Igor makes it look nice, I think you'll have enough to experiment with.

Great, thanks !!!!!!!!!! I'll look into it....
 

Igor, Good afternoon!

I put your function CrossPointOfLines (calculates the coordinates of intersection point of two lines) into my Expert Advisor. As a result, it keeps writing in comments: It has failed to find the intersection point! And cannot find the intersection point.

Maybe it's because I have other objects on my chart in the form of trendlines? Or maybe you or one of the regulars in this thread can tell me what my problem is?

Thanks in advance!

Code - in the attached file.

Files:
 

HOORAY! I figured it out myself) Other trending ones got in the way...

Since I'm not very good at making friends with arrays, I've made a maximally simplified function. So far it seems to be working).

//+------------------------------------------------------------------+
double Middle(string nm1,string nm2)
  {
  double M;
  double x0, x1, y1, x2, y2, x3, y3, x4, y4;
  double k1, k3;
  
  if(ObjectFind(nm1)==0 && ObjectFind(nm2)==0)
    {
    x1=ObjectGet(nm1, OBJPROP_TIME1);
    x2=ObjectGet(nm1, OBJPROP_TIME2);
    y1=ObjectGet(nm1, OBJPROP_PRICE1);
    y2=ObjectGet(nm1, OBJPROP_PRICE2);
    
    x3=ObjectGet(nm2, OBJPROP_TIME1);
    x4=ObjectGet(nm2, OBJPROP_TIME2);
    y3=ObjectGet(nm2, OBJPROP_PRICE1);
    y4=ObjectGet(nm2, OBJPROP_PRICE2);
    
    k1=(y2-y1)/(x2-x1); 
    k3=(y4-y3)/(x4-x3);
    
    if(k1 != k3)
      {
      x0 = (y1 - y3 + k3*x3 - k1*x1)/(k3 - k1);
      M = y1 + k1*(x0 - x1);
      }
    }
  return(M);
  }
//+----------------------------------------------------------------------------+