0% found this document useful (0 votes)
28 views21 pages

Kapoor - MSM Jackpot Setup

The document is a Pine Script code for a trading indicator titled 'Kapoor - MSM Jackpot setup' designed for various indices like NIFTY and BANKNIFTY. It calculates the At-The-Money (ATM) strike prices, options symbols, and pivot points using different methodologies including Camarilla. The script allows user inputs for strike price, expiry date, and pivot settings, and dynamically adjusts based on the selected index and timeframe.

Uploaded by

limoko7589
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views21 pages

Kapoor - MSM Jackpot Setup

The document is a Pine Script code for a trading indicator titled 'Kapoor - MSM Jackpot setup' designed for various indices like NIFTY and BANKNIFTY. It calculates the At-The-Money (ATM) strike prices, options symbols, and pivot points using different methodologies including Camarilla. The script allows user inputs for strike price, expiry date, and pivot settings, and dynamically adjusts based on the selected index and timeframe.

Uploaded by

limoko7589
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 21

//@version=6

indicator(title="Kapoor - MSM Jackpot setup", shorttitle="MSM Index Trade Setup",


overlay=true, dynamic_requests = true, max_labels_count = 500, max_lines_count =
500)

userInputStrike = input.int(23700, "Strike Price")


expiryDay = input.string("16", "Expiry Day")
expiryMonth = input.string("01", "Expiry Month")
expiryYear = input.string("25", "Expiry Year")

//
===================================================================================
===================================================================
// ATM
//
===================================================================================
===================================================================
strikeDiff = 50
// index = "NIFTY"
prefix = "NIFTY"
if syminfo.ticker == "NIFTY"
strikeDiff := 50
prefix := "NIFTY"
if syminfo.ticker == "BANKNIFTY"
prefix := "BANKNIFTY"
strikeDiff := 100
if syminfo.ticker == "CNXFINANCE"
prefix := "FINNIFTY"
strikeDiff := 50
if syminfo.ticker == "MIDCPNIFTY"
prefix := "MIDCPNIFTY"
strikeDiff := 25

atmBasis = request.security(syminfo.tickerid, timeframe.period, close)


lowerStrike = math.floor(atmBasis/strikeDiff)* strikeDiff
upperStrike = math.ceil(atmBasis/strikeDiff)* strikeDiff
ATM = (math.abs(atmBasis - lowerStrike) < math.abs(atmBasis - upperStrike)) ?
lowerStrike:upperStrike

string putSymbol = na
string callSymbol = na
float callPrice = na
float putPrice = na

if syminfo.ticker == "NIFTY"
strikeDiff := 50
prefix := "NIFTY"

if syminfo.ticker == "BANKNIFTY"
prefix := "BANKNIFTY"
strikeDiff := 100

if syminfo.ticker == "CNXFINANCE"
prefix := "FINNIFTY"
strikeDiff := 50

if syminfo.ticker == "MIDCPNIFTY"
prefix := "MIDCPNIFTY"
strikeDiff := 25

putSymbol := prefix +expiryYear + expiryMonth+expiryDay+ "P" +


str.tostring(userInputStrike)
callSymbol := prefix +expiryYear + expiryMonth+expiryDay+ "C" +
str.tostring(userInputStrike)

callPrice := request.security(callSymbol, "", close)


putPrice := request.security(putSymbol, "", close)

AUTO = "Auto"
DAILY = "Daily"
WEEKLY = "Weekly"
MONTHLY = "Monthly"
QUARTERLY = "Quarterly"
YEARLY = "Yearly"
BIYEARLY = "Biyearly"
TRIYEARLY = "Triyearly"
QUINQUENNIALLY = "Quinquennially"
DECENNIALLY = "Decennially"

TRADITIONAL = "Traditional"
FIBONACCI = "Fibonacci"
WOODIE = "Woodie"
CLASSIC = "Classic"
DM = "DM"
CAMARILLA = "Camarilla"

kind = input.string(title="Type", defval="Camarilla", options=[ CAMARILLA])


