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.

SL not improving as tested in HT
 Post subject: SL not improving as tested in HT Post rating: 0   New post Posted: Tue 14 May, 2013, 08:59 

User rating: 0
Joined: Sun 11 Sep, 2011, 17:43
Posts: 10
Location: Bulgaria,
Guys,

I ran into a weird issue. Below is the code that governs my stop losses. As
you see, the stop loss is about to be moved to secure about 20 PIPS, once
the price is about 40 PIPS above (for longs) and 40 PIPS below (for shorts)
the open price of the deal. On the hist tester this works perfectly - if
there are 10 long deals for example, all of their SLs get improved once the
rule is true. However, on the live, the only deal SL that gets improved is
the last one filled...please advise.

 //stop loss long deals

                for (IOrder order : engine.getOrders(instrument)) {
                    if (order.getState() == IOrder.State.FILLED && order.isLong()) {
                        if (order.getProfitLossInPips() > 40) {
                            order.setStopLossPrice(order.getOpenPrice() + 0.0020);
                         }
                    }
                }
                   
            //stop loss short deals
           
                for (IOrder order : engine.getOrders(instrument)) {
                    if (order.getState() == IOrder.State.FILLED && !order.isLong()) {
                        if(order.getProfitLossInPips() > 40) {
                            order.setStopLossPrice(order.getOpenPrice() - 0.0020);
                        }
                    }
                }


Thanks for the help!


 
 Post subject: Re: SL not improving as tested in HT Post rating: 0   New post Posted: Tue 14 May, 2013, 11:31 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Consider adding some logging to the strategy to see what execution paths get taken and why, see:
https://www.dukascopy.com/wiki/#IConsole/Logging_values


 

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