study("MT", overlay=true)
ma_1 = input(title="ma_1", type=input.integer, defval=28, minval=1)
ma_2 = input(title="ma_2", type=input.integer, defval=144, minval=1)
method = input(title="method", type=input.integer, defval=3, minval=0, maxval=3)
_price = input(title="price", type=input.integer, defval=0, minval=0, maxval=6)
signal = input(title="signal", type=input.integer, defval=14, minval=1)
s_method = input(title="s_method", type=input.integer, defval=0, minval=0, maxval=3)
signal2 = input(title="signal2", type=input.integer, defval=70, minval=1)
s_method2 = input(title="s_method2", type=input.integer, defval=0, minval=0, maxval=3)
price = 0.0
GetMA(_src,_period,_method) =>
var _value = 0.0
if method==0
_value := sma(_src,_period)
if method==1
_value := ema(_src,_period)
if method==2
_value := rma(_src,_period)
if method==3
_value := wma(_src,_period)
_value
if(_price==0)
price := close
if(_price==1)
price := open
if(_price==2)
price := high
if(_price==3)
price := low
if(_price==4)
price := (high+low)/2.0
if(_price==5)
price := (close+high+low)/3.0
if(_price==6)
price := (2.0*close+high+low)/4.0
dgts_2f(n) =>
c=0
d=0.0
d:=abs(n)
d:=d-floor(d)
for i=0 to 42
if ( d==0 )
break
d:=d*10
d:=d-floor(round(d))
c:=c+1
ExtMapBuffer1 = GetMA(price,ma_1,method)
ExtMapBuffer2 = GetMA(price,ma_2,method)
MACD_Map = ExtMapBuffer1 - ExtMapBuffer2
SignalMap = GetMA(MACD_Map, signal, s_method)
SignalMap2 = GetMA(MACD_Map, signal2, s_method2)
SignalLine = ExtMapBuffer2 + SignalMap
SignalLine2 = ExtMapBuffer2 + SignalMap2
plot(SignalLine, title="SignalLine", color=color.yellow, linewidth=2, style=plot.style_line, transp=00, offset=0, trackprice=false)
plot(SignalLine2, title="SignalLine2", color=color.aqua, linewidth=2, style=plot.style_line, transp=00, offset=0, trackprice=false)
Ext1 = plot(ExtMapBuffer1, title="ExtMapBuffer1", color=color.blue, linewidth=1, style=plot.style_line, transp=00, offset=0, trackprice=false)
Ext2 = plot(ExtMapBuffer2, title="ExtMapBuffer2", color=color.maroon, linewidth=1, style=plot.style_line, transp=00, offset=0, trackprice=false)
is_call = crossover(SignalLine, SignalLine2) and SignalLine < ExtMapBuffer1 and SignalLine < ExtMapBuffer2 and ExtMapBuffer1 < ExtMapBuffer2
is_put = crossover(SignalLine2, SignalLine) and SignalLine > ExtMapBuffer1 and SignalLine > ExtMapBuffer2 and ExtMapBuffer1 > ExtMapBuffer2
PipValue = pow(10, -1 * abs(log(syminfo.mintick) / log(10)))
if abs(log(syminfo.mintick) / log(10)) == 3
PipValue := 0.01
else
PipValue := 0.0001
if is_call
diff = (ExtMapBuffer2 - ExtMapBuffer1) / PipValue
label.new(bar_index, na, text=tostring(round(diff, 2)), color=color.lime, style=label.style_labeldown, yloc=yloc.abovebar)
else if is_put
diff = (ExtMapBuffer1 - ExtMapBuffer2) / PipValue
label.new(bar_index, na, text=tostring(round(diff, 2)), color=color.red, style=label.style_labelup, yloc=yloc.belowbar)
color_area = ExtMapBuffer2>=ExtMapBuffer1 ? color.new(color.maroon , 70) : color.new(color.blue , 70)
fill(Ext1, Ext2, color=color_area , title = "Border")// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/