API Support wrote:
No they are not, stop loss of a position is in opposite direction than the position's direction - if you make a BUY order then the stop loss of it will be a SELL order.
Yes you are right on the stop loss and i changed my mistakes in the first post
,now the problem is about take profit
we use something like these in MQL:
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-StopLoss*Point,Ask+TakeProfit*Point,"buy opened",255,0,Lime);
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+StopLoss*Point,Bid-TakeProfit*Point,"sell opened",255,0,Red);
,so in my opinion the java code should be changed like this(changes in Red) :
private IOrder submitOrder(double amount, OrderCommand orderCmd, double takeProfitPips) throws JFException{
double stopLossPrice, takeProfitPrice;
//Calculating stop loss and take profit prices
if (orderCmd == OrderCommand.BUY){
stopLossPrice = history.getLastTick(this.instrument).getBid() - this.stopLossPips * this.instrument.getPipValue();
takeProfitPrice = history.getLastTick(this.instrument).
getAsk() + takeProfitPips * this.instrument.getPipValue();
}else {
stopLossPrice = history.getLastTick(this.instrument).getAsk() + this.stopLossPips * this.instrument.getPipValue();
takeProfitPrice = history.getLastTick(this.instrument).
getBid() - takeProfitPips * this.instrument.getPipValue();
}
//Submitting an order for the specified instrument at the current market price
return engine.submitOrder(getLabel(orderCmd), this.instrument, orderCmd, amount, 0, 20, stopLossPrice, takeProfitPrice);
}