Bollinger Bands - futures io
futures io



Bollinger Bands


Discussion in EasyLanguage Programming

Updated
    1. trending_up 2,685 views
    2. thumb_up 5 thanks given
    3. group 2 followers
    1. forum 5 posts
    2. 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)

 
Search this Thread
 

Bollinger Bands

(login for full post details)
  #1 (permalink)
sixhundread
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

Reply With Quote

Can you help answer these questions
from other members on futures io?
Market on Close data within IB
Platforms and Indicators
How do I create Strategy with the Second Entry indicator
NinjaTrader
Multi Time Frame High/Low/Median levels
NinjaTrader
Dissect open interest data
Crypto Futures
help with take profit several targets
TradeStation
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Is anyone actually making money?
123 thanks
ApexTraderFunding.com experience and review
11 thanks
Artificial Intelligence (AI) and Chat GPT
7 thanks
Dax market profile (FDAX, TPO)
7 thanks
Want your NinjaTrader indicator created, free?
7 thanks
 
(login for full post details)
  #2 (permalink)
sixhundread
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

Reply With Quote
 
(login for full post details)
  #3 (permalink)
 kevinkdog   is a Vendor
 
 
Posts: 3,464 since Jul 2012
Thanks: 1,827 given, 6,985 received



sixhundread View Post
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

Follow me on Twitter Reply With Quote
The following 3 users say Thank You to kevinkdog for this post:
 
(login for full post details)
  #4 (permalink)
 ShadowFox 
CO/USA
 
Experience: Intermediate
Platform: TradeStation, Multicharts
Trading: Stocks, Futures
 
ShadowFox's Avatar
 
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.

Visit my futures io Trade Journal Reply With Quote
The following 2 users say Thank You to ShadowFox for this post:
 
(login for full post details)
  #5 (permalink)
sixhundread
Vienna and Austria
 
 
Posts: 36 since Jul 2021
Thanks: 21 given, 7 received


ShadowFox View Post
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

Reply With Quote
 
(login for full post details)
  #6 (permalink)
sixhundread
Vienna and Austria
 
 
Posts: 36 since Jul 2021
Thanks: 21 given, 7 received


kevinkdog View Post
CurrentBar is a bar number, not a price.

Try using close instead of currentbar

i will try it thanks for your help!

Reply With Quote


futures io Trading Community Platforms and Indicators EasyLanguage Programming > Bollinger Bands


Last Updated on July 22, 2021


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
     



Copyright © 2023 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada), info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts