// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © fengyangsi //@version=5 indicator(title = "Price Action All In One", shorttitle = "PAIO", overlay = true, max_lines_count = 500, max_labels_count = 500, max_boxes_count = 500) //Traditional Gap traditionalGapUse = input.bool( defval = true, title = "Use Traditional Gap", tooltip = "Space between bars", group = "Traditional Gap") traditionalGapUpColor = input.color(defval = color.new(#089981, 60), title = "Upward gap color", inline = "Traditional Gap Color", group = "Traditional Gap") traditionalGapDownColor = input.color(defval = color.new(#F23645, 60), title = "Downward gap color", inline = "Traditional Gap Color", group = "Traditional Gap") if traditionalGapUse if low > high[1] p1 = chart.point.from_index(index = bar_index[1], price = high[1]) p2 = chart.point.from_index(index = bar_index, price = low) box.new(top_left = p1,bottom_right = p2, border_width = 0, bgcolor = traditionalGapUpColor) else if high < low[1] p1 = chart.point.from_index(index = bar_index[1], price = low[1]) p2 = chart.point.from_index(index = bar_index, price = high) box.new(top_left = p1,bottom_right = p2, border_width = 0, bgcolor = traditionalGapDownColor) //Tail Gap tailGapUse = input.bool( defval = true, title = "Use Tail Gap", tooltip = "Space between tails", group = "Tail Gap") tailGapUpColor = input.color(defval = color.new(#089981, 70), title = "Upward gap color", inline = "Tail Gap Color", group = "Tail Gap") tailGapDownColor = input.color(defval = color.new(#F23645, 70), title = "Downward gap color", inline = "Tail Gap Color", group = "Tail Gap") if tailGapUse if low > high[2] and low <= high[1] and low[1] <= high[2] p1 = chart.point.from_index(index = bar_index[2], price = high[2]) p2 = chart.point.from_index(index = bar_index, price = low) box.new(top_left = p1,bottom_right = p2, border_width = 0, bgcolor = tailGapUpColor) else if high < low[2] and high >= low[1] and high[1] >= low[2] p1 = chart.point.from_index(index = bar_index[2], price = low[2]) p2 = chart.point.from_index(index = bar_index, price = high) box.new(top_left = p1,bottom_right = p2, border_width = 0, bgcolor = tailGapDownColor) //Bar Count barCountUse = input.bool( defval = true, title = "Use Bar Count", tooltip = "Numbering/Order of bar", group = "Bar Count") barCountInterval = input.int( defval = 1, minval = 0, title = "Label Interval", inline = "Bar Count Label", group = "Bar Count") barCountSize = input.string( defval = size.normal, title = "", inline = "Bar Count Label", options = [size.auto, size.tiny, size.small, size.normal, size.large, size.huge], group = "Bar Count") barCountColor = input.color( defval = color.orange, title = "", inline = "Bar Count Label", group = "Bar Count") barCountTF = input.timeframe(defval = "1D", title = "TimeFrame", group = "Bar Count") var int count = 0 count += 1 timeTF = time(barCountTF)//barCountTF != "1D" ? time(barCountTF) : time_tradingday if timeTF != timeTF[1] count := 1 if (count + barCountInterval) % (barCountInterval + 1) == 0 and barCountUse countLable = label.new(x = bar_index, y = 0, text = str.tostring(count), yloc = yloc.belowbar, style = label.style_none, textcolor = barCountColor, size = barCountSize) //Ema ema1stUse = input.bool(defval = true, title = "Use 1st", inline = "1st", group = "Ema") ema1stSource = input.source(defval = close, title = "Source", inline = "1st", group = "Ema") ema1stLength = input.int(defval = 20, minval = 0, title = "Length", inline = "1st", group = "Ema") ema1stOffset = input.int(defval = 0, title = "Offset", inline = "1st", group = "Ema") ema1stTimeFrame = input.timeframe(defval = "", title = "Time Frame", inline = "1st-2", group = "Ema") ema1stIsCoD = input.string(defval = "discrete", title = "Display Way", options = ["continuous", "discrete"], inline = "1st-2", group = "Ema") ema1stValue = request.security(symbol = syminfo.tickerid, timeframe = ema1stTimeFrame, expression = ta.ema(ema1stSource, ema1stLength), gaps = ema1stIsCoD == "discrete" ? barmerge.gaps_off : barmerge.gaps_on) ema2stUse = input.bool(defval = true, title = "Use 2st", inline = "2st", group = "Ema") ema2stSource = input.source(defval = close, title = "Source", inline = "2st", group = "Ema") ema2stLength = input.int(defval = 20, minval = 0, title = "Length", inline = "2st", group = "Ema") ema2stOffset = input.int(defval = 0, title = "Offset", inline = "2st", group = "Ema") ema2stTimeFrame = input.timeframe(defval = "15", title = "Time Frame", inline = "2st-2", group = "Ema") ema2stIsCoD = input.string(defval = "discrete", title = "Display Way", options = ["continuous", "discrete"], inline = "2st-2", group = "Ema") ema2stValue = request.security(symbol = syminfo.tickerid, timeframe = ema2stTimeFrame, expression = ta.ema(ema2stSource, ema2stLength), gaps = ema2stIsCoD == "discrete" ? barmerge.gaps_off : barmerge.gaps_on) ema3stUse = input.bool(defval = true, title = "Use 3st", inline = "3st", group = "Ema") ema3stSource = input.source(defval = close, title = "Source", inline = "3st", group = "Ema") ema3stLength = input.int(defval = 20, minval = 0, title = "Length", inline = "3st", group = "Ema") ema3stOffset = input.int(defval = 0, title = "Offset", inline = "3st", group = "Ema") ema3stTimeFrame = input.timeframe(defval = "60", title = "Time Frame", inline = "3st-2", group = "Ema") ema3stIsCoD = input.string(defval = "discrete", title = "Display Way", options = ["continuous", "discrete"], inline = "3st-2", group = "Ema") ema3stValue = request.security(symbol = syminfo.tickerid, timeframe = ema3stTimeFrame, expression = ta.ema(ema3stSource, ema3stLength), gaps = ema3stIsCoD == "discrete" ? barmerge.gaps_off : barmerge.gaps_on) plot(series = ema1stUse ? ema1stValue : na, title = "1st Ema", color = color.orange, linewidth = 2, style = plot.style_line, offset = ema1stOffset) plot(series = ema2stUse ? ema2stValue : na, title = "2st Ema", color = color.orange, linewidth = 1, style = plot.style_circles, offset = ema2stOffset) plot(series = ema3stUse ? ema3stValue : na, title = "3st Ema", color = color.orange, linewidth = 1, style = plot.style_line, offset = ema3stOffset) //Last Bar lbDisplay = input.string(defval = "Today", title = "Display", options = ["Today", "TimeFrame", "All"], group = "Last Bar") l1stUse = input.bool( defval = true, title = "Use 1st line", inline = "l1st", group = "Last Bar") l1stTF = input.timeframe(defval = "1D", title = "TimeFrame", inline = "l1st", group = "Last Bar") l1stSource = input.source( defval = close,title = "Source", inline = "l1st", group = "Last Bar") l1stValue = request.security(symbol = syminfo.tickerid, timeframe = l1stTF, expression = l1stSource, gaps = barmerge.gaps_off) l2stUse = input.bool( defval = true, title = "Use 2st line", inline = "l2st", group = "Last Bar") l2stTF = input.timeframe(defval = "1D", title = "TimeFrame", inline = "l2st", group = "Last Bar") l2stSource = input.source( defval = high, title = "Source", inline = "l2st", group = "Last Bar") l2stValue = request.security(symbol = syminfo.tickerid, timeframe = l2stTF, expression = l2stSource, gaps = barmerge.gaps_off) l3stUse = input.bool( defval = true, title = "Use 3st line", inline = "l3st", group = "Last Bar") l3stTF = input.timeframe(defval = "1D", title = "TimeFrame", inline = "l3st", group = "Last Bar") l3stSource = input.source( defval = low, title = "Source", inline = "l3st", group = "Last Bar") l3stValue = request.security(symbol = syminfo.tickerid, timeframe = l3stTF, expression = l3stSource, gaps = barmerge.gaps_off) l1stValue := l1stValue != l1stValue[1] ? na : (last_bar_time > (lbDisplay == "Today" ? time_close("1D") : (lbDisplay == "TimeFrame" ? time_close(l1stTF) : last_bar_time)) ? na : l1stValue) l2stValue := l2stValue != l2stValue[1] ? na : (last_bar_time > (lbDisplay == "Today" ? time_close("1D") : (lbDisplay == "TimeFrame" ? time_close(l2stTF) : last_bar_time)) ? na : l2stValue) l3stValue := l3stValue != l3stValue[1] ? na : (last_bar_time > (lbDisplay == "Today" ? time_close("1D") : (lbDisplay == "TimeFrame" ? time_close(l3stTF) : last_bar_time)) ? na : l3stValue) if barstate.islast l1stValue := l1stValue[1] l2stValue := l2stValue[1] l3stValue := l3stValue[1] plot(series = l1stUse ? l1stValue : na, title = "1stl", color = #434651, linewidth = 2, style = plot.style_linebr) plot(series = l2stUse ? l2stValue : na, title = "2stl", color = #F23645, linewidth = 1, style = plot.style_linebr) plot(series = l3stUse ? l3stValue : na, title = "3stl", color = #089981, linewidth = 1, style = plot.style_linebr) //Inside And Outside useOO = input.bool( defval = true, title = "Use OO Pattern", group = "I & O Bar") useII = input.bool( defval = true, title = "Use II Pattern", group = "I & O Bar") useIOI = input.bool( defval = true, title = "Use IOI Pattern", group = "I & O Bar") ioLableSize = input.string(defval = size.large, title = "Label Size", options = [size.auto, size.tiny, size.small, size.normal, size.large, size.huge], inline = "ioLable", group = "I & O Bar") ioLableColor = input.color( defval = color.gray, title = "", inline = "ioLable", group = "I & O Bar") patternOO = high >= high[1] and low <= low[1] and high[1] >= high[2] and low[1] <= low[2] and (high != high[1] or low != low[1]) patternII = high <= high[1] and low >= low[1] and high[1] <= high[2] and low[1] >= low[2] and (high != high[1] or low != low[1]) patternIOI = high <= high[1] and low >= low[1] and high[1] >= high[2] and low[1] <= low[2] var label lastOOLable = na var label lastIILable = na var label lastIOILable = na if patternOO and useOO index = 0 while patternOO[index + 1] index += 1 if lastOOLable.get_x() + index == bar_index lastOOLable.set_text(str.repeat("o", index + 2)) else lastOOLable := label.new(x = bar_index, y = 0, yloc = yloc.abovebar, style = label.style_none, text = "oo", size = ioLableSize, textcolor = ioLableColor) if patternII and useII index = 0 while patternII[index + 1] index += 1 if lastIILable.get_x() + index == bar_index lastIILable.set_text(str.repeat("i", index + 2)) else if lastIOILable.get_x() + 2 + index == bar_index lastIOILable.set_text("ioi" + str.repeat("i", index + 1)) else if not patternIOI lastIILable := label.new(x = bar_index, y = 0, yloc = yloc.abovebar, style = label.style_none, text = "ii", size = ioLableSize, textcolor = ioLableColor) if patternIOI and useIOI lastIOILable := label.new(x = bar_index - 1, y = 0, yloc = yloc.abovebar, style = label.style_none, text = "ioi", size = ioLableSize, textcolor = ioLableColor) index = 0 while patternOO[index + 1] index += 1 if lastOOLable.get_x() + index == bar_index lastOOLable.delete() lastIOILable.set_text(str.repeat("i", index) + "ioi")