Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

TradingGroundhog - Strategy & Fractal V1

A Pine Script v4 strategy built on Highest (high, 2), Lowest (low, 2) and Valuewhen (high[2], 2). It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits cash_given_per_lot in cash and pays no commission. 11 settings; defaults include Start Date 13, Start Month 9 and Start Year 2021.

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 TradingGroundhog - Strategy & Fractal V1 repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 2 of 2 trades.
How did TradingGroundhog - Strategy & Fractal V1 do on BTCUSDT 1D with default settings?
−2.94%
From 26 Jan 2024 to 21 Oct 2026, over 8 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can TradingGroundhog - Strategy & Fractal V1 be converted to Pine Script v5?
Yes
The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
Does TradingGroundhog - Strategy & Fractal V1 use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does TradingGroundhog - Strategy & Fractal V1 run in Zeal Terminal?
Yes
It compiles in 56 ms and runs 1,000 bars in 5,141 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • Plot
  • Plot
  • Plot
  • Shape
  • Shape
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (11)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$97,061$202,527Equity from $100,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots. Zeal Terminal's engine currently reads an order side written as long = true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 112) so the engine trades the way the script says.
Net profit
−2.94%
−$2,939.04
Buy and hold
+102.5%
same period
Closed trades
8
3 won · 5 lost
Profitable
37.5%
of closed trades
Profit factor
0.46
gross profit ÷ gross loss
Max drawdown
5.85%
−$5,970.30

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

    2 settings do nothing

    “Show Swings HL”, “Show Zig Zag” are declared but never read.

  • 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

    3 settings have no label

    In the settings dialog ShowSwingsHL (line 32), showchannel (line 37), showZigZag (line 40) 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 an argument v6 removed

    when = on line 112, 113. The upgraded version below moves each call inside an if block.

  • Note

    Uses long =, which v5 renamed line 112

    long = on line 112. v5 writes it as direction = strategy.long or strategy.short.

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 highest → ta.highest, lowest → ta.lowest, valuewhen → ta.valuewhen, barssince → ta.barssince, sma → ta.sma.
  • 2 strategy calls use the when = argument (line 112, 113). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

Same 8 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 1: //@version=4 → //@version=5
  • Line 26: highest → ta.highest
  • Line 27: lowest → ta.lowest
  • Line 33: valuewhen → ta.valuewhen
  • Line 33: valuewhen → ta.valuewhen
  • Line 33: valuewhen → ta.valuewhen
9 more edits
  • Line 33: valuewhen → ta.valuewhen
  • Line 34: valuewhen → ta.valuewhen
  • Line 34: valuewhen → ta.valuewhen
  • Line 34: valuewhen → ta.valuewhen
  • Line 34: valuewhen → ta.valuewhen
  • Line 45: barssince → ta.barssince
  • Line 46: barssince → ta.barssince
  • Line 48: sma → ta.sma
  • Line 112: long = true → direction = strategy.long
-// @version = 4+// @version = 5// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/⋯fbot = filterBW ? regularbotfractal : regularbotfractal or billwbotfractal-topf = ftop ? high[2] >= highest(high, length) ? true : false : false+topf = ftop ? high[2] >= ta.highest(high, length) ? true : false : false-botf = fbot ? low[2] <= lowest(low, length) ? true : false : false+botf = fbot ? low[2] <= ta.lowest(low, length) ? true : false : falsefilteredtopf = filterFractals ? topf : ftop⋯ShowSwingsHL = input(true)-highswings = filteredtopf == false ? na : valuewhen(filteredtopf == true, high[2], 2) < valuewhen(filteredtopf == true, high[2], 1) and valuewhen(filteredtopf == true, high[2], 1) > valuewhen(filteredtopf == true, high[2], 0)+highswings = filteredtopf == false ? na : ta.valuewhen(filteredtopf == true, high[2], 2) < ta.valuewhen(filteredtopf == true, high[2], 1) and ta.valuewhen(filteredtopf == true, high[2], 1) > ta.valuewhen(filteredtopf == true, high[2], 0)-lowswings = filteredbotf == false ? na : valuewhen(filteredbotf == true, low[2], 2) > valuewhen(filteredbotf == true, low[2], 1) and valuewhen(filteredbotf == true, low[2], 1) < valuewhen(filteredbotf == true, low[2], 0)+lowswings = filteredbotf == false ? na : ta.valuewhen(filteredbotf == true, low[2], 2) > ta.valuewhen(filteredbotf == true, low[2], 1) and ta.valuewhen(filteredbotf == true, low[2], 1) < ta.valuewhen(filteredbotf == true, low[2], 0)//---------------------------------------------------------------------------------------------------------⋯isbot = filteredbotf ? true : false-topcount = barssince(istop)+topcount = ta.barssince(istop)-botcount = barssince(isbot)+botcount = ta.barssince(isbot)vamp = input(title="VolumeMA",  defval=2)-vam = sma(volume, vamp)+vam = ta.sma(volume, vamp)fractalup = 0.0⋯//  ||---   Buy And Sell:-strategy.entry(id="Long", long=true, when = Signal_Test and afterStartDate)+strategy.entry(id="Long", direction = strategy.long, when = Signal_Test and afterStartDate)strategy.close_all(when = Signal_Test_OUT_TEMP and afterStartDate)⋯

