首页 > 其他分享 >同花顺官方MACD背离公式及tradding view的LAZYBAER的能量背离公式的分析

同花顺官方MACD背离公式及tradding view的LAZYBAER的能量背离公式的分析

时间:2024-01-31 19:13:12浏览次数:29  
标签:lbR title color 公式 tradding phFound obv osc 背离

同花顺MACD背离

BACKGROUNDSTYLE(2);
DIFF:EMA(CLOSE,SHORT)-EMA(CLOSE,LONG),COLORWHITE,PRECIS3;
DEA :EMA(DIFF,M),COLORYELLOW,PRECIS3;
MACD:(DIFF-DEA)*2,COLORSTICK,PRECIS3;

GJ:=MAX(C,O);
L4:=LLV(GJ,4);
JL:=(HHV(DIFF,55)-LLV(DIFF,55))/5;
GT:=DEA>REF(DEA,1) AND REF(DEA,1)<REF(DEA,2);
A1:=BARSLAST(REF(GT,1));
底背离:=REF(L4,A1+1)>CLOSE AND DIFF>REF(DIFF,A1+1) AND GT;
DRAWTEXT(底背离,REF(DEA,A1)*1.18,' 底背离'),COLORRED;
H4:=HHV(GJ,4);
GT2:=DEA<REF(DEA,1) AND REF(DEA,1)>REF(DEA,2);
A2:=BARSLAST(REF(GT2,1));
顶背离:= REF(H4,A2+1)<H4 AND  DIFF<REF(DIFF,A2+1) AND GT2;

DRAWTEXT(顶背离,REF(DEA,A2)*1.18,' 顶背离'),COLORGREEN;

traddingview的OBV背离 pinescript(主要代码出自lazybear)

 

//
// @author LazyBear
// 
// Appreciate a note if you use this code anywhere. 
// 
study(title="OBV with Divergence", shorttitle="OBV_Divergence_LB")

len = input(20)
src = close
lbR = input(title="Pivot Lookback Right", defval=5)
lbL = input(title="Pivot Lookback Left", defval=5)
rangeUpper = input(title="Max of Lookback Range", defval=60)
rangeLower = input(title="Min of Lookback Range", defval=5)
plotBull = input(title="Plot Bullish", defval=true)
plotHiddenBull = input(title="Plot Hidden Bullish", defval=false)
plotBear = input(title="Plot Bearish", defval=true)
plotHiddenBear = input(title="Plot Hidden Bearish", defval=false)


bearColor = red
bullColor = green
hiddenBullColor = color(green, 80)
hiddenBearColor = color(red, 80)
textColor = white
noneColor = color(white, 100)

obv(src) => cum(change(src) > 0 ? volume : change(src) < 0 ? -volume : 0*volume)
os=obv(src)
obv_osc = (os - ema(os,len))
obc_color=obv_osc > 0 ? green : red
plot(obv_osc, color=obc_color, style=line,title="OBV-Points", linewidth=2)
plot(obv_osc, color=silver, transp=70, title="OBV", style=area)
hline(0)

plFound = na(pivotlow(obv_osc, lbL, lbR)) ? false : true
phFound = na(pivothigh(obv_osc, lbL, lbR)) ? false : true

_inRange(cond) =>
    bars = barssince(cond == true)
    rangeLower <= bars and bars <= rangeUpper

//------------------------------------------------------------------------------
// Regular Bullish

// Osc: Higher Low
oscHL = obv_osc[lbR] > valuewhen(plFound, obv_osc[lbR], 1) and _inRange(plFound[1])

// Price: Lower Low
priceLL = low[lbR] < valuewhen(plFound, low[lbR], 1)

bullCond = plotBull and priceLL and oscHL and plFound

plot(
     plFound ? obv_osc[lbR] : na,
     offset=-lbR,
     title="Regular Bullish",
     linewidth=2,
     color=(bullCond ? bullColor : noneColor),
     transp=0
     )

