StockFetcher Forums · Filter Exchange · Bollinger Bands for a Custom Indicator....<< 1 2 >>Post Follow-up
chetron
2,817 posts
msg #60032
Ignore chetron
2/27/2008 7:52:39 PM

does anyone have something that takes a custom indictor to derive bollinger bands from,

for instance...

Fetcher[

set{var1,high + low}
set{median_price,var1 / 2}

add column median_price

draw median_price

]



i would like to use something like median_price, instead of close, to wrap in bollinger bands.

any ideas would be appreciated.
tia chet

nikoschopen
2,824 posts
msg #60034
Ignore nikoschopen
2/27/2008 10:35:06 PM

The Bollinger band formula consists of the following:

BOLU = Upper Bollinger Band
BOLD = Lower Bollinger Band

where
n = Smoothing Period
m = Number of Standard Deviations (SD)
SD = Standard Deviation over Last n Periods
Typical Price (TP) = (HI + LO + CL) / 3
(here replaced with (HI + LO) / 2)
BOLU = MA(TP, n) + m * SD[TP, n]
BOLD = MA(TP, n) - m * SD[TP, n]


(Source:Investopedia)

The following filter takes into account 2 standard deviation of the 20-day moving average of the "median": For some reason, however, it doesn't look right. I'm thinking the fault lies with the way the standard deviation is calculated by StockFetcher.

Fetcher[
set{Median,Day Position(0.5,1)}
Set{MA20,CMA(Median,20)}
set{SD,cstddev(MA20,20)}
set{SD20,2 * pow(SD,2)}
set{BOLU,MA20 + SD20}
set{BOLD,MA20 - SD20}

add column Median
add column MA20{MA(Median,20)}
add column BOLU
add column BOLD

draw MA20 on plot price
draw BOLU on plot price
draw BOLD on plot price
]



chetron
2,817 posts
msg #60035
Ignore chetron
2/27/2008 10:46:41 PM

thank you very much, niko




tomb
267 posts
msg #60062
Ignore tomb
2/29/2008 8:44:22 AM

Hi,

A couple notes on why your Custom Bollinger Band doesn't quite look right. First, on line 3 you are taking the standard deviation of the median line. According to your posted formula, it actually should be the standard deviation of the typical price, not the average of the typical price.

Next, you have placed a "pow(SD,2)" on line 4, I am not sure where that originates. Anyhow, below is a version that should produce a bit closer representation:

Fetcher[set{Median,Day Position(0.5,1)}
Set{MA20,CMA(Median,20)}
set{SD,cstddev(Median,20)}
set{SD20,2 * SD}
set{BOLU,MA20 + SD20}
set{BOLD,MA20 - SD20}

add column Median
add column MA20{MA(Median,20)}
add column BOLU
add column BOLD

draw MA20 on plot price
draw BOLU on plot price
draw BOLD on plot price
]



If you wanted, for verification, to see how these compare to the default Bollinger Bands on StockFetcher (we use "close" by default, instead of typical price.)

Fetcher[set{Median,close}
Set{MA20,CMA(Median,20)}
set{SD,cstddev(Median,20)}
set{SD20,2 * SD}
set{BOLU,MA20 + SD20}
set{BOLD,MA20 - SD20}

add column Median
add column MA20{MA(Median,20)}
and add column Median Bollinger Band(20) {refMedian20}
add column BOLU
and add column Upper Bollinger Band(20) {refUpper20}
add column BOLD
and add column Lower Bollinger Band(20) {refLower20}

draw MA20 on plot price
draw BOLU on plot price
draw BOLD on plot price
and draw Bollinger Band(20)
]



Tom




chetron
2,817 posts
msg #60063
Ignore chetron
2/29/2008 8:55:22 AM

thank you very much, tom

chet



stocktrader
294 posts
msg #60064
Ignore stocktrader
2/29/2008 9:38:42 AM


Fetcher[set{Median,Day Position(0.5,1)}
Set{MA20,CMA(Median,20)}
set{SD,cstddev(Median,20)}
set{SD20,2 * SD}
set{BOLU,MA20 + SD20}
set{BOLD,MA20 - SD20}
set{x,count(volume above volume 1 day ago,1)*2}
set{y,count(volume above average volume(90),3)}
set{z,x+y}
set{toptail,high-open}
set{bottail,close-low} and set{taildelta,bottail-toptail}

z is above 1.1
close has been decreasing over the last 3 days
close is between .1 and 5
low is below BOLU
count(close above open,3) is below 2.1
average volume(90) is above 100000

add column Median
add column MA20{MA(Median,20)}
add column BOLU
add column BOLD

draw MA20 on plot price
draw BOLU on plot price
draw BOLD on plot price

offset 0
]



nikoschopen
2,824 posts
msg #60065
Ignore nikoschopen
2/29/2008 11:49:38 AM

Tomb,

Thanks for the clarification. As for the "pow(SD,2)" on line 4, I dunno what happened. I guess I got tripped up while working with more than just one formula.

chetron
2,817 posts
msg #60067
Ignore chetron
2/29/2008 12:52:02 PM

another thought....

Fetcher[

Set{MA20,CMA(volume,20)}
set{SD,cstddev(volume,20)}
set{SD20,2 * SD}
set{BOLU,MA20 + SD20}
set{BOLD,MA20 - SD20}
set{varvol,volume}

draw varvol on plot varvol
draw MA20 on plot varvol
draw BOLU on plot varvol
draw BOLD on plot varvol

]



nikoschopen
2,824 posts
msg #60069
Ignore nikoschopen
2/29/2008 4:08:35 PM

Alright, bro, I fess up: I'm a slop. :^)

May this serve as a reminder to always double-check the damn filter before rubber-stamping it.

Cheers!

tomb
267 posts
msg #60074
Ignore tomb
2/29/2008 7:06:59 PM

Hi,

Certainly didn't mean to imply that anything was sloppy; quite the contrary, I have seen some great StockFetcher filters from you (and many others.) I had just noticed the mention of a potential problem with the standard deviation function and wanted to double-check that the bands could be recreated!

Tom




StockFetcher Forums · Filter Exchange · Bollinger Bands for a Custom Indicator....<< 1 2 >>Post Follow-up

*** Disclaimer *** StockFetcher.com does not endorse or suggest any of the securities which are returned in any of the searches or filters. They are provided purely for informational and research purposes. StockFetcher.com does not recommend particular securities. StockFetcher.com, Vestyl Software, L.L.C. and involved content providers shall not be liable for any errors or delays in the content, or for any actions taken based on the content.


Copyright 2022 - Vestyl Software L.L.C.Terms of Service | License | Questions or comments? Contact Us
EOD Data sources: DDFPlus & CSI Data Quotes delayed during active market hours. Delay times are at least 15 mins for NASDAQ, 20 mins for NYSE and Amex. Delayed intraday data provided by DDFPlus


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.