Last active
July 2, 2020 21:22
-
-
Save oscarvs/f05612579c9a174e8d5b to your computer and use it in GitHub Desktop.
PineScript "Bitcoin Kill Zones" for TradingView.com
This file contains hidden or 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 https://www.tradingview.com/u/oscarvs @ 18 October 2014 | @theoscarvs | |
// Inspired by @ICT_MHuddleston concepts and @CRInvestor courses, code based on @ChrisMoody scripts | |
// https://github.com/oscarvs/bitcoin-killzones | |
// Time sessions are directly sync from exchange/tv data (Change manually if you need to adjust DST Daylight saving time) | |
study(title="Bitcoin Kill Zones v2 [oscarvs]",shorttitle="Bitcoin Kill Zones v2", overlay=true) | |
timeinrange(res, sess) => time(res, sess) != 0 | |
// **** Checkboxes and custom Session | |
iKZNY = input(true, title="New York Kill Zone") | |
iOpenKZLondon = input(true, title="London Open Kill Zone") | |
iCloseKZLondon = input(true, title="London Close Kill Zone") | |
iAsiaKZ = input(true, title="Asia Kill Zone") | |
KZNY = input('1230-1430', type=session, title="New York Kill Zone") | |
LondonOpenKZ = input('0600-0800', type=session, title="London Open Kill Zone") | |
LondonCloseKZ = input('1500-1700', type=session, title="London Close Kill Zone") | |
AsiaKZ = input('2300-0300', type=session, title="Asia Kill Zone") | |
iRealOpenSessionAlertBar = input(true, title="Real Open Session Alert Bar") | |
NYOpenAlertBar = input('1330-1345', type=session, title="New York Open Session") | |
LondonOpenAlertBar = input('0700-0715', type=session, title="London Open Session") | |
LondonCloseAlertBar = input('1545-1600', type=session, title="London Close Session") | |
AsiaOpenAlertBar = input('0000-0015', type=session, title="Asia Open Session") | |
// **** Logic | |
sessToUse = iKZNY == 1 ? KZNY : '0000-0000' | |
sessToUse2 = iRealOpenSessionAlertBar == 1 ? NYOpenAlertBar : '0000-0000' | |
sessToUse3 = iOpenKZLondon == 1 ? LondonOpenKZ : '0000-0000' | |
sessToUse4 = iRealOpenSessionAlertBar == 1 ? LondonOpenAlertBar : '0000-0000' | |
sessToUse5 = iCloseKZLondon == 1 ? LondonCloseKZ : '0000-0000' | |
sessToUse6 = iRealOpenSessionAlertBar == 1 ? LondonCloseAlertBar : '0000-0000' | |
sessToUse7 = iAsiaKZ == 1 ? AsiaKZ : '0000-0000' | |
sessToUse8 = iRealOpenSessionAlertBar == 1 ? AsiaOpenAlertBar : '0000-0000' | |
// *** Apply custom rules | |
bgPlot = (iKZNY == 0 ? time(period) : time(period, sessToUse)) | |
bgPlot2 = (iRealOpenSessionAlertBar == 0 ? time(period) : time(period, sessToUse2)) | |
bgPlot3 = (iOpenKZLondon == 0 ? time(period) : time(period, sessToUse3)) | |
bgPlot4 = (iRealOpenSessionAlertBar == 0 ? time(period) : time(period, sessToUse4)) | |
bgPlot5 = (iCloseKZLondon == 0 ? time(period) : time(period, sessToUse5)) | |
bgPlot6 = (iRealOpenSessionAlertBar == 0 ? time(period) : time(period, sessToUse6)) | |
bgPlot7 = (iAsiaKZ == 0 ? time(period) : time(period, sessToUse7)) | |
bgPlot8 = (iRealOpenSessionAlertBar == 0 ? time(period) : time(period, sessToUse8)) | |
//**** Plot as background | |
bgcolor(iKZNY and bgPlot > 0 ? red : na, transp=90) | |
bgcolor(iKZNY and iRealOpenSessionAlertBar and bgPlot2 > 0 ? red : na, transp=70) | |
bgcolor(iOpenKZLondon and bgPlot3 > 0 ? green : na, transp=90) | |
bgcolor(iOpenKZLondon and iRealOpenSessionAlertBar and bgPlot4 > 0 ? green : na, transp=70) | |
bgcolor(iCloseKZLondon and bgPlot5 > 0 ? olive : na, transp=90) | |
bgcolor(iCloseKZLondon and iRealOpenSessionAlertBar and bgPlot6 > 0 ? olive : na, transp=70) | |
bgcolor(iAsiaKZ and bgPlot7 > 0 ? orange : na, transp=90) | |
bgcolor(iAsiaKZ and iRealOpenSessionAlertBar and bgPlot8 > 0 ? orange : na, transp=70) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment