커뮤니티

문의 합니다

프로필 이미지
남산
2019-02-27 19:39:38
232
글번호 126622
답변완료
input : 시작시간(090000),종료시간(0); input : Period15(15),Period20(20),Period30(30),Period120(120),Period180(180),Period240(240),Period480(480), Period960(960),Period60(60),Period3(3),Period10(10),Period2(2),Period7(7),Period144(144),Period100(100); input : 초기진입익절틱수(150),초기진입손절틱수(150),추가진입익절틱수(200),추가진입손절틱수(200); var : mav15(0),mav20(0),mav30(0),mav120(0),mav180(0),mav240(0),mav480(0),mav960(0),mav60(0),mav1(0), mav3(0),mav10(0),mav2(0),mav7(0),mav144(0),mav100(0),Bxcond(false),Sxcond(false); var : Tcond(false); var : T(0); input : ntime1(4),P(50); var : S1(0),D1(0),TM(0),TF(0); var : cnt(0),sum1(0),tmav1(0),tmav11(0),tmav12(0),tmav13(0); Array : C1[50](0); if Bdate != Bdate[1] Then { S1 = TimeToMinutes(stime); D1 = sdate; } if D1 > 0 then { if sdate == D1 Then TM = TimeToMinutes(stime)-S1; Else TM = TimeToMinutes(stime)+1440-S1; TF = TM%ntime1; if Bdate != Bdate[1] or (Bdate == Bdate[1] and TF < TF[1]) Then { for cnt = 1 to 49 { C1[cnt] = C1[cnt-1][1]; } tmav11 = tmav1[1]; tmav12 = tmav11[1]; tmav13 = tmav12[1]; } C1[0] = C; if C1[P] > 0 then{ sum1 = 0; for cnt = 0 to P-1{ sum1 = sum1+C1[cnt]; } tmav1 = sum1/P; } } mav15 = ma(c, Period15); mav20 = ma(c, Period20); mav30 = ma(c, Period30); mav120 = ma(c, Period120); mav180 = ma(c, Period180); mav240 = ma(c, Period240); mav480 = ma(c, Period480); mav960 = ma(c, Period960); mav60 = ma(c, Period60); mav3 = ma(c, Period3); mav10 = ma(c, Period10); mav2 = ma(c, Period2); mav7 = ma(c, Period7); mav144 = ma(c, Period144); mav100 = ma(c, Period100); 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",1) == true or IsExitName("bx",1) == true) Then BXcond = true; if (IsExitName("sl",0) == true or IsExitName("sp",0) == true or IsExitName("sx",1) == true or IsExitName("sx",1) == true) Then SXcond = true; } if Tcond == true then { if MarketPosition <= 0 and Bxcond == false and tmav13 < tmav12 and tmav12 < tmav11 and tmav11 < tmav1 and tmav12 > 0 Then { buy("매수",OnClose,def,1); } if MarketPosition == 1 Then { if crossup(mav20, mav30) and CurrentContracts < 5 Then buy("매수1",OnClose,def,1); } if MarketPosition == 1 Then { if (tmav12 > tmav11 and tmav11 > tmav1 and tmav12 > 0) Then exitlong("수청산",OnClose,def,"매수"); if (CrossDown(mav20, mav30)) or (tmav12 > tmav11 and tmav11 > tmav1 and tmav12 > 0) Then exitlong("수청산1",OnClose,def,"매수1"); ExitLong("bp1",atlimit,AvgEntryPrice+PriceScale*초기진입익절틱수,"매수"); ExitLong("bl1",AtStop,AvgEntryPrice-PriceScale*초기진입손절틱수,"매수"); ExitLong("bp2",atlimit,AvgEntryPrice+PriceScale*추가진입익절틱수,"매수1"); ExitLong("bl2",AtStop,AvgEntryPrice-PriceScale*추가진입손절틱수,"매수1"); } if MarketPosition >= 0 and Sxcond == false and tmav13 > tmav12 and tmav12 > tmav11 and tmav11 > tmav1 and tmav12 > 0 Then { sell("매도",OnClose,def,1); } if MarketPosition == -1 then { if CrossDown(mav20, mav30) and CurrentContracts < 5 Then sell("매도1",OnClose,def,1); } if MarketPosition == -1 then { if (tmav12 < tmav11 and tmav11 < tmav1 and tmav12 > 0) Then ExitShort("도청산",OnClose,def,"매도"); if (crossup(mav20, mav30)) or (tmav12 < tmav11 and tmav11 < tmav1 and tmav12 > 0) Then ExitShort("도청산1",OnClose,def,"매도1"); ExitShort("sp1",atlimit,AvgEntryPrice-PriceScale*초기진입익절틱수,"매도"); ExitShort("sl1",AtStop,AvgEntryPrice+PriceScale*초기진입손절틱수,"매도"); ExitShort("sp2",atlimit,AvgEntryPrice-PriceScale*추가진입익절틱수,"매도1"); ExitShort("sl2",AtStop,AvgEntryPrice+PriceScale*추가진입손절틱수,"매도1"); } } 위 수식은 평균틱수 익절 및 손절을 지정하였습니다 지정한 익절틱수 손절틱수로 변경하고자 하오니 수식변경 부탁합니다 항상 감사합니다
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2019-02-28 13:42:46

