Skip to content

Instantly share code, notes, and snippets.

@pequet
Last active May 4, 2018 16:53
Show Gist options
  • Save pequet/e80b2d9f514a644380a561bbc4b05213 to your computer and use it in GitHub Desktop.
Save pequet/e80b2d9f514a644380a561bbc4b05213 to your computer and use it in GitHub Desktop.
// Created by @pequet (https://www.tradingview.com/u/pequet) April 11 2017
// https://github.com/pequet/
// NOT FOR DISTRIBUTION
// @version=3
study(title="BITFINEX:LONGS:SHORTS v0.0.3", shorttitle="LONGS:SHORTS", overlay=false, precision=8)
Market(side) =>
market = ticker=="BTCEUR" or ticker=="XBTEUR" ? "BTCEUR"
: ticker=="BTCJPY" or ticker=="XBTJPY" ? "BTCJPY"
: ticker=="BTCUSD" or ticker=="XBTUSD" or ticker=="BTCUSDT" or ticker=="BTCUSD1W" or ticker=="BTCUSD2W" or ticker=="BTCUSD3M" ? "BTCUSD"
: ticker=="ETHUSD" or ticker=="ETHUSDT" ? "ETHUSD"
: ticker=="ETHBTC" ? "ETHBTC"
: ticker=="EOSUSD" or ticker=="EOSUSDT" ? "EOSUSD"
: ticker=="EOSBTC" ? "EOSBTC"
: ticker=="EOSETH" ? "EOSETH"
: ticker=="LTCUSD" or ticker=="LTCUSDT" ? "LTCUSD"
: ticker=="LTCBTC" ? "LTCBTC"
: ticker=="XRPUSD" or ticker=="XRPUSDT" ? "XRPUSD"
: ticker=="XRPBTC" ? "XRPBTC"
: ticker=="BCHUSD" or ticker=="BCHUSDT" ? "BCHUSD"
: ticker=="BCHBTC" ? "BCHBTC"
: ticker=="BCHETH" ? "BCHETH"
: ticker=="IOTABTC" ? "IOTABTC"
: ticker=="IOTAETH" ? "IOTAETH"
: ticker=="NEOUSD" or ticker=="NEOUSDT" ? "NEOUSD"
: ticker=="NEOBTC" ? "NEOBTC"
: ticker=="NEOETH" ? "NEOETH"
: ticker=="ETCUSD" or ticker=="ETCUSDT" ? "ETCUSD"
: ticker=="ETCBTC" ? "ETCBTC"
: ticker=="OMGUSD" or ticker=="OMGUSDT" ? "OMGUSD"
: ticker=="OMGBTC" ? "OMGBTC"
: ticker=="OMGETH" ? "OMGETH"
: ticker=="XMRUSD" or ticker=="XMRUSDT" ? "XMRUSD"
: ticker=="XMRBTC" ? "XMRBTC"
: ticker=="DASHUSD" or ticker=="DASHUSDT" ? "DASHUSD"
: ticker=="DASHBTC" ? "DASHBTC"
: ticker=="ZECUSD" or ticker=="ZECUSDT" ? "ZECUSD"
: ticker=="ZECBTC" ? "ZECBTC"
: ticker=="BTGUSD" or ticker=="BTGUSDT" ? "BTGUSD"
: ticker=="BTGBTC" ? "BTGBTC"
: ticker=="QTUMUSD" or ticker=="QTUMUSDT" ? "QTUMUSD"
: ticker=="QTUMBTC" ? "QTUMBTC"
: ticker=="QTUMETH" ? "QTUMETH"
: ticker=="RDNUSD" or ticker=="RDNUSDT" ? "RDNUSD"
: ticker=="RDNBTC" ? "RDNBTC"
: ticker=="RDNETH" ? "RDNETH"
: ""
[security("BITFINEX:"+(market != "" ? market : "BTCUSD")+side, period, close), market != ""]
// 😵
// "SANUSD",
// "SANBTC",
// "SANETH",
// "EDOUSD",
// "EDOBTC",
// "EDOETH",
// "ETPUSD",
// "ETPBTC",
// "ETPETH",
// "QASHUSD",
// "QASHBTC",
// "DATAUSD",
// "DATABTC",
// "DATAETH",
// "AVTUSD",
// "AVTBTC",
// "AVTETH",
// "RRTUSD",
// "RRTBTC",
// "AIOUSD",
// "AIOBTC",
// "AIOETH",
// "REQUSD",
// "REQBTC",
// "REQETH",
// "LRCUSD",
// "LRCBTC",
// "LRCETH",
// "WAXUSD",
// "WAXBTC",
// "WAXETH",
// "DAIUSD",
// "DAIBTC",
// "DAIETH",
// "CFIUSD",
// "CFIBTC",
// "CFIETH",
// "AGIUSD",
// "AGIBTC",
// "AGIETH",
// "BFTUSD",
// "BFTBTC",
// "BFTETH",
// "MTNUSD",
// "MTNBTC",
// "MTNETH",
// "ODEUSD",
// "ODEBTC",
// "ODEETH"
[longs, found] = Market("LONGS")
[shorts, found2] = Market("SHORTS")
plot(found ? shorts : na, color=red, transp=0, linewidth=1, title="Shorts")
plot(found ? longs : na, color=green, transp=0, linewidth=1, title="Longs")
// crosses
plotshape(found and barstate.islast and cross(longs, shorts), style=shape.xcross, location=location.top, color=crossunder(longs, shorts) ? orange : yellow, transp=0, size=size.small, title="Cross (Potential)", show_last=1)
plotshape(found and not barstate.islast and cross(longs, shorts), style=shape.xcross, location=location.top, color=crossunder(longs, shorts) ? red : green, transp=0, size=size.small, title="Cross")
// -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment