커뮤니티
예스랭귀지 Q&A
답변완료
[공지] 예스랭귀지 AI 어시스턴트, '예스나 AI' 출시 및 무료 체험 안내
안녕하세요, 예스스탁 입니다.복잡한 수식 공부 없이 여러분의 아이디어를 말하면 시스템 트레이딩 언어 예스랭귀지로 작성해주는 서비스예스나 AI(YesNa AI)가 출시되었습니다.지금 예스나 AI를 직접 경험해 보실 수 있도록 20크레딧(질문권 20회)를 무료로 증정해 드리고 있습니다.바로 여러분의 아이디어를 코드로 변환해보세요.--------------------------------------------------🚀 YesNa AI 핵심 기능- 지표식/전략식/종목검색식 생성: 자연어로 요청하면 예스랭귀지 문법에 맞는 코드를 작성합니다.- 종목검색식 변환 지원: K증권의 종목 검색식을 예스랭귀지로 변환 지원합니다.- 컴파일 검증: 작성된 코드가 실행 가능한지 컴파일러를 통해 문법 검증을 거쳐 결과물을 제공합니다.상세한 서비스 개요 및 활용 방법은 [서비스 소개 페이지]에서 확인하실 수 있습니다.▶ 서비스 소개 페이지: 바로가기서비스 사용 유의사항 및 결제 환불정책은 [이용약관]을 참고 부탁드립니다.▶ 서비스 이용약관: 바로가기💬 이용 문의사용 중 문의사항은 [프로그램 사용법 Q&A] 게시판에서 [예스나 AI] 카테고리를 설정 후 문의해 주시면 상세히 안내해 드리겠습니다.--------------------------------------------------앞으로도 AI를 활용한 다양한 트레이딩 기능들을 지속적으로 선보일 예정입니다.많은 관심과 기대 부탁드립니다.
2026-02-27
1514
글번호 230811
답변완료
트레이딩뷰 수식 변환 요청드립니다.
슈퍼트렌드 수식 변환 요청드립니다.
과거글 찾아보니 예스스탁에서 만든 슈퍼트렌드가 있던데 트레이딩뷰의 슈퍼트렌드와 타점이 다릅니다. 그래서 함수 공부도 해볼 겸 트레이딩뷰에서 공식 제공하는 수식을 변환하고 있는데, 생각대로 그려지지 않습니다.
예스 랭귀지를 처음 해보는거라 변수 선언 등에서 뭔가 놓친 부분이 있는것 같은데
아래의 트레이딩뷰 코드와 똑같이 잘 변환됬는지, 혹시 예스 랭귀지 문법상 틀린 부분이 있는지 확인 부탁드립니다. (그림이 안그려지는 걸로 봐선 분명 틀린 부분이 있을 건데 잘 모르겠습니다.)
/*트레이딩뷰 소스 발췌
pine_supertrend(factor, atrPeriod) =>
src = hl2
atr = ta.atr(atrPeriod)
upperBand = src + factor * atr
lowerBand = src - factor * atr
prevLowerBand = nz(lowerBand[1])
prevUpperBand = nz(upperBand[1])
lowerBand := lowerBand > prevLowerBand or close[1] < prevLowerBand ? lowerBand : prevLowerBand
upperBand := upperBand < prevUpperBand or close[1] > prevUpperBand ? upperBand : prevUpperBand
int direction = na
float superTrend = na
prevSuperTrend = superTrend[1]
if na(atr[1])
direction := 1
else if prevSuperTrend == prevUpperBand
direction := close > upperBand ? -1 : 1
else
direction := close < lowerBand ? 1 : -1
superTrend := direction == -1 ? lowerBand : upperBand
[superTrend, direction]
[pineSupertrend, pineDirection] = pine_supertrend(3, 10)
*/
// 예스랭귀지 변환
input : factor(3),atrPeriod(10);
var : src(0), sATR(0), upperBand(0), lowerBand(0), prevLowerBand(0), prevUpperBand(0);
var : direction(0), superTrend(0), prevSuperTrend(0), linecolor(0);
src = (High + Low) / 2;
sATR = ATR(atrPeriod);
upperBand = src + factor * sATR;
lowerBand = src - factor * sATR;
prevLowerBand = lowerBand[1];
prevUpperBand = upperBand[1];
if !(lowerBand > prevLowerBand or close[1] < prevLowerBand) Then{
lowerBand = prevLowerBand;
}
if !(upperBand < prevUpperBand or close[1] > prevUpperBand) Then{
upperBand = prevUpperBand;
}
prevSuperTrend = superTrend[1];
if IsNAN(sATR[1]) Then
{
direction = 1;
}Else if prevSuperTrend == prevUpperBand Then
{
direction = IFF(close > upperBand, -1, 1);
}
Else
{
direction = IFF(close < lowerBand, 1, -1);
}
superTrend = IFF(direction == -1, lowerBand, upperBand);
linecolor = IFF(direction == -1 , Green, Red);
plot1(superTrend,"SuperTrend",linecolor);
2023-08-23
1291
글번호 171766
답변완료
수식문의 드립니다
input : sum_length(500),vwap_smoothing(400);
var : vol_period(0),evwma(0),vwap_smooth(0),long(False),short(False);
input : length(60);
var : mav(0);
vol_period = AccumN(volume, sum_length);
evwma = 100.100;
evwma = ((vol_period - volume) * iff(IsNan(evwma[1]) == true, close,evwma[1]) + volume * close) / vol_period;
if Bdate != Bdate[1] Then
{
var1 = 0;
Var2 = 0;
Var3 = 0;
}
var1 = var1 +((H+L+C)/3)*v;
Var2 = Var2 + v;
Var3 = var1/Var2;
vwap_smooth = ema(Var3, vwap_smoothing);
Plot1(evwma);
Plot2(vwap_smooth);
지표식에서 종목 검색식으로 할려고
밑부분 두줄 삭제하고
(((Plot1(evwma);
Plot2(vwap_smooth);)))
evwma,vwap두선이 크로스업 할때 상하 위치가 반대인 경우도 있었서
if CrossUp(evwma,vwap_smooth) or CrossUp(vwap_smooth,evwma) Then
Find(1);
로 적용했는데 크로스 다운도 검색이 되고 먼가 잘못된듯 합니다.
도움 부탁 드리겠습니다.
2023-08-23
1269
글번호 171765
답변완료
수식 부탁합니다
안녕하세요!
옵션 전일 매도한 분량을 종목에 관계 없이 당일 장 시작 전 동시호가체결시간(오전 8시 35분)에 시장가로 전량 청산 주문 하는 식 원합니다.
2023-08-23
1202
글번호 171763
매버릭 님에 의해서 삭제되었습니다.
2023-08-23
1
글번호 171761
답변완료
시스템 작성의뢰
수고 하십니다!
1.거래량 5 이평선이 15 이상 상승하면 신호로 알려주고 on balance price 지표가 - 33 이하로 내려가고 obv 지표가 -2400 이하로 하락하고 pvi지표가 99.50 이하로 하락하고 biii지표가 -0.15 이하로 하락 하고 er bear power 지표가 0.00 이상 상승 하고120,240,480,960 ,1920 이동평균선이 역배열이 되고 960
이평선과 1920 이평선의 간격이 7틱이상 벌어지고 120 이평선이 240 이평선을 업크로스할때 6 계약 매수를 하고난 후 30 틱 이상 하락 하면 3 계약 매수를 하고난 후 30 틱 이상 하락 하면 3 계약 매수를 또 하고 60 틱이상 상승한 다음 120
이평선이 240 이평선을 다운크로스 할때 청산을 한다
2.거래량 5 이평선이 15 이상 상승하면 신호로 알려주고 on balance price 지표가 35 이상 상승하고 obv 지표가 200 이상 상승 하고 pvi지표가 100.50 이상 상승 하고 biii 지표가 0.01 이상 상승 하고 er bear power 지표가 - 0.01 이하로 하락 하고
120,240,480,960 ,1920 , 3840 이동평균선이 정배열이 되고 1920 이평선과 3840 이평선의 간격이 16 틱이상 벌어지고
120 이평선이 240 이평선을 다운크로스할때 6 계약 매도를 하고난 후 30 틱 이상 상승 하면 3 계약 매도를 하고난 후 30 틱 이상 상승 하면 3 계약 매도를 또 하고 60 틱이상 하락한 다음 120 이평선이 240 이평선을 업크로스 할때 청산을 한다
2023-08-23
1186
글번호 171760
답변완료
부탁드립니다
###3분봉 1분봉 에 사용하고싶습니다
1,
input : ATrPeriod2(11),factor2(2.0);
var : src2(0),ATrv2(0),upperband2(0),lowerBand2(0),direction2(0),superTrend2(0);
var : prevupperband2(0),prevlowerBand2(0),prevsupertrend2(0);
src2 = (h+l)/2;
atrv2 = atr(atrPeriod2);
upperBand2 = src2 + factor2 * atrv2;
lowerBand2 = src2 - factor2 * atrv2;
prevLowerBand2 = iff(IsNan(lowerBand2[1])==False,lowerBand2[1],0);
prevUpperBand2 = iff(IsNan(upperBand2[1])==false,upperBand2[1],0);
lowerBand2 = iff(lowerBand2 > prevLowerBand2 or close[1] < prevLowerBand2 , lowerBand2 , prevLowerBand2);
upperBand2 = iff(upperBand2 < prevUpperBand2 or close[1] > prevUpperBand2 , upperBand2 , prevUpperBand2);
prevsupertrend2 = iff(IsNan(SuperTrend2[1])==false,SuperTrend2[1],0);
if isnan(atrv2[1]) == true Then
direction2 = 1;
else if SuperTrend2[1] == UpperBand2[1] Then
direction2 = iff(close > upperBand2 , -1 , 1);
else
direction2 = iff(close < lowerBand2 , 1 , -1);
superTrend2 = iff(direction2 == -1 , lowerBand2 , upperBand2);
if direction2 < 0 Then
Plot3(superTrend2,"upTrend2",Black);
Else
NoPlot(3);
2,
input : ATrPeriod3(12),factor3(3.0);
var : src3(0),ATrv3(0),upperband3(0),lowerBand3(0),direction3(0),superTrend3(0);
var : prevupperband3(0),prevlowerBand3(0),prevsupertrend3(0);
src3 = (h+l)/2;
atrv3 = atr(atrPeriod3);
upperBand3 = src3 + factor3 * atrv3;
lowerBand3 = src3 - factor3 * atrv3;
prevLowerBand3 = iff(IsNan(lowerBand3[1])==False,lowerBand3[1],0);
prevUpperBand3 = iff(IsNan(upperBand3[1])==false,upperBand3[1],0);
lowerBand3 = iff(lowerBand3 > prevLowerBand3 or close[1] < prevLowerBand3 , lowerBand3 , prevLowerBand3);
upperBand3 = iff(upperBand3 < prevUpperBand3 or close[1] > prevUpperBand3 , upperBand3 , prevUpperBand3);
prevsupertrend3 = iff(IsNan(SuperTrend3[1])==false,SuperTrend3[1],0);
if isnan(atrv3[1]) == true Then
direction3 = 1;
else if prevsupertrend3 == prevUpperBand3 Then
direction3 = iff(close > upperBand3 , -1 , 1);
else
direction3 = iff(close < lowerBand3 , 1 , -1);
superTrend3 = iff(direction3 == -1 , lowerBand3 , upperBand3);
if direction3 < 0 Then
Plot5(superTrend3,"upTrend3",BlacK);
Else
NoPlot(5);
if direction3 > 0 Then
Plot6(superTrend3,"downTrend3",GreeN);
Else
NoPlot(6);
### 수정할 부분이 있다면 3분 1분봉 용으로 사용하고싶습니다
2023-08-22
953
글번호 171759
답변완료
array
안녕하세요?
StandardDevArray(arr,10,1);에서
- 괄호 우측 1은 무엇인가요?
- 2, 3으로 변경해도 결과가 같습니다
2023-08-22
1118
글번호 171758
답변완료
83425번 2항 문의사항 입니다.
83425번
2번항에 해당되는 파인스크립 을 예스 수식으로 변환 부탁드립니다 에서
변환해주신 수식 적용하니 지표가 트레이딩뷰차트랑 예스차트랑 다르게 표기 됩니다.
파일 첨부 하오니 검토 부탁 드리겠습니다.
아래: 파인스크립트 수식 83425번 2번항
atr_length = input(500)
start = input(500)
increment = input(500)
maximum = input(500)
entry_bars = input(500, title='Entry on Nth trend bar')
atr = ta.atr(atr_length)
atr := na(atr) ? ta.tr : atr
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 close <= psar[1] // PSAR switches from long to short
sar_short_to_long = trend_dir[1] == -1 and close >= psar[1] // PSAR switches from short to long
trend_change = barstate.isfirst[1] or sar_long_to_short or sar_short_to_long
// Calculate trend direction
trend_dir := barstate.isfirst[1] and close[1] > open[1] ? 1 : barstate.isfirst[1] and close[1] <= open[1] ? -1 : sar_long_to_short ? -1 : sar_short_to_long ? 1 : nz(trend_dir[1])
trend_bars := sar_long_to_short ? -1 : sar_short_to_long ? 1 : trend_dir == 1 ? nz(trend_bars[1]) + 1 : trend_dir == -1 ? nz(trend_bars[1]) - 1 : nz(trend_bars[1])
// Calculate Acceleration Factor
af := trend_change ? start : trend_dir == 1 and high > ep[1] or trend_dir == -1 and low < ep[1] ? math.min(maximum, af[1] + increment) : af[1]
// Calculate extreme point
ep := trend_change and trend_dir == 1 ? high : trend_change and trend_dir == -1 ? low : trend_dir == 1 ? math.max(ep[1], high) : math.min(ep[1], low)
// Calculate PSAR
psar := barstate.isfirst[1] and close[1] > open[1] ? low[1] : barstate.isfirst[1] and close[1] <= open[1] ? high[1] : trend_change ? ep[1] : trend_dir == 1 ? psar[1] + af * atr : psar[1] - af * atr
plot(psar, style=plot.style_cross, color=trend_dir == 1 ? color.green : color.red, linewidth=2)
// Strategy
strategy.entry('Long', strategy.long, when=trend_bars == entry_bars)
strategy.entry('Short', strategy.short, when=trend_bars == -entry_bars)
---------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------
아래: 변환해주신 수식 입니다.
2-1 지표
input : atr_length(500),start(500),increment(500),maximum(500),entry_bars(500);
var : atrv(0),psar(0),af(0),trend_dir(0),ep(0),trend_bars(0);
var : sar_long_to_short(False),sar_short_to_long(False);
var : trend_change(False);
atrv = atr(atr_length);
atrv = iff(IsNan(atrv) == true ,TrueRange , atrv);
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 close <= psar[1]; // PSAR switches from long to short
sar_short_to_long = trend_dir[1] == -1 and close >= psar[1]; // PSAR switches from short to long
trend_change = sar_long_to_short or sar_short_to_long;
// Calculate trend direction
trend_dir = iff(close[1] > open[1] , 1 ,
IFf(close[1] <= open[1] , -1 ,
IFf(sar_long_to_short , -1 ,
iff(sar_short_to_long , 1 , iff(isnan(trend_dir[1])==False,trend_dir[1],0)))));
trend_bars = iff(sar_long_to_short , -1 ,
IFf(sar_short_to_long , 1 ,
iff(trend_dir == 1 , iff(isnan(trend_bars[1])==False,trend_bars[1],0)+ 1 ,
IFf( trend_dir == -1 , iff(isnan(trend_bars[1])==False,trend_bars[1],0) - 1 , iff(isnan(trend_bars[1])==False,trend_bars[1],0) ))));
// Calculate Acceleration Factor
af = iff(trend_change , start ,
iff(trend_dir == 1 and high > 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 , high ,
iff(trend_change and trend_dir == -1 , low ,
iff(trend_dir == 1 , max(ep[1], high) , min(ep[1], low))));
// Calculate PSAR
psar = iff(close[1] > open[1] , low[1] ,
IFf(close[1] <= open[1] , high[1] ,
IFf(trend_change , ep[1] ,
IFf(trend_dir == 1 , psar[1] + af * atrv , psar[1] - af * atrv))));
plot1(psar,"psar",iff(trend_dir == 1 , green , red));
2-2 시스템
input : atr_length(500),start(500),increment(500),maximum(500),entry_bars(500);
var : atrv(0),psar(0),af(0),trend_dir(0),ep(0),trend_bars(0);
var : sar_long_to_short(False),sar_short_to_long(False);
var : trend_change(False);
atrv = atr(atr_length);
atrv = iff(IsNan(atrv) == true ,TrueRange , atrv);
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 close <= psar[1]; // PSAR switches from long to short
sar_short_to_long = trend_dir[1] == -1 and close >= psar[1]; // PSAR switches from short to long
trend_change = sar_long_to_short or sar_short_to_long;
// Calculate trend direction
trend_dir = iff(close[1] > open[1] , 1 ,
IFf(close[1] <= open[1] , -1 ,
IFf(sar_long_to_short , -1 ,
iff(sar_short_to_long , 1 , iff(isnan(trend_dir[1])==False,trend_dir[1],0)))));
trend_bars = iff(sar_long_to_short , -1 ,
IFf(sar_short_to_long , 1 ,
iff(trend_dir == 1 , iff(isnan(trend_bars[1])==False,trend_bars[1],0)+ 1 ,
IFf( trend_dir == -1 , iff(isnan(trend_bars[1])==False,trend_bars[1],0) - 1 , iff(isnan(trend_bars[1])==False,trend_bars[1],0) ))));
// Calculate Acceleration Factor
af = iff(trend_change , start ,
iff(trend_dir == 1 and high > 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 , high ,
iff(trend_change and trend_dir == -1 , low ,
iff(trend_dir == 1 , max(ep[1], high) , min(ep[1], low))));
// Calculate PSAR
psar = iff(close[1] > open[1] , low[1] ,
IFf(close[1] <= open[1] , high[1] ,
IFf(trend_change , ep[1] ,
IFf(trend_dir == 1 , psar[1] + af * atrv , psar[1] - af * atrv))));
IF trend_bars == entry_bars TheN
Buy();
IF trend_bars == -entry_bars TheN
Sell();
2-3 종목검색
input : atr_length(500),start(500),increment(500),maximum(500),entry_bars(500);
var : atrv(0),psar(0),af(0),trend_dir(0),ep(0),trend_bars(0);
var : sar_long_to_short(False),sar_short_to_long(False);
var : trend_change(False);
atrv = atr(atr_length);
atrv = iff(IsNan(atrv) == true ,TrueRange , atrv);
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 close <= psar[1]; // PSAR switches from long to short
sar_short_to_long = trend_dir[1] == -1 and close >= psar[1]; // PSAR switches from short to long
trend_change = sar_long_to_short or sar_short_to_long;
// Calculate trend direction
trend_dir = iff(close[1] > open[1] , 1 ,
IFf(close[1] <= open[1] , -1 ,
IFf(sar_long_to_short , -1 ,
iff(sar_short_to_long , 1 , iff(isnan(trend_dir[1])==False,trend_dir[1],0)))));
trend_bars = iff(sar_long_to_short , -1 ,
IFf(sar_short_to_long , 1 ,
iff(trend_dir == 1 , iff(isnan(trend_bars[1])==False,trend_bars[1],0)+ 1 ,
IFf( trend_dir == -1 , iff(isnan(trend_bars[1])==False,trend_bars[1],0) - 1 , iff(isnan(trend_bars[1])==False,trend_bars[1],0) ))));
// Calculate Acceleration Factor
af = iff(trend_change , start ,
iff(trend_dir == 1 and high > 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 , high ,
iff(trend_change and trend_dir == -1 , low ,
iff(trend_dir == 1 , max(ep[1], high) , min(ep[1], low))));
// Calculate PSAR
psar = iff(close[1] > open[1] , low[1] ,
IFf(close[1] <= open[1] , high[1] ,
IFf(trend_change , ep[1] ,
IFf(trend_dir == 1 , psar[1] + af * atrv , psar[1] - af * atrv))));
IF trend_bars == entry_bars TheN
find(1);
즐거운 하루되세요
2023-08-22
1604
글번호 171757
답변완료
전략실행차트 멀티 사용법
안녕하세요.
현재 전략실행차트를 통해 시스템트레이딩을 잘 활용하고 있는데요,
혹시 여러개의 차트를 동시에 활용해서 시스템을 만들 수 있나요?
그리고 수식 작성 시,
당일의 고점, 저점을 dayhigh[1], daylow[1] 함수를 활용하고 있는데요,
최근 한시간 이내의 고점, 저점을 계산해주는 함수가 따로 있을까요?
확인부탁드립니다. 감사합니다.
2023-08-22
1236
글번호 171754