커뮤니티

다시 여쭤봅니다.

프로필 이미지
아로마
2009-06-08 11:38:27
586
글번호 22654
답변완료

첨부 이미지

안녕하세요. 답변 감사드립니다. 1-1. 모든 진입신호 허용으로 적용하였습니다. 1-2. 추가진입의 경우, 제가 의도하는 바는 차트에서 청산신호가 나오지 않아야 하는데 작성된 식을 적용하면 첫 진입 후 대부분 '매수(도) 수익1'로 청산됩니다. 차트를 첨부하였습니다. 이때 첫 진입시의 손절, 추가진입기준이 되는 atr이 1포인트입니다 (여러배수로 테스트해보고 있습니다). 그런데 추가진입이 일어나기 전에 청산되어졌습니다. 제가 의도하는 바를 잘 설명드리지 못한 면이 있나해서 다시 여쭤봅니다. 매수의 경우(일괄청산시)- 100에 진입신호가 나옵니다. 이때 손절,피라미딩의 기준이 되는 atr이 1입니다. 가격이 101까지 오르지 못하고 atr만큼 떨어졌습니다(99에 1계약청산). 그런데 가격이 99까지 안떨어지고 가격이 101로 올랐습니다. 추가 1계약 진입합니다. 이제 101에서 atr만큼 하락할 때 모두 청산하고자 합니다(100에 2계약청산). 100까지 안떨어지면 청산안합니다. 그런데 100까지 안떨어지고 102가 되었습니다. 추가 1계약 진입합니다. 이제 102에서 atr만큼 하락할 때 모두 청산하고자 합니다(101에 3계약청산). 101가지 안떨어지면 청산안합니다. 감사합니다. > 예스스탁 님이 쓴 글입니다. > 제목 : Re : 분할진입 문의드립니다. > 안녕하세요 예스스탁입니다. 1. 포지션을 누적하기 위해서는 시스템 트레이딩 설정창에 피라미딩을 모든 진입 신호 허용으로 설정하셔야 합니다. 설정하면 정상적으로 신호가 발생합니다. 다만 이식은 추가진입과 일괄청산(목표이익)이 겹치는 부분이 있습니다. 예를 들어 매수의 경우 매수진입후 Var8 = atr(60)만큼 가격이 상승할때마다 추가진입 4회까지 매수의 경우 추가 진입할 때마다 Var8 = atr(60)만큼 청산가격을 올리는 방식 으로 추기집입분과 청산의 경우가 겹치는 부분이 많아 추가진입이 일어나기 힙듭니다. 그래서 전체 거래에서 분할진입을 많이 보실 수 없습니다. 2. 추가로 4번 진입을 막으시려면 추가 진입식의 CurrentEntries < 4 를 삭제하시면 됩니다. 다만 이경우 분할로 청산하기 위해서는 횟수를 이용해야 하는데 분할진입횟수 산정이 어려워 분할청산식 작성이 어렵습니다. 즐거운 하루되세요 > 아로마 님이 쓴 글입니다. > 제목 : 분할진입 문의드립니다. > 안녕하세요. 항상 수고가 많으십니다. 그리고 친절한 답변에 감사드립니다. 얼마전 질문드린 피라미딩에 관한 식(10857번글 : 아래에 붙여놨습니다)을 적용해보니 첫번째 진입 후 피라미딩이 일어나지 않고 곧바로 손절되거나 '매수(도) 수익1'로 청산됩니다. 왜 그런지 이유를 잘 모르겠습니다. 아래와 같이 다시 질문을 드립니다. 1) 일괄청산(매수의 경우) 첫번째 진입의 손절은 진입시점의 atr만큼 하락시 실행. 진입시점의 atr만큼 상승시 추가진입. 추가진입이 이루어질때마다 일괄청산 가격도 atr만큼씩 상향 이동. 예)진입시점의 atr : 1 첫번째 진입;100(1계약) / 청산 99(전체 1계약) 두번째 진입; 101(1계약) / 청산 100(전체 2계약) 세번째 진입; 102(1계약) / 청산 101(전체 3계약) 네번까지 진입하는 경우와 종가청산전까지 계속 이루어지는 경우 2가지로 알아보고자 합니다. 2) 분할청산(매수의 경우) 청산은 진입한 가격에서 각각 atr만큼 하락시 실행. 첫번째 진입;100(1계약) / 청산 99(전체 1계약) 두번째 진입; 101(1계약) / 청산 100(전체 1계약) 세번째 진입; 102(1계약) / 청산 101(전체 1계약) 네번까지 진입하는 경우와 종가청산전까지 계속 이루어지는 경우 2가지로 알아보고자 합니다. 아래는 10857번글입니다. 지난 번 식은 4회까지 분할진입하는 경우였는데 횟수 제한없이 종가청산전까지 추가진입하는 경우도 부탁드립니다. 감사합니다... 안녕하세요 예스스탁입니다. 1. input : 자본금(50000000); var : 매매당손절금액(0),진입시점의변동성(0),주문가능계약수(0); var : cond(false,data2); var : BEP(0),SEP(0); var1 = data2(c); var2 = data2(h); var3 = data2(L); Var4 = Lowest(close,100)[1]; Var5 = Lowest(close,100)[1]; Var6 = Highest(close,100)[1]; Var7 = Highest(close,100)[1]; Var8 = atr(60); 매매당손절금액 = int(자본금*0.02); 진입시점의변동성 = var8*500000; 주문가능계약수 = int(매매당손절금액/진입시점의변동성); if stime > 100000 and stime < 140000 Then{ if MarketPosition == 0 and data2(c)>data2(o) and data2(c)>data2(dayhigh[1]) and data2(c) > data2(o) and data2(C[1]) > data2(o[1]) and data2(c[2]) > data2(o[2]) and data2(c[3]) > data2(o[3]) then{ buy("매수",OnClose,def,주문가능계약수); } } if stime > 100000 and stime < 140000 Then{ if MarketPosition == 0 and data2(c)<data2(o) and data2(c)<data2(daylow[1]) then sell("매도",OnClose,def,주문가능계약수); } if MarketPosition == 1 and CurrentEntries < 4 and CountIF(CurrentEntries< CurrentEntries[1],BarsSinceEntry) < 1 Then{ buy("추가매수",AtStop,EntryPrice+var8[BarsSinceEntry]*CurrentEntries,주문가능계약수[BarsSinceEntry]); } if MarketPosition == -1 and CurrentEntries < 4 and CountIF(CurrentEntries< CurrentEntries[1],BarsSinceEntry) < 1 Then{ Sell("추가매도",AtStop,EntryPrice-var8[BarsSinceEntry]*CurrentEntries,주문가능계약수[BarsSinceEntry]); } if MarketPosition == 1 Then{ if CurrentEntries > CurrentEntries[1] Then BEP = C; if CurrentEntries == 1 Then{ Exitlong("매수손절1",AtStop,EntryPrice-var8[BarsSinceEntry],"",주문가능계약수[BarsSinceEntry],1); Exitlong("매수수익1",AtLimit,BEP+var8); } if CurrentEntries == 2 Then{ Exitlong("매수손절2",AtStop,EntryPrice,"",주문가능계약수[BarsSinceEntry],1); Exitlong("매수수익2",AtLimit,BEP+var8); } if CurrentEntries == 3 Then{ Exitlong("매수손절3",AtStop,EntryPrice+var8[BarsSinceEntry],"",주문가능계약수[BarsSinceEntry],1); Exitlong("매수수익3",AtLimit,BEP+var8); } if CurrentEntries == 4 Then{ Exitlong("매수손절4",AtStop,EntryPrice+var8[BarsSinceEntry]*2,"",주문가능계약수[BarsSinceEntry],1); Exitlong("매수수익4",AtLimit,BEP+var8); } if stime > 100500 and stime < 143000 then { If CrossDown(close,Var4) Then ExitLong("매수반대청산1",Onclose); } } if MarketPosition == -1 Then{ if CurrentEntries > CurrentEntries[1] Then SEP = C; if CurrentEntries == 1 Then{ ExitShort("매도손절1",AtStop,EntryPrice+var8[BarsSinceEntry],"",주문가능계약수[BarsSinceEntry],1); ExitShort("매도수익1",atlimit,SEP-var8); } if CurrentEntries == 2 Then{ ExitShort("매도손절2",AtStop,EntryPrice,"",주문가능계약수[BarsSinceEntry],1); ExitShort("매도수익2",atlimit,SEP-var8); } if CurrentEntries == 3 Then{ ExitShort("매도손절3",AtStop,EntryPrice-var8[BarsSinceEntry],"",주문가능계약수[BarsSinceEntry],1); ExitShort("매도수익3",atlimit,SEP-var8); } if CurrentEntries == 4 Then{ ExitShort("매도손절4",AtStop,EntryPrice-var8[BarsSinceEntry]*2,"",주문가능계약수[BarsSinceEntry],1); ExitShort("매도수익4",atlimit,SEP-var8); } if stime > 100500 and stime < 140000 then { If Crossup(close,Var6) Then ExitShort("매도반대청산1",Onclose); } } SetStopEndofday(150400); 2. input : 자본금(50000000); var : 매매당손절금액(0),진입시점의변동성(0),주문가능계약수(0); var : cond(false,data2); var : BEP(0),SEP(0); var1 = data2(c); var2 = data2(h); var3 = data2(L); Var4 = Lowest(close,100)[1]; Var5 = Lowest(close,100)[1]; Var6 = Highest(close,100)[1]; Var7 = Highest(close,100)[1]; Var8 = atr(60); 매매당손절금액 = int(자본금*0.02); 진입시점의변동성 = var8*500000; 주문가능계약수 = int(매매당손절금액/진입시점의변동성); if stime > 100000 and stime < 140000 Then{ if MarketPosition == 0 and data2(c)>data2(o) and data2(c)>data2(dayhigh[1]) and data2(c) > data2(o) and data2(C[1]) > data2(o[1]) and data2(c[2]) > data2(o[2]) and data2(c[3]) > data2(o[3]) then{ buy("매수",OnClose,def,주문가능계약수); } } if stime > 100000 and stime < 140000 Then{ if MarketPosition == 0 and data2(c)<data2(o) and data2(c)<data2(daylow[1]) then sell("매도",OnClose,def,주문가능계약수); } if MarketPosition == 1 and CurrentEntries < 4 and CountIF(CurrentEntries< CurrentEntries[1],BarsSinceEntry) < 1 Then{ buy("추가매수",AtStop,EntryPrice+var8[BarsSinceEntry]*CurrentEntries,주문가능계약수[BarsSinceEntry]); } if MarketPosition == -1 and CurrentEntries < 4 and CountIF(CurrentEntries< CurrentEntries[1],BarsSinceEntry) < 1 Then{ Sell("추가매도",AtStop,EntryPrice-var8[BarsSinceEntry]*CurrentEntries,주문가능계약수[BarsSinceEntry]); } if MarketPosition == 1 Then{ if CurrentEntries > CurrentEntries[1] Then BEP = C; if CurrentEntries == 1 Then{ Exitlong("매수손절1",AtStop,EntryPrice-var8[BarsSinceEntry],"",주문가능계약수[BarsSinceEntry],1); Exitlong("매수수익1",AtLimit,BEP+var8); } if CurrentEntries == 2 Then{ Exitlong("매수손절2",AtStop,EntryPrice,"",주문가능계약수[BarsSinceEntry],1); Exitlong("매수수익2",AtLimit,BEP+var8); } if CurrentEntries == 3 Then{ Exitlong("매수손절3",AtStop,EntryPrice+var8[BarsSinceEntry],"",주문가능계약수[BarsSinceEntry],1); Exitlong("매수수익3",AtLimit,BEP+var8); } if CurrentEntries == 4 Then{ Exitlong("매수손절4",AtStop,EntryPrice+var8[BarsSinceEntry]*2,"",주문가능계약수[BarsSinceEntry],1); Exitlong("매수수익4",AtLimit,BEP+var8); } if stime > 100500 and stime < 143000 then { If CrossDown(close,Var4) Then ExitLong("매수반대청산1",Onclose); } } if MarketPosition == -1 Then{ if CurrentEntries > CurrentEntries[1] Then SEP = C; if CurrentEntries == 1 Then{ ExitShort("매도손절1",AtStop,EntryPrice+var8[BarsSinceEntry],"",주문가능계약수[BarsSinceEntry],1); ExitShort("매도수익1",atlimit,SEP-var8); } if CurrentEntries == 2 Then{ ExitShort("매도손절2",AtStop,EntryPrice,"",주문가능계약수[BarsSinceEntry],1); ExitShort("매도수익2",atlimit,SEP-var8); } if CurrentEntries == 3 Then{ ExitShort("매도손절3",AtStop,EntryPrice-var8[BarsSinceEntry],"",주문가능계약수[BarsSinceEntry],1); ExitShort("매도수익3",atlimit,SEP-var8); } if CurrentEntries == 4 Then{ ExitShort("매도손절4",AtStop,EntryPrice-var8[BarsSinceEntry]*2,"",주문가능계약수[BarsSinceEntry],1); ExitShort("매도수익4",atlimit,SEP-var8); } if stime > 100500 and stime < 140000 then { If Crossup(close,Var6) Then ExitShort("매도반대청산1",Onclose); } } SetStopEndofday(150400); 즐거운 하루되세요 > 아로마 님이 쓴 글입니다. > 제목 : 수식부탁드립니다. > 안녕하세요. 혹시나해서 다시 글을 올려봅니다. 항상 수고가 많으십니다. 아래의 식에서 분할진입을 적용해보고 싶습니다. 제가 수식을 작성해보려고 하는데 잘 안되서 도움을 부탁드립니다. input : 자본금(50000000); var : 매매당손절금액(0),진입시점의변동성(0),주문가능계약수(0); 매매당손절금액 = int(자본금*0.02); 진입시점의변동성 = var8*500000; 주문가능계약수 = int(매매당손절금액/진입시점의변동성); var : cond(false,data2); var1 = data2(c); var2 = data2(h); var3 = data2(L); Var4 = Lowest(close,100)[1]; Var5 = Lowest(close,100)[1]; Var6 = Highest(close,100)[1]; Var7 = Highest(close,100)[1]; Var8 = atr(60); if stime > 100000 and stime < 140000 Then{ if data2(date) != data2(date[3]) Then cond = False; if data2(c)>data2(o) and data2(c)>data2(dayhigh[1]) Then{ cond = True; if cond == True and data2(c) > data2(o) and data2(C[1]) > data2(o[1]) and data2(c[2]) > data2(o[2]) and data2(c[3]) > data2(o[3]) then{ buy("매수",OnClose,def,주문가능계약수); cond = False; }}} if stime > 100000 and stime < 140000 Then{ if data2(c)<data2(o) and data2(c)<data2(daylow[1]) then sell("매도",OnClose,def,주문가능계약수); } if MarketPosition == 1 Then{ Exitlong("매수손절",AtStop,EntryPrice-var8[BarsSinceEntry]); if stime > 100500 and stime < 143000 then { If CrossDown(close,Var4) Then ExitLong("매수반대청산1",Onclose); SetStopEndofday(150400); } } if MarketPosition == -1 Then{ ExitShort("매도손절",AtStop,EntryPrice+var8[BarsSinceEntry]); if stime > 100500 and stime < 140000 then { If Crossup(close,Var6) Then ExitShort("매도반대청산1",Onclose); SetStopEndofday(150400); } } 위의 식에서 추가진입은 균등한 계약수로 매수진입후 Var8 = atr(60)만큼 가격이 상승할때마다 추가진입 4회까지 매도진입후 Var8 = atr(60)만큼 가격이 하락할때마다 추가진입 4회까지 청산은 두가지 경우로 작성 부탁드립니다. 어느 것이 더 나은지 알아보고자 합니다. 1)일괄청산 매수의 경우 추가 진입할 때마다 Var8 = atr(60)만큼 청산가격을 올리는 방식 매도의 경우 추가 진입할 때마다 Var8 = atr(60)만큼 청산가격을 내리는 방식 2)분할청산 각각의 진입에 대한 손절은 각각의 진입가격대비 Var8 = atr(60)만큼 손실이 날 때 위의 1),2)청산조건을 제외하고는 원래의 식에서 설정한 조건에 맞으면 일괄청산되게 적용하고자 합니다. 감사합니다...
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2009-06-08 17:13:13

