커뮤니티
예스랭귀지 Q&A
답변완료
[공지] 예스랭귀지 AI 어시스턴트, '예스나 AI' 출시 및 무료 체험 안내
안녕하세요, 예스스탁 입니다.복잡한 수식 공부 없이 여러분의 아이디어를 말하면 시스템 트레이딩 언어 예스랭귀지로 작성해주는 서비스예스나 AI(YesNa AI)가 출시되었습니다.지금 예스나 AI를 직접 경험해 보실 수 있도록 20크레딧(질문권 20회)를 무료로 증정해 드리고 있습니다.바로 여러분의 아이디어를 코드로 변환해보세요.--------------------------------------------------🚀 YesNa AI 핵심 기능- 지표식/전략식/종목검색식 생성: 자연어로 요청하면 예스랭귀지 문법에 맞는 코드를 작성합니다.- 종목검색식 변환 지원: K증권의 종목 검색식을 예스랭귀지로 변환 지원합니다.- 컴파일 검증: 작성된 코드가 실행 가능한지 컴파일러를 통해 문법 검증을 거쳐 결과물을 제공합니다.상세한 서비스 개요 및 활용 방법은 [서비스 소개 페이지]에서 확인하실 수 있습니다.▶ 서비스 소개 페이지: 바로가기서비스 사용 유의사항 및 결제 환불정책은 [이용약관]을 참고 부탁드립니다.▶ 서비스 이용약관: 바로가기💬 이용 문의사용 중 문의사항은 [프로그램 사용법 Q&A] 게시판에서 [예스나 AI] 카테고리를 설정 후 문의해 주시면 상세히 안내해 드리겠습니다.--------------------------------------------------앞으로도 AI를 활용한 다양한 트레이딩 기능들을 지속적으로 선보일 예정입니다.많은 관심과 기대 부탁드립니다.
2026-02-27
4316
글번호 230811
답변완료
함수문의드립니다
"코스피 프로그램 비차익 순매수금액" 데이터를 불러오고자 합니다
함수명을 알려주시면 고맙겠습니다.
2017-11-02
162
글번호 113845
답변완료
55321 수정사항입니다
도움 감사드립니다. 그런데 텍스트가 챠트중간에 나와서 불편하네요. 우측으로 정렬시키려 이전에 도움받은 내용으로 수정을 해봤는데 잘 안되네요.
도움 부탁드려요.
<< 텍스트를 우측여백에 위치시키기>>
####################
안녕하세요
예스스탁입니다.
1.
var : cnt(0);
Array : TL[301](0),TX[301](0);
if CurrentDate == sdate then{
if sdate != sdate[1] then{
for cnt = 1 to 300{
TL_Delete(TL[cnt]);
TL[cnt] = TL_New(sdate[1],stime[1],DayClose(cnt),sdate,stime,DayClose(cnt));
TL_SetExtRight(TL[cnt],true);
TL_SetExtLeft(TL[cnt],true);
Text_Delete(TX[cnt]);
TX[cnt] = Text_New(sdate,stime,DayClose(cnt),NumToStr(DayClose(cnt),2));
}
}
TL_Delete(TL[0]);
TL[0] = TL_New(sdate[1],stime[1],DayClose(0),sdate,stime,DayClose(0));
TL_SetExtRight(TL[0],true);
TL_SetExtLeft(TL[0],true);
Text_Delete(TX[0]);
TX[0] = Text_New(sdate,stime,DayClose(cnt),NumToStr(DayClose(0),2));
}
2
var : cnt(0,data1),C2(0,data2);
Array : TL[301](0,data1),TX[301](0,data1);
C2 = data2(C);
if CurrentDate == sdate then{
if sdate != sdate[1] then
{
for cnt = 1 to 300
{
TL_Delete(TL[cnt]);
TL[cnt] = TL_New(sdate[1],stime[1],C2[cnt-1],sdate,stime,C2[cnt-1]);
TL_SetExtRight(TL[cnt],true);
TL_SetExtLeft(TL[cnt],true);
Text_Delete(TX[cnt]);
TX[cnt] = Text_New(sdate,stime,C2[cnt-1],NumToStr(C2[cnt-1],2));
}
}
TL_Delete(TL[0]);
TL[0] = TL_New(sdate[1],stime[1],c,sdate,stime,c);
TL_SetExtRight(TL[0],true);
TL_SetExtLeft(TL[0],true);
Text_Delete(TX[0]);
TX[0] = Text_New(sdate,stime,c,NumToStr(c,2));
}
즐거운 하루되세요
> 스로우 님이 쓴 글입니다.
> 제목 : 추세선문의
> <<분봉 챠트>> 에서 아래 요구사항을 구현하고자 합니다. 도움 부탁드려요. ^^
1) 과거 300일간의 일봉의 종가를 모두 선으로 그리고 수치값을 우측여백에 표시합니다.
2) 과거 1000개의 60분봉의 종가를 모두 선으로 그리고 수치값을 우측여백에 표시합니다.
==>
a)참조데이타 이용를 이용하는 방법과
b)함수식으로 구현하는 방법
2가지 다 부탁드립니다. <<감사합니다. ^^>>
2017-11-02
177
글번호 113841
답변완료
질문
좋은 답변 감사드립니다. 아래수식은 추세매매수식인데 이것을 진입후 0.5pt수익이며는 청산하는 수식으로 변형부탁드립니다. 재 진입은 반대포지션진입조건이 뜨며는 진입합니다. 여기서 0.5pt는 변수처리 부탁드립니다.감사합니다.
1.
var : Xcnt(0);
if bdate != bdate[1] Then
Xcnt = 0;
if TotalTrades > TotalTrades[1] and IsExitName("StopLoss",1) == true Then
Xcnt = Xcnt+1;
var1 = (DayHigh+daylow)/2;
if NextBarSdate == sdate and Xcnt < 3 Then
{
if Bdate != Bdate[1] or (Bdate == Bdate[1] and H < var1+PriceScale*1) Then
buy("b",AtStop,var1+PriceScale*1);
}
SetStopLoss(PriceScale*5,PointStop);
2
var : Xcnt(0);
if bdate != bdate[1] Then
Xcnt = 0;
if TotalTrades > TotalTrades[1] and IsExitName("StopLoss",1) == true Then
Xcnt = Xcnt+1;
var1 = (DayHigh+daylow)/2;
if NextBarSdate == sdate and Xcnt < 3 Then
{
if Bdate != Bdate[1] or (Bdate == Bdate[1] and L > var1-PriceScale*1) Then
sell("s",AtStop,var1-PriceScale*1);
}
SetStopLoss(PriceScale*5,PointStop);
2017-11-02
160
글번호 113840
답변완료
문의드립니다.
덕분에 도전하고 있습니다. 매번 감사합니다.
1. 시스템
5분봉기준
지표는 30분
진입
-30분차트에서 40볼린저밴드 중앙선 상향돌파시 매수진입
-40볼린저밴드 상단선 상향돌파시 추가진입
청산
-40볼린저밴드 상단선 하향돌파시 추가진입분 청산
-40이평 하향돌파시 청산
필터
60bandwidth 기울기(변동률,전보다 높으면 1 낮으면 0) 하향시(0일시) 진입하지 않음
2. 시스템
5분봉
지표는 30분
밴드폭이 n이하라면
진입1
볼린저밴드 표준편차 1.8 기준 종가가 하단선을 하향돌파하면 매수진입
청산1
조건 1
표준편차 1.8기준 종가가 상단선을 상향돌파하면 진입 1 청산
조건2
진입1한 상태에서 진입시점 밴드폭보다 밴드폭이 x%늘어나면 조건1 청산하고 매도진입으로 바꿈
청산2
조건2를 통해 매수진입이나 매도진입이 바뀐 상태에서는 청산 조건을 이평선으로 바꿈(매수라면 하향돌파, 매도라면 상향돌파)
진입 2
조건3
밴드폭이 n이하라면 표준편차 1.8기준 종가가 상향돌파하면 매도진입
조건3 상태에서 밴드폭보다 밴드폭이 x%늘어나면 조건3 청산하고 매수진입으로 바꿈.
바뀐 경우 청산기준은 청산2를 따름
3. 시스템
5분봉기준
30분봉지표
5일 이평이 20이평 상향돌파 진입
조건1 전거래가 수익이면 n개봉간 진입금지
조건2 진입은 안했지만 진입가정 손실거래가 3회 생겼으면 포지션 2배
4. 지표
5분봉기준
30분봉 볼린저밴드 밴드폭
5. 시스템
진입
5일 이평이 20이평 돌파 진입
청산
5일 이평이 20이평 하향돌파 청산
-진입 수익률이 n%가 되면 n개봉간 진입금지
-손실거래가 3회가 되면 진입포지션 수량 1.5배진입
2017-11-02
189
글번호 113839
답변완료
다른 분봉 표현을 어떻게 하는지요?
안녕하세요 수고많습니다. 다른분들 질문을 찾다가 못찾아서 질문드립니다.
1. 제가 만들려고 하는 해외선물차트에서 기본은 2분봉에서 이평값과 10분봉에서 이평값, 20분에서 이평값을 참고하려면 어떻게 하면 될까요?
2분봉에서 이평값,
10분봉에서 이평값
20분에서 이평값을 각각 가져올 수 있나요?
2. 1번이 어렵다면
2분봉에서 5개,10개씩 합쳐서 평균값을 변수A = 5개 평균, 변수b=10개평균 이렇게 저장하면
이전값에 대하여 변수A[1],변수A[2].변수A[3]이런 식으로 가능한가요? 변수A에 대한 과거값은 출력해보니 10개 정도 가능한 것 같은데 과거값이 10개정도는 표현이 가능한가요?
2분봉에서 10분봉 추정할 수 있을까요? 단순이동평균이라면
var1 = (c + c[1] + c[2] + c[3] + c[4]) /5
var2 = ma(var1,5);
10분봉과 비슷한 흐름이 나올까요? 상승과 하락추세만 맞으면 될 듯합니다. 정확히 안맞아도 가능하면 됩니다.
### 질문을 올리고 테스트를 해보았는데 결과가 맞는지 헛갈립니다.
2분봉에서 5개씩 합쳐서 평균값을 내었을때 5분봉에 1개와 맞는지 모르겠습니다.
지표로 테스트하였습니다.
Input : Period1(5), Period2(20);
var : Sma1(0),Sma2(0),Ema1(0),Ema2(0),sma3(0),sma4(0),sma5(0),sma6(0);
var : hap5(0), hap10(0);
hap5 = (c+c[1]+c[2]+c[3]+c[4])/5;
hap10 = (c+c[1]+c[2]+c[3]+c[4]+c[5]+c[6]+c[7]+c[8]+c[9])/10;
Sma1 = ma(C,Period1);
Sma2 = ma(C,Period2);
Ema1 = Ema(C,Period1);
Ema2 = Ema(C,Period2);
sma3 = ma(hap5,Period1);
sma4 = ma(hap5,Period2);
sma5 = ma(hap10,Period1);
sma6 = ma(hap10,Period2);
##sma3 = (sma1+sma1[1]+sma1[2]+sma1[3]+sma1[4])/5;
##sma4 = (sma1+sma1[1]+sma1[2]+sma1[3]+sma1[4]+sma1[5]+sma1[6]+sma1[7]+sma1[8]+sma1[9])/10;
Plot1(Sma1, "이동평균1");
Plot2(Sma2, "이동평균2");
Plot3(Ema1, "지수이동평균1");
Plot4(Ema2, "지수이동평균2");
Plot5(sma3, "5이동평균1");
Plot6(sma4, "5이동평균2");
Plot7(sma5, "10이동평균1");
Plot8(sma6, "10이동평균2");
2017-11-02
186
글번호 113838
답변완료
수식 부탁 드립니다
Var : 전환선(0);
전환선 = (highest(H,9)+lowest(L,9))/2;
Plot1(전환선, "전환선");
위 전환선을 위로 2틱 돌파하면 매수 신호을 아래로 2틱 깨면 매도 신호을 나오게 부탁 드립니다
그리고 국선과 해선 모두 신호 후 수익 5틱단위로 표기 부탁 드립니다
2017-11-02
155
글번호 113837
답변완료
타주기 지표 문의드립니다.
문의드립니다.
타주기로 30분봉과 60틱차트로 놓고 시스템을 작성하려 합니다.
기준점을 이평선 지표로 주려고 하는데요
본래차트에서는 Y축을 가격으로 지정할수가있는데
타주기 차트에서는 Y축에 가격이 안되고 화면, 전체만 지정이 가능하네요
방법이 없는건가요??
봉 갯수가 차이나서 그런걸까요??
답변부탁드려요
2017-11-01
191
글번호 113836
하늘이여o 님에 의해서 삭제되었습니다.
2017-11-01
0
글번호 113835
답변완료
kalman filter 지표를 예스트렝이더로 구현 가능한가요?
static void matrix_multiply(float* A, float* B, int m, int p, int n, float* C)
// Matrix Multiplication Routine
{
// A = input matrix (m x p)
// B = input matrix (p x n)
// m = number of rows in A
// p = number of columns in A = number of rows in B
// n = number of columns in B
// C = output matrix = A*B (m x n)
int i, j, k;
for (i=0;i<m;i++)
for(j=0;j<n;j++)
{
C[n*i+j]=0;
for (k=0;k<p;k++)
C[n*i+j]= C[n*i+j]+A[p*i+k]*B[n*k+j];
}
}
static void matrix_addition(float* A, float* B, int m, int n, float* C)
// Matrix Addition Routine
{
// A = input matrix (m x n)
// B = input matrix (m x n)
// m = number of rows in A = number of rows in B
// n = number of columns in A = number of columns in B
// C = output matrix = A+B (m x n)
int i, j;
for (i=0;i<m;i++)
for(j=0;j<n;j++)
C[n*i+j]=A[n*i+j]+B[n*i+j];
}
static void matrix_subtraction(float* A, float* B, int m, int n, float* C)
// Matrix Subtraction Routine
{
// A = input matrix (m x n)
// B = input matrix (m x n)
// m = number of rows in A = number of rows in B
// n = number of columns in A = number of columns in B
// C = output matrix = A-B (m x n)
int i, j;
for (i=0;i<m;i++)
for(j=0;j<n;j++)
C[n*i+j]=A[n*i+j]-B[n*i+j];
}
static void matrix_transpose(float* A, int m, int n, float* C)
// Matrix Transpose Routine
{
// A = input matrix (m x n)
// m = number of rows in A
// n = number of columns in A
// C = output matrix = the transpose of A (n x m)
int i, j;
for (i=0;i<m;i++)
for(j=0;j<n;j++)
C[m*j+i]=A[n*i+j];
}
static int matrix_inversion(float* A, int n, float* AInverse)
// Matrix Inversion Routine
{
// A = input matrix (n x n)
// n = dimension of A
// AInverse = inverted matrix (n x n)
// This function inverts a matrix based on the Gauss Jordan method.
// The function returns 1 on success, 0 on failure.
int i, j, iPass, imx, icol, irow;
float det, temp, pivot, factor;
float* ac = (float*)calloc(n*n, sizeof(float));
det = 1;
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
AInverse[n*i+j] = 0;
ac[n*i+j] = A[n*i+j];
}
AInverse[n*i+i] = 1;
}
// The current pivot row is iPass.
// For each pass, first find the maximum element in the pivot column.
for (iPass = 0; iPass < n; iPass++)
{
imx = iPass;
for (irow = iPass; irow < n; irow++)
{
if (fabs(A[n*irow+iPass]) > fabs(A[n*imx+iPass])) imx = irow;
}
// Interchange the elements of row iPass and row imx in both A and AInverse.
if (imx != iPass)
{
for (icol = 0; icol < n; icol++)
{
temp = AInverse[n*iPass+icol];
AInverse[n*iPass+icol] = AInverse[n*imx+icol];
AInverse[n*imx+icol] = temp;
if (icol >= iPass)
{
temp = A[n*iPass+icol];
A[n*iPass+icol] = A[n*imx+icol];
A[n*imx+icol] = temp;
}
}
}
// The current pivot is now A[iPass][iPass].
// The determinant is the product of the pivot elements.
pivot = A[n*iPass+iPass];
det = det * pivot;
if (det == 0)
{
free(ac);
return 0;
}
for (icol = 0; icol < n; icol++)
{
// Normalize the pivot row by dividing by the pivot element.
AInverse[n*iPass+icol] = AInverse[n*iPass+icol] / pivot;
if (icol >= iPass) A[n*iPass+icol] = A[n*iPass+icol] / pivot;
}
for (irow = 0; irow < n; irow++)
{
// Add a multiple of the pivot row to each row. The multiple factor
// is chosen so that the element of A on the pivot column is 0.
if (irow != iPass) factor = A[n*irow+iPass];
for (icol = 0; icol < n; icol++)
{
if (irow != iPass)
{
AInverse[n*irow+icol] -= factor * AInverse[n*iPass+icol];
A[n*irow+icol] -= factor * A[n*iPass+icol];
}
}
}
}
free(ac);
return 1;
}
static void matrix_print(float* A, int m, int n)
// Matrix print.
{
// A = input matrix (m x n)
// m = number of rows in A
// n = number of columns in A
int i, j;
for (i=0;i<m;i++)
{
printf("| ");
for(j=0;j<n;j++)
{
printf("%7.3f ", A[n*i+j]);
}
printf("|₩n");
}
}
// n states
// m inputs
// r outputs
#define n 2
#define m 1
#define r 1
float kalman_updat_(float gyroscope_rate, float accelerometer_angle)
{
// A is an n by n matrix
// B is an n by m matrix
// C is an r by n matrix
// Sz is an r by r matrix
// Sw is an n by n matrix
// xhat is an n by 1 vector
// P is an n by n matrix
// y is an r by 1 vector
// u is an m by 1 vector
// Constants.
static float A[n][n] = {{1.0, -0.019968}, {0.0, 1.0}};
static float B[n][m] = {{0.019968}, {0.0}};
static float C[r][n] = {{1.0, 0.0}};
static float Sz[r][r] = {{17.2}};
static float Sw[n][n] = {{0.005, 0.005}, {0.005, 0.005}};
// Persistant states.
static float xhat[n][1] = {{0.0}, {0.0}};
static float P[n][n] = {{0.005, 0.005}, {0.005, 0.005}};
// Inputs.
float u[m][m]; // Gyroscope rate.
float y[m][m]; // Accelerometer angle.
// Temp values.
float AP[n][n]; // This is the matrix A*P
float CT[n][r]; // This is the matrix C'
float APCT[n][r]; // This is the matrix A*P*C'
float CP[r][n]; // This is the matrix C*P
float CPCT[r][r]; // This is the matrix C*P*C'
float CPCTSz[r][r]; // This is the matrix C*P*C'+Sz
float CPCTSzInv[r][r]; // This is the matrix inv(C*P*C'+Sz)
float K[n][r]; // This is the Kalman gain.
float Cxhat[r][1]; // This is the vector C*xhat
float yCxhat[r][1]; // This is the vector y-C*xhat
float KyCxhat[n][1]; // This is the vector K*(y-C*xhat)
float Axhat[n][1]; // This is the vector A*xhat
float Bu[n][1]; // This is the vector B*u
float AxhatBu[n][1]; // This is the vector A*xhat+B*u
float AT[n][n]; // This is the matrix A'
float APAT[n][n]; // This is the matrix A*P*A'
float APATSw[n][n]; // This is the matrix A*P*A'+Sw
float KC[n][n]; // This is the matrix K*C
float KCP[n][n]; // This is the matrix K*C*P
float KCPAT[n][n]; // This is the matrix K*C*P*A'
// Fill in inputs.
u[0][0] = gyroscope_rate;
y[0][0] = accelerometer_angle;
#if 0
// Print various matrices.
printf("u =₩n");
matrix_print((float*) u, m, m);
printf("y =₩n");
matrix_print((float*) y, m, m);
printf("A =₩n");
matrix_print((float*) A, n, n);
printf("B =₩n");
matrix_print((float*) B, n, m);
printf("State =₩n");
matrix_print((float*) xhat, n, 1);
#endif
// Updat the state estimate by extrapolating estimate with gyroscope input.
// xhat_est = A * xhat + B * u
matrix_multiply((float*) A, (float*) xhat, n, n, 1, (float*) Axhat);
matrix_multiply((float*) B, (float*) u, n, r, 1, (float*) Bu);
matrix_addition((float*) Axhat, (float*) Bu, n, 1, (float*) AxhatBu);
#if 0
printf("State Estimate =₩n");
matrix_print((float*) AxhatBu, n, 1);
#endif
// Compute the innovation.
// Inn = y - c * xhat;
matrix_multiply((float*) C, (float*) xhat, r, n, 1, (float*) Cxhat);
matrix_subtraction((float*) y, (float*) Cxhat, r, 1, (float*) yCxhat);
#if 0
printf("Innovation =₩n");
matrix_print((float*) yCxhat, r, 1);
#endif
// Compute the covariance of the innovation.
// s = C * P * C' + Sz
matrix_transpose((float*) C, r, n, (float*) CT);
matrix_multiply((float*) C, (float*) P, r, n, n, (float*) CP);
matrix_multiply((float*) CP, (float*) CT, r, n, r, (float*) CPCT);
matrix_addition((float*) CPCT, (float*) Sz, r, r, (float*) CPCTSz);
// Compute the kalman gain matrix.
// K = A * P * C' * inv(s)
matrix_multiply((float*) A, (float*) P, n, n, n, (float*) AP);
matrix_multiply((float*) AP, (float*) CT, n, n, r, (float*) APCT);
matrix_inversion((float*) CPCTSz, r, (float*) CPCTSzInv);
matrix_multiply((float*) APCT, (float*) CPCTSzInv, n, r, r, (float*) K);
// Updat he state estimate.
// xhat = xhat_est + K * Inn;
matrix_multiply((float*) K, (float*) yCxhat, n, r, 1, (float*) KyCxhat);
matrix_addition((float*) AxhatBu, (float*) KyCxhat, n, 1, (float*) xhat);
// Compute the new covariance of the estimation error.
// P = A * P * A' - K * C * P * A' + Sw
matrix_transpose((float*) A, n, n, (float*) AT);
matrix_multiply((float*) AP, (float*) AT, n, n, n, (float*) APAT);
matrix_addition((float*) APAT, (float*) Sw, n, n, (float*) APATSw);
matrix_multiply((float*) K, (float*) C, n, r, n, (float*) KC);
matrix_multiply((float*) KC, (float*) P, n, n, n, (float*) KCP);
matrix_multiply((float*) KCP, (float*) AT, n, n, n, (float*) KCPAT);
matrix_subtraction((float*) APATSw, (float*) KCPAT, n, n, (float*) P);
// Return the estimate.
return xhat[0][0];
}
int main(int argc, char **argv)
{
int i;
float gyro_input;
float accel_input;
float kalman_output;
for (i = 0; i < SAMPLE_COUNT; ++i)
{
// Get the gyro and accelerometer input.
gyro_input = sample_data[i][0];
accel_input = sample_data[i][1];
// Updat the Kalman filter and get the output.
kalman_output = kalman_updat(gyro_input, accel_input);
// Print out input data and the kalman output.
printf("%d gyro=%7.3f deg/sec accel=%7.3f degrees kalman_output=%5.1f degrees₩n", i, gyro_input, accel_input, kalman_output);
}
return 0;
}
2017-11-01
352
글번호 113834