예스스탁
예스스탁 답변
2025-06-30 14:33:20
안녕하세요
예스스탁입니다.
input : 분(20),length(100),ATRPeriod(200),ATRSignal(200);
var : up_color(0),dn_color(0);
var : S1(0),D1(0),TM(0),TF(0),cnt(0);
var : ii(0),CC(0),C1(0),sumh(0),suml(0),mah(0),mal(0);
var : sma_high(0),sma_low(0),sma_high1(0),sma_low1(0);
var : TH(0),TL(0),sumTR(0),alpha(0),sum(0),atr_value(0);
var : trend(false),trend1(False),trend_value(0),trend_color(0);
Array : TR[300](0),ATRV[300](0),HH[300](0),LL[300](0);
up_color = Green;
dn_color = Red;
if Bdate != Bdate[1] Then
{
S1 = TimeToMinutes(stime);
D1 = sdate;
}
if D1 > 0 then
{
if sdate == D1 Then
TM = TimeToMinutes(stime)-S1;
Else
TM = TimeToMinutes(stime)+1440-S1;
TF = TM%분;
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and 분 > 1 and TF < TF[1]) or
(Bdate == Bdate[1] and 분 > 1 and TM >= TM[1]+분) or
(Bdate == Bdate[1] and 분 == 1 and TM > TM[1]) Then
{
ii = ii +1;
for cnt = 299 downto 1
{
HH[cnt] = HH[cnt-1];
LL[cnt] = LL[cnt-1];
TR[cnt] = TR[cnt-1];
ATRV[cnt] = ATRV[cnt-1];
}
HH[0] = H;
LL[0] = L;
C1 = CC[1];
sma_high1 = sma_high[1];
sma_low1 = sma_low[1];
trend1 = trend[1];
}
if H > HH[0] Then
HH[0] = H;
if L < LL[0] Then
LL[0] = L;
CC = c;
TR[0] = max(C1,HH[0])-Min(C1,LL[0]);
if ii >= length Then
{
sumh = 0;
suml = 0;
For cnt = 0 to length-1
{
sumh = sumh + hh[cnt];
suml = suml + ll[cnt];
}
mah = sumh/length;
mal = suml/length;
}
if ii >= ATRPeriod+1 then
{
if ii == ATRPeriod+1 Then
{
sumTR = 0;
for cnt = 0 to ATRPeriod-1
{
sumTR = sumTR + TR[cnt];
}
ATRV[0] = sumTR/ATRPeriod;
}
Else
{
alpha = 1 / ATRPeriod ;
ATrV[0] = alpha * TR[0] + (1 - alpha) * ATrV[1];
}
}
if ii >= ATRPeriod+ATRSignal then
{
sum = 0;
For cnt = 0 to 199
{
sum = sum + ATRV[cnt];
}
atr_value = (sum/200)*0.8;
sma_high = sumh/length + atr_value;
sma_low = suml/length - atr_value;
if CC > sma_high and C1 < sma_high1 Then
trend = true;
Else if CC < sma_low and C1 > sma_low1 Then
trend = False;
Else
trend = trend1;
trend_value = IFf(trend, sma_low, sma_high);
trend_color = iff(trend , up_color , IFf(trend == False, dn_color, Black));
if trend == true Then
Plot1(trend_value,"trend true",trend_color);
Else
NoPlot(1);
if trend == False Then
Plot2(trend_value,"trend False",trend_color);
Else
NoPlot(2);
}
}
즐거운 하루되세요
> 사노소이 님이 쓴 글입니다.
> 제목 : 수식 부탁드립니다
> 타주기 적용 부탁드립니다.
input : length(100);
var : trend(False),trend_value(nan),trend_color(0);
var : up_color(0),dn_color(0),atr_value(0);
var : alpha(0),ATRV(0);
var : sma_high(0),sma_low(0);
var : signal_up(False),signal_down(False);
up_color = Green;
dn_color = Red;
alpha = 1 / 200 ;
ATrV = IFf(IsNan(ATrV[1]) == true, ma(TrueRange,200) , alpha * TrueRange + (1 - alpha) * IFf(isnan(ATrV[1])==true,0,ATrV[1]));
atr_value = ma(ATrV, 200) * 0.8;
sma_high = ma(high, length) + atr_value;
sma_low = ma(low, length) - atr_value;
if CrossUp(close, sma_high) Then
trend = true;
if CrossDown(close, sma_low) Then
trend = false;
trend_value = IFf(trend, sma_low, sma_high);
trend_color = iff(trend , up_color , IFf(trend == False, dn_color, Black));
signal_up = trend != trend[1] and trend[1] == False;
signal_down = trend != trend[1] and trend[1] == true;
if trend == true Then
Plot1(trend_value,"trend true",trend_color);
Else
NoPlot(1);
if trend == False Then
Plot2(trend_value,"trend False",trend_color);
Else
NoPlot(2);