plotshape(
     bullCond ? obv_osc[lbR] : na,
     offset=-lbR,
     title="Regular Bullish Label",
     text=" Bull ",
     style=shape.labelup,
     location=location.absolute,
     color=bullColor,
     textcolor=textColor,
     transp=0
     )

//------------------------------------------------------------------------------
// Hidden Bullish

// Osc: Lower Low
oscLL = obv_osc[lbR] < valuewhen(plFound, obv_osc[lbR], 1) and _inRange(plFound[1])

// Price: Higher Low
priceHL = low[lbR] > valuewhen(plFound, low[lbR], 1)

hiddenBullCond = plotHiddenBull and priceHL and oscLL and plFound

plot(
     plFound ? obv_osc[lbR] : na,
     offset=-lbR,
     title="Hidden Bullish",
     linewidth=2,
     color=(hiddenBullCond ? hiddenBullColor : noneColor),
     transp=0
     )

plotshape(
     hiddenBullCond ? obv_osc[lbR] : na,
     offset=-lbR,
     title="Hidden Bullish Label",
     text=" H Bull ",
     style=shape.labelup,
     location=location.absolute,
     color=bullColor,
     textcolor=textColor,
     transp=0
     )

//------------------------------------------------------------------------------
// Regular Bearish

// Osc: Lower High
oscLH = obv_osc[lbR] < valuewhen(phFound, obv_osc[lbR], 1) and _inRange(phFound[1])

// Price: Higher High
priceHH = high[lbR] > valuewhen(phFound, high[lbR], 1)

bearCond = plotBear and priceHH and oscLH and phFound

plot(
     phFound ? obv_osc[lbR] : na,
     offset=-lbR,
     title="Regular Bearish",
     linewidth=2,
     color=(bearCond ? bearColor : noneColor),
     transp=0
     )

plotshape(
     bearCond ? obv_osc[lbR] : na,
     offset=-lbR,
     title="Regular Bearish Label",
     text=" Bear ",
     style=shape.labeldown,
     location=location.absolute,
     color=bearColor,
     textcolor=textColor,
     transp=0
     )

//------------------------------------------------------------------------------
// Hidden Bearish

// Osc: Higher High
oscHH = obv_osc[lbR] > valuewhen(phFound, obv_osc[lbR], 1) and _inRange(phFound[1])

// Price: Lower High
priceLH = high[lbR] < valuewhen(phFound, high[lbR], 1)

hiddenBearCond = plotHiddenBear and priceLH and oscHH and phFound

plot(
     phFound ? obv_osc[lbR] : na,
     offset=-lbR,
     title="Hidden Bearish",
     linewidth=2,
     color=(hiddenBearCond ? hiddenBearColor : noneColor),
     transp=0
     )

plotshape(
     hiddenBearCond ? obv_osc[lbR] : na,
     offset=-lbR,
     title="Hidden Bearish Label",
     text=" H Bear ",
     style=shape.labeldown,
     location=location.absolute,
     color=bearColor,
     textcolor=textColor,
     transp=0
     )

 

标签:lbR,title,color,公式,tradding,phFound,obv,osc,背离
From: https://www.cnblogs.com/ip99/p/17999921

