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
RakeshPoluri I have a question about the bands on the candles. Is it bollinger bands or something else?
Nicolas I think that's 2 Bollinger Bands
Emperor.it "style(line,2)" C'è una guida ai parametri che si possono modificare ? Tipo stile della lin...
IV Mcm https://www.prorealcode.com/programming-with-prorealtime/
Nicolas C'est dans ce sujet: https://www.prorealcode.com/topic/trendline-une-approche-du-trading/ M...
Pensera Bonjour Nicolas, comment est-il possible de backtester cet indicateur? cela fait une erreu...
Nicolas Oui bien sûr, il doit y avoir pas mal de sujets dans le forum à ce propos.
Nicolas Il doit s'agir d'un mauvais copier/coller. Je suggère de télécharger le fichier itf contenu ...
Bard Hello @Nicolas, I can get this to display in a separate indicator panel but not on Price as ...
Stenozar Hi @Nicolas, how can I put the bands on price? Thanks, Stefano
Guillaume Mcm I gave the above message fix ;)
Tradingrob Is it possible to put the itf-file in the right way here in Prorealcode? so the right 'trend...
Guillaume Mcm Update link ;) https://www.prorealcode.com/topic/trend-histogramme-cci-mise-a-jour-suite-...
Screw27 Hi man, I installed the indicator and i don't know why but my graph it is so big
HelixKing sounds interesting I'll take a look
Godo Bonjour Souhait Sam, Après de nombreux essais pour le mettre en format afin d'utiliser ce c...
Nicolas Il faut supprimer celles qui existent dans la fenêtre d'optimisation et les créer en dur dan...
crusoe76 hi there, anyone can help making this strategy work, i have a message saying replace variabl...
Screw27 Salut nicolas j'aimerais savoir tes résulats grace a cettte methode
eva.g.forsgren It dose not work, I get a strap instead of candels???????????????????????????????????????????
Nicolas That indicator is the one below the chart. The indicator to put on the price chart is this o...
pyhrus P.S : IG , que j'ai contacté ,m'indique que la version V11 , ne sera pas disponible avant un...
Hasardeur Dear Nicolas, is there someting at the arry to modify in order to run the trend at the actu...
MALIMALO Dear Nicolas, just try touse your indicator with backtest but it's not working. is anybody...
ribes65 Bonjour Nicolas, Merci pour votre travail. Est-il envisageable de créer un screener pour ...
Nicolas Bien sûr, merci de formuler une demande dans le forum des screeners pour prorealtime. En res...
ipbvba Est il possible de le transformer en indicateur (pour ne plus avoir les lignes mais uniqueme...
Vinks_o_7 Vonasi you're a beast !!! ;-)))
pableitor Amazing indicator , you are pushing PRT to the limit! But looking at the scatter its not c...
supertiti Bonjour Nicolas, Je ne comprend pas bien , le trend change de couleur quand les prix sont a...
Nicolas Oui ce serait possible, cependant l'indicateur est bien prévu pour conserver la couleur de l...
supertiti Quand tu pourras si tu peux nous coder la troisième couleur cela améliorerait les trades cou...
Nicolas How to import file page: in the help section of the website explains howto
kenssa import through the indicator page/window in the Proreal time
chicoteca Buenas, no consigo que se me muestre en el chart de DAX. ¿Cómo procedo? Gracias.-
Bard Excellent job Vonasi, thanks very much for updating and improving your previous indicator.
Gianluca sorry but doesnt work like you posted
Vonasi You would need to let me know the exact instrument and time frame that you are trying to app...
frenqle Hi There.. It seems the TSL stop loss is not working.. it does not respond is that correct?
Ciccarelli Franco Per lasciare che la strategia venga eseguita (dopo aver importato il file): Basta eliminare...
JADINVEST Hello Jan, hello everyone, Thanks Jan for this strategy! Since 2020, have any of you found a...
Stockastiss Can this code be simply transferred into Backtestingcode so one doesnt need to use call ? (i...
Vonasi Sorry for the late reply. Add the code to your strategy and remove line 5 and line 39. Chang...
viktorthunss Hi! How many averages are there? Can I see the somewhere?
leofi https://www.prorealcode.com/topic/simple-average-with-visual-color/
leofi Go visit www.prorealcode.com/topic/simple-average-with-visual-color/ and watch 2em post
Dritan Hi,I am new on Prorealtime and coding.I downloaded the indi but I have it on a separate wind...
Nicolas Just add it on the price series.
yomisadiku Hello Nicolas, Can I use high and low price at lines hh=max(hh,close) and ll=min(ll,close) ...
Nicolas Yes you can do that, the impact will be that the trailing stop line will be much close to th...

Top