Trading Articles
Article Categories
Article Tools
Bollinger Bands
Updated July 22, 2021
trending_up
2,685 views
thumb_up
5 thanks given
group
2 followers
forum
5 posts
attach_file
0 attachments
Welcome to futures io: the largest futures trading community on the planet, with well over 150,000 members
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to
register in order to view the content of the threads and start contributing to our community.
It's free and simple.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
(login for full post details)
#1 (permalink )
Vienna and Austria
Posts: 36 since Jul 2021
Thanks: 21 given,
7
received
I tried to code a bollinger strategy witch:
Sellshorts if the price hits the upper band,
covers if the price closes under the mid band,
buys if the price hits the low band,
sells if the price closes over the mid band.
this is the code i made:
Inputs: BandLen(20);
Vars: UpBand(0), LoBand(0), MidBand(0);
UpBand = Average(High, BandLen) + 2 * StdDev(High, BandLen);
LoBand = Average(Low, BandLen) - 2 * StdDev(Low, Bandlen);
MidBAnd = average(Close, BandLen);
If Marketposition = 0 and Currentbar < LoBand Then
buy Tomorrow at Open;
if Marketposition > 0 and Currentbar < MidBand Then
sell Tomorrow at open;
if marketposition = 0 and currentbar > UpBand Then
sell short Tomorrow at open;
if Marketposition < 0 and currentbar > MidBand Then
buy to cover Tomorrow at open;
but it really doesnt what i want.
can anyone explain why?
thanks a lot!
600
Can you help answer these questions from other members on futures io?
Best Threads (Most Thanked) in the last 7 days on futures io
(login for full post details)
#2 (permalink )
Vienna and Austria
Posts: 36 since Jul 2021
Thanks: 21 given,
7
received
Inputs: BandLen(20);
Vars: UpBand(0), LoBand(0), MidBand(0);
UpBand = Average(High, BandLen) + 2 * StdDev(High, BandLen);
LoBand = Average(Low, BandLen) - 2 * StdDev(Low, Bandlen);
MidBAnd = average(Close, BandLen);
If Marketposition <= 0 and Currentbar < LoBand Then
buy Tomorrow at Open;
if Marketposition = 1 and Currentbar > MidBand Then
sell Tomorrow at open;
if marketposition >= 0 and currentbar > UpBand Then
sell short Tomorrow at open;
if Marketposition =-1 and currentbar < MidBand Then
buy to cover Tomorrow at open;
also tried this... not working
(login for full post details)
#3 (permalink )
Posts: 3,464 since Jul 2012
Thanks: 1,827 given,
6,985
received
sixhundread
Inputs: BandLen(20);
Vars: UpBand(0), LoBand(0), MidBand(0);
UpBand = Average(High, BandLen) + 2 * StdDev(High, BandLen);
LoBand = Average(Low, BandLen) - 2 * StdDev(Low, Bandlen);
MidBAnd = average(Close, BandLen);
If Marketposition <= 0 and Currentbar < LoBand Then
buy Tomorrow at Open;
if Marketposition = 1 and Currentbar > MidBand Then
sell Tomorrow at open;
if marketposition >= 0 and currentbar > UpBand Then
sell short Tomorrow at open;
if Marketposition =-1 and currentbar < MidBand Then
buy to cover Tomorrow at open;
also tried this... not working
CurrentBar is a bar number, not a price.
Try using close instead of currentbar
The following 3 users say Thank You to kevinkdog for this post:
(login for full post details)
#4 (permalink )
CO/USA
Experience: Intermediate
Platform: TradeStation, Multicharts
Trading: Stocks, Futures
Posts: 116 since Jun 2020
Thanks: 69 given,
156
received
The first thing I see is the use of currentbar. Currentbar gives you the current bar count. Probably getting some interesting results with that one. You want to use "close" instead.
There are some interesting ways you can generate orders here. Tradestation runs a strategy once per bar, unless you have intrabarordergeneration turned on (which I highly suggest you stay away from). So on a daily bar it will only run the strategy once per day, but that doesn't mean you can't generate orders that might fill intraday. For instance, instead of waiting for a close outside a BB, you could use a limit order to fill at the BB which may hit intraday.
Alternatively on the exit, waiting for a close above the mid could be exchanged for a stop order at the mid once you are in a trade. Therefore it would fill intraday. Also if you set this kind of order when you fill your entry conditions it can trigger the same day. Meaning, currently if you fill a buy and the price climbs above the mid in the same day, you will not exit until tomorrow. With a stop placed at the same time as the buy you could exit in the same bar.
Just food for thought.
The following 2 users say Thank You to ShadowFox for this post:
(login for full post details)
#5 (permalink )
Vienna and Austria
Posts: 36 since Jul 2021
Thanks: 21 given,
7
received
ShadowFox
The first thing I see is the use of currentbar. Currentbar gives you the current bar count. Probably getting some interesting results with that one. You want to use "close" instead.
There are some interesting ways you can generate orders here. Tradestation runs a strategy once per bar, unless you have intrabarordergeneration turned on (which I highly suggest you stay away from). So on a daily bar it will only run the strategy once per day, but that doesn't mean you can't generate orders that might fill intraday. For instance, instead of waiting for a close outside a BB, you could use a
limit order to fill at the BB which may hit intraday.
Alternatively on the exit, waiting for a close above the mid could be exchanged for a
stop order at the mid once you are in a trade. Therefore it would fill intraday. Also if you set this kind of order when you fill your entry conditions it can trigger the same day. Meaning, currently if you fill a buy and the price climbs above the mid in the same day, you will not exit until tomorrow. With a stop placed at the same time as the buy you could exit in the same bar.
Just food for thought.
thanks!!!!!
I will try my best
(login for full post details)
#6 (permalink )
Vienna and Austria
Posts: 36 since Jul 2021
Thanks: 21 given,
7
received
kevinkdog
CurrentBar is a bar number, not a price.
Try using close instead of currentbar
i will try it thanks for your help!
Last Updated on July 22, 2021
Ongoing