Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

© Investoz trendwarning

A Pine Script v4 strategy built on EMA (close, 21), Crossover (aema1, gema7) and Crossunder (aema1, gema7). 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 10% of equity and pays no commission. 16 settings; defaults include Lila linje 21, Blå linje 34 and Grön linje 55.

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 © Investoz trendwarning repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did © Investoz trendwarning 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; it opened a long position that was still open on the last bar, so there is no result to report. On ETHUSDT 1D it did trade; that row of the markets table below has its figures. A backtest, not investment advice.
Can © Investoz trendwarning 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 © Investoz trendwarning use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does © Investoz trendwarning run in Zeal Terminal?
Yes
It compiles in 37 ms and runs 1,000 bars in 84 ms, in the browser.

BTCUSDT · 1D · default settings

  • Lila linje
  • Blå linje
  • Grön linje
  • Gul linje
  • Orange linje
  • Röd linje
  • Brun linje
  • 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 (16)
Negative Trend.Positive Trend.========================40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$100,434$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. Lines, boxes and labels are the script's own drawings, the most recent ones its limits keep.
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.17%
−$169.75

One run with the author's default settings, $100,000 starting capital, commission as the script sets it. A long position was still open at the last bar. 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.

  • Likely bug

    ema(close, 1) ignores the settings line 60

    Line 60 hard-codes close where line 36 uses “Source” and 1 where line 36 uses “Lila linje”. Changing those settings moves one band but not this one.

    ema(close,1)ema(src, ema1)
  • Likely bug

    ema(close, 1) ignores the settings line 63

    Line 63 hard-codes close where line 36 uses “Source” and 1 where line 36 uses “Lila linje”. Changing those settings moves one band but not this one.

    ema(close,1)ema(src, ema1)
  • 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

    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 92, 95. The upgraded version below moves each call inside an if block.

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 ema → ta.ema, crossover → ta.crossover, crossunder → ta.crossunder, valuewhen → ta.valuewhen, cum → ta.cum, tostring → str.tostring.
  • 2 strategy calls use the when = argument (line 92, 95). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

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

  • Line 9: //@version=4 → //@version=5
  • Line 36: ema → ta.ema
  • Line 37: ema → ta.ema
  • Line 38: ema → ta.ema
  • Line 39: ema → ta.ema
  • Line 40: ema → ta.ema
15 more edits
  • Line 41: ema → ta.ema
  • Line 42: ema → ta.ema
  • Line 59: crossover → ta.crossover
  • Line 60: ema → ta.ema
  • Line 62: crossunder → ta.crossunder
  • Line 63: ema → ta.ema
  • Line 97: valuewhen → ta.valuewhen
  • Line 98: valuewhen → ta.valuewhen
  • Line 100: cum → ta.cum
  • Line 109: valuewhen → ta.valuewhen
  • Line 110: valuewhen → ta.valuewhen
  • Line 112: cum → ta.cum
  • Line 123: tostring → str.tostring
  • Line 124: tostring → str.tostring
  • Line 125: tostring → str.tostring
