peak(vars Data) : bool

valley(vars Data) : bool

Determines if a series had a maximum (peak) or minimum (valley) at the previous bar.

Parameters:

Data Data series.

Returns:

true if the series had a peak or valley at the previous bar, false otherwise.

Modifies

rMomentum - Data movement in percent per time frame; indicates the 'sharpness' of the peak or valley.

Algorithm:

bool peak(var* Data) { return (Data[2] < Data[1]) && (Data[1] > Data[0]); }
bool valley(var* Data) { return (Data[2] > Data[1]) && (Data[1] < Data[0]); } 			 

Remarks:

Example:

function run()
{
  vars Trend = series(LowPass(series(price()),1000),3);
  if(valley(Trend))
    enterLong();
  if(peak(Trend))
    enterShort();
}

See also:

crossOver, crossUnder, rising, falling, peakF, valleyF, predict

► latest version online