Skip to content

Instantly share code, notes, and snippets.

@bongkook
Last active October 16, 2019 03:32
Show Gist options
  • Save bongkook/a61f38b7a146ec02383120168fe1e3e0 to your computer and use it in GitHub Desktop.
Save bongkook/a61f38b7a146ec02383120168fe1e3e0 to your computer and use it in GitHub Desktop.
TradingView Indicators
//Created by Chrismoody on 7/22/2014 By Request for user lucalucious
//Modified Heikinashi with EMA Filter...
//Choice To Plot EMA Trend Is Based Off Of
study(title = "CM_Modified_Heik_Trend_Bars", shorttitle="CM_TrendBars",overlay=true)
note = input(false, title="Lower Numbers = More Sensitive to Price Change...Higher Numbers = Less Sensitive")
uema = input(34, minval=1, maxval=50, title="EMA UpTrend")
dema = input(34, minval=1, maxval=50, title="EMA DownTrend")
shema = input(false, title="Show EMA Trend is Based On?")
haclose = (open + high + low + close)/4
haopen = na(haopen[1]) ? (open + close)/2 : (haopen[1] + haclose[1]) / 2
upEma = ema(haclose, uema)
downEma = ema(haopen, dema)
emaAvg = (upEma + downEma)/2
heikUpColor() => hlc3 >= emaAvg
heikDownColor() => hlc3 < emaAvg
col = hlc3 >= emaAvg[1] ? lime : hlc3 < emaAvg[1] ? red : white
barcolor(heikUpColor() ? lime: heikDownColor() ? red : na)
plot(shema and emaAvg ? emaAvg : na, title="EMA UpTrend", style=line, linewidth=3, color=col)
@bongkook
Copy link
Author

f_highest(_src, _length)=>
_adjusted_length = _length < 1 ? 1 : _length
_value = _src
for _i = 0 to (_adjusted_length-1)
_value := _src[_i] >= _value ? _src[_i] : _value
_return = _value

f_lowest(_src, _length)=>
_adjusted_length = _length < 1 ? 1 : _length
_value = _src
for _i = 0 to (_adjusted_length-1)
_value := _src[_i] <= _value ? _src[_i] : _value
_return = _value

@bongkook
Copy link
Author

bongkook commented Jan 23, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment