예스스탁
예스스탁 답변
2020-12-07 18:12:20
안녕하세요
예스스탁입니다.
1 사용자함수
inputs: PeriodType( numericsimple ),
PeriodsAgo( numericsimple ),
oPeriodOpen( numericref ),
oPeriodHigh( numericref ),
oPeriodLow( numericref ),
oPeriodClose( numericref ) ;
variables: var0( 0 ), cnt(0);
arrays: OO[100](0), HH[100](0),LL[100](0),CC[100](0);
if PeriodType == 0 or
(PeriodType == 1 and bDate <> bDate[1]) or
(PeriodType == 2 and DayOfWeek(bDate) < DayOfWeek(bDate[1])) or
(PeriodType == 3 and Bdate > bDate[1]+30) or
(PeriodType == 4 and Bdate > bDate[1]+1000) Then
{
OO[0] = O;
HH[0] = H;
LL[0] = L;
CC[0] = C;
For cnt = 1 to 99
{
OO[cnt] = OO[cnt-1][1];
HH[cnt] = HH[cnt-1][1];
LL[cnt] = LL[cnt-1][1];
CC[cnt] = CC[cnt-1][1];
}
}
Else
{
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 ;
var1 = -1;
var2 = -1;
var3 = -1;
var4 = -1;
Var5 = -1;
if OO[PeriodsAgo-1] > 0 Then
{
var1 = OO[PeriodsAgo-1];
Var2 = HH[0];
Var3 = LL[0] ;
For cnt = 0 to PeriodsAgo-1
{
if HH[cnt] > var2 Then
Var2 = HH[cnt];
if LL[cnt] < Var3 Then
Var3 = LL[cnt];
}
Var4 = CC[0];
var5 = 1;
}
oPeriodOpen = var1;
oPeriodHigh = Var2;
oPeriodLow = Var3;
oPeriodClose = Var4;
OHLCPeriodsAgo = -1;
2 지표
vars: oPeriodOpen(0), oPeriodHigh(0), oPeriodLow(0), oPeriodClose(0);
Value1 = OHLCPeriodsAgo(1, 5, oPeriodOpen, oPeriodHigh, oPeriodLow, oPeriodClose);
Value2 = oPeriodOpen;
Value3 = oPeriodHigh;
Value4 = oPeriodLow;
Value5 = oPeriodClose;
Plot1(Value2);
Plot2(Value3);
Plot3(Value4);
Plot4(Value5);
즐거운 하루되세요
> sky93 님이 쓴 글입니다.
> 제목 : TS OHLCPeriodsAgo (Function) 의 YES 변환 문의
> 수고하십니다.
TS의 함수중 지정 주기의 시고저종가를 반환하는 함수입니다.
YES 초보라서 좀 어렵네요.
YES 랭귀지 함수로 변환을 부탁드립니다.
감사합니다.
inputs:
PeriodType( numericsimple ),
PeriodsAgo( numericsimple ),
oPeriodOpen( numericref ),
oPeriodHigh( numericref ),
oPeriodLow( numericref ),
oPeriodClose( numericref ) ;
variables:
var0( 0 ), sess_last_bar(false) ;
arrays:
arr0[ 4, 50 ]( -1 ) ;
sess_last_bar = sessionlastbar;
condition1 = PeriodsAgo > 50 or BarType > IFF(PeriodType<>0, PeriodType + 1, PeriodType + 2) or BarType > 4 ;
if condition1 then
begin
oPeriodOpen = -1 ;
oPeriodHigh = -1 ;
oPeriodLow = -1 ;
oPeriodClose = -1 ;
OHLCPeriodsAgo = -1 ;
end
else
begin
if PeriodType = 0 then
Condition1 = sess_last_bar[1]
else if PeriodType = 1 then
Condition1 = Date <> Date[1]
else if PeriodType = 2 then
Condition1 = DayOfWeek( Date ) < DayOfWeek( Date[1] )
else if PeriodType = 3 then
Condition1 = Month( Date ) <> Month( Date[1] )
else if PeriodType = 4 then
Condition1 = Year( Date ) <> Year( Date[1] ) ;
condition1 = CurrentBar = 1 or Condition1 ;
if condition1 then
begin
var0 = var0 - 1 ;
if var0 = -1
then var0 = 50 ;
arr0[ 1, var0 ] = O ;
arr0[ 2, var0 ] = H ;
arr0[ 3, var0 ] = L ;
arr0[ 4, var0 ] = C ;
end
else
begin
condition1 = H > arr0[ 2, var0 ] ;
if condition1 then arr0[ 2, var0 ] = H ;
condition1 = L < arr0[ 3, var0 ] ;
if condition1 then arr0[ 3, var0 ] = L ;
arr0[ 4, var0 ] = C ;
end ;
oPeriodOpen = arr0[ 1, Mod( var0 + PeriodsAgo, 51 ) ] ;
oPeriodHigh = arr0[ 2, Mod( var0 + PeriodsAgo, 51 ) ] ;
oPeriodLow = arr0[ 3, Mod( var0 + PeriodsAgo, 51 ) ] ;
oPeriodClose = arr0[ 4, Mod( var0 + PeriodsAgo, 51 ) ] ;
OHLCPeriodsAgo = 1 ;
end ;
if false then
Value1 = OHLCPeriodsAgo[1] ;
--------------------------------------------------------------------------
아래는 함수 설명입니다.
OHLCPeriodsAgo (Function)
image₩trumpet2.gif Disclaimer
The OHLCPeriodsAgo series function returns the Open, High, Low, and Close of a specified time segment, a specified number of periods ago.
Syntax
OHLCPeriodsAgo(PeriodType, PeriodsAgo, oPeriodOpen, oPeriodHigh, oPeriodLow, oPeriodClose)
Returns (Integer)
The oPeriodOpen, oPeriodHigh, oPeriodLow, and oPeriodCLose output parameters returns the Open, High, Low, and Close from a time segment. The OHLCPeriodsAgo function itself returns 1 if the specified time segment was available, and -1 if not.
Parameters
Name
Type
Description
PeriodType
Numeric
Sets the time period on which to base values (1=Day, 2=Week, 3=Month, 4=Year)
PeriodsAgo
Numeric
Sets the number of PeriodType periods ago
oPeriodOpen
Numeric
Outputs the open of the specified time segment
oPeriodHigh
Numeric
Outputs the high of the specified time segment
oPeriodLow
Numeric
Outputs the low of the specified time segment
oPeriodClose
Numeric
Outputs the close of the specified time segment
Remarks
See Multiple Output Function for more information on using output parameters to return values.
Example
Assigns to Value2 through Value5 the Open, High, Low, and Close of the last 20 weeks. Value1 is assigned a value of 1.
vars: oPeriodOpen(0), oPeriodHigh(0), oPeriodLow(0), oPeriodClose(0);
Value1 = OHLCPeriodsAgo(2, 20, oPeriodOpen, oPeriodHigh, oPeriodLow, oPeriodClose);
Value2 = oPeriodOpen;
Value3 = oPeriodHigh;
Value4 = oPeriodLow;
Value5 = oPeriodClose;
sky93
2020-12-11 11:28:19
수고하십니다.
해 주신 내용으로 적용을 해 보았습니다.
60분봉차트에서 지표를 불러서 일/주/월봉 1봉전 시고저종가를 표기해보니
60분봉상에서 일/주/월봉 1봉전 시고저종가는 지정주기내 분봉 흐름에서는 가격이 고정이
되어 있어야 할텐데 보시다시피(시:빨,고:주,저:연,종:초) 분봉의 흐름에 따라 변동이 발
생합니다.
번거로우시겠지만,한번 더 부탁드립니다.
감사합니다.
첨부는 주봉 1봉전 지표적용 이미지 입니다.(일,월,년 모두 비슷한 문제가 있음)
> 예스스탁 님이 쓴 글입니다.
> 제목 : Re : TS OHLCPeriodsAgo (Function) 의 YES 변환 문의
> 안녕하세요
예스스탁입니다.
1 사용자함수
inputs: PeriodType( numericsimple ),
PeriodsAgo( numericsimple ),
oPeriodOpen( numericref ),
oPeriodHigh( numericref ),
oPeriodLow( numericref ),
oPeriodClose( numericref ) ;
variables: var0( 0 ), cnt(0);
arrays: OO[100](0), HH[100](0),LL[100](0),CC[100](0);
if PeriodType == 0 or
(PeriodType == 1 and bDate <> bDate[1]) or
(PeriodType == 2 and DayOfWeek(bDate) < DayOfWeek(bDate[1])) or
(PeriodType == 3 and Bdate > bDate[1]+30) or
(PeriodType == 4 and Bdate > bDate[1]+1000) Then
{
OO[0] = O;
HH[0] = H;
LL[0] = L;
CC[0] = C;
For cnt = 1 to 99
{
OO[cnt] = OO[cnt-1][1];
HH[cnt] = HH[cnt-1][1];
LL[cnt] = LL[cnt-1][1];
CC[cnt] = CC[cnt-1][1];
}
}
Else
{
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 ;
var1 = -1;
var2 = -1;
var3 = -1;
var4 = -1;
Var5 = -1;
if OO[PeriodsAgo-1] > 0 Then
{
var1 = OO[PeriodsAgo-1];
Var2 = HH[0];
Var3 = LL[0] ;
For cnt = 0 to PeriodsAgo-1
{
if HH[cnt] > var2 Then
Var2 = HH[cnt];
if LL[cnt] < Var3 Then
Var3 = LL[cnt];
}
Var4 = CC[0];
var5 = 1;
}
oPeriodOpen = var1;
oPeriodHigh = Var2;
oPeriodLow = Var3;
oPeriodClose = Var4;
OHLCPeriodsAgo = -1;
2 지표
vars: oPeriodOpen(0), oPeriodHigh(0), oPeriodLow(0), oPeriodClose(0);
Value1 = OHLCPeriodsAgo(1, 5, oPeriodOpen, oPeriodHigh, oPeriodLow, oPeriodClose);
Value2 = oPeriodOpen;
Value3 = oPeriodHigh;
Value4 = oPeriodLow;
Value5 = oPeriodClose;
Plot1(Value2);
Plot2(Value3);
Plot3(Value4);
Plot4(Value5);
즐거운 하루되세요
> sky93 님이 쓴 글입니다.
> 제목 : TS OHLCPeriodsAgo (Function) 의 YES 변환 문의
> 수고하십니다.
TS의 함수중 지정 주기의 시고저종가를 반환하는 함수입니다.
YES 초보라서 좀 어렵네요.
YES 랭귀지 함수로 변환을 부탁드립니다.
감사합니다.
inputs:
PeriodType( numericsimple ),
PeriodsAgo( numericsimple ),
oPeriodOpen( numericref ),
oPeriodHigh( numericref ),
oPeriodLow( numericref ),
oPeriodClose( numericref ) ;
variables:
var0( 0 ), sess_last_bar(false) ;
arrays:
arr0[ 4, 50 ]( -1 ) ;
sess_last_bar = sessionlastbar;
condition1 = PeriodsAgo > 50 or BarType > IFF(PeriodType<>0, PeriodType + 1, PeriodType + 2) or BarType > 4 ;
if condition1 then
begin
oPeriodOpen = -1 ;
oPeriodHigh = -1 ;
oPeriodLow = -1 ;
oPeriodClose = -1 ;
OHLCPeriodsAgo = -1 ;
end
else
begin
if PeriodType = 0 then
Condition1 = sess_last_bar[1]
else if PeriodType = 1 then
Condition1 = Date <> Date[1]
else if PeriodType = 2 then
Condition1 = DayOfWeek( Date ) < DayOfWeek( Date[1] )
else if PeriodType = 3 then
Condition1 = Month( Date ) <> Month( Date[1] )
else if PeriodType = 4 then
Condition1 = Year( Date ) <> Year( Date[1] ) ;
condition1 = CurrentBar = 1 or Condition1 ;
if condition1 then
begin
var0 = var0 - 1 ;
if var0 = -1
then var0 = 50 ;
arr0[ 1, var0 ] = O ;
arr0[ 2, var0 ] = H ;
arr0[ 3, var0 ] = L ;
arr0[ 4, var0 ] = C ;
end
else
begin
condition1 = H > arr0[ 2, var0 ] ;
if condition1 then arr0[ 2, var0 ] = H ;
condition1 = L < arr0[ 3, var0 ] ;
if condition1 then arr0[ 3, var0 ] = L ;
arr0[ 4, var0 ] = C ;
end ;
oPeriodOpen = arr0[ 1, Mod( var0 + PeriodsAgo, 51 ) ] ;
oPeriodHigh = arr0[ 2, Mod( var0 + PeriodsAgo, 51 ) ] ;
oPeriodLow = arr0[ 3, Mod( var0 + PeriodsAgo, 51 ) ] ;
oPeriodClose = arr0[ 4, Mod( var0 + PeriodsAgo, 51 ) ] ;
OHLCPeriodsAgo = 1 ;
end ;
if false then
Value1 = OHLCPeriodsAgo[1] ;
--------------------------------------------------------------------------
아래는 함수 설명입니다.
OHLCPeriodsAgo (Function)
image₩trumpet2.gif Disclaimer
The OHLCPeriodsAgo series function returns the Open, High, Low, and Close of a specified time segment, a specified number of periods ago.
Syntax
OHLCPeriodsAgo(PeriodType, PeriodsAgo, oPeriodOpen, oPeriodHigh, oPeriodLow, oPeriodClose)
Returns (Integer)
The oPeriodOpen, oPeriodHigh, oPeriodLow, and oPeriodCLose output parameters returns the Open, High, Low, and Close from a time segment. The OHLCPeriodsAgo function itself returns 1 if the specified time segment was available, and -1 if not.
Parameters
Name
Type
Description
PeriodType
Numeric
Sets the time period on which to base values (1=Day, 2=Week, 3=Month, 4=Year)
PeriodsAgo
Numeric
Sets the number of PeriodType periods ago
oPeriodOpen
Numeric
Outputs the open of the specified time segment
oPeriodHigh
Numeric
Outputs the high of the specified time segment
oPeriodLow
Numeric
Outputs the low of the specified time segment
oPeriodClose
Numeric
Outputs the close of the specified time segment
Remarks
See Multiple Output Function for more information on using output parameters to return values.
Example
Assigns to Value2 through Value5 the Open, High, Low, and Close of the last 20 weeks. Value1 is assigned a value of 1.
vars: oPeriodOpen(0), oPeriodHigh(0), oPeriodLow(0), oPeriodClose(0);
Value1 = OHLCPeriodsAgo(2, 20, oPeriodOpen, oPeriodHigh, oPeriodLow, oPeriodClose);
Value2 = oPeriodOpen;
Value3 = oPeriodHigh;
Value4 = oPeriodLow;
Value5 = oPeriodClose;