Simplified Trailing Stop

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #232525 quote
    DeathMetal
    Participant
    New

    Hello, after following the discussion on the forum about trailing stops, I think this is way too complicated, so I made a simplified version. We start with a trail stop a few points below our entry price, so that if things start immediately against us, we keep a good mood. If the trade comes our way, the trail stop will be increased. Furthermore, we always sell our trades “at market” so that we do not have to take restrictions from the broker into account (especially when announcing important economic data, for example)

    
    Moving stoploss 
    /////////////////////////////////////////////////////////////////////
    ////                     values for DAX                     ////////
    ////////////////////////////////////////////////////////////////////
    SET TARGET pPROFIT 100  // max profit
    SET STOP   pLOSS   35   // max loss
    
    ///trailing stop function
    trailingstep  = 25 //  trailing step to move the "stoploss" 
    firstStep = 10     //  set newSL at x points under buying price by start
    
    //reset the stoploss value
    IF NOT ONMARKET THEN
    newSL=0
    OpenAtpriceL=1000000
    OpenAtpriceS=0
    ENDIF
    
    
    //////////////////////////////////////////////////////////////////////
    ///                         managing positions                   /////
    //////////////////////////////////////////////////////////////////////
    
    //manage long positions
    IF LONGONMARKET THEN
    //first move (a tiny bit under buying price)
    IF newSL=0  THEN
    OpenAtPriceL= close
    newSL = OpenAtPriceL - firstSTep
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=trailingstep THEN
    newSL = newSL+trailingstep
    ENDIF
    ENDIF
     
    //manage short positions
    IF SHORTONMARKET THEN
    IF newSL=0  THEN
    OpenAtPriceS= close
    newSL = OpenAtPriceS + firstSTep
    ENDIF
    //next moves
    IF newSL>0 AND newSL-close>=trailingstep THEN
    newSL = newSL-trailingstep
    ENDIF
    ENDIF
     
    // exit the positions
    IF newSL>0 and LongOnMarket THEN
    IF close < newSL THEN
    SELL AT Market
    ENDIF
    ENDIF
    IF newSL>0 and ShortOnMarket THEN
    IF close > newSL THEN
    EXITSHORT  AT Market
    ENDIF
    endif
    

     

     
    GraHal and MobiusGrey thanked this post
    #232528 quote
    DeathMetal
    Participant
    New

    Don’t copy the first line. (1. moving stoploss)

    #232529 quote
    Aragorna
    Participant
    Junior

    Hi Deathmetal,

    thanks for this. I’ve experienced problem with stop loss, especially stop limit order refused by broker during the trailing. is it this kind of problem that it overcomes? thanks

    Alessio

    #232531 quote
    DeathMetal
    Participant
    New

    Yes, that is correct

    KumoNoJuzza thanked this post
    #232563 quote
    KumoNoJuzza
    Participant
    New

    Interesting. I will amend my trailing “stops” without orders at market.

    #232587 quote
    KumoNoJuzza
    Participant
    New

    I mean with of course.

    #232589 quote
    JS
    Participant
    Senior

    Using “market orders” in a trailing stop is fine, but only on a fast time frame… you don’t want to wait too long for your  Trailing Stop Market Orders to be executed…

    KumoNoJuzza thanked this post
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Simplified Trailing Stop


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
DeathMetal @deathmetal Participant
Summary

This topic contains 6 replies,
has 4 voices, and was last updated by JS
1 year, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/10/2024
Status: Active
Attachments: No files
Logo Logo
Loading...