⋯// Det är fritt fram för vem som helst att använda sig av denna indikator.  -//@version=4+//@version=5//Skapar en strategiskript med 1 % av eget kapital som ett exempel. Detta går att ändra i skriptets inställningar, välj egenskaper och sedan ändra orderstorlek⋯//EMA-aema1 = ema(src, ema1)+aema1 = ta.ema(src, ema1)-bema2 = ema(src, ema2)+bema2 = ta.ema(src, ema2)-cema3 = ema(src, ema3)+cema3 = ta.ema(src, ema3)-dema4 = ema(src, ema4)+dema4 = ta.ema(src, ema4)-eema5 = ema(src, ema5)+eema5 = ta.ema(src, ema5)-fema6 = ema(src, ema6)+fema6 = ta.ema(src, ema6)-gema7 = ema(src, ema7)+gema7 = ta.ema(src, ema7)//Skriver ut linjer i diagrammet om förhållandet är sant, annars falskt.⋯//Skapa en algoritm för positiv trend-PositivTrend = crossover(aema1,gema7)?1:0+PositivTrend = ta.crossover(aema1,gema7)?1:0-TrendPositiv = ema(close,1) > aema1 and aema1 > bema2?1:0+TrendPositiv = ta.ema(close,1) > aema1 and aema1 > bema2?1:0//Skapa en algoritm för negativ trend-NegativTrend = crossunder(aema1,gema7)?1:0+NegativTrend = ta.crossunder(aema1,gema7)?1:0-TrendNegativ = ema(close,1) < aema1 and aema1 < bema2?1:0+TrendNegativ = ta.ema(close,1) < aema1 and aema1 < bema2?1:0//Skapar en textruta med varningstext för positiv trend⋯//Beräkning av positiv trend-vspositiv(positiv)=>valuewhen(Endbar==startbar,positiv,0)+vspositiv(positiv)=>ta.valuewhen(Endbar==startbar,positiv,0)-vepositiv(positiv)=>valuewhen(Endbar==Endbar,positiv,0)+vepositiv(positiv)=>ta.valuewhen(Endbar==Endbar,positiv,0)positivmean(TrendPositiv)=>-    csumpositiv = cum(TrendPositiv)+    csumpositiv = ta.cum(TrendPositiv)//Slut//   ⋯//Beräkning av negativ trend-vsnegativ(negativ)=>valuewhen(Endbar==startbar,negativ,0)+vsnegativ(negativ)=>ta.valuewhen(Endbar==startbar,negativ,0)-venegativ(negativ)=>valuewhen(Endbar==Endbar,negativ,0)+venegativ(negativ)=>ta.valuewhen(Endbar==Endbar,negativ,0)negativmean(TrendNegativ)=>-    csumnegativ = cum(TrendNegativ)+    csumnegativ = ta.cum(TrendNegativ)//Slut//   ⋯streck = "==============================================="-totalastaplar = "\n" + "Total number of days: " + tostring(tid)+ " days "+"\n"+ streck + "\n"+totalastaplar = "\n" + "Total number of days: " + str.tostring(tid)+ " days "+"\n"+ streck + "\n"-totalpositiv = "Total number of days in positive trend "+" 📈 : "  +tostring(positivmeanpositiv*tid, "##.##") +" days " + "\n"+totalpositiv = "Total number of days in positive trend "+" 📈 : "  +str.tostring(positivmeanpositiv*tid, "##.##") +" days " + "\n"-totalnegativ = "\n" + "Total number of days in negative trend" + " 📉 : "  +tostring(negativmeannegativ*tid, "##.##") +" days " +"\n"+totalnegativ = "\n" + "Total number of days in negative trend" + " 📉 : "  +str.tostring(negativmeannegativ*tid, "##.##") +" days " +"\n"//Textruta för antal staplar i trend⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 14: input() → input.int()
  • Line 15: input() → input.bool()
  • Line 16: input() → input.int()
  • Line 17: input() → input.bool()
  • Line 18: input() → input.int()
  • Line 19: input() → input.bool()
12 more edits
  • Line 20: input() → input.int()
  • Line 21: input() → input.bool()
  • Line 22: input() → input.int()
  • Line 23: input() → input.bool()
  • Line 24: input() → input.int()
  • Line 25: input() → input.bool()
  • Line 26: input() → input.int()
  • Line 27: input() → input.bool()
  • Line 29: input() → input.int()
  • Line 32: input() → input.source()
  • Line 92: when = PositivTrend → if block
  • Line 95: when = NegativTrend → if block
⋯//Lägger till inmatningar till skriptindikatorn. Användaren kan se och redigera inmatningar i objektdialogen efter eget val.-ema1 = input(21, minval=1, maxval=500, title="Lila linje")+ema1 = input.int(21, minval=1, maxval=500, title="Lila linje")-valema1=input(true, title="Visa lila linje")+valema1=input.bool(true, title="Visa lila linje")-ema2 = input(34, minval=1, maxval=500, title="Blå linje")+ema2 = input.int(34, minval=1, maxval=500, title="Blå linje")-valema2=input(true, title="Visa blå linje")+valema2=input.bool(true, title="Visa blå linje")-ema3 = input(55, minval=1, maxval=500, title="Grön linje")+ema3 = input.int(55, minval=1, maxval=500, title="Grön linje")-valema3=input(true, title="Visa grön linje")+valema3=input.bool(true, title="Visa grön linje")-ema4 = input(89, minval=1, maxval=500, title="Gul linje")+ema4 = input.int(89, minval=1, maxval=500, title="Gul linje")-valema4=input(true, title="Visa gul linje")+valema4=input.bool(true, title="Visa gul linje")-ema5 = input(141, minval=1, maxval=500, title="Orange linje")+ema5 = input.int(141, minval=1, maxval=500, title="Orange linje")-valema5=input(true, title="Visa orange linje")+valema5=input.bool(true, title="Visa orange linje")-ema6 = input(230, minval=1, maxval=500, title="Röd linje")+ema6 = input.int(230, minval=1, maxval=500, title="Röd linje")-valema6=input(true, title="Visa röd linje")+valema6=input.bool(true, title="Visa röd linje")-ema7 = input(371, minval=1, maxval=500, title="Röd linje")+ema7 = input.int(371, minval=1, maxval=500, title="Röd linje")-valema7=input(true, title="Visa röd linje")+valema7=input.bool(true, title="Visa röd linje")//Inmatningar för antal staplar-startbar = input(1, minval=1, title="First Bar")+startbar = input.int(1, minval=1, title="First Bar")Endbar = bar_index + 1//Källa input, stängning. Användaren kan själv byta till vilken källa som önskas.-src = input(close, title="Source")+src = input.source(close, title="Source")//Antal staplar sedan den längsta ema började och framåt. ⋯if (PositivTrend) -    strategy.entry("Take position", strategy.long, when = PositivTrend)+    if PositivTrend+        strategy.entry("Take position", strategy.long)//Sälj om negativ trendif (NegativTrend)-    strategy.close("Take position", when = NegativTrend, comment="Close position")+    if NegativTrend+        strategy.close("Take position", comment="Close position")//Beräkning av positiv trend⋯

