Dukascopy
 
 
Wiki JStore Search Login

Are you using Trailing Stop Loss in Jforex 3?
 Post subject: Are you using Trailing Stop Loss in Jforex 3? Post rating: 0   New post Posted: Thu 04 Jan, 2018, 22:08 

User rating: 18
Joined: Thu 20 Apr, 2017, 22:42
Posts: 165
Location: Russian Federation,
Hi Everyone.

I recently tried using native Trailing Stop Loss implemented in JForex3 platform (which I understand is handled server-side) and it seems practicallu unusable because of following 2 points.

1. As far as I understand from (docs) and (this topic) - "trailing stop loss (TSL)" steps with the same increments as TSL, i.e. if i have TSL=30pips my SL will be changing like following 1.2000 -> 1.2030 -> 1.2060 -> 1.2090, NOT just more-or-less exactly 30pips behind the moving price.

Increments of 30pips (or whatever rather high number of pips i'll configure for TSL) is really awful.

2. Minimal supported TSL is 10pips - this is typically unacceptably high for pairs like EUR/USD, but it is just 1/5 of the typical spread in USD/ZAR (~50pips). I see no real logic in harcoding TSL to >= 10pips.

---

These 2 points make "trailing stop loss" mostly not usable for me. Am I missing something? Are you using it?


 
 Post subject: Re: Are you using Trailing Stop Loss in Jforex 3? Post rating: 0   New post Posted: Tue 23 Jan, 2018, 17:43 
User avatar

User rating: 0
Joined: Fri 17 Jan, 2014, 18:13
Posts: 72
Location: NetherlandsNetherlands
As far as i understand (and tested), the pip settings for trailing stop is different from the way MT4 and cTrader do. The pip setting makes sure SL only changes after a minimum of 10 pips price change. This has to do with the limitation of setting SL max once per second.

The distance (in price) between SL and Current Price is not influenced by this Trail pip setting. In stead, SL follows on the same distance as it was when SL was set. So the price distance is arbitrary. First you set the SL, then you set Trailing with standard 10 pips or more.


 
 Post subject: Re: Are you using Trailing Stop Loss in Jforex 3? Post rating: 0   New post Posted: Tue 23 Jan, 2018, 19:38 

User rating: 18
Joined: Thu 20 Apr, 2017, 22:42
Posts: 165
Location: Russian Federation,
Thanks for comment. It appears that I've got that logic wrong. I just created a dummy strategy to check what you are saying and - yes, you are correct.
- Actual trailing SL is the difference (PRICE - SL PRICE) at the moment when trailing SL was created
- Server updates SL at the provided interval of pips (10+ pips), it is not the trailing SL
(All this is unnatural to me :) - I see that 'trailing step' parameter absolutely useless and misleading, i see no reason someone will set it higher than 10pips and therefore it is more a boolean parameter - "use TSL with 10pips increments" or "do not user TSL")

Here sample strategy and its output for reference (I assume LIVE/DEMO works with the same logic as historical tester):
    @Override
    public void onStart(IContext context) throws JFException {
        this.context = context;

        o = context.getEngine().submitOrder("Test_TSL", EURUSD, BUYLIMIT,
                /* amount */        0.1,
                /* price */       1.181,
                /* slippage */       10,
                /* stop-loss */       0,
                /* take-profit */ 1.191);
    }

    @Override public void onMessage(IMessage message) throws JFException {
        IOrder o = message.getOrder();

        switch( message.getType() ) {
            case ORDER_FILL_OK:
                info("" + message);
                info(String.format("set tsl(price: %.5f, side: %s, pips: %s)",
                                   o.getOpenPrice() - 15 * pip, OfferSide.BID, 25));
                o.setStopLossPrice(o.getOpenPrice() - 15 * pip, OfferSide.BID, 25);       <--  SL is 15 pips below, TSL: is 25 pips
                oldSL = o.getStopLossPrice();

                break;

            case ORDER_CHANGED_OK:
                double newSL = o.getStopLossPrice();
                double slStep = oldSL == 0 ? 0 : (newSL - oldSL) / pip;
                double priceToSL = (lastTick.getBid() - newSL) / pip;

                info(String.format("%s, SL: %s, SL step: %.1f ---- Cur.price: %s, price-to-sl: %.1f pips",
                                   message, newSL, slStep, lastTick.getBid(), priceToSL));
                oldSL = newSL;
                break;
        }
    }

Output, printed in reverse order: SL is updated each 25 pips, actual TSL ~= 15 pips.
Executed for EURUSD at 2017-11-30

   ORDER_CHANGED_OK - Stop loss price changed order: FILLED BUY 0.1 @ 1.18097, SL: 1.1895, SL step: 25.1 ---- Cur.price: 1.19096, price-to-sl: 14.6 pips
   ORDER_CHANGED_OK - Stop loss price changed order: FILLED BUY 0.1 @ 1.18097, SL: 1.18699, SL step: 25.1 ---- Cur.price: 1.18845, price-to-sl: 14.6 pips
   ORDER_CHANGED_OK - Stop loss price changed order: FILLED BUY 0.1 @ 1.18097, SL: 1.18448, SL step: 25.1 ---- Cur.price: 1.18594, price-to-sl: 14.6 pips
   ORDER_CHANGED_OK - Stop loss price changed order: FILLED BUY 0.1 @ 1.18097, SL: 1.18197, SL step: 25.0 ---- Cur.price: 1.18343, price-to-sl: 14.6 pips
   ORDER_CHANGED_OK - Stop loss condition changed order: FILLED BUY 0.1 @ 1.18097, SL: 1.17947, SL step: 0.0 ---- Cur.price: 1.18093, price-to-sl: 14.6 pips
   set tsl(price: 1.17947, side: Bid, pips: 25)
   ORDER_FILL_OK - Order filled order: FILLED BUY 0.1 @ 1.18097


Attachments:
TslTestStrategy.java [2.41 KiB]
Downloaded 201 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 

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