Code voor trailstop and stoploss at the same time

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #232930 quote
    DeathMetal
    Participant
    New

    Hereby code for trailstop long and short and  stoploss at the same time.  (Beause this doesn’t work by using the two program instructions stop trailing and stoplosss)

     

    /////  trailingstop for long and short  and stoploss    /////////////////////
    ////////////////////////////////////////////////////////////////////////////
    ////  Version 1.0    dd 21-05-2024//////////////////////////////////////////
    
    /// Reset variables
    IF NOT ONMARKET  THEN
    LaagsteKoers=1000000
    HoogsteKoers=0
    ENDIF
    
    once UitstapOpTSL=45 // points to trail for long
    once UitstapOpTSS=55  // points to trail for short
    
    
    //////////////   LONG    /////////////////////////////
    If LongOnMarket AND HoogsteKoers=0 THEN
    OpeningsprijsL= close
    Hoogstekoers=openingsprijsL
    ENDIF 
    
    //  Determine highest high
    If LONGONMARKET THEN 
    DezeHigh= high
    If DezeHigh > HoogsteKoers then
    Hoogstekoers=DezeHigh
    ENDIF 
    ENDIF 
    
    
    //Sell trade if close< highest high- x points (UitstapOpTSL )
    IF (close < (Hoogstekoers - UitstapOpTSL)) and LONGONMARKET  then
    SELL AT MARKET
    ENDIF 
    
    
    
    /////////////////  SHORT          ////////////////////////////////////////////
    
    
    IF ShortOnMarket AND LaagsteKoers=1000000 THEN
    OpeningsprijsS= close
    Laagstekoers=openingsprijsS
    ENDIF 
    
    
    IF ShortOnMarket THEN
    DezeLow= low
    If DezeLow < laagsteKoers then
    LaagsteKoers=DezeLow
    endif
    ENDIF
    
    
    
    IF (close >  (Laagstekoers + UitstapOpTSS)) and SHORTONMARKET  then
    EXITSHORT AT MARKET
    endif
    
    
    SET TARGET pPROFIT 75
    SET STOP pLOSS 35
    
    
    ///  Exit by trailingstop is at market, only use this on small timeframes!!
    
    
    robertogozzi thanked this post
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.

Code voor trailstop and stoploss at the same time


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
DeathMetal @deathmetal Participant
Summary

This topic contains 1 voice and has 0 replies.

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