커뮤니티
시스템식 질문입니다.
2013-04-11 11:27:51
150
글번호 61946
어제 답변해주신 말씀보고 다시 확인하니 피라미딩이 허용안함에 체크되서 안됬던거 같습니다.
>>
답변을 참조로 2차분할매수손절 식을 작성해보았습니다.
종목은 우수AMS 13년 4월4일 매매에다 적용해보았습니다. 전에 질문드린날이랑 같은 그런데 위에 그림처럼 2차 분할매수가 계속반복되서 들어가는거 같습니다. 2차분할매수인
"2-b1"이 3번미만 진입하게 하려면 어떻게 수정해야되는지 문의드립니다.
만약 3차분할매수손절식을 작성한다해도 큰 흐름은 차이 없겠지여?
또 식을 보시고 잘못작성된 부분 있으면 수정 부탁드립니다.
//========
var:전일(20130303),매매일(20130404),일차매수가(1500),이차매수가(1420),매수금액(2000000);
var:일차손절(1470),이차손절(1390);
var:이차손절선아웃(0);
var:cnt(0),count(0);
var:매수수량(0),exit(0);
count =0;
for cnt = 0 to 20 {
if sdate == EntryDate(cnt) Then
count =count + 1;
}
//--
매수수량 =int(매수금액/c);
//--
##일차++++++
if stime == 150000 and sdate == 전일 and 이차손절선아웃 == 0 then {
if Nextbaropen <= 일차매수가 Then
buy("1-b1",atstop,일차매수가,매수수량);
Else
buy("1-b2",atlimit,일차매수가,매수수량);
}
if count ==0 and 매매일 == date and 이차손절선아웃 == 0 then {
if H< 일차매수가 Then
buy("1-b1-2",atstop,일차매수가,매수수량);
if L> 일차매수가 Then
buy("1-b2-2",atlimit,일차매수가,매수수량);
}
//--------------------------------//
If MarketPosition ==1 Then
{
//
exit=int(MaxContracts*0.5);
//
if currentcontracts == maxcontracts Then
exitlong("1-b+x1",atlimit,Entryprice*1.03,"",exit,1);
//
if currentcontracts < Maxcontracts Then
exitlong("1-b+x2",atlimit,entryprice * 1.07);
//
if CurrentEntries ==1 Then
{
exitlong("1-b-x1",AtStop,일차손절,"",Exit,1);
messagelog("일차손절 %.f",일차손절);
이차손절선아웃 =0;
}
//2차매수 ****
if currententries ==1 and 이차손절선아웃 ==0
and countif(CurrentContracts > currentcontract [1],BarsSinceEntry) < 4 Then //이렇게하면 3회까지만 추가매수될줄 알았습니다만..
# if currententries ==1 or currententries ==2 Then
{
buy("2-b1",atlimit,이차매수가,exit);
messagelog("이차매수가 %.f",이차매수가);
messagelog("이차손절선아웃 %.f",이차손절선아웃);
}
//
If CurrentEntries ==2 or currentEntries ==1 Then
{
exitlong("2-b1+x1",atlimit,entryprice*1.03,"",exit,1);
}
//
if currentcontracts < Maxcontracts Then
{
exitlong("2-b1+x2",atlimit,entryprice * 1.07);
}
//
if CurrentEntries ==2 or currentEntries == 1 Then
{
//
exitlong("2-bx-all",atstop,이차손절); //
이차손절선아웃=1;
}
}
//========
- 1. 예스질문-2차재진입횟수.JPG (0.07 MB)
답변 1
예스스탁 예스스탁 답변
2013-04-11 18:28:59
안녕하세요
예스스탁입니다.
모든 포지션 함수는 봉완성시에 최종값을 리턴합니다.
하나의 봉에서 exit만큼 진입과 청산이 발생하면
최종 수량이 모두 동일하므로
CurrentContracts > currentcontract[1]가 성립하지 않습니다.
그러므로 계속 CurrentEntries가 1이 됩니다.
또한 손절청산들이 지정한 값 이하이면 무조건 청산이므로
2차 매수가가 손절보다 작으므로 무조건 발생하게 됩니다.
첫진입과 같이 모든 진입과 청산식을 지정한 값보다 가격이 위에 있다가
내려올때로 지정하셔야 합니다.
또한 이차손절선아웃에 1이 할당되는 것이 현재진입횟수가 1 아니면 2면 무조건 할당되게 되어 있습니다.
이차손절선아웃에 1이 할당되는 것은 if조건만 만족하면 저장이 됩니다.
해당 내용은 식상에서 삭제했습니다.
var:전일(20130303),매매일(20130404),일차매수가(1500),이차매수가(1420),매수금액(2000000);
var:일차손절(1470),이차손절(1390);
var:이차손절선아웃(0);
var:cnt(0),count(0);
var:매수수량(0),exit(0);
count =0;
for cnt = 0 to 20 {
if sdate == EntryDate(cnt) Then
count =count + 1;
}
//--
매수수량 =int(매수금액/c);
//--
##일차++++++
if stime == 150000 and MarketPosition == 0 and sdate == 전일 and 이차손절선아웃 == 0 then {
if Nextbaropen <= 일차매수가 Then
buy("1-b1",atstop,일차매수가,매수수량);
Else
buy("1-b2",atlimit,일차매수가,매수수량);
}
if count ==0 and MarketPosition == 0 and 매매일 == date and 이차손절선아웃 == 0 then {
if H< 일차매수가 Then
buy("1-b1-2",atstop,일차매수가,매수수량);
if L> 일차매수가 Then
buy("1-b2-2",atlimit,일차매수가,매수수량);
}
//--------------------------------//
If MarketPosition ==1 Then
{
//
exit=int(MaxContracts*0.5);
//
if currentcontracts == maxcontracts Then
exitlong("1-b+x1",atlimit,Entryprice*1.03,"",exit,1);
//
if currentcontracts < Maxcontracts Then
exitlong("1-b+x2",atlimit,entryprice * 1.07);
//
if MaxEntries == 1 and L > 일차손절 Then
{
exitlong("1-b-x1",AtStop,일차손절,"",Exit,1);
# messagelog("일차손절 %.f",일차손절);
}
//2차매수 ****
if currententries >= 1 and currententries < 3 Then
{
if L > 이차매수가 Then
buy("2-b1",atlimit,이차매수가,exit);
}
//
If CurrentEntries ==2 or currentEntries ==1 Then
{
exitlong("2-b1+x1",atlimit,entryprice*1.03,"",exit,1);
}
//
if currentcontracts < Maxcontracts Then
{
exitlong("2-b1+x2",atlimit,entryprice * 1.07);
}
//
if currentEntries >= 1 Then
{
//
exitlong("2-bx-all",atstop,이차손절); //
}
}
//========
즐거운 하루되세요
즐거운 하루되세요
> 비엔에프 님이 쓴 글입니다.
> 제목 : 시스템식 질문입니다.
> 어제 답변해주신 말씀보고 다시 확인하니 피라미딩이 허용안함에 체크되서 안됬던거 같습니다.
>>
답변을 참조로 2차분할매수손절 식을 작성해보았습니다.
종목은 우수AMS 13년 4월4일 매매에다 적용해보았습니다. 전에 질문드린날이랑 같은 그런데 위에 그림처럼 2차 분할매수가 계속반복되서 들어가는거 같습니다. 2차분할매수인
"2-b1"이 3번미만 진입하게 하려면 어떻게 수정해야되는지 문의드립니다.
만약 3차분할매수손절식을 작성한다해도 큰 흐름은 차이 없겠지여?
또 식을 보시고 잘못작성된 부분 있으면 수정 부탁드립니다.
//========
var:전일(20130303),매매일(20130404),일차매수가(1500),이차매수가(1420),매수금액(2000000);
var:일차손절(1470),이차손절(1390);
var:이차손절선아웃(0);
var:cnt(0),count(0);
var:매수수량(0),exit(0);
count =0;
for cnt = 0 to 20 {
if sdate == EntryDate(cnt) Then
count =count + 1;
}
//--
매수수량 =int(매수금액/c);
//--
##일차++++++
if stime == 150000 and sdate == 전일 and 이차손절선아웃 == 0 then {
if Nextbaropen <= 일차매수가 Then
buy("1-b1",atstop,일차매수가,매수수량);
Else
buy("1-b2",atlimit,일차매수가,매수수량);
}
if count ==0 and 매매일 == date and 이차손절선아웃 == 0 then {
if H< 일차매수가 Then
buy("1-b1-2",atstop,일차매수가,매수수량);
if L> 일차매수가 Then
buy("1-b2-2",atlimit,일차매수가,매수수량);
}
//--------------------------------//
If MarketPosition ==1 Then
{
//
exit=int(MaxContracts*0.5);
//
if currentcontracts == maxcontracts Then
exitlong("1-b+x1",atlimit,Entryprice*1.03,"",exit,1);
//
if currentcontracts < Maxcontracts Then
exitlong("1-b+x2",atlimit,entryprice * 1.07);
//
if CurrentEntries ==1 Then
{
exitlong("1-b-x1",AtStop,일차손절,"",Exit,1);
messagelog("일차손절 %.f",일차손절);
이차손절선아웃 =0;
}
//2차매수 ****
if currententries ==1 and 이차손절선아웃 ==0
and countif(CurrentContracts > currentcontract [1],BarsSinceEntry) < 4 Then //이렇게하면 3회까지만 추가매수될줄 알았습니다만..
# if currententries ==1 or currententries ==2 Then
{
buy("2-b1",atlimit,이차매수가,exit);
messagelog("이차매수가 %.f",이차매수가);
messagelog("이차손절선아웃 %.f",이차손절선아웃);
}
//
If CurrentEntries ==2 or currentEntries ==1 Then
{
exitlong("2-b1+x1",atlimit,entryprice*1.03,"",exit,1);
}
//
if currentcontracts < Maxcontracts Then
{
exitlong("2-b1+x2",atlimit,entryprice * 1.07);
}
//
if CurrentEntries ==2 or currentEntries == 1 Then
{
//
exitlong("2-bx-all",atstop,이차손절); //
이차손절선아웃=1;
}
}
//========
다음글
이전글