// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ //@version=4 // V 1.22 // There is a code that can control sensitivity. // There is a code for prevent 'repaint' // thanks to // https://www.tradingview.com/script/l0wdrsUO-String-Manipulation-Framework-PineCoders-FAQ/ // https://www.tradingview.com/u/PineCoders/#published-scripts String Manipulation Framework [PineCoders FAQ] strategy(title = "Open Explorer", shorttitle = "trade.inn Explorer",overlay=true, calc_on_every_tick=false, initial_capital=100000, default_qty_type=strategy.percent_of_equity, default_qty_value=100, pyramiding = 0, commission_type=strategy.commission.percent, commission_value=0.25) // === INPUTS === tradeType = input("LONG", title = "What trades should be taken : ", options=["LONG", "SHORT", "BOTH", "NONE"]) resMultiplier = input(defval = 5, title = "Multiplier for Alternate Resolution('1' is original)", minval = 1) basisType = input(defval = "TEMA",title = "MA Type: ", options=["SMA", "EMA", "DEMA", "TEMA", "WMA", "VWMA", "SMMA", "HullMA", "LSMA", "ALMA", "SSMA", "TMA"]) basisLen = input(defval = 10, title = "MA Period", minval = 1) offsetSigma = input(defval = 6, title = "Offset for LSMA / Sigma for ALMA", minval = 1) offsetALMA = input(defval = 0.85, title = "Offset for ALMA", minval = 0.1, step = 0.01) useStartPeriodTime = input(true, "Start", input.bool, group = "Date Range", inline = "Start Period") startPeriodTime = input(timestamp(" 4 Mar 2025"), "", input.time, group = "Date Range", inline = "Start Period") useEndPeriodTime = input(true, "End ", input.bool, group = "Date Range", inline = "End Period") endPeriodTime = input(timestamp("19 Apr 2025"), "", input.time, group = "Date Range", inline = "End Period") enableHighlight = input(false, "Highlight", input.bool, group = "Date Range", inline = "Highlight") highlightType = input( "Anchors","", input.string, options = ["Anchors", "Background"], group = "Date Range",inline = "Highlight") highlightColor = input(color.red, "", input.color, group = "Date Range", inline = "Highlight") scolor = input(defval = true, title = "Show coloured Bars to indicate Trend?", group = "Date Range") //=== Code to adjust sensitivity 'Multiplier*atr'=== Periods = input(defval = 30, title ="ATR Length", group = "Sensitivity", minval = 1) Multiplier = input(defval = 0.18, title ="ATR Multiplier", group = "Sensitivity", minval = 0.0, step = 0.01) Non_Repainting = input(defval = 1, title = "Forces to Non-Repainting", options=[0,1,2], group = "Sensitivity") //===/Code to adjust sensitivity 'Multiplier*atr' === showLabel = input(defval = true, title = "Show Screener Label with Text Color", group = "Label", inline = "Show Label") textColor = input(color.blue, "", input.color, group = "Label", inline = "Show Label") sort_by = input(defval ="Change Rate",title = "Label Sort by: ", options=["Profit", "Change Rate", "None"], group = "Label") posX_scr = input(defval = 100, title = "Position Label x-axis( bars)", group = "Label") posY_scr = input(defval = 150, title = "Position Label y-axis(ohlc4)", group = "Label") // === /INPUTS === start = useStartPeriodTime ? startPeriodTime >= time : false end = useEndPeriodTime ? endPeriodTime <= time : false calcPeriod = not start and not end var line startAnchor = line.new(na, na, na, na, xloc.bar_time, extend.both, highlightColor, width = 2) var line endAnchor = line.new(na, na, na, na, xloc.bar_time, extend.both, highlightColor, width = 2) useBgcolor = false // —————————— PineCoders MTF Selection Framework functions // ————— Converts current "timeframe.multiplier" plus the TF into minutes of type float. f_resInMinutes() => _resInMinutes = timeframe.multiplier * ( timeframe.isseconds ? 1. / 60. : timeframe.isminutes ? 1. : timeframe.isdaily ? 1440. : timeframe.isweekly ? 10080. : timeframe.ismonthly ? 43800. : na) // ————— Returns resolution of _resolution period in minutes. f_tfResInMinutes(_resolution) => // _resolution: resolution of any TF (in "timeframe.period" string format). security(syminfo.tickerid, _resolution, f_resInMinutes()) // ————— Given current resolution, returns next step of HTF. f_resNextStep(_res) => // _res: current TF in fractional minutes. _res <= 1 ? "60" : _res <= 60 ? "1D" : _res <= 360 ? "3D" : _res <= 1440 ? "1W" : _res <= 10080 ? "1M" : "12M" // ————— Returns a multiple of current resolution as a string in "timeframe.period" format usable with "security()". f_multipleOfRes(_res, _mult) => // _res: current resolution in minutes, in the fractional format supplied by f_resInMinutes() companion function. // _mult: Multiple of current TF to be calculated. // Convert current float TF in minutes to target string TF in "timeframe.period" format. _targetResInMin = _res * max(_mult, 1) // Find best string to express the resolution. _targetResInMin <= 0.083 ? "5S" : _targetResInMin <= 0.251 ? "15S" : _targetResInMin <= 0.501 ? "30S" : _targetResInMin <= 1440 ? tostring(round(_targetResInMin)) : _targetResInMin <= 43800 ? tostring(round(min(_targetResInMin / 1440, 365))) + "D" : tostring(round(min(_targetResInMin / 43800, 12))) + "M" // ————— HTF calcs // Get current resolution in float minutes. var vResInMinutes = f_resInMinutes() stratRes = f_multipleOfRes(vResInMinutes, resMultiplier) // === BASE FUNCTIONS === // Returns MA input selection variant, default to SMA if blank or typo. variant(type, src, len, offSig, offALMA) => v1 = sma(src, len) // Simple v2 = ema(src, len) // Exponential v3 = 2 * v2 - ema(v2, len) // Double Exponential v4 = 3 * (v2 - ema(v2, len)) + ema(ema(v2, len), len) // Triple Exponential v5 = wma(src, len) // Weighted v6 = vwma(src, len) // Volume Weighted v7 = 0.0 v7 := na(v7[1]) ? sma(src, len) : (v7[1] * (len - 1) + src) / len // Smoothed v8 = wma(2 * wma(src, len / 2) - wma(src, len), round(sqrt(len))) // Hull v9 = linreg(src, len, offSig) // Least Squares v10 = alma(src, len, 0.85, 6) // Arnaud Legoux v11 = sma(v1,len) // Triangular (extreme smooth) // SuperSmoother filter // © 2013 John F. Ehlers a1 = exp(-1.414*3.14159 / len) b1 = 2*a1*cos(1.414*3.14159 / len) c2 = b1 c3 = (-a1)*a1 c1 = 1 - c2 - c3 v12 = 0.0 v12 := c1*(src + nz(src[1])) / 2 + c2*nz(v12[1]) + c3*nz(v12[2]) type=="EMA" ? v2 : type=="DEMA" ? v3 : type=="TEMA" ? v4 : type=="WMA" ? v5 : type=="VWMA" ? v6 : type=="SMMA" ? v7 : type=="HullMA" ? v8 : type=="LSMA" ? v9 : type=="ALMA" ? v10 : type=="TMA" ? v11: type=="SSMA" ? v12 : v1 atr = atr(Periods) // ==== Code for prevent 'repaint' === // security wrapper for repeat calls f_security( _id, _res, _exp, _non_rep) => security(_id, _res, _exp[_non_rep == 2 and barstate.isrealtime ? 1 : 0], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)[_non_rep >= 1 and barstate.isrealtime ? 1 : 0] // ====/Code for prevent 'repaint' === // === /BASE FUNCTIONS === // === SERIES SETUP === closeSeries = variant(basisType, close, basisLen, offsetSigma, offsetALMA) openSeries = variant(basisType, open, basisLen, offsetSigma, offsetALMA) // === /SERIES === // Get Alternate resolution Series if selected. closeSeriesAlt = f_security(syminfo.tickerid, stratRes, closeSeries, Non_Repainting) openSeriesAlt = f_security(syminfo.tickerid, stratRes, openSeries, Non_Repainting) // === PLOTTING === trendColour = (closeSeriesAlt > openSeriesAlt + Multiplier*atr) ? color.green : (closeSeriesAlt < openSeriesAlt - Multiplier*atr) ? color.red : color.yellow bcolour = (closeSeriesAlt > openSeriesAlt) ? color.green : color.red barcolor(scolor ? bcolour : na, title = "Bar Colours") closeP = plot(series= scolor and calcPeriod ? closeSeriesAlt : na, title = "Close Series", color = trendColour, linewidth = 2, style = plot.style_line, transp = 20) openP = plot(series= scolor and calcPeriod ? openSeriesAlt : na, title = "Open Series", color = trendColour, linewidth = 2, style = plot.style_line, transp = 20) fill(closeP,openP,color=trendColour,transp=80) if enableHighlight if highlightType == "Anchors" if useStartPeriodTime line.set_xy1(startAnchor, startPeriodTime, low) line.set_xy2(startAnchor, startPeriodTime, high) if useEndPeriodTime line.set_xy1(endAnchor, calcPeriod ? time : line.get_x1(endAnchor), low) line.set_xy2(endAnchor, calcPeriod ? time : line.get_x1(endAnchor), high) if highlightType == "Background" useBgcolor := true bgcolor(useBgcolor and calcPeriod ? highlightColor : na, editable = false) // plot "calcPeriod of time" // === /PLOTTING === // // // === STRATEGY conditions longCond = crossover( closeSeriesAlt, openSeriesAlt + Multiplier*atr) //Code to adjust sensitivity 'Multiplier*atr' shortCond = crossunder(closeSeriesAlt, openSeriesAlt - Multiplier*atr) //Code to adjust sensitivity 'Multiplier*atr' // === /STRATEGY conditions. // === STRATEGY === // stop loss slPoints = input(defval = 0, title = "Stop Loss Points (zero for disable)", group = "Stop Condition", minval = 0) tpPoints = input(defval = 0, title = "Target Profit Points (zero for disable)", group = "Stop Condition", minval = 0) //set up exit parameters TP = tpPoints>0?tpPoints:na SL = slPoints>0?slPoints:na // Make sure we are within the bar range, Set up entries and exit conditions if (calcPeriod and tradeType!="NONE") strategy.entry("long", strategy.long, when=longCond ==true and tradeType!="SHORT",comment = "buy" , alert_message = "Long") strategy.entry("short", strategy.short, when=shortCond==true and tradeType!="LONG", comment = "sell" , alert_message = "Short") strategy.close("long", when=shortCond==true and tradeType=="LONG", comment = "buy close" , alert_message = "Long close") strategy.close("short", when=longCond ==true and tradeType=="SHORT",comment = "sell close" , alert_message = "Short close") strategy.exit( "XL", from_entry = "long", profit = TP, loss = SL, comment = "XL long" , alert_message = "exit long") strategy.exit( "XS", from_entry = "short", profit = TP, loss = SL, comment = "XL short" , alert_message = "exit short") // === /STRATEGY === // eof /////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// // If you don't want a [screen label], comment or delete the line below all. // /////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ————— Function returning a string representation of a numeric `_val` using a special `_fmt` string allowing all strings to be of the same width, to help align columns of values. f_tostringPad(_val, _fmt) => // float _val: string to separate. // string _fmt: formatting string similar to those used in the `tostring()` format string, with "?" used to indicate padding, // e.g., "??0.00" to ensure that numbers always contain three characters left of the decimal point. // WARNING: A minus sign MUST begin the format ("-??0.00") if negative values are to be handled, otherwise negative values will have no minus sign. // Character used to pad numbers: Unicode figure space (U+2007). var string FIGURE_SPACE = " " // Character used to pad minus signs: Unicode punctuation space (U+2008). var string PUNCTUATION_SPACE = " " // Preliminary conversion of the value to a string. string _formattedVal = tostring(_val, _fmt) // Remove minus sign from format string. _formattedVal := str.replace_all(_formattedVal, "-", "") // Split value and format string into characters. string[] _chars = str.split(_formattedVal, "") string[] _charsFmt = str.split(_fmt, "") // Detect if we need to handle negative values, and if so, remove the minus sign from format. bool _handleNegs = array.get(_charsFmt, 0) == "-" if _handleNegs array.shift(_charsFmt) // Detect if value or format string are without a decimal point and if so, add a temporary one for our logic, which we'll remove later. int _pointPos = array.indexof(_chars, ".") int _pointPosFmt = array.indexof(_charsFmt, ".") bool _noPoint = _pointPos == -1 bool _noPointFmt = _pointPosFmt == -1 if _noPoint array.push(_chars, ".") _pointPos := array.indexof(_chars, ".") if _noPointFmt array.push(_charsFmt, ".") _pointPosFmt := array.indexof(_charsFmt, ".") // Remove extra instances of "?" in front of value. _extraChars = _pointPos - _pointPosFmt if _extraChars > 0 for _i = 0 to _extraChars - 1 array.shift(_chars) // Add minus sign or space if needed. if _handleNegs // Format accounts for negative values; insert minus sign or space. array.unshift(_chars, (_val < 0 ? "-" : PUNCTUATION_SPACE)) // Remove temporary decimal point if needed. if _noPointFmt or _noPoint array.pop(_chars) // Rejoin our array and replace the "?" chars left in our result with figure space padding. string _return = array.join(_chars, "") _return := str.replace_all(_return, "?", FIGURE_SPACE) f_rmDnC(_str, _space) => // string _str: string to separate. var string FIGURE_SPACE = " " string[] _chars = str.split(_str, "") int _len = array.size(_chars) int _ofPos = array.indexof(_chars, ":") string[] _substr = array.new_string(0) if _ofPos >= 0 and _ofPos < _len - 1 _substr := array.slice(_chars, _ofPos + 1, _len) if (_ofPos < 0 or _ofPos > _len - 1) and _len < _space for _i = _len to _space-1 array.push(_chars, FIGURE_SPACE) // array.insert(_chars, 0, FIGURE_SPACE) int _len2 = array.size(_substr) if (_ofPos >= 0 and _ofPos < _len - 1) and _len2 < _space for _i = _len2 to _space-1 array.push(_substr, FIGURE_SPACE) // array.insert(_substr, 0, FIGURE_SPACE) string _return = _ofPos >= 0 and _ofPos < _len - 1 ? array.join(_substr, "") : array.join(_chars, "") OCCmax(_id, _multiplier, _non_rep) => var Trend = 0 var Position = 0 var to_num = 0 var profit = 0.0 var changeRate = 0.0 var tm = 0 if _id == '' Trend := 0, Position := 0, profit := -99999999.9, changeRate := -99999999.9, tm := 0 else Trend := closeSeries[_non_rep == 2 and barstate.isrealtime ? 1 : 0] > (openSeries[_non_rep == 2 and barstate.isrealtime ? 1 : 0] + _multiplier * atr) ? 1 : closeSeries[_non_rep == 2 and barstate.isrealtime ? 1 : 0] < (openSeries[_non_rep == 2 and barstate.isrealtime ? 1 : 0] - _multiplier * atr) ? -1 : 0 Position := Trend != 0 ? Trend : Position[1] to_num := 0 for i = 1 to 4999 to_num := to_num + 1 if Position[i] != Position[0] break profit := 100.0 * (close[0] - close[to_num]) / close[to_num] tm := to_num * resMultiplier changeRate := 100.0 * profit / (tm * vResInMinutes) [Trend, Position, profit, changeRate, tm] ////////////////////////////////////////////////////////////////////////////////////////////// // If you want to reduce the input space, adjust the 'array_size'. // // And comment the id number as many as you want from the line below. // // 'array_size' is 1 larger than the 'ID number'. array_size cannot be greater than 38. // ////////////////////////////////////////////////////////////////////////////////////////////// array_size = 38 var id_ = array.new_string(array_size), var t_ = array.new_int(array_size), var p_ = array.new_int(array_size) var pr_ = array.new_float(array_size), var cr_ = array.new_float(array_size), var tm_ = array.new_int(array_size) id00 = syminfo.tickerid , [t00, p00, pr00, cr00, tm00] = security(id00, stratRes, OCCmax(id00, Multiplier, Non_Repainting)), array.set(id_, 0, f_rmDnC(id00, 8)), array.set(t_, 0, t00), array.set(p_, 0, p00), array.set(pr_, 0, pr00), array.set(cr_, 0, cr00), array.set(tm_, 0, tm00) id01 = input('', title='Symbol 01',type=input.symbol, group = "Inputs to view trends"), [t01, p01, pr01, cr01, tm01] = security(id01, stratRes, OCCmax(id01, Multiplier, Non_Repainting)), array.set(id_, 1, f_rmDnC(id01, 8)), array.set(t_, 1, t01), array.set(p_, 1, p01), array.set(pr_, 1, pr01), array.set(cr_, 1, cr01), array.set(tm_, 1, tm01) id02 = input('', title='Symbol 02',type=input.symbol, group = "Inputs to view trends"), [t02, p02, pr02, cr02, tm02] = security(id02, stratRes, OCCmax(id02, Multiplier, Non_Repainting)), array.set(id_, 2, f_rmDnC(id02, 8)), array.set(t_, 2, t02), array.set(p_, 2, p02), array.set(pr_, 2, pr02), array.set(cr_, 2, cr02), array.set(tm_, 2, tm02) id03 = input('', title='Symbol 03',type=input.symbol, group = "Inputs to view trends"), [t03, p03, pr03, cr03, tm03] = security(id03, stratRes, OCCmax(id03, Multiplier, Non_Repainting)), array.set(id_, 3, f_rmDnC(id03, 8)), array.set(t_, 3, t03), array.set(p_, 3, p03), array.set(pr_, 3, pr03), array.set(cr_, 3, cr03), array.set(tm_, 3, tm03) id04 = input('', title='Symbol 04',type=input.symbol, group = "Inputs to view trends"), [t04, p04, pr04, cr04, tm04] = security(id04, stratRes, OCCmax(id04, Multiplier, Non_Repainting)), array.set(id_, 4, f_rmDnC(id04, 8)), array.set(t_, 4, t04), array.set(p_, 4, p04), array.set(pr_, 4, pr04), array.set(cr_, 4, cr04), array.set(tm_, 4, tm04) id05 = input('', title='Symbol 05',type=input.symbol, group = "Inputs to view trends"), [t05, p05, pr05, cr05, tm05] = security(id05, stratRes, OCCmax(id05, Multiplier, Non_Repainting)), array.set(id_, 5, f_rmDnC(id05, 8)), array.set(t_, 5, t05), array.set(p_, 5, p05), array.set(pr_, 5, pr05), array.set(cr_, 5, cr05), array.set(tm_, 5, tm05) id06 = input('', title='Symbol 06',type=input.symbol, group = "Inputs to view trends"), [t06, p06, pr06, cr06, tm06] = security(id06, stratRes, OCCmax(id06, Multiplier, Non_Repainting)), array.set(id_, 6, f_rmDnC(id06, 8)), array.set(t_, 6, t06), array.set(p_, 6, p06), array.set(pr_, 6, pr06), array.set(cr_, 6, cr06), array.set(tm_, 6, tm06) id07 = input('', title='Symbol 07',type=input.symbol, group = "Inputs to view trends"), [t07, p07, pr07, cr07, tm07] = security(id07, stratRes, OCCmax(id07, Multiplier, Non_Repainting)), array.set(id_, 7, f_rmDnC(id07, 8)), array.set(t_, 7, t07), array.set(p_, 7, p07), array.set(pr_, 7, pr07), array.set(cr_, 7, cr07), array.set(tm_, 7, tm07) id08 = input('', title='Symbol 08',type=input.symbol, group = "Inputs to view trends"), [t08, p08, pr08, cr08, tm08] = security(id08, stratRes, OCCmax(id08, Multiplier, Non_Repainting)), array.set(id_, 8, f_rmDnC(id08, 8)), array.set(t_, 8, t08), array.set(p_, 8, p08), array.set(pr_, 8, pr08), array.set(cr_, 8, cr08), array.set(tm_, 8, tm08) id09 = input('', title='Symbol 09',type=input.symbol, group = "Inputs to view trends"), [t09, p09, pr09, cr09, tm09] = security(id09, stratRes, OCCmax(id09, Multiplier, Non_Repainting)), array.set(id_, 9, f_rmDnC(id09, 8)), array.set(t_, 9, t09), array.set(p_, 9, p09), array.set(pr_, 9, pr09), array.set(cr_, 9, cr09), array.set(tm_, 9, tm09) id10 = input('', title='Symbol 10',type=input.symbol, group = "Inputs to view trends"), [t10, p10, pr10, cr10, tm10] = security(id10, stratRes, OCCmax(id10, Multiplier, Non_Repainting)), array.set(id_, 10, f_rmDnC(id10, 8)), array.set(t_, 10, t10), array.set(p_, 10, p10), array.set(pr_, 10, pr10), array.set(cr_, 10, cr10), array.set(tm_, 10, tm10) id11 = input('', title='Symbol 11',type=input.symbol, group = "Inputs to view trends"), [t11, p11, pr11, cr11, tm11] = security(id11, stratRes, OCCmax(id11, Multiplier, Non_Repainting)), array.set(id_, 11, f_rmDnC(id11, 8)), array.set(t_, 11, t11), array.set(p_, 11, p11), array.set(pr_, 11, pr11), array.set(cr_, 11, cr11), array.set(tm_, 11, tm11) id12 = input('', title='Symbol 12',type=input.symbol, group = "Inputs to view trends"), [t12, p12, pr12, cr12, tm12] = security(id12, stratRes, OCCmax(id12, Multiplier, Non_Repainting)), array.set(id_, 12, f_rmDnC(id12, 8)), array.set(t_, 12, t12), array.set(p_, 12, p12), array.set(pr_, 12, pr12), array.set(cr_, 12, cr12), array.set(tm_, 12, tm12) id13 = input('', title='Symbol 13',type=input.symbol, group = "Inputs to view trends"), [t13, p13, pr13, cr13, tm13] = security(id13, stratRes, OCCmax(id13, Multiplier, Non_Repainting)), array.set(id_, 13, f_rmDnC(id13, 8)), array.set(t_, 13, t13), array.set(p_, 13, p13), array.set(pr_, 13, pr13), array.set(cr_, 13, cr13), array.set(tm_, 13, tm13) id14 = input('', title='Symbol 14',type=input.symbol, group = "Inputs to view trends"), [t14, p14, pr14, cr14, tm14] = security(id14, stratRes, OCCmax(id14, Multiplier, Non_Repainting)), array.set(id_, 14, f_rmDnC(id14, 8)), array.set(t_, 14, t14), array.set(p_, 14, p14), array.set(pr_, 14, pr14), array.set(cr_, 14, cr14), array.set(tm_, 14, tm14) id15 = input('', title='Symbol 15',type=input.symbol, group = "Inputs to view trends"), [t15, p15, pr15, cr15, tm15] = security(id15, stratRes, OCCmax(id15, Multiplier, Non_Repainting)), array.set(id_, 15, f_rmDnC(id15, 8)), array.set(t_, 15, t15), array.set(p_, 15, p15), array.set(pr_, 15, pr15), array.set(cr_, 15, cr15), array.set(tm_, 15, tm15) id16 = input('', title='Symbol 16',type=input.symbol, group = "Inputs to view trends"), [t16, p16, pr16, cr16, tm16] = security(id16, stratRes, OCCmax(id16, Multiplier, Non_Repainting)), array.set(id_, 16, f_rmDnC(id16, 8)), array.set(t_, 16, t16), array.set(p_, 16, p16), array.set(pr_, 16, pr16), array.set(cr_, 16, cr16), array.set(tm_, 16, tm16) id17 = input('', title='Symbol 17',type=input.symbol, group = "Inputs to view trends"), [t17, p17, pr17, cr17, tm17] = security(id17, stratRes, OCCmax(id17, Multiplier, Non_Repainting)), array.set(id_, 17, f_rmDnC(id17, 8)), array.set(t_, 17, t17), array.set(p_, 17, p17), array.set(pr_, 17, pr17), array.set(cr_, 17, cr17), array.set(tm_, 17, tm17) id18 = input('', title='Symbol 18',type=input.symbol, group = "Inputs to view trends"), [t18, p18, pr18, cr18, tm18] = security(id18, stratRes, OCCmax(id18, Multiplier, Non_Repainting)), array.set(id_, 18, f_rmDnC(id18, 8)), array.set(t_, 18, t18), array.set(p_, 18, p18), array.set(pr_, 18, pr18), array.set(cr_, 18, cr18), array.set(tm_, 18, tm18) id19 = input('', title='Symbol 19',type=input.symbol, group = "Inputs to view trends"), [t19, p19, pr19, cr19, tm19] = security(id19, stratRes, OCCmax(id19, Multiplier, Non_Repainting)), array.set(id_, 19, f_rmDnC(id19, 8)), array.set(t_, 19, t19), array.set(p_, 19, p19), array.set(pr_, 19, pr19), array.set(cr_, 19, cr19), array.set(tm_, 19, tm19) id20 = input('', title='Symbol 20',type=input.symbol, group = "Inputs to view trends"), [t20, p20, pr20, cr20, tm20] = security(id20, stratRes, OCCmax(id20, Multiplier, Non_Repainting)), array.set(id_, 20, f_rmDnC(id20, 8)), array.set(t_, 20, t20), array.set(p_, 20, p20), array.set(pr_, 20, pr20), array.set(cr_, 20, cr20), array.set(tm_, 20, tm20) id21 = input('', title='Symbol 21',type=input.symbol, group = "Inputs to view trends"), [t21, p21, pr21, cr21, tm21] = security(id21, stratRes, OCCmax(id21, Multiplier, Non_Repainting)), array.set(id_, 21, f_rmDnC(id21, 8)), array.set(t_, 21, t21), array.set(p_, 21, p21), array.set(pr_, 21, pr21), array.set(cr_, 21, cr21), array.set(tm_, 21, tm21) id22 = input('', title='Symbol 22',type=input.symbol, group = "Inputs to view trends"), [t22, p22, pr22, cr22, tm22] = security(id22, stratRes, OCCmax(id22, Multiplier, Non_Repainting)), array.set(id_, 22, f_rmDnC(id22, 8)), array.set(t_, 22, t22), array.set(p_, 22, p22), array.set(pr_, 22, pr22), array.set(cr_, 22, cr22), array.set(tm_, 22, tm22) id23 = input('', title='Symbol 23',type=input.symbol, group = "Inputs to view trends"), [t23, p23, pr23, cr23, tm23] = security(id23, stratRes, OCCmax(id23, Multiplier, Non_Repainting)), array.set(id_, 23, f_rmDnC(id23, 8)), array.set(t_, 23, t23), array.set(p_, 23, p23), array.set(pr_, 23, pr23), array.set(cr_, 23, cr23), array.set(tm_, 23, tm23) id24 = input('', title='Symbol 24',type=input.symbol, group = "Inputs to view trends"), [t24, p24, pr24, cr24, tm24] = security(id24, stratRes, OCCmax(id24, Multiplier, Non_Repainting)), array.set(id_, 24, f_rmDnC(id24, 8)), array.set(t_, 24, t24), array.set(p_, 24, p24), array.set(pr_, 24, pr24), array.set(cr_, 24, cr24), array.set(tm_, 24, tm24) id25 = input('', title='Symbol 25',type=input.symbol, group = "Inputs to view trends"), [t25, p25, pr25, cr25, tm25] = security(id25, stratRes, OCCmax(id25, Multiplier, Non_Repainting)), array.set(id_, 25, f_rmDnC(id25, 8)), array.set(t_, 25, t25), array.set(p_, 25, p25), array.set(pr_, 25, pr25), array.set(cr_, 25, cr25), array.set(tm_, 25, tm25) id26 = input('', title='Symbol 26',type=input.symbol, group = "Inputs to view trends"), [t26, p26, pr26, cr26, tm26] = security(id26, stratRes, OCCmax(id26, Multiplier, Non_Repainting)), array.set(id_, 26, f_rmDnC(id26, 8)), array.set(t_, 26, t26), array.set(p_, 26, p26), array.set(pr_, 26, pr26), array.set(cr_, 26, cr26), array.set(tm_, 26, tm26) id27 = input('', title='Symbol 27',type=input.symbol, group = "Inputs to view trends"), [t27, p27, pr27, cr27, tm27] = security(id27, stratRes, OCCmax(id27, Multiplier, Non_Repainting)), array.set(id_, 27, f_rmDnC(id27, 8)), array.set(t_, 27, t27), array.set(p_, 27, p27), array.set(pr_, 27, pr27), array.set(cr_, 27, cr27), array.set(tm_, 27, tm27) id28 = input('', title='Symbol 28',type=input.symbol, group = "Inputs to view trends"), [t28, p28, pr28, cr28, tm28] = security(id28, stratRes, OCCmax(id28, Multiplier, Non_Repainting)), array.set(id_, 28, f_rmDnC(id28, 8)), array.set(t_, 28, t28), array.set(p_, 28, p28), array.set(pr_, 28, pr28), array.set(cr_, 28, cr28), array.set(tm_, 28, tm28) id29 = input('', title='Symbol 29',type=input.symbol, group = "Inputs to view trends"), [t29, p29, pr29, cr29, tm29] = security(id29, stratRes, OCCmax(id29, Multiplier, Non_Repainting)), array.set(id_, 29, f_rmDnC(id29, 8)), array.set(t_, 29, t29), array.set(p_, 29, p29), array.set(pr_, 29, pr29), array.set(cr_, 29, cr29), array.set(tm_, 29, tm29) id30 = input('', title='Symbol 30',type=input.symbol, group = "Inputs to view trends"), [t30, p30, pr30, cr30, tm30] = security(id30, stratRes, OCCmax(id30, Multiplier, Non_Repainting)), array.set(id_, 30, f_rmDnC(id30, 8)), array.set(t_, 30, t30), array.set(p_, 30, p30), array.set(pr_, 30, pr30), array.set(cr_, 30, cr30), array.set(tm_, 30, tm30) id31 = input('', title='Symbol 31',type=input.symbol, group = "Inputs to view trends"), [t31, p31, pr31, cr31, tm31] = security(id31, stratRes, OCCmax(id31, Multiplier, Non_Repainting)), array.set(id_, 31, f_rmDnC(id31, 8)), array.set(t_, 31, t31), array.set(p_, 31, p31), array.set(pr_, 31, pr31), array.set(cr_, 31, cr31), array.set(tm_, 31, tm31) id32 = input('', title='Symbol 32',type=input.symbol, group = "Inputs to view trends"), [t32, p32, pr32, cr32, tm32] = security(id32, stratRes, OCCmax(id32, Multiplier, Non_Repainting)), array.set(id_, 32, f_rmDnC(id32, 8)), array.set(t_, 32, t32), array.set(p_, 32, p32), array.set(pr_, 32, pr32), array.set(cr_, 32, cr32), array.set(tm_, 32, tm32) id33 = input('', title='Symbol 33',type=input.symbol, group = "Inputs to view trends"), [t33, p33, pr33, cr33, tm33] = security(id33, stratRes, OCCmax(id33, Multiplier, Non_Repainting)), array.set(id_, 33, f_rmDnC(id33, 8)), array.set(t_, 33, t33), array.set(p_, 33, p33), array.set(pr_, 33, pr33), array.set(cr_, 33, cr33), array.set(tm_, 33, tm33) id34 = input('', title='Symbol 34',type=input.symbol, group = "Inputs to view trends"), [t34, p34, pr34, cr34, tm34] = security(id34, stratRes, OCCmax(id34, Multiplier, Non_Repainting)), array.set(id_, 34, f_rmDnC(id34, 8)), array.set(t_, 34, t34), array.set(p_, 34, p34), array.set(pr_, 34, pr34), array.set(cr_, 34, cr34), array.set(tm_, 34, tm34) id35 = input('', title='Symbol 35',type=input.symbol, group = "Inputs to view trends"), [t35, p35, pr35, cr35, tm35] = security(id35, stratRes, OCCmax(id35, Multiplier, Non_Repainting)), array.set(id_, 35, f_rmDnC(id35, 8)), array.set(t_, 35, t35), array.set(p_, 35, p35), array.set(pr_, 35, pr35), array.set(cr_, 35, cr35), array.set(tm_, 35, tm35) id36 = input('', title='Symbol 36',type=input.symbol, group = "Inputs to view trends"), [t36, p36, pr36, cr36, tm36] = security(id36, stratRes, OCCmax(id36, Multiplier, Non_Repainting)), array.set(id_, 36, f_rmDnC(id36, 8)), array.set(t_, 36, t36), array.set(p_, 36, p36), array.set(pr_, 36, pr36), array.set(cr_, 36, cr36), array.set(tm_, 36, tm36) id37 = input('', title='Symbol 37',type=input.symbol, group = "Inputs to view trends"), [t37, p37, pr37, cr37, tm37] = security(id37, stratRes, OCCmax(id37, Multiplier, Non_Repainting)), array.set(id_, 37, f_rmDnC(id37, 8)), array.set(t_, 37, t37), array.set(p_, 37, p37), array.set(pr_, 37, pr37), array.set(cr_, 37, cr37), array.set(tm_, 37, tm37) scr_label = '[ Confirmed Reversal: ]\n' pot_label = '[ Potential Reversal: ]\n' up_label = '[ Uptrend: Profit %, CgRate Bars ]\n' dn_label = '[ Downtrend: ]\n' // { sorting start if sort_by == "Profit" up_label := up_label + '|         -----------           | \n' if sort_by == "Change Rate" up_label := up_label + '|                 ---------    | \n' if sort_by == "None" up_label := up_label + '|                           | \n' arrayForSort = array.new_float(array_size, 0.0) if sort_by == "Profit" arrayForSort := array.copy(pr_) if sort_by == "Change Rate" arrayForSort := array.copy(cr_) array.sort(arrayForSort, order.descending) var not_blank = 0 not_blank := 0 for i = 0 to array_size-1 if array.get(id_, i)[0] == "       " break not_blank := not_blank + 1 var sorted_index = 0 var stock_info = '' // {for id00 syminfo.tickerid stock_info := array.get(id_, 0)[0] + ' ' + f_tostringPad(array.get(pr_, 0)[0], "-??0.00") + ' ' + f_tostringPad(array.get(cr_, 0)[0], "-?0.00") + f_tostringPad(array.get(tm_, 0)[0], "????0") + '\n' scr_label := array.get(p_, 0)[0] != array.get(p_, 0)[1] and array.get(t_, 0)[0] != 0 ? scr_label + stock_info : scr_label pot_label := array.get(t_, 0)[0] == 0 ? pot_label + stock_info : pot_label up_label := array.get(t_, 0)[0] == 1 ? up_label + stock_info : up_label dn_label := array.get(t_, 0)[0] == -1 ? dn_label + stock_info : dn_label // }for id00 syminfo.tickerid for i = 0 to not_blank-1 if sort_by == "Profit" sorted_index := array.indexof(pr_, array.get(arrayForSort, i)[0]) != -1 ? array.indexof(pr_, array.get(arrayForSort, i)[0]) : 0 if sort_by == "Change Rate" sorted_index := array.indexof(cr_, array.get(arrayForSort, i)[0]) != -1 ? array.indexof(cr_, array.get(arrayForSort, i)[0]) : 0 if sort_by == "None" sorted_index := i stock_info := array.get(id_, sorted_index)[0] + ' ' + f_tostringPad(array.get(pr_, sorted_index)[0], "-??0.00") + ' ' + f_tostringPad(array.get(cr_, sorted_index)[0], "-?0.00") + f_tostringPad(array.get(tm_, sorted_index)[0], "????0") + '\n' scr_label := array.get(p_, sorted_index)[0] != array.get(p_, sorted_index)[1] and array.get(t_, sorted_index)[0] != 0 ? scr_label + stock_info : scr_label pot_label := array.get(t_, sorted_index)[0] == 0 ? pot_label + stock_info : pot_label up_label := array.get(t_, sorted_index)[0] == 1 ? up_label + stock_info : up_label dn_label := array.get(t_, sorted_index)[0] == -1 ? dn_label + stock_info : dn_label // } sorting end f_colorscr (_valscr ) => _valscr ? #00000000 : na f_printscr (_txtscr ) => var _lblscr = label(na), label.delete(_lblscr ), _lblscr := label.new( time + (time-time[1])*posX_scr, ohlc4[posY_scr], _txtscr, xloc.bar_time, yloc.price, f_colorscr ( showLabel ), // textcolor = showLabel ? col : na, textcolor = showLabel ? textColor : na, size = size.normal, style = label.style_label_center, textalign = text.align_right ) f_printscr ( scr_label + '\n' + pot_label +'\n' + up_label + '\n' + dn_label)