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.

problem sending order (tester)
 Post subject: problem sending order (tester) Post rating: 0   New post Posted: Sun 22 Sep, 2013, 22:43 
User avatar

User rating: 0
Joined: Sun 22 Sep, 2013, 22:29
Posts: 18
Location: RomaniaRomania
This is my first attempt, I didn't run this on demo yet (just on tester).

here are some blocks:

public void onMessage(IMessage message) throws JFException {
        CurrentContext.getConsole().getNotif().println(message.getContent()); 
        if (message.getType()==IMessage.Type.SENDING_ORDER)
          {
             CurrentContext.getConsole().getNotif().println("SENDING ORDER");   
          }
       
    }


CurrentContext is defined as
private IContext CurrentContext = null; 
and receives value in OnStart:
CurrentContext = context; 


far down in the code there is:

        try { 
               CurrentContext.getConsole().getNotif().println("before try");
               IOrder order = CurrentContext.getEngine().submitOrder(commBuy, Instr, IEngine.OrderCommand.BUY, defaultAmount);
               CurrentContext.getConsole().getNotif().println("tried");   }
         catch (JFException e) {e.printStackTrace();}


What I get as message is just "before try". It doesn't reach "tried" and there is no SENDING ORDER or other kind of message. Why this?


 
 Post subject: Re: problem sending order (tester) Post rating: 0   New post Posted: Mon 23 Sep, 2013, 00:18 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi:

That seems some problem with your order parameters... is commBuy a string ? is instr assigned as instrument ? and default amount as double and a valid value ?

The order is created ?

Trade well

JL


 
 Post subject: Re: problem sending order (tester) Post rating: 0   New post Posted: Mon 23 Sep, 2013, 12:03 
User avatar

User rating: 0
Joined: Sun 22 Sep, 2013, 22:29
Posts: 18
Location: RomaniaRomania
jlongo wrote:
Hi:

That seems some problem with your order parameters... is commBuy a string ? is instr assigned as instrument ? and default amount as double and a valid value ?

The order is created ?

Trade well

JL


Mmm, now I see the mistakes. commBuy had an invalid character in it. After I corrected, I saw orders sent and mistakes reported...

Solved it.

I have some questions:
1. Does this work in position-style (MT5) or order-style (MT4) ? How do I switch between styles? (I want order-style)
2. How do I set orders to have just stop loss, but no take profit ?
3. How do I delete pending orders?
4. How do I update stop loss/take profit?
5. The amount in millions is in millions of the first currency in the pair or in millions of the account currency?


 
 Post subject: Re: problem sending order (tester) Post rating: 0   New post Posted: Mon 23 Sep, 2013, 14:23 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi:

1 - Not know about mt4/5 but i think that is order style.
2 - you have two choices: at order creation with the correct parameters but you need to set a valid take profit also, or later with order.setStopLoss();
see - https://www.dukascopy.com/client/javadoc ... ang.String, com.dukascopy.api.Instrument, com.dukascopy.api.IEngine.OrderCommand, double, double, double, double, double)
and
https://www.dukascopy.com/client/javadoc ... ice(double)

3 - close the pending order - order.close();

4 - same as 2 (2ª choice) for stop loss or take profit

5 - Amount on primary currency - see https://www.dukascopy.com/wiki/#Order_Amounts


Trade well

JL


 
 Post subject: Re: problem sending order (tester) Post rating: 0   New post Posted: Tue 24 Sep, 2013, 22:02 
User avatar

User rating: 0
Joined: Sun 22 Sep, 2013, 22:29
Posts: 18
Location: RomaniaRomania
jlongo wrote:
Hi:

1 - Not know about mt4/5 but i think that is order style.
2 - you have two choices: at order creation with the correct parameters but you need to set a valid take profit also, or later with order.setStopLoss();
see - https://www.dukascopy.com/client/javadoc ... ang.String, com.dukascopy.api.Instrument, com.dukascopy.api.IEngine.OrderCommand, double, double, double, double, double)
and
https://www.dukascopy.com/client/javadoc ... ice(double)

3 - close the pending order - order.close();

4 - same as 2 (2ª choice) for stop loss or take profit

5 - Amount on primary currency - see https://www.dukascopy.com/wiki/#Order_Amounts


Trade well

JL


Thank you very much! Made huge progress in just 2 days!


 
 Post subject: Re: problem sending order (tester) Post rating: 0   New post Posted: Wed 25 Sep, 2013, 07:20 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
fxeconomist wrote:
1. Does this work in position-style (MT5) or order-style (MT4) ? How do I switch between styles? (I want order-style)
Go through the following wiki section, every concept is supplied with example strategies, see:
https://www.dukascopy.com/wiki/#Orders_overview
fxeconomist wrote:
2. How do I set orders to have just stop loss, but no take profit ?
See: https://www.dukascopy.com/wiki/#Set_Stop_Loss_price
fxeconomist wrote:
3. How do I delete pending orders?
by calling IOrder.close on IOrder.State.OPENED orders, see: https://www.dukascopy.com/wiki/#Close_Orders
fxeconomist wrote:
4. How do I update stop loss/take profit?
See:
https://www.dukascopy.com/wiki/#Set_Stop_Loss_price
https://www.dukascopy.com/wiki/#Set_Take_Profit_price


 

Jump to:  

cron
  © 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