Breakout of range Trading Strategy

Breakout of range Trading Strategy

Trading system “OUT OF THE RANGE”:
The system looks at the last X candles and determines which were the highest and lowest price values during this period. When the system is activated, it automatically add two pending stop orders on market: a long stop order at Y pips above the highest detected; a short stop order at Y pips below the lowest detected.

The idea is to have 2 pending stop orders placed below the detected high / low in order to enter the position if the price goes out of the range formed during the last X candles. If at the candlestick X + 1 one of the input stop order has not been executed, the system does not touch the pending orders.
NB: the system re-calculates the input stop levels according to the new X last candles. If at the candlestick X + 1 the system has executed an input stop, then the system remains inactive during X candles, so as not to re-position input stop commands which would be distorted by the last break of a Last up / down on the X + 1 last candles.
ALSO: the system might not succeed in positioning the new input stop if the candlestick X + 1 was closing at the new high / low.

Stop orders positioned at Y pips above / below the last up / down of the last X candles must be linked; That is, if one of the orders is executed, the other stop order of the waiting entry must be deleted. It is only after executing one of the input halts that the system then waits for the formation of X new candlesticks to reposition two input stop orders. NB: Without this condition, the system would be able to position 2 orders permanently all X candles even though there are already two stop orders of input already waiting …
The system has a time schedule: At the start time, the system starts counting X candles (and not it looks at the previous X). This is to prevent the system from counting candles on Friday one Sunday for example … At the end of the hour, the system no longer counts the candles. If two orders are waiting for execution, they are deleted. And if a trade is open, it remains because it has a fixed SL and TP anyway.

This trading strategy has been coded by a request on the French forum. Please consider that there is no typical settings and it is not dedicated to any instrument or timeframe at all. This strategy is almost like a “sandbox” for studying purpose and to define suitable parameters for your preferred instruments. Current default settings come from optimisation on EURUSD 5 minutes timeframe over last 20.000 bars only.

 

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. bluetime6 • 03/16/2017 #

    Hello Nicolas.
    Can i ask you for something?
    I backtested your strategy in Dax 4H Timeframe in this way
    //PRC_Out of the range TS | strategy
    //10.03.2017
    //Nicolas @ www.prorealcode.com
    //Sharing ProRealTime knowledge

    defparam cumulateorders = false

    // --- parameters

    Size = 1 //position size
    StopLoss = 60 //stoploss in points
    TakeProfit = 60 //takeprofit in points
    LookbackPeriod = 20 //lookback period to find highest high and lowest low (price range)
    PointsDistance = 5 //distance in points to add/substract from highest high or lowest low to put the pending stop orders
    // ------------

    if not onmarket and barindex-tradeindex(1)>=LookbackPeriod then
    BUY Size CONTRACTS AT highest[LookbackPeriod](high)+PointsDistance*pointsize STOP
    SELLSHORT Size CONTRACTS AT lowest[LookbackPeriod](low)-PointsDistance*pointsize STOP
    endif

    SET STOP PLOSS StopLoss
    SET TARGET PPROFIT TakeProfit

     
     
    The backtest brings around an +/- 0,00 Euro result. Is not really fine, but i see an interesting thing. The max drawdowin by 10.000 units testing is only -720 Euro. The losses in follow only 5 times!
    So the code above is likely suitabel to use with an martingale system (dangerous i know).
    So i hope you can put the martingale code snippet in the code above?
    kind regards
    blue
     
     

  2. Mirko borgna • 03/16/2017 #

    va bene anche france 40, ho modificato stoploss a 50 e takeprofit a 90

  3. Mirko borgna • 03/16/2017 #

    a 15m

  4. David29 • 03/16/2017 #

    Bonjour Nicolas,

    Merci pour ce code.

    L’avez-vous également pour CAC40 ? Ou sinon quels sont paramètres à modifier pour l’adapter au CAC40 ?

    Merci d’avance

    • Nicolas • 03/16/2017 #

      Tous les paramètres à modifier sont situés entre les lignes 8 et 16.

  5. carlo__ • 03/16/2017 #

    Hi Nicolas, sorry for the noob question. I want to test the script on stocks. Which are the right parameters to replace Size, StopLoss and TakeProfit assuming i would use the price % and number of shares?

    Thanks

    • Nicolas • 03/16/2017 #

      Change the stoploss and takeprofit value to percent ones. And change the SET TARGET PROFIT to SET TARGET %PROFIT , same for %LOSS.

  6. bertrandpinoy • 03/16/2017 #

    bonjour je suis novice dans les strategie, je test un code sur PRT et lorsqu il se declanche il ne precise pas de SL sur mon graph…qq un peu m expliquer? Merci cordialement

    • Nicolas • 03/16/2017 #

      si il n’y a pas de stoploss définit dans le code, alors c’est normal 🙂

  7. bertrandpinoy • 03/16/2017 #

    bonjour merci pour la réponse. Oui b sur … est il possible que le SL soit coder sous une autre forme?
    il s agit du code SP500 OPTIMIZER
    // Definición de los parámetros del código
    DEFPARAM CumulateOrders = true // Acumulación de posiciones desactivada

    // Condiciones para entrada de posiciones largas
    indicator1 = ExponentialAverage[24](MACDline[21,44,24](close))
    indicator2 = MACDline[21,44,24](close)
    c1 = (indicator1 = indicator4)

    indicator8 = close + 5
    ignored, ignored, indicator9 = CALL “MiIndicador(3)”(close)
    c6 = (indicator8 = indicator21)

    IF c1 AND c2 AND c6 and c11 THEN
    BUY 5 CONTRACT AT MARKET
    ENDIF

    // Condiciones de salida de posiciones largas
    ignored, indicator10, ignored = CALL “MiIndicador(3)”(close)
    c7 = (close CROSSES under indicator10)

    IF c7 THEN
    SELL AT MARKET
    ENDIF
    SET STOP pLOSS 100
    SET TARGET pPROFIT 60

    • Nicolas • 03/16/2017 #

      ok mais pourquoi poser la question ici ? Pour des questions non spécifique à cette article, il vaudrait mieux utiliser le forum, merci.

