Dukascopy
 
 
Wiki JStore Search Login

On stopLoss Listener
 Post subject: On stopLoss Listener Post rating: 0   New post Posted: Fri 18 Sep, 2015, 14:34 
User avatar

User rating: 0
Joined: Fri 18 Sep, 2015, 14:32
Posts: 15
Location: Germany, Dresden
Hello Ladies and Gentleman,

is there any possiblity to listen on a closed trade, that has been closed by the stopLoss?

Or by the takeProfit?

I've searched for an according listener Interface, but didn't find anything that fits my needs.

Best Regards,
henry


 
 Post subject: Re: On stopLoss Listener Post rating: 0   New post Posted: Mon 16 Nov, 2015, 06:20 
User avatar

User rating: 0
Joined: Tue 04 Sep, 2012, 06:35
Posts: 11
Location: Hungary,
You could use the IStrategy.onMessage method and set up guards for messages concerning orders closed by SL or TP.

public void onMessage(IMessage message) throws JFException {
    if (message.getReasons().contains(IMessage.Reason.ORDER_CLOSED_BY_TP)) {
        // your logic here - it gets triggered as an order gets closed by tp
    } else if (message.getReasons().contains(IMessage.Reason.ORDER_CLOSED_BY_SL)) {
        //  logic here gets triggered by positions closed for exceeding their SL
    } else {
        //if the message is about something else
    }
}


The above example was taken from the wiki section with slight modifications, it's usually worth checking out first.


 

Jump to:  

  © 1998-2024 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