Bletherfeng wrote:
Please help:
1.indicatorResult = indicators.calculateIndicator(selectedInstrument, Period.TEN_MINS, new OfferSide[] {OfferSide.BID},
"SMA", new IIndicators.AppliedPrice[] {IIndicators.AppliedPrice.CLOSE}, new Object[] {30}, 0);
Does it mean Jforex use 30 candles to calculate SMA based on candle's closed price(every hour )?
2.How to execute my strategy OnCandle instead of Ontick?(please show me the code or give me specified API URL)
3.How to get the closed price of previous Candles?(code or API)
Thanks a lot!
1. Yes, SMA will be calculated based on last 30 candles closed price at your specified period.(Period.TEN_MINS in your code sample).
2. Here is a good example of how to use onBar method:
https://www.dukascopy.com/wiki/en/development/get-started-api/use-in-jforex/strategy-tutorial#create-the-logic-in-the-onbar-method3.
https://www.dukascopy.com/wiki/en/development/strategy-api/historical-data/history-bars For example, if you use Bar by Shift method, shift with 0 value will always refer to current candle, 1 - previous fully formed candle, etc.
IHistory history = context.getHistory();
double firstHistoryBarClosePrice = history.getBar(myInstrument, myPeriod, OfferSide.BID, 1).getClose();
double secondHistoryBarClosePrice = history.getBar(myInstrument, myPeriod, OfferSide.BID, 2).getClose();