Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ See [github commits](https://github.com/TA-Lib/ta-lib/commits) for complete list
- CUMSUM: Cumulative Sum (#372)
- DONCHIAN: Donchian Channels, the rolling extrema bands (#342)
- DPO: Detrended Price Oscillator, price displaced back a half cycle less its moving average (#363)
- ER: Kaufman Efficiency Ratio (#350)
- EFI: Elder's Force Index (#206)
- FOSC: Forecast Oscillator, the close against the previous bar's time series forecast (#345)
- HMA: Hull Moving Average (#139)
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ set(LIB_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/src/ta_func/ta_DX.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/ta_func/ta_EFI.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/ta_func/ta_EMA.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/ta_func/ta_ER.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/ta_func/ta_EXP.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/ta_func/ta_FLOOR.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/ta_func/ta_FOSC.c"
Expand Down
78 changes: 78 additions & 0 deletions include/ta_func.h
Original file line number Diff line number Diff line change
Expand Up @@ -7853,6 +7853,84 @@ TA_LIB_API TA_RetCode TA_EMA_Value( const TA_EMA_Stream *stream, double *outReal
*/
TA_LIB_API TA_RetCode TA_EMA_Clone( const TA_EMA_Stream *stream, TA_EMA_Stream **clone );

/*
* TA_ER - Kaufman Efficiency Ratio
*
* Input = double
* Output = double
*
* Optional Parameters
* -------------------
* optInTimePeriod:(From 2 to 100000)
* Number of one-bar changes in the path sum
*
*
*/
TA_LIB_API TA_RetCode TA_ER( int startIdx,
int endIdx,
const double inReal[],
int optInTimePeriod, /* From 2 to 100000 */
int *outBegIdx,
int *outNBElement,
double outReal[] );

TA_LIB_API TA_RetCode TA_S_ER( int startIdx,
int endIdx,
const float inReal[],
int optInTimePeriod, /* From 2 to 100000 */
int *outBegIdx,
int *outNBElement,
double outReal[] );

TA_LIB_API int TA_ER_Lookback( int optInTimePeriod ); /* From 2 to 100000 */



/*
* Streaming API for TA_ER — incremental per-bar evaluation.
* See docs/streaming-api-design.md.
*/
typedef struct TA_ER_Stream TA_ER_Stream;

TA_LIB_API TA_RetCode TA_ER_Open( TA_ER_Stream **stream, const double inReal[], int historyLen, int optInTimePeriod, double *outReal );

TA_LIB_API TA_RetCode TA_ER_Update( TA_ER_Stream *stream, double inReal, double *outReal );

TA_LIB_API TA_RetCode TA_ER_Peek( const TA_ER_Stream *stream, double inReal, double *outReal );

TA_LIB_API TA_RetCode TA_ER_Close( TA_ER_Stream *stream );

/*
* OpenAndFill: like Open, but a single pass ALSO fills the caller's arrays
* with the whole warm-up history — bit-identical to TA_ER( 0, historyLen-1,
* ... ).
*/
TA_LIB_API TA_RetCode TA_ER_OpenAndFill( TA_ER_Stream **stream, const double inReal[], int historyLen, int optInTimePeriod, int *outBegIdx, int *outNBElement, double outReal[] );

/*
* UpdateAndFill: commit barCount closed bars and write the barCount values,
* in one call — barCount back-to-back TA_ER_Update calls, including the
* per-bar rejection. A rejected bar k leaves the bars before it committed and
* written, itself uncommitted and its output slot untouched; TA_StreamOutRange
* then reports k+1, the rejected bar being the last one counted. Outputs must
* not alias the inputs or each other.
*/
TA_LIB_API TA_RetCode TA_ER_UpdateAndFill( TA_ER_Stream *stream, const double inReal[], int barCount, double outReal[] );

/*
* Value: the value(s) at the last bar the stream counted — the bar
* TA_StreamOutRange ends on — without recomputing. Seeded by Open, refreshed by
* every accepted Update and UpdateAndFill, left alone by Peek.
*/
TA_LIB_API TA_RetCode TA_ER_Value( const TA_ER_Stream *stream, double *outReal );

/*
* Clone: fork the stream — an independent stream at the same bar, owning its
* own copy of everything the original owns. Both must be closed. The fork
* carries the value and the range verbatim.
*/
TA_LIB_API TA_RetCode TA_ER_Clone( const TA_ER_Stream *stream, TA_ER_Stream **clone );

/*
* TA_EXP - Vector Arithmetic Exp
*
Expand Down
20 changes: 20 additions & 0 deletions src/ta_abstract/frames/ta_frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -2302,6 +2302,26 @@ unsigned int TA_EMA_FramePPLB( const TA_ParamHolderPriv *params )
{
return TA_EMA_Lookback(params->optIn[0].data.optInInteger /* optInTimePeriod*/ );
}
TA_RetCode TA_ER_FramePP( const TA_ParamHolderPriv *params,
int startIdx,
int endIdx,
int *outBegIdx,
int *outNBElement )
{
return TA_ER(
startIdx,
endIdx,
params->in[0].data.inReal, /* inReal */
params->optIn[0].data.optInInteger, /* optInTimePeriod*/
outBegIdx,
outNBElement,
params->out[0].data.outReal /* outReal */
);
}
unsigned int TA_ER_FramePPLB( const TA_ParamHolderPriv *params )
{
return TA_ER_Lookback(params->optIn[0].data.optInInteger /* optInTimePeriod*/ );
}
TA_RetCode TA_EXP_FramePP( const TA_ParamHolderPriv *params,
int startIdx,
int endIdx,
Expand Down
9 changes: 9 additions & 0 deletions src/ta_abstract/frames/ta_frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,15 @@ TA_RetCode TA_EMA_FramePP( const TA_ParamHolderPriv *params,
unsigned int TA_EMA_FramePPLB( const TA_ParamHolderPriv *params )
;

TA_RetCode TA_ER_FramePP( const TA_ParamHolderPriv *params,
int startIdx,
int endIdx,
int *outBegIdx,
int *outNBElement )
;
unsigned int TA_ER_FramePPLB( const TA_ParamHolderPriv *params )
;

TA_RetCode TA_EXP_FramePP( const TA_ParamHolderPriv *params,
int startIdx,
int endIdx,
Expand Down
Loading