커뮤니티
예스랭귀지 Q&A
답변완료
[공지] 예스랭귀지 AI 어시스턴트, '예스나 AI' 출시 및 무료 체험 안내
안녕하세요, 예스스탁 입니다.복잡한 수식 공부 없이 여러분의 아이디어를 말하면 시스템 트레이딩 언어 예스랭귀지로 작성해주는 서비스예스나 AI(YesNa AI)가 출시되었습니다.지금 예스나 AI를 직접 경험해 보실 수 있도록 20크레딧(질문권 20회)를 무료로 증정해 드리고 있습니다.바로 여러분의 아이디어를 코드로 변환해보세요.--------------------------------------------------🚀 YesNa AI 핵심 기능- 지표식/전략식/종목검색식 생성: 자연어로 요청하면 예스랭귀지 문법에 맞는 코드를 작성합니다.- 종목검색식 변환 지원: K증권의 종목 검색식을 예스랭귀지로 변환 지원합니다.- 컴파일 검증: 작성된 코드가 실행 가능한지 컴파일러를 통해 문법 검증을 거쳐 결과물을 제공합니다.상세한 서비스 개요 및 활용 방법은 [서비스 소개 페이지]에서 확인하실 수 있습니다.▶ 서비스 소개 페이지: 바로가기서비스 사용 유의사항 및 결제 환불정책은 [이용약관]을 참고 부탁드립니다.▶ 서비스 이용약관: 바로가기💬 이용 문의사용 중 문의사항은 [프로그램 사용법 Q&A] 게시판에서 [예스나 AI] 카테고리를 설정 후 문의해 주시면 상세히 안내해 드리겠습니다.--------------------------------------------------앞으로도 AI를 활용한 다양한 트레이딩 기능들을 지속적으로 선보일 예정입니다.많은 관심과 기대 부탁드립니다.
2026-02-27
1531
글번호 230811
답변완료
부탁 드립니다
수고 하십니다
키움차트 수식 입니다
예스로 변환 좀 부탁 드립니다
매수 진입
R=highest(H,X);
S=lowest(L,X);
A=countsince(time>=T1,crossUp(c,R(1)) or crossDown(c,S(1)));
crossUp(A,0.5) and C>R(1)
수식 : 매수청산
R=highest(H,X);
S=lowest(L,X);
crossDown(c,S(1))
2023-06-11
1243
글번호 169659
답변완료
추세선 상하대칭
input : Period(250);
Var:j(0),T(0);
Var: date11(0),date12(0),time11(0),time12(0),
date21(0),date22(0),time21(0),time22(0),
date31(0),date32(0),time31(0),time32(0);
Array:HiVal[20](0),LoVal[20](0),HiBar[20](0),LoBar[20](0);
var : btx1(0),btx2(0),btx11(0),btx12(0),btx21(0),btx22(0);
Plot1(value12);
For j = 0 To 19
{
HiBar[j] = HiBar[j] + 1;
LoBar[j] = LoBar[j] + 1;
}
if crossup(c,highest(H,Period)[1]) Then
T = 1;
if CrossDown(c,Lowest(L,Period)[1]) Then
T = -1;
If T == -1 Then
{
If T[1] != -1 Then
{
For j = 18 DownTo 0
{
LoVal[j+1] = LoVal[j];
LoBar[j+1] = LoBar[j];
}
LoVal[0] = L;
LoBar[0] = 0;
date11 = date[HiBar[0]];
time11 = stime[HiBar[0]];
Value11 = HiVal[0];
date12 = date[LoBar[0]];
time12 = stime[LoBar[0]];
Value12 = LoVal[0];
date21 = date[HiBar[0]];
time21 = stime[HiBar[0]];
date22 = date[0];
time22 = stime[0];
if hival[0] > 0 and Loval[0] > 0 Then
{
btx11 = Text_New(date12,time12,Value11+abs(Hival[0]-loval[0])*1.618,"■");
btx12 = Text_New(date12,time12,Value11+abs(Hival[0]-loval[0])*0.618,"■");
btx1 = Text_New(date12,time12,Value11+abs(Hival[0]-loval[0]),"■");
btx2 = Text_New(date12,time12,Value12-abs(Hival[0]-loval[0]),"■");
btx21 = Text_New(date12,time12,Value12-abs(Hival[0]-loval[0])*1.618,"■");
btx22 = Text_New(date12,time12,Value12-abs(Hival[0]-loval[0])*0.618,"■");
Text_SetStyle(btx11,2,2);
Text_SetStyle(btx12,2,2);
Text_SetStyle(btx1,2,2);
Text_SetStyle(btx2,2,2);
Text_SetStyle(btx21,2,2);
Text_SetStyle(btx22,2,2);
Text_SetColor(btx11,Lime);
Text_SetColor(btx12,Lime);
Text_SetColor(btx1,Blue);
Text_SetColor(btx2,Blue);
Text_SetColor(btx21,Lime);
Text_SetColor(btx22,Lime);
}
}
If LoVal[0] > L Then
{
LoVal[0] = L;
LoBar[0] = 0;
date12 = date[LoBar[0]];
time12 = stime[LoBar[0]];
Value12 = LoVal[0];
date22 = date[0];
time22 = stime[0];
Text_SetLocation(btx11, date12,time12,Value11+abs(Hival[0]-loval[0])*1.618);
Text_SetLocation(btx12, date12,time12,Value11+abs(Hival[0]-loval[0])*0.618);
Text_SetLocation(btx1, date12,time12,Value11+abs(Hival[0]-loval[0]));
Text_SetLocation(btx2, date12,time12,Value12-abs(Hival[0]-loval[0]));
Text_SetLocation(btx21, date12,time12,Value12-abs(Hival[0]-loval[0])*1.618);
Text_SetLocation(btx22, date12,time12,Value12-abs(Hival[0]-loval[0])*0.618);
}
}
If T == 1 Then
{
If T[1] != 1 Then
{
For j = 18 DownTo 0
{
HiVal[j+1] = HiVal[j];
HiBar[j+1] = HiBar[j];
}
HiVal[0] = H;
HiBar[0] = 0;
date11 = date[LoBar[0]];
time11 = stime[LoBar[0]];
Value11 = LoVal[0];
date12 = date[HiBar[0]];
time12 = stime[HiBar[0]];
Value12 = HiVal[0];
date31 = date[LoBar[0]];
time31 = stime[LoBar[0]];
date32 = date[0];
time32 = stime[0];
if hival[0] > 0 and Loval[0] > 0 Then
{
btx11 = Text_New(date12,time12,Value12+abs(Hival[0]-loval[0])*1.618,"■");
btx12 = Text_New(date12,time12,Value12+abs(Hival[0]-loval[0])*0.618,"■");
btx1 = Text_New(date12,time12,Value12+abs(Hival[0]-loval[0]),"■");
btx2 = Text_New(date12,time12,Value11-abs(Hival[0]-loval[0]),"■");
btx21 = Text_New(date12,time12,Value11-abs(Hival[0]-loval[0])*1.618,"■");
btx22 = Text_New(date12,time12,Value11-abs(Hival[0]-loval[0])*0.618,"■");
Text_SetStyle(btx11,2,2);
Text_SetStyle(btx12,2,2);
Text_SetStyle(btx1,2,2);
Text_SetStyle(btx2,2,2);
Text_SetStyle(btx21,2,2);
Text_SetStyle(btx22,2,2);
Text_SetColor(btx11,Lime);
Text_SetColor(btx12,Lime);
Text_SetColor(btx1,Red);
Text_SetColor(btx2,Red);
Text_SetColor(btx21,Lime);
Text_SetColor(btx22,Lime);
}
}
If HiVal[0] < H Then
{
HiVal[0] = H;
HiBar[0] = 0;
date12 = date[HiBar[0]];
time12 = stime[HiBar[0]];
Value12 = HiVal[0];
date32 = date[0];
time32 = stime[0];
Text_SetLocation(btx11, date12,time12,Value12+abs(Hival[0]-loval[0])*1.618);
Text_SetLocation(btx12, date12,time12,Value12+abs(Hival[0]-loval[0])*0.618);
Text_SetLocation(btx1, date12,time12,Value12+abs(Hival[0]-loval[0]));
Text_SetLocation(btx2, date12,time12,Value11-abs(Hival[0]-loval[0]));
Text_SetLocation(btx21, date12,time12,Value11-abs(Hival[0]-loval[0])*1.618);
Text_SetLocation(btx22, date12,time12,Value11-abs(Hival[0]-loval[0])*0.618);
}
}
네모 표시를, 추세선의 크기가 작으면 무시하고 1P 이상일 때만 표시되게 수정 부탁드립니다.
2023-06-11
1690
글번호 169658
답변완료
수식 부탁드립니다.
1. 진입조건
기술적적조건1 (TDI, DI)
TDI = 최근 20일추세크기 - 이전 20일 동안 횡보변동성크기
추세크기 = 절대값(최근20일 동안의 20일 모멘텀들의 합)
횡보변동성크기 = (최근 40일동안의 20일 모멘텀 절대값의 합) -(최근20일동안의 20 일 모멘텀 절대값의 합)
DI = 최근 20일 동안의 20일 모멘텀 값의 합
buy power = 현재봉 포함 과거 n일 간의 최고점 - 15일 전봉 포함 과거 n일간의 최저점
(n기간 선택가능하게)
sell power = n일전 봉 포함 과거 15일간의 최고점 - 현재봉 포함 과거 15일 간의 최저점
TTF(n기간) = (buy power-sell power)/(0.5 * (buy power + sell power)) * 100
TTF > 100 이면서 DI가 TDI를 상향 돌파시 매수
TTF <-100 이면서 DI가 TDI를 하향 돌파시 매도
거래수량(총 예수금의 1%) = 예수금/ (100 * (20봉간 최고값-최저값))
=> 예스랭귀지에서 예수금을 읽어와서 거래가 가능한지 아니면 예수금을 직접 입력해줘야하는지 궁금합니다.
기술적조건2 (adx,force index, chaikin oscillator)
종가가 N일간의 최고점 돌파(N값 선택가능하게) and
돌파시점의 ADX값이 N일전의 ADX값보다 클 것 and
돌파시점의 force index값이 N일전의 force index값보다 클 것 and
돌파시점의 chaikin oscillator 값이 N일전의 chaikin oscillator값보다 클 것
시간조건
09:00이후 진입, 15:20에 보유한 모든 수량 청산
예수금조건
거래수량(총 예수금의 1%) = 예수금/ (100 * (20봉간 최고값-최저값))
2. 필터조건
ADX 조건1) ADX > 25 일 것
ADX 조건2) (ADX 20봉평균 < 10) and (최근 3일 ADX >10 일 것) and
(ADX - 5일전 ADX >0 일 것)
ADX 조건 1 혹은 ADX조건2를 만족할 것
3. 청산조건
청산조건1 (최고-최저 range)
진입이후 봉이 갱신될 때마다
청산지점(진입후 최고가- 3* abs[20봉간 최고값-최저값])의 값을 비교하여,
기존 청산지점 > 새로계산된 청산지점 -> 기존 청산지점 유지
기존 청산지점 < 새로계산된 청산지점 -> 새로 계산된 청산지점을 청산지점으로 갱신
청산조건2 (표준편차)
진입이후 봉이 갱신될 때마다
청산지점(진입후 최고가 - 3*abs[20봉간 표준편차])의 값을 비교하여,
기존 청산지점 > 새로계산된 청산지점 -> 기존 청산지점 유지
기존 청산지점 < 새로계산된 청산지점 -> 새로 계산된 청산지점을 청산지점으로 갱신
2023-06-10
1143
글번호 169657
답변완료
TS이지랭귀지를 예스랭귀지로 변환하고 싶습니다.
예스랭귀지로 변환해서 거래하고 싶습니다. 양이 좀 많아서 죄송합니다.
잘부탁드립니다.
1. 기울기관련수식
{ period = length of exponential trend
filter = whole percent trend change to give signal
lag = enter after a lag of "lag"
}
input: period(20), filter(0), lag(0);
vars: signal(0);
{ Linear regression slope }
signal = LRSsignal(period,filter,lag);
if signal = 1 then Buy This Bar on close;
if signal = -1 then Sell Short This Bar on close;
2. 모멘텀 관련 수식
{ period = length of calculation }
input: period(20), usefutures(false), printfile(true);
vars: nhigh(0), nlow(0), adate(" "),
totalPL(0), dailyPL(0), psignal(0), ATR(0), ATRperiod(20), size(0),
futuresinvestment(25000), stockinvestment(10000);;
if usefutures then begin
size = futuresinvestment/(avgtruerange(ATRperiod)*bigpointvalue);
end
else size = stockinvestment/close[1];
{ 매수, 매도 수식 }
if close > close[period] then begin
buy to cover all contracts this bar on close;
Buy size contracts This Bar on close;
end;
if close < close[period] then begin
sell all contracts this bar on close;
Sell Short size contracts This Bar on close;
end;
totalpl = netprofit + openpositionprofit;
dailyPL = psignal*currentshares*(close - close[1]);
psignal = marketposition;
end;
3. 변동성 시스템
inputs: period(20), volfactor(2.0), usefutures(false);
vars: ATR(0), change(0), sizeper(20), size(0),
stockinvestment(10000), futuresinvestment(25000);
ATR = avgtruerange(period);
change = close - close[1];
// size for new positions
if usefutures then begin
size = futuresinvestment/(avgtruerange(sizeper)*bigpointvalue);
end
else begin size = stockinvestment/close;
end;
if marketposition <= 0 and change > volfactor*ATR[1] then
buy size contracts next bar on open
else if marketposition >= 0 and change < -volfactor*ATR[1] then
sell short size contracts next bar on open;
4. 볼린저밴드관련 수식
inputs: period(20), factor(2.0);
vars: alpha(0), mt(0), ut(0), dt(0), mt2(0), ut2(0), dt2(0), but(0), blt(0);
{ smoothing constant }
alpha = 2/(period + 1);
mt = alpha*close + (1 - alpha)*mt;
ut = alpha*mt + (1 - alpha)*ut;
dt = ((2 - alpha)*mt - ut)/(1 - alpha);
mt2 = alpha*absvalue(close - dt) + (1 - alpha)*mt2;
ut2 = alpha*mt2 + (1 - alpha)*ut2;
dt2 = ((2 - alpha)*mt2 - ut2)/(1 - alpha);
but = dt + factor*dt2;
blt = dt - factor*dt2;
종가가 볼린저밴드 상단 돌파시 매수, 종가가 볼린저밴드 하단 돌파시 매도
5.선형회귀 밴드
inputs: period(20), bandwidth(2.0);
vars: slope(0), lrvalue(0), resid(0), sdresid(0), angle(0),
intercept(0), upperband(0), lowerband(0), size(0), investment(25000);
Value1 = LinearReg( close, period, currentbar, slope, angle, intercept,
lrvalue ) ;
{ slope = LinearRegSlope(close,period);
lrvalue = linearRegValue(close,period,currentbar);}
resid = Close - lrvalue;
If Currentbar > period then begin
{ position size }
size = investment / (avgtruerange(30)*bigpointvalue);
size = maxlist(size,1);
sdresid = stddev(close,period);
Upperband = lrvalue + slope + bandwidth*sdresid;
Lowerband = lrvalue + slope - bandwidth*sdresid;
{ plot1(upperband,"UB");
Plot2(lowerband,"LB");
} plot3(lrvalue,"LR");
{ If Close > upperband[1] then buy size contracts this bar on close
Else if Close < lowerband[1] then sell short size contracts this bar on close; }
end;
6. 스윙인덱스 관련 수식
Inputs for TSM SWING:
type = 0, normal price
= 1, 3-month rate
= 2, bond price at par
swing = price swing in whole % (e.g., 2% = 2.0) }
input: type(0), swing(2.5), usefutures(false), printfile(true);
vars: pcswing(0), lastswing(0), curhigh(0), curlow(0), swhigh(0), swlow(0) , highbar(0),
lowbar(0), chighbar(0), clowbar(0), lowp(0), highp(0), xclose(0), xhigh(0),
xlow(0), divide(4), par(800), prevhigh(0), prevlow(0), adate(" "),
totalPL(0), dailyPL(0), psignal(0), ATR(0), ATRperiod(20), size(0),
futuresinvestment(25000), stockinvestment(10000);
pcswing = swing / 100.;
if usefutures then begin
size = futuresinvestment/(avgtruerange(ATRperiod)*bigpointvalue);
end
else size = stockinvestment/close[1];
if type = 0 then begin
xhigh = high;
xlow = low;
xclose = close;
end
else if type = 1 then begin
xhigh = 100 - low;
xlow = 100 - high;
xclose = 100 - close;
end
else if type = 2 then begin
xhigh = par / low;
xlow = par / high;
xclose = par / close;
end;
{ INITIALIZE MOST RECENT HIGH AND LOW }
if currentbar = 1 then begin
curhigh = xclose; { current high }
curlow = xclose; { current low }
end;
{ Buy or sell signals }
if type = 0 then begin
if marketposition <= 0 and xhigh > swhigh then begin
Buy to cover all contracts this bar on close;
Buy size contracts This Bar on close;
end
else if marketposition >= 0 and xlow < swlow then begin
sell all contracts this bar on close;
Sell Short size contracts This Bar on close;
end;
end
else begin
if marketposition >= 0 and xhigh > swhigh then begin
sell all contracts this bar on close;
Sell Short size contracts This Bar on close;
end
else if marketposition <= 0 and xlow < swlow then begin
Buy to cover all contracts This Bar on close;
buy size contracts this bar on close;
end;
end;
{ SEARCH FOR A NEW HIGH -- favor reversals }
if lastswing<>1 then begin
{ REVERSE FROM HIGH IF MINIMUM % SWING }
if xlow < curhigh - curhigh*pcswing then begin
lastswing = 1; { lastswing high fixed }
swhigh = curhigh; { new verified high }
highbar = chighbar;
curlow = xlow; { initialize new lows }
lowp = xlow; { swing low for plot }
clowbar = currentbar;
end
else begin
if xhigh > curhigh then begin
curhigh = xhigh; { new current high }
chighbar = currentbar;
end;
end;
end;
{ SEARCH FOR A NEW LOW - favor reversal }
if lastswing <> -1 then begin
{ REVERSAL FROM LOW IF MINIMUM % SWING }
if xhigh > curlow + curlow*pcswing then begin
lastswing = -1;
swlow = curlow;
lowbar = clowbar;
curhigh = xhigh; { initialize current high }
highp = xhigh; { swing high for plot }
chighbar = currentbar;
end
else begin
if xlow < curlow then begin
curlow = xlow;
clowbar = currentbar;
end;
end;
end;
totalpl = netprofit + openpositionprofit;
dailyPL = psignal*currentshares*(close - close[1]);
psignal = marketposition;
end;
7. 표준편차 이동평균 관련 수식
inputs: period(40);
vars: SD(0), SDV(0), stdavg(0);
SD = stddev(close,period);
SDV = (SD - SD[1])/SD;
StdAvg = Average(close,period/2) + .05*SDV;
plot1(stdavg,"StdAvg");
8. 추세추종 시스템 관련 수식
{ period = length of calculaton
entryoption = 0 buy/sell on current close
= 1 buy/sell on next open
= 2 buy/sell next close
crossoption = 0 using trendline,
= 1 use price crossing trendline
longonly true then only long positions
high-vol filter
}
input: usemovingaverage(true), usebreakout(false), useslope(false), useexponential(false), period(80),
entryoption(0), crossoption(0), longonly(false), exitvol(0), reentervol(0), stoploss(0),
usestocks(true),usefutures(false),variablesize(true), reinvest(false), futuresinvestment(25000),
stockinvestment(10000), printfiles(false);
vars: signal(0), price(0), size(1), investment(1000), slope(0), ATRper(20), smooth(1.0),
atrange(0), MA(0), adate(" "), equity(0), PL(0), PLlong(0), PLshort(0), exposure(0),
expsmooth(0), tradeentry(0), tradeentrybar(0), tradeprice(0),dailyreturn(0), NAV(100),
volper(20), returns(0), vol(0), exitvolOK(true), reentervolOK(true), exitonstop(0),
bestprice(0);
If Currentbar = 1 then begin
if usestocks then begin
investment = stockinvestment;
if variablesize = false then size = 100;
end
else begin
investment = futuresinvestment;
if variablesize = false then size = 1;
end;
if useexponential then smooth = 2/(period + 1);
end;
if variablesize then begin
if usefutures then begin
atrange = avgtruerange(ATRper);
if atrange = 0 then
size = 1
else
if atrange <> 0 then size = investment/(atrange*bigpointvalue);
end;
if usestocks then begin
if close[1] <> 0 then size = investment/close[1];
end;
end;
if usemovingaverage then begin
MA = average(close,period);
if crossoption = 0 then begin
if MA > MA[1] then signal = 1
else if MA < MA[1] then signal = -1;
end
else if crossoption = 1 then begin
if close >= MA then signal = 1
else signal = -1;
end;
end
else if usebreakout then begin
if high > highest(high[1],period) then signal = 1
else if low < lowest(low[1],period) then signal = -1;
end
else if useslope then begin
slope = linearregslope(close,period);
if slope > 0 then signal = 1
else if slope < 0 then signal = -1;
end
else if useexponential then begin
if currentbar = 1 then
expsmooth = close
else begin
expsmooth = expsmooth + smooth*(close - expsmooth);
end;
if expsmooth > expsmooth[1] then signal = 1
else if expsmooth < expsmooth[1] then signal = -1;
end;
// reset exit on stop
if exitonstop <> 0 then begin
if exitonstop > 0 and signal < 0 then exitonstop = 0
else if exitonstop < 0 and signal > 0 then exitonstop = 0;
end;
// exit percentage trailing stop-loss
if stoploss <> 0 and marketposition <> 0 then begin
// return on trade as of close
// PL = marketposition*currentcontracts*(close - entryprice);
if marketposition > 0 then begin
// bestprice = maxlist(bestprice,high);
// if close/bestprice - 1 < -stoploss then begin
if close/entryprice - 1 < -stoploss then begin
sell ("XLstop") all contracts next bar on open;
exitonstop = marketposition;
end;
end
else if marketposition < 0 then begin
bestprice = minlist(bestprice,low);
if bestprice/close - 1 < -stoploss then begin
buy to cover ("XSstop") all contracts next bar on open;
exitonstop = marketposition;
end;
end;
end;
// exit volatility filter
if exitvol <> 0 then begin
returns = close/close[1] - 1;
vol = stddev(returns,volper)*squareroot(252.);
if reentervol <> 0 and vol < reentervol then exitvolOK = true;
if vol > exitvol then exitvolOK = false;
// exit on volatility filter
if marketposition <> 0 and exitvolOK = false then begin
if marketposition > 0 then sell ("XLvol") all contracts next bar on open
else if marketposition < 0 then buy to cover ("XSvol") all contracts next bar on open;
reentervolOK = false;
end;
end;
if marketposition = 0 and reentervolOK = false and vol < reentervol
then reentervolOK = true;
{ entry and entry options, always reverse position }
If entryoption = 0 and exitvolOK and exitonstop = 0 then begin
if signal = 1 and marketposition <> 1 then begin
if usemovingaverage then Buy ("BMA") size contracts this bar on close
else if usebreakout then Buy ("BBO") size contracts this bar on close
else if useslope then buy ("BLRS") size contracts this bar on close
else if useexponential then buy ("BEXP") size contracts this bar on close;
// adate = ELdatetostring(tradeentry);
// print(file("c:₩tradestation₩Trend_trade_length.csv"), adate, ",", currentbar - tradeentrybar:5:0,
// ",", size*(close - tradeprice):8:2);
tradeentry = date;
tradeentrybar = currentbar;
tradeprice = close;
bestprice = close;
end
else if signal = -1 and marketposition <> -1 then begin
if longonly then begin
if usemovingaverage then sell ("XMA") all contracts this bar on close
else if usebreakout then sell ("XBO") all contracts this bar on close
else if useslope then sell ("XLRS") all contracts this bar on close
else if useexponential then sell ("XEXP") all contracts this bar on close;
// adate = ELdatetostring(tradeentry);
// print(file("c:₩tradestation₩Trend_trade_length.csv"), adate, ",", currentbar - tradeentrybar:5:0,
// ",", size*(close - tradeprice):8:2);
tradeentry = date;
tradeentrybar = currentbar;
tradeprice = close;
bestprice = close;
end
else begin
if usemovingaverage then sell short ("SMA") size contracts this bar on close
else if usebreakout then sell short ("SBO") size contracts this bar on close
else if useslope then sell short ("SLRS") size contracts this bar on close
else if useexponential then sell short ("SEXP") size contracts this bar on close;
// adate = ELdatetostring(tradeentry);
// print(file("c:₩tradestation₩Trend_trade_length.csv"), adate, ",", currentbar - tradeentrybar:5:0,
// ",", size*(close - tradeprice):8:2);
tradeentry = date;
tradeentrybar = currentbar;
tradeprice = close;
bestprice = close;
end;
end;
end
else if entryoption = 1 and exitvolOK then begin
If signal = 1 and marketposition <> 1 then buy size contracts next bar on open
Else if signal = -1 and marketposition <> -1 then begin
if longonly then sell all contracts next bar on open
else sell short size contracts next bar on open;
end;
end
else if entryoption = 2 and exitvolOK then begin
If signal[1] = 1 and marketposition <> 1 then buy size contracts this bar on close
Else if signal[1] = -1 and marketposition <> -1 then begin
if longonly then sell all contracts next bar on open
else sell short size contracts next bar on open;
end;
end;
if lastbaronchart then
if marketposition > 0 then sell all contracts this bar on close
else if marketposition < 0 then buy to cover all contracts this bar on close;
equity = netprofit + openpositionprofit;
PL = equity - equity[1];
dailyreturn = 0;
if investment <> 0 then dailyreturn = PL/investment;
NAV = NAV*(1 + dailyreturn);
if marketposition > 0 then
PLlong = PLlong + PL
else if marketposition < 0 then
PLshort = PLshort + PL;
if reinvest then investment = stockinvestment + equity;
If printfiles then begin
adate = ELdatetostring(date);
// if currentbar = 1 then begin
// print(file("c:₩tradestation₩Trend_trade_length.csv"), "Enter,Days,PL");
// end;
// if usemovingaverage then begin
If Currentbar = 1 then begin
print(file("c:₩tradestation₩Trend_PL.csv"),"Date,TotalPL");
print(file("c:₩tradestation₩Trend_Detail.csv"),
"Date,Open,High,Low,Close,MA,size,marketposition,PLtoday,PLlong,",
"PLshort,TotalPL,Return,NAV");
end;
print(file("c:₩tradestation₩Trend_PL.csv"),adate, ",", PL:8:4);
print(file("c:₩tradestation₩Trend_Detail.csv"),adate, ",", open:8:4, ",", high:8:4, ",",
low:8:4, ",", close:8:4, ",", MA:8:4, ",", currentcontracts:6:2, ",",
marketposition:6:2, ",", PL:8:4, ",", PLlong:8:4, ",",
PLshort:8:4, ",", equity:8:4, ",", dailyreturn:6:5, ",", NAV:10:3);
// end
// else if usebreakout then begin
// If Currentbar = 1 then print(file("c:₩tradestation₩BO_PL.csv"), "Date,size,netPL,PLlong,PLshort,PLtoday");
// print(file("c:₩tradestation₩BO_PL.csv"),adate, ",", size:8:3, ",", equity:8:4, ",", PLlong:8:4, ",",
// PLshort:8:4, ",", PL:8:4);
// end
// else if useslope then begin
// If Currentbar = 1 then print(file("c:₩tradestation₩LRS_PL.csv"), "Date,size,netPL,PLlong,PLshort,PLtoday");
// print(file("c:₩tradestation₩LRS_PL.csv"),adate, ",", size:8:3, ",", equity:8:4, ",", PLlong:8:4, ",",
// PLshort:8:4, ",", PL:8:4);
// end;
end;
9.표준편차 청산수식
{ inputs: length = average true range calculation period
(normally 30 for intraday, 20 for daily)
factor = standard deviation value for stop }
inputs: length(20), factor1(2.06), factor2(3.2);
vars: up1(0), up2(0), dn1(0), dn2(0);
up1 = highest(high,length) - TSMStdevStop(length, factor1);
up2 = highest(high, length) - TSMStdevStop(length, factor2);
dn1 = lowest(low, length) + TSMStdevStop(length, factor1);
dn2 = lowest(low, length) + TSMStdevStop(length, factor2);
plot1(up1,"TSMup1");
plot2(up2,"TSMup2");
plot3(dn1,"TSMdn1");
plot4(dn2,"TSMdn2");
10. 효율비 관련 수식
input: period(20);
vars: change(0), noise(0), diff(0), ratio(0), signal(0), sumratio(0), avgratio(0);
ratio = 0;
diff = AbsValue(close - close[1]);
if currentbar > period then begin
change = close - close[period];
signal = AbsValue(change);
noise = summation(diff,period);
ratio = 0;
if noise <> 0 then ratio = signal/noise;
sumratio = sumratio + ratio;
end;
if lastbaronchart then begin
avgratio = sumratio/(currentbar - period);
2023-06-10
1554
글번호 169656
답변완료
수식좀 요청 드립니다
* 좋은 한주 되십시요.
<요청1> 박스가 형성 되도록 수식좀 요청 드립니다.
<기준> 현재봉 이전 20개봉(변수) 박스 좀 부탁 드립니다.(이전거는 필요 없음)
즉 20개봉중 최대값과 최소값을 네모 모양으로 박스 1개만 부탁 드립니다.
<요청2> 아래수식 꼬리가 안보이는데 윗꼬리 아래 꼬리 표현좀 부탁 드립니다.
<아래 차트 기준>
var : xClose(0),xOpen(0),xHigh(0),xLow(0);
#Heiken Ashi 시고저종
if index == 0 then
{
xOpen = open;
xClose = (O+H+L+C)/4;
xHigh = MaxList( high, xOpen, xClose);
xLow = MinList( low, xOpen,xClose);
}
else
{
xClose = (O+H+L+C)/4;
xOpen = (xOpen [1] + xClose [1])/2 ;
xHigh = MaxList(High, xOpen, xClose) ;
xLow = MinList(Low, xOpen, xClose) ;
}
if XClose > Xopen Then
PlotPaintBar(Xhigh,Xlow,"강조",MAGENTA);
else if XClose < Xopen Then
PlotPaintBar(Xhigh,Xlow,"강조",CYAN);
else
PlotPaintBar(Xhigh,Xlow,"강조",GREEN);
고맙습니다. 수고하십시요.
2023-06-12
1015
글번호 169655
답변완료
부탁드립니다.
a=cci(p);
b=eavg(a,p)
p/10
2023-06-10
1125
글번호 169654
답변완료
문의 드립니다.~~~~
수고하십니다.
cme 해선 매매시
당일 시가대비 n틱 상승시 매도
당일 시가대비 m틱 하락시 매수하는 식 부탁드립니다.
2023-06-10
1074
글번호 169653
답변완료
수식부탁드립니다
수식부탁드립니다
당일용 분봉에서
dmiv>30 && dp<dm 이 없고 dmiv>30 && dp>dm 이면
이후 dmiv>30 && dp<dm 이 나올때까지는 별도 조건의 매수식을 적용하고
이후 dmiv>30 && dp<dm 이 나오면 매수가 없다가
이후 dmiv>30 && dp>dm 이 나오면 별도 조건의 매수식을 적용
위의 그림처럼 빨간선 구간에서만 별도 매수식을 적용하도록 수식 부탁드려요..
2023-06-10
1598
글번호 169652
답변완료
예스수식으로 전환부탁드립니다.
아래 키움수식을 예스수식으로 전환부탁드립니다.
1)수식
a=crossup(sar(af,maxAf),c) or crossdown(sar(af,maxAf),c);
valuewhen(1,a,avg(c,5))
(** af=0.01, maxAf=0.2 **)
2)수식
a=c;
b=(highest(high,midPeriod)+lowest(low,midPeriod))/2;
valuewhen(1,crossup(a,b),c)
(** midPeriod=26 **)
감사합니다.
2023-06-10
1688
글번호 169651