-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1 for BTFG_STFG strategy and studies
- Loading branch information
Showing
10 changed files
with
389 additions
and
2 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
# | ||
# BTFG_STFG | ||
# | ||
# This script adapted from posts from @kerberos007 | ||
# https://twitter.com/kerberos007 | ||
# | ||
# Want the latest version of this script? | ||
# https://github.com/korygill/technical-analysis# | ||
# Use on thinkorswim and thinkscript | ||
# author @korygill | ||
# | ||
|
||
script GetBollingerBandPercent | ||
{ | ||
input price = close; | ||
input upper = 2; | ||
input lower = 2; | ||
input averageType = AverageType.SIMPLE; | ||
input displace = 0; | ||
input length = 20; | ||
|
||
def upperBand = BollingerBands(price, displace, length, lower, upper, averageType).UpperBand; | ||
def lowerBand = BollingerBands(price, displace, length, lower, upper, averageType).LowerBand; | ||
|
||
plot BBPercent = (price - lowerBand) / (upperBand - lowerBand) * 100; | ||
} | ||
|
||
declare lower; | ||
|
||
input averageType = AverageType.Simple; | ||
input price = close; | ||
input displace = 0; | ||
input length = 20; | ||
input StdDev_DnBuy = -2.0; | ||
input StdDev_UpBuy = 2.0; | ||
input StdDev_DnSell = -1.0; | ||
input StdDev_UpSell = 1.0; | ||
|
||
plot PercentBBuy = GetBollingerBandPercent(price, StdDev_UpBuy, StdDev_DnBuy); | ||
plot PercentBSell = GetBollingerBandPercent(price, StdDev_UpSell, StdDev_DnSell); | ||
|
||
plot ZeroLine = 0; | ||
plot HalfLine = 50; | ||
plot UnitLine = 100; | ||
|
||
def vixPrice = close("VIX"); | ||
def vixPercentBBuy = GetBollingerBandPercent(vixPrice, StdDev_UpBuy, StdDev_DnBuy); | ||
def vixPercentBSell = GetBollingerBandPercent(vixPrice, StdDev_UpSell, StdDev_DnSell); | ||
|
||
|
||
|
||
def opacity = 25; | ||
def linewidth = 1; | ||
|
||
PercentBBuy.SetDefaultColor(Color.GREEN);#(GetColor(3)); | ||
PercentBBuy.AssignValueColor(CreateColor( | ||
0, | ||
255, #255-Max(0,Min(100-opacity,PercentBBuy))*2.55, | ||
0)); | ||
PercentBBuy.SetPaintingStrategy(PaintingStrategy.LINE); | ||
PercentBBuy.SetLineWeight(linewidth); | ||
|
||
PercentBSell.SetDefaultColor(Color.RED);#(GetColor(7)); | ||
PercentBSell.AssignValueColor(CreateColor( | ||
255, #Max(opacity,Min(100,PercentBSell))*2.55, | ||
0, | ||
0)); | ||
PercentBSell.SetPaintingStrategy(PaintingStrategy.LINE); | ||
PercentBSell.SetLineWeight(linewidth); | ||
|
||
ZeroLine.SetDefaultColor(Color.GREEN); | ||
HalfLine.SetDefaultColor(GetColor(8)); | ||
UnitLine.SetDefaultColor(Color.RED); | ||
|
||
# LONG | ||
AddVerticalLine( | ||
Crosses(PercentBBuy, ZeroLine, CrossingDirection.ABOVE), | ||
"+++ Go Long +++", Color.GREEN, curve.SHORT_DASH | ||
); | ||
|
||
AddVerticalLine( | ||
Crosses(PercentBSell, UnitLine, CrossingDirection.ABOVE), | ||
"+++ Cover Long +++", Color.RED, curve.SHORT_DASH | ||
); | ||
|
||
# SHORT | ||
AddVerticalLine( | ||
Crosses(PercentBBuy, UnitLine, CrossingDirection.BELOW), | ||
"--- (Go Short) ---", Color.YELLOW, curve.SHORT_DASH | ||
); | ||
|
||
AddVerticalLine( | ||
Crosses(PercentBSell, ZeroLine, CrossingDirection.BELOW), | ||
"--- (Cover Short) ---", Color.MAGENTA, curve.SHORT_DASH | ||
); | ||
|
||
|
||
#AddVerticalLine( | ||
# GetDayofWeek(GetYYYYMMDD()) == 5, | ||
# "Friday", Color.LIGHT_GRAY, curve.MEDIUM_DASH | ||
#); | ||
|
||
AddLabel(yes, GetSymbol(), COLOR.CYAN); | ||
AddLabel(yes, "Long=Green cross > 0, Cover=Red cross > 100", COLOR.GREEN); | ||
AddLabel(yes, "Short=Red cross < 100, Cover=Green cross < 0", COLOR.RED); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# | ||
# BTFG_STFG_Strat | ||
# | ||
# This script adapted from posts from @kerberos007 | ||
# https://twitter.com/kerberos007 | ||
# | ||
# Want the latest version of this script? | ||
# https://github.com/korygill/technical-analysis# | ||
# Use on thinkorswim and thinkscript | ||
# author @korygill | ||
# | ||
|
||
script GetBollingerBandPercent | ||
{ | ||
input price = close; | ||
input upper = 2; | ||
input lower = 2; | ||
input averageType = AverageType.SIMPLE; | ||
input displace = 0; | ||
input length = 20; | ||
|
||
def upperBand = BollingerBands(price, displace, length, lower, upper, averageType).UpperBand; | ||
def lowerBand = BollingerBands(price, displace, length, lower, upper, averageType).LowerBand; | ||
|
||
plot BBPercent = (price - lowerBand) / (upperBand - lowerBand) * 100; | ||
} | ||
|
||
input averageType = AverageType.SIMPLE; | ||
input price = close; | ||
input displace = 0; | ||
input length = 20; | ||
input StdDev_DnBuy = -2.0; | ||
input StdDev_UpBuy = 2.0; | ||
input StdDev_DnSell = -1.0; | ||
input StdDev_UpSell = 1.0; | ||
input LongShortBoth = {Long, Short, default Both}; | ||
|
||
def PercentBBuy = GetBollingerBandPercent(price, StdDev_UpBuy, StdDev_DnBuy); | ||
|
||
def PercentBSell = GetBollingerBandPercent(price, StdDev_UpSell, StdDev_DnSell); | ||
|
||
def ZeroLine = 0; | ||
def HalfLine = 50; | ||
def UnitLine = 100; | ||
|
||
def lsb; | ||
switch (LongShortBoth) | ||
{ | ||
case Long: lsb = 0; | ||
case Short: lsb = 1; | ||
default: lsb = 2; | ||
} | ||
|
||
# LONG | ||
AddOrder(OrderType.BUY_TO_OPEN, | ||
Crosses(PercentBBuy, ZeroLine, CrossingDirection.ABOVE) and lsb != 1, | ||
tickColor = COLOR.WHITE, arrowColor = COLOR.GREEN | ||
); | ||
|
||
AddOrder(OrderType.SELL_TO_CLOSE, | ||
Crosses(PercentBSell, UnitLine, CrossingDirection.ABOVE) and lsb != 1, | ||
tickColor = COLOR.WHITE, arrowColor = COLOR.RED | ||
); | ||
|
||
# SHORT | ||
AddOrder(OrderType.SELL_TO_OPEN, | ||
Crosses(PercentBBuy, UnitLine, CrossingDirection.BELOW) and lsb != 0, | ||
tickColor = COLOR.WHITE, arrowColor = COLOR.YELLOW | ||
); | ||
|
||
AddOrder(OrderType.BUY_TO_CLOSE, | ||
Crosses(PercentBSell, ZeroLine, CrossingDirection.BELOW) and lsb != 0, | ||
tickColor = COLOR.WHITE, arrowColor = COLOR.MAGENTA | ||
); | ||
|
||
AddLabel(yes, "Go Long", COLOR.GREEN); | ||
AddLabel(yes, "Cover Long", COLOR.RED); | ||
AddLabel(yes, "Go Short", COLOR.YELLOW); | ||
AddLabel(yes, "Cover Short", COLOR.MAGENTA); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# VIX_BTFG_STFG # | ||
|
||
This is a long/short study based on the work of [@kerberos007](https://twitter.com/kerberos007). If you look at their feed, you will see lots of work regarding this strategy using Bollinger Bands, Percent B (%B), and some initial parameters that give good back testing results. | ||
|
||
As with any strategy, you should understand it, tweak it to your own risk profile, and extend it to incorporate other indicators and strategies. | ||
|
||
Alternatively, just buy or sell the glitch! | ||
|
||
## Strategy and Study Development ## | ||
|
||
This strategy/study is for the VIX. | ||
|
||
A *strategy* for this study is still under development... This study can be used independently, or you can find this study in use on the [BTFG_STFG](/BTFG_STFG/BTFG_STFG.md) page. See that page for a lot of info on how to configure studies in thinkorswim. | ||
|
||
Per the aformentioned work from [@kerberos007](https://twitter.com/kerberos007) | ||
|
||
Calls | ||
go long VIX calls when %B(20,1.5) crosses > 0 | ||
cover VIX calls when %B(20,1.5) crosses > 100 | ||
|
||
Puts | ||
go long VIX puts when %B(20,1.2) crosses < 100 | ||
cover VIX puts when %B(20,2) crosses < 0 | ||
|
||
A *Study* will fire many times more than its corresponding *Strategy*. This is also good for developing a new strategy, so you can eyeball when various conditions happen and you get your aha moment. | ||
|
||
## post script ## | ||
|
||
These studies may or may not work on other synbols. With modifications to the parameters, maybe they work better for Gold than the Euro. Welcome to technical analysis and your journey down the rabbit hole. | ||
|
||
## feedback welcome ## | ||
|
||
Have a suggestion? Found an issue? Reach out to me on twitter, my DM is open to all. If you are a github user, file an issue or make a suggested change and PR to this repo. | ||
|
||
|
||
--- | ||
back to [README.md](/README.md) |
Oops, something went wrong.