Attachments forums

List of attachments posted on this forum.


All files on forums: 135938

Re: Already Converted TradingView Indicators to MT4 Indicators

Enes Kocoglu, Sat Mar 25, 2023 8:49 pm

//@version=4
// gkjch
// Original By: JustUncleL : https://www.tradingview.com/script/Ja29 ... ustUncleL/

study(title="Simple Pivots", shorttitle="Pivots", overlay=true, max_bars_back=50)

ShowPivots = input(true, title="Show Pivot Lines")

left = input(8, minval=1, title="Pivot Lookback Left Hand Side")
right = input(8, minval=1, title="Pivot lookback Right Hand Side")

ExtendCurrentPivots = input(defval = true, title = "Draw lines extending from most recent pivots forward")
ShowPivotPrice = input(defval = false, title = "Place price of prior pivots on chart")

Shunt = input(1, minval=0, maxval=1, type=input.integer, title="When to start Printing Pivot (0 = no wait, 1 = wait for candle close)")
maxLvlLen = input(0, minval=0, title="Maximum Level Extension Length - 0 indicates no maximum")


// Get High and Low Pivot Points
pvthi_ = pivothigh(high, left, right)
pvtlo_ = pivotlow(low, left, right)

// Force Pivot completion before plotting.
pvthi = pvthi_[Shunt]
pvtlo = pvtlo_[Shunt]

//Count How many candles for current Pivot Level, If new reset.
counthi = 0
countlo = 0
counthi := na(pvthi) ? nz(counthi[1]) + 1 : 0
countlo := na(pvtlo) ? nz(countlo[1]) + 1 : 0

pvthis = 0.0
pvtlos = 0.0
pvthis := na(pvthi) ? pvthis[1] : high[right + Shunt]
pvtlos := na(pvtlo) ? pvtlos[1] : low[right + Shunt]

// Colors for Lines
hipc = pvthis != pvthis[1] ? na : color.green
lopc = pvtlos != pvtlos[1] ? na : color.red

// Draw historical levels, "line" objects are limited in history.
plot(ShowPivots and (maxLvlLen == 0 or counthi < maxLvlLen) ? pvthis : na, color=hipc, linewidth=1, offset=-right - Shunt, title="Top Levels")
plot(ShowPivots and (maxLvlLen == 0 or countlo < maxLvlLen) ? pvtlos : na, color=lopc, linewidth=1, offset=-right - Shunt, title="Bottom Levels")

drawLabel(_offset, _pivot, _style, _yloc, _color, _text, _size) =>
if not na(_pivot)
label.new(bar_index[_offset], _pivot, text = _text+tostring(_pivot, format.mintick)+"]", style=_style, yloc=_yloc, color=_color, textcolor=_color, size = _size)

drawLabel(right+Shunt, ShowPivotPrice and counthi < counthi[1] and pvthis != pvthis[1] ? pvthis : na, label.style_none, yloc.abovebar, color.green, "[", size.normal)
drawLabel(right+Shunt, ShowPivotPrice and countlo < countlo[1] and pvtlos != pvtlos[1] ? pvtlos : na, label.style_none, yloc.belowbar, color.red, "[", size.normal)

LineFunction(ShowLine, startLine, stopLine, levelLine, colorLine, lineStyle, lineWidth, lastLine) =>
line.delete(lastLine)
ShowLine?
line.new(
x1 = startLine,
x2 = stopLine,
y1 = levelLine,
y2 = levelLine,
xloc = xloc.bar_index,
extend = extend.right,
color = colorLine,
style = lineStyle,
width = lineWidth): na

var line HiPivot = na
var line LoPivot = na
HiPivot := LineFunction(ExtendCurrentPivots, counthi > counthi[1] ? bar_index-right-Shunt : na, bar_index, pvthis, color.green, close > pvthis ? line.style_solid : line.style_dotted, 1, HiPivot[1])
LoPivot := LineFunction(ExtendCurrentPivots, countlo > countlo[1] ? bar_index-right-Shunt : na, bar_index, pvtlos, color.red, close < pvtlos ? line.style_solid : line.style_dotted, 1, LoPivot[1])



Can masters adapt this pivot indicator mt4?
All files in topic