안녕하세요 예스스탁입니다. 각 진입별로 손익절을 지정하고자 하시면 진입의 이름을 세부적으로 나누어 그이름으로 지정되어야 합니다. 아래 수식 참고하시기 바랍니다. input : 시작시간(090000),종료시간(0); input : Period15(15),Period20(20),Period30(30),Period120(120),Period180(180),Period240(240),Period480(480), Period960(960),Period60(60),Period3(3),Period10(10),Period2(2),Period7(7),Period144(144),Period100(100); input : 익절틱수1(150),손절틱수1(150),익절틱수2(200),손절틱수2(200),익절틱수3(200),손절틱수3(200),익절틱수4(200),손절틱수4(200),익절틱수5(200),손절틱수5(200); var : mav15(0),mav20(0),mav30(0),mav120(0),mav180(0),mav240(0),mav480(0),mav960(0),mav60(0),mav1(0), mav3(0),mav10(0),mav2(0),mav7(0),mav144(0),mav100(0),Bxcond(false),Sxcond(false); var : Tcond(false); var : T(0); input : ntime1(4),P(50); var : S1(0),D1(0),TM(0),TF(0); var : cnt(0),sum1(0),tmav1(0),tmav11(0),tmav12(0),tmav13(0); Array : C1[50](0); var : BE1(0),BE2(0),BE3(0),BE4(0),BE5(0); var : SE1(0),SE2(0),SE3(0),SE4(0),SE5(0); if Bdate != Bdate[1] Then { S1 = TimeToMinutes(stime); D1 = sdate; } if D1 > 0 then { if sdate == D1 Then TM = TimeToMinutes(stime)-S1; Else TM = TimeToMinutes(stime)+1440-S1; TF = TM%ntime1; if Bdate != Bdate[1] or (Bdate == Bdate[1] and TF < TF[1]) Then { for cnt = 1 to 49 { C1[cnt] = C1[cnt-1][1]; } tmav11 = tmav1[1]; tmav12 = tmav11[1]; tmav13 = tmav12[1]; } C1[0] = C; if C1[P] > 0 then{ sum1 = 0; for cnt = 0 to P-1{ sum1 = sum1+C1[cnt]; } tmav1 = sum1/P; } } mav15 = ma(c, Period15); mav20 = ma(c, Period20); mav30 = ma(c, Period30); mav120 = ma(c, Period120); mav180 = ma(c, Period180); mav240 = ma(c, Period240); mav480 = ma(c, Period480); mav960 = ma(c, Period960); mav60 = ma(c, Period60); mav3 = ma(c, Period3); mav10 = ma(c, Period10); mav2 = ma(c, Period2); mav7 = ma(c, Period7); mav144 = ma(c, Period144); mav100 = ma(c, Period100); 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",1) == true or IsExitName("bx",1) == true) Then BXcond = true; if (IsExitName("sl",0) == true or IsExitName("sp",0) == true or IsExitName("sx",1) == true or IsExitName("sx",1) == true) Then SXcond = true; } if Tcond == true then { if MarketPosition <= 0 and Bxcond == false and tmav13 < tmav12 and tmav12 < tmav11 and tmav11 < tmav1 and tmav12 > 0 Then { buy("매수1",OnClose,def,1); } if MarketPosition == 1 Then { if crossup(mav20, mav30) and MaxEntries == 1 Then buy("매수2",OnClose,def,1); if crossup(mav20, mav30) and MaxEntries == 2 Then buy("매수3",OnClose,def,1); if crossup(mav20, mav30) and MaxEntries == 3 Then buy("매수4",OnClose,def,1); if crossup(mav20, mav30) and MaxEntries == 4 Then buy("매수5",OnClose,def,1); } if MarketPosition == 1 Then { if (tmav12 > tmav11 and tmav11 > tmav1 and tmav12 > 0) Then exitlong("수청산1",OnClose,def,"매수1"); if (CrossDown(mav20, mav30)) or (tmav12 > tmav11 and tmav11 > tmav1 and tmav12 > 0) Then { exitlong("수청산2",OnClose,def,"매수2"); exitlong("수청산3",OnClose,def,"매수3"); exitlong("수청산4",OnClose,def,"매수4"); exitlong("수청산5",OnClose,def,"매수5"); } if CurrentContracts > CurrentContracts[1] and MaxEntries == 1 Then BE1 = LatestEntryPrice(0); if CurrentContracts > CurrentContracts[1] and MaxEntries == 2 Then BE2 = LatestEntryPrice(0); if CurrentContracts > CurrentContracts[1] and MaxEntries == 3 Then BE3 = LatestEntryPrice(0); if CurrentContracts > CurrentContracts[1] and MaxEntries == 4 Then BE4 = LatestEntryPrice(0); if CurrentContracts > CurrentContracts[1] and MaxEntries == 5 Then BE5 = LatestEntryPrice(0); ExitLong("bp1",atlimit,BE1+PriceScale*익절틱수1,"매수1"); ExitLong("bl1",AtStop,BE1-PriceScale*손절틱수1,"매수1"); ExitLong("bp2",atlimit,BE2+PriceScale*익절틱수2,"매수2"); ExitLong("bl2",AtStop,BE2-PriceScale*손절틱수2,"매수2"); ExitLong("bp3",atlimit,BE3+PriceScale*익절틱수3,"매수3"); ExitLong("bl3",AtStop,BE3-PriceScale*손절틱수3,"매수3"); ExitLong("bp4",atlimit,BE4+PriceScale*익절틱수4,"매수4"); ExitLong("bl4",AtStop,BE4-PriceScale*손절틱수4,"매수4"); ExitLong("bp5",atlimit,BE5+PriceScale*익절틱수5,"매수5"); ExitLong("bl5",AtStop,BE5-PriceScale*손절틱수5,"매수5"); } if MarketPosition >= 0 and Sxcond == false and tmav13 > tmav12 and tmav12 > tmav11 and tmav11 > tmav1 and tmav12 > 0 Then { sell("매도1",OnClose,def,1); } if MarketPosition == -1 then { if CrossDown(mav20, mav30) and MaxEntries == 1 Then sell("매도2",OnClose,def,1); if CrossDown(mav20, mav30) and MaxEntries == 2 Then sell("매도3",OnClose,def,1); if CrossDown(mav20, mav30) and MaxEntries == 3 Then sell("매도4",OnClose,def,1); if CrossDown(mav20, mav30) and MaxEntries == 4 Then sell("매도5",OnClose,def,1); } if MarketPosition == -1 then { if (tmav12 < tmav11 and tmav11 < tmav1 and tmav12 > 0) Then ExitShort("도청산1",OnClose,def,"매도1"); if (crossup(mav20, mav30)) or (tmav12 < tmav11 and tmav11 < tmav1 and tmav12 > 0) Then { ExitShort("도청산2",OnClose,def,"매도2"); ExitShort("도청산3",OnClose,def,"매도3"); ExitShort("도청산4",OnClose,def,"매도4"); ExitShort("도청산5",OnClose,def,"매도5"); } if CurrentContracts > CurrentContracts[1] and MaxEntries == 1 Then SE1 = LatestEntryPrice(0); if CurrentContracts > CurrentContracts[1] and MaxEntries == 2 Then SE2 = LatestEntryPrice(0); if CurrentContracts > CurrentContracts[1] and MaxEntries == 3 Then SE3 = LatestEntryPrice(0); if CurrentContracts > CurrentContracts[1] and MaxEntries == 4 Then SE4 = LatestEntryPrice(0); if CurrentContracts > CurrentContracts[1] and MaxEntries == 5 Then SE5 = LatestEntryPrice(0); ExitShort("sp1",atlimit,SE1-PriceScale*익절틱수1,"매도1"); ExitShort("sl1",AtStop,SE1+PriceScale*손절틱수1,"매도1"); ExitShort("sp2",atlimit,SE2-PriceScale*익절틱수2,"매도2"); ExitShort("sl2",AtStop,SE2+PriceScale*손절틱수2,"매도2"); ExitShort("sp3",atlimit,SE3-PriceScale*익절틱수3,"매도3"); ExitShort("sl3",AtStop,SE3+PriceScale*손절틱수3,"매도3"); ExitShort("sp4",atlimit,SE4-PriceScale*익절틱수4,"매도4"); ExitShort("sl4",AtStop,SE4+PriceScale*손절틱수4,"매도4"); ExitShort("sp5",atlimit,SE5-PriceScale*익절틱수5,"매도5"); ExitShort("sl5",AtStop,SE5+PriceScale*손절틱수5,"매도5"); } } 즐거운 하루되세요 > 남산 님이 쓴 글입니다. > 제목 : 문의 합니다 > input : 시작시간(090000),종료시간(0); input : Period15(15),Period20(20),Period30(30),Period120(120),Period180(180),Period240(240),Period480(480), Period960(960),Period60(60),Period3(3),Period10(10),Period2(2),Period7(7),Period144(144),Period100(100); input : 초기진입익절틱수(150),초기진입손절틱수(150),추가진입익절틱수(200),추가진입손절틱수(200); var : mav15(0),mav20(0),mav30(0),mav120(0),mav180(0),mav240(0),mav480(0),mav960(0),mav60(0),mav1(0), mav3(0),mav10(0),mav2(0),mav7(0),mav144(0),mav100(0),Bxcond(false),Sxcond(false); var : Tcond(false); var : T(0); input : ntime1(4),P(50); var : S1(0),D1(0),TM(0),TF(0); var : cnt(0),sum1(0),tmav1(0),tmav11(0),tmav12(0),tmav13(0); Array : C1[50](0); if Bdate != Bdate[1] Then { S1 = TimeToMinutes(stime); D1 = sdate; } if D1 > 0 then { if sdate == D1 Then TM = TimeToMinutes(stime)-S1; Else TM = TimeToMinutes(stime)+1440-S1; TF = TM%ntime1; if Bdate != Bdate[1] or (Bdate == Bdate[1] and TF < TF[1]) Then { for cnt = 1 to 49 { C1[cnt] = C1[cnt-1][1]; } tmav11 = tmav1[1]; tmav12 = tmav11[1]; tmav13 = tmav12[1]; } C1[0] = C; if C1[P] > 0 then{ sum1 = 0; for cnt = 0 to P-1{ sum1 = sum1+C1[cnt]; } tmav1 = sum1/P; } } mav15 = ma(c, Period15); mav20 = ma(c, Period20); mav30 = ma(c, Period30); mav120 = ma(c, Period120); mav180 = ma(c, Period180); mav240 = ma(c, Period240); mav480 = ma(c, Period480); mav960 = ma(c, Period960); mav60 = ma(c, Period60); mav3 = ma(c, Period3); mav10 = ma(c, Period10); mav2 = ma(c, Period2); mav7 = ma(c, Period7); mav144 = ma(c, Period144); mav100 = ma(c, Period100); 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",1) == true or IsExitName("bx",1) == true) Then BXcond = true; if (IsExitName("sl",0) == true or IsExitName("sp",0) == true or IsExitName("sx",1) == true or IsExitName("sx",1) == true) Then SXcond = true; } if Tcond == true then { if MarketPosition <= 0 and Bxcond == false and tmav13 < tmav12 and tmav12 < tmav11 and tmav11 < tmav1 and tmav12 > 0 Then { buy("매수",OnClose,def,1); } if MarketPosition == 1 Then { if crossup(mav20, mav30) and CurrentContracts < 5 Then buy("매수1",OnClose,def,1); } if MarketPosition == 1 Then { if (tmav12 > tmav11 and tmav11 > tmav1 and tmav12 > 0) Then exitlong("수청산",OnClose,def,"매수"); if (CrossDown(mav20, mav30)) or (tmav12 > tmav11 and tmav11 > tmav1 and tmav12 > 0) Then exitlong("수청산1",OnClose,def,"매수1"); ExitLong("bp1",atlimit,AvgEntryPrice+PriceScale*초기진입익절틱수,"매수"); ExitLong("bl1",AtStop,AvgEntryPrice-PriceScale*초기진입손절틱수,"매수"); ExitLong("bp2",atlimit,AvgEntryPrice+PriceScale*추가진입익절틱수,"매수1"); ExitLong("bl2",AtStop,AvgEntryPrice-PriceScale*추가진입손절틱수,"매수1"); } if MarketPosition >= 0 and Sxcond == false and tmav13 > tmav12 and tmav12 > tmav11 and tmav11 > tmav1 and tmav12 > 0 Then { sell("매도",OnClose,def,1); } if MarketPosition == -1 then { if CrossDown(mav20, mav30) and CurrentContracts < 5 Then sell("매도1",OnClose,def,1); } if MarketPosition == -1 then { if (tmav12 < tmav11 and tmav11 < tmav1 and tmav12 > 0) Then ExitShort("도청산",OnClose,def,"매도"); if (crossup(mav20, mav30)) or (tmav12 < tmav11 and tmav11 < tmav1 and tmav12 > 0) Then ExitShort("도청산1",OnClose,def,"매도1"); ExitShort("sp1",atlimit,AvgEntryPrice-PriceScale*초기진입익절틱수,"매도"); ExitShort("sl1",AtStop,AvgEntryPrice+PriceScale*초기진입손절틱수,"매도"); ExitShort("sp2",atlimit,AvgEntryPrice-PriceScale*추가진입익절틱수,"매도1"); ExitShort("sl2",AtStop,AvgEntryPrice+PriceScale*추가진입손절틱수,"매도1"); } } 위 수식은 평균틱수 익절 및 손절을 지정하였습니다 지정한 익절틱수 손절틱수로 변경하고자 하오니 수식변경 부탁합니다 항상 감사합니다