Clean v5

VerifiedDownload the v5 script

Same 8 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 8: input() → input.int()
  • Line 9: input() → input.int()
  • Line 10: input() → input.int()
  • Line 17: input() → input.bool()
  • Line 18: input() → input.bool()
  • Line 19: input() → input.int()
7 more edits
  • Line 32: input() → input.bool()
  • Line 37: input() → input.bool()
  • Line 40: input() → input.bool()
  • Line 47: input() → input.int()
  • Line 90: input() → input.float()
  • Line 112: when = Signal_Test and afterStartDate → if block
  • Line 113: when = Signal_Test_OUT_TEMP and afterStartDate → if block
⋯cash_given_per_lot = cash_amout/pyramid_val-startDate = input(title="Start Date",defval=13)+startDate = input.int(title="Start Date",defval=13)-startMonth = input(title="Start Month",defval=9)+startMonth = input.int(title="Start Month",defval=9)-startYear = input(title="Start Year",defval=2021)+startYear = input.int(title="Start Year",defval=2021)afterStartDate = (time >= timestamp(syminfo.timezone,startYear, startMonth, startDate, 0, 0))⋯//  ||---   Fractal Recognition:-filterBW = input(true, title="filter Bill Williams Fractals:")+filterBW = input.bool(true, title="filter Bill Williams Fractals:")-filterFractals = input(true, title="Filter fractals using extreme method:")+filterFractals = input.bool(true, title="Filter fractals using extreme method:")-length = input(2, title="Extreme Window:")+length = input.int(2, title="Extreme Window:")regulartopfractal = high[4] < high[3] and high[3] < high[2] and high[2] > high[1] and high[1] > high[0]⋯//  ||---   V1 : Added Swing High/Low Option-ShowSwingsHL = input(true)+ShowSwingsHL = input.bool(true)highswings = filteredtopf == false ? na : ta.valuewhen(filteredtopf == true, high[2], 2) < ta.valuewhen(filteredtopf == true, high[2], 1) and ta.valuewhen(filteredtopf == true, high[2], 1) > ta.valuewhen(filteredtopf == true, high[2], 0)⋯//  ||---   V2 : Plot Lines based on the fractals.-showchannel = input(true)+showchannel = input.bool(true)//---------------------------------------------------------------------------------------------------------//  ||---   ZigZag:-showZigZag = input(true)+showZigZag = input.bool(true)//----------------------------------------------------------------------------------------------------------⋯botcount = ta.barssince(isbot)-vamp = input(title="VolumeMA",  defval=2)+vamp = input.int(title="VolumeMA",  defval=2)vam = ta.sma(volume, vamp)⋯var Signal_Test_TEMP = false-longLossPerc = input(title="Long Stop Loss (%)", minval=0.0, step=0.1, defval=0.01) * 0.01+longLossPerc = input.float(title="Long Stop Loss (%)", minval=0.0, step=0.1, defval=0.01) * 0.01if filteredbotf and open < Bottom_1 and (Bottom_1 - open) / Bottom_1 >= longLossPerc⋯//  ||---   Buy And Sell:-strategy.entry(id="Long", direction = strategy.long, when = Signal_Test and afterStartDate)+if Signal_Test and afterStartDate+    strategy.entry(id="Long", direction = strategy.long)-strategy.close_all(when = Signal_Test_OUT_TEMP and afterStartDate)+if Signal_Test_OUT_TEMP and afterStartDate+    strategy.close_all()//----------------------------------------------------------------------------------------------------------

Does it run in Pine Script v6?

Yes

Same 8 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.

Download the v6 script

-// @version = 5+// @version = 6// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/⋯

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
Start Date13intafterStartDate
Start Month9intafterStartDate
Start Year2021intafterStartDate
filter Bill Williams Fractals:trueboolbillwtopfractal billwbotfractal ftop fbot
Filter fractals using extreme method:trueboolfilteredtopf filteredbotf
Extreme Window:2inttopf botf
Show Swings HL (no label in the script)trueboolunused
Showchannel (no label in the script)trueboolplot
Show Zig Zag (no label in the script)trueboolunused
VolumeMA2intvam
Long Stop Loss (%)0.01float · min 0.0 · step 0.1line 91

What it calculates

  • Highest (highest, ta.highest in v5)high, Extreme Window: (2)topf · line 26
  • Lowest (lowest, ta.lowest in v5)low, Extreme Window: (2)botf · line 27
  • Valuewhen (valuewhen, ta.valuewhen in v5)filteredtopf == true, high[2], 2highswings · line 33
  • Valuewhen (valuewhen, ta.valuewhen in v5)filteredbotf == true, low[2], 2lowswings · line 34
  • Barssince (barssince, ta.barssince in v5)istoptopcount · line 45
  • Barssince (barssince, ta.barssince in v5)isbotbotcount · line 46
  • SMA (sma, ta.sma in v5)volume, VolumeMA (2)vam · line 48

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.

highhighprice datalengthExtreme Window:setting · 2lowlowprice datavolumevolumeprice datavampVolumeMAsetting · 2timetimeprice datastartYearStart Yearsetting · 2021startMonthStart Monthsetting · 9startDateStart Datesetting · 13topfHighest→ topfbotfLowest→ botfhighswingsValuewhen→ highswingslowswingsValuewhen→ lowswingstopcountBarssince→ topcountbotcountBarssince→ botcountvamSMA→ vamcash_given_per_lot, Bottom_1, Bottom_2, Bottom_3, Top_1, Top_2, Top_3cash_given_per_lot · Bo…7 valuesbillwtopfractalbillwtopfractalvaluebillwbotfractalbillwbotfractalvalueftopftopvaluefbotfbotvaluefilteredtopffilteredtopfvaluefilteredbotffilteredbotfvalueistopistopvalueisbotisbotvaluefractalupfractalupvaluefractaldownfractaldownvalueafterStartDateafterStartDateconditionregulartopfractalregulartopfractalconditionregularbotfractalregularbotfractalconditionupupconditiondowndownconditionentry:LongOpen Longstrategy.entryclose_all:close_all strategy.close_allplot:104plotplotplot:105plotplotplot:106plotplotplot:107plotplotplotshape:108plotshapeplotshapeplotshape:109plotshapeplotshape

Order rules

OrderFires whenBy defaultLine
Open Long longSignal_Test and afterStartDateOn112
Close Signal_Test_OUT_TEMP and afterStartDateOn113

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Does it repaint?

No

No repainting patterns in the source, and the live replay matched history.

2/2trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.
  • ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
  • 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

The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D−2.9%+102.5%838%0.465.9%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−0.8%+5.5%650%0.552.4%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−1.4%+9.8%743%0.858.9%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+2.3%+8.4%540%1.982.9%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+3.0%+16.7%863%1.515.3%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−0.4%+21.5%450%0.833.4%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.6%+148.3%667%1.433.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+4.7%+17.1%10100%—0.5%8 May 2026 – 21 Oct 2026

Backtests are simulations on historical data and are not investment advice.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market250%$556.48
Sideways market540%−$1,732.30
Falling market10%−$1,763.22

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

5.3%

The 95th percentile of the worst drawdown when the same 8 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 2.9% to 5.3%; the tick is what actually happened, 4.9%. Order luck alone moves it this much.

0%6%
All 8 trades
SideEntryExitBarsP&L
long4 May 2024 62,882.0024 May 2024 67,969.7020$809.08
long17 Jun 2024 66,676.9025 Jul 2024 65,376.0038−$195.10
long8 Aug 2024 55,133.8016 Sep 2024 59,132.0039$725.18
long6 Feb 2025 96,612.401 May 2025 94,172.0084−$252.60
long29 Aug 2025 112,567.009 Oct 2025 123,306.0041$954.02
long13 Oct 2025 114,959.008 Jan 2026 91,364.2087−$2,052.44
long24 Jan 2026 89,600.3020 Apr 2026 73,801.8086−$1,763.22
long1 Jun 2026 73,674.4024 Jul 2026 65,099.0053−$1,163.96

