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.

how to place orders?
 Post subject: how to place orders? Post rating: 0   New post Posted: Tue 20 Nov, 2012, 14:13 
User avatar

User rating: 1
Joined: Sat 24 Sep, 2011, 12:11
Posts: 31
Location: China,
i have read wiki for quite a while but still not clear about that and this is my code,can someone please tell me where is bug
================================
private IOrder submitOrder(OrderCommand orderCmd) throws JFException {
        long goodTillTime =  System.currentTimeMillis() + 60*1000*15*30;
        double stopLossPrice, takeProfitPrice;
        double k=0;
        for (int i=1;i<=55;i++)
         
        {
         double Bar_length=history.getBar(instrument, selectedPeriod, OfferSide.BID, i).getHigh()-history.getBar(instrument, selectedPeriod, OfferSide.BID, i).getLow();
         k=k+Bar_length;
         }
         k=k/27;
        // Calculating stop loss and take profit prices
        if (orderCmd == OrderCommand.PLACE_BID) {
            stopLossPrice = history.getLastTick(this.instrument).getBid() - getPipPrice(this.stopLossPips)-k;
            takeProfitPrice = history.getLastTick(this.instrument).getBid() + getPipPrice(this.takeProfitPips);
            console.getOut().println(k);
    return engine.submitOrder(getLabel(instrument), this.instrument, orderCmd, this.amount, history.getLastTick(this.instrument).getBid()-k, 2, stopLossPrice, takeProfitPrice,goodTillTime);  //this one really submit orders!!!
        }
        if (orderCmd == OrderCommand.PLACE_OFFER){
            stopLossPrice = history.getLastTick(this.instrument).getAsk() + getPipPrice(this.stopLossPips)+k;
            takeProfitPrice = history.getLastTick(this.instrument).getAsk() - getPipPrice(this.takeProfitPips);
            console.getOut().println(k);
    return engine.submitOrder(getLabel(instrument), this.instrument, orderCmd, this.amount, history.getLastTick(this.instrument).getBid()+k, 2, stopLossPrice, takeProfitPrice,goodTillTime);  //this one really submit orders!!!
        }

===========================
after compiled ,error message is : This method must return a result of type IOrder


 
 Post subject: Re: how to place orders? Post rating: 0   New post Posted: Tue 20 Nov, 2012, 16:02 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
all execution paths of the method need to return an IOrder object. Adding return null should solve the compilation problem, however, you need to check if this is correct from you strategy logic perspective.
In order to avoid such compile-time errors, consider using an IDE, e.g. Eclipse or NetBeans.


 

Jump to:  

  © 1998-2025 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