커뮤니티
수식수정 부탁드립니다.
2018-10-29 23:19:43
195
글번호 123185
아래의 그림에서 1차매수후 TR-Stop으로 손절을 당한 후 다시 1차매수가 되고 있는데
제가 원하는 것은 1차매수후 TR-Stop으로 손절을 당했다면 그 다음에는 BuySetup2 조건이 만족되었을 때 2차매수하는 것입니다. 수식 수정 부탁드립니다.
input : 셋업일(20170717),시작시간(090000),매수시간(150000),매수시간2(150000),종료일(20181231),P(20),Period3(14),dv(2),sto1(25),sto2(6),sto3(6),MAP(5),N(21),
금액1(1000000),금액2(2000000),목표수익1(1.024),목표수익2(1.024),절반매도(1.10),목표가(1000000),진입가격대비하락(0.97),손절가(100),스탑로스(6),TR스탑(0.95),밴드하단보정(1.03), RS과매수수준(60), RS과매도수준(40),고점대비하락(0.94);
var : BBup(0),BBdn(0),BBMid(0),stok(0),stoD(0),RS(0),BuySetup(true),BuySetup2(true),BuySetup3(true),ExitSetup1(false),Xcond(false),mav(0),Dncnt(0),BuySetupindex(0);
# 5일 이평선
mav = ma(C,MAP);
# RSI
RS = RSI(Period3);
# 볼린져밴드
BBup = BollBandUp(P,dv);
BBMid = ma(C,P);
BBdn = BollBandDown(P,dv);
# 스톡케스틱
stok = StochasticsK(sto1,sto2);
Stod = StochasticsD(sto1,sto2,sto3);
# 1차 매수조건
if TotalTrades > TotalTrades[1] Then
BuySetup = false;
if MaxEntries== 1 Then{
BuySetup = false;
}
if MarketPosition == 0 and (RS <RS과매도수준) and C< BBdn and (sDate >= 셋업일) and (sTime <= 매수시간) and L <= highest(H,50)*고점대비하락 Then{
BuySetup = true;
}
if MarketPosition == 0 and BuySetup == true and C > O and (sTime >= 시작시간) and (sTime <= 매수시간) Then
buy("1차매수",OnClose,def,Floor(금액1/C));
# 2차 매수 조건
# 1차매수가 되어 있다면 BuySetup2 = false
if MarketPosition== 1 Then{
BuySetup2 = false;
}
# 1차매수가 TR-Stop 손절을 당한 후 1차매수가 대비 00% 하락시 2차매수
if MarketPosition == 0 and
MarketPosition(1) == 1 and
IsEntryName("1차매수",1) == true and
IsExitName("TR-Stop",1) == true Then
BuySetup2 = true;
if BuySetup2 == true and C > mav and (sTime >= 시작시간) and (sTime <= 매수시간2) and C < (EntryPrice(1)*0.975) and MarketPosition == 0 Then
buy("2차매수",OnClose,def,Floor(금액2/C));
#매 도 전 략
#[ 목표수익 ]
# 1차 매수중인 경우
if MaxEntries == 1 and
IsEntryName("1차매수",1) == true Then
ExitLong("목표수익1",Atlimit,EntryPrice*목표수익1);
# 2차 매수중인 경우
if MaxEntries == 1 and
IsEntryName("2차매수",1) == true Then
ExitLong("목표수익2",Atlimit,EntryPrice*목표수익2);
# 손절전략============
# 1차 매수물량 손절 전략
# 이전 50개 캔들중에서 최저점 이탈시 매도 (5분봉은 제외)
if MarketPosition == 1 Then
{
if IsEntryName("1차매수") == true and c < lowest(L,50)[BarsSinceEntry] Then
ExitLong("전저점 이탈");
}
# 2차 매수물량 손절 전략
#2차매수후 2차 매수가의 2% 하락하면 전량청산
if MarketPosition == 1 and
IsEntryName("1차매수",1) == true and
IsExitName("전저점 이탈",1) == true Then
ExitLong("2차손절",AtStop,EntryPrice*0.97);
SetStopEndofday(153000);
if MarketPosition == 1 Then{
ExitLong("TR-Stop",AtStop,highest(H,BarsSinceEntry)*TR스탑);
}
Else{
ExitSetup1 = false;
}
- 1. KakaoTalk_20181029_231623572.png (0.09 MB)
답변 1
예스스탁 예스스탁 답변
2018-10-30 11:38:48
안녕하세요
예스스탁입니다.
input : 셋업일(20170717),시작시간(090000),매수시간(150000),매수시간2(150000),종료일(20181231),P(20),Period3(14),dv(2),sto1(25),sto2(6),sto3(6),MAP(5),N(21),
금액1(1000000),금액2(2000000),목표수익1(1.024),목표수익2(1.024),절반매도(1.10),목표가(1000000),진입가격대비하락(0.97),손절가(100),스탑로스(6),TR스탑(0.95),밴드하단보정(1.03), RS과매수수준(60), RS과매도수준(40),고점대비하락(0.94);
var : BBup(0),BBdn(0),BBMid(0),stok(0),stoD(0),RS(0),BuySetup(true),BuySetup2(true),BuySetup3(true),ExitSetup1(false),Xcond(false),mav(0),Dncnt(0),BuySetupindex(0);
# 5일 이평선
mav = ma(C,MAP);
# RSI
RS = RSI(Period3);
# 볼린져밴드
BBup = BollBandUp(P,dv);
BBMid = ma(C,P);
BBdn = BollBandDown(P,dv);
# 스톡케스틱
stok = StochasticsK(sto1,sto2);
Stod = StochasticsD(sto1,sto2,sto3);
# 1차 매수조건
if TotalTrades > TotalTrades[1] Then
BuySetup = false;
if MaxEntries== 1 Then
{
BuySetup = false;
}
Condition1 = IsExitName("TR-Stop",1) == true and IsEntryName("1차매수",1) == true;
if MarketPosition == 0 and
(RS <RS과매도수준) and C< BBdn and
(sDate >= 셋업일) and (sTime <= 매수시간) and
L <= highest(H,50)*고점대비하락 Then{
BuySetup = true;
}
if MarketPosition == 0 and
Condition1 == false and
BuySetup == true and C > O and (sTime >= 시작시간) and (sTime <= 매수시간) Then
buy("1차매수",OnClose,def,Floor(금액1/C));
# 2차 매수 조건
# 1차매수가 되어 있다면 BuySetup2 = false
if MarketPosition== 1 Then
{
BuySetup2 = false;
}
# 1차매수가 TR-Stop 손절을 당한 후 1차매수가 대비 00% 하락시 2차매수
if MarketPosition == 0 and
MarketPosition(1) == 1 and
IsEntryName("1차매수",1) == true and
IsExitName("TR-Stop",1) == true Then
BuySetup2 = true;
if BuySetup2 == true and C > mav and (sTime >= 시작시간) and (sTime <= 매수시간2) and C < (EntryPrice(1)*0.975) and MarketPosition == 0 Then
buy("2차매수",OnClose,def,Floor(금액2/C));
#매 도 전 략
#[ 목표수익 ]
# 1차 매수중인 경우
if MaxEntries == 1 and
IsEntryName("1차매수",1) == true Then
ExitLong("목표수익1",Atlimit,EntryPrice*목표수익1);
# 2차 매수중인 경우
if MaxEntries == 1 and
IsEntryName("2차매수",1) == true Then
ExitLong("목표수익2",Atlimit,EntryPrice*목표수익2);
# 손절전략============
# 1차 매수물량 손절 전략
# 이전 50개 캔들중에서 최저점 이탈시 매도 (5분봉은 제외)
if MarketPosition == 1 Then
{
if IsEntryName("1차매수") == true and c < lowest(L,50)[BarsSinceEntry] Then
ExitLong("전저점 이탈");
}
# 2차 매수물량 손절 전략
#2차매수후 2차 매수가의 2% 하락하면 전량청산
if MarketPosition == 1 and
IsEntryName("1차매수",1) == true and
IsExitName("전저점 이탈",1) == true Then
ExitLong("2차손절",AtStop,EntryPrice*0.97);
SetStopEndofday(153000);
if MarketPosition == 1 Then{
ExitLong("TR-Stop",AtStop,highest(H,BarsSinceEntry)*TR스탑);
}
Else{
ExitSetup1 = false;
}
즐거운 하루되세요
> 뽄때 님이 쓴 글입니다.
> 제목 : 수식수정 부탁드립니다.
> 아래의 그림에서 1차매수후 TR-Stop으로 손절을 당한 후 다시 1차매수가 되고 있는데
제가 원하는 것은 1차매수후 TR-Stop으로 손절을 당했다면 그 다음에는 BuySetup2 조건이 만족되었을 때 2차매수하는 것입니다. 수식 수정 부탁드립니다.
input : 셋업일(20170717),시작시간(090000),매수시간(150000),매수시간2(150000),종료일(20181231),P(20),Period3(14),dv(2),sto1(25),sto2(6),sto3(6),MAP(5),N(21),
금액1(1000000),금액2(2000000),목표수익1(1.024),목표수익2(1.024),절반매도(1.10),목표가(1000000),진입가격대비하락(0.97),손절가(100),스탑로스(6),TR스탑(0.95),밴드하단보정(1.03), RS과매수수준(60), RS과매도수준(40),고점대비하락(0.94);
var : BBup(0),BBdn(0),BBMid(0),stok(0),stoD(0),RS(0),BuySetup(true),BuySetup2(true),BuySetup3(true),ExitSetup1(false),Xcond(false),mav(0),Dncnt(0),BuySetupindex(0);
# 5일 이평선
mav = ma(C,MAP);
# RSI
RS = RSI(Period3);
# 볼린져밴드
BBup = BollBandUp(P,dv);
BBMid = ma(C,P);
BBdn = BollBandDown(P,dv);
# 스톡케스틱
stok = StochasticsK(sto1,sto2);
Stod = StochasticsD(sto1,sto2,sto3);
# 1차 매수조건
if TotalTrades > TotalTrades[1] Then
BuySetup = false;
if MaxEntries== 1 Then{
BuySetup = false;
}
if MarketPosition == 0 and (RS <RS과매도수준) and C< BBdn and (sDate >= 셋업일) and (sTime <= 매수시간) and L <= highest(H,50)*고점대비하락 Then{
BuySetup = true;
}
if MarketPosition == 0 and BuySetup == true and C > O and (sTime >= 시작시간) and (sTime <= 매수시간) Then
buy("1차매수",OnClose,def,Floor(금액1/C));
# 2차 매수 조건
# 1차매수가 되어 있다면 BuySetup2 = false
if MarketPosition== 1 Then{
BuySetup2 = false;
}
# 1차매수가 TR-Stop 손절을 당한 후 1차매수가 대비 00% 하락시 2차매수
if MarketPosition == 0 and
MarketPosition(1) == 1 and
IsEntryName("1차매수",1) == true and
IsExitName("TR-Stop",1) == true Then
BuySetup2 = true;
if BuySetup2 == true and C > mav and (sTime >= 시작시간) and (sTime <= 매수시간2) and C < (EntryPrice(1)*0.975) and MarketPosition == 0 Then
buy("2차매수",OnClose,def,Floor(금액2/C));
#매 도 전 략
#[ 목표수익 ]
# 1차 매수중인 경우
if MaxEntries == 1 and
IsEntryName("1차매수",1) == true Then
ExitLong("목표수익1",Atlimit,EntryPrice*목표수익1);
# 2차 매수중인 경우
if MaxEntries == 1 and
IsEntryName("2차매수",1) == true Then
ExitLong("목표수익2",Atlimit,EntryPrice*목표수익2);
# 손절전략============
# 1차 매수물량 손절 전략
# 이전 50개 캔들중에서 최저점 이탈시 매도 (5분봉은 제외)
if MarketPosition == 1 Then
{
if IsEntryName("1차매수") == true and c < lowest(L,50)[BarsSinceEntry] Then
ExitLong("전저점 이탈");
}
# 2차 매수물량 손절 전략
#2차매수후 2차 매수가의 2% 하락하면 전량청산
if MarketPosition == 1 and
IsEntryName("1차매수",1) == true and
IsExitName("전저점 이탈",1) == true Then
ExitLong("2차손절",AtStop,EntryPrice*0.97);
SetStopEndofday(153000);
if MarketPosition == 1 Then{
ExitLong("TR-Stop",AtStop,highest(H,BarsSinceEntry)*TR스탑);
}
Else{
ExitSetup1 = false;
}
이전글