커뮤니티

함수 한번더 부탁드립니다

프로필 이미지
짜왕
2022-02-25 14:47:57
1234
글번호 156757
답변완료
아래 인풋변수에서 period의 변수를 바꾼다면 어디어디 변수를 77로 바꿔야하는지 궁금합니다 input : ntime(5),Period(77); Vars: HH(0), LL(0) ,center(0), LongCondition(False),ShortCondition(False),ExitLongConditon(False), ExitShortCondition(False); var : S1(0),D1(0),TM(0),TF(0),cnt(0); Array : tH[100](0),tL[100](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%ntime; if Bdate != Bdate[1] or (Bdate == Bdate[1] and ntime > 1 and TF < TF[1]) or (Bdate == Bdate[1] and ntime > 1 and TM >= TM[1]+ntime) or (Bdate == Bdate[1] and ntime == 1 and TM > TM[1]) Then { tH[0] = H; tL[0] = L; For cnt = 1 to 99 { tH[cnt] = tH[cnt-1][1]; tL[cnt] = tL[cnt-1][1]; } } if tH[0] > 0 and H > tH[0] Then tH[0] = H; if tL[0] > 0 and L < tL[0] Then tL[0] = L; if tH[Period] > 0 and tL[Period] > 0 Then { HH = 0; LL = 0; For cnt = 1 to Period { if HH == 0 or (HH > 0 and tH[cnt] > HH) Then HH = tH[cnt]; if LL == 0 or (LL > 0 and tL[cnt] < LL) Then LL = tL[cnt]; } center= (HH+LL)/2 ; If MarketPosition <= 0 and C < HH Then Begin Buy("매수",AtStop,HH); End; If MarketPosition == 1 and C > center Then Begin ExitLong("매수청산",AtStop,center); End; If MarketPosition >= 0 and C > LL Then Begin Sell("매도",AtStop,LL); End; If MarketPosition == -1 and C < center Then Begin ExitShort("매도청산",AtStop,center); End; } }
사용자 함수
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2022-02-25 15:22:57

안녕하세요 예스스탁입니다. 1 별도로 수정할 부분이 없습니다. 외부변수(input)은 주어진 값을 수식 내에 전달해 별도로 수식 수정없이 사용하기 위한 변수입니다. 77이라고만 지정하시면 5분봉 77개의 최고가와 최저가를 자동으로 계산합니다. 2 수식에 타주기 최고가와 최저가를 100개까지만 계산해 저장되게 되어 있습니다. 만약 period를 100이상으로 지정하신다면 배열크기와 for문 종료값을 좀더 크게 넉넉히 지정해 주셔야 합니다. Array : tH[100](0),tL[100](0); For cnt = 1 to 99 즐거운 하루되세요 > 짜왕 님이 쓴 글입니다. > 제목 : 함수 한번더 부탁드립니다 > 아래 인풋변수에서 period의 변수를 바꾼다면 어디어디 변수를 77로 바꿔야하는지 궁금합니다 input : ntime(5),Period(77); Vars: HH(0), LL(0) ,center(0), LongCondition(False),ShortCondition(False),ExitLongConditon(False), ExitShortCondition(False); var : S1(0),D1(0),TM(0),TF(0),cnt(0); Array : tH[100](0),tL[100](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%ntime; if Bdate != Bdate[1] or (Bdate == Bdate[1] and ntime > 1 and TF < TF[1]) or (Bdate == Bdate[1] and ntime > 1 and TM >= TM[1]+ntime) or (Bdate == Bdate[1] and ntime == 1 and TM > TM[1]) Then { tH[0] = H; tL[0] = L; For cnt = 1 to 99 { tH[cnt] = tH[cnt-1][1]; tL[cnt] = tL[cnt-1][1]; } } if tH[0] > 0 and H > tH[0] Then tH[0] = H; if tL[0] > 0 and L < tL[0] Then tL[0] = L; if tH[Period] > 0 and tL[Period] > 0 Then { HH = 0; LL = 0; For cnt = 1 to Period { if HH == 0 or (HH > 0 and tH[cnt] > HH) Then HH = tH[cnt]; if LL == 0 or (LL > 0 and tL[cnt] < LL) Then LL = tL[cnt]; } center= (HH+LL)/2 ; If MarketPosition <= 0 and C < HH Then Begin Buy("매수",AtStop,HH); End; If MarketPosition == 1 and C > center Then Begin ExitLong("매수청산",AtStop,center); End; If MarketPosition >= 0 and C > LL Then Begin Sell("매도",AtStop,LL); End; If MarketPosition == -1 and C < center Then Begin ExitShort("매도청산",AtStop,center); End; } }