Code Z-Score Indicator

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #6898 quote
    tempiotrad
    Participant
    New

    Good evening, I ask politely if you can have the code for Z-Score.

    The formula is: (Close – Average close to n periods) / Standard Deviation to n periods.

    The indicator should show the lines at +2 (green) and -2 (red) standard deviations and the 0 level (which is when the Close = Average Close).

    Thanks in advance for the help

    #6910 quote
    Nicolas
    Keymaster
    Master

    Yes of course. Z-score.. I used to work a lot with it, I’m a ‘mean reverting theory’ lover.. 🙂

    n = 20
    avg=average[n](close)
    st = std[n](close)
    
    zscore = (Close-avg)/st
    
    RETURN zscore

    You can combine different n time horizons to compound a more precise deviation for instance. What is the purpose of this request? 🙂

    #6949 quote
    tempiotrad
    Participant
    New

    Good morning Nicolas, thanks for your response and your availability.

    The purpose of my request is to use the indicator to see when the prices are very far from the average, and then locate the probable turning points. In my opinion it works well especially when there are divergences with prices.

    I plan to also use it with other indicators … I’ll let you know.

    Kindly ask you if you can draw horizontal lines to +2 (green) and a – 2 (red) to see immediately when prices exceed the standard deviation

    #6956 quote
    Nicolas
    Keymaster
    Master

    What you are doing here is normalizing the bollinger bands indicator. Try to set a Bollinger bands on price and you’ll see the exact same informations (with n=20 of course). Though, Z-score is more convenient view I agree.

    To add these 2 lines, replace the last line of code with this :

    RETURN zscore, 2 coloured(0,255,0), -2 coloured(255,0,0)

    Have a nice day.

    #6957 quote
    tempiotrad
    Participant
    New

    Thank you very much Nicolas. I thank you also for your advice on BB. You’re really kind. If I let you know the news.Have a nice day

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

Code Z-Score Indicator


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
tempiotrad @tempiotrad Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by tempiotrad
9 years, 8 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 05/12/2016
Status: Active
Attachments: 1 files
Logo Logo
Loading...