Trading System API  3.0
Library for Simulating and Deploying Trading and Investment Strategies
tsa::functor::stochastic Class Reference

Functor for calculating Stochastic indicator over a given period. More...

#include <TSAFunctors.h>

Inherits tsa::functor::parent< T >.

Public Member Functions

const parent & operator() (const series< double > &hi, const series< double > &lo, const series< double > &cl, size_t period, size_t k_smooth_period=3, size_t d_smooth_period=3)
 

Detailed Description

Functor for calculating Stochastic indicator over a given period.

Member Function Documentation

const parent< double > & tsa::functor::stochastic::operator() ( const series< double > &  hi,
const series< double > &  lo,
const series< double > &  cl,
size_t  period,
size_t  k_smooth_period = 3,
size_t  d_smooth_period = 3 
)

Returns the components of the Stochastic Indicator as a tuple.

functor::stochastic f_stoch; // member of strategy object
instrument i; // member of strategy object
{
auto stoch = f_stoch(i.high, i.low, i.close, 50, 3, 3);
double stoch_fast = stoch.fast;
double stoch_slow = stoch.slow;
double stoch_raw = stoch.raw;
}
Returns
Returns a tuple with the following values:
  • tuple.k (the 'raw' stochastic)
  • tuple.fast (the smoothed 'raw' stochastic)
  • tuple.slow (the smoothed 'fast' stochastic)
Parameters
hiseries of highs
loSeries of lows
clSeries of closes
periodIndicator period
k_smooth_periodfast smooting