pivot_time_frame = input.string(title="Pivots Timeframe", defval=AUTO,
options=[AUTO, DAILY, WEEKLY, MONTHLY, QUARTERLY, YEARLY, BIYEARLY, TRIYEARLY,
QUINQUENNIALLY, DECENNIALLY])
look_back = input.int(title="Number of Pivots Back", defval=15, minval=1,
maxval=5000)
is_daily_based = input.bool(title="Use Daily-based Values", defval=true,
tooltip="When this option is unchecked, Pivot Points will use intraday data while
calculating on intraday charts. If Extended Hours are displayed on the chart, they
will be taken into account during the pivot level calculation. If intraday OHLC
values are different from daily-based values (normal for stocks), the pivot levels
will also differ.")
show_labels_x = input.bool(title="Show Labels", defval=true, group="labels")
show_prices = input.bool(title="Show Prices", defval=true, group="labels")
position_labels = input.string("Left", "Labels Position", options=["Left",
"Right"], group="labels")
line_width = input.int(title="Line Width", defval=1, minval=1, maxval=100,
group="levels")

var DEF_COLOR = #FB8C00


var arr_time = array.new_int()
var p = array.new_float()
p_color = input.color(DEF_COLOR, "P ", inline="P", group="levels")
p_show = input.bool(true, "", inline="P", group="levels")
var r1 = array.new_float()
var s1 = array.new_float()
s1_color = input.color(DEF_COLOR, "S1", inline="S1/R1" , group="levels")
s1_show = input.bool(true, "", inline="S1/R1", group="levels")
r1_color = input.color(DEF_COLOR, " R1", inline="S1/R1",
group="levels")
r1_show = input.bool(true, "", inline="S1/R1", group="levels")
var r2 = array.new_float()
var s2 = array.new_float()
s2_color = input.color(DEF_COLOR, "S2", inline="S2/R2", group="levels")
s2_show = input.bool(true, "", inline="S2/R2", group="levels")
r2_color = input.color(DEF_COLOR, " R2", inline="S2/R2",
group="levels")
r2_show = input.bool(true, "", inline="S2/R2", group="levels")
var r3 = array.new_float()
var s3 = array.new_float()
s3_color = input.color(DEF_COLOR, "S3", inline="S3/R3", group="levels")
s3_show = input.bool(true, "", inline="S3/R3", group="levels")
r3_color = input.color(DEF_COLOR, " R3", inline="S3/R3",
group="levels")
r3_show = input.bool(true, "", inline="S3/R3", group="levels")
var r4 = array.new_float()
var s4 = array.new_float()
s4_color = input.color(DEF_COLOR, "S4", inline="S4/R4", group="levels")
s4_show = input.bool(true, "", inline="S4/R4", group="levels")
r4_color = input.color(DEF_COLOR, " R4", inline="S4/R4",
group="levels")
r4_show = input.bool(true, "", inline="S4/R4", group="levels")
var r5 = array.new_float()
var s5 = array.new_float()
s5_color = input.color(DEF_COLOR, "S5", inline="S5/R5", group="levels")
s5_show = input.bool(true, "", inline="S5/R5", group="levels")
r5_color = input.color(DEF_COLOR, " R5", inline="S5/R5",
group="levels")
r5_show = input.bool(true, "", inline="S5/R5", group="levels")
pivotX_open = float(na)
pivotX_open := nz(pivotX_open[1], open)
pivotX_high = float(na)
pivotX_high := nz(pivotX_high[1], high)
pivotX_low = float(na)
pivotX_low := nz(pivotX_low[1], low)
pivotX_prev_open = float(na)
pivotX_prev_open := nz(pivotX_prev_open[1])
pivotX_prev_high = float(na)
pivotX_prev_high := nz(pivotX_prev_high[1])
pivotX_prev_low = float(na)
pivotX_prev_low := nz(pivotX_prev_low[1])
pivotX_prev_close = float(na)
pivotX_prev_close := nz(pivotX_prev_close[1])

get_pivot_resolution() =>
resolution = "M"
if pivot_time_frame == AUTO
if timeframe.isintraday
resolution := timeframe.multiplier <= 15 ? "D" : "W"
else if timeframe.isweekly or timeframe.ismonthly
resolution := "12M"
else if pivot_time_frame == DAILY
resolution := "D"
else if pivot_time_frame == WEEKLY
resolution := "W"
else if pivot_time_frame == MONTHLY
resolution := "M"
else if pivot_time_frame == QUARTERLY
resolution := "3M"
else if pivot_time_frame == YEARLY or pivot_time_frame == BIYEARLY or
pivot_time_frame == TRIYEARLY or pivot_time_frame == QUINQUENNIALLY or
pivot_time_frame == DECENNIALLY
resolution := "12M"
resolution

var lines = array.new_line()


var labels = array.new_label()

draw_line(i, pivot, col) =>


if array.size(arr_time) > 1
array.push(lines, line.new(array.get(arr_time, i), array.get(pivot, i),
array.get(arr_time, i + 1), array.get(pivot, i), color=col, xloc=xloc.bar_time,
width=line_width))

draw_label(i, y, txt, txt_color) =>


if (show_labels_x or show_prices) and not na(y)
display_text = (show_labels_x ? txt : "") + (show_prices ? str.format("
({0})", math.round_to_mintick(y)) : "")
label_style = position_labels == "Left" ? label.style_label_right :
label.style_label_left
x = position_labels == "Left" ? array.get(arr_time, i) :
array.get(arr_time, i + 1)
array.push(labels, label.new(x = x, y=y, text=display_text,
textcolor=txt_color, style=label_style, color=#00000000, xloc=xloc.bar_time))

camarilla() =>
pivotX_Median = (pivotX_prev_high + pivotX_prev_low + pivotX_prev_close) / 3
pivot_range = pivotX_prev_high - pivotX_prev_low
array.push(p, pivotX_Median)
array.push(r1, pivotX_prev_close + pivot_range * 1.1 / 12.0)
array.push(s1, pivotX_prev_close - pivot_range * 1.1 / 12.0)
array.push(r2, pivotX_prev_close + pivot_range * 1.1 / 6.0)
array.push(s2, pivotX_prev_close - pivot_range * 1.1 / 6.0)
array.push(r3, pivotX_prev_close + pivot_range * 1.1 / 4.0)
array.push(s3, pivotX_prev_close - pivot_range * 1.1 / 4.0)
array.push(r4, pivotX_prev_close + pivot_range * 1.1 / 2.0)
array.push(s4, pivotX_prev_close - pivot_range * 1.1 / 2.0)
r5_val = pivotX_prev_high / pivotX_prev_low * pivotX_prev_close
array.push(r5, r5_val)
array.push(s5, 2 * pivotX_prev_close - r5_val)

calc_pivot() =>
if kind == CAMARILLA
camarilla()

resolution = get_pivot_resolution()
SIMPLE_DIVISOR = -1
custom_years_divisor = switch pivot_time_frame
BIYEARLY => 2
TRIYEARLY => 3
QUINQUENNIALLY => 5
DECENNIALLY => 10
=> SIMPLE_DIVISOR

calc_high(prev, curr) =>


if na(prev) or na(curr)
nz(prev, nz(curr, na))
else
math.max(prev, curr)

calc_low(prev, curr) =>


if not na(prev) and not na(curr)
math.min(prev, curr)
else
nz(prev, nz(curr, na))

calc_OHLC_for_pivot(custom_years_divisor) =>
if custom_years_divisor == SIMPLE_DIVISOR
[open, high, low, close, open[1], high[1], low[1], close[1], time[1],
time_close]
else
var prev_sec_open = float(na)
var prev_sec_high = float(na)
var prev_sec_low = float(na)
var prev_sec_close = float(na)
var prev_sec_time = int(na)
var curr_sec_open = float(na)
var curr_sec_high = float(na)
var curr_sec_low = float(na)
var curr_sec_close = float(na)
if year(time_close) % custom_years_divisor == 0
curr_sec_open := open
curr_sec_high := high
curr_sec_low := low
curr_sec_close := close
prev_sec_high := high[1]
prev_sec_low := low[1]
prev_sec_close := close[1]
prev_sec_time := time[1]
for i = 2 to custom_years_divisor
prev_sec_open := nz(open[i], prev_sec_open)
prev_sec_high := calc_high(prev_sec_high, high[i])
prev_sec_low := calc_low(prev_sec_low, low[i])
prev_sec_time := nz(time[i], prev_sec_time)
[curr_sec_open, curr_sec_high, curr_sec_low, curr_sec_close, prev_sec_open,
prev_sec_high, prev_sec_low, prev_sec_close, prev_sec_time, time_close]

[sec_open, sec_high, sec_low, sec_close, prev_sec_open, prev_sec_high,


prev_sec_low, prev_sec_close, prev_sec_time, sec_time] =
request.security(syminfo.tickerid, resolution,
calc_OHLC_for_pivot(custom_years_divisor), lookahead = barmerge.lookahead_on)
sec_open_gaps_on = request.security(syminfo.tickerid, resolution, open, gaps =
barmerge.gaps_on, lookahead = barmerge.lookahead_on)

is_change_years = custom_years_divisor > 0 and ta.change(time(resolution)) != 0 and


year(time_close) % custom_years_divisor == 0

var is_change = false


var uses_current_bar = timeframe.isintraday and kind == WOODIE
var change_time = int(na)
is_time_change = (ta.change(time(resolution) != 0) and custom_years_divisor ==
SIMPLE_DIVISOR) or is_change_years
if is_time_change
change_time := time

var start_time = time


var was_last_premarket = false
var start_calculate_in_premarket = false

is_last_premarket = barstate.islast and session.ispremarket and time_close >


sec_time and not was_last_premarket

if is_last_premarket
was_last_premarket := true
start_calculate_in_premarket := true
if session.ismarket
was_last_premarket := false

without_time_change = barstate.islast and array.size(arr_time) == 0


is_can_calc_pivot = (not uses_current_bar and is_time_change and session.ismarket)
or (ta.change(sec_open) != 0 and not start_calculate_in_premarket) or
is_last_premarket or (uses_current_bar and not na(sec_open_gaps_on)) or
without_time_change
enough_bars_for_calculate = prev_sec_time >= start_time or is_daily_based

if is_can_calc_pivot and enough_bars_for_calculate


if array.size(arr_time) == 0 and is_daily_based
pivotX_prev_open := prev_sec_open[1]
pivotX_prev_high := prev_sec_high[1]
pivotX_prev_low := prev_sec_low[1]
pivotX_prev_close := prev_sec_close[1]
pivotX_open := sec_open[1]
pivotX_high := sec_high[1]
pivotX_low := sec_low[1]
array.push(arr_time, start_time)
calc_pivot()

if is_daily_based
if is_last_premarket
pivotX_prev_open := sec_open
pivotX_prev_high := sec_high
pivotX_prev_low := sec_low
pivotX_prev_close := sec_close
pivotX_open := open
pivotX_high := high
pivotX_low := low
else
pivotX_prev_open := prev_sec_open
pivotX_prev_high := prev_sec_high
pivotX_prev_low := prev_sec_low
pivotX_prev_close := prev_sec_close
pivotX_open := sec_open
pivotX_high := sec_high
pivotX_low := sec_low
else
pivotX_prev_high := pivotX_high
pivotX_prev_low := pivotX_low
pivotX_prev_open := pivotX_open
pivotX_prev_close := close[1]
pivotX_open := open
pivotX_high := high
pivotX_low := low

if barstate.islast and not is_change and array.size(arr_time) > 0 and not


without_time_change
array.set(arr_time, array.size(arr_time) - 1, change_time)
else if without_time_change
array.push(arr_time, start_time)
else
array.push(arr_time, nz(change_time, time))

calc_pivot()

if array.size(arr_time) > look_back


if array.size(arr_time) > 0
array.shift(arr_time)
if array.size(p) > 0 and p_show
array.shift(p)
if array.size(r1) > 0 and r1_show
array.shift(r1)
if array.size(s1) > 0 and s1_show
array.shift(s1)
if array.size(r2) > 0 and r2_show
array.shift(r2)
if array.size(s2) > 0 and s2_show
array.shift(s2)
if array.size(r3) > 0 and r3_show
array.shift(r3)
if array.size(s3) > 0 and s3_show
array.shift(s3)
if array.size(r4) > 0 and r4_show
array.shift(r4)
if array.size(s4) > 0 and s4_show
array.shift(s4)
if array.size(r5) > 0 and r5_show
array.shift(r5)
if array.size(s5) > 0 and s5_show
array.shift(s5)
is_change := true
else if not is_daily_based
pivotX_high := math.max(pivotX_high, high)
pivotX_low := math.min(pivotX_low, low)

if barstate.islast and not is_daily_based and array.size(arr_time) == 0


runtime.error("Not enough intraday data to calculate Pivot Points. Lower the
Pivots Timeframe or turn on the 'Use Daily-based Values' option in the indicator
settings.")

if barstate.islast and array.size(arr_time) > 0 and is_change


is_change := false
if custom_years_divisor > 0
last_pivot_time = array.get(arr_time, array.size(arr_time) - 1)
pivot_timeframe = str.tostring(12 * custom_years_divisor) + "M"
estimate_pivot_time = last_pivot_time +
timeframe.in_seconds(pivot_timeframe) * 1000
array.push(arr_time, estimate_pivot_time)
else
array.push(arr_time, time_close(resolution))

for i = 0 to array.size(lines) - 1
if array.size(lines) > 0
line.delete(array.shift(lines))
if array.size(labels) > 0
label.delete(array.shift(labels))

for i = 0 to array.size(arr_time) - 2
if array.size(p) > 0 and p_show
draw_line(i, p, p_color)
draw_label(i, array.get(p, i), "P", p_color)
if array.size(r1) > 0 and r1_show
draw_line(i, r1, r1_color)
draw_label(i, array.get(r1, i), "Resistance1", r1_color)
if array.size(s1) > 0 and s1_show
draw_line(i, s1, s1_color)
draw_label(i, array.get(s1, i), "S1", s1_color)
if array.size(r2) > 0 and r2_show
draw_line(i, r2, r2_color)
draw_label(i, array.get(r2, i), "R2", r2_color)
if array.size(s2) > 0 and s2_show
draw_line(i, s2, s2_color)
draw_label(i, array.get(s2, i), "S2", s2_color)
if array.size(r3) > 0 and r3_show
draw_line(i, r3, r3_color)
draw_label(i, array.get(r3, i), "Resistance 1", r3_color)
if array.size(s3) > 0 and s3_show
draw_line(i, s3, s3_color)
draw_label(i, array.get(s3, i), "Support 1", s3_color)
if array.size(r4) > 0 and r4_show
draw_line(i, r4, r4_color)
draw_label(i, array.get(r4, i), "R4", r4_color)
if array.size(s4) > 0 and s4_show
draw_line(i, s4, s4_color)
draw_label(i, array.get(s4, i), "S4", s4_color)
if array.size(r5) > 0 and r5_show
draw_line(i, r5, r5_color)
draw_label(i, array.get(r5, i), "Resistance 2", r5_color)
if array.size(s5) > 0 and s5_show
draw_line(i, s5, s5_color)
draw_label(i, array.get(s5, i),"Support 2",s5_color)
///////////////////////////////////////////////////////////////// Menu

gpQ = "Quick Menu"

i_show_zones = input.bool(true, title="MSM Zones", group=gpQ, inline="Q1")


i_show_mtf = input.bool(true, title="MSM Multi Timeframe", group=gpQ, inline="Q1")

gpADR = "MSM Zones"

i_timeframe = input.string(defval="D", title="Timeframe", options=["1", "3", "5",


"15", "30", "45", "60", "120", "180", "240", "D", "3D", "W", "2W", "M", "3M", "6M",
"12M"], group=gpADR, inline="Z1")
show_open = input.bool(false, title="Open", group=gpADR, inline="Z1")

show_len_1 = input.bool(true, title="", group=gpADR, inline="Z2")


i_length_1 = input.int(14, title="", minval=1, group=gpADR, inline="Z2")
show_len_2 = input.bool(true, title="", group=gpADR, inline="Z2")
i_length_2 = input.int(7, title="", minval=1, group=gpADR, inline="Z2")
show_len_3 = input.bool(true, title="", group=gpADR, inline="Z2")
i_length_3 = input.int(5, title="", minval=1, group=gpADR, inline="Z2")

i_adr_mult = input.float(1, title="MSM Multiplier", minval=0, step=0.1,


group=gpADR, inline="Z3")
show_target = input.bool(false, title="Target Multiplier", group=gpADR,
inline="Z3")
i_target_mult = input.float(2, title="", minval=1, step=1, group=gpADR,
inline="Z3")

i_s_col = input.color(color.new(#043dfa, 0), title="Support", group=gpADR,


inline="Z4")
i_r_col = input.color(color.new(#EF5350, 0), title="Resistance", group=gpADR,
inline="Z4")
show_labels = input.bool(true, title="Labels", group=gpADR, inline="Z4")
showlast = input.bool(false, title="Hide Historical", group=gpADR, inline="Z4")
islast = showlast ? request.security(syminfo.tickerid, i_timeframe,
barstate.islast, lookahead=barmerge.lookahead_on) : true

///////////////////////////////////////////////////////////////// OHLC

pd_open = request.security(syminfo.tickerid, i_timeframe, open[1],


barmerge.gaps_off, barmerge.lookahead_on)
day_open = request.security(syminfo.tickerid, i_timeframe, open, barmerge.gaps_off,
barmerge.lookahead_on)

///////////////////////////////////////////////////////////////// ADR
adr_func(length, high_low) =>
float result = 0
float adr = 0

high_sma = request.security(syminfo.tickerid, i_timeframe, ta.sma(high[1],


length), barmerge.gaps_off, barmerge.lookahead_on)
low_sma = request.security(syminfo.tickerid, i_timeframe, ta.sma(low[1],
length), barmerge.gaps_off, barmerge.lookahead_on)

adr := high_sma - low_sma

if high_low
result := day_open + adr/2 * i_adr_mult //High
else
result := day_open - adr/2 * i_adr_mult //Low

r_1_adr_1 = adr_func(i_length_1, true)


r_1_adr_2 = adr_func(i_length_2, true)
r_1_adr_3 = adr_func(i_length_3, true)

s_1_adr_1 = adr_func(i_length_1, false)


s_1_adr_2 = adr_func(i_length_2, false)
s_1_adr_3 = adr_func(i_length_3, false)

r_adr_avg = math.avg(r_1_adr_1, r_1_adr_2, r_1_adr_3)


s_adr_avg = math.avg(s_1_adr_1, s_1_adr_2, s_1_adr_3)

///////////////////////////////////////////////////////////////// ADR Target

adr_func_2(length, high_low) =>


float result = 0
float adr = 0

high_sma = request.security(syminfo.tickerid, i_timeframe, ta.sma(high[1],


length), barmerge.gaps_off, barmerge.lookahead_on)
low_sma = request.security(syminfo.tickerid, i_timeframe, ta.sma(low[1],
length), barmerge.gaps_off, barmerge.lookahead_on)

adr := high_sma - low_sma

if high_low
result := day_open + adr/2 * i_target_mult //High
else
result := day_open - adr/2 * i_target_mult //Low

r_2_adr_1 = adr_func_2(i_length_1, true)


r_2_adr_2 = adr_func_2(i_length_2, true)
r_2_adr_3 = adr_func_2(i_length_3, true)

s_2_adr_1 = adr_func_2(i_length_1, false)


s_2_adr_2 = adr_func_2(i_length_2, false)
s_2_adr_3 = adr_func_2(i_length_3, false)

r_target_avg = math.avg(r_2_adr_1, r_2_adr_2, r_2_adr_3)


s_target_avg = math.avg(s_2_adr_1, s_2_adr_2, s_2_adr_3)

///////////////////////////////////////////////////////////////// Percentage Change


from Close Formula
open_percent = -((close - day_open)/close)*100

r_1_percent = -((close - r_1_adr_2)/close)*100


s_1_percent = -((close - s_1_adr_2)/close)*100

r_target_percent = -((close - r_target_avg)/close)*100


s_target_percent = -((close - s_target_avg)/close)*100

///////////////////////////////////////////////////////////////// Price Change from


Close Formula

open_points = day_open - close

r_1_points = r_1_adr_2 - close


s_1_points = s_1_adr_2 - close

r_target_points = r_target_avg - close


s_target_points = s_target_avg - close

///////////////////////////////////////////////////////////////// Line Colors


(Transparency to avoid continuous line)

o_col = pd_open != pd_open[1] ? color.new(color.white, 100) : color.silver


r_col = pd_open != pd_open[1] ? color.new(color.white, 100) : color.new(i_r_col, 0)
s_col = pd_open != pd_open[1] ? color.new(color.white, 100) : color.new(i_s_col, 0)

///////////////////////////////////////////////////////////////// ADR Zones Plot


Line

plot(islast and show_open ? day_open : na, title="Pivot", color=o_col)

r_1_adr_1_line = plot(i_show_zones and islast and show_len_1 ? r_1_adr_1 : na,


title="R1 AR1", color=r_col)
r_1_adr_2_line = plot(i_show_zones and islast and show_len_2 ? r_1_adr_2 : na,
title="R1 AR2", color=r_col)
// r_1_adr_3_line = plot(i_show_zones and islast and show_len_3 ? r_1_adr_3 : na,
title="R1 ADR3", color=r_col)
fill(r_1_adr_1_line, r_1_adr_2_line, color=color.new(r_col, 95))
// fill(r_1_adr_2_line, r_1_adr_3_line, color=color.new(r_col, 95))
// fill(r_1_adr_1_line, r_1_adr_3_line, color=color.new(r_col, 95))

plot(i_show_zones and islast and show_target ? r_target_avg : na, title="R Target",


color=r_col)

s_1_adr_1_line = plot(i_show_zones and islast and show_len_1 ? s_1_adr_1 : na,


title="S1 AR1", color=s_col)
s_1_adr_2_line = plot(i_show_zones and islast and show_len_2 ? s_1_adr_2 : na,
title="S1 AR2", color=s_col)
// s_1_adr_3_line = plot(i_show_zones and islast and show_len_3 ? s_1_adr_3 : na,
title="S1 ADR3", color=s_col)
fill(s_1_adr_1_line, s_1_adr_2_line, color=color.new(s_col, 95))
// fill(s_1_adr_2_line, s_1_adr_3_line, color=color.new(s_col, 95))
// fill(s_1_adr_1_line, s_1_adr_3_line, color=color.new(s_col, 95))

plot(i_show_zones and islast and show_target ? s_target_avg : na, title="S Target",


color=s_col)
///////////////////////////////////////////////////////////////// ADR Zones Draw
Line

// Today Start & End


day_start = timestamp(year, month, dayofmonth, 00, 00)
day_end = day_start + 86400000

// Lines & Labels


if show_open and i_show_zones and show_labels
open_ln = line.new(day_start, day_open, day_end, day_open, xloc.bar_time,
color=o_col)
line.delete(open_ln[1])
open_lbl = label.new(day_end, day_open, xloc=xloc.bar_time,
text=str.tostring(day_open, "#.## (") + str.tostring(open_percent, "#.##") + "%|" +
str.tostring(open_points, "#.##") + ")", textcolor=o_col,
color=color.new(color.white, 100), size=size.normal, style=label.style_label_left)
label.delete(open_lbl[1])

if i_show_zones and show_labels


// r_1_adr_1_ln = line.new(day_start, r_1_adr_1, day_end, r_1_adr_1,
xloc.bar_time, color=r_col)
// line.delete(r_1_adr_1_ln[1])
r_1_adr_2_ln = line.new(day_start, r_1_adr_2, day_end, r_1_adr_2,
xloc.bar_time, color=r_col)
line.delete(r_1_adr_2_ln[1])
r_1_adr_3_ln = line.new(day_start, r_1_adr_3, day_end, r_1_adr_3,
xloc.bar_time, color=r_col)
line.delete(r_1_adr_3_ln[1])
// linefill.new(r_1_adr_1_ln, r_1_adr_2_ln, color.new(r_col, 95))
linefill.new(r_1_adr_2_ln, r_1_adr_3_ln, color.new(r_col, 95))
// linefill.new(r_1_adr_1_ln, r_1_adr_3_ln, color.new(r_col, 95))
r_1_lbl = label.new(day_end, r_adr_avg, xloc=xloc.bar_time,
text=str.tostring(r_1_adr_2, "#.## (") + str.tostring(r_1_percent, "#.##") + "%|" +
str.tostring(r_1_points, "#.##") + ")", textcolor=i_r_col,
color=color.new(color.white, 100), size=size.normal, style=label.style_label_left)
label.delete(r_1_lbl[1])

if show_target and i_show_zones and show_labels


r_target_ln = line.new(day_start, r_target_avg, day_end, r_target_avg,
xloc.bar_time, color=r_col)
line.delete(r_target_ln[1])
r_target_lbl = label.new(day_end, r_target_avg, xloc=xloc.bar_time,
text=str.tostring(r_target_avg, "#.## (") + str.tostring(r_target_percent, "#.##")
+ "%|" + str.tostring(r_target_points, "#.##") + ")", textcolor=i_r_col,
color=color.new(color.white, 100), size=size.normal, style=label.style_label_left)
label.delete(r_target_lbl[1])

if i_show_zones and show_labels


// s_1_adr_1_ln = line.new(day_start, s_1_adr_1, day_end, s_1_adr_1,
xloc.bar_time, color=s_col)
// line.delete(s_1_adr_1_ln[1])
s_1_adr_2_ln = line.new(day_start, s_1_adr_2, day_end, s_1_adr_2,
xloc.bar_time, color=s_col)
line.delete(s_1_adr_2_ln[1])
s_1_adr_3_ln = line.new(day_start, s_1_adr_3, day_end, s_1_adr_3,
xloc.bar_time, color=s_col)
line.delete(s_1_adr_3_ln[1])
// linefill.new(s_1_adr_1_ln, s_1_adr_2_ln, color.new(s_col, 95))
linefill.new(s_1_adr_2_ln, s_1_adr_3_ln, color.new(s_col, 95))
// linefill.new(s_1_adr_1_ln, s_1_adr_3_ln, color.new(s_col, 95))
s_1_lbl = label.new(day_end, s_adr_avg, xloc=xloc.bar_time,
text=str.tostring(s_1_adr_2, "#.## (") + str.tostring(s_1_percent, "#.##") + "%|" +
str.tostring(s_1_points, "#.##") + ")", textcolor=i_s_col,
color=color.new(color.white, 100), size=size.normal, style=label.style_label_left)
label.delete(s_1_lbl[1])

if show_target and i_show_zones and show_labels


s_target_ln = line.new(day_start, s_target_avg, day_end, s_target_avg,
xloc.bar_time, color=s_col)
line.delete(s_target_ln[1])
s_target_lbl = label.new(day_end, s_target_avg, xloc=xloc.bar_time,
text=str.tostring(s_target_avg, "#.## (") + str.tostring(s_target_percent, "#.##")
+ "%|" + str.tostring(s_target_points, "#.##") + ")", textcolor=i_s_col,
color=color.new(color.white, 100), size=size.normal, style=label.style_label_left)
label.delete(s_target_lbl[1])

///////////////////////////////////////////////////////////////// ADR Multi


Timeframe

///////////////////////////////////////////////////////////////// Menu

gpMTF = "MSM Multi Timeframe"

i_length = input.int(5, title="Length", minval=1, group=gpMTF, inline="MTF1")

i_show_mtf_1 = input.bool(false, title="", group=gpMTF, inline="MTF2")


i_time_mtf_1 = input.string("D", title="", options=["1", "3", "5", "15", "30",
"45", "60", "120", "180", "240", "D", "3D", "W", "2W", "M", "3M", "6M", "12M"],
group=gpMTF, inline="MTF2")
i_past_mtf_1 = input.bool(true, title="Hide Past", group=gpMTF, inline="MTF2")

i_show_mtf_2 = input.bool(true, title="", group=gpMTF, inline="MTF3")


i_time_mtf_2 = input.string("W", title="", options=["1", "3", "5", "15", "30",
"45", "60", "120", "180", "240", "D", "3D", "W", "2W", "M", "3M", "6M", "12M"],
group=gpMTF, inline="MTF3")
i_past_mtf_2 = input.bool(true, title="Hide Past", group=gpMTF, inline="MTF3")

i_show_mtf_3 = input.bool(true, title="", group=gpMTF, inline="MTF4")


i_time_mtf_3 = input.string("M", title="", options=["1", "3", "5", "15", "30",
"45", "60", "120", "180", "240", "D", "3D", "W", "2W", "M", "3M", "6M", "12M"],
group=gpMTF, inline="MTF4")
i_past_mtf_3 = input.bool(true, title="Hide Past", group=gpMTF, inline="MTF4")

i_show_mtf_O = input.bool(false, title="Open", group=gpMTF, inline="MTF5")


i_show_mtf_lb = input.bool(true, title="Labels", group=gpMTF, inline="MTF5")

islast_D = i_past_mtf_1 ? request.security(syminfo.tickerid, i_time_mtf_1,


barstate.islast, lookahead=barmerge.lookahead_on) : true
islast_W = i_past_mtf_2 ? request.security(syminfo.tickerid, i_time_mtf_2,
barstate.islast, lookahead=barmerge.lookahead_on) : true
islast_M = i_past_mtf_3 ? request.security(syminfo.tickerid, i_time_mtf_3,
barstate.islast, lookahead=barmerge.lookahead_on) : true

///////////////////////////////////////////////////////////////// OHLC

D_open = request.security(syminfo.tickerid, i_time_mtf_1, open, barmerge.gaps_off,


barmerge.lookahead_on)
W_open = request.security(syminfo.tickerid, i_time_mtf_2, open, barmerge.gaps_off,
barmerge.lookahead_on)
M_open = request.security(syminfo.tickerid, i_time_mtf_3, open, barmerge.gaps_off,
barmerge.lookahead_on)

pD_open = request.security(syminfo.tickerid, i_time_mtf_1, open[1],


barmerge.gaps_off, barmerge.lookahead_on)
pW_open = request.security(syminfo.tickerid, i_time_mtf_2, open[1],
barmerge.gaps_off, barmerge.lookahead_on)
pM_open = request.security(syminfo.tickerid, i_time_mtf_3, open[1],
barmerge.gaps_off, barmerge.lookahead_on)

///////////////////////////////////////////////////////////////// ADR Day

adr_func_D(length_D, high_low_D) =>


float result_D = 0
float adr_D = 0

high_sma_D = request.security(syminfo.tickerid, i_time_mtf_1, ta.sma(high[1],


length_D), barmerge.gaps_off, barmerge.lookahead_on)
low_sma_D = request.security(syminfo.tickerid, i_time_mtf_1, ta.sma(low[1],
length_D), barmerge.gaps_off, barmerge.lookahead_on)

adr_D := high_sma_D - low_sma_D

if high_low_D
result_D := D_open + adr_D/2 //High
else
result_D := D_open - adr_D/2 //Low

// Day Formula
r_1_adr_D = adr_func_D(i_length, true)
s_1_adr_D = adr_func_D(i_length, false)

// Percentage Change from Close Formula


D_chg = -((close - D_open)/close)*100
r_1_adr_D_chg = -((close - r_1_adr_D)/close)*100
s_1_adr_D_chg = -((close - s_1_adr_D)/close)*100

// Price Change from Close Formula


D_pts = D_open - close
r_1_adr_D_pts = r_1_adr_D - close
s_1_adr_D_pts = s_1_adr_D - close
///////////////////////////////////////////////////////////////// ADR Week

adr_func_W(length_W, high_low_W) =>


float result_W = 0
float adr_W = 0

high_sma_W = request.security(syminfo.tickerid, i_time_mtf_2, ta.sma(high[1],


length_W), barmerge.gaps_off, barmerge.lookahead_on)
low_sma_W = request.security(syminfo.tickerid, i_time_mtf_2, ta.sma(low[1],
length_W), barmerge.gaps_off, barmerge.lookahead_on)

adr_W := high_sma_W - low_sma_W

if high_low_W
result_W := W_open + adr_W/2 //High
else
result_W := W_open - adr_W/2 //Low

// Week Formula
r_1_adr_W = adr_func_W(i_length, true)
s_1_adr_W = adr_func_W(i_length, false)

// Percentage Change from Close Formula


W_chg = -((close - W_open)/close)*100
r_1_adr_W_chg = -((close - r_1_adr_W)/close)*100
s_1_adr_W_chg = -((close - s_1_adr_W)/close)*100

// Price Change from Close Formula


W_pts = W_open - close
r_1_adr_W_pts = r_1_adr_D - close
s_1_adr_W_pts = s_1_adr_D - close

///////////////////////////////////////////////////////////////// ADR Month

adr_func_M(length_M, high_low_M) =>


float result_M = 0
float adr_M = 0

high_sma_M = request.security(syminfo.tickerid, i_time_mtf_3, ta.sma(high[1],


length_M), barmerge.gaps_off, barmerge.lookahead_on)
low_sma_M = request.security(syminfo.tickerid, i_time_mtf_3, ta.sma(low[1],
length_M), barmerge.gaps_off, barmerge.lookahead_on)

adr_M := high_sma_M - low_sma_M

if high_low_M
result_M := M_open + adr_M/2 //High
else
result_M := M_open - adr_M/2 //Low

// Month Formula
r_1_adr_M = adr_func_M(i_length, true)
s_1_adr_M = adr_func_M(i_length, false)

// Percentage Change from Close Formula


M_chg = -((close - M_open)/close)*100
r_1_adr_M_chg = -((close - r_1_adr_M)/close)*100
s_1_adr_M_chg = -((close - s_1_adr_M)/close)*100
// Price Change from Close Formula
M_pts = M_open - close
r_1_adr_M_pts = r_1_adr_D - close
s_1_adr_M_pts = s_1_adr_D - close

///////////////////////////////////////////////////////////////// Color

o_col_D = pD_open != pD_open[1] ? color.new(color.white, 100) : color.gray


r_col_D = pD_open != pD_open[1] ? color.new(color.white, 100) : color.new(i_r_col,
0)
s_col_D = pD_open != pD_open[1] ? color.new(color.white, 100) : color.new(i_s_col,
0)

o_col_W = pW_open != pW_open[1] ? color.new(color.white, 100) : color.gray


r_col_W = pW_open != pW_open[1] ? color.new(color.white, 100) : color.new(i_r_col,
0)
s_col_W = pW_open != pW_open[1] ? color.new(color.white, 100) : color.new(i_s_col,
0)

o_col_M = pM_open != pM_open[1] ? color.new(color.white, 100) : color.gray


r_col_M = pM_open != pM_open[1] ? color.new(color.white, 100) : color.new(i_r_col,
0)
s_col_M = pM_open != pM_open[1] ? color.new(color.white, 100) : color.new(i_s_col,
0)

///////////////////////////////////////////////////////////////// Plot Line

plot(i_show_mtf and islast_D and i_show_mtf_1 and i_show_mtf_O ? D_open : na,


title="D Open", color=o_col_D, linewidth=3)
plot(i_show_mtf and islast_D and i_show_mtf_1 ? r_1_adr_D : na, title="D
Resistance", color=r_col_D, linewidth=3)
plot(i_show_mtf and islast_D and i_show_mtf_1 ? s_1_adr_D : na, title="D Support",
color=s_col_D, linewidth=3)

plot(i_show_mtf and islast_W and i_show_mtf_2 and i_show_mtf_O ? W_open : na,


title="W Open", color=o_col_W, linewidth=2)
plot(i_show_mtf and islast_W and i_show_mtf_2 ? r_1_adr_W : na, title="W
Resistance", color=r_col_W, linewidth=2)
plot(i_show_mtf and islast_W and i_show_mtf_2 ? s_1_adr_W : na, title="W Support",
color=s_col_W, linewidth=2)

plot(i_show_mtf and islast_M and i_show_mtf_3 and i_show_mtf_O ? M_open : na,


title="M Open", color=o_col_M, linewidth=1)
plot(i_show_mtf and islast_M and i_show_mtf_3 ? r_1_adr_M : na, title="M
Resistance", color=r_col_M, linewidth=1)
plot(i_show_mtf and islast_M and i_show_mtf_3 ? s_1_adr_M : na, title="M Support",
color=s_col_M, linewidth=1)

///////////////////////////////////////////////////////////////// Labels

if i_show_mtf_O and i_show_mtf_lb and i_show_mtf


if i_show_mtf_1
var label D_open_lb = na
D_open_lb := label.new(x=bar_index, y=D_open, text="(" + i_time_mtf_1 + ")
" + str.tostring(D_open, "#.## (") + str.tostring(D_chg, "#.##") + "%)",
style=label.style_label_left, color=color.new(color.white, 100), textcolor=o_col_D)
label.delete(D_open_lb[1])
if i_show_mtf_2
var label W_open_lb = na
W_open_lb := label.new(x=bar_index, y=W_open, text="(" + i_time_mtf_2 + ")
" + str.tostring(W_open, "#.## (") + str.tostring(W_chg, "#.##") + "%)",
style=label.style_label_left, color=color.new(color.white, 100), textcolor=o_col_D)
label.delete(W_open_lb[1])
if i_show_mtf_3
var label M_open_lb = na
M_open_lb := label.new(x=bar_index, y=M_open, text="(" + i_time_mtf_3 + ")
" + str.tostring(M_open, "#.## (") + str.tostring(M_chg, "#.##") + "%)",
style=label.style_label_left, color=color.new(color.white, 100), textcolor=o_col_D)
label.delete(M_open_lb[1])

if i_show_mtf_1 and i_show_mtf_lb and i_show_mtf


var label r_1_adr_D_lb = na
r_1_adr_D_lb := label.new(x=bar_index, y=r_1_adr_D, text="(" + i_time_mtf_1 +
") " + str.tostring(r_1_adr_D, "#.## (") + str.tostring(r_1_adr_D_chg, "#.##") +
"%)", style=label.style_label_left, color=color.new(color.white, 100),
textcolor=r_col_D)
label.delete(r_1_adr_D_lb[1])
var label s_1_adr_D_lb = na
s_1_adr_D_lb := label.new(x=bar_index, y=s_1_adr_D, text="(" + i_time_mtf_1 +
") " + str.tostring(s_1_adr_D, "#.## (") + str.tostring(s_1_adr_D_chg, "#.##") +
"%)", style=label.style_label_left, color=color.new(color.white, 100),
textcolor=s_col_D)
label.delete(s_1_adr_D_lb[1])

if i_show_mtf_2 and i_show_mtf_lb and i_show_mtf


var label r_1_adr_W_lb = na
r_1_adr_W_lb := label.new(x=bar_index, y=r_1_adr_W, text="(" + i_time_mtf_2 +
") " + str.tostring(r_1_adr_W, "#.## (") + str.tostring(r_1_adr_W_chg, "#.##") +
"%)", style=label.style_label_left, color=color.new(color.white, 100),
textcolor=r_col_D)
label.delete(r_1_adr_W_lb[1])
var label s_1_adr_W_lb = na
s_1_adr_W_lb := label.new(x=bar_index, y=s_1_adr_W, text="(" + i_time_mtf_2 +
") " + str.tostring(s_1_adr_W, "#.## (") + str.tostring(s_1_adr_W_chg, "#.##") +
"%)", style=label.style_label_left, color=color.new(color.white, 100),
textcolor=s_col_D)
label.delete(s_1_adr_W_lb[1])

if i_show_mtf_3 and i_show_mtf_lb and i_show_mtf


var label r_1_adr_M_lb = na
r_1_adr_M_lb := label.new(x=bar_index, y=r_1_adr_M, text="(" + i_time_mtf_3 +
") " + str.tostring(r_1_adr_M, "#.## (") + str.tostring(r_1_adr_M_chg, "#.##") +
"%)", style=label.style_label_left, color=color.new(color.white, 100),
textcolor=r_col_D)
label.delete(r_1_adr_M_lb[1])
var label s_1_adr_M_lb = na
s_1_adr_M_lb := label.new(x=bar_index, y=s_1_adr_M, text="(" + i_time_mtf_3 +
") " + str.tostring(s_1_adr_M, "#.## (") + str.tostring(s_1_adr_M_chg, "#.##") +
"%)", style=label.style_label_left, color=color.new(color.white, 100),
textcolor=s_col_D)
label.delete(s_1_adr_M_lb[1])

///////////////////////////////////////////////////////////////// END
// condition_b =

pdhigh = request.security(syminfo.tickerid, i_time_mtf_1, high[1],


barmerge.gaps_off, barmerge.lookahead_on)
pdclose= request.security(syminfo.tickerid, i_time_mtf_1, close[1],
barmerge.gaps_off, barmerge.lookahead_on)
pdlow = request.security(syminfo.tickerid, i_time_mtf_1, low[1], barmerge.gaps_off,
barmerge.lookahead_on)

plot(pdhigh == pdhigh[1] ? pdhigh : na , "previous day high" , color = color.red ,


style = plot.style_linebr )
plot(pdclose == pdclose[1] ? pdclose : na , "previous day close" , color =
color.rgb(73, 68, 68) , style = plot.style_linebr)
plot(pdlow == pdlow[1] ? pdlow : na , "previous day low" , color = color.green ,
style = plot.style_linebr)
plot(pdlow == pdlow[1] ? D_open : na , "current day open" , color = color.gray ,
style = plot.style_linebr)

arrays(a) =>
low < a and high > a ? true : false

adr_test = arrays(s_1_adr_2) or arrays(s_1_adr_3) or arrays(r_1_adr_2) or


arrays(r_1_adr_3) or arrays(pdhigh) or arrays(pdclose) or arrays(pdlow) and
arrays(D_open)

// 22 Color Change SMA


len = input.int(22, minval=1, title='Length')
src = input(close, title='Source')
sma22 = ta.sma(src, len)

plot(sma22, title='SMA', color=close >= sma22 ? color.green : color.red,


linewidth=2)

// Check if the close is below the 22 SMA for bearish candles


bearishCondition = close > sma22 and low > sma22
bull = close < sma22 and high < sma22

// Candlestick Patterns

// find_(bool_) =>
// var float highh = 100000
// bool result = false
// if bool_
// highh := high
// if ta.crossover(close , highh)
// highh := 100000
// result := true

find_(bool_) =>
var float highh = 100000
bool result = false
a_ = ta.barssince(bool_) == 4
if bool_
highh := high
if a_
highh := 100000
if ta.crossover(close , highh)
highh := 100000
result := true

find_s(bool_ ) =>
var float loww = 0.0
bool result = false
a_2 = ta.barssince(bool_) == 4
if bool_
loww := low
if a_2
loww := 0.0
if ta.crossunder(close , loww)
loww := 0.0
result := true

////////////
njndd = input.bool(true , "on/ off strong buy strong sell")

dataHammer = high - low > 3 * (open - close) and (close - low) / (.001 + high -
low) > 0.6 and (open - low) / (.001 + high - low) > 0.6 and bull and adr_test and
njndd
// plotshape(find_(dataHammer) , title='Hammer', location=location.belowbar,
color=color.rgb(15, 135, 182), style=shape.triangleup, text='strong BUY ',
textcolor=color.new(color.green, 0))
// plotshape((dataHammer) , title='Hammer', location=location.belowbar,
color=color.rgb(15, 135, 182), style=shape.triangleup, text='strong BUY above',
textcolor=color.new(color.green, 0))

dataInvertedHammer = high - low > 3 * (open - close) and (high - close) / (.001 +
high - low) > 0.6 and (high - open) / (.001 + high - low) > 0.6 and
bearishCondition and adr_test and njndd
// plotshape(find_s(dataInvertedHammer), title='Inverted Hammer',
location=location.abovebar, color=color.rgb(219, 17, 17), style=shape.triangledown,
text='strong Alert', textcolor=color.new(color.red, 0))
// plotshape((dataInvertedHammer), title='Inverted Hammer',
location=location.belowbar, color=color.rgb(219, 17, 17), style=shape.triangledown,
text='strong Alert Below', textcolor=color.new(color.red, 0))

dataBearishHarami = bearishCondition and close[1] > open[1] and open > close and
open <= close[1] and open[1] <= close and open - close < close[1] - open[1] and
high < high[1] and low > low[1] and adr_test and njndd
// plotshape(find_s(dataBearishHarami), title='Bearish Harami',
location=location.abovebar, color=color.new(color.red, 0),
style=shape.triangledown, text='strong Alert ', textcolor=color.new(color.red, 0))
// plotshape((dataBearishHarami), title='Bearish Harami',
location=location.abovebar, color=color.new(color.red, 0),
style=shape.triangledown, text='strong Alert Below', textcolor=color.new(color.red,
0))

dataBullishHarami = open[1] > close[1] and close > open and close <= open[1] and
close[1] <= open and close - open < open[1] - close[1] and high < high[1] and low
> low[1] and bull and adr_test and njndd
// plotshape( dataBullishHarami , title='Bullish Harami',
location=location.belowbar, color=color.rgb(3, 114, 60), style=shape.triangleup,
text='strong BUY ', textcolor=color.new(color.green, 0))
// plotshape(find_(dataBullishHarami) , title='Bullish Harami',
location=location.belowbar, color=color.rgb(3, 114, 60), style=shape.triangleup,
text='strong BUY ', textcolor=color.new(color.green, 0))

