Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distinction between Rule and Indicator #1142

Open
sgflt opened this issue Apr 5, 2024 · 2 comments
Open

Distinction between Rule and Indicator #1142

sgflt opened this issue Apr 5, 2024 · 2 comments
Labels

Comments

@sgflt
Copy link
Contributor

sgflt commented Apr 5, 2024

I am a little bit confused between purposes of Rule and Indicator.

How to decide which interface I should implement.

For example DownTrendIndicator as Indicator or DownTrendRule and isStatisfiedAt(index)?

@TheCookieLab
Copy link
Member

Let the return types guide your thinking. An Indicator is the closest 1:1 mapping with what you'd typically think of for a technical indicator, and it typically produces some numerical result. A Rule uses Indicators to determine whether or not some condition is satisfied. It can be ambiguous at times, but for your example DownTrendRule is more appropriate.

@sgflt
Copy link
Contributor Author

sgflt commented May 10, 2024

So Rules can be reused inside indicators?

For example Hammer candle indicator have to know whether it is in downtrend.

After some hours of flipping between indicator and rule I gave higher weight to Rules javadoc and implemented trend inidcator instead.

* A rule (also called "trading rule") used to build a {@link Strategy trading
* strategy}. A trading rule can consist of a combination of other rules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants