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 differs in real trading
 Post subject: Trailing Stop differs in real trading Post rating: 0   New post Posted: Wed 01 Aug, 2012, 15:50 
User avatar

User rating: 0
Joined: Wed 01 Aug, 2012, 14:26
Posts: 10
Location: South AfricaSouth Africa
Hi Support

I wrote a strategy with a trailing stop that I coded myself.

The trailing stop is managed by the following lines of code within the "onTick" body:
if (inLong)
        {
            b = tick.getBid();
            if (b<=stoploss)
            {
                order_long.close();
                inLong = false;
            }
            else if (b-trailpips>stoploss)
            {
                stoploss = b-trailpips;
            }
        }
        else if (inShort)
        {
            b = tick.getAsk();
            if (b>=stoploss)
            {
                order_short.close();
                inShort = false;
            }
            else if (b+trailpips<stoploss)
            {
                stoploss = b+trailstop;
            }
        }


This works perfectly in the historical tester, but it does not work at all if strategy is running in real time.
Your help will be greatly appreciated.


 
 Post subject: Re: Trailing Stop differs in real trading Post rating: 0   New post Posted: Thu 02 Aug, 2012, 07:24 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Consider adding logging statements with the relevant values to see when which execution paths get taken and why:
https://www.dukascopy.com/wiki/#IConsole/Logging_values


 

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