커뮤니티

전에 문의했던 사항인데 잘 안되어 다시 부탁드리겠습니다. (매수진입 및 매도 진입)

프로필 이미지
이형지
2020-04-21 22:34:41
612
글번호 138195
답변완료
해당 수식으로 손절을 적용하고 있는데요... ExitLong("즉시손절1",AtStop,EntryPrice-PriceScale*즉시손절1); 매수 진입한 봉한개에서 에서 하락 틱수가 "즉시손절1"틱수를 넘어서더라도 손절처리가 안되요... 매수한 다음봉부터 인지를 한다고 들었습니다. 그러면 진입하자마자 해당봉에서 손실을 제한하는 수식을 알려주시면 감사하겠습니다. 수식은 다음과 같습니다. 변수중 "즉시손절1" 값에 도달시 청산하는 수식 부탁드려요~~ 그봉에 # 매수 진입 조건 변수 Input : RSIPeriod(7),RSI매수값(28),SimPeriod(14),심리도값(36); # RSI와 심리도 기간 및 값 변수 Input : N1(1),초기화(3); # 위 해당 조건 발생후 진입 유효 기간, 7일경과후 초기화 Input : 하락틱수(2); # 해당 조건 발생후 하락틱수만큼 하락후 진입 변수 Input : RSIPeriod1(6),A(0),B(4),D(48),E(72); # 일봉기준 RSI값이 해당변수안에 속해있을때 진입 변수 Input : 거래량1(600),거래량평균봉수(55),거래량평균봉수비율(3.6); # 해당 거래량1,2 사이에 속해 있을때 진입되는 변수 18000 # 1일 1회 거래 # 청산 조건 변수 Input : CCI기간(20),CCI값(500); # CCI값에 의해 청산 수식 변수 Input : 즉시익절1(70),즉시손절1(90); # 익절값 손절값 변수 Input : N2(0.6),N3(0.15); # 상승후 본절청산 관련 수식 Input : tr수익(70),tr하락(25); # 트레일링 관련 수식 Input : N4(0.7),본전생각틱(10); # 하락후 본절청산 관련 수식 Input : N5(0.8),CCI값1(120); # 약 손절 관련 수식 Input : 터치익절(105); var : cnt(0),SigSum(0),count2(0),RSIsig(0); Var : Counter(0), DownAmt(0), UpAmt(0), UpSum(0), DownSum(0), UpAvg(0), DownAvg(0); var : idx(0), PreUpAvg(0), preDownAvg(0),RSIVv(0); Array : C1[100](0); var : CCIv(0),RSIv(0),Simri(0),BuySetup(false),DD(0),entry(0); CCIv = CCI(CCI기간); RSIV = RSI(RSIPeriod); Simri = Simrido(SimPeriod); var4 = ma(V,20); if Bdate != Bdate[1] Then { for cnt = 1 to 99 { C1[cnt] = C1[cnt-1][1]; } PreUpAvg = UpAvg[1]; preDownAvg = DownAvg[1]; idx = idx + 1; } C1[0] = C; If idx == RSIPeriod1+2 Then { UpSum = 0; DownSum = 0; For Counter = 0 To RSIPeriod1 - 1 { UpAmt = C1[Counter] - C1[Counter+1]; If UpAmt >= 0 Then DownAmt = 0; Else { DownAmt = -UpAmt; UpAmt = 0; } UpSum = UpSum + UpAmt; DownSum = DownSum + DownAmt; } UpAvg = UpSum / RSIPeriod1; DownAvg = DownSum / RSIPeriod1; } If idx > RSIPeriod1+2 Then { UpAmt = C1[0] - C1[1]; If UpAmt >= 0 Then DownAmt = 0; Else { DownAmt = -UpAmt; UpAmt = 0; } UpAvg = (PreUpAvg * (RSIPeriod1 - 1) + UpAmt) / RSIPeriod1; DownAvg = (preDownAvg * (RSIPeriod1 - 1) + DownAmt) / RSIPeriod1; } If UpAvg + DownAvg <> 0 Then RSIvv = 100 * UpAvg / (UpAvg + DownAvg); Else RSIvv = 0; if bdate != bdate[1] Then { Entry = 0; Condition2 = true; } if MarketPosition != 0 and MarketPosition != MarketPosition[1] Then entry = entry+1; if TotalTrades > TotalTrades[1] and (IsExitName("즉시손절1",1) == true or IsExitName("본전청산1",1)) then Condition2 = false; Condition1 = RSIv < RSI매수값 and Simri < 심리도값 and ((RSIVV > A and RSIVV < B) or (RSIVV > D and RSIVV < E)) ; if bdate != bdate[1] Then { DD = DD+1; if var2 > 0 and DD == var2+초기화 Then BuySetup = false; } if BuySetup == false and Condition1 == true and Condition1[1] == false Then { var1 = C; var2 = DD; BuySetup = true; } if Condition2 == true and MarketPosition == 0 and C < O and C[1] < O and BuySetup == true and entry == 0 and v < ma(v,거래량평균봉수)*거래량평균봉수비율 and v > 거래량1 Then # and C < O buy("매수",AtLimit,var1-PriceScale*하락틱수); if MarketPosition == 1 then { BuySetup = false; SetStopProfittarget(PriceScale*터치익절,PointStop); if countif(CrossDown(CCIv,CCI값),BarsSinceEntry) >= 1 and CCIv < CCI값 and C < O Then ExitLong("매수cci청산",OnClose); if highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*즉시익절1 and C < O Then ExitLong("즉시익절1",OnClose); if highest(H,BarsSinceEntry) >= (EntryPrice+PriceScale*즉시익절1*N2) Then ExitLong("본전청산1",AtStop,EntryPrice+PriceScale*즉시익절1*N3); Else { ExitLong("즉시손절1",AtStop,EntryPrice-PriceScale*즉시손절1); } if highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*tr수익 Then ExitLong("tr",AtStop, highest(H,BarsSinceEntry)-PriceScale*tr하락); if lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*즉시손절1*N4 and C < O Then ExitLong("저점에서 올라와서 본전 청산",atlimit,EntryPrice+PriceScale*본전생각틱); if lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*즉시손절1 *N5 and CCIv >= CCI값1 and C < O Then ExitLong("저점에서 올라와서 약손절",OnClose); } ===================================================================================== 매도 진입 및 청산 수식 # 매도 진입 조건 변수 Input : RSIPeriod(7),RSI매수값(65),SimPeriod(7),심리도값(45); Input : N1(1),초기화(2); Input : 하락틱수(5); Input : RSIPeriod1(6),A(14),B(40),D(88),E(100); Input : 거래량1(100),거래량평균봉수(60),거래량평균봉수비율(4); # Input : 거래량1(100),거래량2(22000); # 청산 조건 변수 Input : 즉시익절1(70),즉시손절1(70); Input : N2(0.25),N3(-0.75); Input : tr수익(75),tr하락(55); Input : N4(0.45),본전생각틱(55); Input : 터치익절(115); var : cnt(0),SigSum(0),count2(0),RSIsig(0); Var : Counter(0), DownAmt(0), UpAmt(0), UpSum(0), DownSum(0), UpAvg(0), DownAvg(0); var : idx(0), PreUpAvg(0), preDownAvg(0),RSIVv(0); Array : C1[100](0); var : CCIv(0),RSIv(0),Simri(0),SellSetup(false),DD(0),entry(0); RSIV = RSI(RSIPeriod); Simri = Simrido(SimPeriod); if Bdate != Bdate[1] Then { for cnt = 1 to 99 { C1[cnt] = C1[cnt-1][1]; } PreUpAvg = UpAvg[1]; preDownAvg = DownAvg[1]; idx = idx + 1; } C1[0] = C; If idx == RSIPeriod1+2 Then { UpSum = 0; DownSum = 0; For Counter = 0 To RSIPeriod1 - 1 { UpAmt = C1[Counter] - C1[Counter+1]; If UpAmt >= 0 Then DownAmt = 0; Else { DownAmt = -UpAmt; UpAmt = 0; } UpSum = UpSum + UpAmt; DownSum = DownSum + DownAmt; } UpAvg = UpSum / RSIPeriod1; DownAvg = DownSum / RSIPeriod1; } If idx > RSIPeriod1+2 Then { UpAmt = C1[0] - C1[1]; If UpAmt >= 0 Then DownAmt = 0; Else { DownAmt = -UpAmt; UpAmt = 0; } UpAvg = (PreUpAvg * (RSIPeriod1 - 1) + UpAmt) / RSIPeriod1; DownAvg = (preDownAvg * (RSIPeriod1 - 1) + DownAmt) / RSIPeriod1; } If UpAvg + DownAvg <> 0 Then RSIvv = 100 * UpAvg / (UpAvg + DownAvg); Else RSIvv = 0; if bdate != bdate[1] Then { Entry = 0; Condition2 = true; } if MarketPosition != 0 and MarketPosition != MarketPosition[1] Then entry = entry+1; if TotalTrades > TotalTrades[1] and (IsExitName("즉시손절1",1) == true or IsExitName("본전청산1",1)) then Condition2 = false; Condition1 = RSIv > RSI매수값 and Simri > 심리도값 and ((RSIVV > A and RSIVV < B) or (RSIVV > D and RSIVV < E)) ; if bdate != bdate[1] Then { DD = DD+1; if var2 > 0 and DD == var2+초기화 Then SellSetup = false; } if SellSetup == false and Condition1 == true and Condition1[1] == false Then { var1 = C; var2 = DD; SellSetup = true; } if Condition2 == true and MarketPosition == 0 and SellSetup == true and C > O and entry == 0 and v > 거래량1 and v < ma(v,거래량평균봉수)*거래량평균봉수비율 Then sell("매도",AtStop,var1+PriceScale*하락틱수); if MarketPosition == -1 then { SellSetup = false; SetStopProfittarget(PriceScale*터치익절,PointStop); if Lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*즉시익절1 and C > O Then ExitShort("s즉시익절1",OnClose); if Lowest(L,BarsSinceEntry) <= (EntryPrice-PriceScale*즉시익절1*N2) Then ExitShort("s본전청산1",AtStop,EntryPrice-PriceScale*즉시익절1*N3); Else ExitShort("s즉시손절1",AtStop,EntryPrice+PriceScale*즉시손절1); if Lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*tr수익 Then ExitShort("str",AtStop, Lowest(L,BarsSinceEntry)+PriceScale*tr하락); if Highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*즉시손절1*N4 and C > O Then ExitShort("s고점에서 내려와서 본전 청산",atlimit,EntryPrice-PriceScale*본전생각틱); }
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2020-04-22 10:24:18

