yurivin/xchange-trade-bot

Standart strategies and indicators

Claus1 opened this issue · 5 comments

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

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.

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);
    }
}

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

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

Unfortunately no