커뮤니티

수식 문의드립니다

프로필 이미지
남산
2023-01-28 13:40:57
1049
글번호 165786
답변완료
input : 시작시간(090000),종료시간(0); input : Period1(1),Period2(2),Period3(3),Period4(4),Period5(5),Period6(6),Period7(7),Period8(8),Period9(9),Period10(10),Period11(11),Period12(12),Period15(15),Period20(20),Period25(25),Period30(30),Period35(35),Period40(40),Period52(52),Period70(70),Period80(80), Period105(105),Period140(140),Period150(150),Period210(210),Period280(280),Period300(300),Period450(450),Period480(480),Period520(520),Period560(560),Period600(600),Period840(840),Period900(900),Period1120(1120),Period1200(1200),Period1800(1800),Period2400(2400),Period2800(2800),Period3000(3000),Period3600(3600),Period4800(4800),Period7200(7200), Period58(58),Period60(60),Period62(62),Period82(82),Period84(84),Period28(70),Period31(11),Period32(24),Period33(5), Period41(35),Period42(35),Period43(35),Period48(15),Period1001(850),Period1002(520),Period1003(480),Period1008(36),aa4(0.4),aa5(0.5),aa6(0.8),익절틱수s4(111),손절틱수s4(91); var : mav1(0),mav2(0),mav3(0),mav4(0),mav5(0),mav6(0),mav7(0),mav8(0),mav9(0),mav10(0),mav11(0),mav12(0),mav15(0),mav20(0),mav25(0),mav30(0),mav35(0),mav40(0),mav52(0),mav70(0),mav80(0),mav105(0),mav140(0),mav150(0),mav210(0),mav280(0),mav300(0),mav450(0),mav480(0),mav520(0),mav560(0),mav600(0), mav840(0),mav900(0),mav1120(0),mav1200(0),mav1800(0),mav2400(0),mav2800(0),mav3000(0),mav3600(0),mav4800(0),mav7200(0), mav58(0),mav60(0),mav62(0),mav82(0),mav84(0),mav28(0),mav31(0),mav32(0),mav33(0), mav41(0),mav42(0),mav43(0),mav48(0),mav1001(0),mav1002(0),mav1003(0),mav1008(0),Bxcond(false),Sxcond(false); var : Tcond(false); var : T(0); var : ii(0); var : BE1(0),BE2(0),BE3(0),BE4(0),BE5(0); var : SE1(0),SE2(0),SE3(0),SE4(0),SE5(0); mav1 = ma(c, Period1); mav2 = ma(c, Period2); mav3 = ma(c, Period3); mav4 = ma(c, Period4); mav5 = ma(c, Period5); mav6 = ma(c, Period6); mav7 = ma(c, Period7); mav8 = ma(c, Period8); mav9 = ma(c, Period9); mav10 = ma(c, Period10); mav11 = ma(c, Period11); mav12 = ma(c, Period12); mav15 = ma(c, Period15); mav20 = ma(c, Period20); mav25 = ma(c, Period25); mav30 = ma(c, Period30); mav35 = ma(c, Period35); mav40 = ma(c, Period40); mav52 = ma(c, Period52); mav70 = ma(c, Period70); mav80 = ma(c, Period80); mav105 = ma(c, Period105); mav140 = ma(c, Period140); mav150 = ma(c, Period150); mav210 = ma(c, Period210); mav280 = ma(c, Period280); mav300 = ma(c, Period300); mav450 = ma(c, Period450); mav480 = ma(c, Period480); mav520 = ma(c, Period520); mav560 = ma(c, Period560); mav600 = ma(c, Period600); mav840 = ma(c, Period840); mav900 = ma(c, Period900); mav1120 = ma(c, Period1120); mav1200 = ma(c, Period1200); mav1800 = ma(c, Period1800); mav2400 = ma(c, Period2400); mav2800 = ma(c, Period2800); mav3000 = ma(c, Period3000); mav3600 = ma(c, Period3600); mav4800 = ma(c, Period4800); mav7200 = ma(c, Period7200); mav58 = ma(c, Period58); mav60 = ma(c, Period60); mav62 = ma(c, Period62); mav82 = ma(c, Period82); mav84 = ma(c, Period84); mav28 = ma(c, Period28); mav31 = ma(c, Period31); mav32 = ma(c, Period32); mav33 = ma(c, Period33); mav41 = ma(c, Period41); mav42 = ma(c, Period42); mav43 = ma(c, Period43); mav48 = ma(c, Period48); mav1001 = ma(c, Period1001); mav1002 = ma(c, Period1002); mav1003 = ma(c, Period1003); mav1008 = ma(c, Period1008); var1 = abs(c-mav70); var2 = abs(mav10-mav20); var3 = abs(mav20-mav35); var4 = abs(mav35-mav70); var5 = abs(mav70-mav140); var6 = abs(mav140-mav280); var7 = abs(mav280-mav560); var8 = abs(mav560-mav1120); var9 = abs(mav1120-mav1800); input : Atime(30),P1(2),P2(3),P3(5),P4(10),P5(20),P6(40); var : TF(0),cnt(0),sum1(0),bmav2(0),sum2(0),bmav3(0),sum3(0),bmav5(0),sum4(0),bmav10(0),sum5(0),bmav20(0),sum6(0),bmav40(0); Array : CC[500](0); TF = TimeToMinutes(stime)%Atime; if dayindex() == 0 or (TF < TF[1] and stime > stime[1]) Then { for cnt = 1 to 499 { CC[cnt] = CC[cnt-1][1]; } } CC[0] = C; if CC[P6-1] > 0 then { sum1 = 0; sum2 = 0; sum3 = 0; sum4 = 0; sum5 = 0; sum6 = 0; for cnt = 0 to P6 { if cnt < P1 Then sum1 = sum1+CC[cnt]; if cnt < P2 Then sum2 = sum2+CC[cnt]; if cnt < P3 Then sum3 = sum3+CC[cnt]; if cnt < P4 Then sum4 = sum4+CC[cnt]; if cnt < P5 Then sum5 = sum5+CC[cnt]; if cnt < P6 Then sum6 = sum6+CC[cnt]; } Bmav2 = sum1/P1; Bmav3 = sum2/P2; Bmav5 = sum3/P3; Bmav10 = sum4/P4; Bmav20 = sum5/P5; Bmav40 = sum6/P6; } if (sdate != sdate[1] and stime >= 시작시간) or (sdate == sdate[1] and (Stime == 시작시간 or (stime > 시작시간 and stime[1] < 시작시간))) Then { Tcond = True; BXcond = false; SXcond = false; } if stime == 종료시간 or (stime > 종료시간 and stime[1] < 종료시간) Then { Tcond = false; if MarketPosition == 1 Then ExitLong(); if MarketPosition == -1 Then ExitShort(); } if TotalTrades > TotalTrades[1] then { BXcond = false; SXcond = false; if (IsExitName("bl",0) == true or IsExitName("bp",0) == true or IsExitName("bx",0) == true or IsExitName("bx",0) == true) Then BXcond = true; if (IsExitName("sl",0) == true or IsExitName("sp",0) == true or IsExitName("sx",0) == true or IsExitName("sx",0) == true) Then SXcond = true; } if Tcond == true then { if MarketPosition >= 0 Then if mav3600 < c and mav7200 > mav4800 and mav4800 > mav2400 and mav2400 < mav1200 and mav1200 < mav600 and mav1200 < mav300 and ((mav4800 < mav600)or (mav4800 < mav300)) and mav7200[1] > mav7200 and mav4800[1] > mav4800 and mav2400[1] < mav2400 and mav1200[1] < mav1200 and mav900[3] > mav900[2] and mav900[2] > mav900[1] and mav900[1] > mav900 and mav300[1] > mav300 and mav150[1] > mav150 and mav80[1] > mav80 and mav40[1] > mav40 and mav20[1] > mav20 and mav10[1] > mav10 and Bmav40 > Bmav20 and Bmav20 > Bmav10 Then { if CurrentContracts < 1 Then sell("s4",OnClose,def,1); } if MarketPosition == -1 then { #s3 if mav3000[1] < mav3000 and mav2400[1] < mav2400 and mav1200[1] < mav1200 and mav150[1] < mav150 and mav80[1] < mav80 Then { ExitShort("s4-1",OnClose,def,"s4"); } Else if mav2400[1] > mav2400 and mav600[20] > mav600 and mav600[3] > mav600[2] and mav600[2] < mav600[1] and mav600[1] < mav600 Then { ExitShort("s4-2",OnClose,def,"s4"); } Else if mav2400[1] > mav2400 and mav600 > mav300 and mav300[30] > mav300 and mav300[3] < mav300[2] and mav300[2] < mav300[1] and mav300[1] < mav300 Then { ExitShort("s4-3",OnClose,def,"s4"); } Else { if mav2400[1] > mav2400 and mav900 > mav600 and mav600 > mav300 and crossuP(mav80,mav150) Then ExitShort("s4-4",OnClose,def,"s4"); } ExitShort("sp",atlimit,AvgEntryPrice-PriceScale*익절틱수s4,"s4"); ExitShort("sl",AtStop,AvgEntryPrice+PriceScale*손절틱수s4,"s4"); } } 위 수식을 활용하여 시뮬레이션차트 30틱에서 건수 900,000바 환경에서 익절틱수s4(변수이름)을 변수편집을 이용하여 최소60, 최대120, 증가 1로 설정하여 시뮬레이션하면 왜 1개의 값만 나오고 시뮬레이션할 때 마다 다른 값이 나오는지 궁금합니다 실제로 범위내에서 다른 값을 적용하면 시뮬레이션에서 나오 값보다 높은값이 나오는지 궁금합니다 몇일을 찾았으나 원인을 알 수 없어요 감사합니다.
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2023-01-30 13:19:55

안녕하세요 예스스탁입니다. 올려주신 내용을 정확히 이해하지 못했습니다. 1개값만 나온다고 하신 부분이 시뮬레이션 결과가 회차별로 모두 동일하다는 내용으로 파악이 되는데 올려주신 수식을 최적화 해보았지만 첨부된 그림과 같이 익절틱수s4에 따라 총손익등이 변경되고 있습니다. 다만 익절틱수가 올라가서 특정익절틱수 이후에는 진입후 익절에 도달하는 것보다 다른 청산이 먼저 발동되서 해당 익절이 없어 손익이 동일할수는 있습니다. 위 내용이 아니시면 02-3453-1060으로 전화주시기 바랍니다. 즐거운 하루되세요 > 남산 님이 쓴 글입니다. > 제목 : 수식 문의드립니다 > input : 시작시간(090000),종료시간(0); input : Period1(1),Period2(2),Period3(3),Period4(4),Period5(5),Period6(6),Period7(7),Period8(8),Period9(9),Period10(10),Period11(11),Period12(12),Period15(15),Period20(20),Period25(25),Period30(30),Period35(35),Period40(40),Period52(52),Period70(70),Period80(80), Period105(105),Period140(140),Period150(150),Period210(210),Period280(280),Period300(300),Period450(450),Period480(480),Period520(520),Period560(560),Period600(600),Period840(840),Period900(900),Period1120(1120),Period1200(1200),Period1800(1800),Period2400(2400),Period2800(2800),Period3000(3000),Period3600(3600),Period4800(4800),Period7200(7200), Period58(58),Period60(60),Period62(62),Period82(82),Period84(84),Period28(70),Period31(11),Period32(24),Period33(5), Period41(35),Period42(35),Period43(35),Period48(15),Period1001(850),Period1002(520),Period1003(480),Period1008(36),aa4(0.4),aa5(0.5),aa6(0.8),익절틱수s4(111),손절틱수s4(91); var : mav1(0),mav2(0),mav3(0),mav4(0),mav5(0),mav6(0),mav7(0),mav8(0),mav9(0),mav10(0),mav11(0),mav12(0),mav15(0),mav20(0),mav25(0),mav30(0),mav35(0),mav40(0),mav52(0),mav70(0),mav80(0),mav105(0),mav140(0),mav150(0),mav210(0),mav280(0),mav300(0),mav450(0),mav480(0),mav520(0),mav560(0),mav600(0), mav840(0),mav900(0),mav1120(0),mav1200(0),mav1800(0),mav2400(0),mav2800(0),mav3000(0),mav3600(0),mav4800(0),mav7200(0), mav58(0),mav60(0),mav62(0),mav82(0),mav84(0),mav28(0),mav31(0),mav32(0),mav33(0), mav41(0),mav42(0),mav43(0),mav48(0),mav1001(0),mav1002(0),mav1003(0),mav1008(0),Bxcond(false),Sxcond(false); var : Tcond(false); var : T(0); var : ii(0); var : BE1(0),BE2(0),BE3(0),BE4(0),BE5(0); var : SE1(0),SE2(0),SE3(0),SE4(0),SE5(0); mav1 = ma(c, Period1); mav2 = ma(c, Period2); mav3 = ma(c, Period3); mav4 = ma(c, Period4); mav5 = ma(c, Period5); mav6 = ma(c, Period6); mav7 = ma(c, Period7); mav8 = ma(c, Period8); mav9 = ma(c, Period9); mav10 = ma(c, Period10); mav11 = ma(c, Period11); mav12 = ma(c, Period12); mav15 = ma(c, Period15); mav20 = ma(c, Period20); mav25 = ma(c, Period25); mav30 = ma(c, Period30); mav35 = ma(c, Period35); mav40 = ma(c, Period40); mav52 = ma(c, Period52); mav70 = ma(c, Period70); mav80 = ma(c, Period80); mav105 = ma(c, Period105); mav140 = ma(c, Period140); mav150 = ma(c, Period150); mav210 = ma(c, Period210); mav280 = ma(c, Period280); mav300 = ma(c, Period300); mav450 = ma(c, Period450); mav480 = ma(c, Period480); mav520 = ma(c, Period520); mav560 = ma(c, Period560); mav600 = ma(c, Period600); mav840 = ma(c, Period840); mav900 = ma(c, Period900); mav1120 = ma(c, Period1120); mav1200 = ma(c, Period1200); mav1800 = ma(c, Period1800); mav2400 = ma(c, Period2400); mav2800 = ma(c, Period2800); mav3000 = ma(c, Period3000); mav3600 = ma(c, Period3600); mav4800 = ma(c, Period4800); mav7200 = ma(c, Period7200); mav58 = ma(c, Period58); mav60 = ma(c, Period60); mav62 = ma(c, Period62); mav82 = ma(c, Period82); mav84 = ma(c, Period84); mav28 = ma(c, Period28); mav31 = ma(c, Period31); mav32 = ma(c, Period32); mav33 = ma(c, Period33); mav41 = ma(c, Period41); mav42 = ma(c, Period42); mav43 = ma(c, Period43); mav48 = ma(c, Period48); mav1001 = ma(c, Period1001); mav1002 = ma(c, Period1002); mav1003 = ma(c, Period1003); mav1008 = ma(c, Period1008); var1 = abs(c-mav70); var2 = abs(mav10-mav20); var3 = abs(mav20-mav35); var4 = abs(mav35-mav70); var5 = abs(mav70-mav140); var6 = abs(mav140-mav280); var7 = abs(mav280-mav560); var8 = abs(mav560-mav1120); var9 = abs(mav1120-mav1800); input : Atime(30),P1(2),P2(3),P3(5),P4(10),P5(20),P6(40); var : TF(0),cnt(0),sum1(0),bmav2(0),sum2(0),bmav3(0),sum3(0),bmav5(0),sum4(0),bmav10(0),sum5(0),bmav20(0),sum6(0),bmav40(0); Array : CC[500](0); TF = TimeToMinutes(stime)%Atime; if dayindex() == 0 or (TF < TF[1] and stime > stime[1]) Then { for cnt = 1 to 499 { CC[cnt] = CC[cnt-1][1]; } } CC[0] = C; if CC[P6-1] > 0 then { sum1 = 0; sum2 = 0; sum3 = 0; sum4 = 0; sum5 = 0; sum6 = 0; for cnt = 0 to P6 { if cnt < P1 Then sum1 = sum1+CC[cnt]; if cnt < P2 Then sum2 = sum2+CC[cnt]; if cnt < P3 Then sum3 = sum3+CC[cnt]; if cnt < P4 Then sum4 = sum4+CC[cnt]; if cnt < P5 Then sum5 = sum5+CC[cnt]; if cnt < P6 Then sum6 = sum6+CC[cnt]; } Bmav2 = sum1/P1; Bmav3 = sum2/P2; Bmav5 = sum3/P3; Bmav10 = sum4/P4; Bmav20 = sum5/P5; Bmav40 = sum6/P6; } if (sdate != sdate[1] and stime >= 시작시간) or (sdate == sdate[1] and (Stime == 시작시간 or (stime > 시작시간 and stime[1] < 시작시간))) Then { Tcond = True; BXcond = false; SXcond = false; } if stime == 종료시간 or (stime > 종료시간 and stime[1] < 종료시간) Then { Tcond = false; if MarketPosition == 1 Then ExitLong(); if MarketPosition == -1 Then ExitShort(); } if TotalTrades > TotalTrades[1] then { BXcond = false; SXcond = false; if (IsExitName("bl",0) == true or IsExitName("bp",0) == true or IsExitName("bx",0) == true or IsExitName("bx",0) == true) Then BXcond = true; if (IsExitName("sl",0) == true or IsExitName("sp",0) == true or IsExitName("sx",0) == true or IsExitName("sx",0) == true) Then SXcond = true; } if Tcond == true then { if MarketPosition >= 0 Then if mav3600 < c and mav7200 > mav4800 and mav4800 > mav2400 and mav2400 < mav1200 and mav1200 < mav600 and mav1200 < mav300 and ((mav4800 < mav600)or (mav4800 < mav300)) and mav7200[1] > mav7200 and mav4800[1] > mav4800 and mav2400[1] < mav2400 and mav1200[1] < mav1200 and mav900[3] > mav900[2] and mav900[2] > mav900[1] and mav900[1] > mav900 and mav300[1] > mav300 and mav150[1] > mav150 and mav80[1] > mav80 and mav40[1] > mav40 and mav20[1] > mav20 and mav10[1] > mav10 and Bmav40 > Bmav20 and Bmav20 > Bmav10 Then { if CurrentContracts < 1 Then sell("s4",OnClose,def,1); } if MarketPosition == -1 then { #s3 if mav3000[1] < mav3000 and mav2400[1] < mav2400 and mav1200[1] < mav1200 and mav150[1] < mav150 and mav80[1] < mav80 Then { ExitShort("s4-1",OnClose,def,"s4"); } Else if mav2400[1] > mav2400 and mav600[20] > mav600 and mav600[3] > mav600[2] and mav600[2] < mav600[1] and mav600[1] < mav600 Then { ExitShort("s4-2",OnClose,def,"s4"); } Else if mav2400[1] > mav2400 and mav600 > mav300 and mav300[30] > mav300 and mav300[3] < mav300[2] and mav300[2] < mav300[1] and mav300[1] < mav300 Then { ExitShort("s4-3",OnClose,def,"s4"); } Else { if mav2400[1] > mav2400 and mav900 > mav600 and mav600 > mav300 and crossuP(mav80,mav150) Then ExitShort("s4-4",OnClose,def,"s4"); } ExitShort("sp",atlimit,AvgEntryPrice-PriceScale*익절틱수s4,"s4"); ExitShort("sl",AtStop,AvgEntryPrice+PriceScale*손절틱수s4,"s4"); } } 위 수식을 활용하여 시뮬레이션차트 30틱에서 건수 900,000바 환경에서 익절틱수s4(변수이름)을 변수편집을 이용하여 최소60, 최대120, 증가 1로 설정하여 시뮬레이션하면 왜 1개의 값만 나오고 시뮬레이션할 때 마다 다른 값이 나오는지 궁금합니다 실제로 범위내에서 다른 값을 적용하면 시뮬레이션에서 나오 값보다 높은값이 나오는지 궁금합니다 몇일을 찾았으나 원인을 알 수 없어요 감사합니다.