Simple ADX and Day High/Low breakout

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #133103 quote
    BobFlynn
    Participant
    Senior

    Very simple strategy based on Kevin Davey book , I simply used his entry with ADX and a breakup/down of previous days value. See the code below :

    DEFPARAM CumulateOrders = False
    // Position Size
    N = 2
    
    lookbackbars = 10
    ADXentry = ADX[15]<20
    IF ADXentry THEN
    BUY N CONTRACTS AT HIGHEST[lookbackbars](high) STOP
    SELLSHORT N CONTRACTS AT LOWEST[lookbackbars](low) STOP
    ENDIF
    
    SET STOP pLOSS 90 %trailing 0.4

     

     

    I’m sure there is a lot of ways to improve it. I’m currently to convert my stoploss into a trailing stoploss (as I have a limited account with IG, the trailing function isnt allowed). Also for accounts like mine, you will need to launch a LONG only and SHORT only version, as you can’t put two orders in opposite direction.

    us-tech-cash-minutes-mai-1590360633l84cp.png us-tech-cash-minutes-mai-1590360633l84cp.png us-tech-cash-minutes-mai-1590360633l84cp1.png us-tech-cash-minutes-mai-1590360633l84cp1.png
    #145347 quote
    robertogozzi
    Moderator
    Master

    Line 12 is not allowed, since you are using two different forms to set a SL, you should use SET STOP pLOSS or SET STOP %TRAILING.

    But almost everybody use external code snippets to replace the built-in SET STOP TRAILING.

    You can simply add lines 17-56  (unchanged) from this link https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/, then change only the settings for TRAILINGSTART and TRAILINGSTEP.

    #145355 quote
    MAKSIDE
    Participant
    Veteran

    i will check that. problem with breakout is having lot of losing trades

    What is the WF result about that ?

    I don’t have the book Entry and Exit Confessions of a Champion Trader but it’s a very interesting trader

    #145398 quote
    Léo
    Participant
    Average

    Hello

    Cf the code including trailing stop as suggested by Roberto

    //Simple ADX and Day High/Low breakout
    //Very simple strategy based on Kevin Davey book
    //BobFlynn
    //Trailing stop function from Nicolas https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/
    
    DEFPARAM CumulateOrders = False
    // Position Size
    N = 2
     
    lookbackbars = 10
    ADXentry = ADX[15]<20
    IF ADXentry THEN
    BUY N CONTRACTS AT HIGHEST[lookbackbars](high) STOP
    SELLSHORT N CONTRACTS AT LOWEST[lookbackbars](low) STOP
    ENDIF
    
    //************************************************************************
    //trailing stop function
    trailingstart = 90 //trailing will start @trailinstart points profit
    trailingstep = 5 //trailing step to move the "stoploss"
     
    //reset the stoploss value
    IF NOT ONMARKET THEN
    newSL=0
    ENDIF
     
    //manage long positions
    IF LONGONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
    newSL = tradeprice(1)+trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
    newSL = newSL+trailingstep*pipsize
    ENDIF
    ENDIF
     
    //manage short positions
    IF SHORTONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
    newSL = tradeprice(1)-trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
    newSL = newSL-trailingstep*pipsize
    ENDIF
    ENDIF
     
    //stop order to exit the positions
    IF newSL>0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
    //************************************************************************
     
    //GRAPH newSL as "trailing"
    robertogozzi thanked this post
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Simple ADX and Day High/Low breakout


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
BobFlynn @bobflynn Participant
Summary

This topic contains 3 replies,
has 4 voices, and was last updated by Léo
5 years, 5 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/25/2020
Status: Active
Attachments: 2 files
Logo Logo
Loading...