Does it run in Pine Script v6?

Yes

Same 1 trades and the same P&L on ETHUSDT 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

⋯// Det är fritt fram för vem som helst att använda sig av denna indikator.  -//@version=5+//@version=6//Skapar en strategiskript med 1 % av eget kapital som ett exempel. Detta går att ändra i skriptets inställningar, välj egenskaper och sedan ändra orderstorlek⋯

Settings

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

SettingDefaultType and rangeFeeds
Lila linje21int · min 1 · max 500aema1
Visa lila linjetrueboolLila linje
Blå linje34int · min 1 · max 500bema2
Visa blå linjetrueboolBlå linje
Grön linje55int · min 1 · max 500cema3
Visa grön linjetrueboolGrön linje
Gul linje89int · min 1 · max 500dema4
Visa gul linjetrueboolGul linje
Orange linje141int · min 1 · max 500eema5
Visa orange linjetrueboolOrange linje
Röd linje230int · min 1 · max 500fema6
Visa röd linjetrueboolRöd linje
Röd linje371int · min 1 · max 500gema7
Visa röd linjetrueboolBrun linje
First Bar1int · min 1tid line 97 line 109
Sourceclosesourceaema1 bema2 cema3 dema4 eema5 fema6 gema7

What it calculates

  • EMA (ema, ta.ema in v5)Source (close), Lila linje (21)aema1 · line 36
  • EMA (ema, ta.ema in v5)Source (close), Blå linje (34)bema2 · line 37
  • EMA (ema, ta.ema in v5)Source (close), Grön linje (55)cema3 · line 38
  • EMA (ema, ta.ema in v5)Source (close), Gul linje (89)dema4 · line 39
  • EMA (ema, ta.ema in v5)Source (close), Orange linje (141)eema5 · line 40
  • EMA (ema, ta.ema in v5)Source (close), Röd linje (230)fema6 · line 41
  • EMA (ema, ta.ema in v5)Source (close), Röd linje (371)gema7 · line 42
  • Crossover (crossover, ta.crossover in v5)aema1, gema7PositivTrend · line 59
  • EMA (ema, ta.ema in v5)close, 1TrendPositiv · line 60
  • Crossunder (crossunder, ta.crossunder in v5)aema1, gema7NegativTrend · line 62
  • EMA (ema, ta.ema in v5)close, 1TrendNegativ · line 63
  • CUM (cum, ta.cum in v5)TrendPositivcsumpositiv · line 100
  • CUM (cum, ta.cum in v5)TrendNegativcsumnegativ · line 112

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.

closecloseprice dataema1Lila linjesetting · 21ema2Blå linjesetting · 34ema3Grön linjesetting · 55ema4Gul linjesetting · 89ema5Orange linjesetting · 141ema6Röd linjesetting · 230ema7Röd linjesetting · 371startbarFirst Barsetting · 1lowlowprice dataaema1EMA→ aema1bema2EMA→ bema2cema3EMA→ cema3dema4EMA→ dema4eema5EMA→ eema5fema6EMA→ fema6gema7EMA→ gema7PositivTrendCrossover→ PositivTrendTrendPositivEMA→ TrendPositivNegativTrendCrossunder→ NegativTrendTrendNegativEMA→ TrendNegativcsumpositivCUM→ csumpositivcsumnegativCUM→ csumnegativEndbarEndbarvaluetidtidvaluea, ba · b2 valuespositivmeanpositivpositivmeanpositivvaluenegativmeannegativnegativmeannegativvaluevarningpositiv, varningnegativ, barcountlblColourvarningpositiv · varningnegat…entry:Take positionOpen Take positionstrategy.entryclose:Take positionClose Take positionstrategy.closeplot:44Lila linjeplotplot:45Blå linjeplotplot:46Grön linjeplotplot:47Gul linjeplotplot:48Orange linjeplotplot:49Röd linjeplotplot:50Brun linjeplotfill:52Fillfill × 6fill:53Fillfill × 6fill:54Fillfill × 6fill:55Fillfill × 6fill:56Fillfill × 6fill:57Fillfill × 6

