커뮤니티

수식 부탁드립니다.

프로필 이미지
바바큰
2024-05-14 13:54:20
741
글번호 179503
답변완료
수식 감사드립니다. 2가지 수식 부탁드립니다. 참고로 해외선물 입니다. 첫번째: 청산식 추가 (기 작성해주신 수식에서) 1. 만약 포시션이 있다면 월말 2일전에 청산 월말 2일전 청산이 안된다면 2. 만약 포지션이 있다면 지정한 날짜, 시간에 청산 3. 월물 마감일 하루전 지정시간 청산 (청산 이후에는 마지막주(월말)까지 진입이 없게 해주세요) 두번째: 월봉 --> 주봉 으로 변경부탁드립니다. 1. 매매는 10분 봉을 사용합니다. 2. 포지션이 없고, 주봉이 양봉이면 매수(2계약) 음봉이면 매도(2계약) (계약수는 조절이 가능하게 해주세요) 3. 10분봉에서 매수 포지션 일때 주봉이 양봉이면 매수 유지 10분봉에서 매도 포지션 일때 주봉이 음봉이면 매도 유지 청산 1. 주 마지막 날 1시간봉이 주봉과 반대 방향이면 10분봉에서 청산 2. 만약 포시션이 있다면 주간 마직막날 저정한 시간에 청산 3. 월물 마감일 하루전 지정시간 청산 (청산 이후에는 그주는 진입이 없게 해주세요) 지정된 1시간봉에서 청산 후 바로 동일방향 진입이 발생할 수 있으므로 진입식에 주 마지막 날 청산 후에는 진입이 안되게 부탁드립니다. > 예스스탁 님이 쓴 글입니다. > 제목 : Re : 수식 부탁드립니다. > 안녕하세요 예스스탁입니다. 1 10분봉에 적용하시면 됩니다. 2 10분봉에서 월봉이 양봉이면 매수, 음봉이면 매도이므로 지정하신 4시간봉에서 청산 후 바로 동일방향 진입이 발생할 수 있어 진입식에 월 마지막주에는 진입이 안되게 추가했습니다. 진입이 되게 하시려면 진입식에서 sDate < lastMonday 조건을 삭제하시면 됩니다. 3 input : vol(2); var : MO(0); Var : Year(0),Month(0),ndate1(0),ndate2(0),Monthlastday(0); var : cnt(0),lastMonday(0),NO(0),O4(0); if sDate != sDate[1] Then { Year = Floor(sDate / 10000)*10000; month = Floor(FracPortion(sdate/10000)*100)*100; ndate1 = year+month+1; if Month+100 <= 1200 Then ndate2 = year+(month+100)+1; Else ndate2 = (year+10000)+100+1; Monthlastday = DateToJulian(ndate2)-DateToJulian(ndate1); For cnt = 1 to Monthlastday { if DayOfWeek(year+month+cnt) == 1 Then lastMonday = year+month+cnt; } } if sdate > sDate[1]+30 Then { #월 시가 MO = Open; } if MO > 0 and sDate < lastMonday then { if MarketPosition <= 0 and C > MO Then Buy("b",OnClose,Def,vol); if MarketPosition >= 0 and C < MO Then Sell("s",OnClose,Def,vol); } input : 분(240); var : S1(0),D1(0),TM(0),TF(0); if NextBarBdate != Bdate Then { S1 = TimeToMinutes(nextbarstime); D1 = NextBarSdate; } if D1 > 0 then { if NextBarSdate == D1 Then TM = TimeToMinutes(NextBarStime)-S1; Else TM = TimeToMinutes(NextBarStime)+1440-S1; TF = TM%분; #240분봉 완성시 if Bdate != Bdate[1] or (Bdate == Bdate[1] and 분 > 1 and TF < TF[1]) or (Bdate == Bdate[1] and 분 > 1 and TM >= TM[1]+분) or (Bdate == Bdate[1] and 분 == 1 and TM > TM[1]) Then { NO = NextBarOpen; O4 = NO[1]; #매수포지션이고 240분봉은 음봉이면 청산 if MarketPosition == 1 and sDate >= lastMonday and C < O4 Then ExitLong(); #매도포지션이고 240분봉은 양봉이면 청산 if MarketPosition == -1 and sDate >= lastMonday and C > O4 Then ExitShort(); } } 즐거운 하루되세요 > 바바큰 님이 쓴 글입니다. > 제목 : 수식 부탁드립니다. > 항상 감사드립니다. 문의드립니다. 진입 & 포지션 체인지 1. 매매는 10분 봉을 사용합니다. 2. 포지션이 없고, 월봉이 양봉이면 매수(2계약) 음봉이면 매도(2계약) (계약수는 조절이 가능하게 해주세요) 3. 10분봉에서 매수 포지션 일때 월봉이 양봉이면 매수 유지 10분봉에서 매도 포지션 일때 월봉이 음봉이면 매도 유지 청산 1. 월 마지막 주 4시간봉이 월봉과 반대 방향이면 10분봉에서 청산 문의 1. 전략 차트를 10분봉과 4시간봉(보조), 월봉(보조) 3개의 차트로 세팅해야 하나요?
시스템
답변 3
프로필 이미지

예스스탁 예스스탁 답변

2024-05-14 13:52:39

안녕하세요 예스스탁입니다. 1 랭귀지에 휴일데이터가 없어 공휴일을 알수 없습니다. 단순히 토요일과 일요일만 제외하고 월말 2일전을 판단해 15시에 청산되게 작성해 드립니다. input : vol(2),Xtime(150000); var : MO(0),trade(False); Var : Year(0),Month(0),ndate1(0),ndate2(0),Monthlastday(0); var : cnt(0),lastMonday(0),NO(0),O4(0),count(0),Xdate(0); if sdate > sDate[1]+30 Then { #월 시가 MO = Open; trade = true; } if sDate != sDate[1] Then { Year = Floor(sDate / 10000)*10000; month = Floor(FracPortion(sdate/10000)*100)*100; ndate1 = year+month+1; if Month+100 <= 1200 Then ndate2 = year+(month+100)+1; Else ndate2 = (year+10000)+100+1; Monthlastday = DateToJulian(ndate2)-DateToJulian(ndate1); For cnt = 1 to Monthlastday { if DayOfWeek(year+month+cnt) == 1 Then lastMonday = year+month+cnt; } count = 0; For cnt = Monthlastday downto 1 { if DayOfWeek(year+month+cnt) > 0 and DayOfWeek(year+month+cnt) < 6 Then { count = count+1; if count == 3 Then xdate = year+month+cnt; } } } if MO > 0 and sDate < lastMonday and trade == true then { if MarketPosition <= 0 and C > MO Then Buy("b",OnClose,Def,vol); if MarketPosition >= 0 and C < MO Then Sell("s",OnClose,Def,vol); } input : 분(240); var : S1(0),D1(0),TM(0),TF(0); if NextBarBdate != Bdate Then { S1 = TimeToMinutes(nextbarstime); D1 = NextBarSdate; } if D1 > 0 then { if NextBarSdate == D1 Then TM = TimeToMinutes(NextBarStime)-S1; Else TM = TimeToMinutes(NextBarStime)+1440-S1; TF = TM%분; #240분봉 완성시 if Bdate != Bdate[1] or (Bdate == Bdate[1] and 분 > 1 and TF < TF[1]) or (Bdate == Bdate[1] and 분 > 1 and TM >= TM[1]+분) or (Bdate == Bdate[1] and 분 == 1 and TM > TM[1]) Then { NO = NextBarOpen; O4 = NO[1]; #매수포지션이고 240분봉은 음봉이면 청산 if MarketPosition == 1 and sDate >= lastMonday and C < O4 Then ExitLong(); #매도포지션이고 240분봉은 양봉이면 청산 if MarketPosition == -1 and sDate >= lastMonday and C > O4 Then ExitShort(); } } if sDate == Xdate Then { if (sdate != sdate[1] and stime >= xTime) or (sdate == sdate[1] and stime >= xTime and stime[1] < xTime) Then { trade = False; if MarketPosition == 1 Then ExitLong(); if MarketPosition == -1 Then ExitShort(); } } 2 1번과 같이 휴일데이터가 없어 주마지막날은 단지 금요일로만 지정해 드릴수 있습니다. 금요일 휴일인 경우 수식으로 그 전날에 청산하게는 작성이 불가능합니다. input : vol(2),Xtime(150000); var : MO(0),trade(False); Var : Year(0),Month(0),ndate1(0),ndate2(0),Monthlastday(0); var : cnt(0),lastMonday(0),NO(0),O4(0),count(0),Xdate(0); if dayofweek(sdate) < DayOfWeek(sDate[1]) Then { #주봉 시가 MO = Open; trade = true; } if MO > 0 and trade == true then { if MarketPosition <= 0 and C > MO Then Buy("b",OnClose,Def,vol); if MarketPosition >= 0 and C < MO Then Sell("s",OnClose,Def,vol); } input : 분(60); var : S1(0),D1(0),TM(0),TF(0); if NextBarBdate != Bdate Then { S1 = TimeToMinutes(nextbarstime); D1 = NextBarSdate; } if D1 > 0 then { if NextBarSdate == D1 Then TM = TimeToMinutes(NextBarStime)-S1; Else TM = TimeToMinutes(NextBarStime)+1440-S1; TF = TM%분; #240분봉 완성시 if Bdate != Bdate[1] or (Bdate == Bdate[1] and 분 > 1 and TF < TF[1]) or (Bdate == Bdate[1] and 분 > 1 and TM >= TM[1]+분) or (Bdate == Bdate[1] and 분 == 1 and TM > TM[1]) Then { NO = NextBarOpen; O4 = NO[1]; #매수포지션이고 240분봉은 음봉이면 청산 if MarketPosition == 1 and sDate >= lastMonday and C < O4 and DayOfWeek(sDate) == 5 Then ExitLong(); #매도포지션이고 240분봉은 양봉이면 청산 if MarketPosition == -1 and sDate >= lastMonday and C > O4 and DayOfWeek(sDate) == 5 Then ExitShort(); } } if DayOfWeek(sDate) == 5 Then { if (sdate != sdate[1] and stime >= xTime) or (sdate == sdate[1] and stime >= xTime and stime[1] < xTime) Then { trade = False; if MarketPosition == 1 Then ExitLong(); if MarketPosition == -1 Then ExitShort(); } } 즐거운 하루되세요 > 바바큰 님이 쓴 글입니다. > 제목 : 수식 부탁드립니다. > 수식 감사드립니다. 2가지 수식 부탁드립니다. 참고로 해외선물 입니다. 첫번째: 청산식 추가 (기 작성해주신 수식에서) 1. 만약 포시션이 있다면 월말 2일전에 청산 월말 2일전 청산이 안된다면 2. 만약 포지션이 있다면 지정한 날짜, 시간에 청산 (청산 이후에는 마지막주(월말)까지 진입이 없게 해주세요) 두번째: 월봉 --> 주봉 으로 변경부탁드립니다. 1. 매매는 10분 봉을 사용합니다. 2. 포지션이 없고, 주봉이 양봉이면 매수(2계약) 음봉이면 매도(2계약) (계약수는 조절이 가능하게 해주세요) 3. 10분봉에서 매수 포지션 일때 주봉이 양봉이면 매수 유지 10분봉에서 매도 포지션 일때 주봉이 음봉이면 매도 유지 청산 1. 주 마지막 날 1시간봉이 주봉과 반대 방향이면 10분봉에서 청산 2. 만약 포시션이 있다면 주간 마직막날 저정한 시간에 청산 지정된 1시간봉에서 청산 후 바로 동일방향 진입이 발생할 수 있으므로 진입식에 주 마지막 날 청산 후에는 진입이 안되게 부탁드립니다. > 예스스탁 님이 쓴 글입니다. > 제목 : Re : 수식 부탁드립니다. > 안녕하세요 예스스탁입니다. 1 10분봉에 적용하시면 됩니다. 2 10분봉에서 월봉이 양봉이면 매수, 음봉이면 매도이므로 지정하신 4시간봉에서 청산 후 바로 동일방향 진입이 발생할 수 있어 진입식에 월 마지막주에는 진입이 안되게 추가했습니다. 진입이 되게 하시려면 진입식에서 sDate < lastMonday 조건을 삭제하시면 됩니다. 3 input : vol(2); var : MO(0); Var : Year(0),Month(0),ndate1(0),ndate2(0),Monthlastday(0); var : cnt(0),lastMonday(0),NO(0),O4(0); if sDate != sDate[1] Then { Year = Floor(sDate / 10000)*10000; month = Floor(FracPortion(sdate/10000)*100)*100; ndate1 = year+month+1; if Month+100 <= 1200 Then ndate2 = year+(month+100)+1; Else ndate2 = (year+10000)+100+1; Monthlastday = DateToJulian(ndate2)-DateToJulian(ndate1); For cnt = 1 to Monthlastday { if DayOfWeek(year+month+cnt) == 1 Then lastMonday = year+month+cnt; } } if sdate > sDate[1]+30 Then { #월 시가 MO = Open; } if MO > 0 and sDate < lastMonday then { if MarketPosition <= 0 and C > MO Then Buy("b",OnClose,Def,vol); if MarketPosition >= 0 and C < MO Then Sell("s",OnClose,Def,vol); } input : 분(240); var : S1(0),D1(0),TM(0),TF(0); if NextBarBdate != Bdate Then { S1 = TimeToMinutes(nextbarstime); D1 = NextBarSdate; } if D1 > 0 then { if NextBarSdate == D1 Then TM = TimeToMinutes(NextBarStime)-S1; Else TM = TimeToMinutes(NextBarStime)+1440-S1; TF = TM%분; #240분봉 완성시 if Bdate != Bdate[1] or (Bdate == Bdate[1] and 분 > 1 and TF < TF[1]) or (Bdate == Bdate[1] and 분 > 1 and TM >= TM[1]+분) or (Bdate == Bdate[1] and 분 == 1 and TM > TM[1]) Then { NO = NextBarOpen; O4 = NO[1]; #매수포지션이고 240분봉은 음봉이면 청산 if MarketPosition == 1 and sDate >= lastMonday and C < O4 Then ExitLong(); #매도포지션이고 240분봉은 양봉이면 청산 if MarketPosition == -1 and sDate >= lastMonday and C > O4 Then ExitShort(); } } 즐거운 하루되세요 > 바바큰 님이 쓴 글입니다. > 제목 : 수식 부탁드립니다. > 항상 감사드립니다. 문의드립니다. 진입 & 포지션 체인지 1. 매매는 10분 봉을 사용합니다. 2. 포지션이 없고, 월봉이 양봉이면 매수(2계약) 음봉이면 매도(2계약) (계약수는 조절이 가능하게 해주세요) 3. 10분봉에서 매수 포지션 일때 월봉이 양봉이면 매수 유지 10분봉에서 매도 포지션 일때 월봉이 음봉이면 매도 유지 청산 1. 월 마지막 주 4시간봉이 월봉과 반대 방향이면 10분봉에서 청산 문의 1. 전략 차트를 10분봉과 4시간봉(보조), 월봉(보조) 3개의 차트로 세팅해야 하나요?
프로필 이미지

바바큰

2024-05-14 13:58:30

감사합니다. 해외선물에 해당 수식을 적용시 변경할 부분이 있는지 문의드립니다. > 예스스탁 님이 쓴 글입니다. > 제목 : Re : 수식 부탁드립니다. > 안녕하세요 예스스탁입니다. 1 랭귀지에 휴일데이터가 없어 공휴일을 알수 없습니다. 단순히 토요일과 일요일만 제외하고 월말 2일전을 판단해 15시에 청산되게 작성해 드립니다. input : vol(2),Xtime(150000); var : MO(0),trade(False); Var : Year(0),Month(0),ndate1(0),ndate2(0),Monthlastday(0); var : cnt(0),lastMonday(0),NO(0),O4(0),count(0),Xdate(0); if sdate > sDate[1]+30 Then { #월 시가 MO = Open; trade = true; } if sDate != sDate[1] Then { Year = Floor(sDate / 10000)*10000; month = Floor(FracPortion(sdate/10000)*100)*100; ndate1 = year+month+1; if Month+100 <= 1200 Then ndate2 = year+(month+100)+1; Else ndate2 = (year+10000)+100+1; Monthlastday = DateToJulian(ndate2)-DateToJulian(ndate1); For cnt = 1 to Monthlastday { if DayOfWeek(year+month+cnt) == 1 Then lastMonday = year+month+cnt; } count = 0; For cnt = Monthlastday downto 1 { if DayOfWeek(year+month+cnt) > 0 and DayOfWeek(year+month+cnt) < 6 Then { count = count+1; if count == 3 Then xdate = year+month+cnt; } } } if MO > 0 and sDate < lastMonday and trade == true then { if MarketPosition <= 0 and C > MO Then Buy("b",OnClose,Def,vol); if MarketPosition >= 0 and C < MO Then Sell("s",OnClose,Def,vol); } input : 분(240); var : S1(0),D1(0),TM(0),TF(0); if NextBarBdate != Bdate Then { S1 = TimeToMinutes(nextbarstime); D1 = NextBarSdate; } if D1 > 0 then { if NextBarSdate == D1 Then TM = TimeToMinutes(NextBarStime)-S1; Else TM = TimeToMinutes(NextBarStime)+1440-S1; TF = TM%분; #240분봉 완성시 if Bdate != Bdate[1] or (Bdate == Bdate[1] and 분 > 1 and TF < TF[1]) or (Bdate == Bdate[1] and 분 > 1 and TM >= TM[1]+분) or (Bdate == Bdate[1] and 분 == 1 and TM > TM[1]) Then { NO = NextBarOpen; O4 = NO[1]; #매수포지션이고 240분봉은 음봉이면 청산 if MarketPosition == 1 and sDate >= lastMonday and C < O4 Then ExitLong(); #매도포지션이고 240분봉은 양봉이면 청산 if MarketPosition == -1 and sDate >= lastMonday and C > O4 Then ExitShort(); } } if sDate == Xdate Then { if (sdate != sdate[1] and stime >= xTime) or (sdate == sdate[1] and stime >= xTime and stime[1] < xTime) Then { trade = False; if MarketPosition == 1 Then ExitLong(); if MarketPosition == -1 Then ExitShort(); } } 2 1번과 같이 휴일데이터가 없어 주마지막날은 단지 금요일로만 지정해 드릴수 있습니다. 금요일 휴일인 경우 수식으로 그 전날에 청산하게는 작성이 불가능합니다. input : vol(2),Xtime(150000); var : MO(0),trade(False); Var : Year(0),Month(0),ndate1(0),ndate2(0),Monthlastday(0); var : cnt(0),lastMonday(0),NO(0),O4(0),count(0),Xdate(0); if dayofweek(sdate) < DayOfWeek(sDate[1]) Then { #주봉 시가 MO = Open; trade = true; } if MO > 0 and trade == true then { if MarketPosition <= 0 and C > MO Then Buy("b",OnClose,Def,vol); if MarketPosition >= 0 and C < MO Then Sell("s",OnClose,Def,vol); } input : 분(60); var : S1(0),D1(0),TM(0),TF(0); if NextBarBdate != Bdate Then { S1 = TimeToMinutes(nextbarstime); D1 = NextBarSdate; } if D1 > 0 then { if NextBarSdate == D1 Then TM = TimeToMinutes(NextBarStime)-S1; Else TM = TimeToMinutes(NextBarStime)+1440-S1; TF = TM%분; #240분봉 완성시 if Bdate != Bdate[1] or (Bdate == Bdate[1] and 분 > 1 and TF < TF[1]) or (Bdate == Bdate[1] and 분 > 1 and TM >= TM[1]+분) or (Bdate == Bdate[1] and 분 == 1 and TM > TM[1]) Then { NO = NextBarOpen; O4 = NO[1]; #매수포지션이고 240분봉은 음봉이면 청산 if MarketPosition == 1 and sDate >= lastMonday and C < O4 and DayOfWeek(sDate) == 5 Then ExitLong(); #매도포지션이고 240분봉은 양봉이면 청산 if MarketPosition == -1 and sDate >= lastMonday and C > O4 and DayOfWeek(sDate) == 5 Then ExitShort(); } } if DayOfWeek(sDate) == 5 Then { if (sdate != sdate[1] and stime >= xTime) or (sdate == sdate[1] and stime >= xTime and stime[1] < xTime) Then { trade = False; if MarketPosition == 1 Then ExitLong(); if MarketPosition == -1 Then ExitShort(); } } 즐거운 하루되세요 > 바바큰 님이 쓴 글입니다. > 제목 : 수식 부탁드립니다. > 수식 감사드립니다. 2가지 수식 부탁드립니다. 참고로 해외선물 입니다. 첫번째: 청산식 추가 (기 작성해주신 수식에서) 1. 만약 포시션이 있다면 월말 2일전에 청산 월말 2일전 청산이 안된다면 2. 만약 포지션이 있다면 지정한 날짜, 시간에 청산 (청산 이후에는 마지막주(월말)까지 진입이 없게 해주세요) 두번째: 월봉 --> 주봉 으로 변경부탁드립니다. 1. 매매는 10분 봉을 사용합니다. 2. 포지션이 없고, 주봉이 양봉이면 매수(2계약) 음봉이면 매도(2계약) (계약수는 조절이 가능하게 해주세요) 3. 10분봉에서 매수 포지션 일때 주봉이 양봉이면 매수 유지 10분봉에서 매도 포지션 일때 주봉이 음봉이면 매도 유지 청산 1. 주 마지막 날 1시간봉이 주봉과 반대 방향이면 10분봉에서 청산 2. 만약 포시션이 있다면 주간 마직막날 저정한 시간에 청산 지정된 1시간봉에서 청산 후 바로 동일방향 진입이 발생할 수 있으므로 진입식에 주 마지막 날 청산 후에는 진입이 안되게 부탁드립니다. > 예스스탁 님이 쓴 글입니다. > 제목 : Re : 수식 부탁드립니다. > 안녕하세요 예스스탁입니다. 1 10분봉에 적용하시면 됩니다. 2 10분봉에서 월봉이 양봉이면 매수, 음봉이면 매도이므로 지정하신 4시간봉에서 청산 후 바로 동일방향 진입이 발생할 수 있어 진입식에 월 마지막주에는 진입이 안되게 추가했습니다. 진입이 되게 하시려면 진입식에서 sDate < lastMonday 조건을 삭제하시면 됩니다. 3 input : vol(2); var : MO(0); Var : Year(0),Month(0),ndate1(0),ndate2(0),Monthlastday(0); var : cnt(0),lastMonday(0),NO(0),O4(0); if sDate != sDate[1] Then { Year = Floor(sDate / 10000)*10000; month = Floor(FracPortion(sdate/10000)*100)*100; ndate1 = year+month+1; if Month+100 <= 1200 Then ndate2 = year+(month+100)+1; Else ndate2 = (year+10000)+100+1; Monthlastday = DateToJulian(ndate2)-DateToJulian(ndate1); For cnt = 1 to Monthlastday { if DayOfWeek(year+month+cnt) == 1 Then lastMonday = year+month+cnt; } } if sdate > sDate[1]+30 Then { #월 시가 MO = Open; } if MO > 0 and sDate < lastMonday then { if MarketPosition <= 0 and C > MO Then Buy("b",OnClose,Def,vol); if MarketPosition >= 0 and C < MO Then Sell("s",OnClose,Def,vol); } input : 분(240); var : S1(0),D1(0),TM(0),TF(0); if NextBarBdate != Bdate Then { S1 = TimeToMinutes(nextbarstime); D1 = NextBarSdate; } if D1 > 0 then { if NextBarSdate == D1 Then TM = TimeToMinutes(NextBarStime)-S1; Else TM = TimeToMinutes(NextBarStime)+1440-S1; TF = TM%분; #240분봉 완성시 if Bdate != Bdate[1] or (Bdate == Bdate[1] and 분 > 1 and TF < TF[1]) or (Bdate == Bdate[1] and 분 > 1 and TM >= TM[1]+분) or (Bdate == Bdate[1] and 분 == 1 and TM > TM[1]) Then { NO = NextBarOpen; O4 = NO[1]; #매수포지션이고 240분봉은 음봉이면 청산 if MarketPosition == 1 and sDate >= lastMonday and C < O4 Then ExitLong(); #매도포지션이고 240분봉은 양봉이면 청산 if MarketPosition == -1 and sDate >= lastMonday and C > O4 Then ExitShort(); } } 즐거운 하루되세요 > 바바큰 님이 쓴 글입니다. > 제목 : 수식 부탁드립니다. > 항상 감사드립니다. 문의드립니다. 진입 & 포지션 체인지 1. 매매는 10분 봉을 사용합니다. 2. 포지션이 없고, 월봉이 양봉이면 매수(2계약) 음봉이면 매도(2계약) (계약수는 조절이 가능하게 해주세요) 3. 10분봉에서 매수 포지션 일때 월봉이 양봉이면 매수 유지 10분봉에서 매도 포지션 일때 월봉이 음봉이면 매도 유지 청산 1. 월 마지막 주 4시간봉이 월봉과 반대 방향이면 10분봉에서 청산 문의 1. 전략 차트를 10분봉과 4시간봉(보조), 월봉(보조) 3개의 차트로 세팅해야 하나요?
프로필 이미지

예스스탁 예스스탁 답변

2024-05-14 16:15:06

안녕하세요 예스스탁입니다. 해외선물이시면 일부 날짜지정을 변경하셔야 합니다. 1 input : vol(2),Xtime(150000); var : MO(0),trade(False); Var : Year(0),Month(0),ndate1(0),ndate2(0),Monthlastday(0); var : cnt(0),lastMonday(0),NO(0),O4(0),count(0),Xdate(0); if bdate > bDate[1]+30 Then { #월 시가 MO = Open; trade = true; } if bDate != bDate[1] Then { Year = Floor(bDate / 10000)*10000; month = Floor(FracPortion(bdate/10000)*100)*100; ndate1 = year+month+1; if Month+100 <= 1200 Then ndate2 = year+(month+100)+1; Else ndate2 = (year+10000)+100+1; Monthlastday = DateToJulian(ndate2)-DateToJulian(ndate1); For cnt = 1 to Monthlastday { if DayOfWeek(year+month+cnt) == 1 Then lastMonday = year+month+cnt; } count = 0; For cnt = Monthlastday downto 1 { if DayOfWeek(year+month+cnt) > 0 and DayOfWeek(year+month+cnt) < 6 Then { count = count+1; if count == 3 Then xdate = year+month+cnt; } } } if MO > 0 and bDate < lastMonday and trade == true then { if MarketPosition <= 0 and C > MO Then Buy("b",OnClose,Def,vol); if MarketPosition >= 0 and C < MO Then Sell("s",OnClose,Def,vol); } input : 분(240); var : S1(0),D1(0),TM(0),TF(0); if NextBarBdate != Bdate Then { S1 = TimeToMinutes(nextbarstime); D1 = NextBarSdate; } if D1 > 0 then { if NextBarSdate == D1 Then TM = TimeToMinutes(NextBarStime)-S1; Else TM = TimeToMinutes(NextBarStime)+1440-S1; TF = TM%분; #240분봉 완성시 if Bdate != Bdate[1] or (Bdate == Bdate[1] and 분 > 1 and TF < TF[1]) or (Bdate == Bdate[1] and 분 > 1 and TM >= TM[1]+분) or (Bdate == Bdate[1] and 분 == 1 and TM > TM[1]) Then { NO = NextBarOpen; O4 = NO[1]; #매수포지션이고 240분봉은 음봉이면 청산 if MarketPosition == 1 and sDate >= lastMonday and C < O4 Then ExitLong(); #매도포지션이고 240분봉은 양봉이면 청산 if MarketPosition == -1 and sDate >= lastMonday and C > O4 Then ExitShort(); } } if sDate == Xdate Then { if (sdate != sdate[1] and stime >= xTime) or (sdate == sdate[1] and stime >= xTime and stime[1] < xTime) Then { trade = False; if MarketPosition == 1 Then ExitLong(); if MarketPosition == -1 Then ExitShort(); } } 2 input : vol(2),Xtime(150000); var : MO(0),trade(False); Var : Year(0),Month(0),ndate1(0),ndate2(0),Monthlastday(0); var : cnt(0),lastMonday(0),NO(0),O4(0),count(0),Xdate(0); if dayofweek(bdate) < DayOfWeek(bDate[1]) Then { #주봉 시가 MO = Open; trade = true; } if MO > 0 and trade == true then { if MarketPosition <= 0 and C > MO Then Buy("b",OnClose,Def,vol); if MarketPosition >= 0 and C < MO Then Sell("s",OnClose,Def,vol); } input : 분(60); var : S1(0),D1(0),TM(0),TF(0); if NextBarBdate != Bdate Then { S1 = TimeToMinutes(nextbarstime); D1 = NextBarSdate; } if D1 > 0 then { if NextBarSdate == D1 Then TM = TimeToMinutes(NextBarStime)-S1; Else TM = TimeToMinutes(NextBarStime)+1440-S1; TF = TM%분; #240분봉 완성시 if Bdate != Bdate[1] or (Bdate == Bdate[1] and 분 > 1 and TF < TF[1]) or (Bdate == Bdate[1] and 분 > 1 and TM >= TM[1]+분) or (Bdate == Bdate[1] and 분 == 1 and TM > TM[1]) Then { NO = NextBarOpen; O4 = NO[1]; #매수포지션이고 240분봉은 음봉이면 청산 if MarketPosition == 1 and sDate >= lastMonday and C < O4 and DayOfWeek(sDate) == 5 Then ExitLong(); #매도포지션이고 240분봉은 양봉이면 청산 if MarketPosition == -1 and sDate >= lastMonday and C > O4 and DayOfWeek(sDate) == 5 Then ExitShort(); } } if DayOfWeek(bDate) == 5 Then { if (sdate != sdate[1] and stime >= xTime) or (sdate == sdate[1] and stime >= xTime and stime[1] < xTime) Then { trade = False; if MarketPosition == 1 Then ExitLong(); if MarketPosition == -1 Then ExitShort(); } } 즐거운 하루되세요 > 바바큰 님이 쓴 글입니다. > 제목 : Re : Re : 수식 부탁드립니다. > 감사합니다. 해외선물에 해당 수식을 적용시 변경할 부분이 있는지 문의드립니다. > 예스스탁 님이 쓴 글입니다. > 제목 : Re : 수식 부탁드립니다. > 안녕하세요 예스스탁입니다. 1 랭귀지에 휴일데이터가 없어 공휴일을 알수 없습니다. 단순히 토요일과 일요일만 제외하고 월말 2일전을 판단해 15시에 청산되게 작성해 드립니다. input : vol(2),Xtime(150000); var : MO(0),trade(False); Var : Year(0),Month(0),ndate1(0),ndate2(0),Monthlastday(0); var : cnt(0),lastMonday(0),NO(0),O4(0),count(0),Xdate(0); if sdate > sDate[1]+30 Then { #월 시가 MO = Open; trade = true; } if sDate != sDate[1] Then { Year = Floor(sDate / 10000)*10000; month = Floor(FracPortion(sdate/10000)*100)*100; ndate1 = year+month+1; if Month+100 <= 1200 Then ndate2 = year+(month+100)+1; Else ndate2 = (year+10000)+100+1; Monthlastday = DateToJulian(ndate2)-DateToJulian(ndate1); For cnt = 1 to Monthlastday { if DayOfWeek(year+month+cnt) == 1 Then lastMonday = year+month+cnt; } count = 0; For cnt = Monthlastday downto 1 { if DayOfWeek(year+month+cnt) > 0 and DayOfWeek(year+month+cnt) < 6 Then { count = count+1; if count == 3 Then xdate = year+month+cnt; } } } if MO > 0 and sDate < lastMonday and trade == true then { if MarketPosition <= 0 and C > MO Then Buy("b",OnClose,Def,vol); if MarketPosition >= 0 and C < MO Then Sell("s",OnClose,Def,vol); } input : 분(240); var : S1(0),D1(0),TM(0),TF(0); if NextBarBdate != Bdate Then { S1 = TimeToMinutes(nextbarstime); D1 = NextBarSdate; } if D1 > 0 then { if NextBarSdate == D1 Then TM = TimeToMinutes(NextBarStime)-S1; Else TM = TimeToMinutes(NextBarStime)+1440-S1; TF = TM%분; #240분봉 완성시 if Bdate != Bdate[1] or (Bdate == Bdate[1] and 분 > 1 and TF < TF[1]) or (Bdate == Bdate[1] and 분 > 1 and TM >= TM[1]+분) or (Bdate == Bdate[1] and 분 == 1 and TM > TM[1]) Then { NO = NextBarOpen; O4 = NO[1]; #매수포지션이고 240분봉은 음봉이면 청산 if MarketPosition == 1 and sDate >= lastMonday and C < O4 Then ExitLong(); #매도포지션이고 240분봉은 양봉이면 청산 if MarketPosition == -1 and sDate >= lastMonday and C > O4 Then ExitShort(); } } if sDate == Xdate Then { if (sdate != sdate[1] and stime >= xTime) or (sdate == sdate[1] and stime >= xTime and stime[1] < xTime) Then { trade = False; if MarketPosition == 1 Then ExitLong(); if MarketPosition == -1 Then ExitShort(); } } 2 1번과 같이 휴일데이터가 없어 주마지막날은 단지 금요일로만 지정해 드릴수 있습니다. 금요일 휴일인 경우 수식으로 그 전날에 청산하게는 작성이 불가능합니다. input : vol(2),Xtime(150000); var : MO(0),trade(False); Var : Year(0),Month(0),ndate1(0),ndate2(0),Monthlastday(0); var : cnt(0),lastMonday(0),NO(0),O4(0),count(0),Xdate(0); if dayofweek(sdate) < DayOfWeek(sDate[1]) Then { #주봉 시가 MO = Open; trade = true; } if MO > 0 and trade == true then { if MarketPosition <= 0 and C > MO Then Buy("b",OnClose,Def,vol); if MarketPosition >= 0 and C < MO Then Sell("s",OnClose,Def,vol); } input : 분(60); var : S1(0),D1(0),TM(0),TF(0); if NextBarBdate != Bdate Then { S1 = TimeToMinutes(nextbarstime); D1 = NextBarSdate; } if D1 > 0 then { if NextBarSdate == D1 Then TM = TimeToMinutes(NextBarStime)-S1; Else TM = TimeToMinutes(NextBarStime)+1440-S1; TF = TM%분; #240분봉 완성시 if Bdate != Bdate[1] or (Bdate == Bdate[1] and 분 > 1 and TF < TF[1]) or (Bdate == Bdate[1] and 분 > 1 and TM >= TM[1]+분) or (Bdate == Bdate[1] and 분 == 1 and TM > TM[1]) Then { NO = NextBarOpen; O4 = NO[1]; #매수포지션이고 240분봉은 음봉이면 청산 if MarketPosition == 1 and sDate >= lastMonday and C < O4 and DayOfWeek(sDate) == 5 Then ExitLong(); #매도포지션이고 240분봉은 양봉이면 청산 if MarketPosition == -1 and sDate >= lastMonday and C > O4 and DayOfWeek(sDate) == 5 Then ExitShort(); } } if DayOfWeek(sDate) == 5 Then { if (sdate != sdate[1] and stime >= xTime) or (sdate == sdate[1] and stime >= xTime and stime[1] < xTime) Then { trade = False; if MarketPosition == 1 Then ExitLong(); if MarketPosition == -1 Then ExitShort(); } } 즐거운 하루되세요 > 바바큰 님이 쓴 글입니다. > 제목 : 수식 부탁드립니다. > 수식 감사드립니다. 2가지 수식 부탁드립니다. 참고로 해외선물 입니다. 첫번째: 청산식 추가 (기 작성해주신 수식에서) 1. 만약 포시션이 있다면 월말 2일전에 청산 월말 2일전 청산이 안된다면 2. 만약 포지션이 있다면 지정한 날짜, 시간에 청산 (청산 이후에는 마지막주(월말)까지 진입이 없게 해주세요) 두번째: 월봉 --> 주봉 으로 변경부탁드립니다. 1. 매매는 10분 봉을 사용합니다. 2. 포지션이 없고, 주봉이 양봉이면 매수(2계약) 음봉이면 매도(2계약) (계약수는 조절이 가능하게 해주세요) 3. 10분봉에서 매수 포지션 일때 주봉이 양봉이면 매수 유지 10분봉에서 매도 포지션 일때 주봉이 음봉이면 매도 유지 청산 1. 주 마지막 날 1시간봉이 주봉과 반대 방향이면 10분봉에서 청산 2. 만약 포시션이 있다면 주간 마직막날 저정한 시간에 청산 지정된 1시간봉에서 청산 후 바로 동일방향 진입이 발생할 수 있으므로 진입식에 주 마지막 날 청산 후에는 진입이 안되게 부탁드립니다. > 예스스탁 님이 쓴 글입니다. > 제목 : Re : 수식 부탁드립니다. > 안녕하세요 예스스탁입니다. 1 10분봉에 적용하시면 됩니다. 2 10분봉에서 월봉이 양봉이면 매수, 음봉이면 매도이므로 지정하신 4시간봉에서 청산 후 바로 동일방향 진입이 발생할 수 있어 진입식에 월 마지막주에는 진입이 안되게 추가했습니다. 진입이 되게 하시려면 진입식에서 sDate < lastMonday 조건을 삭제하시면 됩니다. 3 input : vol(2); var : MO(0); Var : Year(0),Month(0),ndate1(0),ndate2(0),Monthlastday(0); var : cnt(0),lastMonday(0),NO(0),O4(0); if sDate != sDate[1] Then { Year = Floor(sDate / 10000)*10000; month = Floor(FracPortion(sdate/10000)*100)*100; ndate1 = year+month+1; if Month+100 <= 1200 Then ndate2 = year+(month+100)+1; Else ndate2 = (year+10000)+100+1; Monthlastday = DateToJulian(ndate2)-DateToJulian(ndate1); For cnt = 1 to Monthlastday { if DayOfWeek(year+month+cnt) == 1 Then lastMonday = year+month+cnt; } } if sdate > sDate[1]+30 Then { #월 시가 MO = Open; } if MO > 0 and sDate < lastMonday then { if MarketPosition <= 0 and C > MO Then Buy("b",OnClose,Def,vol); if MarketPosition >= 0 and C < MO Then Sell("s",OnClose,Def,vol); } input : 분(240); var : S1(0),D1(0),TM(0),TF(0); if NextBarBdate != Bdate Then { S1 = TimeToMinutes(nextbarstime); D1 = NextBarSdate; } if D1 > 0 then { if NextBarSdate == D1 Then TM = TimeToMinutes(NextBarStime)-S1; Else TM = TimeToMinutes(NextBarStime)+1440-S1; TF = TM%분; #240분봉 완성시 if Bdate != Bdate[1] or (Bdate == Bdate[1] and 분 > 1 and TF < TF[1]) or (Bdate == Bdate[1] and 분 > 1 and TM >= TM[1]+분) or (Bdate == Bdate[1] and 분 == 1 and TM > TM[1]) Then { NO = NextBarOpen; O4 = NO[1]; #매수포지션이고 240분봉은 음봉이면 청산 if MarketPosition == 1 and sDate >= lastMonday and C < O4 Then ExitLong(); #매도포지션이고 240분봉은 양봉이면 청산 if MarketPosition == -1 and sDate >= lastMonday and C > O4 Then ExitShort(); } } 즐거운 하루되세요 > 바바큰 님이 쓴 글입니다. > 제목 : 수식 부탁드립니다. > 항상 감사드립니다. 문의드립니다. 진입 & 포지션 체인지 1. 매매는 10분 봉을 사용합니다. 2. 포지션이 없고, 월봉이 양봉이면 매수(2계약) 음봉이면 매도(2계약) (계약수는 조절이 가능하게 해주세요) 3. 10분봉에서 매수 포지션 일때 월봉이 양봉이면 매수 유지 10분봉에서 매도 포지션 일때 월봉이 음봉이면 매도 유지 청산 1. 월 마지막 주 4시간봉이 월봉과 반대 방향이면 10분봉에서 청산 문의 1. 전략 차트를 10분봉과 4시간봉(보조), 월봉(보조) 3개의 차트로 세팅해야 하나요?