커뮤니티
예스랭귀지 Q&A
답변완료
[공지] 예스랭귀지 AI 어시스턴트, '예스나 AI' 출시 및 무료 체험 안내
안녕하세요, 예스스탁 입니다.복잡한 수식 공부 없이 여러분의 아이디어를 말하면 시스템 트레이딩 언어 예스랭귀지로 작성해주는 서비스예스나 AI(YesNa AI)가 출시되었습니다.지금 예스나 AI를 직접 경험해 보실 수 있도록 20크레딧(질문권 20회)를 무료로 증정해 드리고 있습니다.바로 여러분의 아이디어를 코드로 변환해보세요.--------------------------------------------------🚀 YesNa AI 핵심 기능- 지표식/전략식/종목검색식 생성: 자연어로 요청하면 예스랭귀지 문법에 맞는 코드를 작성합니다.- 종목검색식 변환 지원: K증권의 종목 검색식을 예스랭귀지로 변환 지원합니다.- 컴파일 검증: 작성된 코드가 실행 가능한지 컴파일러를 통해 문법 검증을 거쳐 결과물을 제공합니다.상세한 서비스 개요 및 활용 방법은 [서비스 소개 페이지]에서 확인하실 수 있습니다.▶ 서비스 소개 페이지: 바로가기서비스 사용 유의사항 및 결제 환불정책은 [이용약관]을 참고 부탁드립니다.▶ 서비스 이용약관: 바로가기💬 이용 문의사용 중 문의사항은 [프로그램 사용법 Q&A] 게시판에서 [예스나 AI] 카테고리를 설정 후 문의해 주시면 상세히 안내해 드리겠습니다.--------------------------------------------------앞으로도 AI를 활용한 다양한 트레이딩 기능들을 지속적으로 선보일 예정입니다.많은 관심과 기대 부탁드립니다.
2026-02-27
8034
글번호 230811
답변완료
수식부탁합니다
스토캐스틱
A = (20,12,12)
B = (25,6,6)
C = (5,3,3)
두가지 종목 검색식 부탁합니다
1. 하나라도 (어떤 경우는 2개 이상) 지표가 골든크로스 발생하고
골든크로스가 발생하지 않은 지표는 스토캐스틱 K값 > D값 종목 검색식
2. A와 B 지표가 스토캐스틱 K값 > D값인 경우여야 하고 이때
C가 골든크로스 발생한 종목 검색식
2025-04-12
482
글번호 190060
답변완료
수식 부탁드립니다
지표식 부탁드리고요. 시스템식도 가능하면 부탁드립니다.
// INPUTS ========================================================================================================{
//@variable len Length of the Gaussian filter for smoothing (minimum value: 5)
int len = input.int(30, "Length", minval = 5)
//@variable mode 선택 the mode of aggregation to be used: AVG (average), MEADIAN (median), or MODE (mode)
string mode = input.string("AVG", "Type", ["AVG", "MEADIAN", "MODE"])
//@variable distance Multiplier for calculating the distance between the Gaussian filter and the volatility bands
float distance = input.float(3, step = 0.1)
//@variable show_retest Boolean input to determine if retest signals should be displayed
bool show_retest = input.bool(false, "Retest Signals")
//@variable up Color for upward trends and visual signals, represented in RGB
color up = input.color(color.rgb(40, 218, 150), group = "Color")
//@variable dn Color for downward trends and visual signals, represented in hex code
color dn = input.color(#287bda, group = "Color")
// }
// CALCULATIONS ============================================================================================={
//@function Calculates a Gaussian filter for smoothing the data
//@param src (series float) Source price series
//@param length (int) Length of the filter
//@param sigma (float) Standard deviation for the Gaussian function
//@returns (float) Smoothed value for the current bar
gaussian_filter(src, length, sigma) =>
var float[] weights = array.new_float(100) // Create an array to store weights for Gaussian filter
float total = 0.0 // Sum of all weights, used for normalization
float pi = math.pi // Define Pi constant
// Calculate weights for Gaussian filter
for i = 0 to length - 1
float weight = math.exp(-0.5 * math.pow((i - length / 2) / sigma, 2.0)) / math.sqrt(sigma * 2.0 * pi)
weights.set(i, weight)
total := total + weight
// Normalize weights
for i = 0 to length - 1
weights.set(i, weights.get(i) / total)
// Apply Gaussian filter to the source series
float sum = 0.0
for i = 0 to length - 1
sum := sum + src[i] * weights.get(i)
sum
//@function Multi-trend calculation using Gaussian filter
//@param src (series float) Source price series
//@param period (int) Lookback period for trend calculation
//@returns (float[]) Returns score, value, color, trend line, and trend status
multi_trend(src, period) =>
array<float> g_value = array.new<float>() // Array to store Gaussian filtered values
float volatility = ta.sma(high - low, 100) // Calculate the average true range (ATR) volatility
var float lower_band = 0.0 // Lower band for trend analysis
var float upper_band = 0.0 // Upper band for trend analysis
var float trend_line = 0.0 // Trend line value
var bool trend = na // Trend direction status
// Apply Gaussian filter with a step adjustment to calculate multiple trend lines
for step = 0 to 20 by 1
float gaussian_filter = gaussian_filter(src, (period + step), 10)
g_value.push(gaussian_filter)
float coeff = 0.05
float score = 0.0
// Calculate score based on trend analysis
for i = 0 to g_value.size() - 1
float g_f = g_value.get(i)
if g_f > g_value.first()
score += coeff
// Determine color based on score
color color = score > 0.5
? color.from_gradient(score, 0.5, 1, na, dn)
: color.from_gradient(score, 0, 0.5, up, na)
// Determine value based on user-선택된 mode (AVG, MEDIAN, MODE)
float value = switch mode
"AVG" => g_value.avg()
"MEADIAN" => g_value.median()
"MODE" => g_value.mode()
lower_band := value - volatility * distance // Calculate lower band based on value and volatility
upper_band := value + volatility * distance // Calculate upper band based on value and volatility
// Check crossover and crossunder of price with bands to determine trend
if ta.crossover(close, upper_band)
trend := true
if ta.crossunder(close, lower_band)
trend := false
// Set trend line based on trend direction
trend_line :=
trend ? lower_band
: not trend ? upper_band : na
// Return values: score, value, color, trend line, and trend status
[score, value, color, trend_line, trend]
// Get the result from the multi-trend function
[score, avg, color, trend_line, trend] = multi_trend(close, len)
// }
// PLOT ============================================================================================================={
// Plot the average line returned from multi_trend function
p2 = plot(avg, color = color, linewidth=6)
// Plot the trend line based on trend status
p1 = plot(ta.change(trend) ? na : trend_line,
color = close > trend_line ? up : dn,
linewidth = 7,
style = plot.style_linebr)
// Plot the trend line again with styling
plot(trend_line, color = close > trend_line ? up : dn, linewidth=1, style = plot.style_linebr)
// Add labels for cross under and crossover events
if ta.crossunder(close, trend_line)
label.new(bar_index, trend_line, score < 0.5 ? "▼" : "▼",
color = dn,
textcolor = chart.fg_color,
style = label.style_label_lower_right,
size = score < 0.5 ? size.tiny : size.tiny)
if ta.crossover(close, trend_line)
label.new(bar_index, trend_line, score > 0.5 ? "▲" : "▲",
color = up,
textcolor = chart.bg_color,
style = label.style_label_upper_right,
size = score > 0.5 ? size.tiny : size.tiny)
// Determine trend color based on trend direction
color trend_color = trend ? color.new(up, 100) : color.new(dn, 100)
// Fill between trend line and average line to show areas of trend
fill(p1, p2, trend_line, avg, trend_color, na)
fill(p1, p2, trend_line, avg, trend_color, na)
// Add retest labels if the option is enabled
if show_retest
if ta.crossunder(high, avg) and not trend
label.new(bar_index[1], high[1], "▼",
color = color(na),
style = label.style_label_down,
textcolor = chart.fg_color,
size = size.small)
if ta.crossover(close, avg) and trend
label.new(bar_index[1], low[1], "▲",
color = color(na),
style = label.style_label_up,
textcolor = chart.fg_color,
size = size.small)
// Calculate score-up and score-down for trend strength representation
float score_up = (score - 1) * -1
float score_dn = 1 - score_up
// Display trend strength as a table if on the last bar
if barstate.islast
table trend_strength_up = table.new(position.bottom_center, 100, 100)
table trend_strength_dn = table.new(position.top_center, 100, 100)
// Create cells to represent trend strength up
for i = 0 to score_up * 20
trend_strength_up.cell(0 + i, 0, bgcolor = color.new(up, 100 - i * 5), text = i == 0 ? "|" : "", text_color = color.gray)
if i == score_up * 20
trend_strength_up.cell(0 + i, 0,
text = str.tostring(score_up * 100, format.percent) + " ▲",
text_color = chart.fg_color,
height = 2)
// Create cells to represent trend strength down
for i = 0 to score_dn * 20
trend_strength_dn.cell(0 + i, 0, bgcolor = color.new(dn, 100 - i * 5), text = i == 0 ? "|" : "", text_color = color.gray)
if i == score_dn * 20
trend_strength_dn.cell(0 + i, 0,
text = str.tostring(score_dn * 100, format.percent) + " ▼",
text_color = chart.fg_color,
height = 2)
// }
2025-04-11
1359
글번호 190059
답변완료
문의드립니다~
var : shortPeriod(12), longPeriod(26),sigPeriod(9);
Var : macdv(0),macds(0);
macdv = MACD(shortPeriod, longPeriod);
macds = ema(macdv,sigPeriod);
If CrossUP(macdv, macds)
Then
{
if MarketPosition == 0 then
{Buy("매수");}
if MarketPosition == -1 then
{Buy("리버스매수");}
}
If CrossDown(macdv, macds)
Then
{
if MarketPosition == 0 then{
Sell("매도");}
if MarketPosition == 1 then{
Sell("리버스매도");}
}
반자동매매를 고려한 식을 작성하고 싶은데요~
위 식에서 매수진입후에 리버스매도가 잡히면은
시장가로 2계약매도가 들어가는 식으로 적용되는데요.
매수를 하고나서 수동으로 청산했을때에
리버스매도신호가 떴을때 1계약만 매도로 진입하는 방법은 없을까요?
1.리버스매도를 기존에 매수진입한 물량을 일괄청산 또는 청산으로 포지션정리하고
다시 매도1계약진입하는 형태로 구현이 가능한가요?
2.위 조건이 안된다면은 현재 잔고상태를 실시간으로 파악해서 리버스매도신호가 매도신호로(1계약만매도로) 뜨게끔 설정은 가능한 건지요?
2025-04-11
570
글번호 190058
답변완료
지표수식 바꿔주세요 수고하세요
input : Navg(1.5);
var : buyVolume(0),sellVolume(0);
buyVolume = iff( (high==low), 0, volume*(close-low)/(high-low));
sellVolume = iff( (high==low), 0, volume*(high-close)/(high-low));
if buyVolume >= sellVolume*Navg Then
Find(1);
종목검색식 인데요 지표로 보고 싶네요 항상 감사드려요 건강하세요
2025-04-11
518
글번호 190043
답변완료
문의드립니다.
함수를 공부중에 있어 기초적이지만 문의드립니다.
예를 들어 아래와 같은 시스템식이 있을 때
Input : shortPeriod(5), longPeriod(20);
value1 = ma(C, shortPeriod);
value2 = ma(C, longPeriod);
# 매수/매도청산
If CrossUP(value1, value2) Then
{
Buy();
}
# 매도/매수청산
If CrossDown(value1, value2) Then
{
Sell();
}
}
함수를 써서 줄이고 싶습니다.
value1 = ma(C, shortPeriod);
value2 = ma(C, longPeriod);
또는
# 매수/매도청산
If CrossUP(value1, value2) Then
{
Buy();
}
# 매도/매수청산
If CrossDown(value1, value2) Then
{
Sell();
}
}
을 함수를 써서 표현할 수 있을까요?
함수로 수식을 간결하게 할려는 목적도 있고
신호뿐만 아니라 신호안의 수식을 지인과 공유하더라도
특정 로직이나 수치는 감출려는 목적도 있습니다.
방법설명 그럼 부탁드립니다~
2025-04-11
569
글번호 190041
답변완료
수식 수정 의뢰 드립니다.
안녕하세요!
만들어 주신 수식을 적용해보니 국내선물은 정상적으로 작동하는데 해선은 막대모양이 최고가와 최저가사이에 들어가지 않고 밖으로 돌출됩니다. 확인 부탁드립니다 .
#plot1만 막대로 지정하시면 됩니다.
#상승 보라, 하락 형광, 최고갱신 빨강, 최저갱신 파랑으로 표시됩니다.
#최고격차와 최저격차는 선으로 표시되고 각각 텍스트 출력됩니다.
var : diff(0,data1),hh(0,Data1),ll(0,Data1),clr(0,Data1),tx(0),Htx(0),Ltx(0);
diff = Data1(c)-Data2(c);
if Data1(Bdate != Bdate[1]) Then
{
hh = diff;
LL = diff;
if diff > diff[1] Then
clr = Magenta;
Else
clr = Cyan;
Htx = text_new_self(sDate,sTime,HH,NumToStr(HH,2));
Text_SetStyle(Htx,2,1);
Text_SetColor(Htx,Red);
Ltx = text_new_self(sDate,sTime,LL,NumToStr(LL,2));
Text_SetStyle(Ltx,2,1);
Text_SetColor(Ltx,Blue);
}
Else
{
if diff > hh Then
{
hh = diff;
clr = Red;
Text_SetString(Htx,NumToStr(HH,2));
}
else if diff < ll Then
{
ll = diff;
clr = Blue;
Text_SetString(Ltx,NumToStr(LL,2));
}
Else
{
if diff > diff[1] Then
clr = Magenta;
Else
clr = Cyan;
}
Text_SetLocation(Htx,sDate,sTime,HH);
Text_SetLocation(Ltx,sDate,sTime,LL);
}
Plot1(diff,"diff",clr);#막대
plot2(hh,"hh",Red);#선
plot3(ll,"ll",Blue);#선
tx = text_new_self(sDate,sTime,diff,NumToStr(diff,2));
Text_SetStyle(tx,2,0);
Text_SetColor(tx,Black);
그리고 아래 요청 사항도 좀 부탁드립니다.
감사합니다.
-----------------------------------------------------
2. 봉이 완성되고 진폭이 0.55 이상일때 화살표나 점이 표시되는 강조식을 만들고 싶습니다.
진폭값이 표시되어도 좋습니다.
-----------------------------------------------------
3. 아래 수식이 당일 Data1값에 적용이 안되는 것 같습니다.
확인 좀 부탁드려요!
if Data2(c) == data3(c) Then
var1 = Data1(c);
if Data4(c) == data5(c) Then
var1 = Data1(c);
if Data6(c) == data7(c) Then
var1 = Data1(c);
if Data8(c) == data9(c) Then
var1 = Data1(c);
Plot1(var1);
2025-04-11
609
글번호 190040
답변완료
수식 부탁드립니다.
// 사용자 설정
input: 선물기준치(0), 현물기준치(0);
// 외국인 선물 누적 포지션
vars: 선물변동(0), 선물매수(true);
선물변동 = 외국인선물누적 - 외국인선물누적[1];
선물매수 = 선물변동 > 선물기준치;
// 외국인 현물 누적 포지션
vars: 현물변동(0), 현물매수(true);
현물변동 = 외국인현물누적 - 외국인현물누적[1];
현물매수 = 현물변동 > 현물기준치;
// 지수 왜곡 판단
vars: 왜곡(false);
왜곡 = (선물매수 <> 현물매수);
// 시각화
if 선물매수 and 현물매수 then
Plot1(1, "동시 매수"); // 예: 녹색 점
else if not 선물매수 and not 현물매수 then
Plot2(-1, "동시 매도"); // 예: 빨간 점
else if 왜곡 then
Plot3(0, "왜곡"); // 예: 노란 점
위 수식을 지표로 나오게 수정좀 해주세요.
2025-04-11
552
글번호 190039
답변완료
문의
1분봉에서 5분봉의 완성시점을 알수 없을까요?
2025-04-11
464
글번호 190038
답변완료
문의드립니다.
수고많습니다.
시가선 돌파매매 시스템에서 시가를 종가로 돌파한 봉 출현후 "10개 봉 이내에서" 1. 시가대비 75틱 상승하면 봉의 종가가 아니라 즉시 매수 2. 50틱 이상 상승한 봉의 종가에서 매수 이렇게 2가지중 하나가 만족하면 매수하는 식을 구합니다.
하나 더 부탁드리면 해외선물에서 "당일" 고가/저가의 1/2 가격을 선으로 해서 보고 있는데 이것을 "당일" 첫봉부터 20개 봉의 고가와 저가 1/2선으로 변경해 움직이게 하고 싶습니다. 즉 20개 봉 안에 고가, 저가 변화가 없으면 선은 수평이 될 것이고 계속 변화가 없어도 수평이 될 것이고 고점이나 저점을 높이거나 낮추게 되면 그기에 맞게 20개 봉 기준으로 고가와 저가가 재설정 되어 선의 위치가 움직이게 하고 싶습니다.
미리 노고에 감사드립니다.
2025-04-11
537
글번호 190033