커뮤니티
주식매매식
2014-10-20 16:05:37
262
글번호 79582
안녕하십니까.
38557 수식적용해 보았습니다.
첨부와 같이 의도와는 다르게 하락시는 신호가 나오질않네요
제 설명이 약간 잘못되었던것 같습니다.
제가 원하는 것은,
1. 초기매수후 5%(입력값) 하락/상승시 모두 추가매수 하는 것입니다.
즉 초기매수값의 5%별로 매수 가격대가 미리 결정이 되어져 있고
(....110, 106, 100, 95, 90....) 그 가격대에 걸릴때마다 모두 매수하는 것입니다.
상승 하락을 반복하다보면 목표수익에 도달하기 전에 아래 가격에 걸릴때 매수하고
다시 위가격에 걸릴때 매수하고 해서 특정가격대에서 여러번 매수가 가능할 수도 있습니다.
2. 위와 기본 로직은 같으나 같은 가격대에서는 1번만 매수하게 하는 수식.
항상 감사드립니다. 날씨가 갑자기 추워졌네요. 건강유의하세요
38557 답변
===========================================================================
input : 투자금액(1000000),Per(5),첫진입시각(90000),Profit(10),Loss(30);
var : Vol1(0),vol2(0),vol3(0),Upcnt(0),Upval(0),Dncnt(0),Dnval(0);
if CodeCategoryEx == 11 and BasePrice < 50000 Then{//주식
vol1 = int(int((투자금액)/C)/10)*10;
vol2 = int(int((투자금액*0.7)/C)/10)*10;
vol3 = int(int((투자금액*1.3)/C)/10)*10;
}
Else{
vol1 = int((투자금액)/C);//ETF
vol2 = int((투자금액*0.7)/C);
vol3 = int((투자금액*1.3)/C);
}
if MarketPosition == 0 and stime == 첫진입시각 Then{
buy("b",OnClose,def,vol1);
UpVal = c;
DnVal = c;
}
if MarketPosition == 1 Then{
if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "UpB" Then{
Upcnt = Upcnt+1;
UpVal = LatestEntryPrice(0);
}
if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "DnB" Then{
Dncnt = Dncnt+1;
DnVal = LatestEntryPrice(0);
}
buy("UpB",AtStop,UpVal*(1+(Per*(Upcnt+1))/100),Vol2);
buy("DnB",atlimit,DnVal*(1-(Per*(Dncnt+1))/100),Vol3);
ExitLong("BP",atlimit,AvgEntryPrice*(1+Profit/100));
ExitLong("BL",atlimit,AvgEntryPrice*(1+Loss/100));
}
Else{
Upcnt = 0;
Dncnt = 0;
}
- 1. ETF1.jpg (0.25 MB)
답변 3
예스스탁 예스스탁 답변
2014-10-20 17:30:18
안녕하세요
예스스탁입니다.
해당식 추가매수를 하는식이므로
피라미딩을 모든진입신호 허용으로 설정하고
적용하셔야 당일 지정한 시간에 첫진입을 하고
이후 상승이나 하락시에 추가진입신호가 발생합니다.
식에 %값을 잘못지정한 부분이 있어 수정해 드립니다.
input : 투자금액(1000000),Per(5),첫진입시각(90000),Profit(10),Loss(30);
var : Vol1(0),vol2(0),vol3(0),Upval(0),Dnval(0);
if CodeCategoryEx == 11 and BasePrice < 50000 Then{//주식
vol1 = int(int((투자금액)/C)/10)*10;
vol2 = int(int((투자금액*0.7)/C)/10)*10;
vol3 = int(int((투자금액*1.3)/C)/10)*10;
}
Else{
vol1 = int((투자금액)/C);//ETF
vol2 = int((투자금액*0.7)/C);
vol3 = int((투자금액*1.3)/C);
}
if MarketPosition == 0 and stime == 첫진입시각 Then{
buy("b",OnClose,def,vol1);
UpVal = c;
DnVal = c;
}
if MarketPosition == 1 Then{
if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "UpB" Then{
UpVal = LatestEntryPrice(0);
}
if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "DnB" Then{
DnVal = LatestEntryPrice(0);
}
buy("UpB",AtStop,UpVal*(1+(Per)/100),Vol2);
buy("DnB",atlimit,DnVal*(1-(Per)/100),Vol3);
ExitLong("BP",atlimit,AvgEntryPrice*(1+Profit/100));
ExitLong("BL",atlimit,AvgEntryPrice*(1+Loss/100));
}
위식이 당일청산을 염두에 두고
매일 지정한 식에 진입하게 되어 있습니다.
당일청산을 하지 않고 특정일 특정시간에 최초 매수하시는 식이시면
아래와 같이 첫진입식 변경하시면 됩니다.
input : 투자금액(1000000),Per(5),첫진입날짜(20141001),첫진입시각(90000),Profit(10),Loss(30);
var : Vol1(0),vol2(0),vol3(0),Upval(0),Dnval(0);
if CodeCategoryEx == 11 and BasePrice < 50000 Then{//주식
vol1 = int(int((투자금액)/C)/10)*10;
vol2 = int(int((투자금액*0.7)/C)/10)*10;
vol3 = int(int((투자금액*1.3)/C)/10)*10;
}
Else{
vol1 = int((투자금액)/C);//ETF
vol2 = int((투자금액*0.7)/C);
vol3 = int((투자금액*1.3)/C);
}
if MarketPosition == 0 and stime == 첫진입시각 and sdate == 첫진입날짜 Then{
buy("b",OnClose,def,vol1);
UpVal = c;
DnVal = c;
}
if MarketPosition == 1 Then{
if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "UpB" Then{
UpVal = LatestEntryPrice(0);
}
if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "DnB" Then{
DnVal = LatestEntryPrice(0);
}
buy("UpB",AtStop,UpVal*(1+(Per)/100),Vol2);
buy("DnB",atlimit,DnVal*(1-(Per)/100),Vol3);
ExitLong("BP",atlimit,AvgEntryPrice*(1+Profit/100));
ExitLong("BL",atlimit,AvgEntryPrice*(1+Loss/100));
}
위식들은 현재 특정가격대에서 한번만 발생하게 되어 있습니다.
만약 특정가격대에서 횟수에 관계없이 진입하시면 아래식 이용하시면 됩니다.
input : 투자금액(1000000),Per(5),첫진입날짜(20141001),첫진입시각(90000),Profit(10),Loss(30);
var : Vol1(0),vol2(0),vol3(0),Upcnt(0),Upval(0),Dncnt(0),Dnval(0);
if CodeCategoryEx == 11 and BasePrice < 50000 Then{//주식
vol1 = int(int((투자금액)/C)/10)*10;
vol2 = int(int((투자금액*0.7)/C)/10)*10;
vol3 = int(int((투자금액*1.3)/C)/10)*10;
}
Else{
vol1 = int((투자금액)/C);//ETF
vol2 = int((투자금액*0.7)/C);
vol3 = int((투자금액*1.3)/C);
}
if MarketPosition == 0 and stime == 첫진입시각 and sdate == 첫진입날짜 Then{//매일지정시간 진입이면 sdate == 첫진입날짜 제거
buy("b",OnClose,def,vol1);
}
if MarketPosition == 1 Then{
var1 = Ceiling(((H-EntryPrice)/EntryPrice*100)/Per);
var2 = Ceiling(((EntryPrice-Low)/EntryPrice*100)/Per);
if H < EntryPrice*(1+(Per*var1)/100) and H > EntryPrice Then
buy("UpB",AtStop,EntryPrice*(1+(Per*var1)/100),Vol2);
if L > EntryPrice*(1-(Per*var2)/100) and L < EntryPrice Then
buy("DnB",Atlimit,EntryPrice*(1-(Per*var2)/100),Vol3);
ExitLong("BP",atlimit,AvgEntryPrice*(1+Profit/100));
ExitLong("BL",atlimit,AvgEntryPrice*(1+Loss/100));
}
즐거운 하루되세요
> 미수예스 님이 쓴 글입니다.
> 제목 : 주식매매식
> 안녕하십니까.
38557 수식적용해 보았습니다.
첨부와 같이 의도와는 다르게 하락시는 신호가 나오질않네요
제 설명이 약간 잘못되었던것 같습니다.
제가 원하는 것은,
1. 초기매수후 5%(입력값) 하락/상승시 모두 추가매수 하는 것입니다.
즉 초기매수값의 5%별로 매수 가격대가 미리 결정이 되어져 있고
(....110, 106, 100, 95, 90....) 그 가격대에 걸릴때마다 모두 매수하는 것입니다.
상승 하락을 반복하다보면 목표수익에 도달하기 전에 아래 가격에 걸릴때 매수하고
다시 위가격에 걸릴때 매수하고 해서 특정가격대에서 여러번 매수가 가능할 수도 있습니다.
2. 위와 기본 로직은 같으나 같은 가격대에서는 1번만 매수하게 하는 수식.
항상 감사드립니다. 날씨가 갑자기 추워졌네요. 건강유의하세요
38557 답변
===========================================================================
input : 투자금액(1000000),Per(5),첫진입시각(90000),Profit(10),Loss(30);
var : Vol1(0),vol2(0),vol3(0),Upcnt(0),Upval(0),Dncnt(0),Dnval(0);
if CodeCategoryEx == 11 and BasePrice < 50000 Then{//주식
vol1 = int(int((투자금액)/C)/10)*10;
vol2 = int(int((투자금액*0.7)/C)/10)*10;
vol3 = int(int((투자금액*1.3)/C)/10)*10;
}
Else{
vol1 = int((투자금액)/C);//ETF
vol2 = int((투자금액*0.7)/C);
vol3 = int((투자금액*1.3)/C);
}
if MarketPosition == 0 and stime == 첫진입시각 Then{
buy("b",OnClose,def,vol1);
UpVal = c;
DnVal = c;
}
if MarketPosition == 1 Then{
if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "UpB" Then{
Upcnt = Upcnt+1;
UpVal = LatestEntryPrice(0);
}
if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "DnB" Then{
Dncnt = Dncnt+1;
DnVal = LatestEntryPrice(0);
}
buy("UpB",AtStop,UpVal*(1+(Per*(Upcnt+1))/100),Vol2);
buy("DnB",atlimit,DnVal*(1-(Per*(Dncnt+1))/100),Vol3);
ExitLong("BP",atlimit,AvgEntryPrice*(1+Profit/100));
ExitLong("BL",atlimit,AvgEntryPrice*(1+Loss/100));
}
Else{
Upcnt = 0;
Dncnt = 0;
}
미수예스
2014-10-20 22:29:26
감사합니다.
아래 2가지만 확인부탁드립니다.
1. 1번째식에서 Vol3의 수량을 한단계 하락 매수시마다, 최초금액의 30%씩 증액하고 싶습니다.
현재, 130만 --> 130만 --> 130만 ...
희망, 130만 --> 130만+30만 --> 130만 +30만+30만, ...
2. 2번째 3번째는 신호가 안나오는것 같습니다.
감사합니다.
> 예스스탁 님이 쓴 글입니다.
> 제목 : Re : 주식매매식
> 안녕하세요
예스스탁입니다.
해당식 추가매수를 하는식이므로
피라미딩을 모든진입신호 허용으로 설정하고
적용하셔야 당일 지정한 시간에 첫진입을 하고
이후 상승이나 하락시에 추가진입신호가 발생합니다.
식에 %값을 잘못지정한 부분이 있어 수정해 드립니다.
input : 투자금액(1000000),Per(5),첫진입시각(90000),Profit(10),Loss(30);
var : Vol1(0),vol2(0),vol3(0),Upval(0),Dnval(0);
if CodeCategoryEx == 11 and BasePrice < 50000 Then{//주식
vol1 = int(int((투자금액)/C)/10)*10;
vol2 = int(int((투자금액*0.7)/C)/10)*10;
vol3 = int(int((투자금액*1.3)/C)/10)*10;
}
Else{
vol1 = int((투자금액)/C);//ETF
vol2 = int((투자금액*0.7)/C);
vol3 = int((투자금액*1.3)/C);
}
if MarketPosition == 0 and stime == 첫진입시각 Then{
buy("b",OnClose,def,vol1);
UpVal = c;
DnVal = c;
}
if MarketPosition == 1 Then{
if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "UpB" Then{
UpVal = LatestEntryPrice(0);
}
if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "DnB" Then{
DnVal = LatestEntryPrice(0);
}
buy("UpB",AtStop,UpVal*(1+(Per)/100),Vol2);
buy("DnB",atlimit,DnVal*(1-(Per)/100),Vol3);
ExitLong("BP",atlimit,AvgEntryPrice*(1+Profit/100));
ExitLong("BL",atlimit,AvgEntryPrice*(1+Loss/100));
}
위식이 당일청산을 염두에 두고
매일 지정한 식에 진입하게 되어 있습니다.
당일청산을 하지 않고 특정일 특정시간에 최초 매수하시는 식이시면
아래와 같이 첫진입식 변경하시면 됩니다.
input : 투자금액(1000000),Per(5),첫진입날짜(20141001),첫진입시각(90000),Profit(10),Loss(30);
var : Vol1(0),vol2(0),vol3(0),Upval(0),Dnval(0);
if CodeCategoryEx == 11 and BasePrice < 50000 Then{//주식
vol1 = int(int((투자금액)/C)/10)*10;
vol2 = int(int((투자금액*0.7)/C)/10)*10;
vol3 = int(int((투자금액*1.3)/C)/10)*10;
}
Else{
vol1 = int((투자금액)/C);//ETF
vol2 = int((투자금액*0.7)/C);
vol3 = int((투자금액*1.3)/C);
}
if MarketPosition == 0 and stime == 첫진입시각 and sdate == 첫진입날짜 Then{
buy("b",OnClose,def,vol1);
UpVal = c;
DnVal = c;
}
if MarketPosition == 1 Then{
if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "UpB" Then{
UpVal = LatestEntryPrice(0);
}
if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "DnB" Then{
DnVal = LatestEntryPrice(0);
}
buy("UpB",AtStop,UpVal*(1+(Per)/100),Vol2);
buy("DnB",atlimit,DnVal*(1-(Per)/100),Vol3);
ExitLong("BP",atlimit,AvgEntryPrice*(1+Profit/100));
ExitLong("BL",atlimit,AvgEntryPrice*(1+Loss/100));
}
위식들은 현재 특정가격대에서 한번만 발생하게 되어 있습니다.
만약 특정가격대에서 횟수에 관계없이 진입하시면 아래식 이용하시면 됩니다.
input : 투자금액(1000000),Per(5),첫진입날짜(20141001),첫진입시각(90000),Profit(10),Loss(30);
var : Vol1(0),vol2(0),vol3(0),Upcnt(0),Upval(0),Dncnt(0),Dnval(0);
if CodeCategoryEx == 11 and BasePrice < 50000 Then{//주식
vol1 = int(int((투자금액)/C)/10)*10;
vol2 = int(int((투자금액*0.7)/C)/10)*10;
vol3 = int(int((투자금액*1.3)/C)/10)*10;
}
Else{
vol1 = int((투자금액)/C);//ETF
vol2 = int((투자금액*0.7)/C);
vol3 = int((투자금액*1.3)/C);
}
if MarketPosition == 0 and stime == 첫진입시각 and sdate == 첫진입날짜 Then{//매일지정시간 진입이면 sdate == 첫진입날짜 제거
buy("b",OnClose,def,vol1);
}
if MarketPosition == 1 Then{
var1 = Ceiling(((H-EntryPrice)/EntryPrice*100)/Per);
var2 = Ceiling(((EntryPrice-Low)/EntryPrice*100)/Per);
if H < EntryPrice*(1+(Per*var1)/100) and H > EntryPrice Then
buy("UpB",AtStop,EntryPrice*(1+(Per*var1)/100),Vol2);
if L > EntryPrice*(1-(Per*var2)/100) and L < EntryPrice Then
buy("DnB",Atlimit,EntryPrice*(1-(Per*var2)/100),Vol3);
ExitLong("BP",atlimit,AvgEntryPrice*(1+Profit/100));
ExitLong("BL",atlimit,AvgEntryPrice*(1+Loss/100));
}
즐거운 하루되세요
> 미수예스 님이 쓴 글입니다.
> 제목 : 주식매매식
> 안녕하십니까.
38557 수식적용해 보았습니다.
첨부와 같이 의도와는 다르게 하락시는 신호가 나오질않네요
제 설명이 약간 잘못되었던것 같습니다.
제가 원하는 것은,
1. 초기매수후 5%(입력값) 하락/상승시 모두 추가매수 하는 것입니다.
즉 초기매수값의 5%별로 매수 가격대가 미리 결정이 되어져 있고
(....110, 106, 100, 95, 90....) 그 가격대에 걸릴때마다 모두 매수하는 것입니다.
상승 하락을 반복하다보면 목표수익에 도달하기 전에 아래 가격에 걸릴때 매수하고
다시 위가격에 걸릴때 매수하고 해서 특정가격대에서 여러번 매수가 가능할 수도 있습니다.
2. 위와 기본 로직은 같으나 같은 가격대에서는 1번만 매수하게 하는 수식.
항상 감사드립니다. 날씨가 갑자기 추워졌네요. 건강유의하세요
38557 답변
===========================================================================
input : 투자금액(1000000),Per(5),첫진입시각(90000),Profit(10),Loss(30);
var : Vol1(0),vol2(0),vol3(0),Upcnt(0),Upval(0),Dncnt(0),Dnval(0);
if CodeCategoryEx == 11 and BasePrice < 50000 Then{//주식
vol1 = int(int((투자금액)/C)/10)*10;
vol2 = int(int((투자금액*0.7)/C)/10)*10;
vol3 = int(int((투자금액*1.3)/C)/10)*10;
}
Else{
vol1 = int((투자금액)/C);//ETF
vol2 = int((투자금액*0.7)/C);
vol3 = int((투자금액*1.3)/C);
}
if MarketPosition == 0 and stime == 첫진입시각 Then{
buy("b",OnClose,def,vol1);
UpVal = c;
DnVal = c;
}
if MarketPosition == 1 Then{
if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "UpB" Then{
Upcnt = Upcnt+1;
UpVal = LatestEntryPrice(0);
}
if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "DnB" Then{
Dncnt = Dncnt+1;
DnVal = LatestEntryPrice(0);
}
buy("UpB",AtStop,UpVal*(1+(Per*(Upcnt+1))/100),Vol2);
buy("DnB",atlimit,DnVal*(1-(Per*(Dncnt+1))/100),Vol3);
ExitLong("BP",atlimit,AvgEntryPrice*(1+Profit/100));
ExitLong("BL",atlimit,AvgEntryPrice*(1+Loss/100));
}
Else{
Upcnt = 0;
Dncnt = 0;
}
예스스탁 예스스탁 답변
2014-10-21 11:32:36
안녕하세요
예스스탁입니다.
기존식은 하락시 1,300,000만으로만 진입했습니다.
하락시마다 30%증액해서 진입하게 수정했습니다.
올려드린식 모두 신호 발생합니니다.
매일지정한 시각에 첫진입을 하시면
첫번째 진입수식의 if문에서 and sdate == 첫진입날짜 조건을 제거하시면 됩니다.
1. 라인 진입 한번
input : 투자금액(1000000),Per(5),첫진입시각(90000),첫진입날짜(20141001),Profit(10),Loss(30);
var : Mny1(0),Mny2(0),Mny3(0),Vol1(0),Vol2(0),Vol3(0),Upval(0),Dnval(0),UPcnt(0),Dncnt(0);
if MarketPosition == 0 and stime == 첫진입시각 and sdate == 첫진입날짜 Then{
Mny3 = 투자금액+투자금액*0.3;
if CodeCategoryEx == 11 and BasePrice < 50000 Then{
vol1 = int(int((투자금액)/C)/10)*10;
vol2 = int(int((투자금액-투자금액*0.3)/C)/10)*10;
vol3 = int(int((Mny3)/C)/10)*10;
}
Else{
vol1 = int((투자금액)/C);
vol2 = int((투자금액-투자금액*0.3)/C);
vol3 = int((Mny3)/C);
}
UpVal = c;
DnVal = c;
buy("b",OnClose,def,vol1);
}
if MarketPosition == 1 Then{
if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "UpB" Then{
UpVal = LatestEntryPrice(0);
UPCnt = upcnt+1;
if CodeCategoryEx == 11 and BasePrice < 50000 Then{
vol2 = int(int((투자금액-투자금액*0.3)/C)/10)*10;
}
Else{
vol2 = int((투자금액-투자금액*0.3)/C);
}
}
if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "DnB" Then{
DnVal = LatestEntryPrice(0);
DnCnt = Dncnt+1;
Mny3 = Mny3+투자금액*0.3;
if CodeCategoryEx == 11 and BasePrice < 50000 Then{
vol3 = int(int((Mny3)/C)/10)*10;
}
Else{
vol3 = int((Mny3)/C);
}
}
buy("UpB",AtStop,UpVal*(1+(Per)/100),Vol2);
buy("DnB",atlimit,DnVal*(1-(Per)/100),Vol3);
ExitLong("BP",atlimit,AvgEntryPrice*(1+Profit/100));
ExitLong("BL",atlimit,AvgEntryPrice*(1+Loss/100));
}
if MarketPosition != 0 Then{
Upcnt = 0;
Dncnt = 0;
}
2 라인당 진입횟수 제한없음
input : 투자금액(1000000),Per(5),첫진입시각(90000),첫진입날짜(20141001),Profit(10),Loss(30);
var : Mny1(0),Mny2(0),Mny3(0),Vol1(0),Vol2(0),Vol3(0),Upval(0),Dnval(0),UPcnt(0),Dncnt(0);
if MarketPosition == 0 and stime == 첫진입시각 and sdate == 첫진입날짜 Then{//매일지정시간 진입이면 sdate == 첫진입날짜 제거
Mny3 = 투자금액+투자금액*0.3;
if CodeCategoryEx == 11 and BasePrice < 50000 Then{
vol1 = int(int((투자금액)/C)/10)*10;
vol2 = int(int((투자금액-투자금액*0.3)/C)/10)*10;
vol3 = int(int((Mny3)/C)/10)*10;
}
Else{
vol1 = int((투자금액)/C);
vol2 = int((투자금액-투자금액*0.3)/C);
vol3 = int((Mny3)/C);
}
buy("b",OnClose,def,vol1);
}
if MarketPosition == 1 Then{
if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "UpB" Then{
UpVal = LatestEntryPrice(0);
UPCnt = upcnt+1;
if CodeCategoryEx == 11 and BasePrice < 50000 Then{
vol2 = int(int((투자금액-투자금액*0.3)/C)/10)*10;
}
Else{
vol2 = int((투자금액-투자금액*0.3)/C);
}
}
if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "DnB" Then{
DnVal = LatestEntryPrice(0);
DnCnt = Dncnt+1;
Mny3 = Mny3+투자금액*0.3;
if CodeCategoryEx == 11 and BasePrice < 50000 Then{
vol3 = int(int((Mny3)/C)/10)*10;
}
Else{
vol3 = int((Mny3)/C);
}
}
var1 = Ceiling(((H-EntryPrice)/EntryPrice*100)/Per);
var2 = Ceiling(((EntryPrice-Low)/EntryPrice*100)/Per);
if H < EntryPrice*(1+(Per*var1)/100) and H > EntryPrice Then
buy("UpB",AtStop,EntryPrice*(1+(Per*var1)/100),Vol2);
if L > EntryPrice*(1-(Per*var2)/100) and L < EntryPrice Then
buy("DnB",Atlimit,EntryPrice*(1-(Per*var2)/100),Vol3);
ExitLong("BP",atlimit,AvgEntryPrice*(1+Profit/100));
ExitLong("BL",atlimit,AvgEntryPrice*(1+Loss/100));
}
if MarketPosition != 0 Then{
Upcnt = 0;
Dncnt = 0;
}
즐거운 하루되세요
> 미수예스 님이 쓴 글입니다.
> 제목 : Re : Re : 주식매매식
> 감사합니다.
아래 2가지만 확인부탁드립니다.
1. 1번째식에서 Vol3의 수량을 한단계 하락 매수시마다, 최초금액의 30%씩 증액하고 싶습니다.
현재, 130만 --> 130만 --> 130만 ...
희망, 130만 --> 130만+30만 --> 130만 +30만+30만, ...
2. 2번째 3번째는 신호가 안나오는것 같습니다.
감사합니다.
> 예스스탁 님이 쓴 글입니다.
> 제목 : Re : 주식매매식
> 안녕하세요
예스스탁입니다.
해당식 추가매수를 하는식이므로
피라미딩을 모든진입신호 허용으로 설정하고
적용하셔야 당일 지정한 시간에 첫진입을 하고
이후 상승이나 하락시에 추가진입신호가 발생합니다.
식에 %값을 잘못지정한 부분이 있어 수정해 드립니다.
input : 투자금액(1000000),Per(5),첫진입시각(90000),Profit(10),Loss(30);
var : Vol1(0),vol2(0),vol3(0),Upval(0),Dnval(0);
if CodeCategoryEx == 11 and BasePrice < 50000 Then{//주식
vol1 = int(int((투자금액)/C)/10)*10;
vol2 = int(int((투자금액*0.7)/C)/10)*10;
vol3 = int(int((투자금액*1.3)/C)/10)*10;
}
Else{
vol1 = int((투자금액)/C);//ETF
vol2 = int((투자금액*0.7)/C);
vol3 = int((투자금액*1.3)/C);
}
if MarketPosition == 0 and stime == 첫진입시각 Then{
buy("b",OnClose,def,vol1);
UpVal = c;
DnVal = c;
}
if MarketPosition == 1 Then{
if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "UpB" Then{
UpVal = LatestEntryPrice(0);
}
if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "DnB" Then{
DnVal = LatestEntryPrice(0);
}
buy("UpB",AtStop,UpVal*(1+(Per)/100),Vol2);
buy("DnB",atlimit,DnVal*(1-(Per)/100),Vol3);
ExitLong("BP",atlimit,AvgEntryPrice*(1+Profit/100));
ExitLong("BL",atlimit,AvgEntryPrice*(1+Loss/100));
}
위식이 당일청산을 염두에 두고
매일 지정한 식에 진입하게 되어 있습니다.
당일청산을 하지 않고 특정일 특정시간에 최초 매수하시는 식이시면
아래와 같이 첫진입식 변경하시면 됩니다.
input : 투자금액(1000000),Per(5),첫진입날짜(20141001),첫진입시각(90000),Profit(10),Loss(30);
var : Vol1(0),vol2(0),vol3(0),Upval(0),Dnval(0);
if CodeCategoryEx == 11 and BasePrice < 50000 Then{//주식
vol1 = int(int((투자금액)/C)/10)*10;
vol2 = int(int((투자금액*0.7)/C)/10)*10;
vol3 = int(int((투자금액*1.3)/C)/10)*10;
}
Else{
vol1 = int((투자금액)/C);//ETF
vol2 = int((투자금액*0.7)/C);
vol3 = int((투자금액*1.3)/C);
}
if MarketPosition == 0 and stime == 첫진입시각 and sdate == 첫진입날짜 Then{
buy("b",OnClose,def,vol1);
UpVal = c;
DnVal = c;
}
if MarketPosition == 1 Then{
if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "UpB" Then{
UpVal = LatestEntryPrice(0);
}
if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "DnB" Then{
DnVal = LatestEntryPrice(0);
}
buy("UpB",AtStop,UpVal*(1+(Per)/100),Vol2);
buy("DnB",atlimit,DnVal*(1-(Per)/100),Vol3);
ExitLong("BP",atlimit,AvgEntryPrice*(1+Profit/100));
ExitLong("BL",atlimit,AvgEntryPrice*(1+Loss/100));
}
위식들은 현재 특정가격대에서 한번만 발생하게 되어 있습니다.
만약 특정가격대에서 횟수에 관계없이 진입하시면 아래식 이용하시면 됩니다.
input : 투자금액(1000000),Per(5),첫진입날짜(20141001),첫진입시각(90000),Profit(10),Loss(30);
var : Vol1(0),vol2(0),vol3(0),Upcnt(0),Upval(0),Dncnt(0),Dnval(0);
if CodeCategoryEx == 11 and BasePrice < 50000 Then{//주식
vol1 = int(int((투자금액)/C)/10)*10;
vol2 = int(int((투자금액*0.7)/C)/10)*10;
vol3 = int(int((투자금액*1.3)/C)/10)*10;
}
Else{
vol1 = int((투자금액)/C);//ETF
vol2 = int((투자금액*0.7)/C);
vol3 = int((투자금액*1.3)/C);
}
if MarketPosition == 0 and stime == 첫진입시각 and sdate == 첫진입날짜 Then{//매일지정시간 진입이면 sdate == 첫진입날짜 제거
buy("b",OnClose,def,vol1);
}
if MarketPosition == 1 Then{
var1 = Ceiling(((H-EntryPrice)/EntryPrice*100)/Per);
var2 = Ceiling(((EntryPrice-Low)/EntryPrice*100)/Per);
if H < EntryPrice*(1+(Per*var1)/100) and H > EntryPrice Then
buy("UpB",AtStop,EntryPrice*(1+(Per*var1)/100),Vol2);
if L > EntryPrice*(1-(Per*var2)/100) and L < EntryPrice Then
buy("DnB",Atlimit,EntryPrice*(1-(Per*var2)/100),Vol3);
ExitLong("BP",atlimit,AvgEntryPrice*(1+Profit/100));
ExitLong("BL",atlimit,AvgEntryPrice*(1+Loss/100));
}
즐거운 하루되세요
> 미수예스 님이 쓴 글입니다.
> 제목 : 주식매매식
> 안녕하십니까.
38557 수식적용해 보았습니다.
첨부와 같이 의도와는 다르게 하락시는 신호가 나오질않네요
제 설명이 약간 잘못되었던것 같습니다.
제가 원하는 것은,
1. 초기매수후 5%(입력값) 하락/상승시 모두 추가매수 하는 것입니다.
즉 초기매수값의 5%별로 매수 가격대가 미리 결정이 되어져 있고
(....110, 106, 100, 95, 90....) 그 가격대에 걸릴때마다 모두 매수하는 것입니다.
상승 하락을 반복하다보면 목표수익에 도달하기 전에 아래 가격에 걸릴때 매수하고
다시 위가격에 걸릴때 매수하고 해서 특정가격대에서 여러번 매수가 가능할 수도 있습니다.
2. 위와 기본 로직은 같으나 같은 가격대에서는 1번만 매수하게 하는 수식.
항상 감사드립니다. 날씨가 갑자기 추워졌네요. 건강유의하세요
38557 답변
===========================================================================
input : 투자금액(1000000),Per(5),첫진입시각(90000),Profit(10),Loss(30);
var : Vol1(0),vol2(0),vol3(0),Upcnt(0),Upval(0),Dncnt(0),Dnval(0);
if CodeCategoryEx == 11 and BasePrice < 50000 Then{//주식
vol1 = int(int((투자금액)/C)/10)*10;
vol2 = int(int((투자금액*0.7)/C)/10)*10;
vol3 = int(int((투자금액*1.3)/C)/10)*10;
}
Else{
vol1 = int((투자금액)/C);//ETF
vol2 = int((투자금액*0.7)/C);
vol3 = int((투자금액*1.3)/C);
}
if MarketPosition == 0 and stime == 첫진입시각 Then{
buy("b",OnClose,def,vol1);
UpVal = c;
DnVal = c;
}
if MarketPosition == 1 Then{
if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "UpB" Then{
Upcnt = Upcnt+1;
UpVal = LatestEntryPrice(0);
}
if CurrentContracts > CurrentContracts[1] and LatestEntryName(0) == "DnB" Then{
Dncnt = Dncnt+1;
DnVal = LatestEntryPrice(0);
}
buy("UpB",AtStop,UpVal*(1+(Per*(Upcnt+1))/100),Vol2);
buy("DnB",atlimit,DnVal*(1-(Per*(Dncnt+1))/100),Vol3);
ExitLong("BP",atlimit,AvgEntryPrice*(1+Profit/100));
ExitLong("BL",atlimit,AvgEntryPrice*(1+Loss/100));
}
Else{
Upcnt = 0;
Dncnt = 0;
}
다음글
이전글