my test Strategy:
.......................................
.......................................
public class GetBarsExample implements IStrategy {
@Configurable("Instrument")
public Instrument Curinstrument = Instrument.EURUSD;
private IContext context;
private IConsole console;
private IHistory history;
private IBar prevDailyBar;
private IIndicators myIdicator;
private SimpleDateFormat gmtSdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public void onStart(IContext context) throws JFException {
this.context = context;
console = context.getConsole();
history = context.getHistory();
myIdicator = context.getIndicators();
Set<Instrument> instruments = new HashSet<Instrument>();
instruments.add(Curinstrument);
context.setSubscribedInstruments(instruments, true);
double Cur_FiveSMA;
Cur_FiveSMA = myIdicator.sma(Curinstrument, Period.DAILY, OfferSide.ASK, AppliedPrice.CLOSE, 5, 0);
double MA = myIdicator.ma(Curinstrument, Period.DAILY, OfferSide.ASK, IIndicators.AppliedPrice.CLOSE, 5,IIndicators.MaType.SMA, 0);
print(String.format("cur fivesma =%.5f ---MA=%.5f\n ", Cur_FiveSMA,MA));
print out is:
02:26:23 cur fivesma =1.19418 ---MA=1.19418but i use IndChartVsApi's strategy from knowledge base's copy!
02:04:00 [0] 1.20939; [1] 1.20519; [2] 1.20289; [3] 1.19951; [4] 1.19640; [5] 1.19384; [6] 1.19183; [7] 1.19037; [8] 1.18999; [9]
1.19009; API
