Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //@version=5
- indicator(title = "Vortex indicator cross support&resistance [LM]", shorttitle="VI S/R [LM]", overlay=true, format=format.price, precision=4)
- i_period = input.int(56, title="Length", minval=2, group='general setting', inline='11')
- i_showLabels = input.bool(true, title="Show labels", group='general setting', inline='11')
- i_lineCount = input.int(10, 'Line count', group='line setting', inline='12')
- i_extendLines = input.bool(false, 'Extend lines', group='line setting', inline='12')
- i_lineThickness = input.int(2, 'Line thickness', minval=1, group='line setting', inline='13')
- i_lineStyle = input.string(line.style_dotted, 'Line style', options=[line.style_dotted, line.style_solid, line.style_dashed], group='line setting', inline='13')
- i_crossoverColor = input.color(color.green, 'Crossover color', group='line setting', inline='14')
- i_crossunderColor = input.color(color.red, 'Bottom color', group='line setting', inline='14')
- var lineArray = array.new_line()
- var labelArray = array.new_label()
- f_drawLine(_x1, _x2, _yValue, _lineColor, _lineThickness, _lineStyle) =>
- line.new(x1=_x1, y1=_yValue, x2=_x2, y2=_yValue, color=_lineColor, style=_lineStyle, width=_lineThickness)
- f_drawLabel(_x, _y, _textColor) =>
- label.new(_x, _y, ' ' + str.tostring(_y), xloc.bar_index, yloc.price, #00000000, label.style_none, _textColor)
- f_extendArray(_lineArray, _labelArray, _extendLines) =>
- if array.size(_lineArray) > 0
- for _i = array.size(_lineArray) - 1 to 0 by 1
- x2 = line.get_x2(array.get(_lineArray, _i))
- yValue = line.get_y1(array.get(_lineArray, _i))
- if _extendLines or bar_index - 1 == x2 and not(high > yValue and low < yValue)
- if (i_showLabels)
- label.set_x(array.get(_labelArray, _i), bar_index)
- line.set_x2(array.get(_lineArray, _i), bar_index)
- f_drawLineAndLabel(_x1, _x2, _yValue, _colorLine, _lineCount, _lineThickness, _lineStyle, _array, _labelArray) =>
- line l = f_drawLine(_x1, _x2, _yValue, _colorLine, _lineThickness, _lineStyle)
- if (i_showLabels)
- label lab = f_drawLabel(_x2, _yValue, _colorLine)
- if array.size(_labelArray) == _lineCount
- label.delete(array.shift(_labelArray))
- array.push(_labelArray, lab)
- if array.size(_array) == _lineCount
- line.delete(array.shift(_array))
- array.push(_array, l)
- f_tema(_source, _lenght) =>
- ema01 = ta.ema(_source, _lenght)
- ema02 = ta.ema(ema01 , _lenght)
- ema03 = ta.ema(ema02 , _lenght)
- output = (3 * (ema01 - ema02) + ema03)
- vmp = math.sum( math.abs( high - low[1]), i_period )
- vmm = math.sum( math.abs( low - high[1]), i_period )
- str = math.sum( ta.atr(1), i_period )
- vip = f_tema(vmp / str, i_period)
- vim = f_tema(vmm / str, i_period)
- hasCrossedUnder = ta.crossunder(vip,vim)
- hasCrossedOver = ta.crossover(vip,vim)
- if (hasCrossedUnder)
- float yValue = low
- int x1 = bar_index
- int x2 = bar_index
- f_drawLineAndLabel(x1, x2, yValue, i_crossunderColor, i_lineCount, i_lineThickness, i_lineStyle, lineArray, labelArray)
- if (hasCrossedOver)
- float yValue = high
- int x1 = bar_index
- int x2 = bar_index
- f_drawLineAndLabel(x1, x2, yValue, i_crossoverColor, i_lineCount, i_lineThickness, i_lineStyle, lineArray, labelArray)
- f_extendArray(lineArray, labelArray, i_extendLines)
Advertisement
Add Comment
Please, Sign In to add comment