커뮤니티

문의

프로필 이미지
좌오비우오비
2020-04-16 11:00:05
635
글번호 137946
답변완료

첨부 이미지

선물 5분봉 별첨파일 1은 손절 1.00 인데 1.90 청산된 경우입니다 별첨파일 2는 손절 0.80 인데 1.45 청산된 경우입니다. 1. stop주문이므로 손절가격으로 청산되야 하는데 예외가 발생되는 이유가 궁금합니다. 2. 진입시간과 진입제한시간에 대하여 2016년 7월 31일 이전과 2016년 8월 01일 이후 2개로 구분하여 한 번에 시뮬레이션하고 싶습니다. input : 진입시간(090000),진입제한시간(132000); var : tcond(false); if (sdate != sdate[1] and stime >= 진입시간) or (sdate == sdate[1] and stime >= 진입시간 and stime[1] < 진입시간) Then Tcond = true; if (sdate != sdate[1] and stime >= 진입제한시간) or (sdate == sdate[1] and stime >= 진입제한시간 and stime[1] < 진입제한시간) Then Tcond = false; if 진입수식 and Tcond == true then **************************************************************************************** input : 고가갱신수2(1),고가갱신수3(1),저가갱신수2(1),저가갱신수3(1); input : uppyra검증1(0),상승pyra1(0),상승N1(0); input : up손절1(1.00),up익절1(99999),upTR1(1.00); input : uppyra검증2(0),상승pyra2(0),상승N2(0); input : up손절2(0.80),up익절2(99999),upTR2(1.00); input : uppyra검증3(0),상승pyra3(0),상승N3(0); input : up손절3(0.60),up익절3(99999),upTR3(1.00); input : dnpyra검증1(0),하락pyra1(0),하락N1(0); input : dn손절1(1.00),dn익절1(99999),dnTR1(1.00); input : dnpyra검증2(0),하락pyra2(0),하락N2(0); input : dn손절2(0.80),dn익절2(99999),dnTR2(1.00); input : dnpyra검증3(0),하락pyra3(0),하락N3(0); input : dn손절3(0.60),dn익절3(99999),dnTR3(1.00); if dayindex == 0 and MarketPosition == 0 Then{ Condition1 = false; if C > O Then{ buy("b1",AtMarket); Condition1 = true; } if c < O Then{ sell("s1",AtMarket); Condition1 = true; } } if MarketPosition == 0 and #현재 무포지션이고 EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고 MarketPosition(1) == 1 and #직전거래가 매수거래이고 countif(DayHigh(0) != DayHigh(0)[1],BarsSinceExit(1)) >= 고가갱신수2 Then #청산이후 당일고가 갱신이 n회이상 있었으면 buy("b2"); if MarketPosition == 0 and #현재 무포지션이고 EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고 MarketPosition(1) == -1 and #직전거래가 매도거래이고 countif(DayHigh(0) != DayHigh(0)[1],BarsSinceExit(1)) >= 고가갱신수3 Then #청산이후 당일고가 갱신이 n회이상 있었으면 buy("b3"); if MarketPosition == 0 and #현재 무포지션이고 EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고 MarketPosition(1) == -1 and #직전거래가 매도거래이고 countif(DayLow(0) != DayLow(0)[1],BarsSinceExit(1)) >= 저가갱신수2 Then #청산이후 당일저가 갱신이 n회이상 있었으면 sell("s2"); if MarketPosition == 0 and #현재 무포지션이고 EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고 MarketPosition(1) == 1 and #직전거래가 매수거래이고 countif(DayLow(0) != DayLow(0)[1],BarsSinceExit(1)) >= 저가갱신수3 Then #청산이후 당일저가 갱신이 n회이상 있었으면 sell("s3"); if MarketPosition == 1 and IsEntryName("b1") == true Then { if C >= EntryPrice+uppyra검증1 and MaxContracts < 상승N1 Then buy("bb1",AtStop,LatestEntryPrice(0)+상승Pyra1); ExitLong("bl1",AtStop,EntryPrice-pointstop*up손절1); Exitlong("bp1",AtLimit,EntryPrice+pointstop*up익절1); Exitlong("btr1",AtStop,Highest(h,BarsSinceEntry)-pointstop*upTR1); } if MarketPosition == 1 and IsEntryName("b2") == true then { if C >= EntryPrice+uppyra검증2 and MaxContracts < 상승N2 Then buy("bb2",AtStop,LatestEntryPrice(0)+상승Pyra2); ExitLong("bl2",AtStop,EntryPrice-PointStop*up손절2); Exitlong("bp2",AtLimit,EntryPrice+PointStop*up익절2); Exitlong("btr2",AtStop,highest(h,BarsSinceEntry)-PointStop*upTR2); } if MarketPosition == 1 and IsEntryName("b3") == true then { if C >= EntryPrice+uppyra검증3 and MaxContracts < 상승N3 Then buy("bb3",AtStop,LatestEntryPrice(0)+상승Pyra3); ExitLong("bl3",AtStop,EntryPrice-PointStop*up손절3); Exitlong("bp3",AtLimit,EntryPrice+PointStop*up익절3); Exitlong("btr3",AtStop,highest(h,BarsSinceEntry)-PointStop*upTR3); } if MarketPosition == -1 and IsEntryName("s1") == true Then { if C <= EntryPrice-dnpyra검증1 and MaxContracts < 하락N1 Then sell("ss1",AtStop,LatestEntryPrice(0)-하락Pyra1); ExitShort("sl1",AtStop,EntryPrice+PointStop*dn손절1); ExitShort("sp1",AtLimit,EntryPrice-PointStop*dn익절1); ExitShort("str1",AtStop,Lowest(l,BarsSinceEntry)+PointStop*dnTR1); } if MarketPosition == -1 and IsEntryName("s2") == true Then { if C <= EntryPrice-dnpyra검증2 and MaxContracts < 하락N2 Then sell("ss2",AtStop,LatestEntryPrice(0)-하락Pyra2); ExitShort("sl2",AtStop,EntryPrice+PointStop*dn손절2); ExitShort("sp2",AtLimit,EntryPrice-PointStop*dn익절2); ExitShort("str2",AtStop,Lowest(l,BarsSinceEntry)+PointStop*dnTR2); } if MarketPosition == -1 and IsEntryName("s3") == true Then { if C <= EntryPrice-dnpyra검증3 and MaxContracts < 하락N3 Then sell("ss3",AtStop,LatestEntryPrice(0)-하락Pyra3); ExitShort("sl3",AtStop,EntryPrice+PointStop*dn손절3); ExitShort("sp3",AtLimit,EntryPrice-PointStop*dn익절3); ExitShort("str3",AtStop,Lowest(l,BarsSinceEntry)+PointStop*dnTR3); }
시스템
답변 3
프로필 이미지

