Supply & Demand – Order Blocks

Supply & Demand – Order Blocks

Hello PRC/PRT Community,

Below is a joint work between Nicolas (90%) and myself (10%) to convert Order Blocks code from TradingView. All credits go to Sonarlabs who made it available to the public.

For those who trade with Supply and Demand zones, this indicator could help you identify the zones where most likely there are unfilled orders left, which can be a magnet or Support and Resistance. It does not give signals, but it’s definitely a good complement with your Price Action tools. You need to pay attention how the price reacts to these zones, then take action and apply your own system.

You can change the “Sens” parameter to adjust to your Asset and Timeframe.

Above picture shows ES Futures on H4.

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. Razz • 09/14/2022 #

    Thank you Khaled and Nicolas for this great indicator I’ve been looking for something like this for a long time.

  2. Khaled • 09/14/2022 #

    The Graph has been screenshot over last weekend. Difficult to see the scale on the graph above, but there is a zone around 3940 detected by the indicator which served as support following yesterday’s flash crash on the ES (following release of CPI).

  3. ThaNoizy • 09/14/2022 #

    Hey, I can’t get any values from the indicator when I am backtesting, the indicator is supposed to show all order blocks in the past aaswell, right?

    • amiri • 100 days ago #

      bonjour Khaled pouvez vous me dire comment regler l’indicateur pour qu’il affiche les block avec la derniere bougie avant le mouvement et non pas avec l’avant derniere ou avant avant derniere bougie merci d’avance

  4. Barrabas15 • 09/14/2022 #

    It is not possible to modify the sensitivity as per the current code. In order to modify it, the “sens” parameter must be changed to another one in lines 22 (1st parameter, not 2nd), 29 and 36.

    • Khaled • 09/14/2022 #

      Sorry Barrabs, I didn’t get your point. Do you mean that we need to change manually “Sens” in lines 22, 29 and 36? For me, it works fine as it is.

  5. Barrabas15 • 09/14/2022 #

    With the current code I cannot change the sensitivity (try it anyway).
    I attach part of the code in which I have changed the parameter “sens” to “sensib” in lines 22, 29 and 36.
    This way I can change the sensitivity.

    sensib = sens/100 //ExponentialAverage[8](pc) //sens/100
    OBBullMitigation = close[1]
    OBBearMitigation = close[1]

    // If the ROC crossover our Sensitivty input – Then create a Bearish Order Block
    // Sensitivty is negative as this is a Bearish OB
    if pc crosses under -sensib then
    obcreatedbear = 1
    crossindexbear = barindex
    endif

    // If the ROC crossover our Sensitivty input – Then create a Bullish Order Block
    if pc crosses over sensib then
    obcreatedbull = 1
    crossindexbull = barindex
    endif

    • Khaled • 09/14/2022 #

      @Barrabas15 I see your point, but I have the same result with “Sensi “or “Sensib”.

  6. Barrabas15 • 09/14/2022 #

    With the original code the variable “sens” is useless. Even if you modify it, nothing changes.
    With the proposal that I indicate when changing the parameters of the variable, the supply/demand zones DO change.

    • Khaled • 09/14/2022 #

      I’ve tested with a large spectrum of values of “Sens” and you’re right, for certain values of “Sens”, it doesn’t show order blocks. However, when I replace “Sens” with “Sensb”, it shows new blocks. Well spotted. Thank you.

  7. ThaNoizy • 09/14/2022 #

    I am trying to make an algo around this indicator but it is hard because the indicator doesn’t provide any values? Could any of you help me with an example code to make the algo buy when price is inside the order block?
    Thanks

    • Khaled • 09/14/2022 #

      The concept of the Order Blocks is that Institutional come there to search for liquidity. Depending on your timeframe, the price may spend sometime there on a lower TF. The general idea is that you don’t trade Long or Short inside the Box. You wait for a breakout in either direction.

      I didn’t try to put a System together using Order Blocks, but you can try with the variables :
      a1) $top[j]
      a2 )$bottom[j]

      b1) $bottombull[jbull]
      b2) $topbull[jbull]

  8. ThaNoizy • 09/14/2022 #

    I tried your idea Khaled but got the error that says that j and jbull is undefined. do you think this is because the variable is defined in the indicator code and not the system code? Here is the code however:
    c4 = (close) < a1
    c5 = (close) > a2

    a1 = $top[j]
    a2 = $bottom[j]

    b1 = $bottombull[jbull]
    b2 = $topbull[jbull]

    c6 = (close) > b1
    c7 = (close) < b2

  9. jonpt88 • 09/14/2022 #

    This is a great indicator. Unfortunately, I have too much red and green colour in the chart already. How could I change the colour from lets say from green to light blue and from red to pink? Thank you so much for letting me know. Very much appreciated and sorry for such a question. Thank you for this great indicator again!

    • Khaled • 09/14/2022 #

      Hello Jonpt, to change the colors you need to go to lines 133 & 141 and change (“red”, transparency) and (“green”,transparency) with (r,g,b, transparency) codes you see better fit. You have the codes of the colors r, g and b available on this forum or just google RGB PINK and you will get (255,192,203). I hope this is clear enough.

  10. Barrabas15 • 09/14/2022 #

    Attached is a link with the colors you can use with their names. You only have to change in the code the words “green” and “red” by some name of any of the colors of the palette. https://www.prorealcode.com/documentation/coloured/

  11. Inconito75 • 09/14/2022 #

    hello traders,

    how to load it on my mt4 please?
    I downloaded but can’t find it in mt4 indicator

    • Nicolas • 09/14/2022 #

      Hello, we do not provide MT4 code on our website. You should use ProRealTime trading platform in order to benefit from our codes.

  12. larouedegann • 09/14/2022 #

    BRAVO
    très bon code pour ceux qui traident le volumes.
    pour ma part j’ai remplacer le 100 de la ligne 22 par un code créer dans les variables(celui que vous voulez ,NBR)
    ce qui évite de rentrer à chaque fois dans le code.

    • Khaled • 09/14/2022 #

      @larouedegann, this is what I’ve done on my PRT platform, but I put it here directly in the code to make it easier for those who will copy/paste the code instead of downloading the .itf 🙂

    • wtangsiri • 09/14/2022 #

      à quoi correspond le chiffre 100 ? et quelle valeur peut-on la remplacer ? Merci.

  13. AlexMarlier • 09/14/2022 #

    Hi PRC community, what is the code to add to limit the lenght of each rectangle drawn to 5 period (for example) ? Bonjour à toute la communauté, quel est le code à ajouter pour limiter la largeur des rectangles qui sont dessinés à 5 periodes (par exemple) ? Merci !

    • Khaled • 09/14/2022 #

      The idea is to be able to see the rectangle on the last candle. Therefore drawrectangle($leftbull[jbull],$bottombull[jbull],barindex,$topbull[jbull]) starts from where the Order Block has been detected to the last candles (Barindex). If you want to limit the the number of bars the either you do “barindex-x “(chose x) or “$leftbull[jbull]+y” (which in your case is 5).

  14. AlexMarlier • 09/14/2022 #

    Thanks so much Khaled for your help

  15. mataresc • 09/14/2022 #

    Hi , Thanks for sharing. Does it works in intra’day ? Also, is there any documentation about the concepts the indicator is based ?
    Thanks

    • Khaled • 09/14/2022 #

      It is supposed to work on all timeframes. However, the higher the TF, the more reliable the result. You need to adjust the “sens” factor and adapt it for each TF. I would suggest that you focus on a max of 3 TFs. For example, you can visit the weekly TF once per week and draw the zones so that they appear on lower TF, then move to visit Daily, H4 and H1 and draw the zones, then trade as per your system (e.g. M5) with these zones in mind. The idea of these order blocks is that it CAN play a role of Support/Resistance or magnet. I say CAN, because some of the zones may or may not attract new orders. Some of the zones become obsolete after a while, once all the big hands have finished their shopping or distribution at certain zones. I don’t have a specific documentation, but there are a lot of videos on Sypply/demand zones on youtube.

  16. Dron • 09/14/2022 #

    En que time frame es recomendable usarlo?

    • Khaled • 09/14/2022 #

      Sorry, I don’t speak Spanish 🙂

  17. Borja Sanz • 09/14/2022 #

    Thank you Khaled and Nicolas for this great indicator. Very helpfull. Great Job.
    I use it just as a guide for “hot” or relevants zones, so your predefined parameters are fine for me. CONGRATS!.

  18. SkySurferBlue • 09/14/2022 #

    Is there anything more I need to do for the indicator to show on the chart? I downloaded the file in this thread and imported it into ProRealtime v11. It has been added to a 4hr Gold chart but no colour bands are showing up.

    • Nicolas • 09/14/2022 #

      Add it on the price and it should be displayed.
      https://www.prorealcode.com/blog/video-tutorials/how-to-add-an-indicator-on-price-prorealtime/

  19. Erreerra • 09/14/2022 #

    Gracias por el indicador es magnífico. El problema es que me tarda muchísimo en cargar ¿hay alguna forma de que vaya más rápido?

  20. wtangsiri • 09/14/2022 #

    Could you show which “BOS” and which “CHoCH” making these Supply and Demand zone ? Thanks

    • Khaled • 09/14/2022 #

      Hi, I’m not expert in Arrays. If you master programming Arrays, I can share with you a code that is more complete and which shows BOS and CHoCH, etc.

  21. wtangsiri • 09/14/2022 #

    yes, please send to my email address : williamtangsiri@gmail.com
    I will do for you, one question, are the lines that you draw (Supply and demand zones) coming from Bos and CHoCH ? Thanks.

  22. wtangsiri • 09/14/2022 #

    @Khaled, c’est plus la peine, j’ai trouvé la solution, Merci Khaled !

    • Khaled • 09/14/2022 #

      C’est très bien. Tu pourrais partager ta solution avec nous stp? Merci

  23. Meelist • 09/14/2022 #

    Hi Khaled! Thanks for the great work. But question, do I understand correctly, that if I want to use it for example on 3 different timeframes simultaneously, then I should just create 3 different indicator files with different sensitivity? And by your experience so far, let’s say in futures (since that was your screenshot in the beginning), what would be the best sensitivities for example on weekly, daily, hourly (and perhaps even smaller) timeframes? Thanks!

    • Khaled • 09/14/2022 #

      Hi Meelist, good questions. What I personally do on weekly basis : 1) add the indicator on a chart (without other indicators) to see clearly, 2) navigate from weekly, down to 30 min, 3) draw rectangles of the high TF, then keep these drawings on the lower TF, but at certain time you will have too many zones. So it all depends on your style of trading, if you’re a scalper, the weekly zones would not be of much interest. You can adjust the sensitivity with your TF, but it doesn’t change a lot (at least for ES).

  24. Matchsolo • 09/14/2022 #

    Kalhed, ca ne serait pas possible de créer un robot de trading sur la base de ton travail ?
    C’est du super boulot

    • Khaled • 09/14/2022 #

      Je n’ai pas essayé, mais les zones ne sont pas des signaux de trading.

  25. fluvii • 09/14/2022 #

    Hi, Khaled!
    I’m trying to use it in PRT12 beta but it doesn’t work. In PRT11 works fine, but here I don’t understand why not. Could you please help me?
    Thank you in advance!

    • Khaled • 09/14/2022 #

      Sorry Fluvii, but I don’t have v12 yet.

  26. FabienEmmanuel • 09/14/2022 #

    Bonjour Khaled, Merci pour ce super code (et les autres) et aux commentaires qui m’on permis de modifier la sensibilité directement dans la boite de dialogue (Au départ j’avait modifier les paramètres dans le code..)
    C’est top avant Je passais mon temps à tracer les zone de supply et demand.. Et comme je trace encore certains BOS et ChoCh et que j’ai vu que vous pouviez éventuellement partager un code plus complet et qui montre BOS et CHoCH, etc.
    J’en serais ravi moi de le recevoir !! n’ayant pas vraiment trouvé mon bonheur dans PRC
    Cordialement

  27. FabienEmmanuel • 09/14/2022 #

    Mon Email: fabien.emmanuel35@gmail.com

  28. Ha • 09/14/2022 #

    Hello

    Thank you for sharing the code.
    Your indicator doesn’t work properly.
    No zones are printed on chart, instead I get an indicator window on the bottom that has a single straight line.
    Can you please tell me how to fix it?

    Regards,

  29. Crillezz • 09/14/2022 #

    Hello Khaled!!
    Is it possible to build a screener of the indicator when the price returns to a supply/demand zone?

    • alb3rt1 • 248 days ago #

      I join the request to create if is it possible to build a screener based on the indicator when the price entering the supply/demand zone?
      Thanks

    • pintris • 32 days ago #

      Hi, same request. Could someone help in creating a screener for this great indicator that screens the stocks when the price enters this red/green “blocks” that this indicator created ? Many thanks

  30. Bodaris • 110 days ago #

    Bonjour, Merci pour ce super code que je n’aurais su faire moi-même, TOP. Je me demandais, s’il serait pertinent d’avoir une variable “sens” dynamic” pour que cela colle au plus près à la spécificité de chaque actif ? Je sais pas si je me suis bien exprimé ?

avatar
Register or

Likes

avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar avatar

+27 more likes

Related users ' posts
Carlos Garcia If price tags the lower BBand, look for IIIX has positive values to enter a trade. Converse...

Top