Meander Bands updated with ARRAYS

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #121107 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    I decided to explore the recent ARRAY support by ProRealTine v11 and I want to share my work.

    I modified the Meander Bands indicator (see v10.3 at https://www.prorealcode.com/prorealtime-indicators/meander-bands-thomas-stridsman/).

    It used just 5 periods because arrays were not supported in v10.3, thus making adding manual periods time consuming, tiring and error prone. Now I used the same 5 periods to compare the two, to make sure they both yield the same results.

    You can set more periods, if needed:

    // Meander Bands by Thomas Stridsman
    //
    // https://www.prorealcode.com/prorealtime-indicators/meander-bands-thomas-stridsman/
    //
    // March 3, 2020:    modified to use ARRAYS
    //
    //ONCE Periods    = 5
    //ONCE Deviations = 2
    ONCE    Middle    = 0
    ONCE    MeanderHI = 0
    ONCE    MeanderLO = 0
    MyAvg             = 0
    MyVar             = 0
    StDev             = 0
    FOR i = 0 TO (Periods - 1)
       $barO[i] = (Open[i] - close[i+1]) / close[i+1]
       $barH[i] = (High[i] - close[i+1]) / close[i+1]
       $barL[i] = (Low[i]  - close[i+1]) / close[i+1]
       $barC[i] = (Close[i]- close[i+1]) / close[i+1]
       //-------------- average price --------------------------------------
       Avg      = ($barO[i] + $barH[i] + $barL[i] + $barC[i]) / 4
       MyAvg    = MyAvg + Avg
    NEXT
    MyAvg = MyAvg / Periods
    //-------------- calculation of standard deviation ------------------
    FOR i = 0 TO (Periods - 1)
       MyVar = MyVar + ((square($barO[i] - MyAvg) + square($barH[i] - MyAvg) + square($barL[i] - MyAvg) + square($barC[i] - MyAvg)) / 4)
    NEXT
    //
    StDev = SQRT(MyVar / Periods)
    //
    Middle    = close * (1 + MyAvg)
    MeanderHI = close * (1 + MyAvg + (Deviations * StDev))
    MeanderLO = close * (1 + MyAvg - (Deviations * StDev))
    RETURN Middle AS "MeanderMiddle",MeanderHI AS "MeanderHigh",MeanderLO AS "MeanderLow"

    if you do not import the attached .ITF file, but prefer Copying & Pasting the code into ProBuilder v11, make sure lines 7-8 are uncommented.

    x-1.jpg x-1.jpg Meander-Bands-ARRAYS.itf
    #121117 quote
    NicolasNicolas
    Keymaster
    Legend

    Thanks for the update, that definitely shortened the original code! well done.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

Meander Bands updated with ARRAYS


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by NicolasNicolas
6 years, 7 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 03/04/2020
Status: Active
Attachments: 2 files
ProRealCode ProRealCode
Loading...