예스스탁
예스스탁 답변
2022-03-21 18:02:17
안녕하세요
예스스탁입니다.
1
buy2조건 내용은 올리신 수식으로 내용판별이 어렵습니다.
해당 부분은 기존 내용과 같습니다.
2
추가진입을 하는 내용이므로
모든 청산을 진입이 발생하면 1회씩만 발생할수 있게 제어하셔야 합니다.
내용상 일부 청산후에 추가진입이 발생할수 있으므로
청산기준수량도 추가진입후 현재수량으로 지정해 주셔야 합니다.
3
input : P1(5),P2(20),P3(60),P4(120),P5(240),P6(480);
Input : Period(12), Period1(6), Period2(10),Period3(12);
var : StoK(0),StoD(0),RSIV(0);
var : HH(0),LL(0),HV(0),HV1(0),HL(0),HL2(0),CC(0), CC1(0);
var : Xvol(0);
var1=ma(c,P1);
var2=ma(c,P2);
var3=ma(c,P3);
var4=ma(c,P4);
var5=ma(c,P5);
Var6=ma(c,P6);
StoK = StochasticsK(Period,Period1);
StoD = StochasticsD(Period,Period1,Period2);
RSIV = RSI(Period3);
HL = DayHigh/DayLow; #당일 고가-저가 차이
HH = Highest(H,120);
LL = Lowest(L,120);
HL2 = HH/LL; #2시간 내 고가 저가 차이
#돌파 신호 조건
If C >= O and C > Var5 and C > var6 and HL < 1.15 and HL2 < 1.1 and DayOpen < DayClose[1]*1.05 and countif(CrossDown(var5,Var6),240) == 0 and
countif(M > 100000000,3) >= 1 and DayVolume > (DayVolume[1]*0.3) and
Countif(crossup(RSIV,70),3) >= 1 Then
{
value1 = C;
Value2 = Index;
}
Else #돌파조건 만족봉이 아니고
{
if value1 > 0 and Index <= Value2+10 and #돌파이후 10개봉 이내
C >= O and C > value1 and #양봉이고 종가가 돌파봉 종가보드 큼
sDate >= 20220301 and #2022년3월1일 이후
marketposition == 0 and countif(marketposition == 1,120) < 1 Then #최근 120봉은 무포지션
Buy("Buy1");
}
if C < (AvgEntryPrice*0.95) and countif(M > 100000000,3) >= 1 and C > DayOpen and Countif(crossup(RSIV,70),4) >= 1 and C > var6 Then
Condition12 = true;
Else
Condition12 = false;
if CountIF(Condition12[2],10)>=1 and C >= O and MarketPosition == 1 and CountIf(condition12[3],180) == 0 Then
Buy("Buy2",OnClose);
if MarketPosition == 1 Then
{
if CurrentContracts > CurrentContracts[1] Then
{
Xvol = CurrentContracts;
Condition1 = False;
Condition2 = False;
Condition3 = False;
Condition4 = False;
}
#분할매도
if Condition1 == False and c >= AvgEntryPrice*1.05 Then
{
Condition1 = true;
ExitLong("5Per",OnClose,DEf,"",Xvol*(1/4),1);
}
if Condition2 == False and c >= AvgEntryPrice*1.10 Then
{
Condition2 = true;
ExitLong("10Per",OnClose,DEf,"",Xvol*(1/4),1);
}
if Condition3 == False and c >= AvgEntryPrice*1.15 Then
{
Condition3 = true;
ExitLong("15Per",OnClose,DEf,"",Xvol*(1/4),1);
}
if C >= AvgEntryPrice*1.03 Then
Condition4 = true;
if Condition4 == False and crossdown(var1,Var3) Then
ExitLong("Exit");
}
Else
{
Condition1 = False;
Condition2 = False;
Condition3 = False;
Condition4 = False;
}
즐거운 하루되세요
> 마곡개미통 님이 쓴 글입니다.
> 제목 : 주식 시스템 문의 드립니다.
> 안녕하세요
아래 코드로 현재 1분봉으로 매매중인데요
원하는 코드가 잘 안만들어져서 수정 부탁드리고자 합니다.
1. #돌파매수 실행시
Condition11 만족하는 봉 발생시 그 봉의 종가를 CC로 리턴하고 다음봉이 음봉이면 매수대기하다가 첫 양봉 출현시 매수하고자 함
(지금 코드는 임시방편입니다.)
Ex) 조건발생 양봉 - 음봉 - 음봉 - 음봉 - 양봉 -매수
조건발생 양봉 - 양봉 - 매수
2. 마지막 분할매도 부분
수익율 3프로 이상발생한 후 var1 이평이 var3 이평을 crossdown하는 경우 전량 매도
(과거에 수익율이 3프로 이상 발생한 적이 한번이라도 있으면 현재 수익율이 얼마인지 관계없이 crossdown시 전량매도)
아래 코드로 적용해보았는데 작동되질 않습니다.
if countif(C >= AvgEntryPrice*1.03, 60) >= 1 and crossdown(var1,Var3) Then
ExitLong("Exit",OnClose,DEf,"",MaxContracts,1);
3. 분할매도시 주식수량 오차
종목당 일정 금액으로 매수를 하는데 분할매도하면 1~2주씩 남게 됩니다.
어찌해결하면 좋을지 부탁드려요
4. 전체적으로 코드 최적화
초심자이다 보니 코드가 체계적이고 효율적이지 못한것 같습니다.
효율적인 코드로 편집 부탁드릴께요
감사합니다.
--------------------------------------------------------------------------------
input : P1(5),P2(20),P3(60),P4(120),P5(240),P6(480);
Input : Period(12), Period1(6), Period2(10),Period3(12);
var : StoK(0),StoD(0),RSIV(0);
var : HH(0),LL(0),HV(0),HV1(0),HL(0),HL2(0),CC(0), CC1(0);
var1=ma(c,P1);
var2=ma(c,P2);
var3=ma(c,P3);
var4=ma(c,P4);
var5=ma(c,P5);
Var6=ma(c,P6);
StoK = StochasticsK(Period,Period1);
StoD = StochasticsD(Period,Period1,Period2);
RSIV = RSI(Period3);
HL = DayHigh/DayLow; #당일 고가-저가 차이
HH = Highest(H,120);
LL = Lowest(L,120);
HL2 = HH/LL; #2시간 내 고가 저가 차이
#돌파 신호 조건
If C >= O and C > Var5 and C > var6 and HL < 1.15 and HL2 < 1.1 and DayOpen < DayClose[1]*1.05 and countif(CrossDown(var5,Var6),240) == 0 and
countif(M > 100000000,3) >= 1 and DayVolume > (DayVolume[1]*0.3) and
Countif(crossup(RSIV,70),3) >= 1 Then
Condition11 = true;
Else
Condition11 = false;
if C < (AvgEntryPrice*0.95) and countif(M > 100000000,3) >= 1 and C > DayOpen and Countif(crossup(RSIV,70),4) >= 1 and C > var6 Then
Condition12 = true;
Else
Condition12 = false;
#돌파 매수 실행
if countif(Condition11[2],10)>= 1 and C >= O and sDate >= 20220301 and marketposition == 0 and countif(marketposition == 1,120) < 1 Then
Buy("Buy1",OnClose);
if CountIF(Condition12[2],10)>=1 and C >= O and MarketPosition == 1 and C >= O and CountIf(condition12[3],180) == 0 Then
Buy("Buy2",OnClose);
#분할매도
if c >= AvgEntryPrice*1.05 Then
ExitLong("5Per",OnClose,DEf,"",MaxContracts*(1/4),1);
if c >= AvgEntryPrice*1.10 Then
ExitLong("10Per",OnClose,DEf,"",MaxContracts*(1/4),1);
if c >= AvgEntryPrice*1.15 Then
ExitLong("15Per",OnClose,DEf,"",MaxContracts*(1/4),1);
if C >= AvgEntryPrice*1.03 and crossdown(var1,Var3) Then
ExitLong("Exit",OnClose,DEf,"",MaxContracts,1);