예스스탁
예스스탁 답변
2022-03-15 13:18:40
안녕하세요
예스스탁입니다.
1
nexttrend,trend는 상승/하락 추세구간을 지정하는 부분입니다.
4봉고가평균이 maxLowPrice보다 작고 종가가 전봉고가보다 크면 추세하락
4봉저가평균이 minHighPrice보다 크고 종가가 전봉고가보다 크면 추세상승
아래 주석을 참고하시기 바랍니다.
2 주석
input : amplitude(2),channelDeviation(2);
var : trend(0),nextTrend(0),maxLowPrice(0),minHighPrice(0);
var : up(0),down(0),atrHigh(0),atrLow(0),arrowUp(0),arrowDown(0);
var : atr2(0),dev(0),highPrice(0),lowPrice(0),highma(0),lowma(0),ht(0);
#100봉 ATR의 50%
atr2 = atr(100) / 2;
#100봉 ATR의 2배
dev = channelDeviation * atr2;
#4봉 최고가
highPrice = Highest(H,4);
#4봉 최저가
lowPrice = Lowest(L,4);
#4봉 고가평균
highma = ma(high, 4);
#4봉 저가평균
lowma = ma(low, 4);
#다음추세가 1이면
if nextTrend == 1 Then
{
#maxLowPrice에 4봉최저가와 직전 maxLowPrice 중 큰값저장
maxLowPrice = max(lowPrice, maxLowPrice);
#4봉 고가평균이 maxLowPrice보다 작고 종가가 전봉종가보다 작으면
if highma < maxLowPrice and close < iff(isnan(low[1])==true,low,Low[1]) Then
{
#추세는 1
trend = 1;
#다음추세는 0
nextTrend = 0;
# minHighPrice에 4개봉최고가 저장
minHighPrice = highPrice;
}
}
else #다음추세가 1이 아니면(0이면)
{
#minHighPricee에 4봉 최고가와 직전 minHighPrice 중 작은값 저장
minHighPrice = min(highPrice, minHighPrice);
#4봉 저가평균이 minHighPrice보다 크고 종가가 전봉고가보다 크면
if lowma > minHighPrice and close > iff(isnan(high[1])==true,high,high[1]) Then
{
#추세는 0
trend = 0;
#다음추세는 1
nextTrend = 1;
#maxLowPrice에 4봉 최저가 저장
maxLowPrice = lowPrice;
}
}
#추세가 0이면
if trend == 0 Then
{
#전봉 추세가 0이 아니면(추세변경)
if IsNaN(trend[1]) == False and trend[1] != 0 Then
{
#up은 down값
up = iff(IsNaN(down[1]) == true,down,down[1]);
#arrowUp에 up-atr2값 저장
arrowUp = up - atr2;
}
else #추세가 전봉도 0이면
{
#up에 maxLowPrice와 직전up값중 큰값 저장
up = iff(IsNan(up[1]) == true, maxLowPrice , max(maxLowPrice, up[1]));
}
#atrHigh은 up+dev;
atrHigh = up + dev;
#atrLow은 up-dev;
atrLow = up - dev;
}
else #추세가 0이 아니면(1이면)
{
#전봉 추세가가 1이 아니면(추세가 변경)
if isnan(trend[1]) == False and trend[1] != 1 Then
{
#down은 up값
down = iff(IsNan(up[1]) == true, up , up[1]);
#arrowDown은 down + atr2
arrowDown = down + atr2;
}
else
{
#down은 minHighPrice와 직전down값중 큰값 저장
down = iff(IsNan(down[1]) == true, minHighPrice ,min(minHighPrice, down[1]));
}
#atrhigh는 down+dev;
atrHigh = down + dev;
#atrLow는 down-dev;
atrLow = down - dev;
}
ht = iff(trend == 0 , up , down);
plot1(ht, "HalfTrend",iff(trend == 0 ,BLUE,RED));
plot2(atrHigh,"ATR High",RED);
plot3(atrLow, "ATR Low", BLUE);
즐거운 하루되세요
> 스노포스 님이 쓴 글입니다.
> 제목 : 지표수식 의미 질문
> 죄송합니다. 수식 전체 내용 올리고 알고 싶은 부분만 맨 앞에 올립니다.
아래 수식의 의미를 알고 싶습니다.
감사합니다.
if nextTrend == 1 Then
{
maxLowPrice = max(lowPrice, maxLowPrice);
if highma < maxLowPrice and close < iff(isnan(low[1])==true,low,Low[1]) Then
{
trend = 1;
nextTrend = 0;
minHighPrice = highPrice;
}
}
else
{
minHighPrice = min(highPrice, minHighPrice);
if lowma > minHighPrice and close > iff(isnan(high[1])==true,high,high[1]) Then
{
trend = 0;
nextTrend = 1;
maxLowPrice = lowPrice;
}
}
아래 수식 전체 내용
-------------------------------------------------------------------------------
input : amplitude(2),channelDeviation(2);
var : trend(0),nextTrend(0),maxLowPrice(0),minHighPrice(0);
var : up(0),down(0),atrHigh(0),atrLow(0),arrowUp(0),arrowDown(0);
var : atr2(0),dev(0),highPrice(0),lowPrice(0),highma(0),lowma(0),ht(0);
atr2 = atr(100) / 2;
dev = channelDeviation * atr2;
highPrice = Highest(H,4);
lowPrice = Lowest(L,4);
highma = ma(high, 4);
lowma = ma(low, 4);
if nextTrend == 1 Then
{
maxLowPrice = max(lowPrice, maxLowPrice);
if highma < maxLowPrice and close < iff(isnan(low[1])==true,low,Low[1]) Then
{
trend = 1;
nextTrend = 0;
minHighPrice = highPrice;
}
}
else
{
minHighPrice = min(highPrice, minHighPrice);
if lowma > minHighPrice and close > iff(isnan(high[1])==true,high,high[1]) Then
{
trend = 0;
nextTrend = 1;
maxLowPrice = lowPrice;
}
}
if trend == 0 Then
{
if IsNaN(trend[1]) == False and trend[1] != 0 Then
{
up = iff(IsNaN(down[1]) == true,down,down[1]);
arrowUp = up - atr2;
}
else
{
up = iff(IsNan(up[1]) == true, maxLowPrice , max(maxLowPrice, up[1]));
}
atrHigh = up + dev;
atrLow = up - dev;
}
else
{
if isnan(trend[1]) == False and trend[1] != 1 Then
{
down = iff(IsNan(up[1]) == true, up , up[1]);
arrowDown = down + atr2;
}
else
{
down = iff(IsNan(down[1]) == true, minHighPrice ,min(minHighPrice, down[1]));
}
atrHigh = down + dev;
atrLow = down - dev;
}
ht = iff(trend == 0 , up , down);
plot1(ht, "HalfTrend",iff(trend == 0 ,BLUE,RED));
plot2(atrHigh,"ATR High",RED);
plot3(atrLow, "ATR Low", BLUE);