커뮤니티

수식 문의

프로필 이미지
중추신경
2021-06-08 10:32:11
1738
글번호 149745
답변완료
질문 두가지가 있습니다 1. if MarketPosition == -1 Then { if X5 == -1 and CountIf(X5 == 1,BarsSinceEntry) == 0 and X == 1 and CountIf(X == 1 and X != X[1],BarsSinceEntry) >= 3 and (C+O)/2 >= Var27 Then ExitShort("풋청1",AtMarket); 풋 청산을 예로 들면, 위 식에서, 진입한 이후에 5선(X)이 변곡3번이상 나오고 양봉이면 청산인데요.. Barsinceentry 대신에 5와 20이 Deadcross가 나오고 나서 5선이 상승 변곡이 3번이상나오면 청산으로 하고 싶은데요..countif 조건문에서 Deadcross를 넣을수는 없어서요.. Countif(X == 1 and X !=[1], Deadcross(5,20)) >=3 <- 이렇게 표현하고 싶습니다. 2. 보내주신 수식 설명좀 부탁드릴수 있을까요? var : mav1(0),mav2(0),mav3(0),S(0),T(0); mav1 = ma(C,20); mav2 = ma(C,60); mav3 = ma(C,240); if mav1 > mav1[1] Then S = 1; if mav1 < mav1[1] Then S = -1; if CrossUp(mav2,mav3) Then T = 1; if CrossDown(mav2,mav3) Then { T = -1; if mav1 > mav2 Then T = 0; } if T == -1 and CrossUp(mav1,mav2) Then T = -2; if T == -2 and (mav1 < mav2 or mav1 > mav3) Then T = 0; if T == -2 and S == -1 and S != S[1] Then { T = -3; Sell(); } 위 조건에서 T = 0 를 다른 조건으로 두번을 썻는데요..수식이 이해가 안되서요 그리고 60-240이 deadcross한 시점에서 60선이 1파동일때만 진입하고 3파동일때는 진입이 안되게 하는건 어떤부분인지 궁금합니다 - 수식을 잘 작동하고 있습니다. /////////////////////////////////////////////////////////////////////////////// var : Period1(3),Period2(10),Period3(30),Period4(120),X5(0),X20(0),X60(0),XP(0),X(0),Y(0),Z(0),Q(0),Mav1(0), Mav2(0),Mav3(0),Mav4(0); Input : Left(3),right(3); var : B5(0),BP60(0),B20(0),B60(0),S5(0),S20(0),S60(0),SP60(0),Bcnt5(0),Bcnt20(0),Bcnt60(0),BcntP60(0), Scnt5(0), Scnt20(0), Scnt60(0),ScntP60(0),H1(0),H2(0),L1(0),L2(0); InPUT : 진입시작시간(090000), 매매종료시간(153000); if Bdate != Bdate[1] Then { Condition1 = False; Condition2 = False; } Var26 = ema(Ema(Ema(c,period1),period1),period1); //ma(c,period1); //5선 Var27 = ema(Ema(Ema(c,period2),period2),period2); //20선 Var28 = ema(Ema(Ema(c,period3),period3),period3); //60선 Var29 = ema(Ema(Ema(c,period4),period4),period4); //240선 if CrossUp(Var26,Var27) Then X5 = 1; //5-20 cross if CrossDown(Var26,Var27) Then X5 = -1; if CrossUp(Var27,Var28) Then X20 = 1; //20-60 cross if CrossDown(Var27,Var28) Then X20 = -1; if CrossUp(Var28,Var29) Then X60 = 1; //60-240 cross if CrossDown(Var28,Var29) Then X60 = -1; if CrossUp(Var26,Var28) Then XP = 1; //5-60 cross if CrossDown(Var26,Var28) Then XP = -1; if Var26 > var26[1] Then X = 1; if Var26 < var26[1] Then X = -1; if Var27 > var27[1] Then // X5 : 5-20 Cross X : 5선 Y = 1; // X20 : 20-60 Cross Y : 20선 if Var27 < var27[1] Then // X60 : 60-240 cross Z : 60선 Y = -1; // XP : 5-60 cross if Var28 > var28[1] Then Z = 1; if Var28 < var28[1] Then Z = -1; if X == 1 and X != X[1] and Bdate == Bdate[1] Then Condition1 = true; if X == -1 and X != X[1] and Bdate == Bdate[1] Then Condition2 = true; //////////////////////상방기준////////////////// if XP == 1 and X == 1 and Condition1 == true Then //5-60 정배열 & 5상승 { if X != X[1] Then //5선이 상승변곡 이면 B = 1 { BP60 = 1; } //5선이 상승변곡 & 20선 상승 & 5선 20선위 & 몸통이 5 BC 면 B =2 if BP60 == 1 and Y == 1 and Var26 > Var27 and C > O and (C+O)/2 >= var26 Then { BP60 = 2; } } else BP60 = 0; if sDate == 20210429 and sTime < 92000 Then MessageLog("%.2f",BP60); //////////////////////하방기준////////////////// if XP == -1 and X == -1 and Condition2 == true Then { if X!= X[1] Then { SP60 = 1; } if SP60 == 1 and Y == -1 and Var26 < Var27 and C < O and (C+O)/2 < var26 Then { SP60 = 2; } } else SP60 = 0; //////////////////////////상방시그널///////////////// if sTime >= 진입시작시간 and sTime <= 매매종료시간 and XP == 1 Then { if XP != XP[1] Then BcntP60 = 0; if BP60 == 2 and BP60 != BP60[1] Then { BcntP60 = BcntP60+1; if BcntP60 <= 1 Then Buy("BP60"); } } ////////////////////////하방 시그널////////////////// if sTime >= 진입시작시간 and sTime <= 매매종료시간 and XP == -1 Then { if XP != XP[1] Then ScntP60 = 0; if SP60 == 2 and SP60 != SP60[1] Then { ScntP60 = ScntP60+1; if ScntP60 <= 1 Then Sell("SP60"); } } if MarketPosition == 1 Then { if X5 == 1 and CountIf(X5 == -1,BarsSinceEntry) == 0 and X == -1 and CountIf(X == -1 and X != X[1],BarsSinceEntry) >= 3 and (C+O)/2 <= Var27 then ExitLong("콜청1",AtMarket); if X5 == -1 and X == -1 and CountIf(X == -1 and X != X[1],BarsSinceEntry) >= 1 and (C+O)/2 <= Var27 Then ExitLong("콜정2",AtMarket); } if MarketPosition == -1 Then { if X5 == -1 and CountIf(X5 == 1,BarsSinceEntry) == 0 and X == 1 and CountIf(X == 1 and X != X[1],BarsSinceEntry) >= 3 and (C+O)/2 >= Var27 Then ExitShort("풋청1",AtMarket); if X5 == 1 and X == 1 and CountIf(X == 1 and X != X[1],BarsSinceEntry) >= 1 and (C+O)/2 >= Var27 Then ExitShort("풋정2",AtMarket); }
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2021-06-08 11:45:43

안녕하세요 예스스탁입니다. 1 var : DnCond(False),SXcnt(0); var1 = ma(C,5); Var2 = ma(C,20); if MarketPosition == -1 Then { if CrossDown(var1,Var2) Then DnCond = true; if Condition1 == true Then { if X == 1 and X != X[1] Then { SXcnt = SXcnt+1; } if SXcnt >= 3 and (C+O)/2 >= Var27 Then ExitShort("풋청1",AtMarket); } } Else { DnCond = False; sxcnt = 0; } 2 해당식은 60-240 하향이탈(-1)후에 첫번째20-60골드(-2)가 나오고 이후 20이평이 하향반전(-3)되면 매도하는 식입니다. T값이 -1,-2,-3으로 변경되는것은 각 첫번째 조건충족시에만 동작시키기 위함입니다. var : mav1(0),mav2(0),mav3(0),S(0),T(0); mav1 = ma(C,20); mav2 = ma(C,60); mav3 = ma(C,240); #20이평 상승이면 1 if mav1 > mav1[1] Then S = 1; #20이평 하락이면 -1 if mav1 < mav1[1] Then S = -1; #60이평이 240이평을 상향돌파하면 1 if CrossUp(mav2,mav3) Then T = 1; #60이평이 240이평을 하향이탈하면 -1 if CrossDown(mav2,mav3) Then { T = -1; #하향이탈봉에서 20이평이 60이평보다 작은 상태이면 #-1이지만 20이평이 60이평보다 크면 0으로 함 #최초 20이평이 60이평을 상향돌파할때가 기준이므로 #60이평이 240이평을 하향돌파할때 이미 20이평이 60이평보다 크면 조건이 해제되므로 #T값도 0으로 변경 if mav1 > mav2 Then T = 0; } #T가 -1인 상태에서 20이평이 60이평을 돌파하면 T를 -2로 변경 if T == -1 and CrossUp(mav1,mav2) Then T = -2; #T가 -2인 상태에서 20이평이 60이평보다 작아지거나 240이평보다 커지면 #조건이 해제되므로 T도 0 if T == -2 and (mav1 < mav2 or mav1 > mav3) Then T = 0; #T가 -2인 상태에서 20이평 하락전환하면 T는 -3으로 만들고 매 #조건이 해제되므로 T도 0 if T == -2 and S == -1 and S != S[1] Then { T = -3; Sell(); } 즐거운 하루되세요 > 중추신경 님이 쓴 글입니다. > 제목 : 수식 문의 > 질문 두가지가 있습니다 1. if MarketPosition == -1 Then { if X5 == -1 and CountIf(X5 == 1,BarsSinceEntry) == 0 and X == 1 and CountIf(X == 1 and X != X[1],BarsSinceEntry) >= 3 and (C+O)/2 >= Var27 Then ExitShort("풋청1",AtMarket); 풋 청산을 예로 들면, 위 식에서, 진입한 이후에 5선(X)이 변곡3번이상 나오고 양봉이면 청산인데요.. Barsinceentry 대신에 5와 20이 Deadcross가 나오고 나서 5선이 상승 변곡이 3번이상나오면 청산으로 하고 싶은데요..countif 조건문에서 Deadcross를 넣을수는 없어서요.. Countif(X == 1 and X !=[1], Deadcross(5,20)) >=3 <- 이렇게 표현하고 싶습니다. 2. 보내주신 수식 설명좀 부탁드릴수 있을까요? var : mav1(0),mav2(0),mav3(0),S(0),T(0); mav1 = ma(C,20); mav2 = ma(C,60); mav3 = ma(C,240); if mav1 > mav1[1] Then S = 1; if mav1 < mav1[1] Then S = -1; if CrossUp(mav2,mav3) Then T = 1; if CrossDown(mav2,mav3) Then { T = -1; if mav1 > mav2 Then T = 0; } if T == -1 and CrossUp(mav1,mav2) Then T = -2; if T == -2 and (mav1 < mav2 or mav1 > mav3) Then T = 0; if T == -2 and S == -1 and S != S[1] Then { T = -3; Sell(); } 위 조건에서 T = 0 를 다른 조건으로 두번을 썻는데요..수식이 이해가 안되서요 그리고 60-240이 deadcross한 시점에서 60선이 1파동일때만 진입하고 3파동일때는 진입이 안되게 하는건 어떤부분인지 궁금합니다 - 수식을 잘 작동하고 있습니다. /////////////////////////////////////////////////////////////////////////////// var : Period1(3),Period2(10),Period3(30),Period4(120),X5(0),X20(0),X60(0),XP(0),X(0),Y(0),Z(0),Q(0),Mav1(0), Mav2(0),Mav3(0),Mav4(0); Input : Left(3),right(3); var : B5(0),BP60(0),B20(0),B60(0),S5(0),S20(0),S60(0),SP60(0),Bcnt5(0),Bcnt20(0),Bcnt60(0),BcntP60(0), Scnt5(0), Scnt20(0), Scnt60(0),ScntP60(0),H1(0),H2(0),L1(0),L2(0); InPUT : 진입시작시간(090000), 매매종료시간(153000); if Bdate != Bdate[1] Then { Condition1 = False; Condition2 = False; } Var26 = ema(Ema(Ema(c,period1),period1),period1); //ma(c,period1); //5선 Var27 = ema(Ema(Ema(c,period2),period2),period2); //20선 Var28 = ema(Ema(Ema(c,period3),period3),period3); //60선 Var29 = ema(Ema(Ema(c,period4),period4),period4); //240선 if CrossUp(Var26,Var27) Then X5 = 1; //5-20 cross if CrossDown(Var26,Var27) Then X5 = -1; if CrossUp(Var27,Var28) Then X20 = 1; //20-60 cross if CrossDown(Var27,Var28) Then X20 = -1; if CrossUp(Var28,Var29) Then X60 = 1; //60-240 cross if CrossDown(Var28,Var29) Then X60 = -1; if CrossUp(Var26,Var28) Then XP = 1; //5-60 cross if CrossDown(Var26,Var28) Then XP = -1; if Var26 > var26[1] Then X = 1; if Var26 < var26[1] Then X = -1; if Var27 > var27[1] Then // X5 : 5-20 Cross X : 5선 Y = 1; // X20 : 20-60 Cross Y : 20선 if Var27 < var27[1] Then // X60 : 60-240 cross Z : 60선 Y = -1; // XP : 5-60 cross if Var28 > var28[1] Then Z = 1; if Var28 < var28[1] Then Z = -1; if X == 1 and X != X[1] and Bdate == Bdate[1] Then Condition1 = true; if X == -1 and X != X[1] and Bdate == Bdate[1] Then Condition2 = true; //////////////////////상방기준////////////////// if XP == 1 and X == 1 and Condition1 == true Then //5-60 정배열 & 5상승 { if X != X[1] Then //5선이 상승변곡 이면 B = 1 { BP60 = 1; } //5선이 상승변곡 & 20선 상승 & 5선 20선위 & 몸통이 5 BC 면 B =2 if BP60 == 1 and Y == 1 and Var26 > Var27 and C > O and (C+O)/2 >= var26 Then { BP60 = 2; } } else BP60 = 0; if sDate == 20210429 and sTime < 92000 Then MessageLog("%.2f",BP60); //////////////////////하방기준////////////////// if XP == -1 and X == -1 and Condition2 == true Then { if X!= X[1] Then { SP60 = 1; } if SP60 == 1 and Y == -1 and Var26 < Var27 and C < O and (C+O)/2 < var26 Then { SP60 = 2; } } else SP60 = 0; //////////////////////////상방시그널///////////////// if sTime >= 진입시작시간 and sTime <= 매매종료시간 and XP == 1 Then { if XP != XP[1] Then BcntP60 = 0; if BP60 == 2 and BP60 != BP60[1] Then { BcntP60 = BcntP60+1; if BcntP60 <= 1 Then Buy("BP60"); } } ////////////////////////하방 시그널////////////////// if sTime >= 진입시작시간 and sTime <= 매매종료시간 and XP == -1 Then { if XP != XP[1] Then ScntP60 = 0; if SP60 == 2 and SP60 != SP60[1] Then { ScntP60 = ScntP60+1; if ScntP60 <= 1 Then Sell("SP60"); } } if MarketPosition == 1 Then { if X5 == 1 and CountIf(X5 == -1,BarsSinceEntry) == 0 and X == -1 and CountIf(X == -1 and X != X[1],BarsSinceEntry) >= 3 and (C+O)/2 <= Var27 then ExitLong("콜청1",AtMarket); if X5 == -1 and X == -1 and CountIf(X == -1 and X != X[1],BarsSinceEntry) >= 1 and (C+O)/2 <= Var27 Then ExitLong("콜정2",AtMarket); } if MarketPosition == -1 Then { if X5 == -1 and CountIf(X5 == 1,BarsSinceEntry) == 0 and X == 1 and CountIf(X == 1 and X != X[1],BarsSinceEntry) >= 3 and (C+O)/2 >= Var27 Then ExitShort("풋청1",AtMarket); if X5 == 1 and X == 1 and CountIf(X == 1 and X != X[1],BarsSinceEntry) >= 1 and (C+O)/2 >= Var27 Then ExitShort("풋정2",AtMarket); }