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
Gaspare Ciao Ivan si puo' inserire una strategia su questo indicatore per ottimizzare le variabil...
larouedegann TIMEFRAME(15minutes) apparemment ne fonctionne pas
Iván Bonjour Je ne comprends pas bien le problème. L'indicateur fonctionne dans n'importe quelle...
larouedegann OUI je le sais, il fonctionne dans toutes les unités de temps. Mais je souhaite utiliser l'i...
lee Thank you!
jacquesgermain sì da aggiungere
Maik2404 auf welchen Wert muss ich die Kompresionsperiode stellen?
jacquesgermain — Période de compression : ce paramètre détermine la période de rétrospection utilisée pour ...
finplus Bonjour, une petite demande concernant cet indicateur : comment faire pour que lorsque la bo...
LucasBest Bonjour, la coloration des bandes se fait ligne 111 et 112 à l'aide des instructions colorbe...
YvesRobert Bonjour Nicolas, en effet ca marche, je me suis trompé, j'ai bien tout le tracé. C'est parce...
oliTR Bonjour, les conditions longCond et shortCond ne contiennent-elles pas une condition qui s'a...
xpe74 Utilitaire vraiment top, d'autant qu'ajouter des filtres de seuil peux aider a limiter le no...
Jiacky
2 years ago
Range Factor
Range Factor
0
Indicators
Sever
3 years ago
Stenozar Hi Sever, how can I visualize the coloured areas?
Sever Hi Stenozar, You need to add the color zones yourself , just go to Add Color Zone To set ...
Boris Hi IVMcm, thanks for your amazing work. I have tested all of your indicators and use some of...
IV Mcm With pleasure and thanks!
ashiash how to use this indicator can i use tradingview platform
Roland57800 Bonjour Noobywan, si je comprends bien l'utilisation de ce code que je trouve particulièr...
Noobywan Bonjour, quand la question a été posée dans le forum à celui qui avait fait la requête en am...
Fabian This Code draws only a retangle if the condition has been confirmed and NOT before (in that ...
Seabiscuit Hi! I like this indicator a lot, been using it on a 30 min timeframe and usually confirms my...
Ramahu Bonjour et merci pour cet indicateur ! je l'observe sur les actions du Nasdaq et la plupart ...
IV Mcm Line 68 and 70, you must delete the instruction at the end of the line "" Bordercolor(0,0,0,...
BoutDePain This instruction is for the V11 maybe that you are using V10.3 then you can safely remove it.
Protagonist Bonjour, Je vois l'instruction inRange mais je ne trouve pas sa signification. Pouvez-vous...
Manu L. Bonjour Nicolas, j'ai créé un screener avec l'aide à la prog en TF weekly mais je voudrai...
wtangsiri C'est exactement le même signal que donne le croisement et le décroisement de deux EMA (7 et...
PHAN100 bonjour, j'ai un bug sur le programme recopié prorealtime me dit qu'il y a un problème à ...
Nicolas
4 years ago
Nicolas La définition des couleurs se situent entre les lignes 94 et 118. Selon le type de bougie (h...
Manu35250 Bonjour Nicolas, Est il possible de convertir cet indicateur en screener ? J'essaie depui...
Nicolas Bien sûr, merci de formuler la demande dans le forum approprié en respectant les règles de p...

Top