안녕하세요 예스스탁입니다. 올려주신 수식에서는 손절도 터치익절과 같이 강제청산함수로 처리하시면 됩니다. 1 # 매수 진입 조건 변수 Input : RSIPeriod(7),RSI매수값(28),SimPeriod(14),심리도값(36); # RSI와 심리도 기간 및 값 변수 Input : N1(1),초기화(3); # 위 해당 조건 발생후 진입 유효 기간, 7일경과후 초기화 Input : 하락틱수(2); # 해당 조건 발생후 하락틱수만큼 하락후 진입 변수 Input : RSIPeriod1(6),A(0),B(4),D(48),E(72); # 일봉기준 RSI값이 해당변수안에 속해있을때 진입 변수 Input : 거래량1(600),거래량평균봉수(55),거래량평균봉수비율(3.6); # 해당 거래량1,2 사이에 속해 있을때 진입되는 변수 18000 # 1일 1회 거래 # 청산 조건 변수 Input : CCI기간(20),CCI값(500); # CCI값에 의해 청산 수식 변수 Input : 즉시익절1(70),즉시손절1(90); # 익절값 손절값 변수 Input : N2(0.6),N3(0.15); # 상승후 본절청산 관련 수식 Input : tr수익(70),tr하락(25); # 트레일링 관련 수식 Input : N4(0.7),본전생각틱(10); # 하락후 본절청산 관련 수식 Input : N5(0.8),CCI값1(120); # 약 손절 관련 수식 Input : 터치익절(105); var : cnt(0),SigSum(0),count2(0),RSIsig(0); Var : Counter(0), DownAmt(0), UpAmt(0), UpSum(0), DownSum(0), UpAvg(0), DownAvg(0); var : idx(0), PreUpAvg(0), preDownAvg(0),RSIVv(0); Array : C1[100](0); var : CCIv(0),RSIv(0),Simri(0),BuySetup(false),DD(0),entry(0); CCIv = CCI(CCI기간); RSIV = RSI(RSIPeriod); Simri = Simrido(SimPeriod); var4 = ma(V,20); if Bdate != Bdate[1] Then { for cnt = 1 to 99 { C1[cnt] = C1[cnt-1][1]; } PreUpAvg = UpAvg[1]; preDownAvg = DownAvg[1]; idx = idx + 1; } C1[0] = C; If idx == RSIPeriod1+2 Then { UpSum = 0; DownSum = 0; For Counter = 0 To RSIPeriod1 - 1 { UpAmt = C1[Counter] - C1[Counter+1]; If UpAmt >= 0 Then DownAmt = 0; Else { DownAmt = -UpAmt; UpAmt = 0; } UpSum = UpSum + UpAmt; DownSum = DownSum + DownAmt; } UpAvg = UpSum / RSIPeriod1; DownAvg = DownSum / RSIPeriod1; } If idx > RSIPeriod1+2 Then { UpAmt = C1[0] - C1[1]; If UpAmt >= 0 Then DownAmt = 0; Else { DownAmt = -UpAmt; UpAmt = 0; } UpAvg = (PreUpAvg * (RSIPeriod1 - 1) + UpAmt) / RSIPeriod1; DownAvg = (preDownAvg * (RSIPeriod1 - 1) + DownAmt) / RSIPeriod1; } If UpAvg + DownAvg <> 0 Then RSIvv = 100 * UpAvg / (UpAvg + DownAvg); Else RSIvv = 0; if bdate != bdate[1] Then { Entry = 0; Condition2 = true; } if MarketPosition != 0 and MarketPosition != MarketPosition[1] Then entry = entry+1; if TotalTrades > TotalTrades[1] and (IsExitName("즉시손절1",1) == true or IsExitName("본전청산1",1)) then Condition2 = false; Condition1 = RSIv < RSI매수값 and Simri < 심리도값 and ((RSIVV > A and RSIVV < B) or (RSIVV > D and RSIVV < E)) ; if bdate != bdate[1] Then { DD = DD+1; if var2 > 0 and DD == var2+초기화 Then BuySetup = false; } if BuySetup == false and Condition1 == true and Condition1[1] == false Then { var1 = C; var2 = DD; BuySetup = true; } if Condition2 == true and MarketPosition == 0 and C < O and C[1] < O and BuySetup == true and entry == 0 and v < ma(v,거래량평균봉수)*거래량평균봉수비율 and v > 거래량1 Then # and C < O { buy("매수",AtLimit,var1-PriceScale*하락틱수); ExitLong("즉시손절1",AtStop,EntryPrice-PriceScale*즉시손절1); } if MarketPosition == 1 then { BuySetup = false; if countif(CrossDown(CCIv,CCI값),BarsSinceEntry) >= 1 and CCIv < CCI값 and C < O Then ExitLong("매수cci청산",OnClose); if highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*즉시익절1 and C < O Then ExitLong("즉시익절1",OnClose); if highest(H,BarsSinceEntry) >= (EntryPrice+PriceScale*즉시익절1*N2) Then ExitLong("본전청산1",AtStop,EntryPrice+PriceScale*즉시익절1*N3); if highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*tr수익 Then ExitLong("tr",AtStop, highest(H,BarsSinceEntry)-PriceScale*tr하락); if lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*즉시손절1*N4 and C < O Then ExitLong("저점에서 올라와서 본전 청산",atlimit,EntryPrice+PriceScale*본전생각틱); if lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*즉시손절1 *N5 and CCIv >= CCI값1 and C < O Then ExitLong("저점에서 올라와서 약손절",OnClose); } SetStopLoss(PriceScale*즉시손절1,PointStop); SetStopProfittarget(PriceScale*터치익절,PointStop); 2 # 매도 진입 조건 변수 Input : RSIPeriod(7),RSI매수값(65),SimPeriod(7),심리도값(45); Input : N1(1),초기화(2); Input : 하락틱수(5); Input : RSIPeriod1(6),A(14),B(40),D(88),E(100); Input : 거래량1(100),거래량평균봉수(60),거래량평균봉수비율(4); # Input : 거래량1(100),거래량2(22000); # 청산 조건 변수 Input : 즉시익절1(70),즉시손절1(70); Input : N2(0.25),N3(-0.75); Input : tr수익(75),tr하락(55); Input : N4(0.45),본전생각틱(55); Input : 터치익절(115); var : cnt(0),SigSum(0),count2(0),RSIsig(0); Var : Counter(0), DownAmt(0), UpAmt(0), UpSum(0), DownSum(0), UpAvg(0), DownAvg(0); var : idx(0), PreUpAvg(0), preDownAvg(0),RSIVv(0); Array : C1[100](0); var : CCIv(0),RSIv(0),Simri(0),SellSetup(false),DD(0),entry(0); RSIV = RSI(RSIPeriod); Simri = Simrido(SimPeriod); if Bdate != Bdate[1] Then { for cnt = 1 to 99 { C1[cnt] = C1[cnt-1][1]; } PreUpAvg = UpAvg[1]; preDownAvg = DownAvg[1]; idx = idx + 1; } C1[0] = C; If idx == RSIPeriod1+2 Then { UpSum = 0; DownSum = 0; For Counter = 0 To RSIPeriod1 - 1 { UpAmt = C1[Counter] - C1[Counter+1]; If UpAmt >= 0 Then DownAmt = 0; Else { DownAmt = -UpAmt; UpAmt = 0; } UpSum = UpSum + UpAmt; DownSum = DownSum + DownAmt; } UpAvg = UpSum / RSIPeriod1; DownAvg = DownSum / RSIPeriod1; } If idx > RSIPeriod1+2 Then { UpAmt = C1[0] - C1[1]; If UpAmt >= 0 Then DownAmt = 0; Else { DownAmt = -UpAmt; UpAmt = 0; } UpAvg = (PreUpAvg * (RSIPeriod1 - 1) + UpAmt) / RSIPeriod1; DownAvg = (preDownAvg * (RSIPeriod1 - 1) + DownAmt) / RSIPeriod1; } If UpAvg + DownAvg <> 0 Then RSIvv = 100 * UpAvg / (UpAvg + DownAvg); Else RSIvv = 0; if bdate != bdate[1] Then { Entry = 0; Condition2 = true; } if MarketPosition != 0 and MarketPosition != MarketPosition[1] Then entry = entry+1; if TotalTrades > TotalTrades[1] and (IsExitName("즉시손절1",1) == true or IsExitName("본전청산1",1)) then Condition2 = false; Condition1 = RSIv > RSI매수값 and Simri > 심리도값 and ((RSIVV > A and RSIVV < B) or (RSIVV > D and RSIVV < E)) ; if bdate != bdate[1] Then { DD = DD+1; if var2 > 0 and DD == var2+초기화 Then SellSetup = false; } if SellSetup == false and Condition1 == true and Condition1[1] == false Then { var1 = C; var2 = DD; SellSetup = true; } if Condition2 == true and MarketPosition == 0 and SellSetup == true and C > O and entry == 0 and v > 거래량1 and v < ma(v,거래량평균봉수)*거래량평균봉수비율 Then sell("매도",AtStop,var1+PriceScale*하락틱수); if MarketPosition == -1 then { SellSetup = false; SetStopProfittarget(PriceScale*터치익절,PointStop); if Lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*즉시익절1 and C > O Then ExitShort("s즉시익절1",OnClose); if Lowest(L,BarsSinceEntry) <= (EntryPrice-PriceScale*즉시익절1*N2) Then ExitShort("s본전청산1",AtStop,EntryPrice-PriceScale*즉시익절1*N3); if Lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*tr수익 Then ExitShort("str",AtStop, Lowest(L,BarsSinceEntry)+PriceScale*tr하락); if Highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*즉시손절1*N4 and C > O Then ExitShort("s고점에서 내려와서 본전 청산",atlimit,EntryPrice-PriceScale*본전생각틱); } SetStopLoss(PriceScale*즉시손절1,PointStop); SetStopProfittarget(PriceScale*터치익절,PointStop); 즐거운 하루되세요 > 이형지 님이 쓴 글입니다. > 제목 : 전에 문의했던 사항인데 잘 안되어 다시 부탁드리겠습니다. (매수진입 및 매도 진입) > 해당 수식으로 손절을 적용하고 있는데요... ExitLong("즉시손절1",AtStop,EntryPrice-PriceScale*즉시손절1); 매수 진입한 봉한개에서 에서 하락 틱수가 "즉시손절1"틱수를 넘어서더라도 손절처리가 안되요... 매수한 다음봉부터 인지를 한다고 들었습니다. 그러면 진입하자마자 해당봉에서 손실을 제한하는 수식을 알려주시면 감사하겠습니다. 수식은 다음과 같습니다. 변수중 "즉시손절1" 값에 도달시 청산하는 수식 부탁드려요~~ 그봉에 # 매수 진입 조건 변수 Input : RSIPeriod(7),RSI매수값(28),SimPeriod(14),심리도값(36); # RSI와 심리도 기간 및 값 변수 Input : N1(1),초기화(3); # 위 해당 조건 발생후 진입 유효 기간, 7일경과후 초기화 Input : 하락틱수(2); # 해당 조건 발생후 하락틱수만큼 하락후 진입 변수 Input : RSIPeriod1(6),A(0),B(4),D(48),E(72); # 일봉기준 RSI값이 해당변수안에 속해있을때 진입 변수 Input : 거래량1(600),거래량평균봉수(55),거래량평균봉수비율(3.6); # 해당 거래량1,2 사이에 속해 있을때 진입되는 변수 18000 # 1일 1회 거래 # 청산 조건 변수 Input : CCI기간(20),CCI값(500); # CCI값에 의해 청산 수식 변수 Input : 즉시익절1(70),즉시손절1(90); # 익절값 손절값 변수 Input : N2(0.6),N3(0.15); # 상승후 본절청산 관련 수식 Input : tr수익(70),tr하락(25); # 트레일링 관련 수식 Input : N4(0.7),본전생각틱(10); # 하락후 본절청산 관련 수식 Input : N5(0.8),CCI값1(120); # 약 손절 관련 수식 Input : 터치익절(105); var : cnt(0),SigSum(0),count2(0),RSIsig(0); Var : Counter(0), DownAmt(0), UpAmt(0), UpSum(0), DownSum(0), UpAvg(0), DownAvg(0); var : idx(0), PreUpAvg(0), preDownAvg(0),RSIVv(0); Array : C1[100](0); var : CCIv(0),RSIv(0),Simri(0),BuySetup(false),DD(0),entry(0); CCIv = CCI(CCI기간); RSIV = RSI(RSIPeriod); Simri = Simrido(SimPeriod); var4 = ma(V,20); if Bdate != Bdate[1] Then { for cnt = 1 to 99 { C1[cnt] = C1[cnt-1][1]; } PreUpAvg = UpAvg[1]; preDownAvg = DownAvg[1]; idx = idx + 1; } C1[0] = C; If idx == RSIPeriod1+2 Then { UpSum = 0; DownSum = 0; For Counter = 0 To RSIPeriod1 - 1 { UpAmt = C1[Counter] - C1[Counter+1]; If UpAmt >= 0 Then DownAmt = 0; Else { DownAmt = -UpAmt; UpAmt = 0; } UpSum = UpSum + UpAmt; DownSum = DownSum + DownAmt; } UpAvg = UpSum / RSIPeriod1; DownAvg = DownSum / RSIPeriod1; } If idx > RSIPeriod1+2 Then { UpAmt = C1[0] - C1[1]; If UpAmt >= 0 Then DownAmt = 0; Else { DownAmt = -UpAmt; UpAmt = 0; } UpAvg = (PreUpAvg * (RSIPeriod1 - 1) + UpAmt) / RSIPeriod1; DownAvg = (preDownAvg * (RSIPeriod1 - 1) + DownAmt) / RSIPeriod1; } If UpAvg + DownAvg <> 0 Then RSIvv = 100 * UpAvg / (UpAvg + DownAvg); Else RSIvv = 0; if bdate != bdate[1] Then { Entry = 0; Condition2 = true; } if MarketPosition != 0 and MarketPosition != MarketPosition[1] Then entry = entry+1; if TotalTrades > TotalTrades[1] and (IsExitName("즉시손절1",1) == true or IsExitName("본전청산1",1)) then Condition2 = false; Condition1 = RSIv < RSI매수값 and Simri < 심리도값 and ((RSIVV > A and RSIVV < B) or (RSIVV > D and RSIVV < E)) ; if bdate != bdate[1] Then { DD = DD+1; if var2 > 0 and DD == var2+초기화 Then BuySetup = false; } if BuySetup == false and Condition1 == true and Condition1[1] == false Then { var1 = C; var2 = DD; BuySetup = true; } if Condition2 == true and MarketPosition == 0 and C < O and C[1] < O and BuySetup == true and entry == 0 and v < ma(v,거래량평균봉수)*거래량평균봉수비율 and v > 거래량1 Then # and C < O buy("매수",AtLimit,var1-PriceScale*하락틱수); if MarketPosition == 1 then { BuySetup = false; SetStopProfittarget(PriceScale*터치익절,PointStop); if countif(CrossDown(CCIv,CCI값),BarsSinceEntry) >= 1 and CCIv < CCI값 and C < O Then ExitLong("매수cci청산",OnClose); if highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*즉시익절1 and C < O Then ExitLong("즉시익절1",OnClose); if highest(H,BarsSinceEntry) >= (EntryPrice+PriceScale*즉시익절1*N2) Then ExitLong("본전청산1",AtStop,EntryPrice+PriceScale*즉시익절1*N3); Else { ExitLong("즉시손절1",AtStop,EntryPrice-PriceScale*즉시손절1); } if highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*tr수익 Then ExitLong("tr",AtStop, highest(H,BarsSinceEntry)-PriceScale*tr하락); if lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*즉시손절1*N4 and C < O Then ExitLong("저점에서 올라와서 본전 청산",atlimit,EntryPrice+PriceScale*본전생각틱); if lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*즉시손절1 *N5 and CCIv >= CCI값1 and C < O Then ExitLong("저점에서 올라와서 약손절",OnClose); } ===================================================================================== 매도 진입 및 청산 수식 # 매도 진입 조건 변수 Input : RSIPeriod(7),RSI매수값(65),SimPeriod(7),심리도값(45); Input : N1(1),초기화(2); Input : 하락틱수(5); Input : RSIPeriod1(6),A(14),B(40),D(88),E(100); Input : 거래량1(100),거래량평균봉수(60),거래량평균봉수비율(4); # Input : 거래량1(100),거래량2(22000); # 청산 조건 변수 Input : 즉시익절1(70),즉시손절1(70); Input : N2(0.25),N3(-0.75); Input : tr수익(75),tr하락(55); Input : N4(0.45),본전생각틱(55); Input : 터치익절(115); var : cnt(0),SigSum(0),count2(0),RSIsig(0); Var : Counter(0), DownAmt(0), UpAmt(0), UpSum(0), DownSum(0), UpAvg(0), DownAvg(0); var : idx(0), PreUpAvg(0), preDownAvg(0),RSIVv(0); Array : C1[100](0); var : CCIv(0),RSIv(0),Simri(0),SellSetup(false),DD(0),entry(0); RSIV = RSI(RSIPeriod); Simri = Simrido(SimPeriod); if Bdate != Bdate[1] Then { for cnt = 1 to 99 { C1[cnt] = C1[cnt-1][1]; } PreUpAvg = UpAvg[1]; preDownAvg = DownAvg[1]; idx = idx + 1; } C1[0] = C; If idx == RSIPeriod1+2 Then { UpSum = 0; DownSum = 0; For Counter = 0 To RSIPeriod1 - 1 { UpAmt = C1[Counter] - C1[Counter+1]; If UpAmt >= 0 Then DownAmt = 0; Else { DownAmt = -UpAmt; UpAmt = 0; } UpSum = UpSum + UpAmt; DownSum = DownSum + DownAmt; } UpAvg = UpSum / RSIPeriod1; DownAvg = DownSum / RSIPeriod1; } If idx > RSIPeriod1+2 Then { UpAmt = C1[0] - C1[1]; If UpAmt >= 0 Then DownAmt = 0; Else { DownAmt = -UpAmt; UpAmt = 0; } UpAvg = (PreUpAvg * (RSIPeriod1 - 1) + UpAmt) / RSIPeriod1; DownAvg = (preDownAvg * (RSIPeriod1 - 1) + DownAmt) / RSIPeriod1; } If UpAvg + DownAvg <> 0 Then RSIvv = 100 * UpAvg / (UpAvg + DownAvg); Else RSIvv = 0; if bdate != bdate[1] Then { Entry = 0; Condition2 = true; } if MarketPosition != 0 and MarketPosition != MarketPosition[1] Then entry = entry+1; if TotalTrades > TotalTrades[1] and (IsExitName("즉시손절1",1) == true or IsExitName("본전청산1",1)) then Condition2 = false; Condition1 = RSIv > RSI매수값 and Simri > 심리도값 and ((RSIVV > A and RSIVV < B) or (RSIVV > D and RSIVV < E)) ; if bdate != bdate[1] Then { DD = DD+1; if var2 > 0 and DD == var2+초기화 Then SellSetup = false; } if SellSetup == false and Condition1 == true and Condition1[1] == false Then { var1 = C; var2 = DD; SellSetup = true; } if Condition2 == true and MarketPosition == 0 and SellSetup == true and C > O and entry == 0 and v > 거래량1 and v < ma(v,거래량평균봉수)*거래량평균봉수비율 Then sell("매도",AtStop,var1+PriceScale*하락틱수); if MarketPosition == -1 then { SellSetup = false; SetStopProfittarget(PriceScale*터치익절,PointStop); if Lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*즉시익절1 and C > O Then ExitShort("s즉시익절1",OnClose); if Lowest(L,BarsSinceEntry) <= (EntryPrice-PriceScale*즉시익절1*N2) Then ExitShort("s본전청산1",AtStop,EntryPrice-PriceScale*즉시익절1*N3); Else ExitShort("s즉시손절1",AtStop,EntryPrice+PriceScale*즉시손절1); if Lowest(L,BarsSinceEntry) <= EntryPrice-PriceScale*tr수익 Then ExitShort("str",AtStop, Lowest(L,BarsSinceEntry)+PriceScale*tr하락); if Highest(H,BarsSinceEntry) >= EntryPrice+PriceScale*즉시손절1*N4 and C > O Then ExitShort("s고점에서 내려와서 본전 청산",atlimit,EntryPrice-PriceScale*본전생각틱); }