Hello coders! Request to convert Tradingview script to MT4. Thank you!
Automatically finds a triangle on the chart.
https://ru.tradingview.com/script/R1uOE ... otriangle/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ROBO_Trading
//@version=4
study(title = "robotrading autotriangle", shorttitle = "autotriangle", overlay = true)
bars = input(1000)
level = input(false)
newlineh(bars)=>
h = highest(high, bars)
t = 0
for i = 0 to bars
t := i
if high == h
break
var line line1 = na
line.delete(line1)
if level
line1 := line.new(bar_index - t, h, bar_index, h, color = color.blue, width = 3, extend = extend.right)
a = t
newlinel(bars)=>
l = lowest(low, bars)
t = 0
for i = 0 to bars
t := i
if low == l
break
var line line1 = na
line.delete(line1)
if level
line1 := line.new(bar_index - t, l, bar_index, l, color = color.red, width = 3, extend = extend.right)
a = t
h1 = newlineh(bars)
l1 = newlinel(max(1, h1))
h2 = newlineh(max(1, l1))
l2 = newlinel(max(1, h2))
var line line1 = na
line.delete(line1)
hy1 = highest(high, max(1, h1 + 1))
hy2 = highest(high, max(1, h2 + 1))
line1 := line.new(bar_index - h1, hy1, bar_index - h2, hy2, color = color.orange, width = 3, extend = extend.right)
var line line2 = na
line.delete(line2)
ly1 = lowest(low, max(1, l1 + 1))
ly2 = lowest(low, max(1, l2 + 1))
line2 := line.new(bar_index - l1, ly1, bar_index - l2, ly2, color = color.orange, width = 3, extend = extend.right)
Attachments forums
Re: Converting tradingview script to mt4 indicator
dmnik, Thu Jul 15, 2021 2:19 am