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.

Auto close currency pair on Friday
 Post subject: Auto close currency pair on Friday Post rating: 0   New post Posted: Sun 04 Mar, 2012, 12:52 

User rating: 0
Joined: Mon 14 Nov, 2011, 05:16
Posts: 33
Location: PhilippinesPhilippines
Dear Support,

I run several strategies on one account, trading several currency pairs.

I wish to add a code snippet which closes all EURUSD positions on Friday 2100 to avoid margin calls (but not the other pairs).

I have tried the below code, which doesnt seem to work:
           
       for (IOrder orderInMarket : engine.getOrders()) {
            Calendar tradeDate = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
            tradeDate.setTimeInMillis ( orderInMarket.getFillTime() );
            int tradeDay = tradeDate.get ( Calendar.DAY_OF_WEEK  );

 if ( (orderInMarket.getState().equals(IOrder.State.FILLED))
            && (Day == Calendar.FRIDAY && Heures ==21)) {
                orderInMarket.close();     
}
}   


Can you help me?


 
 Post subject: Re: Auto close currency pair on Friday Post rating: 0   New post Posted: Mon 05 Mar, 2012, 15:04 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Consider taking last tick time instead of current system time, as it is done in the following examples:
https://www.dukascopy.com/wiki/#Customize_trading_hours
Mind that if the market is closed then you won't be able to close the orders - you need to do it before the market closes.


 

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