Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

Martingale with MA + Simple Strategy
 Post subject: Martingale with MA + Simple Strategy Post rating: 0   New post Posted: Thu 09 May, 2013, 16:31 

User rating: 0
Joined: Wed 24 Apr, 2013, 12:11
Posts: 7
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_Strategy
https://www.dukascopy.com/wiki/#Martingale_with_MA


 
 Post subject: Re: Martingale with MA + Simple Strategy Post rating: 0   New post Posted: Thu 09 May, 2013, 16:44 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Consider using some java IDE to give you instant assistance on syntax and compile-time errors, see:
https://www.dukascopy.com/wiki/#Use_in_Eclipse
https://www.dukascopy.com/wiki/#Use_in_NetBeans


 

Jump to:  

  © 1998-2026 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com