Bursa
Bursa
Bursa
0 at
https://mozilla.org/MPL/2.0/
// � BURSATRENDBANDCHART
//@version=5
indicator(title = 'TrendBand PriceVolume', shorttitle = 'TrendBandPriceVol', format
= format.volume)
// ����� Function returning the sub-string of `_str` to the left of the `_of`
separating character.
f_strLeftOf(_str, _of) =>
// string _str: string to separate.
// string _op : separator character.
string[] _chars = str.split(_str, "")
int _len = array.size(_chars)
int _ofPos = array.indexof(_chars, _of)
string[] _substr = array.new_string(0)
if _ofPos > 0 and _ofPos <= _len - 1
_substr := array.slice(_chars, 0, _ofPos)
string _return = array.join(_substr, "")
// Shariah Status
import BURSATRENDBANDCHART/bursamalaysianonshariah/7 as s
shariah = s.status()
status_text =
shariah == 0 ? syminfo.ticker + " [S]" :
shariah == 1 ? syminfo.ticker + " [NS]" :
syminfo.ticker
// User input
var string GP2 = 'Display Panel'
i_tableoption = input.bool(true, 'Horizontal', inline = '10', group = GP2)
sector_input = input.bool(true, 'Sector', inline = '10', group = GP2)
string i_tablepos = input.string(
position.top_right, title = 'Position', inline = '11',
options = [
position.bottom_center, position.bottom_left, position.bottom_right,
position.middle_center,position.middle_left, position.middle_right,
position.top_center,position.top_left,position.top_right
],
group = GP2)
string i_textsize = input.string(
size.small, 'Size', inline = '11',
options = [size.auto, size.tiny, size.small, size.normal],
group = GP2)
texts = input.color(color.new(color.green, 0), 'Shariah', group = 'Text Color',
inline = '2')
textns = input.color(color.new(color.red, 0), 'Non-Shariah', group = 'Text Color',
inline = '2')
textna = input.color(color.new(#9598a1, 0), 'Rest of the world', group = 'Text
Color', inline = '2')
showMA = input.bool(true, group = 'PV INPUT', inline = '1')
Value = input.int(30, group = 'PV INPUT', inline = '1')
barColorsOnPrevClose = input.bool(title = 'Color bars based on previous close',
defval = false, group = 'PV INPUT', inline = '1')
// Calculation
avdt = close * volume
sma_1 = ta.sma(avdt, Value)
spike = avdt > ta.highest(avdt, 5)[1] and high > high[1] and close > ta.sma(close,
5) and close > open // and avdt > ta.sma(avdt, 30)
supply = avdt > avdt[1] and close < open and high > ta.ema(close, 8) and
ta.ema(close, 8) > ta.ema(close, 21)
palette =
spike? color.new(#06f806, 50) :
supply? color.new(#d1d4dc, 50) :
barColorsOnPrevClose? close[1] > close? color.new(color.red, 50) :
color.new(color.green, 50) :
open > close ? color.new(color.red, 50) :
color.new(color.green, 50)
// Plot circle
plot(showMA ? sma_1 : na, style = plot.style_line, color = color.new(color.purple,
55), title = 'Volume MA')
plot(avdt, color=palette, title = 'Volume Bar', style = plot.style_columns)
plot(spike ? avdt / 2 : na, title = 'bullish', style = plot.style_circles,
linewidth = 3, color = color.new(color.blue, 0))
plot(supply ? avdt / 2 : na, title = 'bearish', style = plot.style_circles,
linewidth = 3, color = color.new(color.black, 0))
// Unfortunately, this library does not return correct sector for warrant
warrant = na(f_strLeftOf(syminfo.ticker,'-'))