MetaStock™ Zone Forum & FAQ Artykuły Linki Elliott Waves EasyLanguage™ Zone

A B C D E F G H I J K L M N O P R S T U V W Y Z #

Bollinger Band - Last Extreme

Another head-scratcher question:

Can someone show me a method of writing a formula that uses Typ() as the DA for a 20/2 Bollinger Band for all days PRIOR to a given bar, but for that bar's BB value, the BB calc would use the Open price for DA instead???

Second attempt for my previous Q: any way to access the Interval of a chart within an indicator, to base boolean decisions (or other math) on it???

Jim

Figured it out - just have to do it longhand - if anyone can come up with a faster way, esp if it avoids the expansion of the Std Dev calc, please let me know.

The following function finds the 20-bar, 2-SD Upper BBand based on 19 previous Typ()'s, and the current High. It uses the current Low for the Lower BBand, and the current Open for the middle.

Intended use: for backtesting, to simulate what the 20/2 BB would be using intraday "Last" value for the final daily bar, to see if an extreme-band crossover would occur when the day's value was at its extreme ...

One could adapt this for many other uses ...


Bollinger Band - Last-Extreme / for 20-bar, 2-SD

PSum := Ref(Sum(Typ(),19),-1);

MA := (PSum+High)/20;
SOS :=
Power(Ref(Typ(),-19)-MA,2) +
Power(Ref(Typ(),-18)-MA,2) +
Power(Ref(Typ(),-17)-MA,2) +
Power(Ref(Typ(),-16)-MA,2) +
Power(Ref(Typ(),-15)-MA,2) +
Power(Ref(Typ(),-14)-MA,2) +
Power(Ref(Typ(),-13)-MA,2) +
Power(Ref(Typ(),-12)-MA,2) +
Power(Ref(Typ(),-11)-MA,2) +
Power(Ref(Typ(),-10)-MA,2) +
Power(Ref(Typ(),-9)-MA,2) +
Power(Ref(Typ(),-8)-MA,2) +
Power(Ref(Typ(),-7)-MA,2) +
Power(Ref(Typ(),-6)-MA,2) +
Power(Ref(Typ(),-5)-MA,2) +
Power(Ref(Typ(),-4)-MA,2) +
Power(Ref(Typ(),-3)-MA,2) +
Power(Ref(Typ(),-2)-MA,2) +
Power(Ref(Typ(),-1)-MA,2) +
Power(High-MA,2);
HiSD := Sqrt(SOS/20);

MA := (PSum+Low)/20;
SOS :=
Power(Ref(Typ(),-19)-MA,2) +
Power(Ref(Typ(),-18)-MA,2) +
Power(Ref(Typ(),-17)-MA,2) +
Power(Ref(Typ(),-16)-MA,2) +
Power(Ref(Typ(),-15)-MA,2) +
Power(Ref(Typ(),-14)-MA,2) +
Power(Ref(Typ(),-13)-MA,2) +
Power(Ref(Typ(),-12)-MA,2) +
Power(Ref(Typ(),-11)-MA,2) +
Power(Ref(Typ(),-10)-MA,2) +
Power(Ref(Typ(),-9)-MA,2) +
Power(Ref(Typ(),-8)-MA,2) +
Power(Ref(Typ(),-7)-MA,2) +
Power(Ref(Typ(),-6)-MA,2) +
Power(Ref(Typ(),-5)-MA,2) +
Power(Ref(Typ(),-4)-MA,2) +
Power(Ref(Typ(),-3)-MA,2) +
Power(Ref(Typ(),-2)-MA,2) +
Power(Ref(Typ(),-1)-MA,2) +
Power(Low-MA,2);
LoSD := Sqrt(SOS/20);

MA := (Psum+(O+H+L)/3)/20;

MA + HiSD*2;
MA;
MA - LoSD*2

 

Source / From: TOP
Metastockusers[at]yahoogroups[dot]com

Equis and MetaStock® and MetaStock Professional® are registered trademarks of Equis International. Achelis Binary Wave®, The DownLoader®,
Expert Advisor®, OptionScope®, Quotecenter® and Smart Charts® are trademarks of Equis International, a Thomson Reuters company.

TradeStation® Pro, TradeStation® 2000i, OptionStation®, SuperCharts®, PowerEditor® and EasyLanguage®
are registered trademarks of TradeStation Technologies, Inc. Other names and marks referred to are the property of their respective owners.

All information provided on this website is for educational purposes only. Trading involves risk, including possible loss of principal and other losses.

Ten i inne materiały na tej stronie zostały zamieszczone zostały jedynie w celach edukacyjnych, nie ponoszę żadnej odpowiedzialno¶ci za ich stosowanie.

Gra na giełdzie i rynkach walutowych (FOREX) niesie ze sob± ryzyko poważnych strat finansowych!