dataBearishEngulfing = bearishCondition and close[1] > open[1] and open > close and
open >= close[1] and open[1] >= close and open - close > close[1] - open[1] and
high > high[1] and low < low[1] and adr_test and njndd
// plotshape(find_s(dataBearishEngulfing), title='Bearish Engulfing',
location=location.abovebar, color=color.new(color.red, 0),
style=shape.triangledown, text='strong Alert', textcolor=color.new(color.red, 0))
// plotshape((dataBearishEngulfing), title='Bearish Engulfing',
location=location.abovebar, color=color.new(color.red, 0),
style=shape.triangledown, text='strong Alert Below', textcolor=color.new(color.red,
0))

dataBullishEngulfing = open[1] > close[1] and close > open and close >= open[1] and
close[1] >= open and close - open > open[1] - close[1] and high > high[1] and low
< low[1] and bull and adr_test and njndd
// plotshape( dataBullishEngulfing , title='Bullish Engulfing',
location=location.belowbar, color=color.rgb(6, 136, 73), style=shape.triangleup,
text='strong BUY ', textcolor=color.new(color.green, 0))
// plotshape(find_(dataBullishEngulfing) , title='Bullish Engulfing',
location=location.belowbar, color=color.rgb(6, 136, 73), style=shape.triangleup,
text='strong BUY ', textcolor=color.new(color.green, 0))

