-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathMarketMakerScan.pine
More file actions
173 lines (141 loc) · 7.71 KB
/
MarketMakerScan.pine
File metadata and controls
173 lines (141 loc) · 7.71 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
// @version=6
indicator("MarketMaker Scanner", overlay=true)
import TradingView/ta/10
// vim: syntax=pine
MQzones = input.text_area("", "MarketMaker values")
tP = input.string("Top Right", "Table Position", options=["Top Center","Bottom Center","Top Right", "Top Left", "Bottom Right", "Bottom Left"], group="Settings")
sFontSize = input.string(title="Font Size: ", options=["Tiny", "Small", "Normal", "Large"], defval="Small", group="Settings")
txtC = input.color(defval=color.new(color.white, 20),title = "Text Color", group="Settings")
greenC = input.color(defval=color.new(color.green, 50),title = "Green Color", group="Settings")
redC = input.color(defval=color.new(color.red, 50),title = "Red Color", group="Settings")
yellowC = input.color(defval=color.new(color.yellow, 50),title = "Yellow Color", group="Settings")
bool showMQRev = input.bool(true, "Show MarketMaker Reversals", group="Paid Lines")
bool showMQWick = input.bool(true, "Show MarketMaker Wicks", group="Paid Lines")
bool showOnlyBB = input.bool(false, "ONLY Show MarketMaker when at BB extreme)", group="Paid Lines")
bool showBB = input.bool(false, "Show Bollinger Band Touches", group="Show Options")
bool showCH = input.bool(true, "Show Change Percent", group="Show Options")
stLength = input.int(11, "RSI Length", minval=1, group="Indicator Settings")
rsiOB = input.int(80, "RSI Overbought Value", minval=1, group="Indicator Settings")
rsiOS = input.int(20, "RSI Oversold Value", minval=1, group="Indicator Settings")
bbLength = input.int(20, "Bollinger Length", minval=1, group="Indicator Settings")
bbMultiplier = input.float(2, "Bollinger Multiplier", minval=0.1, step=0.1, group="Indicator Settings")
BBtouchTolerance = input.float(0.05, "BB Touch Tolerance (%)", minval=0, step=0.01, group="Indicator Settings") / 100
log.info("update table called")
mapMQ = map.new<float, string>()
bg = color.new(color.black, 100)
tPos = tP == "Top Left" ? position.top_left : tP == "Bottom Right" ? position.bottom_right : tP == "Bottom Left" ? position.bottom_left : tP == "Top Center" ? position.top_center : tP == "Bottom Center" ? position.bottom_center : position.top_right
myFont = sFontSize == "Tiny" ? size.tiny : sFontSize == "Small" ? size.small : sFontSize == "Normal" ? size.normal : sFontSize == "Large" ? size.large : size.auto
log.info("update table called")
// Create Table
var table myTable = table.new(tPos, 17, 20, bgcolor = color.new(color.black, 100), frame_width = 1, frame_color = color.gray, border_width = 1, border_color = color.gray)
// Header
table.cell(myTable, 1, 1, "Ticker", text_color=txtC, bgcolor=bg, text_size=myFont)
table.cell(myTable, 2, 1, "Alerts", text_color=txtC, bgcolor=bg, text_size=myFont)
rowG = 2
findMQMap(float Close, float Open, float POpen, float PClose, float High, float Low, float PHigh, float PLow) =>
log.info("findMQMap with array size " + str.tostring(map.size(mapMQ)))
result = ""
bRed = Close < Open
bGreen = Open < Close
bPRed = PClose < POpen
bPGreen = POpen < PClose
if showMQRev and not showMQWick
keys = map.keys(mapMQ)
for i = 0 to array.size(keys) - 1
keyValue = array.get(keys, i) // 1D Min, key=5659.67
if (bGreen and bPRed and High > keyValue and Low < keyValue and PHigh > keyValue and PLow < keyValue)
result := map.get(mapMQ, keyValue)
break
else if (bPGreen and bRed and High > keyValue and Low < keyValue and PHigh > keyValue and PLow < keyValue)
result := map.get(mapMQ, keyValue)
break
if showMQWick
keys = map.keys(mapMQ)
for i = 0 to array.size(keys) - 1
keyValue = array.get(keys, i) // 1D Min, key=5659.67
if ((High > keyValue and Close < keyValue) or (High > keyValue and Open < keyValue))
result := map.get(mapMQ, keyValue)
break
result
loadUpMQMap(comma) =>
log.info("loadUpMQMap started " + str.tostring(comma))
map.clear(mapMQ)
//NQ: AH1, 20499.96 A Mid, 20136.75 AL1, 19762.99 BH1, 20616.21 BL1, 19648.89 CH1, 20681.25 CL1, 19583.79 DH1
//ES: AH1, 5768.10 A Mid, 5678.00 AL1, 5587.54 BH1, 5793.78 BL1, 5561.10 CH1, 5809.16 CL1, 5547.43 DH1, 5825.88
for i = 0 to array.size(comma) - 2 by 2
valueStr = str.trim(array.get(comma, i))
key = str.trim(array.get(comma, i+1))
valueNum = str.tonumber(key)
map.put(mapMQ, valueNum, valueStr)
log.info("loadUpMQMap finished with " + str.tostring(map.size(mapMQ)))
parseMQLines(string sTicker, float Close) =>
log.info("parseMQLines = '" + sTicker + "', close = " + str.tostring(Close))
string[] _pair = str.split(MQzones, "\n")
string result = ""
for s in _pair
sw = s
if str.contains(sw, ":")
string[] parts = str.split(sw, ":")
sTick = array.get(parts, 0) // $HG1!:
sw := array.get(parts, 1) // SD2, 5.0530, HV, 5.1130, VAH, 5.2195, VAL, 5.0060
if str.contains(sTick, sTicker)
sw := str.trim(sw)
string[] comma = str.split(sw, ", ") // vix r1, 5788, vix r2, 5793
loadUpMQMap(comma)
result
updateTable(sym, simpler) =>
log.info("update table called")
row = rowG
tf = timeframe.period
string[] xxx = str.split(sym, ":")
log.info("update table called")
[Open, Close, High, Low, POpen, PPOpen, PClose, PPClose,PHigh, PLow, PPLow, tickRSI] = request.security(sym, tf, [open, close, high, low, open[1], open[2], close[1], close[2], high[1], low[1], low[2], ta.rsi(close, 14)])
[middle, tickBBUpper, tickBBLower] = request.security(sym, tf, ta.bb(close, bbLength, bbMultiplier))
col = 1
sC = color.white
table.cell(myTable, col, row, sym, text_color=txtC, bgcolor=bg, text_size=myFont)
parseMQLines(simpler, Close)
string homies = findMQMap(Close, Open, POpen, PClose, High, Low, PHigh, PLow)
log.info("parseMQLines homies = '" + homies + "'")
if (homies != '')
homies := "Bounced off " + homies
sC := Close > Open ? greenC : Close < Open ? redC : color.black
else
sC := color.black
col := col + 1
table.cell(myTable, col, row, homies, text_color=txtC, bgcolor=sC, text_size=myFont)
if (showCH)
tickDayOpen = request.security(sym, "1D", open)
col := col + 1
percentChange = ta.changePercent(Close, tickDayOpen)
sC := percentChange > 0 ? greenC : redC
table.cell(myTable, col, row, "CH: " + str.tostring(percentChange, "#.##"), text_color=txtC, bgcolor=sC, text_size=myFont)
if (true)
col := col + 1
sC := tickRSI > rsiOB ? greenC : tickRSI < rsiOS ? redC : color.black
colTTT = tickRSI > rsiOB ? txtC : tickRSI < rsiOS ? txtC : color.new(color.gray, 10)
table.cell(myTable, col, row, "RSI", text_color=colTTT, bgcolor=sC, text_size=myFont)
if (showBB)
col := col + 1
tickTouchingUpperBB = High > tickBBUpper //* BBtouchTolerance
tickTouchingLowerBB = Low < tickBBLower //* BBtouchTolerance
tickTouchingBB = tickTouchingUpperBB or tickTouchingLowerBB
sC := tickTouchingUpperBB ? greenC : tickTouchingLowerBB ? redC : bg
colTTT = tickTouchingBB ? txtC : color.new(color.gray, 10)
table.cell(myTable, col, row, "BB Touch", text_color=colTTT, bgcolor=sC, text_size=myFont)
if barstate.islast
log.info("update table called")
string sw = ""
string commas = ""
rowG := 2
updateTable("TVC:VIX", "VIX")
rowG := rowG + 1
updateTable("CME_MINI:ES1!", "ES")
rowG := rowG + 1
updateTable("CME_MINI:NQ1!", "NQ")
rowG := rowG + 1
updateTable("CME_MINI:RTY1!", "RTY")
rowG := rowG + 1
updateTable("COMEX:GC1!", "GC")
rowG := rowG + 1
updateTable("NYMEX:CL1!", "CL")