커뮤니티
질문드립니다
2019-03-26 11:04:47
362
글번호 127388
1.
현재예스스팟 분봉 확장차트에서 매매신호를 주고 매매하고 있습니다.
장초부터 시작해서 주가가 일봉주기 5일 이동 평균선에 5% 이내로 근접했을때 매수하고 트레일링 스탑으로 매매되는 매매 수식 부탁드립니다. 진입회수는 1회이며 작성한 수식에서 가감해야 할 부분에 대하여 알려주시면 감사하겠습니다.
input : 매수금액(500000);
input : Per(5),수익률(3),근접률(5);
var : Evol(0),Xcnt(0),OpenCond(false),Xcond1(false),Xcond2(false),Xcond3(false);
Var1 = ma(DayClose,5);
input : 진입회수(1);
if stime == 153000 and c<Var1*(1+근접률/100) Then
{
buy("b",AtMarket,def,Floor(매수금액/C));
}
//SetStopTrailing(2,10,PercentStop,1); //최소 10% 수익 이후에 최고 가격대비 2% 하락하면 청산
if MarketPosition == 1 Then
{
SetStopLoss(3);
#봉완성시 다음봉 시가가 진입가 대비 5% 이상 상승하면 true
if NextBarOpen >= EntryPrice*(1+Per/100) Then
OpenCond = true;
#BP1 청산이 발생하면 Xcond1은 true
if LatestExitName(0) == "BP1" Then
Xcond1 = true;
#BP2 청산이 발생하면 Xcond2은 true
if LatestExitName(0) == "BP2" Then
Xcond2 = true;
#BP3 청산이 발생하면 Xcond3은 true
if LatestExitName(0) == "BP3" Then
Xcond3 = True;
#OpenCond가 false일때
if OpenCond == false Then
{
SetStopTrailing(2,3,PercentStop,1); //최소 10% 수익 이후에 최고 가격대비 2% 하락하면 청산
/*if Xcond1 == false then
ExitLong("BP1",atlimit,EntryPrice(0)*1.03,"",Floor(MaxContracts*0.3),1);
if Xcond2 == false then
ExitLong("BP2",atlimit,EntryPrice(0)*1.04,"",Floor(MaxContracts*0.4),1);
if Xcond3 == false then
ExitLong("BP3",atlimit,EntryPrice(0)*1.05);*/
}
#OpenCond가 true일떄
if OpenCond == true Then
{
SetStopTrailing(3.5,5,PercentStop,1);
/* #BP1로 청산이 안된 경우만 발생
if Xcond1 == false Then
ExitLong("BP6",atlimit,EntryPrice*(1+(Per+3)/100),"",Floor(MaxContracts*0.3),1);
#BP2로 청산이 안된 경우만 발생
if Xcond2 == false Then
ExitLong("BP7",atlimit,EntryPrice*(1+(Per+4)/100),"",Floor(MaxContracts*0.4),1);
#BP3로 청산이 안된 경우만 발생
if Xcond3 == false Then
ExitLong("BP8",atlimit,EntryPrice*(1+(Per+5)/100));
#5%이하로 가격하락하면 전량처산 */
//exitlong("BP5",AtStop,EntryPrice*(1+Per/100));
}
SetStopEndofday(151000);
}
#매수포지션이 아니면 모두 false로 초기화
if MarketPosition != 1 Then{
OpenCond = false;
Xcond1 = false;
Xcond2 = false;
Xcond3 = false;
SetStopLoss(0);//해제
SetStopEndofday(0);//해제
SetStopTrailing(0,0);//해제
}
2.
그리고 트레일링 스탑을 분할하여 적용가능한 방법이 있나요?
예를 들어 100주를 매수 했을 경우 20 30 50 주 각각 다르게 적용하여 매도 가능한지
3.
종목검색식 부탁드립니다.
2일봉전 종가 대비 1봉전 고가등락률이 10% 이상
2일봉전 기준 60봉 이내에서 시가대비 고가 10% 미만
1일전 및 2일전 상한가가 아닐것
1일봉전 시가대비 1일봉전 종가 등락률이 5%이상
2일봉전부터 60일봉 기간내 평균거래량보다 1봉전 거래량이 500%이상
3일봉전 종가대비 2일봉전 종가 등락률이 5%이하
아래에 제가 작성한 검색식인데
2일봉전 기준 60봉 이내에서 시가대비 고가 10% 미만
2일봉전부터 60일봉 기간내 평균거래량보다 1봉전 거래량이 500%이상
이 두가지 조건 수식부탁드리며 제가 작성한 것도 맞는지 검토 부탁드립니다.
감사합니다.
var : 상한가(0), UpLimit(0), 전일상한가(0);
var : up1(0), up2(0), up3(0), up4(0), up5(0),up6(0),Up7(0);
if date >= 19981207 then {
if date < 20050328 && CodeCategory() == 2 then
UpLimit = (BP[0] * 1.12);
Else if date >= 20050328 and date < 20150615 Then
UpLimit = (BP[0] * 1.15);
Else
UpLimit = (BP[0] * 1.30);
if CodeCategory() == 2 then {
if date >= 20030721 then {
up1 = int(UpLimit/100+0.00001)*100;
up2 = int(UpLimit/100+0.00001)*100;
up3 = int(UpLimit/100+0.00001)*100;
up4 = int(UpLimit/50+0.00001)*50;
up5 = int(UpLimit/10+0.00001)*10;
up6 = int(UpLimit/5+0.00001)*5;
up7 = int(UpLimit/1+0.00001)*1;
}
else {
up1 = int(UpLimit/1000+0.00001)*1000;
up2 = int(UpLimit/500+0.00001)*500;
up3 = int(UpLimit/100+0.00001)*100;
up4 = int(UpLimit/50+0.00001)*50;
up5 = int(UpLimit/10+0.00001)*10;
up6 = int(UpLimit/10+0.00001)*10;
up7 = int(UpLimit/1+0.00001)*1;
}
}
Else {
up1 = int(UpLimit/1000+0.00001)*1000;
up2 = int(UpLimit/500+0.00001)*500;
up3 = int(UpLimit/100+0.00001)*100;
up4 = int(UpLimit/50+0.00001)*50;
up5 = int(UpLimit/10+0.00001)*10;
up6 = int(UpLimit/5+0.00001)*5;
up7 = int(UpLimit/1+0.00001)*1;
}
if CodeCategory() == 1 || CodeCategory() == 2 then {
if sdate < 20101004 Then{
If BP >= 500000 Then
상한가 = up1;
Else If BP >= 100000 Then
상한가 = iff(up2>=500000, up1, up2);
Else If BP >= 50000 Then
상한가 = iff(up3>=100000, up2, up3);
Else If BP >= 10000 Then
상한가 = iff(up4>=50000, up3, up4);
Else If BP >= 5000 Then
상한가 = iff(up5>=10000, up4, up5);
Else If BP >= 1000 Then
상한가 = iff(up5>=5000, up5, up6);
Else
상한가 = iff(up6>=1000, up6, up6);
}
Else{
If BP >= 500000 Then
상한가 = up1;
Else If BP >= 100000 Then
상한가 = iff(up2>=500000, up1, up2);
Else If BP >= 50000 Then
상한가 = iff(up3>=100000, up2, up3);
Else If BP >= 10000 Then
상한가 = iff(up4>=50000, up3, up4);
Else If BP >= 5000 Then
상한가 = iff(up5>=10000, up4, up5);
Else If BP >= 1000 Then
상한가 = iff(up5>=5000, up5, up6);
Else
상한가 = iff(up6>=1000, up6, up7);
}
}
else if CodeCategory() == 8 || CodeCategory() == 9 then { // ETF
상한가 = up6;
}
}
if C < 상한가 and C[1] < 상한가[1] //1일전 및 2일전 상한가가 아닐것
and C[1] > O[1]*1.05 //1일봉전 시가대비 1일봉전 종가 등락률이 5%이상
and C[2] < C[3]*1.05 //3일봉전 종가대비 2일봉전 종가 등락률이 5%이하
and H[1] > C[2]*1.10 //2일봉전 종가 대비 1봉전 고가등락률이 10% 이상
Then
find(1);
//2일봉전 기준 60봉 이내에서 시가대비 고가 10% 미만
//2일봉전부터 60일봉 기간내 평균거래량보다 1봉전 거래량이 500%이상
답변 1
예스스탁 예스스탁 답변
2019-03-26 11:22:37
안녕하세요
예스스탁입니다.
1
input : 매수금액(500000),P(5);
input : Per(5);
var : OpenCond(false),sum(0),cnt(0);
input : 진입회수(1);
#일간이평계산
sum = 0;
for cnt = 0 to P-1
{
sum = sum + DayClose(cnt);
}
var1 = sum/P;
if stime == 153000 and c < Var1*1.05 Then
{
buy("b",AtMarket,def,Floor(매수금액/C));
}
if MarketPosition == 1 Then
{
if NextBarOpen >= EntryPrice*(1+Per/100) Then
OpenCond = true;
if OpenCond == false Then
{
SetStopTrailing(2,3,PercentStop,1);
}
if OpenCond == true Then
{
SetStopTrailing(3.5,5,PercentStop,1);
}
}
#매수포지션이 아니면 초기화
if MarketPosition != 1 Then
{
OpenCond = false;
SetStopTrailing(0,0);
}
SetStopLoss(3);
SetStopEndofday(151000);
2
분할로 청산하기 위해서는 강제청산 함수를 이용할수 없습니다.
풀어서 작성해야 하는데 5%이상과 이하로 트레일링스탑이 구분되어 있고
어떤 방식으로 수익감소폭을 지정해야 할지 모르겠습니다.
아래 내용을 참고하셔서 수정보완해 완성하시기 바랍니다.
OpenCond가 false일떄는
3%이상 수익후에 최고가격에서 1%,2%,3% 수익감소일때 20%,30% 50% 청산
OpenCond가 true일떄는
5%이상 수익후에 최고가격에서 1%,2%,3% 수익감소일때 20%,30% 50% 청산
input : 매수금액(500000),P(5);
input : Per(5);
var : OpenCond(false),Xcond1(false),Xcond2(false),Xcond3(false);
var : sum(0),cnt(0);
input : 진입회수(1);
sum = 0;
for cnt = 0 to P-1
{
sum = sum + DayClose(cnt);
}
var1 = sum/P;
if stime == 153000 and c < Var1*1.05 Then
{
buy("b",AtMarket,def,Floor(매수금액/C));
}
if MarketPosition == 1 Then
{
if NextBarOpen >= EntryPrice*(1+Per/100) Then
OpenCond = true;
if LatestExitName(0) == "bx11" Then
Xcond1 = true;
if LatestExitName(0) == "bx12" Then
Xcond2 = true;
if LatestExitName(0) == "bx13" Then
Xcond3 = true;
if OpenCond == false and highest(H,BarsSinceEntry) >= EntryPrice*1.03 Then
{
ExitLong("bx11",AtStop,highest(H,BarsSinceEntry)*0.99,"",Floor(MaxContracts*0.2),1);
ExitLong("bx12",AtStop,highest(H,BarsSinceEntry)*0.98,"",Floor(MaxContracts*0.3),1);
ExitLong("bx13",AtStop,highest(H,BarsSinceEntry)*0.97);
}
if OpenCond == true Then
{
if xcond1 == false Then
ExitLong("bx21",AtStop,highest(H,BarsSinceEntry)*0.99,"",Floor(MaxContracts*0.2),1);
if xcond2 == false Then
ExitLong("bx22",AtStop,highest(H,BarsSinceEntry)*0.98,"",Floor(MaxContracts*0.3),1);
if xcond3 == false Then
ExitLong("bx23",AtStop,highest(H,BarsSinceEntry)*0.97);
}
}
#매수포지션이 아니면 초기화
if MarketPosition != 1 Then
{
OpenCond = false;
Xcond1 = false;
Xcond2 = false;
Xcond3 = false;
SetStopTrailing(0,0);
}
SetStopLoss(3);
SetStopEndofday(151000);
3
var : 상한가(0), UpLimit(0), 전일상한가(0);
var : up1(0), up2(0), up3(0), up4(0), up5(0),up6(0),Up7(0);
if date >= 19981207 then {
if date < 20050328 && CodeCategory() == 2 then
UpLimit = (BP[0] * 1.12);
Else if date >= 20050328 and date < 20150615 Then
UpLimit = (BP[0] * 1.15);
Else
UpLimit = (BP[0] * 1.30);
if CodeCategory() == 2 then {
if date >= 20030721 then {
up1 = int(UpLimit/100+0.00001)*100;
up2 = int(UpLimit/100+0.00001)*100;
up3 = int(UpLimit/100+0.00001)*100;
up4 = int(UpLimit/50+0.00001)*50;
up5 = int(UpLimit/10+0.00001)*10;
up6 = int(UpLimit/5+0.00001)*5;
up7 = int(UpLimit/1+0.00001)*1;
}
else {
up1 = int(UpLimit/1000+0.00001)*1000;
up2 = int(UpLimit/500+0.00001)*500;
up3 = int(UpLimit/100+0.00001)*100;
up4 = int(UpLimit/50+0.00001)*50;
up5 = int(UpLimit/10+0.00001)*10;
up6 = int(UpLimit/10+0.00001)*10;
up7 = int(UpLimit/1+0.00001)*1;
}
}
Else {
up1 = int(UpLimit/1000+0.00001)*1000;
up2 = int(UpLimit/500+0.00001)*500;
up3 = int(UpLimit/100+0.00001)*100;
up4 = int(UpLimit/50+0.00001)*50;
up5 = int(UpLimit/10+0.00001)*10;
up6 = int(UpLimit/5+0.00001)*5;
up7 = int(UpLimit/1+0.00001)*1;
}
if CodeCategory() == 1 || CodeCategory() == 2 then {
if sdate < 20101004 Then{
If BP >= 500000 Then
상한가 = up1;
Else If BP >= 100000 Then
상한가 = iff(up2>=500000, up1, up2);
Else If BP >= 50000 Then
상한가 = iff(up3>=100000, up2, up3);
Else If BP >= 10000 Then
상한가 = iff(up4>=50000, up3, up4);
Else If BP >= 5000 Then
상한가 = iff(up5>=10000, up4, up5);
Else If BP >= 1000 Then
상한가 = iff(up5>=5000, up5, up6);
Else
상한가 = iff(up6>=1000, up6, up6);
}
Else{
If BP >= 500000 Then
상한가 = up1;
Else If BP >= 100000 Then
상한가 = iff(up2>=500000, up1, up2);
Else If BP >= 50000 Then
상한가 = iff(up3>=100000, up2, up3);
Else If BP >= 10000 Then
상한가 = iff(up4>=50000, up3, up4);
Else If BP >= 5000 Then
상한가 = iff(up5>=10000, up4, up5);
Else If BP >= 1000 Then
상한가 = iff(up5>=5000, up5, up6);
Else
상한가 = iff(up6>=1000, up6, up7);
}
}
else if CodeCategory() == 8 || CodeCategory() == 9 then { // ETF
상한가 = up6;
}
}
if C < 상한가 and C[1] < 상한가[1] //1일전 및 2일전 상한가가 아닐것
and C[1] > O[1]*1.05 //1일봉전 시가대비 1일봉전 종가 등락률이 5%이상
and C[2] < C[3]*1.05 //3일봉전 종가대비 2일봉전 종가 등락률이 5%이하
and H[1] > C[2]*1.10 //2일봉전 종가 대비 1봉전 고가등락률이 10% 이상
and countif(H < O*1.10,60)[2] == 0 #2일봉전 기준 60봉 이내에서 시가대비 고가 10% 미만
and V[1] >= ma(V,60)[2]*5 #2일봉전부터 60일봉 기간내 평균거래량보다 1봉전 거래량이 500%이상
Then
find(1);
즐거운 하루되세요
> 가이츠 님이 쓴 글입니다.
> 제목 : 질문드립니다
> 1.
현재예스스팟 분봉 확장차트에서 매매신호를 주고 매매하고 있습니다.
장초부터 시작해서 주가가 일봉주기 5일 이동 평균선에 5% 이내로 근접했을때 매수하고 트레일링 스탑으로 매매되는 매매 수식 부탁드립니다. 진입회수는 1회이며 작성한 수식에서 가감해야 할 부분에 대하여 알려주시면 감사하겠습니다.
input : 매수금액(500000);
input : Per(5),수익률(3),근접률(5);
var : Evol(0),Xcnt(0),OpenCond(false),Xcond1(false),Xcond2(false),Xcond3(false);
Var1 = ma(DayClose,5);
input : 진입회수(1);
if stime == 153000 and c<Var1*(1+근접률/100) Then
{
buy("b",AtMarket,def,Floor(매수금액/C));
}
//SetStopTrailing(2,10,PercentStop,1); //최소 10% 수익 이후에 최고 가격대비 2% 하락하면 청산
if MarketPosition == 1 Then
{
SetStopLoss(3);
#봉완성시 다음봉 시가가 진입가 대비 5% 이상 상승하면 true
if NextBarOpen >= EntryPrice*(1+Per/100) Then
OpenCond = true;
#BP1 청산이 발생하면 Xcond1은 true
if LatestExitName(0) == "BP1" Then
Xcond1 = true;
#BP2 청산이 발생하면 Xcond2은 true
if LatestExitName(0) == "BP2" Then
Xcond2 = true;
#BP3 청산이 발생하면 Xcond3은 true
if LatestExitName(0) == "BP3" Then
Xcond3 = True;
#OpenCond가 false일때
if OpenCond == false Then
{
SetStopTrailing(2,3,PercentStop,1); //최소 10% 수익 이후에 최고 가격대비 2% 하락하면 청산
/*if Xcond1 == false then
ExitLong("BP1",atlimit,EntryPrice(0)*1.03,"",Floor(MaxContracts*0.3),1);
if Xcond2 == false then
ExitLong("BP2",atlimit,EntryPrice(0)*1.04,"",Floor(MaxContracts*0.4),1);
if Xcond3 == false then
ExitLong("BP3",atlimit,EntryPrice(0)*1.05);*/
}
#OpenCond가 true일떄
if OpenCond == true Then
{
SetStopTrailing(3.5,5,PercentStop,1);
/* #BP1로 청산이 안된 경우만 발생
if Xcond1 == false Then
ExitLong("BP6",atlimit,EntryPrice*(1+(Per+3)/100),"",Floor(MaxContracts*0.3),1);
#BP2로 청산이 안된 경우만 발생
if Xcond2 == false Then
ExitLong("BP7",atlimit,EntryPrice*(1+(Per+4)/100),"",Floor(MaxContracts*0.4),1);
#BP3로 청산이 안된 경우만 발생
if Xcond3 == false Then
ExitLong("BP8",atlimit,EntryPrice*(1+(Per+5)/100));
#5%이하로 가격하락하면 전량처산 */
//exitlong("BP5",AtStop,EntryPrice*(1+Per/100));
}
SetStopEndofday(151000);
}
#매수포지션이 아니면 모두 false로 초기화
if MarketPosition != 1 Then{
OpenCond = false;
Xcond1 = false;
Xcond2 = false;
Xcond3 = false;
SetStopLoss(0);//해제
SetStopEndofday(0);//해제
SetStopTrailing(0,0);//해제
}
2.
그리고 트레일링 스탑을 분할하여 적용가능한 방법이 있나요?
예를 들어 100주를 매수 했을 경우 20 30 50 주 각각 다르게 적용하여 매도 가능한지
3.
종목검색식 부탁드립니다.
2일봉전 종가 대비 1봉전 고가등락률이 10% 이상
2일봉전 기준 60봉 이내에서 시가대비 고가 10% 미만
1일전 및 2일전 상한가가 아닐것
1일봉전 시가대비 1일봉전 종가 등락률이 5%이상
2일봉전부터 60일봉 기간내 평균거래량보다 1봉전 거래량이 500%이상
3일봉전 종가대비 2일봉전 종가 등락률이 5%이하
아래에 제가 작성한 검색식인데
2일봉전 기준 60봉 이내에서 시가대비 고가 10% 미만
2일봉전부터 60일봉 기간내 평균거래량보다 1봉전 거래량이 500%이상
이 두가지 조건 수식부탁드리며 제가 작성한 것도 맞는지 검토 부탁드립니다.
감사합니다.
var : 상한가(0), UpLimit(0), 전일상한가(0);
var : up1(0), up2(0), up3(0), up4(0), up5(0),up6(0),Up7(0);
if date >= 19981207 then {
if date < 20050328 && CodeCategory() == 2 then
UpLimit = (BP[0] * 1.12);
Else if date >= 20050328 and date < 20150615 Then
UpLimit = (BP[0] * 1.15);
Else
UpLimit = (BP[0] * 1.30);
if CodeCategory() == 2 then {
if date >= 20030721 then {
up1 = int(UpLimit/100+0.00001)*100;
up2 = int(UpLimit/100+0.00001)*100;
up3 = int(UpLimit/100+0.00001)*100;
up4 = int(UpLimit/50+0.00001)*50;
up5 = int(UpLimit/10+0.00001)*10;
up6 = int(UpLimit/5+0.00001)*5;
up7 = int(UpLimit/1+0.00001)*1;
}
else {
up1 = int(UpLimit/1000+0.00001)*1000;
up2 = int(UpLimit/500+0.00001)*500;
up3 = int(UpLimit/100+0.00001)*100;
up4 = int(UpLimit/50+0.00001)*50;
up5 = int(UpLimit/10+0.00001)*10;
up6 = int(UpLimit/10+0.00001)*10;
up7 = int(UpLimit/1+0.00001)*1;
}
}
Else {
up1 = int(UpLimit/1000+0.00001)*1000;
up2 = int(UpLimit/500+0.00001)*500;
up3 = int(UpLimit/100+0.00001)*100;
up4 = int(UpLimit/50+0.00001)*50;
up5 = int(UpLimit/10+0.00001)*10;
up6 = int(UpLimit/5+0.00001)*5;
up7 = int(UpLimit/1+0.00001)*1;
}
if CodeCategory() == 1 || CodeCategory() == 2 then {
if sdate < 20101004 Then{
If BP >= 500000 Then
상한가 = up1;
Else If BP >= 100000 Then
상한가 = iff(up2>=500000, up1, up2);
Else If BP >= 50000 Then
상한가 = iff(up3>=100000, up2, up3);
Else If BP >= 10000 Then
상한가 = iff(up4>=50000, up3, up4);
Else If BP >= 5000 Then
상한가 = iff(up5>=10000, up4, up5);
Else If BP >= 1000 Then
상한가 = iff(up5>=5000, up5, up6);
Else
상한가 = iff(up6>=1000, up6, up6);
}
Else{
If BP >= 500000 Then
상한가 = up1;
Else If BP >= 100000 Then
상한가 = iff(up2>=500000, up1, up2);
Else If BP >= 50000 Then
상한가 = iff(up3>=100000, up2, up3);
Else If BP >= 10000 Then
상한가 = iff(up4>=50000, up3, up4);
Else If BP >= 5000 Then
상한가 = iff(up5>=10000, up4, up5);
Else If BP >= 1000 Then
상한가 = iff(up5>=5000, up5, up6);
Else
상한가 = iff(up6>=1000, up6, up7);
}
}
else if CodeCategory() == 8 || CodeCategory() == 9 then { // ETF
상한가 = up6;
}
}
if C < 상한가 and C[1] < 상한가[1] //1일전 및 2일전 상한가가 아닐것
and C[1] > O[1]*1.05 //1일봉전 시가대비 1일봉전 종가 등락률이 5%이상
and C[2] < C[3]*1.05 //3일봉전 종가대비 2일봉전 종가 등락률이 5%이하
and H[1] > C[2]*1.10 //2일봉전 종가 대비 1봉전 고가등락률이 10% 이상
Then
find(1);
//2일봉전 기준 60봉 이내에서 시가대비 고가 10% 미만
//2일봉전부터 60일봉 기간내 평균거래량보다 1봉전 거래량이 500%이상
이전글