BB2H on 15min TF

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #95999 quote
    stefou102
    Participant
    Veteran

    Hello,

    I’m looking to display the bollinger bands of the 2H TF on a 15min chart. I was able to draft the code here below, but calculation is off a few points vs the actual values and I can’t find why. Maybe someone could see if there is an error in my code.

    DEFPARAM CalculateOnLastBars = 1000
    
    //taking the close every 2H
    IF hour <> hour[1] and (hour=1 or hour = 3 or hour = 5 or hour = 7 or hour = 9 or hour = 11 or hour = 13 or hour = 15 or hour = 17 or hour = 19 or hour = 21 or hour=23) THEN
    
    H2close = close
    
    //taking the current price into account also
    if currenttime+10000-opentime<1499 and date=today then
    H2close = close
    endif
    
    
    
    BBDown = Average[160](H2Close)-2.5*std[160](H2Close)
    BBUp = Average[160](H2Close)+2.5*std[160](H2Close)
    
    
    
    RETURN BBDown,BBUp
    

     

    Thank you in advance,

    #96020 quote
    Nicolas
    Keymaster
    Master

    Because you want to make an average of a non linear data serie.

    160 times the value of H2Close doesn’t mean that you are using 160 different values of it, because the data array of your H2Close is linear, it means that it follows the time passing by with the bar counts.

    #96037 quote
    Vonasi
    Moderator
    Master

    You could create a dummy MTF strategy and use GRAPHONPRICE to draw the 2 hour time frame Bollinger bands on a faster time frame if it is just an indicator that you want rather than a coding challenge!

    #96039 quote
    stefou102
    Participant
    Veteran

    Indeed Nicolas. How can I do to go through the last 160 values, and only store the 20 unique values that matters?

    #96045 quote
    Nicolas
    Keymaster
    Master

    With a loop and some headaches, it is possible without variables arrays, but not the best solution around.

    You should have a look at examples made with GRAPHONPRICE, like Vonasi said, here: GRAPHONPRICE

    #96161 quote
    stefou102
    Participant
    Veteran

    Thx Nicolas and Vonasi for your remarks. Graphonprice is cool but I would prefer to keep my screens light, and I usually use a small segment on the right side to display different level of price from higher TF. So I will give a try. I haven’t seen a post with the kind of loop required, so if you have an idea..

    #99263 quote
    stefou102
    Participant
    Veteran

    Thx you again for your remarks, after some headaches, I finally found a way to code it.

    #99266 quote
    Vonasi
    Moderator
    Master

    I finally found a way to code it.

    Care to share it? The code might be of interest to others trying to do the same thing.

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

BB2H on 15min TF


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
stefou102 @stefou102 Participant
Summary

This topic contains 7 replies,
has 3 voices, and was last updated by Vonasi
6 years, 10 months ago.

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