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 all position before Friday night
 Post subject: Close all position before Friday night Post rating: 0   New post Posted: Sat 25 Jul, 2015, 09:16 
User avatar

User rating: 0
Joined: Fri 14 Nov, 2014, 15:13
Posts: 5
Location: Italy, Venaria Reale
Good morning community, I want to close all my position 20minutes before market close on friday night. Can you suggest some codes for my EA in order to reach my goal? :?:


 
 Post subject: Re: Close all position before Friday night Post rating: 0   New post Posted: Thu 30 Jul, 2015, 09:39 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Please consider the following code

public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
    if (period != this.period || instrument != this.instrument){
         return;
    }
 
    Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    calendar.setTimeInMillis(history.getLastTick(instrument).getTime());
 
    if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY &&
            calendar.get(Calendar.HOUR_OF_DAY) == 20 && calendar.get(Calendar.MINUTE) >= 40) {
 
        for (IOrder order : engine.getOrders(instrument)) {
            order.close();
        }
    }
}


 

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