예스스탁
예스스탁 답변
2020-01-31 10:44:55
안녕하세요
예스스탁입니다.
#study("Alligator Analyses")
input : jawPeriod(13),teethPeriod(8),lipsPeriod(5),jawOffset(8),teethOffset(5),lipsOffset(3);
var : hl2(0),jaw(0),teeth(0),lips(0);
var : alligatorBullishEating(0),alligatorBearishEating(0),tx(0);
hl2 = (h+l)/2;
jaw = 0;
if IsNaN(jaw[1]) == true Then
jaw = ma(hl2,jawPeriod);
Else
jaw = (jaw[1]*(jawPeriod-1) + hl2)/jawPeriod;
teeth = 0;
if IsNaN(teeth[1]) == true Then
teeth = ma(hl2,teethPeriod);
Else
teeth = (teeth[1]*(teethPeriod-1) + hl2)/teethPeriod;
lips = 0;
if IsNaN(lips[1]) == true Then
lips = ma(hl2,lipsPeriod);
Else
lips = (lips[1]*(lipsPeriod-1) + hl2)/lipsPeriod;
plot1(jaw,"jaw",BLUE);
plot2(teeth,"teeth",RED);
plot3(lips,"lips",GREEN);
if lips > teeth and teeth > jaw then
{
tx = Text_New(sdate,stime,h,"▲");
Text_SetStyle(tx,2,1);
}
if lips < teeth and teeth < jaw then
{
tx = Text_New(sdate,stime,L,"▼");
Text_SetStyle(tx,2,0);
}
즐거운 하루되세요
> 임진사댁원장 님이 쓴 글입니다.
> 제목 : 수식전환 부탁드립니다.
> 예스수식으로 전환부탁드립니다.
//@version=3
study("Alligator Analyses")
// user inputs
jawPeriod = input(13, type=integer, minval=1, title="Jaw Period")
teethPeriod = input(8, type=integer, minval=1, title="Teeth Period")
lipsPeriod = input(5, type=integer, minval=1, title="Lips Period")
jawOffset = input(8, type=integer, minval=1, title="Jaw Offset")
teethOffset = input(5, type=integer, minval=1, title="Teeth Offset")
lipsOffset = input(3, type=integer, minval=1, title="Lips Offset")
// calcuulate smma
smma(src, length) =>
smma = 0.0
smma := na(smma[1]) ? sma(src, length) : (smma[1] * (length - 1) + src) / length
smma
// get the 3 smma
jaw = smma(hl2, jawPeriod)
teeth = smma(hl2, teethPeriod)
lips = smma(hl2, lipsPeriod)
// plot the 3 smma
jawData = plot(jaw, color=blue, offset=jawOffset)
teethData = plot(teeth, color=red, offset=teethOffset)
lipsData = plot(lips, color=green, offset=lipsOffset)
// alligator conditions
alligatorBullishEating() =>
ret = na
ret := lips > teeth and teeth > jaw ? 1 : na
ret
alligatorBearishEating() =>
ret = na
ret := lips < teeth and teeth < jaw ? 1 : na
ret
plotshape(alligatorBullishEating(), color=green, style=shape.triangleup, location=location.top, offset=2)
plotshape(alligatorBearishEating(), color=red, style=shape.triangledown, location=location.bottom, offset=2)