njnd = input.bool(true , "on/ off buy above sell below")


// Candlestick Patterns

dataHammer_x = high - low > 3 * (open - close) and (close - low) / (.001 + high -
low) > 0.6 and (open - low) / (.001 + high - low) > 0.6 and bull and njnd
plotshape(find_(dataHammer_x) , title='Hammer', location=location.belowbar,
color=color.rgb(15, 135, 182), style=shape.triangleup, text='Alert ',
textcolor=color.new(color.green, 0))

dataInvertedHammer_x = high - low > 3 * (open - close) and (high - close) / (.001
+ high - low) > 0.6 and (high - open) / (.001 + high - low) > 0.6 and
bearishCondition and njnd
plotshape(find_s(dataInvertedHammer_x) , title='Inverted Hammer',
location=location.abovebar, color=color.rgb(219, 17, 17), style=shape.triangledown,
text='Alert ', textcolor=color.new(color.red, 0))

dataBearishHarami_x = bearishCondition and close[1] > open[1] and open > close and
open <= close[1] and open[1] <= close and open - close < close[1] - open[1] and
njnd and high < high[1] and low > low[1]
plotshape(find_s(dataBearishHarami_x) , title='Bearish Harami',
location=location.abovebar, color=color.new(color.red, 0),
style=shape.triangledown, text='Alert ', textcolor=color.new(color.red, 0))

