finantic.Eval
finantic.Eval is a small but powerful extension that contains the Eval Indicator. This Indicator accepts an indicator expression of unlimited complexity and calculates the values for such a complex expression.
Indicator of Indicator
Imagine you need an indicator of an indicator like a doubly smoothed version of TR (True Range). You could code:
TR tr = new TR(bars);
EMA ema1 = new EMA(tr, 5);
indi1 = new EMA(ema1, 5);
or with the Eval indicator:
indi2 = new Eval(bars, "EMA(EMA(TR(bars), 5), 5)");
Transformations
Indicator Profiler and Indicator Selection both use transformations to make indicator values comparable among symbols and times.
These transformations can easily be calculated with the Eval indictor. In the lists below some example expressions are listed.
Indicator Profiler
IndicatorProfiler uses four transformations to make indicators comparable. Each transformation involves the use of an additional indicator.
- Below Signal Line
Example expression: RSL(APTR(Bars,14),"EMA",5) - Above Signal Line
Example expression: RSL(APTR(Bars,14),"SMA",7) - Conseq Down
Example expression: ConsecUp(AEMA(Bars,15,15),10), 5, 10) - Conseq up
Example expression: ConsecUp(AEMA(Bars,15,15),10), 5, 10)
Indicator Selection
IndicatorSelection uses the following transformations.
- BandP - BandPosition: Prices relative to bands in percent
Example expression: BandP(Close, ATRBandLower(Bars,Close,10,1.00), ATRBandUpper(Bars,Close,10,1.00)) - BWC - BandWidthChange: Rate of change of bandwidth
Example expression: BWC(ATRBandLower(Bars,Close,10,1.00), ATRBandUpper(Bars,Close,10,1.00)) - CAtr - Relative to close ATR: Indicator relative to Close Prices in ATR
Example expression: CAtr(Bars,AEMA(Bars,15,15),10) - CPct - Releative to close percent: Indicator relative to close price in percent
Example expression: CPct(Close,AEMA(Bars,15,15)) - CUD - Consecutive Up or Down Bars: Number of consecutive times input was up or down form N bars ago
Example expression: CUD(APTR(Bars,14)) - PP - Price Proportional Indicator: Normalize a price proportional indicator by dividing it by a snoothed version of prices
Example expression: PP(CyberCycle(Close,0.0175),Close,"EMA",100) - ROC - Rate of Change
Example expression: ROC(AEMA(Bars,15,15),1) - RSL - Relative Signal Line
Example expression: RSL(APTR(Bars,14),"EMA",5) - PP+RSL
Example expression: PP(RSL(ExpDev(Close,10,false),"EMA",5),Close,"EMA",100)
Background
finantic.Eval uses a tokenizer and a rules-based parser to parse indicator expressions with possibly nested indicators like "ROC(ATR(bars, 3), 7)" into a list of function calls that are executed when the Eval indicator is populated. Possible elements in such an indicator expression are (in order of precedence):
- Numbers
- strings
- Time Series: Open, High, Low, Close, Volume, etc.
- Indictors
- Parentheses
- Unary plus or minus
- Multiplication or Division
- Addition or Subtraction
Here is the complete Parsing Expression Grammar (PEG):
IndiExpression => Sum as Indicator
Sum => Product ( ('+' | '-') Product)*
Product => SignedFactor (('*' | '/') SignedFactor)*
SignedFactor => Factor | Sign Factor
Sign => '+' | '-'
Factor => Item | '(' Sum ')'
Item => Indicator | [Identifier] | [Integer] | [Double]
Indicator => [Identifier] '(' ArgumentList? ')'
ArgumentList => Argument (',' Argument)*
Argument => Sum | [String]
Screenshots
Change Log
- Can now handle expressions like Close-SMA() with no spaces around the minus.
- Fixed a problem with complex expressions like "Close-MP(TR(Bars),100, 75)*0.7".
- Performance improvements, no noticeable difference between Eval() and raw indicators.
- New Indicator EvalOpt: optimizable Eval indicator.
- Complete expressions with addition, subtraction, multiplication and division.
- Internal functions: Max, Min, Abs, Sqrt, Pow, Exp and Log.
- Initial release.