예스스탁
예스스탁 답변
2025-03-10 14:15:25
안녕하세요
예스스탁입니다.
input : len(14);
input : src(close);
input : lbR(5);
input : lbL(5);
input : rangeUpper(60);
input : rangeLower(5);
input : plotBull(true);
input : plotHiddenBull(false);
input : plotBear(true);
input : plotHiddenBear(false);
var : osc(0),bearColor(0),bullColor(0),hiddenBullColor(0),hiddenBearColor(0),textColor(0),noneColor(0);
var : plFound(False),phFound(False);
var : ll(Nan),li(Nan),lv(NaN),ld(Nan),lt(Nan);
var : ll1(Nan),li1(Nan),lv1(NaN),ld1(Nan),lt1(Nan);
var : hh(Nan),hi(Nan),hv(NaN),hd(Nan),ht(Nan);
var : hh1(Nan),hi1(Nan),hv1(NaN),hd1(Nan),ht1(Nan);
var : tl1(0),tx1(0);
var : tl2(0),tx2(0);
var : tl3(0),tx3(0);
var : tl4(0),tx4(0);
bearColor = red;
bullColor = green;
hiddenBullColor = green;
hiddenBearColor = red;
textColor = white;
noneColor = white;
osc = (src - ma(src,len)) / (0.015 * AvgDeviation(src, len));
plot1(osc,"CCI",yellow);
plot2(100, "Overbought");
plot3(-100, "Oversold");
plFound = SwingLowBar(1,Osc,lbL, lbR,lbL+lbR+1) != -1;
phFound = SwingHighBar(1,Osc,lbL, lbR,lbL+lbR+1) != -1;
if plFound Then
{
lv = osc[lbR];
ll = l[lbR];
li = Index;
ld = sDate[lbR];
lt = sTime[lbR];
lv1 = Lv[1];
ll1 = ll[1];
li1 = li[1];
ld1 = ld[1];
lt1 = lt[1];
}
if phFound Then
{
hv = osc[lbR];
hh = h[lbR];
hi = Index;
hd = sDate[lbR];
ht = sTime[lbR];
hv1 = hv[1];
hh1 = hh[1];
hi1 = hi[1];
hd1 = hd[1];
ht1 = ht[1];
}
var : oscHL(False),priceLL(False),bullCond(False);
oscHL = lv > lv1 and rangeLower <= li-li1 and li-li1 <= rangeUpper;
priceLL = ll < ll1;
bullCond = plotBull and priceLL and oscHL and plFound;
if bullCond Then
{
tl1 = TL_New_Self(ld1,lt1,lv1,ld,lt,lv);
TL_SetColor(tl1,bullcolor);
TL_SetSize(tl1,1);
tx1 = Text_New_Self(ld,lt,lv,"Bull");
Text_SetStyle(tx1,2,0);
Text_SetColor(tx1,bullColor);
Text_SetBold(tx1,1);
}
var : oscLL(False),priceHL(False),hiddenBullCond(False);
oscLL = lv < Lv1 and rangeLower <= li-li1 and li-li1 <= rangeUpper;
priceHL = ll > ll1;
hiddenBullCond = plotHiddenBull and priceHL and oscLL and plFound;
if hiddenBullCond Then
{
tl2 = TL_New_Self(ld1,lt1,lv1,ld,lt,lv);
TL_SetColor(tl2,bullcolor);
TL_SetSize(tl2,1);
tx2 = Text_New_Self(ld,lt,lv,"H Bull");
Text_SetStyle(tx2,2,0);
Text_SetColor(tx2,bullColor);
Text_SetBold(tx2,1);
}
var : oscLH(False),priceHH(False),bearCond(False);
oscLH = hv < hv1 and rangeLower <= hi-hi1 and hi-hi1 <= rangeUpper;
priceHH = hh > hh1;
bearCond = plotBear and priceHH and oscLH and phFound;
if bearCond Then
{
tl3 = TL_New_Self(hd1,ht1,hv1,hd,ht,hv);
TL_SetColor(tl3,bearcolor);
TL_SetSize(tl3,1);
tx3 = Text_New_Self(hd,ht,hv,"Bear");
Text_SetStyle(tx3,2,1);
Text_SetColor(tx3,bearcolor);
Text_SetBold(tx3,1);
}
var : oscHH(False),priceLH(False),hiddenBearCond(False);
oscHH = hv > Hv1 and rangeLower <= hi-hi1 and hi-hi1 <= rangeUpper;
priceLH = hh < hh1;
hiddenBearCond = plotHiddenBear and priceLH and oscHH and phFound;
if hiddenBearCond Then
{
tl4 = TL_New_Self(hd1,ht1,hv1,hd,ht,hv);
TL_SetColor(tl4,bearcolor);
TL_SetSize(tl4,1);
tx4 = Text_New_Self(hd,ht,hv,"H Bear");
Text_SetStyle(tx4,2,1);
Text_SetColor(tx4,bearcolor);
Text_SetBold(tx4,1);
}
즐거운 하루되세요
> 이글루 님이 쓴 글입니다.
> 제목 : 수식변환
> 항상 수고 많으십니다.
트레이딩뷰에 있는 수식을 이용할수있도록 도움받고자 글 남깁니다.
변환 부탁드립니다.
************
study(title="CCI Divergences", format=format.price)
len = input(title="CCI Period", minval=1, defval=14)
src = input(title="CCI Source", defval=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 = color.red
bullColor = color.green
hiddenBullColor = color.green
hiddenBearColor = color.red
textColor = color.white
noneColor = color.new(color.white, 100)
osc = cci(src, len)
plot(osc, title="CCI", linewidth=2, color=color.yellow)
obLevel = hline(100, title="Overbought", linestyle=hline.style_dotted)
osLevel = hline(-100, title="Oversold", linestyle=hline.style_dotted)
fill(obLevel, osLevel, title="Background", color=color.gray, transp=80)
plFound = na(pivotlow(osc, lbL, lbR)) ? false : true
phFound = na(pivothigh(osc, lbL, lbR)) ? false : true
_inRange(cond) =>
bars = barssince(cond == true)
rangeLower <= bars and bars <= rangeUpper
alertcondition(osc[1] > 100.0 and osc[2] < 100.0, title="CCI value crosses over 100.0", message="Check charts for a CCI cross over 100.0")
alertcondition(osc[1] < 100.0 and osc[2] > 100.0, title="CCI value crosses under 100.0", message="Check charts for a CCI cross under 100.0")
alertcondition(osc[1] > -100. and osc[2] < -100.0, title="CCI value crosses over -100.0", message="Check charts for a CCI cross over -100.0")
alertcondition(osc[1] < -100.0 and osc[2] > -100.0, title="CCI value crosses under -100.0", message="Check charts for a CCI cross under -100.0")
//------------------------------------------------------------------------------
// Regular Bullish
// Osc: Higher Low
oscHL = osc[lbR] > valuewhen(plFound, 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 ? osc[lbR] : na,
offset=-lbR,
title="Regular Bullish",
linewidth=2,
color=(bullCond ? bullColor : noneColor),
transp=0
)
plotshape(
bullCond ? osc[lbR] : na,
offset=-lbR,
title="Regular Bullish Label",
text=" Bull ",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=textColor,
transp=0
)
alertcondition(bullCond, title="Regular bullish divergence in CCI found", message="Check charts for a regular bullish divergence found with CCI")
//------------------------------------------------------------------------------
// Hidden Bullish
// Osc: Lower Low
oscLL = osc[lbR] < valuewhen(plFound, 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 ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bullish",
linewidth=2,
color=(hiddenBullCond ? hiddenBullColor : noneColor),
transp=0
)
plotshape(
hiddenBullCond ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bullish Label",
text=" H Bull ",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=textColor,
transp=0
)
alertcondition(hiddenBullCond, title="Hidden bullish divergence in CCI found", message="Check charts for a hidden bullish divergence found with CCI")
//------------------------------------------------------------------------------
// Regular Bearish
// Osc: Lower High
oscLH = osc[lbR] < valuewhen(phFound, 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 ? osc[lbR] : na,
offset=-lbR,
title="Regular Bearish",
linewidth=2,
color=(bearCond ? bearColor : noneColor),
transp=0
)
plotshape(
bearCond ? osc[lbR] : na,
offset=-lbR,
title="Regular Bearish Label",
text=" Bear ",
style=shape.labeldown,
location=location.absolute,
color=bearColor,
textcolor=textColor,
transp=0
)
alertcondition(bearCond, title="Regular bearish divergence in CCI found", message="Check charts for a regular bearish divergence found with CCI")
//------------------------------------------------------------------------------
// Hidden Bearish
// Osc: Higher High
oscHH = osc[lbR] > valuewhen(phFound, 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 ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bearish",
linewidth=2,
color=(hiddenBearCond ? hiddenBearColor : noneColor),
transp=0
)
plotshape(
hiddenBearCond ? osc[lbR] : na,
offset=-lbR,
title="Hidden Bearish Label",
text=" H Bear ",
style=shape.labeldown,
location=location.absolute,
color=bearColor,
textcolor=textColor,
transp=0
)
alertcondition(hiddenBearCond, title="Hidden bearish divergence in CCI found", message="Check charts for a hidden bearish divergence found with CCI")