안녕하세요 예스스탁입니다. 우선 식을 손절과 파리미딩으로만 구성해 봤습니다. 기존식은 추가진입과 목표이익이 조건이 동일했습니다. 목표이익조건을 제외했습니다. input : 자본금(50000000),N(1); var : 매매당손절금액(0),진입시점의변동성(0),주문가능계약수(0); var : cond(false,data2); var : BEP(0),SEP(0); var1 = data2(c); var2 = data2(h); var3 = data2(L); Var4 = Lowest(close,100)[1]; Var5 = Lowest(close,100)[1]; Var6 = Highest(close,100)[1]; Var7 = Highest(close,100)[1]; Var8 = atr(60); 매매당손절금액 = int(자본금*0.02); 진입시점의변동성 = var8*500000; 주문가능계약수 = int(매매당손절금액/진입시점의변동성); if stime > 100000 and stime < 140000 and MarketPosition == 0 Then{ if data2(c)>data2(o) and data2(c)>data2(dayhigh[1]) and data2(c) > data2(o) and data2(C[1]) > data2(o[1]) and data2(c[2]) > data2(o[2]) and data2(c[3]) > data2(o[3]) then{ buy("매수",OnClose,def,주문가능계약수); } if data2(c)<data2(o) and data2(c)<data2(daylow[1]) then sell("매도",OnClose,def,주문가능계약수); } if stime > 100000 and stime < 140000 Then{ } if MarketPosition == 1 and CurrentEntries < 4 and CountIF(CurrentEntries< CurrentEntries[1],BarsSinceEntry) < 1 Then{ buy("추가매수",AtStop,EntryPrice+(N*var8[BarsSinceEntry])*CurrentEntries,주문가능계약수[BarsSinceEntry]); } if MarketPosition == -1 and CurrentEntries < 4 and CountIF(CurrentEntries< CurrentEntries[1],BarsSinceEntry) < 1 Then{ Sell("추가매도",AtStop,EntryPrice-(N*var8[BarsSinceEntry])*CurrentEntries,주문가능계약수[BarsSinceEntry]); } if MarketPosition == 1 Then{ if CurrentEntries == 1 Then exitlong("BX1",AtStop,EntryPrice-((N*var8[BarsSinceEntry])*CurrentEntries)); if CurrentEntries == 2 Then exitlong("BX2",AtStop,EntryPrice-((N*var8[BarsSinceEntry])*CurrentEntries)); if CurrentEntries == 3 Then exitlong("BX3",AtStop,EntryPrice-((N*var8[BarsSinceEntry])*CurrentEntries)); if CurrentEntries == 4 Then exitlong("BX4",AtStop,EntryPrice-((N*var8[BarsSinceEntry])*CurrentEntries)); } if MarketPosition == -1 Then{ if CurrentEntries == 1 Then ExitShort("SX1",AtStop,EntryPrice+((N*var8[BarsSinceEntry])*CurrentEntries)); if CurrentEntries == 2 Then ExitShort("SX2",AtStop,EntryPrice+((N*var8[BarsSinceEntry])*CurrentEntries)); if CurrentEntries == 3 Then ExitShort("SX3",AtStop,EntryPrice+((N*var8[BarsSinceEntry])*CurrentEntries)); if CurrentEntries == 4 Then ExitShort("SX4",AtStop,EntryPrice+((N*var8[BarsSinceEntry])*CurrentEntries)); } SetStopEndofday(150400); 의도와 다르시면 webmaster@yesstock.com으로 전화번호를 보내주시면 자세한 사항을 유선으로 듣고 변경해 드리도록 하겠습니다. 즐거운 하루되세요 > 아로마 님이 쓴 글입니다. > 제목 : 다시 여쭤봅니다. > 안녕하세요. 답변 감사드립니다. 1-1. 모든 진입신호 허용으로 적용하였습니다. 1-2. 추가진입의 경우, 제가 의도하는 바는 차트에서 청산신호가 나오지 않아야 하는데 작성된 식을 적용하면 첫 진입 후 대부분 '매수(도) 수익1'로 청산됩니다. 차트를 첨부하였습니다. 이때 첫 진입시의 손절, 추가진입기준이 되는 atr이 1포인트입니다 (여러배수로 테스트해보고 있습니다). 그런데 추가진입이 일어나기 전에 청산되어졌습니다. 제가 의도하는 바를 잘 설명드리지 못한 면이 있나해서 다시 여쭤봅니다. 매수의 경우(일괄청산시)- 100에 진입신호가 나옵니다. 이때 손절,피라미딩의 기준이 되는 atr이 1입니다. 가격이 101까지 오르지 못하고 atr만큼 떨어졌습니다(99에 1계약청산). 그런데 가격이 99까지 안떨어지고 가격이 101로 올랐습니다. 추가 1계약 진입합니다. 이제 101에서 atr만큼 하락할 때 모두 청산하고자 합니다(100에 2계약청산). 100까지 안떨어지면 청산안합니다. 그런데 100까지 안떨어지고 102가 되었습니다. 추가 1계약 진입합니다. 이제 102에서 atr만큼 하락할 때 모두 청산하고자 합니다(101에 3계약청산). 101가지 안떨어지면 청산안합니다. 감사합니다. > 예스스탁 님이 쓴 글입니다. > 제목 : Re : 분할진입 문의드립니다. > 안녕하세요 예스스탁입니다. 1. 포지션을 누적하기 위해서는 시스템 트레이딩 설정창에 피라미딩을 모든 진입 신호 허용으로 설정하셔야 합니다. 설정하면 정상적으로 신호가 발생합니다. 다만 이식은 추가진입과 일괄청산(목표이익)이 겹치는 부분이 있습니다. 예를 들어 매수의 경우 매수진입후 Var8 = atr(60)만큼 가격이 상승할때마다 추가진입 4회까지 매수의 경우 추가 진입할 때마다 Var8 = atr(60)만큼 청산가격을 올리는 방식 으로 추기집입분과 청산의 경우가 겹치는 부분이 많아 추가진입이 일어나기 힙듭니다. 그래서 전체 거래에서 분할진입을 많이 보실 수 없습니다. 2. 추가로 4번 진입을 막으시려면 추가 진입식의 CurrentEntries < 4 를 삭제하시면 됩니다. 다만 이경우 분할로 청산하기 위해서는 횟수를 이용해야 하는데 분할진입횟수 산정이 어려워 분할청산식 작성이 어렵습니다. 즐거운 하루되세요 > 아로마 님이 쓴 글입니다. > 제목 : 분할진입 문의드립니다. > 안녕하세요. 항상 수고가 많으십니다. 그리고 친절한 답변에 감사드립니다. 얼마전 질문드린 피라미딩에 관한 식(10857번글 : 아래에 붙여놨습니다)을 적용해보니 첫번째 진입 후 피라미딩이 일어나지 않고 곧바로 손절되거나 '매수(도) 수익1'로 청산됩니다. 왜 그런지 이유를 잘 모르겠습니다. 아래와 같이 다시 질문을 드립니다. 1) 일괄청산(매수의 경우) 첫번째 진입의 손절은 진입시점의 atr만큼 하락시 실행. 진입시점의 atr만큼 상승시 추가진입. 추가진입이 이루어질때마다 일괄청산 가격도 atr만큼씩 상향 이동. 예)진입시점의 atr : 1 첫번째 진입;100(1계약) / 청산 99(전체 1계약) 두번째 진입; 101(1계약) / 청산 100(전체 2계약) 세번째 진입; 102(1계약) / 청산 101(전체 3계약) 네번까지 진입하는 경우와 종가청산전까지 계속 이루어지는 경우 2가지로 알아보고자 합니다. 2) 분할청산(매수의 경우) 청산은 진입한 가격에서 각각 atr만큼 하락시 실행. 첫번째 진입;100(1계약) / 청산 99(전체 1계약) 두번째 진입; 101(1계약) / 청산 100(전체 1계약) 세번째 진입; 102(1계약) / 청산 101(전체 1계약) 네번까지 진입하는 경우와 종가청산전까지 계속 이루어지는 경우 2가지로 알아보고자 합니다. 아래는 10857번글입니다. 지난 번 식은 4회까지 분할진입하는 경우였는데 횟수 제한없이 종가청산전까지 추가진입하는 경우도 부탁드립니다. 감사합니다... 안녕하세요 예스스탁입니다. 1. input : 자본금(50000000); var : 매매당손절금액(0),진입시점의변동성(0),주문가능계약수(0); var : cond(false,data2); var : BEP(0),SEP(0); var1 = data2(c); var2 = data2(h); var3 = data2(L); Var4 = Lowest(close,100)[1]; Var5 = Lowest(close,100)[1]; Var6 = Highest(close,100)[1]; Var7 = Highest(close,100)[1]; Var8 = atr(60); 매매당손절금액 = int(자본금*0.02); 진입시점의변동성 = var8*500000; 주문가능계약수 = int(매매당손절금액/진입시점의변동성); if stime > 100000 and stime < 140000 Then{ if MarketPosition == 0 and data2(c)>data2(o) and data2(c)>data2(dayhigh[1]) and data2(c) > data2(o) and data2(C[1]) > data2(o[1]) and data2(c[2]) > data2(o[2]) and data2(c[3]) > data2(o[3]) then{ buy("매수",OnClose,def,주문가능계약수); } } if stime > 100000 and stime < 140000 Then{ if MarketPosition == 0 and data2(c)<data2(o) and data2(c)<data2(daylow[1]) then sell("매도",OnClose,def,주문가능계약수); } if MarketPosition == 1 and CurrentEntries < 4 and CountIF(CurrentEntries< CurrentEntries[1],BarsSinceEntry) < 1 Then{ buy("추가매수",AtStop,EntryPrice+var8[BarsSinceEntry]*CurrentEntries,주문가능계약수[BarsSinceEntry]); } if MarketPosition == -1 and CurrentEntries < 4 and CountIF(CurrentEntries< CurrentEntries[1],BarsSinceEntry) < 1 Then{ Sell("추가매도",AtStop,EntryPrice-var8[BarsSinceEntry]*CurrentEntries,주문가능계약수[BarsSinceEntry]); } if MarketPosition == 1 Then{ if CurrentEntries > CurrentEntries[1] Then BEP = C; if CurrentEntries == 1 Then{ Exitlong("매수손절1",AtStop,EntryPrice-var8[BarsSinceEntry],"",주문가능계약수[BarsSinceEntry],1); Exitlong("매수수익1",AtLimit,BEP+var8); } if CurrentEntries == 2 Then{ Exitlong("매수손절2",AtStop,EntryPrice,"",주문가능계약수[BarsSinceEntry],1); Exitlong("매수수익2",AtLimit,BEP+var8); } if CurrentEntries == 3 Then{ Exitlong("매수손절3",AtStop,EntryPrice+var8[BarsSinceEntry],"",주문가능계약수[BarsSinceEntry],1); Exitlong("매수수익3",AtLimit,BEP+var8); } if CurrentEntries == 4 Then{ Exitlong("매수손절4",AtStop,EntryPrice+var8[BarsSinceEntry]*2,"",주문가능계약수[BarsSinceEntry],1); Exitlong("매수수익4",AtLimit,BEP+var8); } if stime > 100500 and stime < 143000 then { If CrossDown(close,Var4) Then ExitLong("매수반대청산1",Onclose); } } if MarketPosition == -1 Then{ if CurrentEntries > CurrentEntries[1] Then SEP = C; if CurrentEntries == 1 Then{ ExitShort("매도손절1",AtStop,EntryPrice+var8[BarsSinceEntry],"",주문가능계약수[BarsSinceEntry],1); ExitShort("매도수익1",atlimit,SEP-var8); } if CurrentEntries == 2 Then{ ExitShort("매도손절2",AtStop,EntryPrice,"",주문가능계약수[BarsSinceEntry],1); ExitShort("매도수익2",atlimit,SEP-var8); } if CurrentEntries == 3 Then{ ExitShort("매도손절3",AtStop,EntryPrice-var8[BarsSinceEntry],"",주문가능계약수[BarsSinceEntry],1); ExitShort("매도수익3",atlimit,SEP-var8); } if CurrentEntries == 4 Then{ ExitShort("매도손절4",AtStop,EntryPrice-var8[BarsSinceEntry]*2,"",주문가능계약수[BarsSinceEntry],1); ExitShort("매도수익4",atlimit,SEP-var8); } if stime > 100500 and stime < 140000 then { If Crossup(close,Var6) Then ExitShort("매도반대청산1",Onclose); } } SetStopEndofday(150400); 2. input : 자본금(50000000); var : 매매당손절금액(0),진입시점의변동성(0),주문가능계약수(0); var : cond(false,data2); var : BEP(0),SEP(0); var1 = data2(c); var2 = data2(h); var3 = data2(L); Var4 = Lowest(close,100)[1]; Var5 = Lowest(close,100)[1]; Var6 = Highest(close,100)[1]; Var7 = Highest(close,100)[1]; Var8 = atr(60); 매매당손절금액 = int(자본금*0.02); 진입시점의변동성 = var8*500000; 주문가능계약수 = int(매매당손절금액/진입시점의변동성); if stime > 100000 and stime < 140000 Then{ if MarketPosition == 0 and data2(c)>data2(o) and data2(c)>data2(dayhigh[1]) and data2(c) > data2(o) and data2(C[1]) > data2(o[1]) and data2(c[2]) > data2(o[2]) and data2(c[3]) > data2(o[3]) then{ buy("매수",OnClose,def,주문가능계약수); } } if stime > 100000 and stime < 140000 Then{ if MarketPosition == 0 and data2(c)<data2(o) and data2(c)<data2(daylow[1]) then sell("매도",OnClose,def,주문가능계약수); } if MarketPosition == 1 and CurrentEntries < 4 and CountIF(CurrentEntries< CurrentEntries[1],BarsSinceEntry) < 1 Then{ buy("추가매수",AtStop,EntryPrice+var8[BarsSinceEntry]*CurrentEntries,주문가능계약수[BarsSinceEntry]); } if MarketPosition == -1 and CurrentEntries < 4 and CountIF(CurrentEntries< CurrentEntries[1],BarsSinceEntry) < 1 Then{ Sell("추가매도",AtStop,EntryPrice-var8[BarsSinceEntry]*CurrentEntries,주문가능계약수[BarsSinceEntry]); } if MarketPosition == 1 Then{ if CurrentEntries > CurrentEntries[1] Then BEP = C; if CurrentEntries == 1 Then{ Exitlong("매수손절1",AtStop,EntryPrice-var8[BarsSinceEntry],"",주문가능계약수[BarsSinceEntry],1); Exitlong("매수수익1",AtLimit,BEP+var8); } if CurrentEntries == 2 Then{ Exitlong("매수손절2",AtStop,EntryPrice,"",주문가능계약수[BarsSinceEntry],1); Exitlong("매수수익2",AtLimit,BEP+var8); } if CurrentEntries == 3 Then{ Exitlong("매수손절3",AtStop,EntryPrice+var8[BarsSinceEntry],"",주문가능계약수[BarsSinceEntry],1); Exitlong("매수수익3",AtLimit,BEP+var8); } if CurrentEntries == 4 Then{ Exitlong("매수손절4",AtStop,EntryPrice+var8[BarsSinceEntry]*2,"",주문가능계약수[BarsSinceEntry],1); Exitlong("매수수익4",AtLimit,BEP+var8); } if stime > 100500 and stime < 143000 then { If CrossDown(close,Var4) Then ExitLong("매수반대청산1",Onclose); } } if MarketPosition == -1 Then{ if CurrentEntries > CurrentEntries[1] Then SEP = C; if CurrentEntries == 1 Then{ ExitShort("매도손절1",AtStop,EntryPrice+var8[BarsSinceEntry],"",주문가능계약수[BarsSinceEntry],1); ExitShort("매도수익1",atlimit,SEP-var8); } if CurrentEntries == 2 Then{ ExitShort("매도손절2",AtStop,EntryPrice,"",주문가능계약수[BarsSinceEntry],1); ExitShort("매도수익2",atlimit,SEP-var8); } if CurrentEntries == 3 Then{ ExitShort("매도손절3",AtStop,EntryPrice-var8[BarsSinceEntry],"",주문가능계약수[BarsSinceEntry],1); ExitShort("매도수익3",atlimit,SEP-var8); } if CurrentEntries == 4 Then{ ExitShort("매도손절4",AtStop,EntryPrice-var8[BarsSinceEntry]*2,"",주문가능계약수[BarsSinceEntry],1); ExitShort("매도수익4",atlimit,SEP-var8); } if stime > 100500 and stime < 140000 then { If Crossup(close,Var6) Then ExitShort("매도반대청산1",Onclose); } } SetStopEndofday(150400); 즐거운 하루되세요 > 아로마 님이 쓴 글입니다. > 제목 : 수식부탁드립니다. > 안녕하세요. 혹시나해서 다시 글을 올려봅니다. 항상 수고가 많으십니다. 아래의 식에서 분할진입을 적용해보고 싶습니다. 제가 수식을 작성해보려고 하는데 잘 안되서 도움을 부탁드립니다. input : 자본금(50000000); var : 매매당손절금액(0),진입시점의변동성(0),주문가능계약수(0); 매매당손절금액 = int(자본금*0.02); 진입시점의변동성 = var8*500000; 주문가능계약수 = int(매매당손절금액/진입시점의변동성); var : cond(false,data2); var1 = data2(c); var2 = data2(h); var3 = data2(L); Var4 = Lowest(close,100)[1]; Var5 = Lowest(close,100)[1]; Var6 = Highest(close,100)[1]; Var7 = Highest(close,100)[1]; Var8 = atr(60); if stime > 100000 and stime < 140000 Then{ if data2(date) != data2(date[3]) Then cond = False; if data2(c)>data2(o) and data2(c)>data2(dayhigh[1]) Then{ cond = True; if cond == True and data2(c) > data2(o) and data2(C[1]) > data2(o[1]) and data2(c[2]) > data2(o[2]) and data2(c[3]) > data2(o[3]) then{ buy("매수",OnClose,def,주문가능계약수); cond = False; }}} if stime > 100000 and stime < 140000 Then{ if data2(c)<data2(o) and data2(c)<data2(daylow[1]) then sell("매도",OnClose,def,주문가능계약수); } if MarketPosition == 1 Then{ Exitlong("매수손절",AtStop,EntryPrice-var8[BarsSinceEntry]); if stime > 100500 and stime < 143000 then { If CrossDown(close,Var4) Then ExitLong("매수반대청산1",Onclose); SetStopEndofday(150400); } } if MarketPosition == -1 Then{ ExitShort("매도손절",AtStop,EntryPrice+var8[BarsSinceEntry]); if stime > 100500 and stime < 140000 then { If Crossup(close,Var6) Then ExitShort("매도반대청산1",Onclose); SetStopEndofday(150400); } } 위의 식에서 추가진입은 균등한 계약수로 매수진입후 Var8 = atr(60)만큼 가격이 상승할때마다 추가진입 4회까지 매도진입후 Var8 = atr(60)만큼 가격이 하락할때마다 추가진입 4회까지 청산은 두가지 경우로 작성 부탁드립니다. 어느 것이 더 나은지 알아보고자 합니다. 1)일괄청산 매수의 경우 추가 진입할 때마다 Var8 = atr(60)만큼 청산가격을 올리는 방식 매도의 경우 추가 진입할 때마다 Var8 = atr(60)만큼 청산가격을 내리는 방식 2)분할청산 각각의 진입에 대한 손절은 각각의 진입가격대비 Var8 = atr(60)만큼 손실이 날 때 위의 1),2)청산조건을 제외하고는 원래의 식에서 설정한 조건에 맞으면 일괄청산되게 적용하고자 합니다. 감사합니다...