예스스탁 예스스탁 답변

2020-04-16 11:10:00

안녕하세요 예스스탁입니다. if문은 봉완성시이고 atstop이 봉완성이 되면 값셋팅하고 다음봉의 현재가와 비교합니다. 현재 청산이 진입후 한봉은 완성이 되어야 포지션방향과 진입가등을 인식합니다. 진입과 동시에 셋팅해서 감시하는 청산내용을 추가해 주시면 됩니다. input : 고가갱신수2(1),고가갱신수3(1),저가갱신수2(1),저가갱신수3(1); input : uppyra검증1(0),상승pyra1(0),상승N1(0); input : up손절1(1.00),up익절1(99999),upTR1(1.00); input : uppyra검증2(0),상승pyra2(0),상승N2(0); input : up손절2(0.80),up익절2(99999),upTR2(1.00); input : uppyra검증3(0),상승pyra3(0),상승N3(0); input : up손절3(0.60),up익절3(99999),upTR3(1.00); input : dnpyra검증1(0),하락pyra1(0),하락N1(0); input : dn손절1(1.00),dn익절1(99999),dnTR1(1.00); input : dnpyra검증2(0),하락pyra2(0),하락N2(0); input : dn손절2(0.80),dn익절2(99999),dnTR2(1.00); input : dnpyra검증3(0),하락pyra3(0),하락N3(0); input : dn손절3(0.60),dn익절3(99999),dnTR3(1.00); if dayindex == 0 and MarketPosition == 0 Then{ Condition1 = false; if C > O Then { buy("b1",AtMarket); Condition1 = true; ExitLong("bl1.",AtStop,NextBarOpen-up손절1); Exitlong("bp1.",AtLimit,NextBarOpen+up익절1); } if c < O Then { sell("s1",AtMarket); Condition1 = true; ExitShort("sl1.",AtStop,NextBarOpen+dn손절1); ExitShort("sp1.",AtLimit,NextBarOpen-dn익절1); } } if MarketPosition == 0 and #현재 무포지션이고 EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고 MarketPosition(1) == 1 and #직전거래가 매수거래이고 countif(DayHigh(0) != DayHigh(0)[1],BarsSinceExit(1)) >= 고가갱신수2 Then #청산이후 당일고가 갱신이 n회이상 있었으면 { buy("b2"); ExitLong("bl2.",AtStop,c-up손절2); Exitlong("bp2.",AtLimit,c+up익절2); } if MarketPosition == 0 and #현재 무포지션이고 EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고 MarketPosition(1) == -1 and #직전거래가 매도거래이고 countif(DayHigh(0) != DayHigh(0)[1],BarsSinceExit(1)) >= 고가갱신수3 Then #청산이후 당일고가 갱신이 n회이상 있었으면 { buy("b3"); ExitLong("bl3.",AtStop,c-up손절3); Exitlong("bp3.",AtLimit,c+up익절3); } if MarketPosition == 0 and #현재 무포지션이고 EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고 MarketPosition(1) == -1 and #직전거래가 매도거래이고 countif(DayLow(0) != DayLow(0)[1],BarsSinceExit(1)) >= 저가갱신수2 Then #청산이후 당일저가 갱신이 n회이상 있었으면 { sell("s2"); ExitShort("sl2.",AtStop,c+dn손절2); ExitShort("sp2.",AtLimit,c-dn익절2); } if MarketPosition == 0 and #현재 무포지션이고 EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고 MarketPosition(1) == 1 and #직전거래가 매수거래이고 countif(DayLow(0) != DayLow(0)[1],BarsSinceExit(1)) >= 저가갱신수3 Then #청산이후 당일저가 갱신이 n회이상 있었으면 { sell("s3"); ExitShort("sl3.",AtStop,c+dn손절3); ExitShort("sp3.",AtLimit,c-dn익절3); } if MarketPosition == 1 and IsEntryName("b1") == true Then { if C >= EntryPrice+uppyra검증1 and MaxContracts < 상승N1 Then buy("bb1",AtStop,LatestEntryPrice(0)+상승Pyra1); ExitLong("bl1",AtStop,EntryPrice-up손절1); Exitlong("bp1",AtLimit,EntryPrice+up익절1); Exitlong("btr1",AtStop,Highest(h,BarsSinceEntry)-upTR1); } if MarketPosition == 1 and IsEntryName("b2") == true then { if C >= EntryPrice+uppyra검증2 and MaxContracts < 상승N2 Then buy("bb2",AtStop,LatestEntryPrice(0)+상승Pyra2); ExitLong("bl2",AtStop,EntryPrice-up손절2); Exitlong("bp2",AtLimit,EntryPrice+up익절2); Exitlong("btr2",AtStop,highest(h,BarsSinceEntry)-upTR2); } if MarketPosition == 1 and IsEntryName("b3") == true then { if C >= EntryPrice+uppyra검증3 and MaxContracts < 상승N3 Then buy("bb3",AtStop,LatestEntryPrice(0)+상승Pyra3); ExitLong("bl3",AtStop,EntryPrice-up손절3); Exitlong("bp3",AtLimit,EntryPrice+up익절3); Exitlong("btr3",AtStop,highest(h,BarsSinceEntry)-upTR3); } if MarketPosition == -1 and IsEntryName("s1") == true Then { if C <= EntryPrice-dnpyra검증1 and MaxContracts < 하락N1 Then sell("ss1",AtStop,LatestEntryPrice(0)-하락Pyra1); ExitShort("sl1",AtStop,EntryPrice+dn손절1); ExitShort("sp1",AtLimit,EntryPrice-dn익절1); ExitShort("str1",AtStop,Lowest(l,BarsSinceEntry)+dnTR1); } if MarketPosition == -1 and IsEntryName("s2") == true Then { if C <= EntryPrice-dnpyra검증2 and MaxContracts < 하락N2 Then sell("ss2",AtStop,LatestEntryPrice(0)-하락Pyra2); ExitShort("sl2",AtStop,EntryPrice+dn손절2); ExitShort("sp2",AtLimit,EntryPrice-dn익절2); ExitShort("str2",AtStop,Lowest(l,BarsSinceEntry)+dnTR2); } if MarketPosition == -1 and IsEntryName("s3") == true Then { if C <= EntryPrice-dnpyra검증3 and MaxContracts < 하락N3 Then sell("ss3",AtStop,LatestEntryPrice(0)-하락Pyra3); ExitShort("sl3",AtStop,EntryPrice+dn손절3); ExitShort("sp3",AtLimit,EntryPrice-dn익절3); ExitShort("str3",AtStop,Lowest(l,BarsSinceEntry)+dnTR3); } 즐거운 하루되세요 > 좌오비우오비 님이 쓴 글입니다. > 제목 : 문의 > 선물 5분봉 별첨파일 1은 손절 1.00 인데 1.90 청산된 경우입니다 별첨파일 2는 손절 0.80 인데 1.45 청산된 경우입니다. 1. stop주문이므로 손절가격으로 청산되야 하는데 예외가 발생되는 이유가 궁금합니다. 2. 진입시간과 진입제한시간에 대하여 2016년 7월 31일 이전과 2016년 8월 01일 이후 2개로 구분하여 한 번에 시뮬레이션하고 싶습니다. input : 진입시간(090000),진입제한시간(132000); var : tcond(false); if (sdate != sdate[1] and stime >= 진입시간) or (sdate == sdate[1] and stime >= 진입시간 and stime[1] < 진입시간) Then Tcond = true; if (sdate != sdate[1] and stime >= 진입제한시간) or (sdate == sdate[1] and stime >= 진입제한시간 and stime[1] < 진입제한시간) Then Tcond = false; if 진입수식 and Tcond == true then **************************************************************************************** input : 고가갱신수2(1),고가갱신수3(1),저가갱신수2(1),저가갱신수3(1); input : uppyra검증1(0),상승pyra1(0),상승N1(0); input : up손절1(1.00),up익절1(99999),upTR1(1.00); input : uppyra검증2(0),상승pyra2(0),상승N2(0); input : up손절2(0.80),up익절2(99999),upTR2(1.00); input : uppyra검증3(0),상승pyra3(0),상승N3(0); input : up손절3(0.60),up익절3(99999),upTR3(1.00); input : dnpyra검증1(0),하락pyra1(0),하락N1(0); input : dn손절1(1.00),dn익절1(99999),dnTR1(1.00); input : dnpyra검증2(0),하락pyra2(0),하락N2(0); input : dn손절2(0.80),dn익절2(99999),dnTR2(1.00); input : dnpyra검증3(0),하락pyra3(0),하락N3(0); input : dn손절3(0.60),dn익절3(99999),dnTR3(1.00); if dayindex == 0 and MarketPosition == 0 Then{ Condition1 = false; if C > O Then{ buy("b1",AtMarket); Condition1 = true; } if c < O Then{ sell("s1",AtMarket); Condition1 = true; } } if MarketPosition == 0 and #현재 무포지션이고 EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고 MarketPosition(1) == 1 and #직전거래가 매수거래이고 countif(DayHigh(0) != DayHigh(0)[1],BarsSinceExit(1)) >= 고가갱신수2 Then #청산이후 당일고가 갱신이 n회이상 있었으면 buy("b2"); if MarketPosition == 0 and #현재 무포지션이고 EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고 MarketPosition(1) == -1 and #직전거래가 매도거래이고 countif(DayHigh(0) != DayHigh(0)[1],BarsSinceExit(1)) >= 고가갱신수3 Then #청산이후 당일고가 갱신이 n회이상 있었으면 buy("b3"); if MarketPosition == 0 and #현재 무포지션이고 EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고 MarketPosition(1) == -1 and #직전거래가 매도거래이고 countif(DayLow(0) != DayLow(0)[1],BarsSinceExit(1)) >= 저가갱신수2 Then #청산이후 당일저가 갱신이 n회이상 있었으면 sell("s2"); if MarketPosition == 0 and #현재 무포지션이고 EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고 MarketPosition(1) == 1 and #직전거래가 매수거래이고 countif(DayLow(0) != DayLow(0)[1],BarsSinceExit(1)) >= 저가갱신수3 Then #청산이후 당일저가 갱신이 n회이상 있었으면 sell("s3"); if MarketPosition == 1 and IsEntryName("b1") == true Then { if C >= EntryPrice+uppyra검증1 and MaxContracts < 상승N1 Then buy("bb1",AtStop,LatestEntryPrice(0)+상승Pyra1); ExitLong("bl1",AtStop,EntryPrice-pointstop*up손절1); Exitlong("bp1",AtLimit,EntryPrice+pointstop*up익절1); Exitlong("btr1",AtStop,Highest(h,BarsSinceEntry)-pointstop*upTR1); } if MarketPosition == 1 and IsEntryName("b2") == true then { if C >= EntryPrice+uppyra검증2 and MaxContracts < 상승N2 Then buy("bb2",AtStop,LatestEntryPrice(0)+상승Pyra2); ExitLong("bl2",AtStop,EntryPrice-PointStop*up손절2); Exitlong("bp2",AtLimit,EntryPrice+PointStop*up익절2); Exitlong("btr2",AtStop,highest(h,BarsSinceEntry)-PointStop*upTR2); } if MarketPosition == 1 and IsEntryName("b3") == true then { if C >= EntryPrice+uppyra검증3 and MaxContracts < 상승N3 Then buy("bb3",AtStop,LatestEntryPrice(0)+상승Pyra3); ExitLong("bl3",AtStop,EntryPrice-PointStop*up손절3); Exitlong("bp3",AtLimit,EntryPrice+PointStop*up익절3); Exitlong("btr3",AtStop,highest(h,BarsSinceEntry)-PointStop*upTR3); } if MarketPosition == -1 and IsEntryName("s1") == true Then { if C <= EntryPrice-dnpyra검증1 and MaxContracts < 하락N1 Then sell("ss1",AtStop,LatestEntryPrice(0)-하락Pyra1); ExitShort("sl1",AtStop,EntryPrice+PointStop*dn손절1); ExitShort("sp1",AtLimit,EntryPrice-PointStop*dn익절1); ExitShort("str1",AtStop,Lowest(l,BarsSinceEntry)+PointStop*dnTR1); } if MarketPosition == -1 and IsEntryName("s2") == true Then { if C <= EntryPrice-dnpyra검증2 and MaxContracts < 하락N2 Then sell("ss2",AtStop,LatestEntryPrice(0)-하락Pyra2); ExitShort("sl2",AtStop,EntryPrice+PointStop*dn손절2); ExitShort("sp2",AtLimit,EntryPrice-PointStop*dn익절2); ExitShort("str2",AtStop,Lowest(l,BarsSinceEntry)+PointStop*dnTR2); } if MarketPosition == -1 and IsEntryName("s3") == true Then { if C <= EntryPrice-dnpyra검증3 and MaxContracts < 하락N3 Then sell("ss3",AtStop,LatestEntryPrice(0)-하락Pyra3); ExitShort("sl3",AtStop,EntryPrice+PointStop*dn손절3); ExitShort("sp3",AtLimit,EntryPrice-PointStop*dn익절3); ExitShort("str3",AtStop,Lowest(l,BarsSinceEntry)+PointStop*dnTR3); }
프로필 이미지

