Candle Thief v1.0 (TradingView Anomalies)

Remove from Favorite Scripts Add to Favorite Scripts
// Created by @pequet ( May 30 2016 
// MIT License
// Candle Thief
// Each notch is a missing candle from the chart.  

study("Candle Thief v1.0 (TradingView Anomalies)", shorttitle="Candle Thief v1.0")

// functions
OnePeriod() => ismonthly ? 40320*interval  
     : isweekly ? 10080*interval
     : isdaily ? 1440*interval
     : interval
OneBarTime(i) =>
HowManyActualBarsAgoWas(t) => // t in minutes
    idealBar = OnePeriod()
    totalBars = t / idealBar 
    // countdown
    tLeft = t
    actualBars = 1
    for i = 1 to totalBars
        tLeft := tLeft - ((time[i-1]-time[i])/60000)
        if tLeft > 0
            actualBars := actualBars + 1 

// how long ago was the previous candle compared to normal (only anomalies are shown)
srcTLMU = OneBarTime(0) / OnePeriod() - 1
plot(not na(time[1]) and nz(srcTLMU)!=0 ? srcTLMU : na, color=red, style=histogram, transp=0, title="Missing candles")

// alerts
alertcondition(not na(time[1]) and nz(srcTLMU)!=0, title='Candle Thief!', message='A new bar is missing from the chart.')

// that's it
EN English
EN English (UK)
EN English (IN)
DE Deutsch
FR Français
ES Español
IT Italiano
PL Polski
SV Svenska
TR Türkçe
RU Русский
PT Português
ID Bahasa Indonesia
MS Bahasa Melayu
TH ภาษาไทย
VI Tiếng Việt
JA 日本語
KO 한국어
ZH 简体中文
ZH 繁體中文
AR العربية
Home Stock Screener Forex Signal Finder Cryptocurrency Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Feature Request Blog & News FAQ Help & Wiki Twitter
Profile Profile Settings Account and Billing My Support Tickets Contact Support Ideas Published Followers Following Private Messages Chat Sign Out