Select Page

# Bollinger Band 2 – Yearly Chart

Optuma Forums Optuma Scripting Bollinger Band 2 – Yearly Chart

• This topic has 2 replies, 2 voices, and was last updated 4 years ago by Leon.
Viewing 3 posts - 1 through 3 (of 3 total)
• Author
Posts
• #39215
Leon
• Topics: 2
• Replies: 1
• Posts: 3

Firstly, I know very little to do with Scripting so I’d appreciate your input to get me started. I would like to produce a script for a Bollinger Band (Bars 2) on a Yearly Chart where the  Bollinger Bands come within 5, 10,or 15% between the upper plot and the lower plot.   From this I could have Two separate scripts…..one with either 5%, one with 10% and one with 15% on  Quarterly & Yearly charts but the highest time frame in the Yearly chart is the strongest. I hope you can help me and I’ll attach examples where strong moves  are produced after the squeeze. Thinking out loud – Can a script be written so that it analyses Both Time Frames at once?…..or separately? Thanks in advance.

• This topic was modified 4 years ago by Leon.
#39239
Darren
• Topics: 66
• Replies: 667
• Posts: 733

Hi Leon,

The best place to start is with the Introduction to Scripting video series, which you can watch by signing in here. The language has been designed for non-programmers, so once you understand the logic you should be able to pick it up.

In your example, the difference between the upper and lower Bollinger Bands can be displayed in a tool called Bollinger Bandwidth. This basically takes the distance between the upper and lower bands and divides by the middle band.

Here’s your GE one year example showing both the 2 year Bollinger Bands and the Bandwidth tool: (38.05 – 18.10) / 28.08 = 0.71 (or 71%)

So for scripts for 5%, 10% and 15% you could add different coloured Show Bars for each value, using the BBW() function for the bandwidth.

Red (less then 5%) = BBW(BARS=2) < 0.05

Blue (between 5% and 10%) = BBW(BARS=2) > 0.05 and BBW(BARS=2) < 0.1

Green (between 10% and 15%) = BBW(BARS=2) > 0.1 and BBW(BARS=2) < 0.15

Note that these conditions will be calculated on the timeframe of the chart, so switching between quarterly and annual charts will automatically recalculate the Show Bar results.

If you wanted to create conditions for both timeframes it is possible to create formulas, such as this for both yearly and quarterly below 15%:

BBW(Year(PERIODAMOUNT=1), BARS=2) < 0.15 and BBW(Month(PERIODAMOUNT=3), BARS=2) < 0.15

Let me know what you think.

#39247
Leon
• Topics: 2
• Replies: 1
• Posts: 3

Hi Darren,

Thanks very much for your input. I did sign up to the Scripting video series and tried to work the correct formula to use without success but what you have done here has been of great help. I’ll do some work on it and see how it goes. Thanks again.

Leon

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