Help with Code Bollinger bands

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

    HI All

    Firstly i want to be upfront i have no idea how to code! I would like to have an indicator when the upper and lower bollinger band 3SD is hit on a 5 min,10 min 15, min and hourly chart all at the same time ie across a number of time frames . So could be say 5,10 & 1 hour and another for 5,15 & 1 hour etc same for the lower bollinger band 3SD. If we could tie it in with RSI over say 65 or below 30 on the lower band that would also be beneficial.

    This would tell me when the market is short term over stretched – Ideally i would like to get an alert when this happens as well. I would use this for trading index futures such as FTSE, DOW SPX etc . Feel free to contact me. Thank you Dominic

    #108970 quote
    robertogozzi
    Moderator
    Master

    ProBuilder does not support Multiple Time Frames, so it is impossible to make an indicator with more than one TF, the only one supported is the one on the chart where it’s been added.

    So you need to open more charts at the same time, each one with different TF, then set an alert or use a screener to accomplish what you want.

    Will this meet your goals?

    #108972 quote
    Dominicg01
    Participant
    New

    HI Roberto

     

    Thank you for getting back to me.  So what you are saying is I could have an alert per time frame essentially and we would need the same code on all the time frames.  So the same piece of code say on the 5 min, 10min,15 min and 1 Hour. that would probably work as if i got an alert from all time frames at the same time it would give me what i am looking for. Coudl i also tie it in with RSI reading above or below certain reading? Thanks dom

    #109056 quote
    robertogozzi
    Moderator
    Master

    Here’s the code:

    BBper  = 20                                                //20   periods
    BBdev  = 3.0                                               //3.0  deviation
    BBavg  = average[BBper,0](close)                           //BB mean (middle line)
    BollUP = BBavg + ((std[BBper](close)) * BBdev)             //BB Upper Band
    BollDN = BBavg - ((std[BBper](close)) * BBdev)             //BB Lower Band
    UPhit  = high >= BollUP
    DNhit  = low  <= BollDN
    MyRSI  = Rsi[14](close)
    RsiOB  = MyRSI > 65
    RsiOS  = MyRSI < 30
    LongCond  = UPhit AND RsiOB
    ShortCond = DNhit AND RsiOS
    RETURN LongCond AS "Long", -ShortCond AS "Short"

    unfortunately PRT doesn’t allow to set more than 5 conditions for an alert, so if you need 3 different TF’s you’ll have to set two conditions for two of them and only one for the third TF. In your case you only need ONE condition per TF, since the above indicator returns a signal when BOTH Rsi and Bollinger Bands return valid signals.

    You’ll have to create two different alerts, one for LONG conditions and one for SHORT conditions.

    Anyway, this is a screener that returns a valid scan with a beep:

    TIMEFRAME(1 hour)
    BBper1  = 20                                                //20   periods
    BBdev1  = 3.0                                               //3.0  deviation
    BBavg1  = average[BBper1,0](close)                          //BB mean (middle line)
    BollUP1 = BBavg1 + ((std[BBper1](close)) * BBdev1)          //BB Upper Band
    BollDN1 = BBavg1 - ((std[BBper1](close)) * BBdev1)          //BB Lower Band
    UPhit1  = high >= BollUP1
    DNhit1  = low  <= BollDN1
    MyRSI1  = Rsi[14](close)
    RsiOB1  = MyRSI1 > 65
    RsiOS1  = MyRSI1 < 30
    //
    TIMEFRAME(15 minute)
    BBper2  = 20                                                //20   periods
    BBdev2  = 3.0                                               //3.0  deviation
    BBavg2  = average[BBper2,0](close)                          //BB mean (middle line)
    BollUP2 = BBavg2 + ((std[BBper2](close)) * BBdev2)          //BB Upper Band
    BollDN2 = BBavg2 - ((std[BBper2](close)) * BBdev2)          //BB Lower Band
    UPhit2  = high >= BollUP2
    DNhit2  = low  <= BollDN2
    MyRSI2  = Rsi[14](close)
    RsiOB2  = MyRSI2 > 65
    RsiOS2  = MyRSI2 < 30
    //
    TIMEFRAME(5 minute)
    BBper3  = 20                                                //20   periods
    BBdev3  = 3.0                                               //3.0  deviation
    BBavg3  = average[BBper3,0](close)                          //BB mean (middle line)
    BollUP3 = BBavg3 + ((std[BBper3](close)) * BBdev3)          //BB Upper Band
    BollDN3 = BBavg3 - ((std[BBper3](close)) * BBdev3)          //BB Lower Band
    UPhit3  = high >= BollUP3
    DNhit3  = low  <= BollDN3
    MyRSI3  = Rsi[14](close)
    RsiOB3  = MyRSI3 > 65
    RsiOS3  = MyRSI3 < 30
    //
    TIMEFRAME(default)
    LongCond  = (UPhit1 AND RsiOB1) AND (UPhit2 AND RsiOB2) AND (UPhit3 AND RsiOB3)
    ShortCond = (DNhit1 AND RsiOS1) AND (DNhit2 AND RsiOS2) AND (DNhit3 AND RsiOS3)
    x = 0
    IF LongCond THEN
       x = 1
    ELSIF ShortCond THEN
       x = 2
    ENDIF
    SCREENER[x](x AS "1=↑,2=↓")
    Pic1.jpg Pic1.jpg Pic2.jpg Pic2.jpg Pic3.jpg Pic3.jpg pic4.jpg pic4.jpg Pic5.jpg Pic5.jpg Pic6.jpg Pic6.jpg
    #109158 quote
    Dominicg01
    Participant
    New

    Wow thanks Roberto that is very kind of you ! Sorry i didn’t get back to you yesterday, i was offline all day. Let me play around with this over the next few days and I’ll revert back to you. Once again many thanks Dom

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

Help with Code Bollinger bands


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Dominicg01 @dominicg01 Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by Dominicg01
6 years, 4 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 10/01/2019
Status: Active
Attachments: 6 files
Logo Logo
Loading...