MEDIAN function coding

Forums ProRealTime English forum ProBuilder support MEDIAN function coding

Viewing 13 posts - 1 through 13 (of 13 total)
  • #62594
    DAK

    Hi everyone,

    I am working on an indicator trying to return the Median function instead of the classic Average one.

    For example the Median value of the 5 latest price records such as : Median (Price, 5)

    I haven’t seen any function of this type in ProRealTime or on the site’s topics so I tried to code it but can’t manage to get a correct result.

    Any help would be greatly appreciated. Thanks !

    #62605

    Please confirm this definition for a Median:

    Median :    which is the middle number of a group of numbers; that is, half the numbers have values that are greater than the median, and half the numbers have values that are less than the median. For example, the median of 2, 3, 3, 5, 7, and 10 is 4.

    #62608
    DAK

    Yes Nicolas I confirm this definition.

    Pretty hard to code…

    #62610

    Yes pretty hard without Arrays. Should be possible with a nested loop (first rough idea that come in mind).. let me think of it.

    #62643

    I solved this once with 2 nested for-loops.

    #62652

    @Despair

    Would save me time if you could share your code snippet with us. Thank you in advance.

    #62656

    I will of course do so but I can’t find it so far. :-S I will search again…

    #62659

    Found it 🙂

     

    2 users thanked author for this post.
    #62670
    DAK

    It works very well thank you guys for quick and helpful response !

    #173127

    Hi Nicolas,

    Have you worked out the Median function using arrays?

    Tnx in advance.

    #173148

    Actually I don’t think arrays are of much help in this case, because CLOSE is an array by itself (close[0], close[1], etc…). In any case you will have to always scan LENGTH bars (or elements) to get the MEDIAN.

     

     

    #173150

    What is the data set is not CLOSE?

    #173152

    Whatever tha data set, it is historicized (thus becoming an array).

    Be it MedianPrice, TypicalPrice, xClose (Heikin-Ashi close) or any expression assigned to a variable.

     

Viewing 13 posts - 1 through 13 (of 13 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login