dataBullishHarami_x = open[1] > close[1] and close > open and close <= open[1] and
close[1] <= open and close - open < open[1] - close[1] and bull and njnd and high
< high[1] and low > low[1]
plotshape(find_(dataBullishHarami_x) , title='Bullish Harami',
location=location.belowbar, color=color.rgb(3, 114, 60), style=shape.triangleup,
text='Alert ', textcolor=color.new(color.green, 0))

dataBearishEngulfing_x = bearishCondition and close[1] > open[1] and open > close
and open >= close[1] and open[1] >= close and open - close > close[1] - open[1] and
njnd and high > high[1] and low < low[1]
plotshape(find_s(dataBearishEngulfing_x) , title='Bearish Engulfing',
location=location.abovebar, color=color.new(color.red, 0),
style=shape.triangledown, text='Alert', textcolor=color.new(color.red, 0))

dataBullishEngulfing_x = open[1] > close[1] and close > open and close >= open[1]
and close[1] >= open and close - open > open[1] - close[1] and bull and njnd and
high > high[1] and low < low[1]
plotshape(find_(dataBullishEngulfing_x) , title='Bullish Engulfing',
location=location.belowbar, color=color.rgb(6, 136, 73), style=shape.triangleup,
text='Alert', textcolor=color.new(color.green, 0))