avatar
Register or

Likes

avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar
Related users ' posts
Brisvegas Thats Awesome thank you
Vinks_o_7 Thanks Vonasi !
ALE Very Very Nice
manel Hi - Many thanks for this and your other analytical codes, stellar work - very useful ! With...
Vonasi Good idea Manel. I have posted a new version here that shows results as a percentage: https:...
Paul the last update can be found in topic Strategy DayOpen Straddle for DAX on page 14.
bertrandpinoy l instruction GRAPH pose problème sur PRT... pas vous? cordialement
Nicolas Supprimer simplement les lignes avec GRAPH pour passer en ProOrder, trading live.
DanT01 Hi Nicolas, great work! Is it possible to contact you to help with a couple of indicators? T...
Nicolas Assistance is free on forums. For private job, you can contact me with the trading programmi...
avatar
Anonymous Thank you! I was reading the book Beyond Technical Analysis and wanted to try to coding RAV...
Juan Salas Hi FULVIO09, Nice piece of work. It seems to work very well. Does only work for INDEXES??...
Johann Hi @FULVI09, I understand the instructions however I'm not too sure how to determine the "p...
Player8520 Hello, It doesn't work with me either. However, I changed AA to 180 on line 15, added th...
fredfilm Hi Nicolas, how could we add a price screen to this? eg stock prices between $1 to $3 etc
Simba Greetings from germany! :) Can you told me your EXIT-strategy for this, please? :) Would ...
Eric If you have a high percentage winners and the trades are closed with take profit the spread ...
Casenova I Agree with you JaunJ, and Yes Eric, what you say makes sense too. Optimizing the Stop Loss...
ET Thanks for the system Casenova. In determining the high of the past 4 bars, is there a reaso...
ullle73 nicolas, can you somehome make this to be in the background of the price chart?
jonpt88 none did that yet right?
Nicolas You can ask for a code modification on forums, please open a new topic with your request.
ak5hay2 Works like crazy on bitcoin. Use different timeframes. Thanks a lot Doc!!!
richyowen Hi, great code thanks. Very new to this forum. Is there a way to add a 100point target on an...
lisamitch50 Morning all, Just backtested on quite a few instruments, worked well on backtesting, but tel...
reb Hello have you used this strat since last year ? live or Back test ? What are the results ?
beeb Yes last Year. But only back test
drysheep Hi all, did anyone test this strategy recently? As i dont get a single trade in the backt...
Nicolas
6 years ago
Nicolas Merci, faire une demande dans le forum approprié.
Pere Thanks for this good indicator Nicolas. I would like to make the upper and lower limits mor...
Nicolas because fractals are known 2 bars later! that's why I used rectangle to plot them in the past.
Nicolas
6 years ago
Trinity Impulse
Trinity Impulse
5
Indicators
ribou ah d'accord merci beaucoup
domenico nlevel1 non modifica la curva al variare del suo valore
tiger_man_no1 Very nice ; what is the best period input date for DAILY CHART ?
Alai-n Merci pour ce travail...
patmaba merci Alai-n. C'est ma première participation sur prorealcode, merci pour à toi pour ton co...
longtrade Can this be converted to a screener?

Top