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.

close REJECTED
 Post subject: close REJECTED Post rating: 0   New post Posted: Mon 04 Nov, 2013, 07:39 
User avatar

User rating: 0
Joined: Wed 26 Jun, 2013, 23:18
Posts: 20
Location: France, Paris
Hello,

When I execute this strategy to open a position and close the position.

But this error message appears :
06:32:01 Position #55941574 order close REJECTED, REASON: can't send request to fully close order more than once in a second.

Thank you for your help.
Kind Regards,
David


Attachments:
Strategy2.java [3.05 KiB]
Downloaded 87 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: close REJECTED Post rating: 1   New post Posted: Mon 04 Nov, 2013, 07:55 
User avatar

User rating: 96
Joined: Mon 09 Sep, 2013, 07:09
Posts: 287
Location: Ukraine, SHostka
You should use a filter in the onBar method.
See: https://www.dukascopy.com/wiki/#Filter_Ticks_Bars
Without any filter the onBar method is calling too frequently.


 
 Post subject: Re: close REJECTED Post rating: 1   New post Posted: Mon 04 Nov, 2013, 10:52 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
I think line 81 should be also modified to:
order.waitForUpdate(900000, CLOSED); // As we want to wait till the order is CLOSED, not FILLED.


But this is just a sidenote. It won't 'solve' the error you got.


Alternatively you could consider to move the order closing part to the onMessage() function. Whenever the order gets filled, there will be an onMessage() call, so you could implement the close part there.
I know that this is just an example, and it is not a real strategy, but why not consider other (more sophisticated) approaches right away? ;)

This is the onMessage() code:
public void onMessage(IMessage message) throws JFException {
    IOrder anOrder;

    switch (message.getType()) {
        case ORDER_FILL_OK:
            anOrder = message.getOrder();
            try {
                console.getOut().println("closing order: " + anOrder);
                anOrder.close();
                //order.waitForUpdate(900000, CLOSED); // no need for this here
            } catch (JFException e) {
                e.printStackTrace();
            }
    }
}


Hope this helps.


 

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