커뮤니티

수식 부탁 합니다

프로필 이미지
회원
2017-05-21 00:31:43
95
글번호 109727
답변완료
Input:length(15); Var:j(0),lastHiVal(0),lastLoVal(0),turnPntBit(""),TL1(0); Array:valArr[10](0),barArr[10](0),turnPntArr[10](""); For j = 0 To 9 { barArr[j] = barArr[j] + 1; } Condition1 = Highest(H,length) == H and lastHiVal <> H; Condition2 = Lowest(L,length) == L and lastLoVal <> L; If Condition1 Then lastHiVal = H; If Condition2 Then lastLoVal = L; turnPntBit = ""; If Condition1 and Condition2 Then { If Max(valArr[1],valArr[2]) < H and Min(valArr[1],valArr[2]) > L Then turnPntBit = "HiLo"; Else If Max(valArr[1],valArr[2]) < H Then turnPntBit = "Hi"; Else If Min(valArr[1],valArr[2]) > L Then turnPntBit = "Lo"; } Else If Condition1 Then turnPntBit = "Hi"; Else If Condition2 Then turnPntBit = "Lo"; If turnPntBit <> "" Then { If turnPntBit == "HiLo" Then { valArr[1] = IFF(turnPntArr[1] == "Hi",H,L); barArr[1] = 0; TL_SetEnd(TL1,sDate[barArr[1]],sTime[barArr[1]],valArr[1]); If turnPntArr[1] == "Hi" Then turnPntBit = "Lo"; Else turnPntBit = "Hi"; } If turnPntBit <> turnPntArr[1] Then { for j = 8 downto 1 { valArr[j+1] = valArr[j]; barArr[j+1] = barArr[j]; turnPntArr[j+1] = turnPntArr[j]; } } If turnPntBit <> turnPntArr[1] or (turnPntBit == turnPntArr[1] and ((turnPntBit == "Hi" and valArr[1] < H) or (turnPntBit == "Lo" and valArr[1] > L))) Then { valArr[1] = IFF(turnPntBit == "Hi",H,L); barArr[1] = 0; turnPntArr[1] = turnPntBit; If turnPntArr[1][1] <> turnPntArr[1][0] Then{ TL1 = TL_New(sDate[barArr[2]],sTime[barArr[2]],valArr[2], sDate[barArr[1]],sTime[barArr[1]],valArr[1]); if turnPntArr[1][0] == "Hi" Then buy(); Else sell(); } Else TL_SetEnd(TL1,sDate[barArr[1]],sTime[barArr[1]],valArr[1]); } } TL_SetSize(TL1,1); 위시스템에 추가해서 MACDS선이 0선위에 있을때는 매수신호만 발생 MACDS선이 0선 아래에 있을때는 매도 신호만 발생 하는 시스템식을 만들고 싶습니다. 제가 나름 만들어 보았는데 MACDS선이 0선위에 있는데도 매수 매도 신호 둘다 나옵니다. MACDS선은 아래 수식에서 가져온것입니다. Input : shortPeriod(12), longPeriod(26), Period(9); Var : MACDV(0) , MACDs(0) ; MACDV = MACD(shortPeriod, longPeriod); MACDS = ema(MACDV,Period);
시스템
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2017-05-22 17:11:15

안녕하세요 예스스탁입니다. Input : shortPeriod(12), longPeriod(26), Period(9); Var : MACDV(0) , MACDs(0) ; Input:length(15); Var:j(0),lastHiVal(0),lastLoVal(0),turnPntBit(""),TL1(0); Array:valArr[10](0),barArr[10](0),turnPntArr[10](""); MACDV = MACD(shortPeriod, longPeriod); MACDS = ema(MACDV,Period); For j = 0 To 9 { barArr[j] = barArr[j] + 1; } Condition1 = Highest(H,length) == H and lastHiVal <> H; Condition2 = Lowest(L,length) == L and lastLoVal <> L; If Condition1 Then lastHiVal = H; If Condition2 Then lastLoVal = L; turnPntBit = ""; If Condition1 and Condition2 Then { If Max(valArr[1],valArr[2]) < H and Min(valArr[1],valArr[2]) > L Then turnPntBit = "HiLo"; Else If Max(valArr[1],valArr[2]) < H Then turnPntBit = "Hi"; Else If Min(valArr[1],valArr[2]) > L Then turnPntBit = "Lo"; } Else If Condition1 Then turnPntBit = "Hi"; Else If Condition2 Then turnPntBit = "Lo"; If turnPntBit <> "" Then { If turnPntBit == "HiLo" Then { valArr[1] = IFF(turnPntArr[1] == "Hi",H,L); barArr[1] = 0; TL_SetEnd(TL1,sDate[barArr[1]],sTime[barArr[1]],valArr[1]); If turnPntArr[1] == "Hi" Then turnPntBit = "Lo"; Else turnPntBit = "Hi"; } If turnPntBit <> turnPntArr[1] Then { for j = 8 downto 1 { valArr[j+1] = valArr[j]; barArr[j+1] = barArr[j]; turnPntArr[j+1] = turnPntArr[j]; } } If turnPntBit <> turnPntArr[1] or (turnPntBit == turnPntArr[1] and ((turnPntBit == "Hi" and valArr[1] < H) or (turnPntBit == "Lo" and valArr[1] > L))) Then { valArr[1] = IFF(turnPntBit == "Hi",H,L); barArr[1] = 0; turnPntArr[1] = turnPntBit; If turnPntArr[1][1] <> turnPntArr[1][0] Then{ TL1 = TL_New(sDate[barArr[2]],sTime[barArr[2]],valArr[2], sDate[barArr[1]],sTime[barArr[1]],valArr[1]); if turnPntArr[1][0] == "Hi" Then{ if MACDS > 0 then buy(); Else ExitShort(); } Else{ if MACDS < 0 then sell(); Else exitlong(); } } Else TL_SetEnd(TL1,sDate[barArr[1]],sTime[barArr[1]],valArr[1]); } } TL_SetSize(TL1,1); 즐거운 하루되세요 > fndldl 님이 쓴 글입니다. > 제목 : 수식 부탁 합니다 > Input:length(15); Var:j(0),lastHiVal(0),lastLoVal(0),turnPntBit(""),TL1(0); Array:valArr[10](0),barArr[10](0),turnPntArr[10](""); For j = 0 To 9 { barArr[j] = barArr[j] + 1; } Condition1 = Highest(H,length) == H and lastHiVal <> H; Condition2 = Lowest(L,length) == L and lastLoVal <> L; If Condition1 Then lastHiVal = H; If Condition2 Then lastLoVal = L; turnPntBit = ""; If Condition1 and Condition2 Then { If Max(valArr[1],valArr[2]) < H and Min(valArr[1],valArr[2]) > L Then turnPntBit = "HiLo"; Else If Max(valArr[1],valArr[2]) < H Then turnPntBit = "Hi"; Else If Min(valArr[1],valArr[2]) > L Then turnPntBit = "Lo"; } Else If Condition1 Then turnPntBit = "Hi"; Else If Condition2 Then turnPntBit = "Lo"; If turnPntBit <> "" Then { If turnPntBit == "HiLo" Then { valArr[1] = IFF(turnPntArr[1] == "Hi",H,L); barArr[1] = 0; TL_SetEnd(TL1,sDate[barArr[1]],sTime[barArr[1]],valArr[1]); If turnPntArr[1] == "Hi" Then turnPntBit = "Lo"; Else turnPntBit = "Hi"; } If turnPntBit <> turnPntArr[1] Then { for j = 8 downto 1 { valArr[j+1] = valArr[j]; barArr[j+1] = barArr[j]; turnPntArr[j+1] = turnPntArr[j]; } } If turnPntBit <> turnPntArr[1] or (turnPntBit == turnPntArr[1] and ((turnPntBit == "Hi" and valArr[1] < H) or (turnPntBit == "Lo" and valArr[1] > L))) Then { valArr[1] = IFF(turnPntBit == "Hi",H,L); barArr[1] = 0; turnPntArr[1] = turnPntBit; If turnPntArr[1][1] <> turnPntArr[1][0] Then{ TL1 = TL_New(sDate[barArr[2]],sTime[barArr[2]],valArr[2], sDate[barArr[1]],sTime[barArr[1]],valArr[1]); if turnPntArr[1][0] == "Hi" Then buy(); Else sell(); } Else TL_SetEnd(TL1,sDate[barArr[1]],sTime[barArr[1]],valArr[1]); } } TL_SetSize(TL1,1); 위시스템에 추가해서 MACDS선이 0선위에 있을때는 매수신호만 발생 MACDS선이 0선 아래에 있을때는 매도 신호만 발생 하는 시스템식을 만들고 싶습니다. 제가 나름 만들어 보았는데 MACDS선이 0선위에 있는데도 매수 매도 신호 둘다 나옵니다. MACDS선은 아래 수식에서 가져온것입니다. Input : shortPeriod(12), longPeriod(26), Period(9); Var : MACDV(0) , MACDs(0) ; MACDV = MACD(shortPeriod, longPeriod); MACDS = ema(MACDV,Period);