forked from hwrdprkns/ThinkOrSwim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInSync.txt
More file actions
64 lines (54 loc) · 2.99 KB
/
InSync.txt
File metadata and controls
64 lines (54 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# InSync
# Drew Griffith
#hint: Mean Reversion ENTRY Strategy. The default inputs are based on stocks that are more volatile in nature. If you prefer to trade less volatile stocks, you should lower the extremities input. This strategy looks for long term trending stocks above EMA300, SMA200; Also, there are additional filters in place to ensure a better entry signal. The strategy is based on closing prices of the day of signal, so buy as close to the EOD as possible. The target is the high price of the day of entry. Ideal hold times are less than 5 days. On day 5, the position moves to breakeven. Optimized for use on daily charts.
declare lower;
input audibleAlerts = NO;
input paintbars = YES;
input extremities = 2.0; #0.5-1.5 intraday
input oversold = 0;
input overbought = 500;
input bbp_length = 20;
input mfi_length = 14;
def rsi2_length = 2;
def rsi14_length = 14;
input bmp_length = 14;
input atr_outer = 2.0;
input atr_length = 10;
def averageType = AverageType.EXPONENTIAL;
def trueRangeAverageType = AverageType.EXPONENTIAL;
def price = close;
# study definitions
def rsi2 = RSI(length = rsi2_length);
def rsi14 = RSI(length = rsi14_length);
def mfi = MoneyFlowIndex(length = mfi_length);
def bom = BalanceOfMarketPower(length = bmp_length) * 100;
def bbp = BollingerPercentB(length = bbp_length, "average type" = "EXPONENTIAL");
# ATR Bands
def OuterValueshift = atr_outer * MovingAverage(trueRangeAverageType, TrueRange(high, close, low), atr_length);
def average = MovingAverage(averageType, price, atr_length);
def UpperOuterBand = average + OuterValueshift;
def LowerOuterBand = average - OuterValueshift;
def apa = (price - LowerOuterBand) / (UpperOuterBand - LowerOuterBand) * 100;
# plots
plot insync = Round(bbp + rsi2 + rsi14 + mfi + bom + apa, numberofdigits = -1);
plot pos = overbought;
plot neg = oversold;
insync.AssignValueColor(if insync >= overbought then Color.RED else if insync <= oversold then Color.GREEN else Color.GRAY);
insync.SetLineWeight(3);
pos.AssignValueColor(Color.GREEN);
neg.AssignValueColor(Color.RED);
pos.HideTitle();
neg.HideTitle();
# Large move down / up
def ext = if close < open and ((high / close - 1) * 100) >= extremities then 1
else if close > open and ((close / low - 1) * 100) >= extremities then 1 else Double.NaN;
plot signal = if apa < 0 and rsi2 < 10 and mfi < 35 and bbp < 5 and ext then insync else if apa > 100 and rsi2 > 95 and mfi > 80 and bbp > 100 and ext then insync else Double.NaN;
#signal.hide();
signal.SetPaintingStrategy(paintingstrategy = PaintingStrategy.POINTS);
signal.SetLineWeight(5);
signal.AssignValueColor(Color.YELLOW);
AssignPriceColor(if paintbars and signal and ext then Color.YELLOW else if paintbars and signal and ext then Color.YELLOW else Color.CURRENT);
Alert(audibleAlerts and signal, GetSymbol() + " at exhaustion.", Alert.BAR, Sound.Ding);
## Needed for Watchlist box painting
#insync.AssignValueColor(Color.BLACK);
#AssignBackgroundColor(if insync >= overbought then Color.RED else if insync <= oversold then Color.GREEN else Color.GRAY);