Similar scripts

Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.

ScriptSharesTypeNetTradesMax drawdown
TradingGroundhog - Strategy & Fractal V1 this page—v4 strategy−2.9%85.9%
TradingGroundhog - Strategy & Wavetrend V2 by UnknownUnicorn27666852highest lowest valuewhen barssince smav5 strategy−0.0%20.0%
Trend Bounce [racer8] by racer8highest lowest sma valuewhenv4 strategy+2.4%2232.2%
Coral Trend Pullback Strategy (TradeIQ) by kevinmck100sma lowest highest barssincev5 strategy−1.0%11.0%
Buying Dip Strategy With Take Profit And Stop Loss [racer8] by racer8sma valuewhen lowestv4 strategy−22.3%3434.7%
ChBrkOutStrategySMA by anshuanshu333sma highest lowestv4 strategy−4.5%4220.9%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 56 msWith a workaround 1,000 bars in 5,141 msNot measured
PineTSNo v5 and v6 only—Not measured

Zeal Terminal's engine currently reads an order side written as long = true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 112) so the engine trades the way the script says.

“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.

// @version = 4// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © TradingGroundhog//  ||---   Cash & Date:cash_amout = 10000pyramid_val = 1cash_given_per_lot = cash_amout/pyramid_valstartDate = input(title="Start Date",defval=13)startMonth = input(title="Start Month",defval=9)startYear = input(title="Start Year",defval=2021)afterStartDate = (time >= timestamp(syminfo.timezone,startYear, startMonth, startDate, 0, 0))//  ||------------------------------------------------------------------------------------------------------//  ||---   Strategy:strategy(title="TradingGroundhog - Strategy & Fractal V1 - Short term", overlay=true, max_bars_back = 4000, max_labels_count=500, commission_type=strategy.commission.percent, commission_value=0.00,default_qty_type=strategy.cash, default_qty_value= cash_given_per_lot, pyramiding=pyramid_val)//  ||------------------------------------------------------------------------------------------------------//  ||---   Fractal Recognition:filterBW = input(true, title="filter Bill Williams Fractals:")filterFractals = input(true, title="Filter fractals using extreme method:")length = input(2, title="Extreme Window:")regulartopfractal = high[4] < high[3] and high[3] < high[2] and high[2] > high[1] and high[1] > high[0]regularbotfractal = low[4] > low[3] and low[3] > low[2] and low[2] < low[1] and low[1] < low[0]billwtopfractal = filterBW ? false : (high[4] < high[2] and high[3] < high[2] and high[2] > high[1] and high[2] > high[0] ? true : false)billwbotfractal = filterBW ? false : (low[4] > low[2] and low[3] > low[2] and low[2] < low[1] and low[2] < low[0] ? true : false)ftop = filterBW ? regulartopfractal : regulartopfractal or billwtopfractalfbot = filterBW ? regularbotfractal : regularbotfractal or billwbotfractaltopf = ftop ? high[2] >= highest(high, length) ? true : false : falsebotf = fbot ? low[2] <= lowest(low, length) ? true : false : falsefilteredtopf = filterFractals ? topf : ftopfilteredbotf = filterFractals ? botf : fbot//  ||------------------------------------------------------------------------------------------------------//  ||---   V1 : Added Swing High/Low OptionShowSwingsHL = input(true)highswings = filteredtopf == false ? na : valuewhen(filteredtopf == true, high[2], 2) < valuewhen(filteredtopf == true, high[2], 1) and valuewhen(filteredtopf == true, high[2], 1) > valuewhen(filteredtopf == true, high[2], 0)lowswings = filteredbotf == false ? na : valuewhen(filteredbotf == true, low[2], 2) > valuewhen(filteredbotf == true, low[2], 1) and valuewhen(filteredbotf == true, low[2], 1) < valuewhen(filteredbotf == true, low[2], 0)//---------------------------------------------------------------------------------------------------------//  ||---   V2 : Plot Lines based on the fractals.showchannel = input(true)//---------------------------------------------------------------------------------------------------------//  ||---   ZigZag:showZigZag = input(true)//----------------------------------------------------------------------------------------------------------//  ||---   Fractal computation:istop = filteredtopf ? true : falseisbot = filteredbotf ? true : falsetopcount = barssince(istop)botcount = barssince(isbot)vamp = input(title="VolumeMA",  defval=2)vam = sma(volume, vamp)fractalup = 0.0fractaldown = 0.0up = high[3]>high[4] and high[4]>high[5] and high[2]<high[3] and high[1]<high[2] and volume[3]>vam[3]down = low[3]<low[4] and low[4]<low[5] and low[2]>low[3] and low[1]>low[2] and volume[3]>vam[3]fractalup :=  up ? high[3] : fractalup[1] fractaldown := down ? low[3] : fractaldown[1]//----------------------------------------------------------------------------------------------------------//  ||---   Fractal save:fractaldown_save = array.new_float(0)for i = 0 to 4000    if array.size(fractaldown_save) < 3        if array.size(fractaldown_save) == 0            array.push(fractaldown_save, fractaldown[i])        else             if fractaldown[i] != array.get(fractaldown_save, array.size(fractaldown_save)-1)                array.push(fractaldown_save, fractaldown[i])if array.size(fractaldown_save) < 3    array.push(fractaldown_save, fractaldown)    array.push(fractaldown_save, fractaldown)fractalup_save = array.new_float(0)for i = 0 to 4000    if array.size(fractalup_save) < 3        if array.size(fractalup_save) == 0            array.push(fractalup_save, fractalup[i])        else             if fractalup[i] != array.get(fractalup_save, array.size(fractalup_save)-1)                array.push(fractalup_save, fractalup[i])if array.size(fractalup_save) < 3    array.push(fractalup_save, fractalup)    array.push(fractalup_save, fractalup)Bottom_1 = array.get(fractaldown_save,  0)Bottom_2 = array.get(fractaldown_save,  1)Bottom_3 = array.get(fractaldown_save,  2)Top_1 = array.get(fractalup_save, 0)Top_2 = array.get(fractalup_save, 1)Top_3 = array.get(fractalup_save, 2)//----------------------------------------------------------------------------------------------------------//  ||---   Fractal Buy Sell Signal:bool Signal_Test = falsebool Signal_Test_OUT_TEMP = falsevar Signal_Test_TEMP = falselongLossPerc = input(title="Long Stop Loss (%)", minval=0.0, step=0.1, defval=0.01) * 0.01if filteredbotf and open < Bottom_1 and (Bottom_1 - open) / Bottom_1 >= longLossPerc    Signal_Test := trueif filteredtopf and open > Top_1    Signal_Test_TEMP := trueif filteredtopf and Signal_Test_TEMP    Signal_Test_TEMP := false    Signal_Test_OUT_TEMP := true//----------------------------------------------------------------------------------------------------------//  ||---   Plotting://plotshape(filteredtopf, style=shape.triangledown, location=location.abovebar, color=color.red, text="•", offset=0)//plotshape(filteredbotf, style=shape.triangleup, location=location.belowbar, color=color.lime, text="•", offset=0)//plotshape(ShowSwingsHL ? highswings : na, style=shape.triangledown, location=location.abovebar, color=color.maroon, text="H", offset=0)//plotshape(ShowSwingsHL ? lowswings : na, style=shape.triangleup, location=location.belowbar, color=color.green, text="L", offset=0)plot(showchannel ? (filteredtopf ? high[2] : na) : na, color=color.black, offset=0)plot(showchannel ? (filteredbotf ? low[2] : na) : na, color=color.black, offset=0)plot(showchannel ? (highswings ? high[2] : na) : na, color=color.black, offset=-2)plot(showchannel ? (lowswings ? low[2] : na) : na, color=color.black, offset=-2)plotshape(Signal_Test, style=shape.flag, location=location.belowbar, color=color.yellow, offset=0)plotshape(Signal_Test_OUT_TEMP, style=shape.flag, location=location.abovebar, color=color.white, offset=0)//----------------------------------------------------------------------------------------------------------//  ||---   Buy And Sell:strategy.entry(id="Long", long=true, when = Signal_Test and afterStartDate)strategy.close_all(when = Signal_Test_OUT_TEMP and afterStartDate)//----------------------------------------------------------------------------------------------------------