PDA

View Full Version : Bollinger Band Squeeze Indicator (BBS)


jharonis
05-24-2011, 02:03 PM
I am looking for the Bollinger Band Squeeze Indicator for NT 7...
(BBS)

Anyone who could point me in the right direction??

thanks

NinjaTrader_RyanM
05-24-2011, 03:14 PM
Hello jharonis,

Thanks for the post and welcome to the NinjaTrader forums. If you dont find what you're looking for in the file sharing section (http://www.ninjatrader.com/support/forum/forumdisplay.php?f=37), consider a NinjaScript consultant (http://www.ninjatrader.com/partners#NinjaScript-Consultants) who can be hired to write indicator scripts for you.

Loukas
06-29-2011, 04:52 PM
Hi,
I am trying to create a costum indicator which will calculate the spread between of the Upper to Lower Bolinger Band. I have compiled the code and it is fine, however it doesnt show the indicator on a chart. Do you have any ideas about this issue? Please have a look at the code below

protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "BBSpread"));
BBSpread_chg = new DataSeries(this);
BBUpper_chg = new DataSeries(this);
BBLower_chg = new DataSeries(this);
CalculateOnBarClose = true;
Overlay = false;
}
if (CurrentBar < Period)
return;

BBLower_chg.Set(Bollinger(Close,2,14).Lower[0]);
BBUpper_chg.Set(Bollinger(Close,2,14).Upper[0]);
BBSpread_chg.Set(BBUpper_chg[0]-BBLower_chg[0]);

NinjaTrader_Bertrand
06-30-2011, 03:12 AM
Loukas, I only see you defining a BBSpread Plot, but never filling it with any values, the other data series are just series and not plots that would be visualized.

Loukas
06-30-2011, 01:28 PM
I am still working on how to present the indicator
BBSpread=BBSpread_chg

Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Line, "BBSpread_chg"));

NinjaTrader_Josh
06-30-2011, 03:28 PM
Loukas,

That is not enough code to create a plot. To create a plot requires multiple components. It may be easiest to see how these components are made by looking at a preexisting indicator. Please open up the MACD indicator and take a look at how there are multiple plots created in the Initialize() section. Then expand the Properties region of the code and take a look at the required components in there too. There is one for each plot. You will need to do similar in your own code.

Loukas
06-30-2011, 03:46 PM
Thanks, I have done the Spread and now I stuck with the EMA of Spread.
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot2"));

double emaBSpread = EMA((Bollinger(2,14).Upper[0]-Bollinger(2,14).Lower[0]),23);
Plot2.Set(emaBSpread);

At Properties I have the Plot2 as a dataseries

NinjaTrader_Bertrand
07-01-2011, 04:28 AM
That would not compile Loukas, please create a series holding the difference between the upper and lower values and then feed this series in your EMA.

Loukas
07-01-2011, 04:32 AM
Thanks Bertrand,

Which is the way to create a new indicator by combining two existing indicators ?

eg ROCema.Set(ROC(EMA(14)[0])) ;

NinjaTrader_Bertrand
07-01-2011, 04:47 AM
You're missing the ROC period here, for example the snippet below should compile well :

Value.Set(ROC(EMA(14), 14)[0]);

In general please work with Intellisense to guide you through the overloads available :

http://www.ninjatrader.com/support/helpGuides/nt7/intellisense.htm

Loukas
07-01-2011, 06:32 AM
I would like also to find the lowest value of EMA for the last 252 days.

double MEMA=(Math.Min(EMA,252)) ;

Is this correct or it finds the lowest value at that day?

NinjaTrader_Bertrand
07-01-2011, 06:37 AM
Sorry, my reply needs changing here, I missed the Math.Min in your code snippet:

For the mininum value of a series (your EMA here) please use the MIN() method instead.

Loukas
07-01-2011, 06:45 AM
Yes I applied it on daily Chart but I wondering if it takes the lowest value on the 252 day or it finds the lowest value from all these days

NinjaTrader_Bertrand
07-01-2011, 06:49 AM
It gives you the minimum value of the series over the full lookback, so the last 252 bars here.

hunter548
07-01-2011, 08:00 AM
Loukas,

You can also check out bigmiketrading. I saw a few BB Squeeze indicators there. You might find just what you need or maybe can get additional help.

http://www.bigmiketrading.com

Loukas
07-01-2011, 08:17 AM
Thanks Hunter for the suggestion, I have already looked at BigMikeTrading

Loukas
07-01-2011, 10:42 AM
Hi Bertrand,

The method MIN(TEMA, 252)[0] is very probably that I am looking for instead of Math.Min(..) but I cannot compile the code

double TEMA=((((Close[0]-EMA(13)[0])*0.6)+((Close[0]-EMA(23)[0])*0.3)+((Close[0]-EMA(55)[0])*0.1)));
double CEMA=(((100-0)/(MAX(TEMA,252)[0]-(MIN(TEMA,252)[0])))*(TEMA-MIN(TEMA,252)[0]));

Do you have any suggestion where the mistake is ? The program error indicate that I cannot convert from Double to DataSeries

NinjaTrader_Austin
07-01-2011, 11:03 AM
Loukas, you have set TEMA as a double variable and then try to use it in the MAX and MIN functions, which require a data series. Please see this reference sample for a demonstration of how to use data series to store an intermediate calculation (http://www.ninjatrader-support.com/vb/showthread.php?t=7299) to use in methods that expect a data series.

Loukas
07-01-2011, 11:46 AM
Thanks Austin, Could you give me any suggestion where is the mistake at the second dataseries

TEMA.Set(((Close[0]-EMA(13)[0])*0.6)+((Close[0]-EMA(23)[0])*0.3)+((Close[0]-EMA(55)[0])*0.1));
CEMA.Set(((100-0)/((MAX(TEMA,252)[0])-(MIN(TEMA,252)[0])))*(TEMA-(MIN(TEMA,252)[0])));

Plot0.Set(CEMA[0]);

The erro explanation is that I cannot apply "-" to dataseries and double.
Shall I make other 2 dataseries for MAX and MIN ?

NinjaTrader_Austin
07-01-2011, 11:48 AM
Loukas, the error is here: *(TEMA-(MIN.

The TEMA you're referencing there is still a data series, and you're trying to multiply the data series by a value, which won't work.

You can do this though:

CEMA.Set(((100-0)/((MAX(TEMA,252)[0])-(MIN(TEMA,252)[0])))*(TEMA[0]-(MIN(TEMA,252)[0])));

Note the [0] after the TEMA, which pulls the most recent value from TEMA, which is also a double value.

Loukas
07-01-2011, 12:03 PM
Great, Thanks Austin