//demonstrates how to detect gaps on a separate market data feed and then plot those gaps over a different price chart - specifically for Bitcoin.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=4
study("PSMC - Bitcoin Gaps", precision=3, overlay=true)
// Get user input
marketToReference = input(title="Reference Market", type=input.string, defval="BTC1!")
minimumGap = input(title="Minimum Gap %", type=input.float, defval=5.0, minval=0.01)
overrideNewGaps = input(title="Override On New Gaps", type=input.bool, defval=false)
// Get BTC price data
btcOpen = security(marketToReference, "D", open[barstate.isrealtime ? 1 : 0])
btcHigh = security(marketToReference, "D", high[barstate.isrealtime ? 1 : 0])
btcLow = security(marketToReference, "D", low[barstate.isrealtime ? 1 : 0])
btcClose = security(marketToReference, "D", close[barstate.isrealtime ? 1 : 0])
// Calculate gap %
gapPercent = ((btcOpen - btcClose[1]) / btcOpen) * 100
// Declare gap variables
var lastBullishGapLevel = btcHigh
var lastBearishGapLevel = btcLow
gapAlert = false
// Store bullish gap information
if gapPercent >= minimumGap and (na(lastBullishGapLevel) or overrideNewGaps)
lastBullishGapLevel := btcHigh[1]
gapAlert := true
// Store bearish gap information
if gapPercent <= -minimumGap and (na(lastBearishGapLevel) or overrideNewGaps)
lastBearishGapLevel := btcLow[1]
gapAlert := true
// If bullish gap level is filled, reset our gap level
if btcLow <= lastBullishGapLevel
lastBullishGapLevel := na
// If bearish gap level is filled, reset our gap level
if btcHigh >= lastBearishGapLevel
lastBearishGapLevel := na
// Plot last gap
plot(gapPercent, color=color.orange, transp=100)
plot(lastBullishGapLevel, color=color.green, style=plot.style_linebr, linewidth=2, title="Last Bullish Gap")
plot(lastBearishGapLevel, color=color.red, style=plot.style_linebr, linewidth=2, title="Last Bearish Gap")
// Trigger alert whenever a large gap is detected
alertcondition(gapAlert, title="BTC Gap Detected!", message="Gap detected for BTC: {{plot_0}}")
Overview
PSMC - Bitcoin Gaps measures the percentage gap between the daily open and the previous daily close. A gap at or beyond the minimum percentage stores a bullish level at the prior high or a bearish level at the prior low, then plots those levels on the price chart. A level clears when price trades through it. The override setting can replace a stored level with a newer gap, and an alert condition fires when a qualifying gap appears. It does not place trades.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Reference Market
string
BTC1!
marketToReference
Minimum Gap %
float
5.0
minimumGap
Override On New Gaps
bool
false
overrideNewGaps
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
Moving Average Channel plots separate simple moving averages for upper and lower bands on the price chart. It fills the space between bands with semi-transparent color and colors bars green above the upper band, red below the lower band, or gray in between. Us
This overlay indicator finds pivot highs and lows on the price chart and compares the last two highs and the last two lows. When the percentage difference between a pair is below the Equal HL threshold, it treats them as equal levels and draws a box. Left and
This indicator monitors multiple cryptocurrency symbols for trading signals. It calculates and plots entry prices, take profit, and stop loss levels for each symbol including BTCUSDT, ETHUSDT, BNBUSDT and others. Price crossovers trigger buy, sell or close ale
This overlay indicator draws a fixed-range volume profile on the price chart, splitting traded activity into up and down volume at each price level. It also plots a sentiment profile, a developing point of control, and value-area high and low around a configur
The BZ-tracker indicator marks ARK Invest buy and sell transactions on stock charts with labels. It plots green labels for purchases and red labels for sales, each annotated with a multiplier such as X1 or X2 to show the number of ARK ETFs trading the stock on
This indicator fits a linear regression through stored pivot highs and lows and draws the resulting channel on the price chart. A function returns predicted values, maximum and minimum deviations, and the average absolute deviation. Confirmed two-bar pivots up