Nitin Swing Trading
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ShareTrading_

//@version=5
indicator(title='Swing Trading Nitin', shorttitle='SwingTradeNitin', overlay=true)

//defaultTimeFrame = ((isintraday) ? "D" : ((isdaily) ? "W" : ((isweekly) ? "M" : "3M")))
//inputTimeFrame = input(title="Time Frame", type=string, defval="D")
//chosenTimeFrame = (inputTimeFrame == "D") ? defaultTimeFrame : inputTimeFrame

getSeries(e, timeFrame) =>
    request.security(syminfo.tickerid, timeFrame, e, lookahead=barmerge.lookahead_on)

H = getSeries(high[1], 'M')
L = getSeries(low[1], 'M')
C = getSeries(close[1], 'M')

// Main Pivot
P = (H + L + C) / 3
BC = (H + L) / 2
TC = P - BC + P

// Resistence Levels
// R3 = H + 2 * (P - L)
//R2 = P + H - L
R1 = P * 2 - L
// Support Levels
S1 = P * 2 - H
// S2 = P - (H - L)
// S3 = L - 2 * (H - P)



//UX Input Arguments
bColor = color.navy
rColor = color.orange
sColor = color.green




myWidthMainLevels = input.int(title='Line width for Main levels', defval=2, minval=1)
myStyle = plot.style_circles


plot(R1, title='R1', color=color.new(rColor, 0), linewidth=myWidthMainLevels, style=myStyle)
//plot(R2, title="R2", color=rColor, linewidth=myWidthMainLevels, style=myStyle)
//plot(R3, title="R3", color=rColor, linewidth=myWidthMainLevels, style=myStyle)

plot(P, title='P', color=color.new(bColor, 0), linewidth=2, style=plot.style_circles)
p1 = plot(BC, title='BC', color=color.new(bColor, 0), linewidth=2, style=plot.style_circles)
p2 = plot(TC, title='TC', color=color.new(bColor, 0), linewidth=2, style=plot.style_circles)

plot(S1, title='S1', color=color.new(sColor, 0), linewidth=myWidthMainLevels, style=myStyle)
//plot(S2, title="S2", color=sColor, linewidth=myWidthMainLevels, style=myStyle)
//plot(S3, title="S3", color=sColor, linewidth=myWidthMainLevels, style=myStyle)

