Hi, i'am newbee in Jforex.
I'am progressing step by step.
And i've simple problem. I'm just trying too use indicators and reading results. But I don't understand why my code is wrong. My code works, but values in returns are bullshits.... for me, my code seems to be correct, but results don't correspond to the reality.... i don't get the good values expected when control them in the chart with the same indicators that i called in my code.
I find this totally absurd....
Thanks for your help !!!
Here's my simple code.
package jforex;
import java.util.*;
import com.dukascopy.api.*;
import com.dukascopy.api.IEngine.OrderCommand;
public class StrategyTEST4 implements IStrategy {
private IEngine engine;
private IConsole console;
private IHistory history;
private IContext context;
private IIndicators indicators;
private IUserInterface userInterface;
@Configurable("Instrument")
public Instrument instrument = Instrument.EURUSD;
@Configurable("Period M15")
public Period selectedPeriod = Period.FIFTEEN_MINS;
@Configurable("Period H1")
public Period selectedPeriodh = Period.ONE_HOUR;
@Configurable("Period M5")
public Period selectedPeriodc = Period.FIVE_MINS;
@Configurable("Period M1")
public Period selectedPeriodo = Period.ONE_MIN;
@Configurable("SMA filter")
public Filter indicatorFilter = Filter.NO_FILTER;
@Configurable("Amount")
public double amount = 0.1;
@Configurable("Stop loss")
public int stopLossPips = 20;
@Configurable("w")
public double w = 0;
@Configurable("Take profit")
public int takeProfitPips = 100;
public static void main(String[] args)
{System.out.println("Hello world");
}
public void onStart(IContext context) throws JFException {
this.engine = context.getEngine();
this.console = context.getConsole();
this.history = context.getHistory();
this.context = context;
this.indicators = context.getIndicators();
this.userInterface = context.getUserInterface();
}
public void onAccount(IAccount account) throws JFException {
}
public void onMessage(IMessage message) throws JFException {
}
public void onStop() throws JFException {
}
public void onTick(Instrument instrument, ITick tick) throws JFException {
}
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
int cciperiod = 14;
int shift = 0;
int rsiperiod = 50;
int fastPeriod = 12;
int slowPeriod = 26;
int signalPeriod = 9;
double ccim = indicators.cci(instrument, selectedPeriod, OfferSide.BID, cciperiod, shift);
double ccio = indicators.cci(instrument, selectedPeriodo, OfferSide.ASK, cciperiod, shift);
double ccih = indicators.cci(instrument, selectedPeriodh, OfferSide.BID, cciperiod, shift);
double[] macd = indicators.macd(instrument, selectedPeriodc, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, fastPeriod, slowPeriod, signalPeriod, shift);
double macdd = macd[0];
double rsih = indicators.rsi(instrument, selectedPeriodh, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, rsiperiod, shift);
double rsic = indicators.rsi(instrument, selectedPeriodc, OfferSide.BID, IIndicators.AppliedPrice.CLOSE, rsiperiod, shift);
console.getOut().println("CCI M1 equals "+ccio);
console.getOut().println("MACD M5 equals "+macdd);
console.getOut().println("CCI M5 equals "+ccim);
console.getOut().println("RSI M5 equals "+rsic);
console.getOut().println("CCI HOUR equals "+ccih);
console.getOut().println("RSI H1 equals "+rsih);
}
}