3 lines break reversal strategy on trending stocks

3 lines break reversal strategy on trending stocks

Hello,

Based on 3 lines break indicator and some other pieces of code found elsewhere, I propose this strategy, with several alternative conditions of exits. An optimization variable “strategy” needs to be implemented from 1 to 9, to compare the different variations.

Visually winning trades look beautiful, but at the end, % of winning rates ratio is average. Profit factor is often profitable when tested on various stocks.

Would appreciate some feedback to improve the strategy. I already know that the code may look pretty messy and not optimized.

Discussions about the strategy take place in this forum topic: https://www.prorealcode.com/topic/a-strategy-around-3-lines-break-on-stocks-daily/

Share this

Risk disclosure:

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

ProRealTime ITF files and other attachments : How to import ITF files into ProRealTime platform?

PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials

  1. emism12 • 08/30/2021 #

    Looks great, personally I don’t use automated trading for single stocks, but is definitely on my to do list.
    Good results in emerging companies.
    Backtested it in many forex but didn’t find solid results.

    Thanks for sharing!

  2. adconsulting • 08/30/2021 #

    Ciao,
    I look that the strategy (backtest 50 k), works very good wiht US 500 CASH 1 EURO in 4 h time frame.
    i made the following changes:

    DEFPARAM CumulateOrders=false
    strategy = 5
    n=5 (size 5) I do not use the size it increases
    ma50=Average[30](close)

    / @Name DT_3LineBreak
    // @Type Backtest
    // @Date: 04.08.2021
    // @Source: Tradosaure Youtube + code DocTrading
    // @Timeframe: Daily
    // @Entry:Breakout 3LB reversal with trend filter (close>MA200)
    // @Stop Loss: 3LB low
    // @Take Profit: 1 SL distance (RRR) – to be tested

    DEFPARAM CumulateOrders=false

    // Sub-Strategies:
    // 1- TP = 1SL
    // 2- TP = 1.5 SL
    // 3- TP = 2 SL
    // 4- TP = 5%
    // 5- TBC
    // 6- BE after 5%
    // 7- TP =1.5 SL + BE 5%
    // 8- TP =2 SL + BE 5%
    // 9- BE + Trailing stop
    strategy = 6.50

    //////////////////////////////////////////////////////////////////////
    //// GENERIC CODE
    //////////////////////////////////////////////////////////////////////

    // TAILLE DES POSITIONS : 3 VARIABLES A PARAMÉTRER
    //CAPITALInit = 10000
    // Capital initial (pour le calcul de taille des trades)
    LEVIER = 1
    // Levier : ne pas en abuser, bien vérifier le drawdown
    //REINV = 0
    // 0 = sans réinvestir / 1 = réinvestir les gains

    RISQ = 0.015
    distSL = 0.04 // minimum stop loss distance % to be profitable

    RRR=1 // Risk Reward Ratio
    if strategy = 2 or strategy =7 then
    RRR=1.5
    elsif strategy = 3 or strategy = 8 then
    RRR=2
    endif

    n=6.50
    //////////////////////////////////////////////////////////////////////
    //// INDICATOR
    //////////////////////////////////////////////////////////////////////

    once t=1
    once a0=(close)
    once a1=(close)
    once a2=(close)
    once a3=(close)

    newClose = close
    if t=1 and newClose>a3 then
    a0=a1
    a1=a2
    a2=a3
    a3=newClose
    elsif t=1 and newClose<a0 then
    t=-1
    a1=a3
    a0=a3
    a3=newClose
    elsif t=-1 and newClose<a3 then
    a0=a1
    a1=a2
    a2=a3
    a3=newClose
    elsif t=-1 and newClose>a0 then
    t=1
    a1=a3
    a0=a3
    a3=newClose
    cBuy=1
    else
    cBuy=0
    endif

    //////////////////////////////////////////////////////////////////////
    //// BUY CONDITIONS
    //////////////////////////////////////////////////////////////////////

    i=0
    c1 = cBuy
    ma50=Average[30](close)
    c2 = ma50>ma50[1] or close>ma50
    //c2 = close>Average[200](close)
    c0=1

    if not longonmarket and c0 and c1 and c2 then
    BUY n shares at market nextbaropen
    sellprice = min(high*(1-distSL-0.001),a0)
    targetprice = high+RRR*(high-sellprice)
    if strategy = 4 then
    targetprice = high*1.05
    endif
    ENDIF

    //////////////////////////////////////////////////////////////////////
    //// BREAK EVEN
    //////////////////////////////////////////////////////////////////////
    IF NOT ONMARKET THEN
    breakevenLevel=0
    ENDIF

    //test if the price have moved favourably of “startBreakeven” points already
    IF strategy >5 then
    IF LONGONMARKET AND high>1.05*tradeprice(1) THEN
    //calculate the breakevenLevel
    breakevenLevel = tradeprice(1)*1.02
    ENDIF
    endif

    //place the new stop orders on market at breakevenLevel
    IF breakevenLevel>0 THEN
    SELL AT breakevenLevel STOP
    ENDIF

    //////////////////////////////////////////////////////////////////////
    //// REBUY
    //////////////////////////////////////////////////////////////////////
    if longonmarket and cBuy[0] and t[1]=-1 then
    BUY n shares at market nextbaropen
    endif

    //////////////////////////////////////////////////////////////////////
    //// SELL CONDITIONS
    //////////////////////////////////////////////////////////////////////

    IF longonmarket THEN
    cSell = close < sellprice or close > targetprice
    if strategy=9 then
    cSell = close<a0
    endif
    IF cSell THEN
    SELL at market nextbaropen
    ENDIF
    ENDIF

  3. Kev Monaghan • 08/30/2021 #

    The equity curve looks to follow the stock price almost perfectly, Have you tested on stock that is in a down trend? I have found that to be effective for teaching the system when not to trade, for example I will forbid a system to take Long entries below yesterdays low or some other fail safe, to limit losses and drawdowns, just a suggestion, I havent read or tried to understand the code itself I just find if the equity curve follows the price you are essentially a bag holder.
    Averaging in and out can help improve win rate eg, below a basic and rough example of effective way to average

    INPROFIT = close[1] > (POSITIONPRICE[1]+(POINTSIZE*2))

    If C1 THEN
    BUY 5 XXXX at market
    ELSIF C2 AND COUNT OF POSITION >5 Then
    Buy 5 SHARES AT MARKET
    ENDIF

    IF EX1 AND INPROFIT
    THEN SELL 5 XXXX AT MARKET
    ELSIF EX2 AND NOT INPROFIT THEN
    SELL 5 XXXX AT MARKET
    ENDIF

