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

Standart strategies and indicators #3

Open
Claus1 opened this issue Nov 3, 2018 · 5 comments
Open

Standart strategies and indicators #3

Claus1 opened this issue Nov 3, 2018 · 5 comments

Comments

@Claus1
Copy link

Claus1 commented Nov 3, 2018

Here http://www.ta4j.org you can find ready-to-use strategies and indicators that can be useful for your project.

@yurivin
Copy link
Owner

yurivin commented Nov 10, 2018

Yes, I know. Already trying to use it for strategies development. If there are some strategyes realized on top of ta4j, please give me a link, I will reuse it for this bot teplate and add in to repository.

@Claus1
Copy link
Author

Claus1 commented Nov 13, 2018

@trgpwild
Copy link

trgpwild commented Sep 3, 2019

Here is an example:

import org.ta4j.core.BaseStrategy;
import org.ta4j.core.Rule;
import org.ta4j.core.Strategy;
import org.ta4j.core.TimeSeries;
import org.ta4j.core.indicators.EMAIndicator;
import org.ta4j.core.indicators.MACDIndicator;
import org.ta4j.core.indicators.SMAIndicator;
import org.ta4j.core.indicators.helpers.ClosePriceIndicator;
import org.ta4j.core.trading.rules.CrossedDownIndicatorRule;
import org.ta4j.core.trading.rules.CrossedUpIndicatorRule;
import org.ta4j.core.trading.rules.OverIndicatorRule;

public class MacdStrategy {

    public static Strategy buildStrategy(TimeSeries series) {
        if (series == null) {
            throw new IllegalArgumentException("Series cannot be null");
        }

        ClosePriceIndicator closePrice = new ClosePriceIndicator(series);

        MACDIndicator macd = new MACDIndicator(closePrice, 12, 26);
        EMAIndicator emaMacd = new EMAIndicator(macd, 9);
        SMAIndicator shortTermSMA = new SMAIndicator(closePrice, 50);
        SMAIndicator longTermSMA = new SMAIndicator(closePrice, 100);

        Rule entryRule = new CrossedUpIndicatorRule(macd, emaMacd)
                .and(new OverIndicatorRule(shortTermSMA, longTermSMA));

        Rule exitRule = new CrossedDownIndicatorRule(macd, emaMacd);

        return new BaseStrategy(entryRule, exitRule);
    }
}

@RomanHiden
Copy link

@trgpwild this is ta4j strategy. do you have an example how to integrate those with this trading bot?

@trgpwild
Copy link

@trgpwild this is ta4j strategy. do you have an example how to integrate those with this trading bot?

Unfortunately no

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

No branches or pull requests

4 participants