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.

Updating a trailing stoploss
 Post subject: Updating a trailing stoploss Post rating: 0   New post Posted: Sat 22 Dec, 2018, 04:38 
User avatar

User rating: 2
Joined: Fri 02 Mar, 2012, 22:08
Posts: 200
Location: New Zealand, Dunedin
Hi

I have a strategy which works on a time period of ONE_HOUR

In the 'On Tick' Method I check the trailing stoploss for updating

when I run the strategy on a demo account I get lots of messages saying you can't update the stoploss more than once per second

Should I be worried about these messages?

Is there a way to code the strategy so that I don't get these messsages?

Bob M


 
 Post subject: Re: Updating a trailing stoploss Post rating: 1   New post Posted: Wed 26 Dec, 2018, 12:25 
User avatar

User rating: 21
Joined: Thu 19 May, 2011, 20:50
Posts: 413
Location: Germany, Munich
Hi Bob,

if you send your SL changes more than once a second, the change gets skipped.
We solved this problem by adding a SL manager system.
    * It accepts any price change as often as it appears from a strategy.
    * It updates the position SL price in the platform every second to the latest SL price, but only if any change is needed. This is done by comparing the current position SL price with the latest requested SL price.
    * This also works for TP changes.

Kind regards

Bernhard Schicht
Computer Scientist
CEO Stash GmbH


 
 Post subject: Re: Updating a trailing stoploss Post rating: 0   New post Posted: Wed 09 Jan, 2019, 04:43 
User avatar

User rating: 2
Joined: Fri 02 Mar, 2012, 22:08
Posts: 200
Location: New Zealand, Dunedin
Hello Bernhard

I have the following code
****************************
/**
* Executed on every tick received
*
* @param instrument - instrument of the tick received
* @param tick - tick data
* @throws JFException
*/
@Override
// check if stop-loss position needs updating
public void onTick(Instrument instrument, ITick tick) throws JFException {
// if not USDJPY, then exit
if (!instrument.equals(myInstrument)) {
return; // exit
}

// we can't update stoploss or take profit more frequently than once per second
if (tick.getTime() - lastTickTime < 1000) {
return;
}
updateTrailingStopLoss(instrument, tick, trailingTrig, myStopLoss);
} // end onTick

/**
**********************************

I don't understand why I still get all these rejected changes to the StopLoss

Bob M


 

Jump to:  

cron
  © 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