NexusFi: Find Your Edge


Home Menu

 





Bollinger Bands


Discussion in EasyLanguage Programming

Updated
    1. trending_up 3,777 views
    2. thumb_up 5 thanks given
    3. group 2 followers
    1. forum 5 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
sixhundread
Vienna and Austria
 
Posts: 36 since Jul 2021
Thanks Given: 21
Thanks Received: 7

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 NexusFi?
CME Launches Bitcoin Volatility Futures June 1 -- First …
Cryptocurrency
Without Pulisic, USA 61.5% Live vs. Australia -- France …
Prediction Markets & Event Contracts
US Prop Firms Race Inside the CFTC Perimeter -- Tradeify …
Funded Trading Evaluation Firms
Iran War Prediction Markets: Ceasefire 16%, Ground Invas …
Prediction Markets & Event Contracts
Q1 2026 Shatters All Derivatives Volume Records -- CME H …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
196 thanks
Sober Journey With S&P
27 thanks
30 Sessions
20 thanks
Volume Indicators
8 thanks
BERN ALGOS algo trading journal
8 thanks
  #2 (permalink)
sixhundread
Vienna and Austria
 
Posts: 36 since Jul 2021
Thanks Given: 21
Thanks Received: 7

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
  #3 (permalink)
 kevinkdog   is a Vendor
 
Posts: 3,737 since Jul 2012
Thanks Given: 1,917
Thanks Received: 7,476



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 X Reply With Quote
  #4 (permalink)
 
ShadowFox's Avatar
 ShadowFox 
CO/USA
 
Experience: Intermediate
Platform: TradeStation, Multicharts
Trading: Stocks, Futures
Posts: 129 since Jun 2020
Thanks Given: 70
Thanks Received: 159

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 NexusFi Trade Journal Reply With Quote
Thanked by:
  #5 (permalink)
sixhundread
Vienna and Austria
 
Posts: 36 since Jul 2021
Thanks Given: 21
Thanks Received: 7


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
  #6 (permalink)
sixhundread
Vienna and Austria
 
Posts: 36 since Jul 2021
Thanks Given: 21
Thanks Received: 7


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




Last Updated on July 22, 2021


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts