Value-at-Risk is a risk measurement tool widely used by banks and institutions.
This script uses historical simulation method for the calculation of VaR. The default settings are 250-days period. 1 percentile (or 99 percentile confidence level.) This means the daily loss for the past 250 days should not exceed the risk measure 99% of the time.
traders can calculate the desired level of risk by converting the timeframe OR by multiplying the square root (expected holding period) to find out the VaR value for 5 days, 25 days, 250 days etc.
Do take note that the default assumes a long position, if you are taking a short position, the percentile value has to be adjusted accordingly (to find the worst 1 percent loss for shorts will require changing the input to 99)