package jforex.simpletests;

import com.dukascopy.api.*;
import com.dukascopy.api.util.DateUtils;

@SuppressWarnings({"FieldCanBeLocal"})
public class TestEmptySMA implements IStrategy {
    @Configurable(value="SMAPeriods", stepSize=1)
    public int SMAPeriods = 30;

    @Override
    public void onStart(final IContext context) throws JFException {
        double[] SMAs = new double[0];
        try {
            SMAs = context.getIndicators().ma(
                    Instrument.EURUSD,
                    Period.DAILY,
                    OfferSide.BID,
                    IIndicators.AppliedPrice.CLOSE,
                    SMAPeriods,
                    IIndicators.MaType.SMA,
                    Filter.WEEKENDS,
                    0,
                    DateUtils.parse("2020-01-08 00:00:00:000"),
                    1);
        } catch (Exception e) {
            e.printStackTrace(context.getConsole().getErr());
        }
        context.getConsole().getOut().println(SMAs.length);
        context.getConsole().getOut().println(String.format("%.5f;", SMAs[0]));

        context.stop();
    }

    @Override
    public void onAccount(IAccount account) throws JFException {}

    @Override
    public void onMessage(final IMessage message) throws JFException {}

    @Override
    public void onStop() throws JFException {}

    @Override
    public void onTick(Instrument instrument, ITick tick) throws JFException {}

    @Override
    public void onBar(final Instrument instrument, final Period period, final IBar askBar, final IBar bidBar) {}
}
