커뮤니티
예스랭귀지 Q&A
답변완료
[공지] 예스랭귀지 AI 어시스턴트, '예스나 AI' 출시 및 무료 체험 안내
안녕하세요, 예스스탁 입니다.복잡한 수식 공부 없이 여러분의 아이디어를 말하면 시스템 트레이딩 언어 예스랭귀지로 작성해주는 서비스예스나 AI(YesNa AI)가 출시되었습니다.지금 예스나 AI를 직접 경험해 보실 수 있도록 20크레딧(질문권 20회)를 무료로 증정해 드리고 있습니다.바로 여러분의 아이디어를 코드로 변환해보세요.--------------------------------------------------🚀 YesNa AI 핵심 기능- 지표식/전략식/종목검색식 생성: 자연어로 요청하면 예스랭귀지 문법에 맞는 코드를 작성합니다.- 종목검색식 변환 지원: K증권의 종목 검색식을 예스랭귀지로 변환 지원합니다.- 컴파일 검증: 작성된 코드가 실행 가능한지 컴파일러를 통해 문법 검증을 거쳐 결과물을 제공합니다.상세한 서비스 개요 및 활용 방법은 [서비스 소개 페이지]에서 확인하실 수 있습니다.▶ 서비스 소개 페이지: 바로가기서비스 사용 유의사항 및 결제 환불정책은 [이용약관]을 참고 부탁드립니다.▶ 서비스 이용약관: 바로가기💬 이용 문의사용 중 문의사항은 [프로그램 사용법 Q&A] 게시판에서 [예스나 AI] 카테고리를 설정 후 문의해 주시면 상세히 안내해 드리겠습니다.--------------------------------------------------앞으로도 AI를 활용한 다양한 트레이딩 기능들을 지속적으로 선보일 예정입니다.많은 관심과 기대 부탁드립니다.
2026-02-27
3450
글번호 230811
답변완료
늘 도움을 주셔서 고맙습니다. 추세선을 이용한 시스템식 가능할까요?
안녕하세요.
첨부한 그릠과 같은 시스템식이 가능한지요?
3분봉 기준으로 추세선을 그린 후에 그 추세선을 이용한 매매 시스템에 대한 요청입니다.
코로나로 인하여 많이 힘든 이때 건강하시길 바랍니다.
2020-03-17
491
글번호 136898
답변완료
수정부탁드립니다
Input:length(10),n(1),카운팅시작일자(20200313), 카운팅시작시간(070000);;
Var:j(0),k(0),q(0),TL1(0),TL2(0),TL3(0),
TL_NewBit(0),Tcond(false); // 1:NewLine 2:SetEndLine
Array:고[10,4](0),저[10,4](0); // 1:가격,2:Index,3:sDate,4:sTime
#==========================================#
if sdate >= 카운팅시작일자 and stime >= 카운팅시작시간 Then
Tcond = true;
if Tcond == true Then
{
if (sdate != sdate[1] and stime >= 카운팅시작시간) or
(sdate == sdate[1] and stime >= 카운팅시작시간 and stime[1] < 카운팅시작시간) Then
{
Value1 = HiLoLineZigZag(length,0,고,저,TL_NewBit);
If Value1 == 1 Then { // 고점
If TL_NewBit == 1 Then { // 신규 고점
//TL1 = TL_New(저[1,3],저[1,4],저[1,1],고[1,3],고[1,4],고[1,1]);
TL_SetSize(TL1,1);
k = 0;
For j = 2 To 10 {
If 저[1,1] > 저[j,1] and 저[j,1] > 0 Then { // 전저점보다 낮은 이전 전저점 찾는다
k = j;
j = 10; // exit loop
}
}
If k > 1 Then { // 낮은 전저점이 찾아졌다면
TL2 = TL_New(저[k,3],저[k,4],저[k,1],sDate,sTime,(저[1,1]-저[k,1])/(저[1,2]-저[k,2])*(Index-저[k,2])+저[k,1]);
TL_SetColor(TL2,BLUE);
}
q = q + 1; // 고점이 새로 추가되었으므로 1 증가
If q > 2 and q <= 10 Then { // 1 증가했으니 2보다 커야 하고 배열 크기가 10이므로 10 이내
TL_SetEnd(TL3,sDate,sTime,(고[2,1]-고[q,1])/(고[2,2]-고[q,2])*(Index-고[q,2])+고[q,1]);
}
} Else { // 신규 고점이 아니면 기존 추세선만 연장
If k > 1 Then {
TL_SetEnd(TL2,sDate,sTime,(저[1,1]-저[k,1])/(저[1,2]-저[k,2])*(Index-저[k,2])+저[k,1]);
}
If q > 2 and q <= 10 Then {
TL_SetEnd(TL3,sDate,sTime,(고[2,1]-고[q,1])/(고[2,2]-고[q,2])*(Index-고[q,2])+고[q,1]);
}
}
If TL_NewBit == 2 Then {
TL_SetEnd(TL1,고[1,3],고[1,4],고[1,1]);
}
} Else If Value1 == -1 Then { // 저점
If TL_NewBit == 1 Then { // 신규 저점
//TL1 = TL_New(고[1,3],고[1,4],고[1,1],저[1,3],저[1,4],저[1,1]);
TL_SetSize(TL1,1);
k = k + 1; // 저점이 새로 추가되었으므로 1 증가
If k > 2 and k <= 10 Then { // 1 증가했으니 2보다 커야 하고 배열의 크기가 10이므로 10 이내
TL_SetEnd(TL2,sDate,sTime,(저[2,1]-저[k,1])/(저[2,2]-저[k,2])*(Index-저[k,2])+저[k,1]);
}
q = 0;
For j = 2 To 10 {
If 고[1,1] < 고[j,1] Then { // 전고점보다 높은 이전 전고점을 찾는다
q = j;
j = 10; // exit loop
}
}
If q > 1 Then { // 높은 전고점이 찾아졌다면
TL3 = TL_New(고[q,3],고[q,4],고[q,1],sDate,sTime,(고[1,1]-고[q,1])/(고[1,2]-고[q,2])*(Index-고[q,2])+고[q,1]);
TL_SetColor(TL3,RED);
}
} Else { // 신규 저점이 아니면 기존 추세선만 연장
If k > 2 and k <= 10 Then {
TL_SetEnd(TL2,sDate,sTime,(저[2,1]-저[k,1])/(저[2,2]-저[k,2])*(Index-저[k,2])+저[k,1]);
}
If q > 1 Then {
TL_SetEnd(TL3,sDate,sTime,(고[1,1]-고[q,1])/(고[1,2]-고[q,2])*(Index-고[q,2])+고[q,1]);
}
}
If TL_NewBit == 2 Then {
TL_SetEnd(TL1,저[1,3],저[1,4],저[1,1]);
}
}}}
상기수식을 카운팅일자및 카운팅시간을 넣어서 실행하니 추세선표시가 나타나지않습니다
수식수정부탁드립니다
감사합니다
2020-03-16
452
글번호 136897
답변완료
파생형 ETF는 매일 리벨런싱된다고합니다.
파생형 ETF는 매일 리벨런싱된다고합니다.
제가 레버리지 ETF를 매수하여 아래수식으로 청산할때
산금액에서 10% 올랐을때 청산되는건지 아니면 리벨런싱 된 값의 10% 수익시 청산되는 건가요??
SetStopProfittarget(10,PercentStop);
2020-03-16
454
글번호 136896
답변완료
문의 드립니다.
일목균형표에서 전환선과 기준선을 노랑, 선행스팬1,2를 하늘색으로 했을때, 두 면이 겹치면 새로운 색이 되는데요,
노랑색만 남고 하늘색은 숨기는 방법이 있을까요?
항상 감사한 마음입니다.
2020-03-16
487
글번호 136891
답변완료
점검 부탁드립니다.
수식 감사드립니다.
아래 수식은,
이동평균선(300일선)을 돌파하고 전일종가를 돌파하면 매수,
이동평균선(300일선)을 이탈하고 전일종가를 이탈하면 매도
하는 두가지 조건 만족식인데요, 진입/청산 모두 조건만족즉시가 하니고 봉완성후로 부탁합니다.
그리고 100% 이익일때 50%청산하고 나머지는 홀딩하는 수식인데요,
input : profit(100);
var1 = ma(C,300);
Condition1 = C > var1 and C > DayClose(1);
Condition2 = C < var1 and C < DayClose(1);
if Condition1 == true and Condition1[1] == false Then
buy("b");
if MarketPosition == 1 then
{
ExitLong("bp",atlimit,EntryPrice*(1+profit/100),"",Floor(MaxContracts*0.5),1);
if Condition2 == true and Condition2[1] == false Then
ExitLong("bx");
}
위 수식이 현물용인데, 선물(코인)에서 사용할 수 있도록 매수진입/매수청산, 매도진입/매도청산으로 변경 부탁드리고요,
한가지 더,
매수 또는 매도 진입 후, 전일종가를 이탈하면 손절할 수 있도록 조정해 주시면 감사하겠습니다!
2020-03-16
438
글번호 136890
답변완료
질문 올립니다.
안녕하세요. 늘 감사드립니다.
올리는 질문마다 항상 상세하고 친절하게 답을 주셔서, 그 것을 보며 공부하면서 아주 많이 배우게 되어 대단히 감사합니다.
지금,
둘 내지 세 개의 기준(조건)을 순차적으로(즉, 동시가 아니라 차례대로...) 충족시키고 나면 즉시(AtLimit, AtStop 활용) 주문이 나가서 체결가능하게 하는 매매식을 만드는 방법에 대해 공부하고 있습니다.
이런 예제 소스를 보여 주시면, 보고 열심히 공부하고자 합니다.
잘 부탁드립니다.
예로서,
A. 이평선들 Max Min 돌파이탈 지지저항 전략
변수들:
5개의 이평선들(기간값 각각 input: ii(50), jj(100), kk(150), ll(200), mm(250); 외부변수)의
최대값(var: Max(0))과 최소값(var: Min(0)),
그 것의 중심선 (var: Center(0); Center = (Max+Min)/2); )
Max와 Min의 차이 (var: Dif(0); Dif = Max-Min;)
// 매수1 ((돌파 매수)):
(제1조건:) (C가 Min 아래에 있다가) C가 Min을 뚫고 올라 간 후
(제2조건:) C가 Center를 nn(7)(외부변수)틱보다 더 높게 올라 가면
[ = 즉, C가 Center+nn*PriceScale을 CrossUp 또는 C > Center+nn*PriceScale ],
then 즉시(AtStop?) 매수
[ = Buy("B1", AtStop...); ].
(제3조건) 제1조건, 제2조건 충족 후, C가 Max를 pp(5)(외부변수)보다 더 높게 올라 가면,
[ = 즉, C가 Max+pp*PriceScale을 CrossUp 또는 C > Max+pp*PriceScale],
then 즉시((AtStop?) 매수
[ = Buy("B2", AtStop...); ] // 즉 피라미딩 가능.
// 매수2 ((지지 매수)):
(제1조건): C가 Max의 uu(7)((외부변수)) 틱 위에 있었다가
(제2조건): C가 Max의 아래 위 각 vv(2)((외부변수))틱 범위 속에 들어 갔다가 ((즉, Max에 접근했다가))
(제3조건): C가 Max의 ww(8)((외부변수)) 틱 위로 올라 가는 순간 즉시 매수
[ = Buy("B3", AtStop...); ].
// 매수청산
C가 EMA(ee)(=ee(2)=기간값 2. 외부변수로)를 하향 이탈하는 즉시 ExitLong("EL1", AtStop?...);
// 매도1, 매도2, 매도청산은 매수의 경우와 정 반대로... ((외부변수는 그 대로 같이 사용))
B. 볼린저 밴드 급등 매매 전략
// 매수
(제1조건) C가 하단선을 아래에서 위로 돌파
(제2조건) C가 중간선(EMA(bb) (bb(12)는 볼밴 중심선인 EMA의 기간값 외부변수)을 cc(3)(=외부변수)틱 돌파 ((즉 중간선+cc틱을 상향돌파)) 즉시 매수
[ = Buy("BB", AtStop...); ]
//매수청산1
(제1조건) C가 볼밴 상단선 위에 있다
(제2조건) C가 볼밴 상단선을 dd 틱 (input: dd(3); // 외부변수)만큼 하회하는 즉시 ExitLong("EL1", AtLimit?...);
//매수청산2
(제1조건) C가 볼밴 중심선과 상단선 사이에 있다.
(제2조건) C가 볼밴 중심선을 ff틱(ff(2)=외부변수) 하회하는 즉시 매수청산 = ExitLong("EL2", AtStop?)
//매도와 매도청산은 매수의 경우와 정반대로...
대단히 감사합니다!
2020-03-16
430
글번호 136889
답변완료
부탁드립니다
지표전환 부탁드립니다
OverBought = input(70, minval=10)
OverSold = input(30, maxval=70)
band1 = hline(70, title="Upper Line", linestyle=dashed, linewidth=1, color=red)
band0 = hline(30, title="Lower Line", linestyle=dashed, linewidth=1, color=green)
// Super Trend
sLines = input(true, "Show Super-Trend Lines")
Factor1=input(1,type =float, minval=1,maxval = 100)
Factor2=input(2,type =float, minval=1,maxval = 100)
Factor3=input(3,type =float, minval=1,maxval = 100)
Pd1=10 //input(10,minval=1,maxval = 100)
Pd2=10 //input(10,minval=1,maxval = 100)
Pd3=10 //input(10,minval=1,maxval = 100)
// ST1
Up1=hlc3-(Factor1*atr(Pd1))
Up2=hlc3-(Factor2*atr(Pd2))
Up3=hlc3-(Factor3*atr(Pd3))
Dn1=hlc3+(Factor1*atr(Pd1))
Dn2=hlc3+(Factor2*atr(Pd2))
Dn3=hlc3+(Factor3*atr(Pd3))
// ST1.2
TrendUp1=na
TrendUp2=na
TrendUp3=na
TrendUp1:=close[1]>TrendUp1[1]? max(Up1,TrendUp1[1]) : Up1
TrendUp2:=close[1]>TrendUp2[1]? max(Up2,TrendUp2[1]) : Up2
TrendUp3:=close[1]>TrendUp3[1]? max(Up3,TrendUp3[1]) : Up3
TrendDown1=na
TrendDown2=na
TrendDown3=na
TrendDown1:=close[1]<TrendDown1[1]? min(Dn1,TrendDown1[1]) : Dn1
TrendDown2:=close[1]<TrendDown2[1]? min(Dn2,TrendDown2[1]) : Dn2
TrendDown3:=close[1]<TrendDown3[1]? min(Dn3,TrendDown3[1]) : Dn3
Trend1 = na
Tsl1 = na
Trend2 = na
Tsl2 = na
Trend3 = na
Tsl3 = na
Trend1 := close[1] > TrendDown1[1] ? 1: close[1] < TrendUp1[1]? -1: nz(Trend1[1],1)
Tsl1 := Trend1==1 ? TrendUp1: TrendDown1
Trend2 := close[1] > TrendDown2[1] ? 1: close[1] < TrendUp2[1]? -1: nz(Trend2[1],1)
Tsl2 := Trend2==1 ? TrendUp2: TrendDown2
Trend3 := close[1] > TrendDown3[1] ? 1: close[1] < TrendUp3[1]? -1: nz(Trend3[1],1)
Tsl3 := Trend3==1 ? TrendUp3: TrendDown3
len=input(14)
x=rsi(Tsl2,len)
// Plotting
linecolor = Tsl1 < Tsl2 and Tsl2 < Tsl3 ? red : Tsl1 > Tsl2 and Tsl2 > Tsl3 ? lime : orange
plot(x , color = linecolor , style = line , linewidth = 3 ,title = "SuperTrend")
tgreen=crossover(close, Tsl2)
tred=crossunder(close, Tsl2)
plotchar(tgreen, title="buy", char='b', location=location.bottom, color=black, transp=0, offset=0,size=size.tiny)
plotchar(tred, title="sell", char='s', location=location.top, color=black, transp=0, offset=0,size=size.tiny)
2020-03-16
415
글번호 136888
답변완료
지표수식 전환부탁드립니다.
아래 지표를 예스 지표로 전환부탁드립니다.
//The volume price trend ( VPT ) indicator helps determine a security’s price direction and strength of price change. The indicator consists of a cumulative volume line that adds or subtracts a multiple of the percentage change in a share price’s trend and current volume , depending upon the security’s upward or downward movements.
//https://www.tradingview.com/script/i8FO3CyP-VPT-v4/
source = close
hilow = ((high - low)*100)
openclose = ((close - open)*100)
vol = (volume / hilow)
spreadvol = (openclose * vol)
VPT = spreadvol + cum(spreadvol)
window_len = 28
v_len = 14
price_spread = stdev(high-low, window_len)
v = spreadvol + cum(spreadvol)
smooth = sma(v, v_len)
v_spread = stdev(v - smooth, window_len)
shadow = (v - smooth) / v_spread * price_spread
out = shadow > 0 ? high + shadow : low + shadow
//plot(out, style=line,linewidth=3, color=color)
len=input(10)
vpt=ema(out,len)
//lineColor = vpt > vpt[1] ? color.green : color.red
//plot(vpt, linewidth=3, color=lineColor)
//x=crossover(vpt , vpt[1]) and vpt > vpt[1]
//z=crossunder(vpt , vpt[1]) and vpt <vpt[1]
//plotshape(crossover(vpt , vpt[1]) and vpt > vpt[1], "up arrow", shape.triangleup, location.belowbar, color.green,size=size.tiny)
//plotshape(crossunder(vpt , vpt[1]) and vpt <vpt[1] , "down arrow", shape.triangledown, location.abovebar, color.red,size=size.tiny)
//
// INPUTS //
st_mult = input(1, title = 'SuperTrend Multiplier', minval = 0, maxval = 100, step = 0.01)
st_period = input(100, title = 'SuperTrend Period', minval = 1)
// CALCULATIONS //
up_lev = vpt - (st_mult * atr(st_period))
dn_lev = vpt + (st_mult * atr(st_period))
up_trend = 0.0
up_trend := close[1] > up_trend[1] ? max(up_lev, up_trend[1]) : up_lev
down_trend = 0.0
down_trend := close[1] < down_trend[1] ? min(dn_lev, down_trend[1]) : dn_lev
// Calculate trend var
trend = 0
trend := close > down_trend[1] ? 1: close < up_trend[1] ? -1 : nz(trend[1], 1)
// Calculate SuperTrend Line
st_line = trend ==1 ? up_trend : down_trend
// Plotting
plot(st_line[1], color = trend == 1 ? color.green : color.red , style = plot.style_cross, linewidth = 2, title = "SuperTrend")
buy=crossover( close, st_line)
sell=crossunder(close, st_line)
//plotshape(crossover( close, st_line), location = location.belowbar, color = color.green,size=size.tiny)
//plotshape(crossunder(close, st_line), location = location.abovebar, color = color.red,size=size.tiny)
plotshape(buy,title="Buy", color=color.blue, style=shape.arrowup,location=location.belowbar, text="Buy")
plotshape(sell,title="Sell", color=color.black, style=shape.arrowdown,text="Sell")
/////// Alerts /////
alertcondition(buy,title="buy")
alertcondition(sell,title="sell")
2020-03-16
532
글번호 136887
답변완료
지표수식 전환부탁
다음 수식을 예스지표로 전환부탁드려요.
ATRlength = input(200, minval=1)
ATRMult = input(2.272, minval=1)
ATR = rma(tr(true), ATRlength)
len = input(26, minval=1, title="EMA Length")
src = input(close, title="Source")
out = ema(src, len)
plot(out, title="EMA", color=orange,transp=85)
emaup = out+(ATR*ATRMult)
emadw = out-(ATR*ATRMult)
plot(emaup, title="EMAUP", color=red)
plot(emadw, title="EMADW", color=green)
conversionPeriods = input(5, minval=1),
basePeriods = input(26, minval=1)
laggingSpan2Periods = input(52, minval=1),
displacement = input(26, minval=1)
donchian(len) => avg(lowest(len), highest(len))
conversionLine = donchian(conversionPeriods)
baseLine = donchian(basePeriods)
leadLine1 = avg(conversionLine, baseLine)
leadLine2 = donchian(laggingSpan2Periods)
kjuncol = conversionLine > baseLine ? blue : conversionLine < baseLine ? red : orange
plot(conversionLine, color=red, title="Conversion Line")
plot(baseLine, color=kjuncol,linewidth=2,transp=5, title="Base Line")
p1 = plot(leadLine1, offset = displacement, color=green,transp=85,
title="Lead 1")
p2 = plot(leadLine2, offset = displacement, color=red,transp=85,
title="Lead 2")
fill(p1, p2,silver)
2020-03-16
431
글번호 136886