Created
April 30, 2020 02:03
-
-
Save sandro/c72c23c70a597ed0f3b8c7efb65badac to your computer and use it in GitHub Desktop.
renko something
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ | |
// © SandroTurriate | |
//@version=4 | |
study("Heiken Ashi Trend") | |
haopen = security(heikinashi(syminfo.tickerid), timeframe.period, open) | |
haclose = security(heikinashi(syminfo.tickerid), timeframe.period, close) | |
//plot(0) | |
//plot(1, color=haclose <= haopen ? color.red : color.green, style=plot.style_columns) | |
diff = sma(haclose, 20) - sma(haopen, 20) | |
//plot(3, color=diff > 0 ? color.green : color.red, style=plot.style_columns, histbase=2) | |
renko_tickerid = renko(syminfo.tickerid, "ATR", 10) | |
renko_close = security(renko_tickerid, timeframe.period, close) | |
renko_open = security(renko_tickerid, timeframe.period, open) | |
//plot(2, color=renko_close > renko_open ? color.green : color.red, style=plot.style_columns, histbase=1) | |
prange = atr(20) | |
ptr = tr(true) | |
var popen = open | |
var pclose = open | |
pdiff = close - open | |
if abs(pdiff) > prange | |
if pdiff > 0 | |
if popen[1] < pclose[1] | |
popen := pclose[1] | |
else | |
popen := popen[1] | |
pclose := popen + prange | |
else | |
if popen[1] < pclose[1] | |
popen := popen[1] | |
else | |
popen := pclose[1] | |
pclose := popen - prange | |
//else | |
// popen := nz(popen[1], close) | |
//pclose := popen - prange | |
//popen := nz(pclose[1], open) | |
//pclose := pdiff > 0 ? popen + prange : popen - prange | |
else | |
popen := nz(popen[1], open) | |
pclose := nz(pclose[1], open) | |
plotcandle(popen, popen+ptr, popen-ptr, pclose, color=pclose > popen ? color.green : color.red) | |
plot(abs(pdiff) > prange ? popen : na, style=plot.style_linebr, linewidth=3) | |
// ropen = security(syminfo.tickerid, timeframe.period, open) | |
// rhigh = security(syminfo.tickerid, timeframe.period, high) | |
// rlow = security(syminfo.tickerid, timeframe.period, low) | |
// rclose = security(syminfo.tickerid, timeframe.period, close) | |
// var hopen = (ropen + rclose)/2 | |
// hclose = (ropen + rhigh + rlow + rclose)/4 | |
// if bar_index > 0 | |
// hopen := (hopen[1] + hclose[1])/2 | |
// hhigh = max(rhigh, hopen, hclose) | |
// hlow = min(rlow, hopen, hclose) | |
// trendup = hclose > hopen ? 1 : na | |
// trenddn = hclose <= hopen ? 1 : na | |
// plot(hopen) | |
// plot(security(heikinashi(syminfo.tickerid), timeframe.period, open)) | |
// plot(hclose) | |
// plot(security(heikinashi(syminfo.tickerid), timeframe.period, close)) | |
// //plot(0, color=color.white) | |
// plot(trendup, style=plot.style_columns, color=color.green) | |
// plot(trenddn, style=plot.style_columns, color=color.red) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment