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?