bullishHaramiCond = find_(dataBullishHarami_x)
bullisEngulfingCond = find_(dataBullishEngulfing_x)
bullishHammerCond = find_(dataHammer_x)
bullishHammerCond2 = find_(dataHammer)

if bullishHammerCond or bullishHaramiCond or bullisEngulfingCond or


dataBullishHarami or dataBullishEngulfing or bullishHammerCond2
// label.new(bar_index, high, "", color = color.blue)
label.new(bar_index, low, callSymbol + "\n" + str.tostring(callPrice),style =
label.style_label_up, color = color.teal, textcolor = color.white)

bearishHaramiCond = find_s(dataBearishHarami_x)
bearisEngulfingCond = find_s(dataBearishEngulfing_x)
bearishHammerCond = find_s(dataInvertedHammer_x)

bearishInvertedHammerCond = find_s(dataInvertedHammer)
bearishHaramiCond2 = find_s(dataBearishHarami)
bearisEngulfingCond2 = find_s(dataBearishEngulfing)
if bearishHammerCond or bearishHaramiCond or bearisEngulfingCond or
bearishInvertedHammerCond or bearishHaramiCond2 or bearisEngulfingCond2
// label.new(bar_index, high, "", color = color.blue)
label.new(bar_index, high, putSymbol + "\n" + str.tostring(putPrice),style =
label.style_label_down, color = color.orange, textcolor = color.white)

// Trend and Buy/Sell Signal


DX = 0.0
BullTrend = 0.0
BearTrend = 0.0
alc = ta.sma(high, 20)
baj = ta.sma(low, 20)
amp = alc - baj
BullTrend := (close - ta.lowest(low, 20)) / amp
BearTrend := (ta.highest(high, 20) - close) / amp
DX := math.abs(BullTrend - BearTrend) / (BullTrend + BearTrend) * 10
trend = ta.ema(DX, 20)

You might also like