예스스탁
예스스탁 답변
2023-01-19 13:11:10
안녕하세요
예스스탁입니다.
input : ntime1(30);
input : start(0.02),increment(0.02),maximum(0.2);
input : 상승전환색(Black), 하락전환색(Black) ;
var : S1(0),D1(0),TM(0),TF(0),cnt(0),idx(0);
var : haopen(0),haclose(0),hahigh(0),halow(0);
var : haopen1(0),haclose1(0),hahigh1(0),halow1(0),hacolor(0);
var : trend_dir(0),trend_dir1(0);
var : Psar(0),Psar1(0),Psar2(0);
var : af(0),af1(0),ep(0),ep1(0),trend_bars(0),trend_bars1(0);
var : sar_long_to_short(False),sar_short_to_long(False),trend_change(False);
Array : OO[100](0),HH[100](0),LL[100](0),CC[100](0);
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%ntime1;
if Bdate != Bdate[1] or
(Bdate == Bdate[1] and ntime1 > 1 and TF < TF[1]) or
(Bdate == Bdate[1] and ntime1 > 1 and TM >= TM[1]+ntime1) or
(Bdate == Bdate[1] and ntime1 == 1 and TM > TM[1]) Then
{
# TL_New(sDate,sTime,0,sDate,sTime,9999999);
idx = idx+1;
for cnt = 99 downto 1
{
OO[cnt] = HH[cnt-1];
HH[cnt] = HH[cnt-1];
LL[cnt] = LL[cnt-1];
CC[cnt] = CC[cnt-1];
}
OO[0] = O;
HH[0] = H;
LL[0] = L;
HaOpen1 = HaOpen[1];
HaClose1 = HaClose[1];
Hahigh1 = Hahigh[1];
HaLow1 = Halow[1];
trend_bars1 = trend_bars[1];
trend_dir1 = trend_dir[1];
psar1 = psar[1];
psar2 = psar1[1];
ep1 = ep[1];
af1 = af[1];
}
if HH[0] > 0 and H > HH[0] Then
HH[0] = H;
if LL[0] > 0 and L < LL[0] Then
LL[0] = L;
CC[0] = C;
if idx == 1 then
{
haOpen = OO[0];
haClose = (OO[0]+HH[0]+LL[0]+CC[0])/4;
haHigh = MaxList(HH[0], haOpen, haClose);
haLow = MinList(LL[0], haOpen,haClose);
}
else
{
haClose = (OO[0]+HH[0]+LL[0]+CC[0])/4;
haOpen = (haOpen1 + haClose1)/2 ;
haHigh = MaxList(HH[0], haOpen, haClose) ;
haLow = MinList(LL[0], haOpen, haClose) ;
}
// HA colors
hacolor = iff(haclose > haopen , green ,red);
psar = 0.0; // PSAR
af = 0.0; // Acceleration Factor
trend_dir = 0; // Current direction of PSAR
ep = 0.0; // Extreme point
trend_bars = 0;
sar_long_to_short = trend_dir1 == 1 and haclose <= psar1; // PSAR switches from long to short
sar_short_to_long = trend_dir1 == -1 and haclose >= psar1; // PSAR switches from short to long
trend_change = psar2 == 0 or sar_long_to_short or sar_short_to_long;
// Calculate trend direction
trend_dir = iff(psar2 == 0 and haclose1 > haopen1 , 1 ,
IFf(psar2 == 0 and haclose1 <= haopen1 , -1 ,
iff(sar_long_to_short , -1 ,
iff(sar_short_to_long , 1 , trend_dir1))));
trend_bars = iff(sar_long_to_short , -1 ,
iff(sar_short_to_long , 1 ,
iff(trend_dir == 1 , trend_bars1 + 1 ,
iff(trend_dir == -1 , trend_bars1 - 1 ,trend_bars1))));
// Calculate Acceleration Factor
af = iff(trend_change , start ,
iff((trend_dir == 1 and hahigh > ep1) or (trend_dir == -1 and LL[0] < ep1) , min(maximum, af1 + increment),af1));
// Calculate extreme point
ep = iff(trend_change and trend_dir == 1 , hahigh ,
iff(trend_change and trend_dir == -1 , halow ,
iff(trend_dir == 1 , max(ep1, hahigh) ,min(ep1, halow))));
// Calculate PSAR
psar = iff(psar2 == 0 and haclose1 > haopen1 , halow1 ,
iff(psar2 == 0 and haclose1 <= haopen1 , hahigh1 ,
iff(trend_change , ep1 ,
IFf(trend_dir == 1 , psar1 + af * (ep - psar1) , psar1 - af * (psar1 - ep) ))));
plot1(psar,"pSar",iff(trend_dir == 1 ,상승전환색,하락전환색));
}
즐거운 하루되세요
> 오이도인 님이 쓴 글입니다.
> 제목 : 수식 부탁드립니다
> 수고 하십니다.
아래 지표의 30분 지표값을 5분봉 차트에 표시하고 싶습니다.
수고 하세요...
#######
input : start(0.02),increment(0.02),maximum(0.2);
var : haopen(0),haclose(0),hahigh(0),halow(0),hacolor(0);
var : af(0),trend_dir(0),ep(0),trend_bars(0),psar(0);
var : sar_long_to_short(False),sar_short_to_long(False),trend_change(False);
// Calculation HA Values
if index == 0 then
{
haOpen = open;
haClose = (O+H+L+C)/4;
haHigh = MaxList( high, haOpen, haClose);
haLow = MinList( low, haOpen,haClose);
}
else
{
haClose = (O+H+L+C)/4;
haOpen = (haOpen [1] + haClose [1])/2 ;
haHigh = MaxList(High, haOpen, haClose) ;
haLow = MinList(Low, haOpen, haClose) ;
}
// HA colors
hacolor = iff(haclose > haopen , green ,red);
psar = 0.0; // PSAR
af = 0.0; // Acceleration Factor
trend_dir = 0; // Current direction of PSAR
ep = 0.0; // Extreme point
trend_bars = 0;
sar_long_to_short = trend_dir[1] == 1 and haclose <= psar[1]; // PSAR switches from long to short
sar_short_to_long = trend_dir[1] == -1 and haclose >= psar[1]; // PSAR switches from short to long
trend_change = IsNaN(psar[2]) == true or sar_long_to_short or sar_short_to_long;
// Calculate trend direction
trend_dir = iff(IsNaN(psar[2]) == true and haclose[1] > haopen[1] , 1 ,
IFf(IsNaN(psar[2]) == true and haclose[1] <= haopen[1] , -1 ,
iff(sar_long_to_short , -1 ,
iff(sar_short_to_long , 1 , trend_dir[1]))));
trend_bars = iff(sar_long_to_short , -1 ,
iff(sar_short_to_long , 1 ,
iff(trend_dir == 1 , trend_bars[1] + 1 ,
iff(trend_dir == -1 , trend_bars[1] - 1 ,trend_bars[1]))));
// Calculate Acceleration Factor
af = iff(trend_change , start ,
iff((trend_dir == 1 and hahigh > ep[1]) or (trend_dir == -1 and low < ep[1]) , min(maximum, af[1] + increment),af[1]));
// Calculate extreme point
ep = iff(trend_change and trend_dir == 1 , hahigh ,
iff(trend_change and trend_dir == -1 , halow ,
iff(trend_dir == 1 , max(ep[1], hahigh) ,min(ep[1], halow))));
// Calculate PSAR
psar = iff(IsNaN(psar[2]) == true and haclose[1] > haopen[1] , halow[1] ,
iff(IsNan(psar[2]) == true and haclose[1] <= haopen[1] , hahigh[1] ,
iff(trend_change , ep[1] ,
IFf(trend_dir == 1 , psar[1] + af * (ep - psar[1]) , psar[1] - af * (psar[1] - ep) ))));
input : 상승전환색(Black), 하락전환색(Black) ;
plot1(psar,"pSar",iff(trend_dir == 1 ,상승전환색,하락전환색));