Comments (7)
Related question #1142
from ta4j.
If I consider following implementation:
public class DownTrendIndicator extends AbstractIndicator<Boolean> {
private static final int UNSTABLE_BARS = 5;
private final ADXIndicator directionStrengthIndicator;
private final Rule downtrendRule;
public DownTrendIndicator(final BarSeries series) {
super(series);
this.directionStrengthIndicator = new ADXIndicator(series, UNSTABLE_BARS);
final var plusDMIndicator = new PlusDMIndicator(series);
final var minusDMIndicator = new MinusDMIndicator(series);
this.downtrendRule = new UnderIndicatorRule(plusDMIndicator, minusDMIndicator);
}
@Override
public Boolean getValue(final int index) {
return this.directionStrengthIndicator.getValue(index).isGreaterThan(numOf(25))
&& this.downtrendRule.isSatisfied(index);
}
@Override
public int getUnstableBars() {
return UNSTABLE_BARS;
}
}
Still, BaseStrategy have to be manually filled with unstableBars, which as user, I do not know where to get.
Related to #919
from ta4j.
If propagation through rules to strategy is not viable, then I am thinking about user friendly builder, which does the dirty work.
StrategyBuilder.create()
.withIndicators(List<Indicator>) // Takes max unstable bars
.withEntryRule(Rule)
.withExitRule(Rule)
.build() // calls new BaseStrategy(entry, exit, unstableBars)
;
from ta4j.
Regarding your builder example, the Strategy should only need to know about its two Rules and not the Indicators they use.
An Indicator knows it's own unstable period. If we are returning NaN for any calculation within the unstable period then Rules don't need to know about the unstable period either as it can simply key off of NaN values. Typically Rules are comparing the results of one or more Indicators and if any of them are NaN it should know what to do.
from ta4j.
Related Issues (20)
- [BUG] Supertrend Indicator value goes to 0 and stays 0 forever HOT 2
- Zig Zag indicator implementation question HOT 3
- Create releases more often HOT 23
- Trade style specific question [Support and resistence] HOT 8
- Can ta4j backtest trading multiple stocks simultaneously HOT 2
- [BUG] ProfitLossCriterion: Javadoc says "excludes trading costs" but code uses trading cost HOT 5
- Backtest with fixed entry amount like a new BarSeriesManager or Strategy
- [BUG] VersusEnterAndHoldCriterion should use 'amount' to match comparsion
- [BUG]
- Suggestion for improving the organization of the proyect folders and classes HOT 4
- [BUG] HOT 1
- Suggestion to secure the correct functionality of the library HOT 3
- SMAIndicator inner cache
- Distinction between Rule and Indicator HOT 2
- Move minimal supported base JDK at least to JDK 21 HOT 1
- Indicator and BarSerie should not be responsible for managing constants nor series HOT 2
- Implement reversal candles indicator
- [BUG] Contractf of Num.compareTo is broken
- how to test a strategy with averaging? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ta4j.