PROTECTED SOURCE SCRIPT

MACD1234

55
// This source code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org/MPL/2.0/
// © wyfei123

//version=5
//©jrobotcn 根据AC大神的版本翻译来的,discord.com/channels/898763842992095262/898763948801794048/1033216109878452224
//version=5
indicator("MACD1234")

src=input.source(close)
[dif,dea,macd]=ta.macd(src,input.int(12,'MACD短周期',3),input.int(26,'MACD长周期',5),input.int(9,'MACD信号周期',3))
macd:=macd*2
zero = 0
plot(dif,'DIF',#ff8d1e)
plot(dea,'DEA',#20d6ff)
macdcol=ta.change(macd)<0 ? macd<0 ? #bd1c1c : #60e2b8 : macd<0 ? #ff6666 : #118761
plot(macd,'MACD', macdcol,1,plot.style_columns)

//背离
a1=ta.barssince(ta.crossover(dif,dea)[1])
bot_div=src[a1+1]>src and dif>dif[a1+1] and ta.crossover(dif,dea)
if bot_div
line.new(bar_index-a1-1,dea[a1+1],bar_index,dea,color = #00ff00,style = line.style_dashed)
plotshape(bot_div,'底背离',shape.labelup,location.bottom,#0E884F,0,'底背',color.white,size=size.tiny,display=display.pane)
a2=ta.barssince(ta.crossover(dea,dif)[1])
top_div=src[a2+1]<src and dif[a2+1]>dif and ta.crossover(dea,dif)
if top_div
line.new(bar_index-a2-1,dea[a2+1],bar_index,dea,color = #ff0000,style = line.style_dashed)
plotshape(top_div,'顶背离',shape.labeldown,location.top,color.maroon,0,'顶背',color.white,size=size.tiny,display=display.pane)

// {macd四式}{水下金叉1,水上金叉2,水上死叉3,水下死叉4}
llvdea5=ta.lowest(dea,5)
hhvdea5=ta.highest(dea,5)
gcblow0=ta.crossover(dif,dea) and dea<0
plotchar(gcblow0?llvdea5*1.4:na,'水下金叉','1',location.absolute,#38ee00,size=size.tiny,display = display.pane)
gcabove01=ta.crossover(dif,dea) and dea>0
plotchar(gcabove01?hhvdea5*1.4:na,'水上金叉1','2',location.absolute,#00bc86,size=size.tiny,display = display.pane)
gcabove02=ta.crossover(dea,0) and dea>0
plotchar(gcabove02?llvdea5*1.05:na,'水上金叉2','2',location.absolute,#00bc86,size=size.tiny,display = display.pane)
dcabove0=ta.crossover(dea,dif) and dea>0
plotchar(dcabove0?hhvdea5*1.4:na,'水上死叉','3',location.absolute,#ff6666,size=size.tiny,display = display.pane)
dcblow01=ta.crossover(dea,dif) and dea<0
plotchar(dcblow01?llvdea5*1.5:na,'水下死叉1','4',location.absolute,#c10000,size=size.tiny,display = display.pane)
dcblow02=ta.crossover(0,dea) and dea<0
plotchar(dcblow02?hhvdea5*1.05:na,'水下死叉2','4',location.absolute,#c10000,size=size.tiny,display = display.pane)

免責聲明

這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。