本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RicardoSantos
//@version=5
indicator(title='Multiple Frequency Volatility Correlation', shorttitle='MFVC', overlay=false)
// description:
// This is a complex indicator that looks to provide some insight
// into the correlation between volume and price volatility.
// Rising volatility is depicted with the color green while falling
// volatility is depicted with purple.
// Lightness of the color is used to depict the length of the window
// used, darker == shorter in the 0 -> 512 window range.
//
import RicardoSantos/ColorExtension/4 as colExt
// @function determines color and correlation level.
vc (window, smoothing) =>
float _price = ta.stdev(close, window)
float _vol = ta.stdev(volume, window)
float _cor = ta.correlation(_price, _vol, smoothing)
float _vol_filter = ta.rising(_price, 1) ? 100 : 300 // green : purple
float _win_filter = 25 + (window / 512) * 40 // higher value, lighter color
color _col = colExt.hsl(_vol_filter, 60, _win_filter, 20)
[_col, _cor]
//
int smoothing = input.int(10)
[c002, v002] = vc( 2, smoothing)
[c003, v003] = vc( 3, smoothing)
[c004, v004] = vc( 4, smoothing)
[c006, v006] = vc( 6, smoothing)
[c008, v008] = vc( 8, smoothing)
[c012, v012] = vc( 12, smoothing)
[c016, v016] = vc( 16, smoothing)
[c024, v024] = vc( 24, smoothing)
[c032, v032] = vc( 32, smoothing)
[c048, v048] = vc( 48, smoothing)
[c064, v064] = vc( 64, smoothing)
[c096, v096] = vc( 96, smoothing)
[c128, v128] = vc(128, smoothing)
[c192, v192] = vc(192, smoothing)
[c256, v256] = vc(256, smoothing)
[c384, v384] = vc(384, smoothing)
[c512, v512] = vc(512, smoothing)
array<float> data = array.from(
v002, v003, v004, v006, v008, v012, v016, v024, v032,
v048, v064, v096, v128, v192, v256, v384, v512
)
float min = array.min(data)
float max = array.max(data)
float avg = array.avg(data)
plot(series=v002, title='V002', color=c002, style=plot.style_circles)
plot(series=v003, title='V003', color=c003, style=plot.style_circles)
plot(series=v004, title='V004', color=c004, style=plot.style_circles)
plot(series=v006, title='V006', color=c006, style=plot.style_circles)
plot(series=v008, title='V008', color=c008, style=plot.style_circles)
plot(series=v012, title='V012', color=c012, style=plot.style_circles)
plot(series=v016, title='V016', color=c016, style=plot.style_circles)
plot(series=v024, title='V024', color=c024, style=plot.style_circles)
plot(series=v032, title='V032', color=c032, style=plot.style_circles)
plot(series=v048, title='V048', color=c048, style=plot.style_circles)
plot(series=v064, title='V064', color=c064, style=plot.style_circles)
plot(series=v096, title='V096', color=c096, style=plot.style_circles)
plot(series=v128, title='V128', color=c128, style=plot.style_circles)
plot(series=v192, title='V192', color=c192, style=plot.style_circles)
plot(series=v256, title='V256', color=c256, style=plot.style_circles)
plot(series=v384, title='V384', color=c384, style=plot.style_circles)
plot(series=v512, title='V512', color=c512, style=plot.style_circles)
plot(series=min, title='min', color=color.rgb(120, 123, 134, 40))
plot(series=max, title='max', color=color.rgb(120, 123, 134, 40))
plot(series=avg, title='avg', color=color.teal)