I want use Value Volatility as Input to Bollinger Band

I have Tried Following One . I gives error that BBand need Number and Vol is array

I want to use Vol of every bar particular bar as input to calculate Bband top of that bar .

Change= log(C/Ref(C,-1));/// ((C-Ref(C,-1))/C)*100;
volp=120;//optimize("vol prd",120,60,120,60);
VOL= StDev(Change,Volp)*100 ;
Band= Bbandtop(c,150,VOL);

Hi Rajan,

What you are referring to as Volatility here, is actually defined as ATR( Average True Range ).

BBandTop( ARRAY, periods = 15, width = 2 )
As explained, the third argument "width" is standard deviations using periods averaging range (ATR). So, the inbuilt BBandTop already incorporates the Volatility (in accordance to your definition). Would suggest you to play with 1st Argument - array and the 2nd Argument - period in order to formulate your desired goal.

It appears to me that you want to mix Historical Volatility and Bollinger Band. But these two are completely separate process of measuring Volatility (the rate of price fluctuations w.r.t. to historical time period).

1 Like

still i want to use it as input to width
can u pls help how can i code it

arr = ParamField( "Define Array", 4 );
bbPer = Param( "Bollinger Band Period", 14, 7, 252, 1 );
p = Param( "Vol. Period", 14, 7, 252, 1 );

prCh = ln( arr / Ref( arr, -1 ) );
vol = StDev( prCh, p, True );

Plot( C, "", colorDefault, styleCandle );
Plot( BBandTop( arr, bbPer, SelectedValue( vol ) ), "", colorDefault, styleLine );

thanx Lennon for support