how to get volatility of last bar

Questions about MultiCharts and user contributed studies.
martingale
Posts: 91
Joined: 10 Dec 2010
Has thanked: 2 times
Been thanked: 1 time

how to get volatility of last bar

Postby martingale » 25 Jun 2019

in PEL, if i want to compare volatility of current bar with last bar, how do i code it?
do i have to add volatility as input or there is something like volatility(length) > volatility(length)[-1]

thanks

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: how to get volatility of last bar

Postby Henry MultiСharts » 02 Jul 2019

Hello martingale,

Check if the prebuilt Volatility function works for your calculation.
Store the value it calculates on each bar in a variable and compare the current variable value with the previous one.

martingale
Posts: 91
Joined: 10 Dec 2010
Has thanked: 2 times
Been thanked: 1 time

Re: how to get volatility of last bar

Postby martingale » 02 Jul 2019

Hello martingale,

Check if the prebuilt Volatility function works for your calculation.
Store the value it calculates on each bar in a variable and compare the current variable value with the previous one.
hi Henry
prebuilt volatility function works,
how to store them in each bar and reference the value in next bar?
thanks

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: how to get volatility of last bar

Postby ABC » 03 Jul 2019

martingale,

you can store the function's return value in a variable and use this variable within your code.

Code: Select all

Input: Length( 14 ) ; Variable: vVolatility( 0 ); vVolatility = Volatility( Length ) ; Plot1( vVolatility, "Volatility" ) ;
Regards,

ABC

martingale
Posts: 91
Joined: 10 Dec 2010
Has thanked: 2 times
Been thanked: 1 time

Re: how to get volatility of last bar

Postby martingale » 09 Jul 2019

is the vVolatility an array or just a scalar value in this case?
if i'd refer to vVolatility value of 10 bars ago, i can just use vVolatility(-10)?

thanks

martingale,

you can store the function's return value in a variable and use this variable within your code.

Code: Select all

Input: Length( 14 ) ; Variable: vVolatility( 0 ); vVolatility = Volatility( Length ) ; Plot1( vVolatility, "Volatility" ) ;
Regards,

ABC

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: how to get volatility of last bar

Postby ABC » 10 Jul 2019

martingale,

vVolatility is a variable and you can back reference previous bar's values for variables using a number in square brackets.

vVolatility[0] is the value on the current bar (although [0] is usually omitted), vVolatility[1] is the value one bar to the left of the current bar etc..

Regards,

ABC


Return to “MultiCharts”