Pine Script v4 · Strategy
1St Bar GAP+BkOut Screener v2 by RM
A Pine Script v4 strategy built on Valuewhen ('D', high) and Change (bar_date_ts). It has 0 order rules and no entry of its own. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 26 settings; defaults include Font size Normal, Table Position top_right and S01 AAPL.
Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.
- Does 1St Bar GAP+BkOut Screener v2 by RM repaint?
- Yes
- At least one pattern in the source can repaint: higher-timeframe data.
- How did 1St Bar GAP+BkOut Screener v2 by RM do on BTCUSDT 1D with default settings?
- Not measured
- It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its code limits trading to a date window, which can leave this period out. It closed no trades on the other markets either. A backtest, not investment advice.
- Can 1St Bar GAP+BkOut Screener v2 by RM be converted to Pine Script v5?
- No
- The automatic step from v4 to v5 gives a script that does not run in v5 (Pine Script v5 Error at @L129:C17: No value assigned to the `transp` parameter in color.new()), so no v5 download is offered; the edits are shown below.
- Does 1St Bar GAP+BkOut Screener v2 by RM use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does 1St Bar GAP+BkOut Screener v2 by RM run in Zeal Terminal?
- Yes
- It compiles in 274 ms and runs 1,000 bars in 181 ms, in the browser.
BTCUSDT · 1D · default settings
- Plot
- Plot
- Winning trade
- Losing trade
- Equity
- Buy and hold
Needs AAPL D data, not available: not a Binance spot market Needs BIDU D data, not available: not a Binance spot market Needs AMD D data, not available: not a Binance spot market Needs TAN D data, not available: not a Binance spot market Needs BABA D data, not available: not a Binance spot market Needs BILL D data, not available: not a Binance spot market Needs MSFT D data, not available: not a Binance spot market Needs PFE D data, not available: not a Binance spot market Needs BHVN D data, not available: not a Binance spot market Needs T D data, not available: not a Binance spot market Needs NVAX D data, not available: not a Binance spot market Needs NVDA D data, not available: not a Binance spot market Needs FB D data, not available: not a Binance spot market Needs PTON D data, not available: not a Binance spot market Needs RIOT D data, not available: not a Binance spot market Needs QCOM D data, not available: not a Binance spot market Needs ROKU D data, not available: not a Binance spot market Needs FUBO D data, not available: not a Binance spot market Needs WISH D data, not available: not a Binance spot market Needs WKHS D data, not available: not a Binance spot market Values that depend on it are empty on this chart.
| Opening(D) Gap: |
- Net profit
- 0.00%
- $0.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 0
- 0 won · 0 lost
- Profitable
- 0.0%
- of closed trades
- Profit factor
- —
- gross profit ÷ gross loss
- Max drawdown
- 0.00%
- $0.00
One run with the author's default settings, $100,000 starting capital, commission as the script sets it. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.
Review
What a careful reader of this script would point out, found by checking the source and the backtest.
-
Check
No stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
Check
No commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Note
20 settings have no label
In the settings dialog s01 (line 69), s02 (line 70), s03 (line 71), s04 (line 72), s05 (line 73), s06 (line 74), s07 (line 75), s08 (line 76), s09 (line 77), s10 (line 78), s11 (line 79), s12 (line 80), s13 (line 81), s14 (line 82), s15 (line 83), s16 (line 84), s17 (line 85), s18 (line 86), s19 (line 87), s20 (line 88) show an empty name. The labels on this page come from the variable names.
-
Note
No slippage
Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.
-
Note
Uses transp =, which v5 removed line 129
transp = on line 129. v5 folds the transparency into the colour with color.new(c, transp).
Upgrade and export
Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.
- Upgrading to v5 renames change → ta.change, security → request.security, valuewhen → ta.valuewhen, tostring → str.tostring, barssince → ta.barssince.
v4 → v5
DiffersThe v5 version does not run in Zeal Terminal's engine: Pine Script v5 Error at @L129:C17: No value assigned to the `transp` parameter in color.new()
- Line 32: //@version=4 → //@version=5
- Line 34: input(type = input.resolution) → input.timeframe()
- Line 35: input(type = input.bool) → input.bool()
- Line 36: input(type = input.bool) → input.bool()
- Line 37: input(type = input.bool) → input.bool()
- Line 69: input(type = input.string) → input.string()
62 more edits
- Line 70: input(type = input.string) → input.string()
- Line 71: input(type = input.string) → input.string()
- Line 72: input(type = input.string) → input.string()
- Line 73: input(type = input.string) → input.string()
- Line 74: input(type = input.string) → input.string()
- Line 75: input(type = input.string) → input.string()
- Line 76: input(type = input.string) → input.string()
- Line 77: input(type = input.string) → input.string()
- Line 78: input(type = input.string) → input.string()
- Line 79: input(type = input.string) → input.string()
- Line 80: input(type = input.string) → input.string()
- Line 81: input(type = input.string) → input.string()
- Line 82: input(type = input.string) → input.string()
- Line 83: input(type = input.string) → input.string()
- Line 84: input(type = input.string) → input.string()
- Line 85: input(type = input.string) → input.string()
- Line 86: input(type = input.string) → input.string()
- Line 87: input(type = input.string) → input.string()
- Line 88: input(type = input.string) → input.string()
- Line 92: change → ta.change
- Line 96: change → ta.change
- Line 98: security → request.security
- Line 99: security → request.security
- Line 100: security(resolution = …) → timeframe = …
- Line 102: security → request.security
- Line 103: security(resolution = …) → timeframe = …
- Line 107: valuewhen → ta.valuewhen
- Line 108: valuewhen → ta.valuewhen
- Line 122: change → ta.change
- Line 123: valuewhen → ta.valuewhen
- Line 124: valuewhen → ta.valuewhen
- Line 129: transp = trans1 removed: the call sets no colour to fold it into, so its default colour loses the transparency
- Line 135: tr → ta.tr
- Line 135: tr → ta.tr
- Line 141: security → request.security
- Line 142: security → request.security
- Line 143: security → request.security
- Line 144: security → request.security
- Line 145: security → request.security
- Line 146: security → request.security
- Line 147: security → request.security
- Line 148: security → request.security
- Line 149: security → request.security
- Line 150: security → request.security
- Line 151: security → request.security
- Line 152: security → request.security
- Line 153: security → request.security
- Line 154: security → request.security
- Line 155: security → request.security
- Line 156: security → request.security
- Line 157: security → request.security
- Line 158: security → request.security
- Line 159: security → request.security
- Line 160: security → request.security
- Line 169: tostring → str.tostring
- Line 192: barssince → ta.barssince
- Line 195: barssince → ta.barssince
- Line 221: barssince → ta.barssince
- Line 223: barssince → ta.barssince
- Line 249: barssince → ta.barssince
- Line 250: barssince → ta.barssince
- Line 276: barssince → ta.barssince
⋯//-//@version=4+//@version=5strategy("1St Bar GAP+BkOut Screener v2 by RM", shorttitle = '1Bar Gap+BkOut v2 by RM ', overlay = true)-res = input("", title="input timeframe for the screener" , type = input.resolution)+res = input.timeframe("", title="input timeframe for the screener" )-high_show = input(defval = true , title = "Show 1st Bar High" , type = input.bool)+high_show = input.bool(defval = true , title = "Show 1st Bar High" )-low_show = input(defval = true , title = "Show 1st Bar Low" , type = input.bool)+low_show = input.bool(defval = true , title = "Show 1st Bar Low" )-barNumber = input(defval = false , title = "Show Bar Numbers", type = input.bool)+barNumber = input.bool(defval = false , title = "Show Bar Numbers")input_font = input("Normal", "Font size", options = ["Large" ,"Normal", "Small"])⋯// Symbols _ Use Power Query in Excel-s01 = input( "AAPL" , type=input.string)+s01 = input.string( "AAPL" )-s02 = input( "BIDU" , type=input.string)+s02 = input.string( "BIDU" )-s03 = input( "AMD " , type=input.string)+s03 = input.string( "AMD " )-s04 = input( "TAN " , type=input.string)+s04 = input.string( "TAN " )-s05 = input( "BABA" , type=input.string)+s05 = input.string( "BABA" )-s06 = input( "BILL" , type=input.string)+s06 = input.string( "BILL" )-s07 = input( "MSFT" , type=input.string)+s07 = input.string( "MSFT" )-s08 = input( "PFE" , type=input.string)+s08 = input.string( "PFE" )-s09 = input( "BHVN" , type=input.string)+s09 = input.string( "BHVN" )-s10 = input( "T " , type=input.string)+s10 = input.string( "T " )-s11 = input( "NVAX" , type=input.string)+s11 = input.string( "NVAX" )-s12 = input( "NVDA" , type=input.string)+s12 = input.string( "NVDA" )-s13 = input( "FB " , type=input.string)+s13 = input.string( "FB " )-s14 = input( "PTON" , type=input.string)+s14 = input.string( "PTON" )-s15 = input( "RIOT" , type=input.string)+s15 = input.string( "RIOT" )-s16 = input( "QCOM" , type=input.string)+s16 = input.string( "QCOM" )-s17 = input( "ROKU" , type=input.string)+s17 = input.string( "ROKU" )-s18 = input( "FUBO" , type=input.string)+s18 = input.string( "FUBO" )-s19 = input( "WISH" , type=input.string)+s19 = input.string( "WISH" )-s20 = input( "WKHS" , type=input.string)+s20 = input.string( "WKHS" )// FUNCTIONS //⋯ d = time("W", sess)- change(d) != 0 ? true : na+ ta.change(d) != 0 ? true : na ⋯ t = time(res)- change(t) != 0 ? true : na+ ta.change(t) != 0 ? true : na -adopt(r, s) => security(syminfo.tickerid, r, s)+adopt(r, s) => request.security(syminfo.tickerid, r, s)-f_get_h(back, res) => O = security(symbol = syminfo.tickerid, +f_get_h(back, res) => O = request.security(symbol = syminfo.tickerid, - resolution = res, + timeframe = res, expression = high[back], gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_on)-f_get_l(back, res) => O = security(symbol = syminfo.tickerid, +f_get_l(back, res) => O = request.security(symbol = syminfo.tickerid, - resolution = res, + timeframe = res, expression = low[back], gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_on)⋯gapScreenerFunc() => - high_rangeL = valuewhen(is_newbar('D'),high,0) + high_rangeL = ta.valuewhen(is_newbar('D'),high,0) - low_rangeL = valuewhen(is_newbar('D'),low,0) + low_rangeL = ta.valuewhen(is_newbar('D'),low,0) upGap = low > high[1] ⋯bar_date_ts = timestamp(year(time),month(time),dayofmonth(time),0,0,0)-is_new_date = change(bar_date_ts) +is_new_date = ta.change(bar_date_ts) -high_1st = valuewhen(is_newbar('D'),high,0) +high_1st = ta.valuewhen(is_newbar('D'),high,0) -low_1st = valuewhen(is_newbar('D'),low,0) +low_1st = ta.valuewhen(is_newbar('D'),low,0) RoundCounter = 0⋯trans1 = high_show or low_show ? 95 : 100-fill(up1, down1, color.new (c_white, transp=trans1)) +fill(up1, down1, color.new (c_white)) // bar counter⋯vLine(BarIndex, Color, LineStyle) =>- Line = line.new(x1= BarIndex, y1= low - tr * 5, x2= BarIndex, y2= high + tr * 5, xloc= xloc.bar_index, color=Color, style= LineStyle)+ Line = line.new(x1= BarIndex, y1= low - ta.tr * 5, x2= BarIndex, y2= high + ta.tr * 5, xloc= xloc.bar_index, color=Color, style= LineStyle) ⋯ -[insB01, Gap01, upG_01, dnG_01, c_Up01, c_Dn01] = security(s01, res,gapScreenerFunc())+[insB01, Gap01, upG_01, dnG_01, c_Up01, c_Dn01] = request.security(s01, res,gapScreenerFunc())-[insB02, Gap02, upG_02, dnG_02, c_Up02, c_Dn02] = security(s02, res,gapScreenerFunc())+[insB02, Gap02, upG_02, dnG_02, c_Up02, c_Dn02] = request.security(s02, res,gapScreenerFunc())-[insB03, Gap03, upG_03, dnG_03, c_Up03, c_Dn03] = security(s03, res,gapScreenerFunc())+[insB03, Gap03, upG_03, dnG_03, c_Up03, c_Dn03] = request.security(s03, res,gapScreenerFunc())-[insB04, Gap04, upG_04, dnG_04, c_Up04, c_Dn04] = security(s04, res,gapScreenerFunc())+[insB04, Gap04, upG_04, dnG_04, c_Up04, c_Dn04] = request.security(s04, res,gapScreenerFunc())-[insB05, Gap05, upG_05, dnG_05, c_Up05, c_Dn05] = security(s05, res,gapScreenerFunc())+[insB05, Gap05, upG_05, dnG_05, c_Up05, c_Dn05] = request.security(s05, res,gapScreenerFunc())-[insB06, Gap06, upG_06, dnG_06, c_Up06, c_Dn06] = security(s06, res,gapScreenerFunc())+[insB06, Gap06, upG_06, dnG_06, c_Up06, c_Dn06] = request.security(s06, res,gapScreenerFunc())-[insB07, Gap07, upG_07, dnG_07, c_Up07, c_Dn07] = security(s07, res,gapScreenerFunc())+[insB07, Gap07, upG_07, dnG_07, c_Up07, c_Dn07] = request.security(s07, res,gapScreenerFunc())-[insB08, Gap08, upG_08, dnG_08, c_Up08, c_Dn08] = security(s08, res,gapScreenerFunc())+[insB08, Gap08, upG_08, dnG_08, c_Up08, c_Dn08] = request.security(s08, res,gapScreenerFunc())-[insB09, Gap09, upG_09, dnG_09, c_Up09, c_Dn09] = security(s09, res,gapScreenerFunc())+[insB09, Gap09, upG_09, dnG_09, c_Up09, c_Dn09] = request.security(s09, res,gapScreenerFunc())-[insB10, Gap10, upG_10, dnG_10, c_Up10, c_Dn10] = security(s10, res,gapScreenerFunc())+[insB10, Gap10, upG_10, dnG_10, c_Up10, c_Dn10] = request.security(s10, res,gapScreenerFunc())-[insB11, Gap11, upG_11, dnG_11, c_Up11, c_Dn11] = security(s11, res,gapScreenerFunc())+[insB11, Gap11, upG_11, dnG_11, c_Up11, c_Dn11] = request.security(s11, res,gapScreenerFunc())-[insB12, Gap12, upG_12, dnG_12, c_Up12, c_Dn12] = security(s12, res,gapScreenerFunc())+[insB12, Gap12, upG_12, dnG_12, c_Up12, c_Dn12] = request.security(s12, res,gapScreenerFunc())-[insB13, Gap13, upG_13, dnG_13, c_Up13, c_Dn13] = security(s13, res,gapScreenerFunc())+[insB13, Gap13, upG_13, dnG_13, c_Up13, c_Dn13] = request.security(s13, res,gapScreenerFunc())-[insB14, Gap14, upG_14, dnG_14, c_Up14, c_Dn14] = security(s14, res,gapScreenerFunc())+[insB14, Gap14, upG_14, dnG_14, c_Up14, c_Dn14] = request.security(s14, res,gapScreenerFunc())-[insB15, Gap15, upG_15, dnG_15, c_Up15, c_Dn15] = security(s15, res,gapScreenerFunc())+[insB15, Gap15, upG_15, dnG_15, c_Up15, c_Dn15] = request.security(s15, res,gapScreenerFunc())-[insB16, Gap16, upG_16, dnG_16, c_Up16, c_Dn16] = security(s16, res,gapScreenerFunc())+[insB16, Gap16, upG_16, dnG_16, c_Up16, c_Dn16] = request.security(s16, res,gapScreenerFunc())-[insB17, Gap17, upG_17, dnG_17, c_Up17, c_Dn17] = security(s17, res,gapScreenerFunc())+[insB17, Gap17, upG_17, dnG_17, c_Up17, c_Dn17] = request.security(s17, res,gapScreenerFunc())-[insB18, Gap18, upG_18, dnG_18, c_Up18, c_Dn18] = security(s18, res,gapScreenerFunc())+[insB18, Gap18, upG_18, dnG_18, c_Up18, c_Dn18] = request.security(s18, res,gapScreenerFunc())-[insB19, Gap19, upG_19, dnG_19, c_Up19, c_Dn19] = security(s19, res,gapScreenerFunc())+[insB19, Gap19, upG_19, dnG_19, c_Up19, c_Dn19] = request.security(s19, res,gapScreenerFunc())-[insB20, Gap20, upG_20, dnG_20, c_Up20, c_Dn20] = security(s20, res,gapScreenerFunc())+[insB20, Gap20, upG_20, dnG_20, c_Up20, c_Dn20] = request.security(s20, res,gapScreenerFunc()) ⋯ RoundCounter := 1- s_1 := ' Opening(' + tostring(timeframe.period) + ') Gap: \n'+ s_1 := ' Opening(' + str.tostring(timeframe.period) + ') Gap: \n' s_1 := upG_01 ? s_1 +s01 +' =Gap UP ↑ \n' : dnG_01 ? s_1 +s01 +' =Gap Down ↓ \n': s_1⋯ table.cell_set_text_size(UpTabl, column = 0, row = 0, text_size = font)-plotchar(barNumber and (barssince(is_new_day())+1)==1,char=' ',text="1",color=color.white,location=location.belowbar,editable=false) +plotchar(barNumber and (ta.barssince(is_new_day())+1)==1,char=' ',text="1",color=color.white,location=location.belowbar,editable=false) // Second Candle: check for gaps in first candle and Inside Bands -if (barssince(is_new_day())+1)==2+if (ta.barssince(is_new_day())+1)==2 var s_2 = ""⋯ table.cell_set_text_size(UpTabl, column = 0, row = 1, text_size= font)-plotchar(barNumber and (barssince(is_new_day())+1)==2,char=' ',text="2",color=color.white,location=location.belowbar,editable=false)+plotchar(barNumber and (ta.barssince(is_new_day())+1)==2,char=' ',text="2",color=color.white,location=location.belowbar,editable=false)// Third Candle: check for gaps in first candle and Inside Bands in previous, then for inside or break outs-if (barssince(is_new_day())+1)==3+if (ta.barssince(is_new_day())+1)==3 var s_3 = ""⋯ table.cell_set_text_size(UpTabl, column = 0, row = 2, text_size= font)-plotchar(barNumber and (barssince(is_new_day())+1)==3,char=' ',text="3",color=color.white,location=location.belowbar,editable=false)+plotchar(barNumber and (ta.barssince(is_new_day())+1)==3,char=' ',text="3",color=color.white,location=location.belowbar,editable=false)-if (barssince(is_new_day())+1)==4+if (ta.barssince(is_new_day())+1)==4 var s_4 = ""⋯ table.cell_set_text_size(UpTabl, column = 0, row = 3, text_size= font)-plotchar(barNumber and (barssince(is_new_day())+1)==4,char=' ',text="4",color=color.white,location=location.belowbar,editable=false)+plotchar(barNumber and (ta.barssince(is_new_day())+1)==4,char=' ',text="4",color=color.white,location=location.belowbar,editable=false)//plotchar(barNumber and (barssince(is_new_day())+1)==5,char=' ',text="5",color=color.white,location=location.belowbar,editable=false)⋯Clean v5
Not verifiedThe v5 script does not run in Zeal Terminal's engine (Pine Script v5 Error at @L129:C17: No value assigned to the `transp` parameter in color.new()), so this step could not be checked.
- Line 38: input() → input.string()
- Line 40: input() → input.string()
⋯barNumber = input.bool(defval = false , title = "Show Bar Numbers")-input_font = input("Normal", "Font size", options = ["Large" ,"Normal", "Small"])+input_font = input.string("Normal", "Font size", options = ["Large" ,"Normal", "Small"])font = input_font == "Small" ? size.small : input_font == "Large" ? size.large : size.normal-input_pos = input("top_right", "Table Position", options = ["top_right", "middle_right", "bottom_right", "bottom_center", "bottom_left", "middle_left"])+input_pos = input.string("top_right", "Table Position", options = ["top_right", "middle_right", "bottom_right", "bottom_center", "bottom_left", "middle_left"])pos = input_pos == "top_right" ? position.top_right: input_pos == "middle_right" ? position.middle_right : input_pos == "middle_left" ? position.middle_left : input_pos == "bottom_right" ? position.bottom_right : input_pos == "bottom_center" ? position.bottom_center : position.bottom_left⋯Does it run in Pine Script v6?
Not tested
The v5 script does not run in Zeal Terminal's engine (Pine Script v5 Error at @L129:C17: No value assigned to the `transp` parameter in color.new()), so this step could not be checked. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯//-//@version=5+//@version=6strategy("1St Bar GAP+BkOut Screener v2 by RM", shorttitle = '1Bar Gap+BkOut v2 by RM ', overlay = true)⋯Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| input timeframe for the screener | | timeframe (written input.resolution) | t O up1 down1 insB01 Gap01 upG_01 dnG_01 c_Up01 c_Dn01 insB02 Gap02 upG_02 dnG_02 c_Up02 c_Dn02 insB03 Gap03 upG_03 dnG_03 c_Up03 c_Dn03 insB04 Gap04 upG_04 dnG_04 c_Up04 c_Dn04 insB05 Gap05 upG_05 dnG_05 c_Up05 c_Dn05 insB06 Gap06 upG_06 dnG_06 c_Up06 c_Dn06 insB07 Gap07 upG_07 dnG_07 c_Up07 c_Dn07 insB08 Gap08 upG_08 dnG_08 c_Up08 c_Dn08 insB09 Gap09 upG_09 dnG_09 c_Up09 c_Dn09 insB10 Gap10 upG_10 dnG_10 c_Up10 c_Dn10 insB11 Gap11 upG_11 dnG_11 c_Up11 c_Dn11 insB12 Gap12 upG_12 dnG_12 c_Up12 c_Dn12 insB13 Gap13 upG_13 dnG_13 c_Up13 c_Dn13 insB14 Gap14 upG_14 dnG_14 c_Up14 c_Dn14 insB15 Gap15 upG_15 dnG_15 c_Up15 c_Dn15 insB16 Gap16 upG_16 dnG_16 c_Up16 c_Dn16 insB17 Gap17 upG_17 dnG_17 c_Up17 c_Dn17 insB18 Gap18 upG_18 dnG_18 c_Up18 c_Dn18 insB19 Gap19 upG_19 dnG_19 c_Up19 c_Dn19 insB20 Gap20 upG_20 dnG_20 c_Up20 c_Dn20 plot |
| Show 1st Bar High | true | bool | up1 trans1 plot |
| Show 1st Bar Low | true | bool | down1 trans1 plot |
| Show Bar Numbers | false | bool | plotchar |
| Font size | Normal | string · options ["Large" ,"Normal", "Small"] | font |
| Table Position | top_right | string · options ["top_right", "middle_right", "bottom_right", "bottom_center", "bottom_left", "middle_left"] | pos |
| S01 (no label in the script) | AAPL | string | insB01 Gap01 upG_01 dnG_01 c_Up01 c_Dn01 s_1 s_2 s_3 s_4 |
| S02 (no label in the script) | BIDU | string | insB02 Gap02 upG_02 dnG_02 c_Up02 c_Dn02 s_1 s_2 s_3 s_4 |
| S03 (no label in the script) | AMD | string | insB03 Gap03 upG_03 dnG_03 c_Up03 c_Dn03 s_1 s_2 s_3 s_4 |
| S04 (no label in the script) | TAN | string | insB04 Gap04 upG_04 dnG_04 c_Up04 c_Dn04 s_1 s_2 s_3 s_4 |
| S05 (no label in the script) | BABA | string | insB05 Gap05 upG_05 dnG_05 c_Up05 c_Dn05 s_1 s_2 s_3 s_4 |
| S06 (no label in the script) | BILL | string | insB06 Gap06 upG_06 dnG_06 c_Up06 c_Dn06 s_1 s_2 s_3 s_4 |
| S07 (no label in the script) | MSFT | string | insB07 Gap07 upG_07 dnG_07 c_Up07 c_Dn07 s_1 s_2 s_3 s_4 |
| S08 (no label in the script) | PFE | string | insB08 Gap08 upG_08 dnG_08 c_Up08 c_Dn08 s_1 s_2 s_3 s_4 |
| S09 (no label in the script) | BHVN | string | insB09 Gap09 upG_09 dnG_09 c_Up09 c_Dn09 s_1 s_2 s_3 s_4 |
| S10 (no label in the script) | T | string | insB10 Gap10 upG_10 dnG_10 c_Up10 c_Dn10 s_1 s_2 s_3 s_4 |
| S11 (no label in the script) | NVAX | string | insB11 Gap11 upG_11 dnG_11 c_Up11 c_Dn11 s_1 s_2 s_3 s_4 |
| S12 (no label in the script) | NVDA | string | insB12 Gap12 upG_12 dnG_12 c_Up12 c_Dn12 s_1 s_2 s_3 s_4 |
| S13 (no label in the script) | FB | string | insB13 Gap13 upG_13 dnG_13 c_Up13 c_Dn13 s_1 s_2 s_3 s_4 |
| S14 (no label in the script) | PTON | string | insB14 Gap14 upG_14 dnG_14 c_Up14 c_Dn14 s_1 s_2 s_3 s_4 |
| S15 (no label in the script) | RIOT | string | insB15 Gap15 upG_15 dnG_15 c_Up15 c_Dn15 s_1 s_2 s_3 s_4 |
| S16 (no label in the script) | QCOM | string | insB16 Gap16 upG_16 dnG_16 c_Up16 c_Dn16 s_1 s_2 s_3 s_4 |
| S17 (no label in the script) | ROKU | string | insB17 Gap17 upG_17 dnG_17 c_Up17 c_Dn17 s_1 s_2 s_3 s_4 |
| S18 (no label in the script) | FUBO | string | insB18 Gap18 upG_18 dnG_18 c_Up18 c_Dn18 s_1 s_2 s_3 s_4 |
| S19 (no label in the script) | WISH | string | insB19 Gap19 upG_19 dnG_19 c_Up19 c_Dn19 s_1 s_2 s_3 s_4 |
| S20 (no label in the script) | WKHS | string | insB20 Gap20 upG_20 dnG_20 c_Up20 c_Dn20 s_1 s_2 s_3 s_4 |
What it calculates
- Valuewhen (
valuewhen,ta.valuewhenin v5)is_newbar('D'), high, 0high_rangeL · line 107 - Valuewhen (
valuewhen,ta.valuewhenin v5)is_newbar('D'), low, 0low_rangeL · line 108 - Change (
change,ta.changein v5)bar_date_tsis_new_date · line 122 - Valuewhen (
valuewhen,ta.valuewhenin v5)is_newbar('D'), high, 0high_1st · line 123 - Valuewhen (
valuewhen,ta.valuewhenin v5)is_newbar('D'), low, 0low_1st · line 124
Signal flow
How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.
The script has 78 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.
Order rules
The script places no orders.
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Does it repaint?
Yes
At least one pattern in the source can repaint; it is marked Check below.
- CheckHigher-timeframe data2 security call(s) use lookahead_on (line 99, 102). Without a [1] offset this reads future bars in history.
- ClearFuture-bar referencesNo negative history offsets such as close[-1].
- ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
- ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.
The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.
Other markets
Not run on other markets: the script requests AAPL D, BIDU D, AMD D, TAN D, BABA D, BILL D, MSFT D, PFE D, BHVN D, T D, NVAX D, NVDA D, FB D, PTON D, RIOT D, QCOM D, ROKU D, FUBO D, WISH D, WKHS D, and that data is not available here (not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market; not a Binance spot market). Its results would rest on empty values.
Similar scripts
Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| 1St Bar GAP+BkOut Screener v2 by RM this page | — | v4 strategy | 0.0% | 0 | 0.0% |
| [LunaOwl] Support Resistance Strategy V4 by LunaOwl | valuewhen | v4 strategy | −1.3% | 7 | 25.5% |
| Close Trade at end of day by daytraderph | valuewhen | v4 strategy | No trades on this market | ||
| Pivot Points Standard by Zeal Terminal | valuewhen | v5 indicator | indicator | ||
| Reinforced RSI - The Quant Science by thequantscience | valuewhen | v5 strategy | −3.9% | 7 | 3.9% |
| MACD 50x Leveraged Short Strategy with Real Equity by Noldo | valuewhen | v4 strategy | +15,109.2% | 39 | 2,974.0% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 274 ms | With a workaround 1,000 bars in 181 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.
“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report. PineTS runs Pine Script v5 and v6 only.
Source
Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © raul3429 // 1St Bar GAP/BkOut/Screener v2 by RM Sun21Aug // This is type of custom screener has a list of predefined stock - In the US MArket- that can be modified to suit. // Generally in TV a maximum of 40 stocks can be used at a time. THis script uses 20 entries for stock called s01, s02 ... to s20.// In some cases there may be other TV automatic calls that may produce an excessive number of calls.//// This code runs on each bar and checks if the stocks has an initial Gap, then checks for next bars to be inside the boundaries of the first candle// you can customize this screener according to your requirement.// There are a number of very clever people I have taken bits of code and ideas, thanks to you all :)//Outline: // gap up/ gap down on 1 min first candle -> good// 2nd candle inside 1st candle -> good// 3rd to nth candle to break out from first candle range -> good /alert/ Plot flag// //M code to load watchlist from txt format// //s01 = input( "ADS " , type=input.string)//let // // replace [my directory] and [my Watchlist.txt] for the correspondign values in your computer// Source = Csv.Document(File.Contents("C:\[my directory]\[my Watchlist.txt]"),[Delimiter=",", Columns=108, Encoding=1252, QuoteStyle=QuoteStyle.None]),// #"Transposed Table" = Table.Transpose(Source),// #"Sorted Rows" = Table.Sort(#"Transposed Table",{{"Column1", Order.Ascending}}),// #"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 1, 1, Int64.Type),// #"Changed Type1" = Table.TransformColumnTypes(#"Added Index",{{"Index", type text}}),// #"Inserted Merged Column1" = Table.AddColumn(#"Changed Type1", "Merged", each Text.Combine({"0", [Index]}), type text),// #"Inserted First Characters" = Table.AddColumn(#"Inserted Merged Column1", "Two Characters", each Text.End([Merged], 2), type text),// #"Removed Columns" = Table.RemoveColumns(#"Inserted First Characters",{"Index", "Merged"}),// #"Inserted Merged Column" = Table.AddColumn(#"Removed Columns", "Merged", each Text.Combine({"s", [Two Characters], " = input( '", [Column1], "' , type=input.string)"}), type text)//in// #"Inserted Merged Column"// //--> once input string is created Copy&Paste in this code after // Symbols _ Use Power Query in Excel////@version=4strategy("1St Bar GAP+BkOut Screener v2 by RM", shorttitle = '1Bar Gap+BkOut v2 by RM ', overlay = true)res = input("", title="input timeframe for the screener" , type = input.resolution)high_show = input(defval = true , title = "Show 1st Bar High" , type = input.bool)low_show = input(defval = true , title = "Show 1st Bar Low" , type = input.bool)barNumber = input(defval = false , title = "Show Bar Numbers", type = input.bool)input_font = input("Normal", "Font size", options = ["Large" ,"Normal", "Small"])font = input_font == "Small" ? size.small : input_font == "Large" ? size.large : size.normalinput_pos = input("top_right", "Table Position", options = ["top_right", "middle_right", "bottom_right", "bottom_center", "bottom_left", "middle_left"])pos = input_pos == "top_right" ? position.top_right: input_pos == "middle_right" ? position.middle_right : input_pos == "middle_left" ? position.middle_left : input_pos == "bottom_right" ? position.bottom_right : input_pos == "bottom_center" ? position.bottom_center : position.bottom_left//calc_on_every_tick = true We are waiting to close the bar// --------- Colorsc_black = #000000 // Blackc_maroon = #800000 // Maroonc_green = #008000 // Greenc_green90 = #00800090 //Green 90%c_green100 = #008000FF //Green 100%c_olive = #808000 // Olivec_navy = #000080 // Navyc_purple = #800080 // Purplec_teal = #008080 // Tealc_silver = #c0c0c0 // Silverc_grey = #808080 // Greyc_red = #8B0000 //Redc_red100 = #8B0000FF//Red 100%c_red90 = #8B0000FF//Red 90%c_redLight = #b71c1c //Red Lightc_lime = #00ff00 // Limec_yellow = #ffff00 // Yellowc_yellowTr = #FFFF0090 //YellowTranspc_blue = #0000ff // Bluec_fuchsia = #ff00ff // Fuchsiac_aqua = #00ffff // Aquac_white = #ffffff // Whitec_darkcyan = #00af87 // DarkCyanc_orange = #f57f17 //Orange// Symbols _ Use Power Query in Excels01 = input( "AAPL" , type=input.string)s02 = input( "BIDU" , type=input.string)s03 = input( "AMD " , type=input.string)s04 = input( "TAN " , type=input.string)s05 = input( "BABA" , type=input.string)s06 = input( "BILL" , type=input.string)s07 = input( "MSFT" , type=input.string)s08 = input( "PFE" , type=input.string)s09 = input( "BHVN" , type=input.string)s10 = input( "T " , type=input.string)s11 = input( "NVAX" , type=input.string)s12 = input( "NVDA" , type=input.string)s13 = input( "FB " , type=input.string)s14 = input( "PTON" , type=input.string)s15 = input( "RIOT" , type=input.string)s16 = input( "QCOM" , type=input.string)s17 = input( "ROKU" , type=input.string)s18 = input( "FUBO" , type=input.string)s19 = input( "WISH" , type=input.string)s20 = input( "WKHS" , type=input.string)// FUNCTIONS //is_newday(sess) => d = time("W", sess) change(d) != 0 ? true : na is_newbar(res) => t = time(res) change(t) != 0 ? true : na adopt(r, s) => security(syminfo.tickerid, r, s)f_get_h(back, res) => O = security(symbol = syminfo.tickerid, resolution = res, expression = high[back], gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_on)f_get_l(back, res) => O = security(symbol = syminfo.tickerid, resolution = res, expression = low[back], gaps = barmerge.gaps_off, lookahead = barmerge.lookahead_on)// 1st Bar Limits FunctiongapScreenerFunc() => high_rangeL = valuewhen(is_newbar('D'),high,0) low_rangeL = valuewhen(is_newbar('D'),low,0) upGap = low > high[1] downGap = high < low[1] gap = upGap or downGap breakUp = close > high_rangeL breakDN = close < low_rangeL insideBand = high < high_rangeL and low > low_rangeL [insideBand, gap, upGap, downGap, breakUp, breakDN]outcomeIs(upGap, downGap, insideBand) => result = upGap ? "upGap" : downGap ? "downGap" : insideBand ? "insideB" : na [result]// first bar bar_date_ts = timestamp(year(time),month(time),dayofmonth(time),0,0,0)is_new_date = change(bar_date_ts) high_1st = valuewhen(is_newbar('D'),high,0) low_1st = valuewhen(is_newbar('D'),low,0) RoundCounter = 0up1 = plot(high_show ? adopt(res, high_1st): na, color = c_teal, linewidth=1) down1 = plot(low_show ? adopt(res, low_1st): na, color = c_teal, linewidth=1) trans1 = high_show or low_show ? 95 : 100fill(up1, down1, color.new (c_white, transp=trans1)) // bar counteris_new_day() => d=dayofweek na(d[1]) or d != d[1]vLine(BarIndex, Color, LineStyle) => Line = line.new(x1= BarIndex, y1= low - tr * 5, x2= BarIndex, y2= high + tr * 5, xloc= xloc.bar_index, color=Color, style= LineStyle) if (is_new_date) fisrtDayline = vLine(bar_index,color.new(c_white,95) , line.style_dashed)// Running gapScreenerFunc for all sybmols get InsideBands, Gaps and BreakOuts [insB01, Gap01, upG_01, dnG_01, c_Up01, c_Dn01] = security(s01, res,gapScreenerFunc())[insB02, Gap02, upG_02, dnG_02, c_Up02, c_Dn02] = security(s02, res,gapScreenerFunc())[insB03, Gap03, upG_03, dnG_03, c_Up03, c_Dn03] = security(s03, res,gapScreenerFunc())[insB04, Gap04, upG_04, dnG_04, c_Up04, c_Dn04] = security(s04, res,gapScreenerFunc())[insB05, Gap05, upG_05, dnG_05, c_Up05, c_Dn05] = security(s05, res,gapScreenerFunc())[insB06, Gap06, upG_06, dnG_06, c_Up06, c_Dn06] = security(s06, res,gapScreenerFunc())[insB07, Gap07, upG_07, dnG_07, c_Up07, c_Dn07] = security(s07, res,gapScreenerFunc())[insB08, Gap08, upG_08, dnG_08, c_Up08, c_Dn08] = security(s08, res,gapScreenerFunc())[insB09, Gap09, upG_09, dnG_09, c_Up09, c_Dn09] = security(s09, res,gapScreenerFunc())[insB10, Gap10, upG_10, dnG_10, c_Up10, c_Dn10] = security(s10, res,gapScreenerFunc())[insB11, Gap11, upG_11, dnG_11, c_Up11, c_Dn11] = security(s11, res,gapScreenerFunc())[insB12, Gap12, upG_12, dnG_12, c_Up12, c_Dn12] = security(s12, res,gapScreenerFunc())[insB13, Gap13, upG_13, dnG_13, c_Up13, c_Dn13] = security(s13, res,gapScreenerFunc())[insB14, Gap14, upG_14, dnG_14, c_Up14, c_Dn14] = security(s14, res,gapScreenerFunc())[insB15, Gap15, upG_15, dnG_15, c_Up15, c_Dn15] = security(s15, res,gapScreenerFunc())[insB16, Gap16, upG_16, dnG_16, c_Up16, c_Dn16] = security(s16, res,gapScreenerFunc())[insB17, Gap17, upG_17, dnG_17, c_Up17, c_Dn17] = security(s17, res,gapScreenerFunc())[insB18, Gap18, upG_18, dnG_18, c_Up18, c_Dn18] = security(s18, res,gapScreenerFunc())[insB19, Gap19, upG_19, dnG_19, c_Up19, c_Dn19] = security(s19, res,gapScreenerFunc())[insB20, Gap20, upG_20, dnG_20, c_Up20, c_Dn20] = security(s20, res,gapScreenerFunc()) var UpTabl = table.new(position = pos, columns = 1, rows = 4, bgcolor = c_black, border_width = 2, frame_color= c_yellowTr, frame_width = 2)table.cell_set_text_size(UpTabl, column = 0, row = 0, text_size= font)// Running gapScreenerFunc for first Candle: check for gaps onlyif (is_new_date)// Screener label // ↑ → ↓ var s_1 = "" RoundCounter := 1 s_1 := ' Opening(' + tostring(timeframe.period) + ') Gap: \n' s_1 := upG_01 ? s_1 +s01 +' =Gap UP ↑ \n' : dnG_01 ? s_1 +s01 +' =Gap Down ↓ \n': s_1 s_1 := upG_02 ? s_1 +s02 +' =Gap UP ↑ \n' : dnG_02 ? s_1 +s02 +' =Gap Down ↓ \n': s_1 s_1 := upG_03 ? s_1 +s03 +' =Gap UP ↑ \n' : dnG_03 ? s_1 +s03 +' =Gap Down ↓ \n': s_1 s_1 := upG_04 ? s_1 +s04 +' =Gap UP ↑ \n' : dnG_04 ? s_1 +s04 +' =Gap Down ↓ \n': s_1 s_1 := upG_05 ? s_1 +s05 +' =Gap UP ↑ \n' : dnG_05 ? s_1 +s05 +' =Gap Down ↓ \n': s_1 s_1 := upG_06 ? s_1 +s06 +' =Gap UP ↑ \n' : dnG_06 ? s_1 +s06 +' =Gap Down ↓ \n': s_1 s_1 := upG_07 ? s_1 +s07 +' =Gap UP ↑ \n' : dnG_07 ? s_1 +s07 +' =Gap Down ↓ \n': s_1 s_1 := upG_08 ? s_1 +s08 +' =Gap UP ↑ \n' : dnG_08 ? s_1 +s08 +' =Gap Down ↓ \n': s_1 s_1 := upG_09 ? s_1 +s09 +' =Gap UP ↑ \n' : dnG_09 ? s_1 +s09 +' =Gap Down ↓ \n': s_1 s_1 := upG_10 ? s_1 +s10 +' =Gap UP ↑ \n' : dnG_10 ? s_1 +s10 +' =Gap Down ↓ \n': s_1 s_1 := upG_11 ? s_1 +s11 +' =Gap UP ↑ \n' : dnG_11 ? s_1 +s11 +' =Gap Down ↓ \n': s_1 s_1 := upG_12 ? s_1 +s12 +' =Gap UP ↑ \n' : dnG_12 ? s_1 +s12 +' =Gap Down ↓ \n': s_1 s_1 := upG_13 ? s_1 +s13 +' =Gap UP ↑ \n' : dnG_13 ? s_1 +s13 +' =Gap Down ↓ \n': s_1 s_1 := upG_14 ? s_1 +s14 +' =Gap UP ↑ \n' : dnG_14 ? s_1 +s14 +' =Gap Down ↓ \n': s_1 s_1 := upG_15 ? s_1 +s15 +' =Gap UP ↑ \n' : dnG_15 ? s_1 +s15 +' =Gap Down ↓ \n': s_1 s_1 := upG_16 ? s_1 +s16 +' =Gap UP ↑ \n' : dnG_16 ? s_1 +s16 +' =Gap Down ↓ \n': s_1 s_1 := upG_17 ? s_1 +s17 +' =Gap UP ↑ \n' : dnG_17 ? s_1 +s17 +' =Gap Down ↓ \n': s_1 s_1 := upG_18 ? s_1 +s18 +' =Gap UP ↑ \n' : dnG_18 ? s_1 +s18 +' =Gap Down ↓ \n': s_1 s_1 := upG_19 ? s_1 +s19 +' =Gap UP ↑ \n' : dnG_19 ? s_1 +s19 +' =Gap Down ↓ \n': s_1 s_1 := upG_20 ? s_1 +s20 +' =Gap UP ↑ \n' : dnG_20 ? s_1 +s20 +' =Gap Down ↓ \n': s_1 table.cell(table_id = UpTabl, column = 0, row = 0, text_color = c_white, text = s_1) table.cell_set_text_size(UpTabl, column = 0, row = 0, text_size = font)plotchar(barNumber and (barssince(is_new_day())+1)==1,char=' ',text="1",color=color.white,location=location.belowbar,editable=false) // Second Candle: check for gaps in first candle and Inside Bands if (barssince(is_new_day())+1)==2 var s_2 = "" RoundCounter := RoundCounter + 1 s_2 := 'Second Candle: \n' s_2 := Gap01[1] and insB01 ? s_2 +s01 +' =InsB \n' : s_2 s_2 := Gap02[1] and insB02 ? s_2 +s02 +' =InsB \n' : s_2 s_2 := Gap03[1] and insB03 ? s_2 +s03 +' =InsB \n' : s_2 s_2 := Gap04[1] and insB04 ? s_2 +s04 +' =InsB \n' : s_2 s_2 := Gap05[1] and insB05 ? s_2 +s05 +' =InsB \n' : s_2 s_2 := Gap06[1] and insB06 ? s_2 +s06 +' =InsB \n' : s_2 s_2 := Gap07[1] and insB07 ? s_2 +s07 +' =InsB \n' : s_2 s_2 := Gap08[1] and insB08 ? s_2 +s08 +' =InsB \n' : s_2 s_2 := Gap09[1] and insB09 ? s_2 +s09 +' =InsB \n' : s_2 s_2 := Gap10[1] and insB10 ? s_2 +s10 +' =InsB \n' : s_2 s_2 := Gap11[1] and insB11 ? s_2 +s11 +' =InsB \n' : s_2 s_2 := Gap12[1] and insB12 ? s_2 +s12 +' =InsB \n' : s_2 s_2 := Gap13[1] and insB13 ? s_2 +s13 +' =InsB \n' : s_2 s_2 := Gap14[1] and insB14 ? s_2 +s14 +' =InsB \n' : s_2 s_2 := Gap15[1] and insB15 ? s_2 +s15 +' =InsB \n' : s_2 s_2 := Gap16[1] and insB16 ? s_2 +s16 +' =InsB \n' : s_2 s_2 := Gap17[1] and insB17 ? s_2 +s17 +' =InsB \n' : s_2 s_2 := Gap18[1] and insB18 ? s_2 +s18 +' =InsB \n' : s_2 s_2 := Gap19[1] and insB19 ? s_2 +s19 +' =InsB \n' : s_2 s_2 := Gap20[1] and insB20 ? s_2 +s20 +' =InsB \n' : s_2 table.cell(table_id = UpTabl, column = 0, row = 1, text_color = c_white, text = s_2) table.cell_set_text_size(UpTabl, column = 0, row = 1, text_size= font)plotchar(barNumber and (barssince(is_new_day())+1)==2,char=' ',text="2",color=color.white,location=location.belowbar,editable=false)// Third Candle: check for gaps in first candle and Inside Bands in previous, then for inside or break outsif (barssince(is_new_day())+1)==3 var s_3 = "" RoundCounter := RoundCounter + 1 s_3 := 'Third Candle: \n' s_3 := Gap01[2] and insB01[1] and insB01 ? s_3 +s01 +' =InsB \n' : Gap01[2] and insB01[1] and c_Up01 ? s_3 +s01 +' =BrkUp \n' : Gap01[2] and insB01[1] and c_Dn01 ? s_3 +s01 +' =BrkDn \n': s_3 s_3 := Gap02[2] and insB02[1] and insB02 ? s_3 +s02 +' =InsB \n' : Gap02[2] and insB02[1] and c_Up02 ? s_3 +s02 +' =BrkUp \n' : Gap02[2] and insB02[1] and c_Dn02 ? s_3 +s02 +' =BrkDn \n': s_3 s_3 := Gap03[2] and insB03[1] and insB03 ? s_3 +s03 +' =InsB \n' : Gap03[2] and insB03[1] and c_Up03 ? s_3 +s03 +' =BrkUp \n' : Gap03[2] and insB03[1] and c_Dn03 ? s_3 +s03 +' =BrkDn \n': s_3 s_3 := Gap04[2] and insB04[1] and insB04 ? s_3 +s04 +' =InsB \n' : Gap04[2] and insB04[1] and c_Up04 ? s_3 +s04 +' =BrkUp \n' : Gap04[2] and insB04[1] and c_Dn04 ? s_3 +s04 +' =BrkDn \n': s_3 s_3 := Gap05[2] and insB05[1] and insB05 ? s_3 +s05 +' =InsB \n' : Gap05[2] and insB05[1] and c_Up05 ? s_3 +s05 +' =BrkUp \n' : Gap05[2] and insB05[1] and c_Dn05 ? s_3 +s05 +' =BrkDn \n': s_3 s_3 := Gap06[2] and insB06[1] and insB06 ? s_3 +s06 +' =InsB \n' : Gap06[2] and insB06[1] and c_Up06 ? s_3 +s06 +' =BrkUp \n' : Gap06[2] and insB06[1] and c_Dn06 ? s_3 +s06 +' =BrkDn \n': s_3 s_3 := Gap07[2] and insB07[1] and insB07 ? s_3 +s07 +' =InsB \n' : Gap07[2] and insB07[1] and c_Up07 ? s_3 +s07 +' =BrkUp \n' : Gap07[2] and insB07[1] and c_Dn07 ? s_3 +s07 +' =BrkDn \n': s_3 s_3 := Gap08[2] and insB08[1] and insB08 ? s_3 +s08 +' =InsB \n' : Gap08[2] and insB08[1] and c_Up08 ? s_3 +s08 +' =BrkUp \n' : Gap08[2] and insB08[1] and c_Dn08 ? s_3 +s08 +' =BrkDn \n': s_3 s_3 := Gap09[2] and insB09[1] and insB09 ? s_3 +s09 +' =InsB \n' : Gap09[2] and insB09[1] and c_Up09 ? s_3 +s09 +' =BrkUp \n' : Gap09[2] and insB09[1] and c_Dn09 ? s_3 +s09 +' =BrkDn \n': s_3 s_3 := Gap10[2] and insB10[1] and insB10 ? s_3 +s10 +' =InsB \n' : Gap10[2] and insB10[1] and c_Up10 ? s_3 +s10 +' =BrkUp \n' : Gap10[2] and insB10[1] and c_Dn10 ? s_3 +s10 +' =BrkDn \n': s_3 s_3 := Gap11[2] and insB11[1] and insB11 ? s_3 +s11 +' =InsB \n' : Gap11[2] and insB11[1] and c_Up11 ? s_3 +s11 +' =BrkUp \n' : Gap11[2] and insB11[1] and c_Dn11 ? s_3 +s11 +' =BrkDn \n': s_3 s_3 := Gap12[2] and insB12[1] and insB12 ? s_3 +s12 +' =InsB \n' : Gap12[2] and insB12[1] and c_Up12 ? s_3 +s12 +' =BrkUp \n' : Gap12[2] and insB12[1] and c_Dn12 ? s_3 +s12 +' =BrkDn \n': s_3 s_3 := Gap13[2] and insB13[1] and insB13 ? s_3 +s13 +' =InsB \n' : Gap13[2] and insB13[1] and c_Up13 ? s_3 +s13 +' =BrkUp \n' : Gap13[2] and insB13[1] and c_Dn13 ? s_3 +s13 +' =BrkDn \n': s_3 s_3 := Gap14[2] and insB14[1] and insB14 ? s_3 +s14 +' =InsB \n' : Gap14[2] and insB14[1] and c_Up14 ? s_3 +s14 +' =BrkUp \n' : Gap14[2] and insB14[1] and c_Dn14 ? s_3 +s14 +' =BrkDn \n': s_3 s_3 := Gap15[2] and insB15[1] and insB15 ? s_3 +s15 +' =InsB \n' : Gap15[2] and insB15[1] and c_Up15 ? s_3 +s15 +' =BrkUp \n' : Gap15[2] and insB15[1] and c_Dn15 ? s_3 +s15 +' =BrkDn \n': s_3 s_3 := Gap16[2] and insB16[1] and insB16 ? s_3 +s16 +' =InsB \n' : Gap16[2] and insB16[1] and c_Up16 ? s_3 +s16 +' =BrkUp \n' : Gap16[2] and insB16[1] and c_Dn16 ? s_3 +s16 +' =BrkDn \n': s_3 s_3 := Gap17[2] and insB17[1] and insB17 ? s_3 +s17 +' =InsB \n' : Gap17[2] and insB17[1] and c_Up17 ? s_3 +s17 +' =BrkUp \n' : Gap17[2] and insB17[1] and c_Dn17 ? s_3 +s17 +' =BrkDn \n': s_3 s_3 := Gap18[2] and insB18[1] and insB18 ? s_3 +s18 +' =InsB \n' : Gap18[2] and insB18[1] and c_Up18 ? s_3 +s18 +' =BrkUp \n' : Gap18[2] and insB18[1] and c_Dn18 ? s_3 +s18 +' =BrkDn \n': s_3 s_3 := Gap19[2] and insB19[1] and insB19 ? s_3 +s19 +' =InsB \n' : Gap19[2] and insB19[1] and c_Up19 ? s_3 +s19 +' =BrkUp \n' : Gap19[2] and insB19[1] and c_Dn19 ? s_3 +s19 +' =BrkDn \n': s_3 s_3 := Gap20[2] and insB20[1] and insB20 ? s_3 +s20 +' =InsB \n' : Gap20[2] and insB20[1] and c_Up20 ? s_3 +s20 +' =BrkUp \n' : Gap20[2] and insB20[1] and c_Dn20 ? s_3 +s20 +' =BrkDn \n': s_3 table.cell(table_id = UpTabl, column = 0, row = 2, text_color = c_white, text = s_3) table.cell_set_text_size(UpTabl, column = 0, row = 2, text_size= font)plotchar(barNumber and (barssince(is_new_day())+1)==3,char=' ',text="3",color=color.white,location=location.belowbar,editable=false)if (barssince(is_new_day())+1)==4 var s_4 = "" RoundCounter := RoundCounter + 1 s_4 := 'Fourth Candle: \n' s_4 := Gap01[3] and insB01[2] and insB01[1] and insB01 ? s_4 +s01 +' =InsB \n' : Gap01[3] and insB01[2] and insB01[1] and c_Up01 ? s_4 +s01 +' =BrkUp \n' : Gap01[3] and insB01[2] and insB01[1] and c_Dn01 ? s_4 +s01 +' =BrkDn \n': s_4 s_4 := Gap02[3] and insB02[2] and insB02[1] and insB02 ? s_4 +s02 +' =InsB \n' : Gap02[3] and insB02[2] and insB02[1] and c_Up02 ? s_4 +s02 +' =BrkUp \n' : Gap02[3] and insB02[2] and insB02[1] and c_Dn02 ? s_4 +s02 +' =BrkDn \n': s_4 s_4 := Gap03[3] and insB03[2] and insB03[1] and insB03 ? s_4 +s03 +' =InsB \n' : Gap03[3] and insB03[2] and insB03[1] and c_Up03 ? s_4 +s03 +' =BrkUp \n' : Gap03[3] and insB03[2] and insB03[1] and c_Up03 ? s_4 +s03 +' =BrkUp \n': s_4 s_4 := Gap04[3] and insB04[2] and insB04[1] and insB04 ? s_4 +s04 +' =InsB \n' : Gap04[3] and insB04[2] and insB04[1] and c_Up04 ? s_4 +s04 +' =BrkUp \n' : Gap04[3] and insB04[2] and insB04[1] and c_Up04 ? s_4 +s04 +' =BrkUp \n': s_4 s_4 := Gap05[3] and insB05[2] and insB05[1] and insB05 ? s_4 +s05 +' =InsB \n' : Gap05[3] and insB05[2] and insB05[1] and c_Up05 ? s_4 +s05 +' =BrkUp \n' : Gap05[3] and insB05[2] and insB05[1] and c_Up05 ? s_4 +s05 +' =BrkUp \n': s_4 s_4 := Gap06[3] and insB06[2] and insB06[1] and insB06 ? s_4 +s06 +' =InsB \n' : Gap06[3] and insB06[2] and insB06[1] and c_Up06 ? s_4 +s06 +' =BrkUp \n' : Gap06[3] and insB06[2] and insB06[1] and c_Up06 ? s_4 +s06 +' =BrkUp \n': s_4 s_4 := Gap07[3] and insB07[2] and insB07[1] and insB07 ? s_4 +s07 +' =InsB \n' : Gap07[3] and insB07[2] and insB07[1] and c_Up07 ? s_4 +s07 +' =BrkUp \n' : Gap07[3] and insB07[2] and insB07[1] and c_Up07 ? s_4 +s07 +' =BrkUp \n': s_4 s_4 := Gap08[3] and insB08[2] and insB08[1] and insB08 ? s_4 +s08 +' =InsB \n' : Gap08[3] and insB08[2] and insB08[1] and c_Up08 ? s_4 +s08 +' =BrkUp \n' : Gap08[3] and insB08[2] and insB08[1] and c_Up08 ? s_4 +s08 +' =BrkUp \n': s_4 s_4 := Gap09[3] and insB09[2] and insB09[1] and insB09 ? s_4 +s09 +' =InsB \n' : Gap09[3] and insB09[2] and insB09[1] and c_Up09 ? s_4 +s09 +' =BrkUp \n' : Gap09[3] and insB09[2] and insB09[1] and c_Up09 ? s_4 +s09 +' =BrkUp \n': s_4 s_4 := Gap10[3] and insB10[2] and insB10[1] and insB10 ? s_4 +s10 +' =InsB \n' : Gap10[3] and insB10[2] and insB10[1] and c_Up10 ? s_4 +s10 +' =BrkUp \n' : Gap10[3] and insB10[2] and insB10[1] and c_Up10 ? s_4 +s10 +' =BrkUp \n': s_4 s_4 := Gap11[3] and insB11[2] and insB11[1] and insB11 ? s_4 +s11 +' =InsB \n' : Gap11[3] and insB11[2] and insB11[1] and c_Up11 ? s_4 +s11 +' =BrkUp \n' : Gap11[3] and insB11[2] and insB11[1] and c_Up11 ? s_4 +s11 +' =BrkUp \n': s_4 s_4 := Gap12[3] and insB12[2] and insB12[1] and insB12 ? s_4 +s12 +' =InsB \n' : Gap12[3] and insB12[2] and insB12[1] and c_Up12 ? s_4 +s12 +' =BrkUp \n' : Gap12[3] and insB12[2] and insB12[1] and c_Up12 ? s_4 +s12 +' =BrkUp \n': s_4 s_4 := Gap13[3] and insB13[2] and insB13[1] and insB13 ? s_4 +s13 +' =InsB \n' : Gap13[3] and insB13[2] and insB13[1] and c_Up13 ? s_4 +s13 +' =BrkUp \n' : Gap13[3] and insB13[2] and insB13[1] and c_Up13 ? s_4 +s13 +' =BrkUp \n': s_4 s_4 := Gap14[3] and insB14[2] and insB14[1] and insB14 ? s_4 +s14 +' =InsB \n' : Gap14[3] and insB14[2] and insB14[1] and c_Up14 ? s_4 +s14 +' =BrkUp \n' : Gap14[3] and insB14[2] and insB14[1] and c_Up14 ? s_4 +s14 +' =BrkUp \n': s_4 s_4 := Gap15[3] and insB15[2] and insB15[1] and insB15 ? s_4 +s15 +' =InsB \n' : Gap15[3] and insB15[2] and insB15[1] and c_Up15 ? s_4 +s15 +' =BrkUp \n' : Gap15[3] and insB15[2] and insB15[1] and c_Up15 ? s_4 +s15 +' =BrkUp \n': s_4 s_4 := Gap16[3] and insB16[2] and insB16[1] and insB16 ? s_4 +s16 +' =InsB \n' : Gap16[3] and insB16[2] and insB16[1] and c_Up16 ? s_4 +s16 +' =BrkUp \n' : Gap16[3] and insB16[2] and insB16[1] and c_Up16 ? s_4 +s16 +' =BrkUp \n': s_4 s_4 := Gap17[3] and insB17[2] and insB17[1] and insB17 ? s_4 +s17 +' =InsB \n' : Gap17[3] and insB17[2] and insB17[1] and c_Up17 ? s_4 +s17 +' =BrkUp \n' : Gap17[3] and insB17[2] and insB17[1] and c_Up17 ? s_4 +s17 +' =BrkUp \n': s_4 s_4 := Gap18[3] and insB18[2] and insB18[1] and insB18 ? s_4 +s18 +' =InsB \n' : Gap18[3] and insB18[2] and insB18[1] and c_Up18 ? s_4 +s18 +' =BrkUp \n' : Gap18[3] and insB18[2] and insB18[1] and c_Up18 ? s_4 +s18 +' =BrkUp \n': s_4 s_4 := Gap19[3] and insB19[2] and insB19[1] and insB19 ? s_4 +s19 +' =InsB \n' : Gap19[3] and insB19[2] and insB19[1] and c_Up19 ? s_4 +s19 +' =BrkUp \n' : Gap19[3] and insB19[2] and insB19[1] and c_Up19 ? s_4 +s19 +' =BrkUp \n': s_4 s_4 := Gap20[3] and insB20[2] and insB20[1] and insB20 ? s_4 +s20 +' =InsB \n' : Gap20[3] and insB20[2] and insB20[1] and c_Up20 ? s_4 +s20 +' =BrkUp \n' : Gap20[3] and insB20[2] and insB20[1] and c_Up20 ? s_4 +s20 +' =BrkUp \n': s_4 table.cell(table_id = UpTabl, column = 0, row = 3, text_color = c_white, text = s_4) table.cell_set_text_size(UpTabl, column = 0, row = 3, text_size= font)plotchar(barNumber and (barssince(is_new_day())+1)==4,char=' ',text="4",color=color.white,location=location.belowbar,editable=false)//plotchar(barNumber and (barssince(is_new_day())+1)==5,char=' ',text="5",color=color.white,location=location.belowbar,editable=false)//plotchar(barNumber and (barssince(is_new_day())+1)==6,char=' ',text="6",color=color.white,location=location.belowbar,editable=false)//plotchar(barNumber and (barssince(is_new_day())+1)==7,char=' ',text="7",color=color.white,location=location.belowbar,editable=false)//plotchar(barNumber and (barssince(is_new_day())+1)==8,char=' ',text="8",color=color.white,location=location.belowbar,editable=false)