커뮤니티

예스랭귀지 Q&A

글쓰기
답변완료

시스템식 요청드립니다.

안녕하세요 어제 시스템식 요청했던 사람입니다. 말씀해준신대로 수량옵션에서 1로 적용했더니 동일시간에는 동시에 수량이 빠지는게 없어졌는데 추후에 말씀해주신 문제점도 그대로 발생하게 되었습니다. ((다음봉에서 latestEntryPrice*1.05보다 큰 시세가 있으면 해당 청산이 또 발생하게 됩니다. 해당 청산식이 봉완성시 if조건이 만족하고 다음봉에서 atlimit 가격조건을 충족만 하면 발생하기 때문입니다)) 해당 문제를 해결하기 위해서 "진입명"도 넣고 해봤는데, 제가 원하는 식은 아예 나오질 않더라구요 혹시 아래의 문제를 해결할 수 있는 방법은 없을까요??? 그리고 두번째 문제점은 위의 그림을 보시면 전고점 돌파했을때 매수가 들어가는 부분이 있는데 갭상으로 전고점을 돌파하면서, 10% 익절 매도청산까지 나갔을 경우에 돌파매수가 안됩니다. 여러가지 방식으로 이것저것 넣어봤지만 안되는데, 혹시 해결할수 있는 방법이 있을까요? --------------------------------------------------------------------------------------------------------- 안녕하세요 예스스탁입니다. 현재식에서 수량옵션 1로 하시면 동일날짜에 30주가 청산신호가 나오게 되지만 타점에서 해당 수량이 빠지게 됩니다. 타점에서 진입된 수량이 30주가 안되면 다음진입신호에서 나머지수량이 차감되게 됩니다. 청산신호는 진입명을 지정하지 않으면 먼저 나온신호에서 해당 수량을 차감해 청산하게 됩니다. 또한 다른 문제도 있는데 다음봉에서 latestEntryPrice*1.05보다 큰 시세가 있으면 해당 청산이 또 발생하게 됩니다. 해당 청산식이 봉완성시 if조건이 만족하고 다음봉에서 atlimit 가격조건을 충족만 하면 발생하기 때문입니다. 즐거운 하루되세요 > 맴맴잉 님이 쓴 글입니다. > 제목 : Re : Re : 시스템식 요청드립니다. > 오호~~~ 감사합니다. ExitLong("명칭",신호타입,신호가격,"진입명",수량,수량옵션); 에서 수량옵션을 1로 수정하면 동일날짜에 "타점"과 "타점1"에서 합쳐서 30주를 청산하게 되는게 맞는건가요?? > 예스스탁 님이 쓴 글입니다. > 제목 : Re : 시스템식 요청드립니다. > 안녕하세요 예스스탁입니다. ExitLong("명칭",신호타입,신호가격,"진입명",수량,수량옵션); 청산함수는 위와같이 6개의 옵션을 지정할 수 있습니다. 현재 작성하신 청산식은 if 문으로 최근 진입명이나 청산명이 어떤 이름일때 동작하라는 내용만 있습니다. 1 5번째와 6번째는 수량과 수량관련 옵션입니다. 수량옵션을 0으로 지정하면 피라미딩시 각 진입별로 지정한 수량을 청산하게 됩니다. 수량옵션을 1로 지정하면 지정한 수량만 차감하게 됩니다. 수량옵션은 생략하면 0이 적용됩니다. 작성하신 수식에서는 모두 수량옵션이 생략이 되어 있어 수량옵션은 0이 적용되고 첨부하신 그림과 같이 2회 매수진입이 있고 동일날짜에 "타점"과 "타점1"에서 각각 30주씩 청산이 된 것입니다. 2 4번째 옵션이 진입명입니다. 청산함수에 진입명을 지정하면 해당진입명에서만 지정한 수량을 청산하게 됩니다. 올리신 수식에서는 진입명 옵션을 이용해 제어를 하셔야 합니다. if (LatestEntryName(0) == "타점1")Then ExitLong("타점1 5%익절",AtLimit,latestEntryPrice*1.05,"타점1",Floor(베팅금/타점)*0.3); 위와 같이 진입명에 "타점1"을 지정하시면 가장 최근 진입이 "타점1"이고 진입가에서 5% 상승하면 타점1에서만 30주 청산해라 라는 내용이 됩니다, 3 분할청산을 할 때는 청산함수의 4,5,6번 매개변수를 이용해 원하시는 내용으로 청산이 발생하게 제어를 하셔야 합니다. 즐거운 하루되세요 > 맴맴잉 님이 쓴 글입니다. > 제목 : 시스템식 요청드립니다. > 안녕하세요 수식을 작성하는데 어려움이 있어 이렇게 글을 남깁니다. 위의 그림 2, 3번을 보시면 대략적으로 그림으로 작성하였습니다. 타점 에서 100주 매수후 30주 매도 하고 중간에 30주 매도 해서 총 40주가 남은 상태에서 타점 1로 60주 매수해서 다시 100주가 되도록 맞췄습니다. 그런데 타점1 5% 익절에서 30주만 매도가 되어야 하는데 그림 1 성능보고서를 보시면, 타점에서 30주매도, 타점 1에서 30주 매도 총 60주가 매도 되었습니다. 타점, 타점 1이 따로따로 시스템식이 적용 되는것 같은데 어떻게 해야 할지 부탁드리겠습니다. input : 베팅금(1000000); input : 시작날짜 (20240113),Xtime(110000) ; input : 타점(5000),손절(1000); var : P618(0),P5(0),P382(0),HH(0),LL(0); Var : day(0),EntryDay(0),entry(False),dd(0),ED(0); if sDate >= 시작날짜 Then { if Bdate != Bdate[1] Then { entry = true; day = day+1; dd = dd+1; } if HH == 0 or (HH > 0 and H > HH) Then HH = H; #고점갱신용 수식 if LL == 0 or (LL > 0 and L < LL) Then LL = L; #저점갱신용 수식 } P618 = LL+(HH-LL)*0.618; P5 = LL+(HH-LL)*0.5; P382 = LL+(HH-LL)*0.382; if MarketPosition == 0 and entry == true and c > 타점 Then Buy("타점",AtLimit,타점,Floor((베팅금)/타점)); if MarketPosition == 1 Then { Condition1 = False; If C >= HH[1] AND LatestExitName(0) == "타점 5%익절 P5청산" Then { Condition1 = true; Buy("타점1",OnClosE,DeF,Floor((베팅금)/타점*0.6)); } If C >= HH[1] AND LatestExitName(0) == "타점 10%익절 P618청산" Then { Condition1 = true; Buy("타점2",OnClosE,DeF,Floor((베팅금)/타점*0.8)); } #전봉대비 수량 감소(일부 청산발생을 위미) if CurrentContracts < CurrentContracts[1] Then { #청산가 저장 var1 = LatestExitPrice(0); if LatestExitName(0) == "타점 5%익절" or LatestExitName(0) == "타점1 5%익절" or LatestExitName(0) == "타점2 5%익절" Then Condition11 = true; if LatestExitName(0) == "타점 5%익절 P5청산" or LatestExitName(0) == "타점 10%익절" or LatestExitName(0) == "타점1 5%익절 P618청산" or LatestExitName(0) == "타점1 10%익절" or LatestExitName(0) == "타점2 5%익절 P618청산" or LatestExitName(0) == "타점2 10%익절" Then Condition22 = true; if LatestExitName(0) == "타점 5%익절 P382청산" or LatestExitName(0) == "타점 10%익절 P618청산" or LatestExitName(0) == "타점1 5%익절 P5청산" or LatestExitName(0) == "타점1 10%익절 P618청산" or LatestExitName(0) == "타점2 5%익절 P5청산" or LatestExitName(0) == "타점2 10%익절 P618청산" Then Condition33 = true; if LatestExitName(0) == "타점 10%익절 P5청산" or LatestExitName(0) == "타점1 10%익절 P5청산" or LatestExitName(0) == "타점2 10%익절 P5청산" Then Condition44 = true; } #전봉대비 수량 증가(추가 진입발생을 의미) if CurrentContracts > CurrentContracts[1] Then { #현재수량 저장 Var3 = CurrentContracts; Var4 = AvgEntryPrice; Condition11 = False; Condition22 = False; Condition33= False; Condition44 = False; } if (LatestEntryName(0) == "타점") and Condition1 == False Then ExitLong("타점 5%익절",AtLimit,AvgEntryPrice*1.05,"",Floor(베팅금/타점)*0.3); if (LatestExitName(0) == "타점 5%익절") and c <= P5 Then ExitLong("타점 5%익절 P5청산",AtLimit,P5,"",Floor(베팅금/타점)*0.3); if (LatestExitName(0) == "타점 5%익절 P5청산") and c <= P382 Then ExitLong("타점 5%익절 P382청산",AtLimit,P382,"",Floor(베팅금/타점)*0.4); if (LatestEntryName(0) == "타점") and Condition1 == False Then ExitLong("타점 10%익절",AtLimit,AvgEntryPrice*1.2,"",Floor(베팅금/타점)*0.3); if (LatestExitName(0) == "타점 10%익절") and c <= P618 Then ExitLong("타점 10%익절 P618청산",AtLimit,P618,"",Floor(베팅금/타점)*0.2); if (LatestExitName(0) == "타점 10%익절 P618청산") and c <= P5 Then ExitLong("타점 10%익절 P5청산",AtLimit,P5,"",Floor(베팅금/타점)*0.2); if (LatestEntryName(0) == "타점1")Then ExitLong("타점1 5%익절",AtLimit,latestEntryPrice*1.05,"",Floor(베팅금/타점)*0.3); if (LatestExitName(0) == "타점1 5%익절") and c <= P618 Then ExitLong("타점1 5%익절 P618청산",AtLimit,P618,"",Floor(베팅금/타점)*0.3); if (LatestExitName(0) == "타점1 5%익절 P618청산") and c <= 5 Then ExitLong("타점1 5%익절 P5청산",AtLimit,P5,"",Floor(베팅금/타점)*0.4); if (LatestEntryName(0) == "타점1") Then ExitLong("타점1 10%익절",AtLimit,latestEntryPrice*1.1,"",Floor(베팅금/타점)*0.3); if (LatestExitName(0) == "타점1 10%익절") and c <= P618 Then ExitLong("타점1 10%익절 P618청산",AtLimit,P618,"",Floor(베팅금/타점)*0.2); if (LatestExitName(0) == "타점1 10%익절 P618청산") and c <= P5 Then ExitLong("타점1 10%익절 P5청산",AtLimit,P5,"",(베팅금/타점)*0.2); if (LatestEntryName(0) == "타점2")Then ExitLong("타점2 5%익절",AtLimit,latestEntryPrice*1.05,"",Floor(베팅금/타점)*0.3); if (LatestExitName(0) == "타점2 5%익절") and c <= P618 Then ExitLong("타점2 5%익절 P618청산",AtLimit,P618,"",Floor(베팅금/타점)*0.3); if (LatestExitName(0) == "타점2 5%익절 P618청산") and c <= 5 Then ExitLong("타점2 5%익절 P5청산",AtLimit,P5,"",Floor(베팅금/타점)*0.4); if (LatestEntryName(0) == "타점2") Then ExitLong("타점2 10%익절",AtLimit,latestEntryPrice*1.1,"",(베팅금/타점)*0.3); if (LatestExitName(0) == "타점2 10%익절") and c <= P618 Then ExitLong("타점2 10%익절 P618청산",AtLimit,P618,"",Floor(베팅금/타점)*0.2); if (LatestExitName(0) == "타점2 10%익절 P618청산") and c <= P5 Then ExitLong("타점2 10%익절 P5청산",AtLimit,P5,"",Floor(베팅금/타점)*0.2); } if MarketPosition == 1 and sTime > xtime and 손절 >= c Then ExitLong("손절"); if MarketPosition == 1 and (LatestEntryName(0) == "타점1") and c <= latestEntryPrice*0.96 Then ExitLong("5%돌파손절"); if MarketPosition == 1 and (LatestEntryName(0) == "타점2") and c <= latestEntryPrice*0.96 Then ExitLong("10%돌파손절");
프로필 이미지
맴맴잉
2024-03-12
916
글번호 177390
시스템
답변완료

부탁드립니다.

1. 종가가 전일 최고가 위로 올랐다가 다시 최고가 아래로 떨어지면 빨강색으로, 종가가 전일 최 저가 아래로 내렸다가 다시 최저가 위로 올라서면 파란색으로 구현해 주세요 2. 종가가 전주 최고가 위로 올랐다가 다시 최고가 아래로 떨어지면 빨강색으로, 종가가 전주 최저가 아래로 내렸다가 다시 최저가 위로 올라서면 파란색으로 구현해 주세요 3. 종가가 전월 최고가 위로 올랐다가 다시 최고가 아래로 떨어지면 빨강색으로, 종가가 전월 최저가 아래로 내렸다가 다시 최저가 위로 올라서면 파란색으로 구현해 주세요 고맙습니다.
프로필 이미지
서태공
2024-03-11
668
글번호 177389
강조
답변완료

20이평 값 출력 문의합니다.

주식 종목에 오늘부터 20일 전까지의 20 이평 값만 출력되도록, 아래와 같은 식을 적용하면 실제 20이평 값과 전혀 다른 값이 출력됩니다. 어떻게 수정하면 되는지 문의 드립니다. Input : period(20); Var : dd(0); if sDate >= CurrentDate Then { for dd=0 to (period-1) { Var1 = ma(C[dd], period); MessageLog("var1=%f", Var1); } }
프로필 이미지
투자
2024-03-11
760
글번호 177388
지표
답변완료

수식부탁드려요 도사님.

1.코스피200 종목 2.거래량 -> 2배이상증가 종목 (거래량비율 [n봉]:1봉전) 200% 3.시세->7%이상 (주가등락률:[일]1봉전 , 종가대비0봉전 종가등락률 7%이상) 4.음봉다음, 첫양봉 5.거래폭증제외,상제외 검색식 부탁드립니다.
프로필 이미지
아이덜
2024-03-11
964
글번호 177387
종목검색
답변완료

분할 진입 및 분할 청산

안녕하세요 항상 예스스탁 팀에 감사드리고 있습니다. 분할 진입 및 분할 청산에 관련하여 질문드렸었는데, 생각대로 잘 되지 않아 재문의 드립니다. X라는 변수에 맞춰 계약수 (또는 주식 수)를 관리하고 싶다고 말씀드렸었습니다. 당시, 아래와 같이 답변 주셨는데, 잘 되지 않습니다. ----- var : x(0); if MarketPosition <= 0 and x > 0 Then Buy("b",OnClose,Def,x); if MarketPosition >= 0 and x < 0 Then Sell("s",OnClose,Def,abs(x)); if MarketPosition == 1 Then { if x >= 0 Then { if x > CurrentContracts Then Buy("bb",OnClose,Def,x-CurrentContracts); if x < CurrentContracts Then ExitLong("bx",OnClose,Def,"",CurrentContracts-x,1); } } if MarketPosition == -1 Then { if x <= 0 Then { if abs(x) > CurrentContracts Then Sell("ss",OnClose,Def,abs(x)-CurrentContracts); if abs(x) < CurrentContracts Then ExitShort("sx",OnClose,Def,"",CurrentContracts-abs(x),1); } } --------- 어떤 부분에서 안되냐면, if MarketPosition <= 0 and x > 0 Then Buy("b",OnClose,Def,x); if MarketPosition >= 0 and x < 0 Then Sell("s",OnClose,Def,abs(x)); 이렇게 천 진입은 제대로 되는데, 그 이후가 제대로 되지 않습니다. 특히 추가 주문 및 중간 청산 부분이 잘 되지 않습니다. if MarketPosition == 1 Then { if x >= 0 Then { if x > CurrentContracts Then Buy("bb",OnClose,Def,x-CurrentContracts); if x < CurrentContracts Then ExitLong("bx",OnClose,Def,"",CurrentContracts-x,1); } } ^^^이 부분입니다. 현재 예스트레이더 코인으로 돌리고 있구요, 왜 안되는지 저도 잘 모르겠습니다. 수식만 보면 완벽한것같은데... 피라미딩은 '모든 진입 신호 허용'으로 해놨고, 주문수량도 100000000으로 늘려놨고 진입 횟수도 1000으로 늘려놨는데요 중간에 불타기 또는 부분 청산이 잘 되지 않습니다. 어떤 종목은 잘 되고 어떤 종목은 안됩니다 ㅠㅠㅠㅠ 도와주십쇼 ㅠㅠ
프로필 이미지
이만스닥
2024-03-11
692
글번호 177380
시스템

아트정 님에 의해서 삭제되었습니다.

프로필 이미지
아트정
2024-03-11
24
글번호 177369
시스템

창동개미 님에 의해서 삭제되었습니다.

프로필 이미지
창동개미
2024-03-11
24
글번호 177368
지표
답변완료

수식변환 문의

수고가 많으십니다. 트레이딩뷰의 지표인 Nadaraya" Watson Envelope 예스로 변환해 주시면 좋겠습니다. ================= // This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/ // &#169; LuxAlgo //@version=5 indicator("Nadaraya-Watson Envelope [LuxAlgo]", "LuxAlgo - Nadaraya-Watson Envelope", overlay = true, max_lines_count = 500, max_labels_count = 500, max_bars_back=500) //------------------------------------------------------------------------------ //Settings //-----------------------------------------------------------------------------{ h = input.float(8.,'Bandwidth', minval = 0) mult = input.float(3., minval = 0) src = input(close, 'Source') repaint = input(true, 'Repainting Smoothing', tooltip = 'Repainting is an effect where the indicators historical output is subject to change over time. Disabling repainting will cause the indicator to output the endpoints of the calculations') //Style upCss = input.color(color.teal, 'Colors', inline = 'inline1', group = 'Style') dnCss = input.color(color.red, '', inline = 'inline1', group = 'Style') //-----------------------------------------------------------------------------} //Functions //-----------------------------------------------------------------------------{ //Gaussian window gauss(x, h) => math.exp(-(math.pow(x, 2)/(h * h * 2))) //-----------------------------------------------------------------------------} //Append lines //-----------------------------------------------------------------------------{ n = bar_index var ln = array.new_line(0) if barstate.isfirst and repaint for i = 0 to 499 array.push(ln,line.new(na,na,na,na)) //-----------------------------------------------------------------------------} //End point method //-----------------------------------------------------------------------------{ var coefs = array.new_float(0) var den = 0. if barstate.isfirst and not repaint for i = 0 to 499 w = gauss(i, h) coefs.push(w) den := coefs.sum() out = 0. if not repaint for i = 0 to 499 out += src[i] * coefs.get(i) out /= den mae = ta.sma(math.abs(src - out), 499) * mult upper = out + mae lower = out - mae //-----------------------------------------------------------------------------} //Compute and display NWE //-----------------------------------------------------------------------------{ float y2 = na float y1 = na nwe = array.new<float>(0) if barstate.islast and repaint sae = 0. //Compute and set NWE point for i = 0 to math.min(499,n - 1) sum = 0. sumw = 0. //Compute weighted mean for j = 0 to math.min(499,n - 1) w = gauss(i - j, h) sum += src[j] * w sumw += w y2 := sum / sumw sae += math.abs(src[i] - y2) nwe.push(y2) sae := sae / math.min(499,n - 1) * mult for i = 0 to math.min(499,n - 1) if i%2 line.new(n-i+1, y1 + sae, n-i, nwe.get(i) + sae, color = upCss) line.new(n-i+1, y1 - sae, n-i, nwe.get(i) - sae, color = dnCss) if src[i] > nwe.get(i) + sae and src[i+1] < nwe.get(i) + sae label.new(n-i, src[i], '▼', color = color(na), style = label.style_label_down, textcolor = dnCss, textalign = text.align_center) if src[i] < nwe.get(i) - sae and src[i+1] > nwe.get(i) - sae label.new(n-i, src[i], '▲', color = color(na), style = label.style_label_up, textcolor = upCss, textalign = text.align_center) y1 := nwe.get(i) //-----------------------------------------------------------------------------} //Dashboard //-----------------------------------------------------------------------------{ var tb = table.new(position.top_right, 1, 1 , bgcolor = #1e222d , border_color = #373a46 , border_width = 1 , frame_color = #373a46 , frame_width = 1) if repaint tb.cell(0, 0, 'Repainting Mode Enabled', text_color = color.white, text_size = size.small) //-----------------------------------------------------------------------------} //Plot //-----------------------------------------------------------------------------} plot(repaint ? na : out + mae, 'Upper', upCss) plot(repaint ? na : out - mae, 'Lower', dnCss) //Crossing Arrows plotshape(ta.crossunder(close, out - mae) ? low : na, "Crossunder", shape.labelup, location.absolute, color(na), 0 , text = '▲', textcolor = upCss, size = size.tiny) plotshape(ta.crossover(close, out + mae) ? high : na, "Crossover", shape.labeldown, location.absolute, color(na), 0 , text = '▼', textcolor = dnCss, size = size.tiny) //-----------------------------------------------------------------------------}
프로필 이미지
부호장자
2024-03-11
653
글번호 177365
지표
답변완료

수식

안녕하세요. 시스템 수익 부탁드립니다. 1. 당일 선물 미결이 -10,000 이하로 줄어들면 진입 금지 2. 당일 선물 미결이 -10,000 이하로 줄어들면 청산 감사합니다.
프로필 이미지
한국사람73
2024-03-11
531
글번호 177362
시스템

창동개미 님에 의해서 삭제되었습니다.

프로필 이미지
창동개미
2024-03-11
0
글번호 177354
지표