New Members: Be sure to confirm your email address by clicking on the link that was sent to your email inbox. You will not be able to post messages until you click that link.

bollinger band width fn code is written wrong

The distance between two points in 3d space is always positive, hence it can not be calculated without using absolute value, unless you screwed up and wrote the code wrong, which is what they did. In trying to display the bbWidth of the bull bear spread: !AAIIBULL-!AAIIBEAR said chart is formed from bad data. Two questions. Since neither of the givens: !AAIIBULL or !AAIIBEAR are below -100, if I can shift these parameters up, +100 units, then the bbWidth will be properly displayed. Does someone know how to do this, or is there some other kludge that would work? Second question, since Talia at Stockcharts help, who responded to my question by kindly directing me here, made no note of any intent to write a work order to get the code fixed, so it works properly, it would be propitious if someone here knew how to do this, or knew someone to get it done. Absolute value functions in perl or c are not hard to work with, it merely needs to be inserted in the code so that it works properly.


Best Answer

  • markdmarkd mod
    Accepted Answer
    I don't know of any other syntax, but no harm in experimenting. There are some undocumented options.

    You might experiment with Price Channels to identify major turns, if that's your purpose. A reversal would tend to quickly follow a channel break - but note it would narrow timing, not entry prices.


  • Can you attach an image of the chart that's wrong? Maybe include the settings?
  • markdmarkd mod
    edited October 2019
    I think you are correct that the BBwidth function does not handle negative numbers correctly.

    It seems likely the BBwidth function would have been written originally for stocks (before difference charts were available), which do not trade to negative prices, so that case was not considered in the code.

    I can't think of too many situations where charts include negative numbers, except this one and in some indicators (and lately, some european and japanese interest rate charts). Also, I'm not sure there is a true theoretical justification for using the indicator as you suggest, although it is interesting. So, my guess is a request to modify stable code in a heavily used indicator for a situation few users encounter might be considered but would probably have to receive a low priority, considering the effort and expense and risk involved in writing, testing and incorporating the change, when weighed against more urgent upgrades and fixes and resources available.

    Nevertheless, it might be worthwhile to submit a suggestion to upgrade the BBwidth function, including as much information as you can, and a business-oriented justification. From my experience, suggestions are considered and prioritized and have been implemented, so it's worth a shot.
  • After working on this chart a little more, I think this is a better way to display it: I don't really need the bbWidth. Question Answered, thanks markd.

  • I should have looked for that option. Thank you.

  • Woops, here it is with the settings:

  • Yes it would have to be done in concert with other more important changes and then the testing and QA work wouldn't be spent on this tiny change, but the code is wrong. Is there some way I can shift the input parameters to make them positive as in:

    (!AAIIBULL+100) - (!AAIIBEAR+100)

    ...maybe a syntax I am unaware of " ' ` [ { ?
Sign In or Register to comment.