pine script
ShahBaz | جمعه, ۷ دی ۱۳۹۷، ۱۱:۱۹ ب.ظ
//@version=3
study(title="3MA-CD", shorttitle="3MA-CD")
// Getting inputs
fast_length = input(title="Fast Length", type=integer, defval=5)
slow_length = input(title="Slow Length", type=integer, defval=8)
//slowest_length = input(title="Slowest Length", type=integer, defval=14)
k = input(title="k-histogram", type=integer, defval=10)
d = input(title="d-gholle", type=float, defval=10)
src = input(title="Source", type=source, defval=close)
// Plot colors
col_grow_above = #26A69A
col_grow_below = #FFCDD2
col_fall_above = #B2DFDB
col_fall_below = #EF5350
col_macd = #0094ff
col_signal = #ff6a00
// Calculating
fast_ma = sma(src, fast_length)
slow_ma = sma(src, slow_length)
//slowest_ma =sma(src,slowest_length)
fast_ma2= (fast_ma -d)
macd =(fast_ma2 - slow_ma)*k
//(fast_ma*(d/100))
plot(macd, title="Histogram", style=area, color=(macd>=0 ? (macd[1] < macd ? col_grow_above : col_fall_above) : (macd[1] < macd ? col_grow_below : col_fall_below) ), transp=0 )
plot(fast_ma, title="Fast Length", color=col_macd, transp=0)
plot(slow_ma, title="Slow Length", color=col_signal, transp=0)
//plot(slowest_ma, title="Slowest Length", color=col_grow_below, transp=0)
study(title="3MA-CD", shorttitle="3MA-CD")
// Getting inputs
fast_length = input(title="Fast Length", type=integer, defval=5)
slow_length = input(title="Slow Length", type=integer, defval=8)
//slowest_length = input(title="Slowest Length", type=integer, defval=14)
k = input(title="k-histogram", type=integer, defval=10)
d = input(title="d-gholle", type=float, defval=10)
src = input(title="Source", type=source, defval=close)
// Plot colors
col_grow_above = #26A69A
col_grow_below = #FFCDD2
col_fall_above = #B2DFDB
col_fall_below = #EF5350
col_macd = #0094ff
col_signal = #ff6a00
// Calculating
fast_ma = sma(src, fast_length)
slow_ma = sma(src, slow_length)
//slowest_ma =sma(src,slowest_length)
fast_ma2= (fast_ma -d)
macd =(fast_ma2 - slow_ma)*k
//(fast_ma*(d/100))
plot(macd, title="Histogram", style=area, color=(macd>=0 ? (macd[1] < macd ? col_grow_above : col_fall_above) : (macd[1] < macd ? col_grow_below : col_fall_below) ), transp=0 )
plot(fast_ma, title="Fast Length", color=col_macd, transp=0)
plot(slow_ma, title="Slow Length", color=col_signal, transp=0)
//plot(slowest_ma, title="Slowest Length", color=col_grow_below, transp=0)
- ۹۷/۱۰/۰۷