Custom indicator not based on any of the existing indicators?

 

Hello there.

I've been trying to create an indicator (for learning purposes) that tracks the maximum and the minimum value of the last N samples in the current period.

I want to use the indicator from a class inheriting from CExpertSignal.

I noticed that most articles talk about creating custom indicators, but they are not really "custom", they are based on a existing one.

So, if I want to get the maximum and the minimum from the last N samples, I have been considering:

1) Using CopyHigh, CopyLow from the CExpertSignal and then compute the maximum and the minimum, with no indicator.

2) Find a way to create a "real" custom indicator and compute the max and the min there, and then use the indicator in the CExpertSignal. 

What should I try? 

 
nelsoneci:

Hello there.

I've been trying to create an indicator (for learning purposes) that tracks the maximum and the minimum value of the last N samples in the current period.

I want to use the indicator from a class inheriting from CExpertSignal.

I noticed that most articles talk about creating custom indicators, but they are not really "custom", they are based on a existing one.

So, if I want to get the maximum and the minimum from the last N samples, I have been considering:

1) Using CopyHigh, CopyLow from the CExpertSignal and then compute the maximum and the minimum, with no indicator.

2) Find a way to create a "real" custom indicator and compute the max and the min there, and then use the indicator in the CExpertSignal. 

What should I try? 

I found this code : https://github.com/dennislwm/MLEA/blob/master/MQL5/Include/EA/TurtleSignal.mqh

This is the data I need. Is this the right way to do it? My guess is that it is better to find a way that avoids the multiple copies.

double CTurtleSignal::Highest(int spannedPeriod)
 { 
    double ret = 0;
    
    int copied = CopyHigh(m_symbol.Name(), m_period, 1, spannedPeriod, High);
    for (int i=0; i<spannedPeriod; i++) 
        ret = MathMax(ret, High[i]);

    return ret;
 } 
dennislwm/MLEA
dennislwm/MLEA
  • dennislwm
  • github.com
Permalink Show File Finder Jump to Line
 
nelsoneci:

I found this code : https://github.com/dennislwm/MLEA/blob/master/MQL5/Include/EA/TurtleSignal.mqh

This is the data I need. Is this the right way to do it? My guess is that it is better to find a way that avoids the multiple copies.

 

 } 

You can also use the functions ArrayMaximum and ArrayMinimum to find highest / lowest values inside an array.
Reason: