커뮤니티

변환부탁드립니다.

프로필 이미지
코샘매쓰
2022-01-06 20:32:32
1197
글번호 155213
답변완료
study("Breakout Finder", "BF", overlay = true, max_bars_back = 500, max_lines_count = 400) prd = input(defval = 5, title="Period", minval = 2) bo_len = input(defval = 200, title="Max Breakout Length", minval = 30, maxval = 300) cwidthu = input(defval = 3., title = "Threshold Rate %", minval = 1., maxval = 10) / 100 mintest = input(defval = 2, title = "Minimum Number of Tests", minval = 1) bocolorup = input(defval = color.blue, title = "Breakout Colors", inline = "bocol") bocolordown = input(defval = color.red, title = "", inline = "bocol") lstyle = input(defval = line.style_solid, title = "Line Style", options = [line.style_solid, line.style_dashed, line.style_dotted]) //width lll = max(min(bar_index, 300), 1) float h_ = highest(lll) float l_ = lowest(lll) float chwidth = (h_ - l_) * cwidthu // check if PH/PL ph = pivothigh(prd, prd) pl = pivotlow(prd, prd) //keep Pivot Points and their locations in the arrays var phval = array.new_float(0) var phloc = array.new_int(0) var plval = array.new_float(0) var plloc = array.new_int(0) // keep PH/PL levels and locations if ph array.unshift(phval, ph) array.unshift(phloc, bar_index - prd) if array.size(phval) > 1 // cleanup old ones for x = array.size(phloc) - 1 to 1 if bar_index - array.get(phloc, x) > bo_len array.pop(phloc) array.pop(phval) if pl array.unshift(plval, pl) array.unshift(plloc, bar_index - prd) if array.size(plval) > 1 // cleanup old ones for x = array.size(plloc) - 1 to 1 if bar_index - array.get(plloc, x) > bo_len array.pop(plloc) array.pop(plval) // check bullish cup float bomax = na int bostart = bar_index num = 0 hgst = highest(prd)[1] if array.size(phval) >= mintest and close > open and close > hgst bomax := array.get(phval, 0) xx = 0 for x = 0 to array.size(phval) - 1 if array.get(phval, x) >= close break xx := x bomax := max(bomax, array.get(phval, x)) if xx >= mintest and open <= bomax for x = 0 to xx if array.get(phval, x) <= bomax and array.get(phval, x) >= bomax - chwidth num += 1 bostart := array.get(phloc, x) if num < mintest or hgst >= bomax bomax := na if not na(bomax) and num >= mintest line.new(x1 = bar_index, y1 = bomax, x2 = bostart, y2 = bomax, color = bocolorup, style = lstyle) line.new(x1 = bar_index, y1 = bomax - chwidth, x2 = bostart, y2 = bomax - chwidth, color = bocolorup, style = lstyle) line.new(x1 = bostart, y1 = bomax - chwidth, x2 = bostart, y2 = bomax, color = bocolorup, style = lstyle) line.new(x1 = bar_index, y1 = bomax - chwidth, x2 = bar_index, y2 = bomax, color = bocolorup, style = lstyle) plotshape(not na(bomax) and num >= mintest, location = location.belowbar, style = shape.triangleup, color = bocolorup, size = size.small) alertcondition(not na(bomax) and num >= mintest, title = "Breakout", message = "Breakout") // check bearish cup float bomin = na bostart := bar_index num1 = 0 lwst = lowest(prd)[1] if array.size(plval) >= mintest and close < open and close < lwst bomin := array.get(plval, 0) xx = 0 for x = 0 to array.size(plval) - 1 if array.get(plval, x) <= close break xx := x bomin := min(bomin, array.get(plval, x)) if xx >= mintest and open >= bomin for x = 0 to xx if array.get(plval, x) >= bomin and array.get(plval, x) <= bomin + chwidth num1 += 1 bostart := array.get(plloc, x) if num1 < mintest or lwst <= bomin bomin := na if not na(bomin) and num1 >= mintest line.new(x1 = bar_index, y1 = bomin, x2 = bostart, y2 = bomin, color = bocolordown, style = lstyle) line.new(x1 = bar_index, y1 = bomin + chwidth, x2 = bostart, y2 = bomin + chwidth, color = bocolordown, style = lstyle) line.new(x1 = bostart, y1 = bomin + chwidth, x2 = bostart, y2 = bomin, color = bocolordown, style = lstyle) line.new(x1 = bar_index, y1 = bomin + chwidth, x2 = bar_index, y2 = bomin, color = bocolordown, style = lstyle) plotshape(not na(bomin) and num1 >= mintest, location = location.abovebar, style = shape.triangledown, color = bocolordown, size = size.small) alertcondition(not na(bomin) and num1 >= mintest, title = "Breakdown", message = "Breakdown") alertcondition((not na(bomax) and num >= mintest) or (not na(bomin) and num1 >= mintest), title = "Breakout or Breakdown", message = "Breakout or Breakdown")
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2022-01-07 14:13:43

안녕하세요 예스스탁입니다. 지표식으로 작성해 적용하시기 바랍니다. 해당 랭귀지에 대해 내장식이나 구조를 정확히 알지 못해 아래 내용이 정확한지 모르겠습니다. 아래식 참고하셔서 수정보완해 사용하시기 바랍니다. input : prd (5),bo_len(200),cwidthu(3),mintest(2),bocolorup(blue),bocolordown(red); var : lll(0),h_(0),l_(0),chwidth(0),cnt(0),hi(0),li(0); var : bomax(0),bostart(0),num(0),hgst(0); var : bomin(0),bostart1(0),num1(0),lwst(0); var : xx(0),x(0),box(0),tx(0); Array : phval[100](0),phloc[100](0),plval[100](0),plloc[100](0); //width lll = max(min(index, 300), 1); h_ = highest(h,lll); l_ = lowest(l,lll); chwidth = (h_ - l_) * cwidthu/100; // check if PH/PL if SwingHigh(1,h,prd,prd,prd*2+1) != -1 Then { hi = hi+1; phval[0] = h[prd]; phloc[0] = Index[prd]; For cnt = 1 to 99 { phval[cnt] = phval[cnt-1][1]; phloc[cnt] = phloc[cnt-1][1]; } } if Swinglow(1,h,prd,prd,prd*2+1) != -1 Then { li = li+1; plval[0] = l[prd]; plloc[0] = Index[prd]; For cnt = 1 to 99 { plval[cnt] = plval[cnt-1][1]; plloc[cnt] = plloc[cnt-1][1]; } } bomax = Nan; num = 0; bostart = Index; hgst = Highest(H,prd)[1]; if hi >= mintest and close > open and close > hgst Then { bomax = phval[0]; xx = 0; for x = 0 to hi - 1 { if index-phloc[x] <= Bo_len Then { if phval[x] >= close Then { x = hi+1; } Else { xx = x; bomax = max(bomax,phval[x]); } } } if xx >= mintest and open <= bomax Then { for x = 0 to xx { if phval[x] <= bomax and phval[x] >= bomax - chwidth Then { num = num+1; bostart = phloc[x]; } } if num < mintest or hgst >= bomax Then { bomax = Nan; } } } if IsNaN(bomax) == False and num >= mintest Then { box = box_new(sDate[Index-bostart],sTime[Index-bostart],bomax,sDate,sTime,bomax - chwidth); Box_SetColor(box,bocolorup); tx = Text_New(sDate,sTime,bomax - chwidth,"▲"); Text_SetColor(tx,bocolorup); Text_SetStyle(tx,2,0); } bomin = Nan; bostart1 = index; num1 = 0; lwst = lowest(l,prd)[1]; if li >= mintest and close < open and close < lwst Then { bomin = plval[0]; xx = 0; for x = 0 to li - 1 { if index-plloc[x] <= Bo_len Then { if plval[x] <= close Then { x = li+1; } Else { xx = x; bomin = min(bomin, plval[x]); } } } if xx >= mintest and open >= bomin Then { for x = 0 to xx { if plval[x] >= bomin and plval[x] <= bomin + chwidth Then { num1 = num1+ 1; bostart1 = plloc[x]; } } if num1 < mintest or lwst <= bomin Then { bomin = Nan; } } } if IsNan(bomin) == False and num1 >= mintest Then { box = box_new(sDate[Index-bostart1],sTime[Index-bostart1],bomin,sDate,sTime,bomin + chwidth); Box_SetColor(box,bocolordown); tx = Text_New(sDate,sTime,bomin + chwidth,"▼"); Text_SetColor(tx,bocolordown); Text_SetStyle(tx,2,1); } 즐거운 하루되세요 > 코샘매쓰 님이 쓴 글입니다. > 제목 : 변환부탁드립니다. > study("Breakout Finder", "BF", overlay = true, max_bars_back = 500, max_lines_count = 400) prd = input(defval = 5, title="Period", minval = 2) bo_len = input(defval = 200, title="Max Breakout Length", minval = 30, maxval = 300) cwidthu = input(defval = 3., title = "Threshold Rate %", minval = 1., maxval = 10) / 100 mintest = input(defval = 2, title = "Minimum Number of Tests", minval = 1) bocolorup = input(defval = color.blue, title = "Breakout Colors", inline = "bocol") bocolordown = input(defval = color.red, title = "", inline = "bocol") lstyle = input(defval = line.style_solid, title = "Line Style", options = [line.style_solid, line.style_dashed, line.style_dotted]) //width lll = max(min(bar_index, 300), 1) float h_ = highest(lll) float l_ = lowest(lll) float chwidth = (h_ - l_) * cwidthu // check if PH/PL ph = pivothigh(prd, prd) pl = pivotlow(prd, prd) //keep Pivot Points and their locations in the arrays var phval = array.new_float(0) var phloc = array.new_int(0) var plval = array.new_float(0) var plloc = array.new_int(0) // keep PH/PL levels and locations if ph array.unshift(phval, ph) array.unshift(phloc, bar_index - prd) if array.size(phval) > 1 // cleanup old ones for x = array.size(phloc) - 1 to 1 if bar_index - array.get(phloc, x) > bo_len array.pop(phloc) array.pop(phval) if pl array.unshift(plval, pl) array.unshift(plloc, bar_index - prd) if array.size(plval) > 1 // cleanup old ones for x = array.size(plloc) - 1 to 1 if bar_index - array.get(plloc, x) > bo_len array.pop(plloc) array.pop(plval) // check bullish cup float bomax = na int bostart = bar_index num = 0 hgst = highest(prd)[1] if array.size(phval) >= mintest and close > open and close > hgst bomax := array.get(phval, 0) xx = 0 for x = 0 to array.size(phval) - 1 if array.get(phval, x) >= close break xx := x bomax := max(bomax, array.get(phval, x)) if xx >= mintest and open <= bomax for x = 0 to xx if array.get(phval, x) <= bomax and array.get(phval, x) >= bomax - chwidth num += 1 bostart := array.get(phloc, x) if num < mintest or hgst >= bomax bomax := na if not na(bomax) and num >= mintest line.new(x1 = bar_index, y1 = bomax, x2 = bostart, y2 = bomax, color = bocolorup, style = lstyle) line.new(x1 = bar_index, y1 = bomax - chwidth, x2 = bostart, y2 = bomax - chwidth, color = bocolorup, style = lstyle) line.new(x1 = bostart, y1 = bomax - chwidth, x2 = bostart, y2 = bomax, color = bocolorup, style = lstyle) line.new(x1 = bar_index, y1 = bomax - chwidth, x2 = bar_index, y2 = bomax, color = bocolorup, style = lstyle) plotshape(not na(bomax) and num >= mintest, location = location.belowbar, style = shape.triangleup, color = bocolorup, size = size.small) alertcondition(not na(bomax) and num >= mintest, title = "Breakout", message = "Breakout") // check bearish cup float bomin = na bostart := bar_index num1 = 0 lwst = lowest(prd)[1] if array.size(plval) >= mintest and close < open and close < lwst bomin := array.get(plval, 0) xx = 0 for x = 0 to array.size(plval) - 1 if array.get(plval, x) <= close break xx := x bomin := min(bomin, array.get(plval, x)) if xx >= mintest and open >= bomin for x = 0 to xx if array.get(plval, x) >= bomin and array.get(plval, x) <= bomin + chwidth num1 += 1 bostart := array.get(plloc, x) if num1 < mintest or lwst <= bomin bomin := na if not na(bomin) and num1 >= mintest line.new(x1 = bar_index, y1 = bomin, x2 = bostart, y2 = bomin, color = bocolordown, style = lstyle) line.new(x1 = bar_index, y1 = bomin + chwidth, x2 = bostart, y2 = bomin + chwidth, color = bocolordown, style = lstyle) line.new(x1 = bostart, y1 = bomin + chwidth, x2 = bostart, y2 = bomin, color = bocolordown, style = lstyle) line.new(x1 = bar_index, y1 = bomin + chwidth, x2 = bar_index, y2 = bomin, color = bocolordown, style = lstyle) plotshape(not na(bomin) and num1 >= mintest, location = location.abovebar, style = shape.triangledown, color = bocolordown, size = size.small) alertcondition(not na(bomin) and num1 >= mintest, title = "Breakdown", message = "Breakdown") alertcondition((not na(bomax) and num >= mintest) or (not na(bomin) and num1 >= mintest), title = "Breakout or Breakdown", message = "Breakout or Breakdown")