Order rules

OrderFires whenBy defaultLine
Open Take position longPositivTrendOn92
Close Take positionNegativTrendOn95

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.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • 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 1D0.0%+102.5%00%—0.2%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h0.0%+5.5%00%—0.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−0.7%+9.8%10%0.001.5%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+2.0%+8.4%520%3.450.9%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−2.8%+16.7%20%0.004.2%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+3.6%+21.5%1100%—0.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D0.0%+148.3%00%—0.8%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+1.7%+17.1%250%22.280.2%8 May 2026 – 21 Oct 2026

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

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
© Investoz trendwarning this page—v4 strategy0.0%00.2%
On-Balance Volume by Zeal Terminalcum emav5 indicatorindicator
Chaikin Oscillator by Zeal Terminalcum emav5 indicatorindicator
OBV Pyr by RafaelZioniema cumv4 strategy−1.2%279.5%
MACD Strategy with trailing ATR stop by Wunderbitcum emav4 strategy+72.7%8953.7%
Full CRYPTO pack macd, rsi, obv, ema strategy by SoftKill21ema cumv4 strategyNo trades on this market

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 37 msYes 1,000 bars in 84 msNot measured
PineTSNo v5 and v6 only—Not measured

“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/// © Investoz// Indikatorn är byggd som ett utbildningsyfte och är därför ingen rekommendation för köp/sälj av aktier. Tanken är att skapa en visuell form i en graf// som visar om det finns någon trend såväl positiv som negativ. En dialogruta med en varning talar om vilken trend som råder. I koden finns en möjlighet// att ta position eller gå ur position om man vill skapa en startegi kring denna trendindikator. Rekommenderar dock starkt att inte enbart förlita sig på denna// indikator som beslut för köp/sälj då resultaten blir negativa om man köper på psoitiv trend och säljer på negativ trend. Det måste kombineras med andra idéer// och därför fungerar denna skript mer som ett komplement till sin egen strategi.// Det är fritt fram för vem som helst att använda sig av denna indikator.  //@version=4//Skapar en strategiskript med 1 % av eget kapital som ett exempel. Detta går att ändra i skriptets inställningar, välj egenskaper och sedan ändra orderstorlek//till ett annat värde av % på eget kapital.strategy("© Investoz Trend Warning", overlay=true, initial_capital=100000, default_qty_type = strategy.percent_of_equity, default_qty_value = 10, pyramiding = 0, margin_long = 0.5)//Lägger till inmatningar till skriptindikatorn. Användaren kan se och redigera inmatningar i objektdialogen efter eget val.ema1 = input(21, minval=1, maxval=500, title="Lila linje")valema1=input(true, title="Visa lila linje")ema2 = input(34, minval=1, maxval=500, title="Blå linje")valema2=input(true, title="Visa blå linje")ema3 = input(55, minval=1, maxval=500, title="Grön linje")valema3=input(true, title="Visa grön linje")ema4 = input(89, minval=1, maxval=500, title="Gul linje")valema4=input(true, title="Visa gul linje")ema5 = input(141, minval=1, maxval=500, title="Orange linje")valema5=input(true, title="Visa orange linje")ema6 = input(230, minval=1, maxval=500, title="Röd linje")valema6=input(true, title="Visa röd linje")ema7 = input(371, minval=1, maxval=500, title="Röd linje")valema7=input(true, title="Visa röd linje")//Inmatningar för antal staplarstartbar = input(1, minval=1, title="First Bar")Endbar = bar_index + 1//Källa input, stängning. Användaren kan själv byta till vilken källa som önskas.src = input(close, title="Source")//Antal staplar sedan den längsta ema började och framåt. tid=Endbar + startbar - 1//EMAaema1 = ema(src, ema1)bema2 = ema(src, ema2)cema3 = ema(src, ema3)dema4 = ema(src, ema4)eema5 = ema(src, ema5)fema6 = ema(src, ema6)gema7 = ema(src, ema7)//Skriver ut linjer i diagrammet om förhållandet är sant, annars falskt.h=plot(valema1 ? aema1 : na, title="Lila linje", style=plot.style_line, linewidth=1, color=#7b9b97)i=plot(valema2 ? bema2 : na, title="Blå linje", style=plot.style_line, linewidth=1, color=#a2b6b3)j=plot(valema3 ? cema3 : na, title="Grön linje", style=plot.style_line, linewidth=1, color=#d9e5e3)k=plot(valema4 ? dema4 : na, title="Gul linje", style=plot.style_line, linewidth=1, color=#ff8383)l=plot(valema5 ? eema5 : na, title="Orange linje", style=plot.style_line, linewidth=1, color=#dc6262)m=plot(valema6 ? fema6 : na, title="Röd linje", style=plot.style_line, linewidth=1, color=#b71c1c)n=plot(valema7 ? gema7 : na, title="Brun linje", style=plot.style_line, linewidth=1, color=color.maroon)//Fyller bakgrunden mellan två linjer med en viss färg.fill(h, i, color = color.new(#7b9b97,34))fill(i, j, color = color.new(#a2b6b3,34))fill(j, k, color = color.new(#d9e5e3,34))fill(k, l, color = color.new(#ff8383,34))fill(l, m, color = color.new(#dc6262,34))fill(m, n, color = color.new(#b71c1c,34))//Skapa en algoritm för positiv trendPositivTrend = crossover(aema1,gema7)?1:0TrendPositiv = ema(close,1) > aema1 and aema1 > bema2?1:0//Skapa en algoritm för negativ trendNegativTrend = crossunder(aema1,gema7)?1:0TrendNegativ = ema(close,1) < aema1 and aema1 < bema2?1:0//Skapar en textruta med varningstext för positiv trendvarningtextpositiv = "Positive Trend."+"\n" + "Take position"if PositivTrend    varningpositiv=label.new(     bar_index,      low,       xloc=xloc.bar_index,      yloc=yloc.price,     color=#7b9b97,      textcolor=color.white,     text=varningtextpositiv,     style=label.style_label_down,     textalign=text.align_left)//Skapar en textruta med varningstext för negativ trendvarningtextnegativ = "Negative Trend."+"\n" + "Cover the positions"if NegativTrend    varningnegativ=label.new(     bar_index,      low,       xloc=xloc.bar_index,      yloc=yloc.price,     color=#b71c1c,      textcolor=color.white,     text=varningtextnegativ,     style=label.style_label_up,     textalign=text.align_left)//Köp om positiv trendif (PositivTrend)     strategy.entry("Take position", strategy.long, when = PositivTrend)//Sälj om negativ trendif (NegativTrend)    strategy.close("Take position", when = NegativTrend, comment="Close position")//Beräkning av positiv trendvspositiv(positiv)=>valuewhen(Endbar==startbar,positiv,0)vepositiv(positiv)=>valuewhen(Endbar==Endbar,positiv,0)positivmean(TrendPositiv)=>    csumpositiv = cum(TrendPositiv)//Slut//       a = vepositiv(csumpositiv)//Start//    b = vspositiv(csumpositiv)//Slut - Start//     (a - b)/(tid)positivmeanpositiv = positivmean(TrendPositiv) //Beräkning av negativ trendvsnegativ(negativ)=>valuewhen(Endbar==startbar,negativ,0)venegativ(negativ)=>valuewhen(Endbar==Endbar,negativ,0)negativmean(TrendNegativ)=>    csumnegativ = cum(TrendNegativ)//Slut//       a = venegativ(csumnegativ)//Start//    b = vsnegativ(csumnegativ)//Slut - Start//     (a - b)/(tid)negativmeannegativ = negativmean(TrendNegativ) //Inmatning av text som ska in i texruta som visar antal staplar i trendlogga = "\n"+"© Investoz: Trend Warning"+ "\n"streck = "==============================================="totalastaplar = "\n" + "Total number of days: " + tostring(tid)+ " days "+"\n"+ streck + "\n"totalpositiv = "Total number of days in positive trend "+" 📈 : "  +tostring(positivmeanpositiv*tid, "##.##") +" days " + "\n"totalnegativ = "\n" + "Total number of days in negative trend" + " 📉 : "  +tostring(negativmeannegativ*tid, "##.##") +" days " +"\n"//Textruta för antal staplar i trendif barstate.ishistory    barcountlbl=label.new(     bar_index,      low,       xloc=xloc.bar_index,      yloc=yloc.price,     color=color.white,      textcolor=color.black,     text=streck+logga+streck+totalastaplar+totalpositiv+streck+totalnegativ+streck,     style=label.style_label_lower_left,     textalign=text.align_left)    label.delete(barcountlbl[1])//////////////////////////////////