Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 01:28
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Ayumi), 838 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Using 2 Bollinger Bands #409477
10/18/12 06:46
10/18/12 06:46
Joined: Sep 2012
Posts: 99
T
TankWolf Offline OP
Junior Member
TankWolf  Offline OP
Junior Member
T

Joined: Sep 2012
Posts: 99
Hi All,

Im currently having trouble figuring out how Im to achieve the following. Basically I want to have 2 bollinger bands. The first set being 1 deviation away and the 2nd set being 2 deviations away.

var *BBand1 = series(BBands(Close,19,1,1,MAType_SMA));
var *BBand2 = series(BBands(Close,19,2,2,MAType_SMA));

Quote:

BBands(var* Data, int TimePeriod, var NbDevUp, var NbDevDn, int MAType): var
Bollinger Bands. Consist of three lines; the middle band is a simple moving average (generally 20 periods) of the typical price (TP). The upper and lower bands are n standard deviations (generally 2) above and below the middle band. The bands widen and narrow when the volatility of the price is higher or lower, respectively. Bollinger Bands indicate when the price has become relatively high or low, which is signaled through the touch or minor penetration of the upper or lower line. Returns: rRealUpperBand, rRealMiddleBand, rRealLowerBand. Parameters: NbDevUp (Deviation multiplier for upper band), NbDevDn (Deviation multiplier for lower band), MAType (Type of Moving Average).


Now as it says above the BBands function returns 3 variables: "rRealUpperBand, rRealMiddleBand & rRealLowerBand". My question is if I use two bollinger deviations how do I call both the variables for BBands. I can get it to work easily if I just use one set of bollinger bands but when I use two does the 2nd BBands function return different names than "rRealUpperBand, rRealMiddleBand & rRealLowerBand"?

Hope this makes sense...

Re: Using 2 Bollinger Bands [Re: TankWolf] #409483
10/18/12 08:32
10/18/12 08:32
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Use a second set of variables:

Code:
BBands(Close,19,1,1,MAType_SMA)); 
var *BBAnd1Upper = series(rRealUpperBand);
var *BBAnd1Lower = series(rRealLowerBand);
BBands(Close,19,2,2,MAType_SMA));
var *BBAnd2Upper = series(rRealUpperBand);
var *BBAnd2Lower = series(rRealLowerBand);



Re: Using 2 Bollinger Bands [Re: jcl] #409493
10/18/12 10:47
10/18/12 10:47
Joined: Sep 2012
Posts: 99
T
TankWolf Offline OP
Junior Member
TankWolf  Offline OP
Junior Member
T

Joined: Sep 2012
Posts: 99
Ok thanks makes sense. Though just out of curiousity would it work also if you just used the following:

Quote:

var *BBand1 = series(BBands(Close,19,1,1,MAType_SMA));


Then to get the 2nd deviation away you could do this for example?

Quote:

if(priceClose() > ((rRealUpperBand - rRealMiddleBand) + rRealUpperBand))


In theory you should be able to get the distance between the upper and middle band and just add it to the upperband price again to get the 2nd deviation away correct?

Re: Using 2 Bollinger Bands [Re: TankWolf] #409497
10/18/12 12:12
10/18/12 12:12
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Yes, BBands returns rRealUpperBand, so your code is correct, and as I see it you also get correctly twice the deviation in your example.


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1