forked from dearvn/trading-futures-tradingview-script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolor-trend-lite.txt
32 lines (22 loc) · 1.19 KB
/
color-trend-lite.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © binancash
//@version=5
indicator("Snag - Best Futures Color Trend", overlay=true)
o_h = math.max(open[3], open[2], open[1])
o_l = math.min(open[3], open[2], open[1])
o_o = open[1]
o_c = open
src(_src) =>
Close = (o_h + o_l + o_o + o_c)/4
Open = (o_o + o_c) / 2
High = math.max(o_h, math.max(Open, Close))
Low = math.min(o_l, math.min(Open, Close))
HL2 = math.avg(High, Low)
HLC3 = math.avg(High, Low, Close)
OHLC4 = math.avg(Open, High, Low, Close)
Price = _src == 'close' ? Close : _src == 'open' ? Open : _src == 'high' ? High : _src == 'low' ? Low : _src == 'hl2' ? HL2 : _src == 'hlc3' ? HLC3 : OHLC4
Source = math.round(Price / syminfo.mintick) * syminfo.mintick // PineCoders method for aligning Pine prices with chart instrument prices
// === PLOTTING ===
bar_up = src('close') < src('open')
barColor = src('close') < src('open') ? color.blue : color.red // series color
plotcandle(src('open'), src('high'), src('low'), src('close'), title = "", color = barColor, wickcolor = barColor, bordercolor = barColor) // plot bars