繁体   English   中英

结合指标并修正到一个尺度

[英]Combining indicators and correcting to one scale

我试图将两个指标组合到一个面板中。

问题是,指标 A 的比例是 0 到 100,而指标 B 的比例是 -100 到 100

什么样的方程可以改变任一指标的最终值以匹配另一个? 最好以指标 A 的 0 到 100 的比例计。

谢谢

您可以使用此处描述的rescale()函数。

// ————— When the scale of the signal to rescale is known (bounded).
rescale(_src, _oldMin, _oldMax, _newMin, _newMax) =>
    // Rescales series with known min/max.
    // _src            : series to rescale.
    // _oldMin, _oldMax: min/max values of series to rescale.
    // _newMin, _newMin: min/max values of rescaled series.
    _newMin + (_newMax - _newMin) * (_src - _oldMin) / max(_oldMax - _oldMin, 10e-10)

如果您不知道最大值和最小值,可以使用normalize()函数。

// ————— When the scale of the signal to rescale is unknown (unbounded).
// Min/Max of signal to rescale is determined by its historical low/high.
normalize(_src, _min, _max) =>
    // Normalizes series with unknown min/max using historical min/max.
    // _src      : series to rescale.
    // _min, _min: min/max values of rescaled series.
    var _historicMin =  10e10
    var _historicMax = -10e10
    _historicMin := min(nz(_src, _historicMin), _historicMin)
    _historicMax := max(nz(_src, _historicMax), _historicMax)
    _min + (_max - _min) * (_src - _historicMin) / max(_historicMax - _historicMin, 10e-10)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM