Torben Moving Median

Torben Moving Median

Median filtering is a commonly used technique in signal processing. Typically used on signals that may contain outliers skewing the usual statistical estimators, it is usually considered too expensive to be implemented in real-time or CPU-intensive applications.

Let us define the median of N numerical values by:

  • The median of a list of N values is found by sorting the input array in increasing order, and taking the middle value.
  • The median of a list of N values has the property that in the list there are as many greater as smaller values than this element.

Example:

Torben’s method

This method was pointed out by Torben Mogensen.

It is certainly not the fastest way of finding a median, but it has the very interesting property that it does not modify the input array when looking for the median. It becomes extremely powerful when the number of elements to consider starts to be large, and copying the input array may cause enormous overheads. For read-only input sets of several hundred megabytes in size, it is the solution of choice, also because it accesses elements sequentially and not randomly. Beware that it needs to read the array several times though: a first pass is only looking for min and max values, further passes go through the array and come out with the median.

Credits to Fast median search: an ANSI C implementation.

PRT implementation

I have translated that C implementation by N. Devillard of Torben Mogensen algorithm in PRT, obtaining this moving median indicator:

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. yanntorp • 11/09/2020 #

    Bonjour,
    je souhaiterai savoir comment vous définissez la variable closedbar = t puisque cela me retourne une erreur.
    Merci pour votre aide.

    • Nicolas • 11/09/2020 #

      Le plus simple est de télécharger le fichier itf présent sur cette page et de l’importer dans la plateforme, vous aurez ainsi accès à toutes les fonctionnalités du code directement.

    • Daniele Maddaluno • 11/09/2020 #

      Le closedbar est simplement une variable de type boolean, et = t signifie qu’il est égal à true (c’est-à-dire checked box, 1).
      Cependant, il est beaucoup plus rapide d’importer le fichier “.itf”, comme l’a suggéré Nicolas.

      The closedbar is just a variable of type boolean, and = t means it is equal to true (i.e. a checked box, 1).
      However, it is much faster to import the “.itf” file, as Nicolas suggested.

  2. yanntorp • 11/09/2020 #

    merci pour vos réponses et le partage de ce code. Cela fonctionne très bien.

  3. Bruno Carnazzi • 11/09/2020 #

    GENIUS !

  4. AK27 • 11/09/2020 #

    Bonjour pensez vous qu’il est possible de creer un screener par rapport à cet indicateur, que le screener avertisse dès qu’une bougie validée clôture au dessus de la torben 20 par exemple 🙂

    • Daniele Maddaluno • 11/09/2020 #

      Bien sûr, vous pouvez écrire quelque chose comme ceci dans un screener:

      torben = CALL “Torben Moving Median”[20, 1](close)
      filter = close crosses over torben
      screener[filter]

    • AK27 • 11/09/2020 #

      merci Daniele vous êtes top, vous pensez qu’il est plus judicieux d’utiliser un screener de croisement de torben ou de franchissement du prix de la torben 20 ? je priorise le % de réussite au % de gain. 🙂

  5. AK27 • 11/09/2020 #

    Bonjour Daniele j’ai une idée d’indicateur qui va vous plaire je peux vous parler ou ? discord, twitter ? mail ?

  6. Daniele Maddaluno • 11/09/2020 #
  7. AK27 • 11/09/2020 #

    C’est payant visiblement sur linkdin je peux pas vous envoyer, discord vous avez ?

avatar
Register or

Likes

avatar avatar avatar avatar avatar avatar avatar
Related users ' posts
Doddge Hola Iván, ¿sería posible crear un screener que indique cuándo las velas coloreadas del indi...
RTR Ivan thank you for the pro-screener. I a trying to understand how to write the signals from ...
Iván Hi, Lines 62 and 63. These lines define buy and sell conditions.
Iván Hi You should delete from the indicator code all drawing functions and all variables not us...
Iván I've created a screener to show [longcondition or shortcondition]
Chrisinobi Hallo Ivan, Danke das ist Perfekt !! Kannst du bitte in der Screener-Bibliothek die itf. hoc...
MaoRai54 Thanks, now it's OK. in your first code at line 15-16 it's missing.
Madrosat Hello Ivan Did you try a strategy with this indicator
Iván Hi. No I didn't. This is a code translation requested by an user a few days ago.
Iván
1 year ago
cjr30 Simplemente modifica las lineas 19 y 21 por las siguientes: drawtext("▲",barindex,low-0.1*a...
groelandes Gracias!!
WhyAskOZ i copied the code into strategy and it gives error on line 21 and 23. it says " Line 1: ...
Iván
1 year ago
Madrosat Hello Ivan You have interesting topics on indicators , smart supertrend, optimised trend t...
Iván Hi! thanks. All of these codes are translations requested in the forum. I've on mind to back...
Raspete01 Buenos días Iván, estoy intentando llevar el código eliminando los colores y pasando un Back...
Iván
1 year ago
winnie37 Hi Ivan, if i want to use it, and call the oscillator value (in grey, green or red), how to...
Iván The oscillator is smoothtype. In inputs there is de lag to configure the output
ARLEQUIN49 Hello Ivan, Would it be possible to convert the code of this QQE MOD indicator which accomp...
ARLEQUIN49 here is the code: //@version=4 //By Glaz, Modified // study("QQE MOD") RSI_Period = i...
Iván Hi, Yes I can translate it but please, create a new topic for it.
Fgats quelques explications en Français ici : Some explanations in French here : https://www.p...
Nicolas Merci pour cette contribution, j'apprécie ! :)
Fgats Merci Nicolas pour ces encouragements et merci aussi pour le commentaire en Anglais accompa...
Alai-n I really like it when you develop ideas around price movement! I am much less a fan of all t...
elcortijoverde Muy buen trabajo.Intuitivo y claro.Gracias por tu dedicación y aportación.
Nicolas
2 years ago
B-Xtrender
B-Xtrender
8
Indicators
616248 Bonjour Nicolas, Peux tu nous expliquer le principe de fonctionnement ? Ou nous mettre un...
Nicolas Le lien vers l'article IFTA de l'auteur est dans le post déjà :)
P. Marlowe Very poweful indeed. It deserves close attention. I really appreciate very much IFTA backgro...
JS
2 years ago
Trendilo
Trendilo
1
Indicators
Coded1 very interesting indicator, thanks JS
Nicolas
2 years ago
Lucas0000 Hello, Congratulations on this programming, it seems incredible to me, I am new to this but ...
plbourse Hello, I am trying to use this singal (in fact I have converted it to an indicateur giving B...
manfeber Buenos dias,alguien me podria decir como se descargar el archivo o el indicador Q-Trend??,ya...
BriceE Bonjour Nicolas, Je suis a la recherche d'indicateurs pour me donner la meilleure indicatio...
Nicolas
2 years ago
Maxime Baudin Well done Nicolas, creative!
Stenozar Hi Nicolas, please can you explain how to read/use this indicator? thanks!
JC_Bywan For people interested in the screener: https://www.prorealcode.com/topic/screener-buy-sell-m...
octum Gracias NJicolas. Las lineas 35 y 36 dan fallo. (¿Es adrede para iniciados?) Puedes co...
mortezaali14 Salut Nicholas, comment exécuter ce fichier dans les métadonnées
Nicolas Yes, Magic if the variable that contains the value of the line, you can test if it goes up o...
dadah1987 Bonjour Nicolas, merci pour cet indicateur. Utilisant pour l'instant la création simplifié p...
Nicolas Merci d'ouvrir un sujet sur le forum avec une description complète du système.
GustavoLoboOrenstein Is it possible to add histogram with only increasing bars?

Top