Modified 'Three Libe Break' Request
Posted: Wed Apr 14, 2021 9:01 am
Is it possible to translate the following into lua? This code cones from tradingview website. Thanks
//@version=3
////////////////////////////////////////////////////////////
// Copyright by HPotter v1.0 30/05/2019
// This is a modified version of the three line break price representation.
// It is composed with 2 lines made of Close price values forming a “cloud”.
// If the trend is bullish and the price breach the lower level of the green
// cloud, a new bearish trend is taking place.
// If the current trend is bearish and the price breakout the upper band of
// the cloud, a new bullish trend is forming.
// This is a “price action” indicator, signals may be filtered by long term trend
// analysis with other indicators such as Supertrend for instance.
////////////////////////////////////////////////////////////
study(title="Three Line Break", overlay = true)
xtrend = 1
xu = close
xu1 = close
xu2 = close
xu3 = close
if xtrend[1] == 1
if close > xu[1]
xu3 := xu2[1]
xu2 := xu1[1]
xu1 := xu[1]
xu := close
xtrend := 1
else
if close < xu3[1]
xu3 := xu1[1]
xu2 := xu1[1]
xu1 := xu1[1]
xu := close
xtrend := -1
else
xtrend := 1
else
if close > xu3[1]
xu3 := xu1[1]
xu2 := xu1[1]
xu1 := xu1[1]
xu := close
xtrend := 1
else
if close < xu[1]
xu3 := xu2[1]
xu2 := xu1[1]
xu1 := xu[1]
xu := close
xtrend := -1
else
xtrend := -1
colorm = xtrend == -1 ? red: xtrend == 1 ? green : blue
p1 = plot(xu, color=colorm)
p2 = plot(xu3, color=colorm)
fill(p1, p2, color=colorm)
//@version=3
////////////////////////////////////////////////////////////
// Copyright by HPotter v1.0 30/05/2019
// This is a modified version of the three line break price representation.
// It is composed with 2 lines made of Close price values forming a “cloud”.
// If the trend is bullish and the price breach the lower level of the green
// cloud, a new bearish trend is taking place.
// If the current trend is bearish and the price breakout the upper band of
// the cloud, a new bullish trend is forming.
// This is a “price action” indicator, signals may be filtered by long term trend
// analysis with other indicators such as Supertrend for instance.
////////////////////////////////////////////////////////////
study(title="Three Line Break", overlay = true)
xtrend = 1
xu = close
xu1 = close
xu2 = close
xu3 = close
if xtrend[1] == 1
if close > xu[1]
xu3 := xu2[1]
xu2 := xu1[1]
xu1 := xu[1]
xu := close
xtrend := 1
else
if close < xu3[1]
xu3 := xu1[1]
xu2 := xu1[1]
xu1 := xu1[1]
xu := close
xtrend := -1
else
xtrend := 1
else
if close > xu3[1]
xu3 := xu1[1]
xu2 := xu1[1]
xu1 := xu1[1]
xu := close
xtrend := 1
else
if close < xu[1]
xu3 := xu2[1]
xu2 := xu1[1]
xu1 := xu[1]
xu := close
xtrend := -1
else
xtrend := -1
colorm = xtrend == -1 ? red: xtrend == 1 ? green : blue
p1 = plot(xu, color=colorm)
p2 = plot(xu3, color=colorm)
fill(p1, p2, color=colorm)