相关文章

  • [office] excel中设置公式的方法步骤详解
    Excel是一个办公很经常用到的一个办公软件,他主要用于数据的分析、查看、对比等,让数据看起来更直观,更容易对比,而有很多时候需要设置打钩来登记相关信息,现在请欣赏小编带来的excel中设置公式教程。excel中设置公式教程一:直接输入公式excel中设置公式步骤1:选定需要输入公......
  • [office] excel如何保护公式?excel保护公式操作方法
    在上一篇文章我们介绍了excel表格隐藏公式方法,在隐藏单元格中的公式之后,依旧是可以对计算的结果进行更改!那么如何才能保护工作表中的公式不会被更改呢?下面来了解下excel保护公式操作方法。excel保护公式操作步骤:步骤1在工作表中选中包含公式的单元格或区域,单击“开......
  • [office] excel表格如何设置公式锁定
    Excel中的公式具体该如何操作才能实现锁定呢?对于新手来说还是有一定难度,怎么办?接下来是小编为大家带来的excel表格公式锁定的方法,欢迎大家来到学习。excel表格公式设置锁定的方法锁定公式步骤1:小编以目前在使用的表格为例,为大家演示。Ctrl+A选定全部单元格,点击右键–......
  • [office] 财务必须熟练使用的15个函数公式,超详细参数详解+举例!
    又到了咱们的Excel技巧课堂分享时刻,一名会计,势必要成为一名表格高手,才能在职场中乘风破浪。不然一个公式参数设置都要10分钟,按时下班怕是不可能,升职加薪更是无望了!今天蛙蛙给大家分享的就是Excel学习逃不开的函数公式,以参数详解+举例的方式,给大家讲讲咱们经常用到的15个公式。一定......
  • 龙哥量化:通达信(副图)打板专家技术指标源码公式源码选股公式源码
    如果您需要代写公式,请联系我。龙哥QQ:591438821龙哥微信:Long622889新建一个副图公式,放在副图看信号新建一个条件选股公式,用来选股,都用这个源码 X_1:=MA(CLOSE,20);X_2:=HHV(X_1,5);X_3:=X_1-(X_2-X_1);X_4:=MA(CLOSE,60);XG:CLOSE>REF(CLOSE,1)ANDMA(CLOSE,5)>MA(CLOSE,......
  • 龙哥量化:通达信(副图)稳赚趋势策略技术指标源码公式源码
    如果您需要代写公式,请联系我。龙哥QQ:591438821龙哥微信:Long622889介绍:主力线上穿操作线之后,主力线以45°角上穿分水岭,同时操作线也以45°角向上运行,这中情况下涨停概率在90%以上,此时买入 VAR1:=(EMA(C,12)-EMA(C,26))*100+50;VAR2:=EMA(VAR1,9);VAR3:=((HHV(H,21)-C)/(......
  • 龙哥量化:通达信(副图)买在起涨点技术指标源码公式源码
    如果您需要代写公式,请联系我。龙哥QQ:591438821龙哥微信:Long622889黄金点三个时买入,蓝点出时毫不犹豫出半仓,加之和布林轨结合用,站稳中轨持半仓,直到第二波蓝点出就全止盈。出第一蓝点时同时破中轨肯定是大阴线就全止盈出局。VAR1:=1090630;喜来财:DRAWNULL,NODRAW;珍珠点:IF(DA......
  • 通达信蒙氏剑鞘线主图指标公式源码
    {波峰}TY:=H;A1:=REF(TY,10)=HHV(TY,2*10+1);B1:=FILTER(A1,10);C1:=BacKSET(B1,10+1);HD:=FILTER(C1,10);A2:=REF(TY,10)=LLV(TY,2*10+1);B2:=FILTER(A2,10);C002:=BACKSET(B2,10+1);LD:=FILTER(C002,10);波峰:REF(H,BArslAst(HD)),COLOR00808F,POINTDOT,LINETHICK4;S......
  • 通达信黄金VIP量比指标公式源码副图
    T1:=20;T2:=60;T3:=120;LONG1:IF(C>Ema(C,T1),1,0),COLORWHITE;LONG2:IF(C>EMA(C,T2),1,0),COLORWHITE;LONG3:IF(C>EMA(C,T3),1,0),COLORWHITE;VAR0:=(WINNER(C*0.9))*100;stICKLINE(1,0,VAR0,3,0),COLOR000077;STICKLINE(1,0,VAR0,2.5,0),COLOR000099;......
  • 通达信黑马秘籍主图指标公式源码副图
    M1:MA(CLOSE,13),COLORYELLOW,LINETHICK2; M2:MA(CLOSE,34),LINETHICK2,COLORWHITE; M3:MA(CLOSE,55),COLORGREEN,LINETHICK2; A:MA(C,5)COLORBLUE,LINETHICK3; B:=A<ref(a,1); IF(B-1,A,DRAWNULL)COLORRED,LINETHICK3; DRAWTEXT(LAST(C<o,3,0)and=""......