Dear Support,
Thank you for your reply. I did some investigation during the past days, and here are my answers:
I used different periods (mostly 1min and 5min). I always run the historical tester with tick data, and with process all ticks. And tick filters are disabled on the platform, and in the strategy as well.
Quote:
Do you take into account that the long positions should be compared to the ASK candles?
I was not completely aware of this. I am also not sure if I submit orders properly, based on this ASK/BID candles/prices. Could you confirm that this is to proper way? I am interested in if the indicator calculation (especially the side parameter) is proper.
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException
{
double RSI9;
if ( (instrument.equals(selectedInstrument)) && (period.equals(selectedPeriod)))
{
//Long side
RSI9 = indicators.rsi(instrument, selectedPeriod, OfferSide.BID, appliedPrice, 9, 0);
if (RSI9 < rsiHighLimit)
engine.submitOrder(createLabel(instrument), instrument, OrderCommand.BUY, amount, 0.0, 0.0, bidBar.getClose()-stopLoss*0.00001, bidBar.getClose()+takeProfit*0.00001);
//Short side
RSI9 = indicators.rsi(instrument, selectedPeriod, OfferSide.ASK, appliedPrice, 9, 0);
if (RSI9 > rsiShortLimit)
engine.submitOrder(createLabel(instrument), instrument, OrderCommand.SELL, amount, 0.0, 0.0, askBar.getClose()+stopLoss*0.00001, askBar.getClose()-takeProfit*0.00001);
}
}
I have another issue with the above code (next to the initial one, when the order`s price is within a candle):
Whenever I submit an order with the above code, sometime the order`s price is different then the current candle`s open price. This is why we can see the order placed within the candle. When I calculate the stopLoss and takeProfit in the onBar() function, I use bidBar/askBar.getClose() price as a base, and add/substract my stopLoss/takeProfit values to this base price. But this base price (the bidBar/askBar.getClose()) is not the same as the order`s price (the price in which the order was submitted). Because of this, the SL/TP prices are not exactly stopLoss/takeProfit pips away from the order`s price. How can I solve this isseu? Would that be a solution to place the orders without SL/TP, and in the onMessage() function, when the order is filled, set the SL/TP prices using the order.getPrice() as base?