avatar
Register or

Likes

avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar
Related users ' posts
bertrandpinoy BONJOUR PAUL impossible de tenter le trading automatique, PRT me dis que l instruction "GRAP...
Paul Bonjour, supprimez les lignes avec un "graph"
bertrandpinoy merci. vous l utiliser actuellment sur quel instrument vous? et quel timeframe? Merci
Francesco78 Hi CKW, yes I do run it live, and so far I had no problem, which kind of errors?
JohnScher Hello Francesco. Are you still active with the Threeliner? I also follow that, that you ...
fatlung Hi Francesco May I know the time zone applicable to this strategy?
finplus bonjour, il y a un problème à la fin du code avec elsif (close 0 then ... ne manque t il pas...
kj1988 Hello Nicolas, thank you for this useful indicator. Could you tell me how I can remove the...
Nicolas remove lines 101 to 103
GraHal Yes sorry, I set up a link to a screen shot on my google drive and then I got locked into th...
gabri Here's the thread https://www.prorealcode.com/topic/multiframe-rsi-of-rsi/
Bernard13 Bonjour Nicolas, Pourriez-vous m'indiquer si cet indicateur fonctionne avec la V11 ? Le di...
Doctrading Hello, Higher timeframes are better. I suggest D1 or H4.Best regards,
Pinkybouh hello, I propose to add another conditions: ie: haussier: close > open and close >...
TheHovisTrader I'd be interested in the actual profit of this - in the example the stop range is at least 2...
Lyam Pareil ne marche pas dommage
ahmedbouaziz89 Bonjour, quand j'ajoute le code ou le fichier dans l'outils screeners de Prorealtime je ne v...
tyvix Bonjour le code marche bien c est juste qu'il n y a pas d opportunité au moment ou vous le...
Julio Hi Doctrading, Is it possible to flip this to a "going bearish" by simply switching the cod...
Doctrading Hello, Yes, you can do it very simply...
Tarek Laaroussi Hi doctrading i am the one who sent you the email first thanks for the code . It really wo...
pata_tony Hi, i'm not able to see the indicator. Could you please help me? Thanks
Nicolas This is not an indicator but a screener, to be used with the ProScreener module.
JOKAMAURICE Le programme ne se charge pas dans PRT
zilliq I think the "best"  method to backtest is  to do a simplier Walk forward backtest (and we ho...
volpiemanuele Hi, I have modified and optimized the strategy on FTSE 100 CASH Eur 1 on IG demo account. B...
RobHansson Thanks for this screener. I would like the tool removed the shares that have been on the lis...
davidspain hello doctor!! amazing job. I would like to ask u if it is possible to create an indicator ...
GABRIELE1976 bonjour, je voudrais utiliser ce screener pour trouver les titres qui, à l’ouverture de la j...
Doctrading
8 years ago
Gaps screener
Gaps screener
14
Screeners
jbox Bonjour,   Je souhaite affiché affiché les gap sur le graph des prix directement J'a...
owes29 Hi what do you find are the best settings for intraday trading regards Lee  
rille66 Hi doctrading. If you wan't to change the screener to register the gap open in realtime so y...
EAxelsson Hi, shouldn´t it be or instead of and? if FiftyTwoWeekHigh = FiftyTwoWeekHigh[1] OR FiftyTwo...
qigley Line 4 has a redundant term "Close>EMA2." is not necessary as EMA2 will always be less t...
Mike.44 Thanks It a good job !

Top