커뮤니티
예스랭귀지 Q&A
답변완료
[공지] 예스랭귀지 AI 어시스턴트, '예스나 AI' 출시 및 무료 체험 안내
안녕하세요, 예스스탁 입니다.복잡한 수식 공부 없이 여러분의 아이디어를 말하면 시스템 트레이딩 언어 예스랭귀지로 작성해주는 서비스예스나 AI(YesNa AI)가 출시되었습니다.지금 예스나 AI를 직접 경험해 보실 수 있도록 20크레딧(질문권 20회)를 무료로 증정해 드리고 있습니다.바로 여러분의 아이디어를 코드로 변환해보세요.--------------------------------------------------🚀 YesNa AI 핵심 기능- 지표식/전략식/종목검색식 생성: 자연어로 요청하면 예스랭귀지 문법에 맞는 코드를 작성합니다.- 종목검색식 변환 지원: K증권의 종목 검색식을 예스랭귀지로 변환 지원합니다.- 컴파일 검증: 작성된 코드가 실행 가능한지 컴파일러를 통해 문법 검증을 거쳐 결과물을 제공합니다.상세한 서비스 개요 및 활용 방법은 [서비스 소개 페이지]에서 확인하실 수 있습니다.▶ 서비스 소개 페이지: 바로가기서비스 사용 유의사항 및 결제 환불정책은 [이용약관]을 참고 부탁드립니다.▶ 서비스 이용약관: 바로가기💬 이용 문의사용 중 문의사항은 [프로그램 사용법 Q&A] 게시판에서 [예스나 AI] 카테고리를 설정 후 문의해 주시면 상세히 안내해 드리겠습니다.--------------------------------------------------앞으로도 AI를 활용한 다양한 트레이딩 기능들을 지속적으로 선보일 예정입니다.많은 관심과 기대 부탁드립니다.
2026-02-27
8158
글번호 230811
하늘이여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
847
글번호 113834
답변완료
문의요~
if MarketPosition == 1 Then
ExitLong("항롱손절",AtStop,EntryPrice-PriceScale*40);
if MarketPosition == -1 Then
ExitShort("항숏손절",AtStop,EntryPrice+PriceScale*40);
}
1. 손절식이거든요~ 조건만족시에 즉시 주문이 나가게 할려고 하는데
봉이 완성되고나서 주문이 나가는거 같아서요~
맞게 작성이 된건지 문의드립니다.
2. 당일 손실200틱이상이면 해당종목에서 더이상 진입신호 안나오는 식도 부탁드립니다.
3. 최근100개봉 중에서 양봉의개수가 60개이상이거나 음봉의개수가60개이상일때만 진입신호가 나오게 부탁드립니다.
4.그리고 하나더 추가해서 최근100봉중에서 봉의 평균절대값이4틱이상이다도 부탁드릴게요~
2017-11-02
230
글번호 113833
답변완료
수식 수정부탁드립니다
안녕하세요?
최근고점과 직전고점위 10틱 위에 원(또는 점)으로 고점이 출력되도록 표시되고....
최근저점과 직전저점아래 10틱 아래에 원(또는 점) 으로 저점이 출력되도록 부탁드립니다.
54927번 식은 아래와 같습니다.....
input : Left(3),Right(3);
var : SHV1(0),SHV2(0),SHL1(0),SHL2(0);
var : SLV1(0),SLV2(0),SLH1(0),SLH2(0);
var : AA(0),BB(0),CC(0);
if SwingHigh(1,h,Left,right,left+right+1) != -1 Then{
SHV1 = H[Right]; //최근고점
SHV2 = SHV1[1]; //직전고점
SHL1 = L; //최근 고점이후 최저가 저장할 변수 초기값
SHL2 = SHL1[1]; //직전고점과 최근고점 사이 최저가
}
#최근 고점 발생 후 최저가 갱신
If SHV1 > 0 and L < SHL1 Then
SHL1 = L;
#종가가 최근 고점보다 클때
if SHV2 > 0 and C > SHV1 Then{
AA = SHL2;
BB = SHV1;
CC = SHL1;
}
if SwingLow(1,L,Left,right,left+right+1) != -1 Then{
SLV1 = L[Right]; //최근저점
SLV2 = SLV1[1]; //직전저점
SLH1 = H; //최근 저점이후 최고가 저장할 변수 초기값
SLH2 = SLH1[1]; //직전저점과 최근저점 사이 최고가
}
#최근 저점 발생 후 최고가 갱신
If SLV1 > 0 and H > SLH1 Then
SLH1 = H;
#종가가 최근 저점보다 작을때
if C < SLV1 and SLV2 > 0 Then{
AA = SLH2;
BB = SLV1;
CC = SLH1;
}
2017-11-01
267
글번호 113830
답변완료
문의드립니다
안녕하세요?
아래수식에서 신호발생후 한개봉이후에 다시조건이만족하면 신호가발생하게해주세요
제가원하는것은 양봉3개 또는 음봉3개가 나올때마다 발생하는sound를 듣기위함입니다
항시집중할수가없어서 입니다
아래수식이가지고있는 저에게 한가지문제점은 포지션을 보유하고있는경우에는 양봉3개나 음봉3개가 다시발생해도 이미보유하고있는포지션으로 인해 보유포지션의 신호가 청산이되기전가지는 양봉3개 또는 음봉3개가 나와도 또발생하지않는점입니다
if CountIF(C>O,3)==3 Then
buy();
if CountIF(C<O,3)==3 Then
Sell();
감사합니다
2017-11-01
282
글번호 113827
답변완료
수식 문의 드립니다.
수고하십니다.
아래 수식을 기본으로
변경가능한 일정한 기간(P)내에 Condition1의 조건을 1회이상 만족하고 그 기간동안에
만족한 회수를 합산한 검색결과값으로 나타내는 종목검색식으로 변경 해주시면 고맙겠습니다.
input : P(10);
Condition1 = V >= V[1]*1.5 and C > O and H-max(C,O) >= abs(C-O)*0.5;
if countif(Condition1==true,P) >= 2 Then
find(1);
2017-11-01
258
글번호 113826
답변완료
수식작성
시스템트레이딩 수식좀 부탁드립니다.
선물분봉차트로 당일청산입니다. 5분봉으로 하고 당일고가+당일저가/2의 중간값을 중앙선으로 합니다. 창은 두 개를 띄어놓고 매수진입창과 매도진입창을 따로 운영합니다. 매수진입창은 지수가 중앙선1틱위로 올라가며는 매수진입, 손절은 진입가기준 5틱반대로 가며는 손절입니다. 매도진입창은 지수가 중앙선 아래로 1틱 내려가며는 매도진입, 손절은 진입가 5틱반대로 가며는 손절입니다. 하나의 창에서 손절이 하루 3번 나오며는 그 창에서는 더 이상 진입하지 않습니다. 차트수식입니다. (dayhigh()+daylow())/2
감사합니다.
2017-11-01
240
글번호 113817
답변완료
수식
아래 수식을 매수진입과 매도진입으로 나누어 두 개창을 뛰어놓고 분활해서 거래하고자 하는데 수식을 두가지수식으로 나누어서 만들어 주시며는 감사하겠습니다, 감사합니다.
Var : vA_value(0), vB_value(0),vStartMin(0);
input : BarsEntryInterval(20), pMaxContracts(4),pTimeInterval(11);
var : PreTT(0), TT(0),cond99(false);
If date <> date[1] Then Begin
vA_value = H;
vB_value = L;
Cond99 = False;
vStartMin = TimeToMinutes(stime);
PreTT = TotalTrades[1];
End;
If Cond99 == False Then Begin
if vA_value < H Then vA_value = H;
if vB_value > L Then vB_value = L;
End;
If (TimeToMinutes(stime) - vStartMin) == pTimeInterval And Cond99 == False Then Begin
Cond99 = True;
End;
if Cond99 Then Begin
If CrossUp(C, vA_value) Then ExitShort("BX");
If CrossDown(C, vB_value) Then ExitLong("SX");
If time <= 115900 And TT - PreTT <= 2 Then Begin
If CrossUp(C, vA_value) Then Buy("B");
If CrossDown(C, vB_value) Then Sell("S");
End;
if MarketPosition == 1 And C > vA_value And CurrentContracts < pMaxContracts Then Begin
if BarsSinceEntry == ( 1 * BarsEntryInterval) Then
Buy("reBuy1");
if BarsSinceEntry == ( 2 * BarsEntryInterval)
Then
Buy("reBuy2");
if BarsSinceEntry == ( 3 * BarsEntryInterval)
Then
Buy("reBuy3");
End
Else if MarketPosition == -1 And C < vB_value And CurrentContracts < pMaxContracts Then Begin
if BarsSinceEntry == ( 1 * BarsEntryInterval) Then
Sell("reSell1");
if BarsSinceEntry == ( 2 * BarsEntryInterval)
Then
Sell("reSell2");
if BarsSinceEntry == ( 3 * BarsEntryInterval)
Then
Sell("reSell3");
End;
End;
SetStopEndofday(151500);
2017-11-01
247
글번호 113816
답변완료
이것저것 문의드립니다.
도와주시는 덕분에 도전하고 있습니다. 매번 감사합니다.
1,2번은 지표들로 바이너리 웨이브 지표를 만들려고 하는데요. 가능할런지요. 저런 식의 분봉 참조가 불가능하다면 30분봉 하나만이라도 부탁드립니다.
1.
1분봉기준
30분 RSI 70 이상
10분 RSI 70 이상
5분 RSI 70 이상
2.
1분봉기준
5분
MFI 변화율 상승이면(이전봉보다 더 크면) 1
BANDWIDTH 동일(변화율 상승이면)
스토캐스틱 동일
매수잔량-매도잔량 동일
상승형거래량-하락형거래량 동일
상승형체결건수-하락형체결건수 동일
3.
모든 조건 충족시 진입
-20 이평이 50이평보다 크다
-스토캐스틱(5,3)이 25 이하
-해머형 or 관통형 발생(발생하면 신호봉이라고 침)
-신호봉의 종가가 직전봉의 고점보다 낮음.
청산
목표청산 2*ATR
손절청산 ATR- 진입봉의 저가
4. 시스템
이평선 위로 봉이 세개 이상 있을 때만 진입
이평선 아래로 봉이 세개 이상 있을 때만 청산
5. 시스템질문
헷갈려서 질문드립니다.
-1 먄약에 매수는 종가가 당일 고가와 저가변동폭의 하위 20% 이내에 형성되면 당일에 매수하고
-2 종가가 당일 고가와 저가 변동폭의 상위 20%이내에 형성되면 익일 시가에 매도
이렇게 하면 -1 매수는 -2번 조건에 의해 당일에 사서 익일에 상위 20%이내에 청산될텐데요.
만약에 2번의 조건을 따로 매도 전략으로 만드려면 어떻게 코딩을 짜면 될까요? 그러니까 어제 사서 오늘 청산된 것 말고 따로 -2 전략의 조건을 감시해서 익일 시가에 매도포지션을 잡게 하려면 어떻게 하면 될까요?
종합하면 일봉으로 전략 짰을 대 3일 매수 진입 4일 매수진입 청산 5일 매도 진입 이렇게 되는 코딩이 궁금합니다.
2017-11-01
293
글번호 113813