TradingViewの移動平均乖離率のオシレータのサンプルスクリプトです。
◆サンプルスクリプト
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
//@version=4 study(title="Moving average deviation rate", overlay=false) //input _maPeriod = input(20, title="Moving average period") _deviationrate = input(15,title="deviation rate") //deviation rate _sma = sma(close, _maPeriod) _rate = (close - _sma) / _sma * 100 plot(_rate, color = color.red) _deviationupper = _rate > _deviationrate _deviationunder = _rate < _deviationrate * -1 bgcolor(_deviationupper ? color.red : color.white ) bgcolor(_deviationunder ? color.blue : color.white ) |