좌오비우오비

2020-04-16 11:40:29

좌오비우오비 님에 의해 삭제된 답변입니다.
프로필 이미지

예스스탁 예스스탁 답변

2020-04-16 15:24:20

안녕하세요 예스스탁입니다. input : 고가갱신수2(1),고가갱신수3(1),저가갱신수2(1),저가갱신수3(1); input : uppyra검증1(0),상승pyra1(0),상승N1(0); input : up손절1(1.00),up익절1(99999),upTR1(1.00); input : uppyra검증2(0),상승pyra2(0),상승N2(0); input : up손절2(0.80),up익절2(99999),upTR2(1.00); input : uppyra검증3(0),상승pyra3(0),상승N3(0); input : up손절3(0.60),up익절3(99999),upTR3(1.00); input : dnpyra검증1(0),하락pyra1(0),하락N1(0); input : dn손절1(1.00),dn익절1(99999),dnTR1(1.00); input : dnpyra검증2(0),하락pyra2(0),하락N2(0); input : dn손절2(0.80),dn익절2(99999),dnTR2(1.00); input : dnpyra검증3(0),하락pyra3(0),하락N3(0); input : dn손절3(0.60),dn익절3(99999),dnTR3(1.00); input : 진입날짜1(20080101),종료날짜1(20160731); input : 진입시간1(090000),진입제한시간1(132000); input : 진입날짜2(20160801); input : 진입시간2(090000),진입제한시간2(132000); var : Dcond(false),tcond(false); if sdate >= 진입날짜1 and sdate <= 종료날짜1 then { if (sdate != sdate[1] and stime >= 진입시간1) or (sdate == sdate[1] and stime >= 진입시간1 and stime[1] < 진입시간1) Then Tcond = true; if (sdate != sdate[1] and stime >= 진입제한시간1) or (sdate == sdate[1] and stime >= 진입제한시간1 and stime[1] < 진입제한시간1) Then Tcond = false; } if sdate >= 진입날짜2 then { if (sdate != sdate[1] and stime >= 진입시간2) or (sdate == sdate[1] and stime >= 진입시간2 and stime[1] < 진입시간2) Then Tcond = true; if (sdate != sdate[1] and stime >= 진입제한시간2) or (sdate == sdate[1] and stime >= 진입제한시간2 and stime[1] < 진입제한시간2) Then Tcond = false; } if Tcond == true then { if dayindex == 0 and MarketPosition == 0 Then{ Condition1 = false; if C > O Then { buy("b1",AtMarket); Condition1 = true; ExitLong("bl1.",AtStop,NextBarOpen-up손절1); Exitlong("bp1.",AtLimit,NextBarOpen+up익절1); } if c < O Then { sell("s1",AtMarket); Condition1 = true; ExitShort("sl1.",AtStop,NextBarOpen+dn손절1); ExitShort("sp1.",AtLimit,NextBarOpen-dn익절1); } } if MarketPosition == 0 and #현재 무포지션이고 EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고 MarketPosition(1) == 1 and #직전거래가 매수거래이고 countif(DayHigh(0) != DayHigh(0)[1],BarsSinceExit(1)) >= 고가갱신수2 Then #청산이후 당일고가 갱신이 n회이상 있었으면 { buy("b2"); ExitLong("bl2.",AtStop,c-up손절2); Exitlong("bp2.",AtLimit,c+up익절2); } if MarketPosition == 0 and #현재 무포지션이고 EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고 MarketPosition(1) == -1 and #직전거래가 매도거래이고 countif(DayHigh(0) != DayHigh(0)[1],BarsSinceExit(1)) >= 고가갱신수3 Then #청산이후 당일고가 갱신이 n회이상 있었으면 { buy("b3"); ExitLong("bl3.",AtStop,c-up손절3); Exitlong("bp3.",AtLimit,c+up익절3); } if MarketPosition == 0 and #현재 무포지션이고 EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고 MarketPosition(1) == -1 and #직전거래가 매도거래이고 countif(DayLow(0) != DayLow(0)[1],BarsSinceExit(1)) >= 저가갱신수2 Then #청산이후 당일저가 갱신이 n회이상 있었으면 { sell("s2"); ExitShort("sl2.",AtStop,c+dn손절2); ExitShort("sp2.",AtLimit,c-dn익절2); } if MarketPosition == 0 and #현재 무포지션이고 EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고 MarketPosition(1) == 1 and #직전거래가 매수거래이고 countif(DayLow(0) != DayLow(0)[1],BarsSinceExit(1)) >= 저가갱신수3 Then #청산이후 당일저가 갱신이 n회이상 있었으면 { sell("s3"); ExitShort("sl3.",AtStop,c+dn손절3); ExitShort("sp3.",AtLimit,c-dn익절3); } } if MarketPosition == 1 and IsEntryName("b1") == true Then { if C >= EntryPrice+uppyra검증1 and MaxContracts < 상승N1 Then buy("bb1",AtStop,LatestEntryPrice(0)+상승Pyra1); ExitLong("bl1",AtStop,EntryPrice-up손절1); Exitlong("bp1",AtLimit,EntryPrice+up익절1); Exitlong("btr1",AtStop,Highest(h,BarsSinceEntry)-upTR1); } if MarketPosition == 1 and IsEntryName("b2") == true then { if C >= EntryPrice+uppyra검증2 and MaxContracts < 상승N2 Then buy("bb2",AtStop,LatestEntryPrice(0)+상승Pyra2); ExitLong("bl2",AtStop,EntryPrice-up손절2); Exitlong("bp2",AtLimit,EntryPrice+up익절2); Exitlong("btr2",AtStop,highest(h,BarsSinceEntry)-upTR2); } if MarketPosition == 1 and IsEntryName("b3") == true then { if C >= EntryPrice+uppyra검증3 and MaxContracts < 상승N3 Then buy("bb3",AtStop,LatestEntryPrice(0)+상승Pyra3); ExitLong("bl3",AtStop,EntryPrice-up손절3); Exitlong("bp3",AtLimit,EntryPrice+up익절3); Exitlong("btr3",AtStop,highest(h,BarsSinceEntry)-upTR3); } if MarketPosition == -1 and IsEntryName("s1") == true Then { if C <= EntryPrice-dnpyra검증1 and MaxContracts < 하락N1 Then sell("ss1",AtStop,LatestEntryPrice(0)-하락Pyra1); ExitShort("sl1",AtStop,EntryPrice+dn손절1); ExitShort("sp1",AtLimit,EntryPrice-dn익절1); ExitShort("str1",AtStop,Lowest(l,BarsSinceEntry)+dnTR1); } if MarketPosition == -1 and IsEntryName("s2") == true Then { if C <= EntryPrice-dnpyra검증2 and MaxContracts < 하락N2 Then sell("ss2",AtStop,LatestEntryPrice(0)-하락Pyra2); ExitShort("sl2",AtStop,EntryPrice+dn손절2); ExitShort("sp2",AtLimit,EntryPrice-dn익절2); ExitShort("str2",AtStop,Lowest(l,BarsSinceEntry)+dnTR2); } if MarketPosition == -1 and IsEntryName("s3") == true Then { if C <= EntryPrice-dnpyra검증3 and MaxContracts < 하락N3 Then sell("ss3",AtStop,LatestEntryPrice(0)-하락Pyra3); ExitShort("sl3",AtStop,EntryPrice+dn손절3); ExitShort("sp3",AtLimit,EntryPrice-dn익절3); ExitShort("str3",AtStop,Lowest(l,BarsSinceEntry)+dnTR3); } 즐거운 하루되세요 > 좌오비우오비 님이 쓴 글입니다. > 제목 : 질문이 하나 더 있었는데요 > 2. 진입시간과 진입제한시간에 대하여 2008년 1월 1일 부터 2016년 7월 31일 까지 2016년 8월 1일 부터 현재까지 2개로 구분하여 한 번에 시뮬레이션하고 싶습니다. input : 진입시간(090000),진입제한시간(132000); var : tcond(false); if (sdate != sdate[1] and stime >= 진입시간) or (sdate == sdate[1] and stime >= 진입시간 and stime[1] < 진입시간) Then Tcond = true; if (sdate != sdate[1] and stime >= 진입제한시간) or (sdate == sdate[1] and stime >= 진입제한시간 and stime[1] < 진입제한시간) Then Tcond = false; if 진입수식 and Tcond == true then > 예스스탁 님이 쓴 글입니다. > 제목 : Re : 문의 > 안녕하세요 예스스탁입니다. if문은 봉완성시이고 atstop이 봉완성이 되면 값셋팅하고 다음봉의 현재가와 비교합니다. 현재 청산이 진입후 한봉은 완성이 되어야 포지션방향과 진입가등을 인식합니다. 진입과 동시에 셋팅해서 감시하는 청산내용을 추가해 주시면 됩니다. input : 고가갱신수2(1),고가갱신수3(1),저가갱신수2(1),저가갱신수3(1); input : uppyra검증1(0),상승pyra1(0),상승N1(0); input : up손절1(1.00),up익절1(99999),upTR1(1.00); input : uppyra검증2(0),상승pyra2(0),상승N2(0); input : up손절2(0.80),up익절2(99999),upTR2(1.00); input : uppyra검증3(0),상승pyra3(0),상승N3(0); input : up손절3(0.60),up익절3(99999),upTR3(1.00); input : dnpyra검증1(0),하락pyra1(0),하락N1(0); input : dn손절1(1.00),dn익절1(99999),dnTR1(1.00); input : dnpyra검증2(0),하락pyra2(0),하락N2(0); input : dn손절2(0.80),dn익절2(99999),dnTR2(1.00); input : dnpyra검증3(0),하락pyra3(0),하락N3(0); input : dn손절3(0.60),dn익절3(99999),dnTR3(1.00); if dayindex == 0 and MarketPosition == 0 Then{ Condition1 = false; if C > O Then { buy("b1",AtMarket); Condition1 = true; ExitLong("bl1.",AtStop,NextBarOpen-up손절1); Exitlong("bp1.",AtLimit,NextBarOpen+up익절1); } if c < O Then { sell("s1",AtMarket); Condition1 = true; ExitShort("sl1.",AtStop,NextBarOpen+dn손절1); ExitShort("sp1.",AtLimit,NextBarOpen-dn익절1); } } if MarketPosition == 0 and #현재 무포지션이고 EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고 MarketPosition(1) == 1 and #직전거래가 매수거래이고 countif(DayHigh(0) != DayHigh(0)[1],BarsSinceExit(1)) >= 고가갱신수2 Then #청산이후 당일고가 갱신이 n회이상 있었으면 { buy("b2"); ExitLong("bl2.",AtStop,c-up손절2); Exitlong("bp2.",AtLimit,c+up익절2); } if MarketPosition == 0 and #현재 무포지션이고 EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고 MarketPosition(1) == -1 and #직전거래가 매도거래이고 countif(DayHigh(0) != DayHigh(0)[1],BarsSinceExit(1)) >= 고가갱신수3 Then #청산이후 당일고가 갱신이 n회이상 있었으면 { buy("b3"); ExitLong("bl3.",AtStop,c-up손절3); Exitlong("bp3.",AtLimit,c+up익절3); } if MarketPosition == 0 and #현재 무포지션이고 EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고 MarketPosition(1) == -1 and #직전거래가 매도거래이고 countif(DayLow(0) != DayLow(0)[1],BarsSinceExit(1)) >= 저가갱신수2 Then #청산이후 당일저가 갱신이 n회이상 있었으면 { sell("s2"); ExitShort("sl2.",AtStop,c+dn손절2); ExitShort("sp2.",AtLimit,c-dn익절2); } if MarketPosition == 0 and #현재 무포지션이고 EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고 MarketPosition(1) == 1 and #직전거래가 매수거래이고 countif(DayLow(0) != DayLow(0)[1],BarsSinceExit(1)) >= 저가갱신수3 Then #청산이후 당일저가 갱신이 n회이상 있었으면 { sell("s3"); ExitShort("sl3.",AtStop,c+dn손절3); ExitShort("sp3.",AtLimit,c-dn익절3); } if MarketPosition == 1 and IsEntryName("b1") == true Then { if C >= EntryPrice+uppyra검증1 and MaxContracts < 상승N1 Then buy("bb1",AtStop,LatestEntryPrice(0)+상승Pyra1); ExitLong("bl1",AtStop,EntryPrice-up손절1); Exitlong("bp1",AtLimit,EntryPrice+up익절1); Exitlong("btr1",AtStop,Highest(h,BarsSinceEntry)-upTR1); } if MarketPosition == 1 and IsEntryName("b2") == true then { if C >= EntryPrice+uppyra검증2 and MaxContracts < 상승N2 Then buy("bb2",AtStop,LatestEntryPrice(0)+상승Pyra2); ExitLong("bl2",AtStop,EntryPrice-up손절2); Exitlong("bp2",AtLimit,EntryPrice+up익절2); Exitlong("btr2",AtStop,highest(h,BarsSinceEntry)-upTR2); } if MarketPosition == 1 and IsEntryName("b3") == true then { if C >= EntryPrice+uppyra검증3 and MaxContracts < 상승N3 Then buy("bb3",AtStop,LatestEntryPrice(0)+상승Pyra3); ExitLong("bl3",AtStop,EntryPrice-up손절3); Exitlong("bp3",AtLimit,EntryPrice+up익절3); Exitlong("btr3",AtStop,highest(h,BarsSinceEntry)-upTR3); } if MarketPosition == -1 and IsEntryName("s1") == true Then { if C <= EntryPrice-dnpyra검증1 and MaxContracts < 하락N1 Then sell("ss1",AtStop,LatestEntryPrice(0)-하락Pyra1); ExitShort("sl1",AtStop,EntryPrice+dn손절1); ExitShort("sp1",AtLimit,EntryPrice-dn익절1); ExitShort("str1",AtStop,Lowest(l,BarsSinceEntry)+dnTR1); } if MarketPosition == -1 and IsEntryName("s2") == true Then { if C <= EntryPrice-dnpyra검증2 and MaxContracts < 하락N2 Then sell("ss2",AtStop,LatestEntryPrice(0)-하락Pyra2); ExitShort("sl2",AtStop,EntryPrice+dn손절2); ExitShort("sp2",AtLimit,EntryPrice-dn익절2); ExitShort("str2",AtStop,Lowest(l,BarsSinceEntry)+dnTR2); } if MarketPosition == -1 and IsEntryName("s3") == true Then { if C <= EntryPrice-dnpyra검증3 and MaxContracts < 하락N3 Then sell("ss3",AtStop,LatestEntryPrice(0)-하락Pyra3); ExitShort("sl3",AtStop,EntryPrice+dn손절3); ExitShort("sp3",AtLimit,EntryPrice-dn익절3); ExitShort("str3",AtStop,Lowest(l,BarsSinceEntry)+dnTR3); } 즐거운 하루되세요 > 좌오비우오비 님이 쓴 글입니다. > 제목 : 문의 > 선물 5분봉 별첨파일 1은 손절 1.00 인데 1.90 청산된 경우입니다 별첨파일 2는 손절 0.80 인데 1.45 청산된 경우입니다. 1. stop주문이므로 손절가격으로 청산되야 하는데 예외가 발생되는 이유가 궁금합니다. 2. 진입시간과 진입제한시간에 대하여 2016년 7월 31일 이전과 2016년 8월 01일 이후 2개로 구분하여 한 번에 시뮬레이션하고 싶습니다. input : 진입시간(090000),진입제한시간(132000); var : tcond(false); if (sdate != sdate[1] and stime >= 진입시간) or (sdate == sdate[1] and stime >= 진입시간 and stime[1] < 진입시간) Then Tcond = true; if (sdate != sdate[1] and stime >= 진입제한시간) or (sdate == sdate[1] and stime >= 진입제한시간 and stime[1] < 진입제한시간) Then Tcond = false; if 진입수식 and Tcond == true then **************************************************************************************** input : 고가갱신수2(1),고가갱신수3(1),저가갱신수2(1),저가갱신수3(1); input : uppyra검증1(0),상승pyra1(0),상승N1(0); input : up손절1(1.00),up익절1(99999),upTR1(1.00); input : uppyra검증2(0),상승pyra2(0),상승N2(0); input : up손절2(0.80),up익절2(99999),upTR2(1.00); input : uppyra검증3(0),상승pyra3(0),상승N3(0); input : up손절3(0.60),up익절3(99999),upTR3(1.00); input : dnpyra검증1(0),하락pyra1(0),하락N1(0); input : dn손절1(1.00),dn익절1(99999),dnTR1(1.00); input : dnpyra검증2(0),하락pyra2(0),하락N2(0); input : dn손절2(0.80),dn익절2(99999),dnTR2(1.00); input : dnpyra검증3(0),하락pyra3(0),하락N3(0); input : dn손절3(0.60),dn익절3(99999),dnTR3(1.00); if dayindex == 0 and MarketPosition == 0 Then{ Condition1 = false; if C > O Then{ buy("b1",AtMarket); Condition1 = true; } if c < O Then{ sell("s1",AtMarket); Condition1 = true; } } if MarketPosition == 0 and #현재 무포지션이고 EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고 MarketPosition(1) == 1 and #직전거래가 매수거래이고 countif(DayHigh(0) != DayHigh(0)[1],BarsSinceExit(1)) >= 고가갱신수2 Then #청산이후 당일고가 갱신이 n회이상 있었으면 buy("b2"); if MarketPosition == 0 and #현재 무포지션이고 EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고 MarketPosition(1) == -1 and #직전거래가 매도거래이고 countif(DayHigh(0) != DayHigh(0)[1],BarsSinceExit(1)) >= 고가갱신수3 Then #청산이후 당일고가 갱신이 n회이상 있었으면 buy("b3"); if MarketPosition == 0 and #현재 무포지션이고 EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고 MarketPosition(1) == -1 and #직전거래가 매도거래이고 countif(DayLow(0) != DayLow(0)[1],BarsSinceExit(1)) >= 저가갱신수2 Then #청산이후 당일저가 갱신이 n회이상 있었으면 sell("s2"); if MarketPosition == 0 and #현재 무포지션이고 EntryDate(1) == sdate and #직전거래가 오늘 발생한 거래이고 MarketPosition(1) == 1 and #직전거래가 매수거래이고 countif(DayLow(0) != DayLow(0)[1],BarsSinceExit(1)) >= 저가갱신수3 Then #청산이후 당일저가 갱신이 n회이상 있었으면 sell("s3"); if MarketPosition == 1 and IsEntryName("b1") == true Then { if C >= EntryPrice+uppyra검증1 and MaxContracts < 상승N1 Then buy("bb1",AtStop,LatestEntryPrice(0)+상승Pyra1); ExitLong("bl1",AtStop,EntryPrice-pointstop*up손절1); Exitlong("bp1",AtLimit,EntryPrice+pointstop*up익절1); Exitlong("btr1",AtStop,Highest(h,BarsSinceEntry)-pointstop*upTR1); } if MarketPosition == 1 and IsEntryName("b2") == true then { if C >= EntryPrice+uppyra검증2 and MaxContracts < 상승N2 Then buy("bb2",AtStop,LatestEntryPrice(0)+상승Pyra2); ExitLong("bl2",AtStop,EntryPrice-PointStop*up손절2); Exitlong("bp2",AtLimit,EntryPrice+PointStop*up익절2); Exitlong("btr2",AtStop,highest(h,BarsSinceEntry)-PointStop*upTR2); } if MarketPosition == 1 and IsEntryName("b3") == true then { if C >= EntryPrice+uppyra검증3 and MaxContracts < 상승N3 Then buy("bb3",AtStop,LatestEntryPrice(0)+상승Pyra3); ExitLong("bl3",AtStop,EntryPrice-PointStop*up손절3); Exitlong("bp3",AtLimit,EntryPrice+PointStop*up익절3); Exitlong("btr3",AtStop,highest(h,BarsSinceEntry)-PointStop*upTR3); } if MarketPosition == -1 and IsEntryName("s1") == true Then { if C <= EntryPrice-dnpyra검증1 and MaxContracts < 하락N1 Then sell("ss1",AtStop,LatestEntryPrice(0)-하락Pyra1); ExitShort("sl1",AtStop,EntryPrice+PointStop*dn손절1); ExitShort("sp1",AtLimit,EntryPrice-PointStop*dn익절1); ExitShort("str1",AtStop,Lowest(l,BarsSinceEntry)+PointStop*dnTR1); } if MarketPosition == -1 and IsEntryName("s2") == true Then { if C <= EntryPrice-dnpyra검증2 and MaxContracts < 하락N2 Then sell("ss2",AtStop,LatestEntryPrice(0)-하락Pyra2); ExitShort("sl2",AtStop,EntryPrice+PointStop*dn손절2); ExitShort("sp2",AtLimit,EntryPrice-PointStop*dn익절2); ExitShort("str2",AtStop,Lowest(l,BarsSinceEntry)+PointStop*dnTR2); } if MarketPosition == -1 and IsEntryName("s3") == true Then { if C <= EntryPrice-dnpyra검증3 and MaxContracts < 하락N3 Then sell("ss3",AtStop,LatestEntryPrice(0)-하락Pyra3); ExitShort("sl3",AtStop,EntryPrice+PointStop*dn손절3); ExitShort("sp3",AtLimit,EntryPrice-PointStop*dn익절3); ExitShort("str3",AtStop,Lowest(l,BarsSinceEntry)+PointStop*dnTR3); }