Predicting the Lower Bollinger Band price?
Author: mgreco19
Creation Date: 3/19/2017 3:36 AM
profile picture

mgreco19

#1
Trying to figure out a way to predict the price of the lower bollinger band at open the next day. I can backtest using the below Rule8 but I'm aiming for a way to get the actual number that this might produce at open so I could use that as a condition in place of Rule8 below.

CODE:
Please log in to see this code.



Is there a way to code out the calculation of the lower bollinger band where bars 0-18 are used and bar 0 is used twice. I tried to convert something I had somewhere else into WLP but have only got this far and think I'm on the right track but not sure.

MiddleBB-2.5*SQR(((Close[bar]- MiddleBB)^2 +(Close[bar]- MiddleBB)^2 +(Close[bar-1]- MiddleBB)^2 +(Close[bar-2]- MiddleBB)^2 +(Close[bar-3]- MiddleBB)^2 +(Close[bar-4]- MiddleBB)^2 +(Close[bar-5]- MiddleBB)^2 +(Close[bar-6]- MiddleBB)^2 +(Close[bar-7]- MiddleBB)^2 +( Close[bar-8]- MiddleBB)^2 +( Close[bar-9]- MiddleBB)^2 +( Close[bar-10]- MiddleBB)^2 +( Close[bar-11]- MiddleBB)^2 +( Close[bar-12]- MiddleBB)^2 +( Close[bar-13]- MiddleBB)^2 +( Close[bar-14]- MiddleBB)^2 +( Close[bar-15]- MiddleBB)^2 +( Close[bar-16]- MiddleBB)^2 +( Close[bar-17]- MiddleBB)^2 +( Close[bar-18]- MiddleBB)^2 )/20)
profile picture

Eugene

#2
Here's your formula for the current bar as I understand it. You can get Open[bar+1] shortly after the market's open using Open.PartialValue or GetSessionOpen with providers that support it.
CODE:
Please log in to see this code.
profile picture

Eugene

#3
Or if you wish to make it more universal:

CODE:
Please log in to see this code.
profile picture

Cone

#4
Here's another way to look at it. If you're operating on the Open, then you should test that way too. Here's a mock-up that compares the predicted bband series using the Opening price with the bband using the Close for the same day. You can see how the "red" series is fairly accurately predicting the BBand for the next day. (Try using a short period to better see the effect.)

CODE:
Please log in to see this code.
profile picture

mgreco19

#5
Thanks! That worked as expected.

Is it possible to automate a strategy where you place a limit order only if Today's open is below Today's lower bollinger band? I realize the bollinger band moves throughout the day which is why I was trying to predict that value and can use that in place of the actual bollinger band as it would remain constant. I've included what I have below to when backtesting but always receive the below error message with every symbol. I'm assuming it is because of the Open[bar+1] and LowerBB[bar+1]. If I'm going about this the wrong way any suggestions are welcome.

Error processing symbol AAPL Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

CODE:
Please log in to see this code.
profile picture

Eugene

#6
Your assumption is correct. If it was that simple to use Open[bar+1] we would've suggested it, wouldn't we? If you review Cone's code carefully, you'll notice a pointer to GetSessionOpen in the QuickRef that makes possible to run this kind of strategy after market open.