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.

trailing stop with bar
 Post subject: trailing stop with bar Post rating: 0   New post Posted: Fri 27 Apr, 2012, 07:04 

User rating: 1
Joined: Wed 07 Mar, 2012, 05:56
Posts: 101
Location: New CaledoniaNew Caledonia
hello support,

i would like to define a trailing stop, but not in pips but with bar.

i mean, if i take a long trade at the close of currbar, stoploss = currbar.getLow().
when the next bar close the stop loss go to the low of the bar, etc...

could you explain me how to define this.

thank you


 
 Post subject: Re: trailing stop with bar Post rating: 0   New post Posted: Sun 29 Apr, 2012, 17:02 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Assume that you have a FILLED or OPENED order and you want to update the stop loss on every Eur/Usd 10 min bar:
   @Override
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
        if(instrument != Instrument.EURUSD || period != Period.TEN_MINS){
            return;
        }
        //We can change SL only for FILLED and OPENED orders
        if(order.getState() == IOrder.State.FILLED || order.getState() == IOrder.State.OPENED){
            order.setStopLossPrice(bidBar.getLow());
        }
   }
See more:
https://www.dukascopy.com/wiki/#Set_Stop_Loss_price


 
 Post subject: Re: trailing stop with bar Post rating: 0   New post Posted: Mon 30 Apr, 2012, 07:45 

User rating: 1
Joined: Wed 07 Mar, 2012, 05:56
Posts: 101
Location: New CaledoniaNew Caledonia
ok thanks you for your reply


 

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