<div class="bbWrapper">I republished this. Hopefully you can find it at <a href="https://www.tradingview.com/script/wnRg4LVI-Target-Lines/" target="_blank" class="link link--external" rel="noopener">https://www.tradingview.com/script/wnRg4LVI-Target-Lines/</a><br />
<br />
<hr /><br />
This script let's you monitor four prices:<br />
<br />
1. The expected move range. This is typically the at-the-money straddle price. There is roughly a 68% probability that prices will stay inside the expected move.<br />
2. The Magic 8-Ball price. This is from Bryan Cairns's Magic 8-Ball, which is an AI predication of where the market will close today. More information at <a href="https://launchpass.com/magic-8-ball/members" target="_blank" class="link link--external" rel="noopener">https://launchpass.com/magic-8-ball/memb...</a><br />
3. Two short strikes. Option traders will typically have one short strike for a credit spread or two for a <a href="https://www.tradingview.com/scripts/butterflypattern/" target="_blank" class="link link--external" rel="noopener">butterfly</a> or iron condor.<br />
<br />
The EM Ratio is the distance of the monitored short strike divided by the expected move. If this ratio is less greater than 2.0, the likelihood of prices getting to the short strike are very low (<5% typically)<br />
<br />
Here is a sample of what a chart might look like:<br />
<br />
<a href="https://s3.us-east-2.amazonaws.com/f1.aeromir.com/2/2023/01/2023-01-22_15-13-38.jpg" target="_blank" class="link link--external" rel="noopener">https://s3.us-east-2.amazonaws.com/f1.aeromir.com/2/2023/01/2023-01-22_15-13-38.jpg</a><br />
<br />
IMPORTANT: All data is manually entered. I update the expected move and Magic 8-Ball Prices every 5-minutes during the trading day on my chart.<br />
<br />
There are fields to adjust how far above or below the lines the text will appear. This is sometimes necessary if you change time frames.<br />
<br />
<div class="bbCodeBlock bbCodeBlock--screenLimited bbCodeBlock--code">
<div class="bbCodeBlock-title">
Code:
</div>
<div class="bbCodeBlock-content" dir="ltr">
<pre class="bbCodeCode" dir="ltr" data-xf-init="code-block" data-lang=""><code>// Target Lines
// By Tom Nunamaker [email protected]
// https://aeromir.com/
//@version=5
indicator("Target Lines", overlay=true)
_lastTradedPrice = close[0]
expectedmove = input.float(32.0, "Expected Move", inline = "01")
showExpectedMove = input.bool(true, "Visible", inline = "01")
color cEMline = input.color(color.purple, "Lines", inline = "01")
color cEMText = input.color(color.rgb(236, 131, 255), "Text", inline = "01")
magic8ball = input.price(title="Magic 8-Ball", defval=4060, inline = "02")
showMagic8ball = input.bool(true, "Visible", inline = "02")
color cM8Bline = input.color(color.rgb(255, 152, 0), "Line", inline = "02")
color cM8BText = input.color(color.rgb(255, 152, 0), "Text", inline = "02")
shortstrike1 = input.price(title="Short Strike 1", defval=4080.00, inline = "03")
showShortStrike1 = input.bool(true, "Visible", inline = "03")
color cSSline = input.color(color.red, "Lines", inline = "03")
color cSSText = input.color(color.red, "Text ", inline = "03")
shortstrike2 = input.price(title="Short Strike 2", defval=4050.00, inline = "04")
showShortStrike2 = input.bool(true, "Visible", inline = "04")
baroffset = input.int(3, "Bar Offset", inline = "05")
show200MA = input.bool(false, "Show 200 SMA ", inline = "06")
show50MA = input.bool(false, "Show 50 SMA", inline = "06")
abEMUpper = input.float(.25,"Distance EM #1 text above line")
abEMLower = input.float(-2,"Distance EM #2 text below line")
abSSUpper = input.float(.25,"Distance SS #1 text above line")
abSSLower = input.float(-2.25,"Distance SS #2 text below line")
abM8BUpper = input.float(.25,"Distance Magic 8-Ball text above line")
emupper = close[0] + expectedmove
emlower = close[0] - expectedmove
labelupper = label.new(na,na)
labellower = label.new(na,na)
labelshortstrike1 = label.new(na,na)
labelshortstrike2 = label.new(na,na)
labelmagic8ball = label.new(na,na)
labelSMA200 = label.new(na,na)
sma200 = ta.sma(close, 200)
plot1 = request.security(syminfo.tickerid, 'D', sma200)
plot(show200MA ? plot1 : na,title="200-Day SMA",linewidth=2,color=color.lime)
sma50 = ta.sma(close, 50)
plot2 = request.security(syminfo.tickerid, 'D', sma50)
plot(show50MA ? plot2 : na,title="5-Day SMA",linewidth=2,color=color.orange)
// Expected Move lines
if barstate.islast and showExpectedMove
labelupper := label.new(x=bar_index + baroffset, y=close, color=color.black, textcolor=cEMText, style=label.style_none)
label.delete(labelupper[1])
label.set_text(id=labelupper, text="EM: +" + str.tostring(expectedmove, "0.00") + " " + str.tostring(close + expectedmove, "0.00"))
label.set_size(id=labelupper, size=size.normal)
label.set_y(labelupper, emupper + abEMUpper)
labelx = label.get_x(labelupper) + baroffset
label.set_x(labelupper,labelx)
if barstate.islast and showExpectedMove
labellower := label.new(x=bar_index + baroffset, y=close, color=color.black, textcolor=cEMText, style=label.style_none)
label.delete(labellower[1])
label.set_text(id=labellower, text="EM: -" + str.tostring(expectedmove, '0.00') + " " + str.tostring(close - expectedmove, '0.00'))
label.set_size(id=labellower, size=size.normal)
label.set_y(labellower, emlower + abEMLower)
labelx = label.get_x(labellower) + baroffset
label.set_x(labellower,labelx)
if showExpectedMove
var line line11 = line.new(0, 0, 0, 0, extend=extend.right, style=line.style_solid, color=cEMline, width=3)
var line line12 = line.new(0, 0, 0, 0, extend=extend.right, style=line.style_solid, color=cEMline, width=3)
line.set_xy1(line11, bar_index-1, _lastTradedPrice + expectedmove)
line.set_xy2(line11, bar_index, _lastTradedPrice + expectedmove)
line.set_xy1(line12, bar_index-1, _lastTradedPrice - expectedmove)
line.set_xy2(line12, bar_index, _lastTradedPrice - expectedmove)
// Short Strike 1
SS1ToMark = shortstrike1 - close[1]
EMRatio1 = SS1ToMark/expectedmove
if showShortStrike1
var line line13 = line.new(0, 0, 0, 0, extend=extend.right, style=line.style_solid, color=cSSline, width=3)
line.set_xy1(line13, bar_index-1, shortstrike1)
line.set_xy2(line13, bar_index, shortstrike1)
if barstate.islast and showShortStrike1
labelshortstrike1 := label.new(x=bar_index + baroffset, y=shortstrike1, color=color.black, textcolor=cSSText, style=label.style_none)
label.delete(labelshortstrike1[1])
label.set_text(id=labelshortstrike1, text="Short: " + str.tostring(shortstrike1, '#') + " Dist: " + str.tostring(SS1ToMark, '0.00') + " EM Ratio: " + str.tostring(EMRatio1, '0.00') )
label.set_y(labelshortstrike1, shortstrike1 + abSSUpper)
labelx = label.get_x(labelshortstrike1) + 3 +baroffset
label.set_x(labelshortstrike1,labelx)
// Short Strike #2
SS2ToMark = close[1] - shortstrike2
EMRatio2 = SS2ToMark/expectedmove
if showShortStrike2
var line line14 = line.new(0, 0, 0, 0, extend=extend.right, style=line.style_solid, color=cSSline, width=3)
line.set_xy1(line14, bar_index-1, shortstrike2)
line.set_xy2(line14, bar_index, shortstrike2)
if barstate.islast and showShortStrike2
labelshortstrike2 := label.new(x=bar_index + baroffset, y=shortstrike2, color=color.black, textcolor=cSSText, style=label.style_none)
label.delete(labelshortstrike2[1])
label.set_text(id=labelshortstrike2, text="Short: " + str.tostring(shortstrike2, '#') + " Dist: " + str.tostring(SS2ToMark, '0.00') + " EM Ratio: " + str.tostring(EMRatio2, '0.00') )
label.set_y(labelshortstrike2, shortstrike2 + abSSLower)
labelx = label.get_x(labelshortstrike2) + 3 + baroffset
label.set_x(labelshortstrike2,labelx)
// Magic 8-Ball
M8BDist = magic8ball - close[1]
M8BEMration = M8BDist/expectedmove
if showMagic8ball
var line linemagic8ball = line.new(0, 0, 0, 0, extend=extend.right, style=line.style_solid, color=cM8Bline, width=3)
line.set_xy1(linemagic8ball, bar_index-1, magic8ball)
line.set_xy2(linemagic8ball, bar_index, magic8ball)
if barstate.islast and showMagic8ball
labelmagic8ball := label.new(x=bar_index + baroffset, y=magic8ball, color=color.black, textcolor=cM8BText, style=label.style_none)
label.delete(labelmagic8ball[1])
label.set_text(id=labelmagic8ball, text="8-Ball: " + str.tostring(magic8ball, '0.00') + " Dist: " + str.tostring(M8BDist, '0.00') + " EM Ratio: " + str.tostring(M8BEMration, '0.00') )
label.set_y(labelmagic8ball, magic8ball + abM8BUpper)
labelx = label.get_x(labelmagic8ball) + 3 + baroffset
label.set_x(labelmagic8ball,labelx)</code></pre>
</div>
</div></div>
Last edited: