Efficiency Ratio (Market Noise) by Alejandro P

BlueCapitalTrading · study · 25 行 · 点赞 280 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

//@version=4
//@author=© Alexter6277
study(title="Efficiency Ratio (Market Noise) by Alejandro P", shorttitle="Efficiency Ratio - AP", overlay=false, precision=2, resolution="")
 
ERLength = input(10, minval=1, title="Efficiency Ratio Length")
UseDirectional = input(false, title="Use Directional Efficiency Ratio",tooltip="If Use Directional Efficiency Ratio is \"true\" then the calculation will take into account the drection of the market moves and will have values of -100 to 100 while when it is \"false\" the basic ratio will be used with values between 0 to 100")
UseRelative = input(true,"Use Relative Color Markers", tooltip="By selecting to use Relaive Colors the script will change the color of the indicator values to show if the level is low, medium, high or extreme.",group="Relative Color")
ExtremeLevel = input(95.0, minval=0, maxval=100, title="% Extreme Level",group="Relative Color") 
HighLevel = input(50.0, minval=0, maxval=100, title="% High Level",group="Relative Color")
LowLevel = input(25.0, minval=0, maxval=100, title="% Low Level",group="Relative Color")
 
// Relative ATR Percent Function
EfficiencyRatio (source,length,driectional) =>
    netchange = driectional ? source - source[length] : abs(source - source[length])
    SumOfChanges = 0.0
    for i = 0 to length-1
        SumOfChanges := SumOfChanges + abs(source[i] - source[i+1])
    EffRatio = (netchange / SumOfChanges)*100
    EffRatio
 
ER = EfficiencyRatio(close,ERLength,UseDirectional)
 
clr = (ER >= ExtremeLevel or ER <= -ExtremeLevel) ? color.purple : (ER >= HighLevel or ER <= -HighLevel) ? color.green : (ER >= LowLevel or ER <= -LowLevel) ? color.blue : color.red
 
plot(ER, "Efficiency Ratio",style=plot.style_columns ,color = UseRelative?clr:color.blue)

← 返回列表