Created
April 11, 2018 21:53
-
-
Save pequet/75dc5c7d5e8172c832ce11afb04f4b4f to your computer and use it in GitHub Desktop.
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
// Created by @pequet (https://www.tradingview.com/u/pequet) April 11, 2018 | |
// https://github.com/pequet/ | |
// NOT FOR DISTRIBUTION | |
// @version=3 | |
// References: | |
// http://stockcharts.com/school/doku.php?id=chart_school:chart_analysis:gaps_and_gap_analysis | |
// https://bioequity.org/statistics-do-stock-price-gaps-always-get-filled/ | |
study(title="Pandas Target Practice v1.0.4", shorttitle="Pandas Target Practice", overlay=false, precision=8) | |
// based on Gap Meter v1.0.4 | |
// INPUTS/CONFIG | |
// ------------- | |
gapThresholdConfig = 0 // a gap is a gap | |
// CALCULATE | |
// --------- | |
a = min(open,close) | |
b = max(open[1],close[1]) | |
gap1 = a-b>gapThresholdConfig?a-b:na | |
gaplevel1 = a-b>gapThresholdConfig?b:0 | |
c = min(open[1],close[1]) | |
d = max(open,close) | |
gap2 = c-d>gapThresholdConfig?c-d:na | |
gaplevel2 = c-d>gapThresholdConfig?c:0 | |
gapHeight = not na(gap1) ? gap1 : not na(gap2) ? gap2 : na | |
// PLOT | |
// ---- | |
// candles | |
_candleColor = open > close ? silver : gray | |
_wickColor = gray | |
plotcandle(open, high, low, close, color=_candleColor, wickcolor=_wickColor, title="") | |
// plot(gap1 > 0 ? b + 0.5 * gapHeight : gap2 > 0 ? d + 0.5 * gapHeight : na, style=line, color=fuchsia, linewidth=1, transp=0, title="Pandas Zipline", offset=0) // pandas zipline | |
// plot(gapHeight, title="Gap", color=not na(gap1) ? green : red, transp=20, style=histogram, linewidth=4, offset=0) // gap meter | |
plotshape(gap1 > 0 ? b + 0.5 * gapHeight : gap2 > 0 ? d + 0.5 * gapHeight : na, location=location.absolute, style=shape.circle, color=gap1 > 0 ? green : red, size=size.small, title="Gap", offset=0) // pandas targets | |
// that's all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great stuff!