Hello, i found those two strategies on JForex Wiki page, and i wanted to make one strategy with some functions from both.
I want to replace this:
/**
* Get the order direction depending on MA value.
*/
private OrderCommand getOrderCommand() throws JFException{
double ma5_0 = indicators.ma(instrument, tf,OfferSide.BID,IIndicators.AppliedPrice.CLOSE,MAPeriod,IIndicators.MaType.SMA,0);
double ma5_1 = indicators.ma(instrument, tf,OfferSide.BID,IIndicators.AppliedPrice.CLOSE,MAPeriod2,IIndicators.MaType.SMA,0);
double price = history.getLastTick(instrument).getBid();
return (price < ma5_0 || price < ma5_1) ? SELL : BUY;
}
With this:
public void onMessage(IMessage message) throws JFException {
if (message.getType() == Type.ORDER_CLOSE_OK){
//Fetching closed order
IOrder order = message.getOrder();
//Defining take profit for the next order
if (order.getProfitLossInPips() > 0) submitOrder(amount, order.getOrderCommand(), 10);
else submitOrder(amount, oppositeOrderCmd(order), this.takeProfitPips);
}
}
private OrderCommand oppositeOrderCmd(IOrder order){
//Returns opposite order command
return order.isLong() ? OrderCommand.SELL : OrderCommand.BUY;But i just can't do it, i get syntax errors etc. all the time. When i fix one i get another one. I thought i'd be able to do it, but im not, i only have some JS knowledge and Java with API is too much for me.
Could anyone help me?
Here are the links to both strategies:
https://www.dukascopy.com/wiki/#Simple_Strategyhttps://www.dukascopy.com/wiki/#Martingale_with_MA