Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Ichimoku Long and Short Strategy

A Pine Script v4 strategy built on ATR (14). It has 8 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays no commission. 17 settings; defaults include Conversion Line Length 9, Base Line Length 26 and Lagging Span 2 Length 52.

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 Ichimoku Long and Short Strategy repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 3 of 3 trades.
How did Ichimoku Long and Short Strategy do on BTCUSDT 1D with default settings?
+80.91%
From 26 Jan 2024 to 21 Oct 2026, over 13 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Ichimoku Long and Short Strategy 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 Ichimoku Long and Short Strategy use a stop loss?
Yes
strategy.exit sets a stop on line 68, 84.
Does Ichimoku Long and Short Strategy run in Zeal Terminal?
Yes
It compiles in 51 ms and runs 1,000 bars in 116 ms, in the browser.

BTCUSDT · 1D · default settings

  • Long Signal
  • Short Signal
  • Take profit
  • Middle Line
  • Stop Loss
  • Conversion Line
  • Base Line
  • Lagging Span
  • Lead 1
  • Lead 2
  • 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 (15)
-----------Long conditio50,00075,000100,000125,000AprJulOct2025AprJulOct2026AprJulOct$180,905$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
+80.91%
$80,913.50
Buy and hold
+102.5%
same period
Closed trades
13
6 won · 7 lost
Profitable
46.2%
of closed trades
Profit factor
1.20
gross profit ÷ gross loss
Max drawdown
148.19%
−$180,854.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

    1 setting does nothing

    “Entry Strategy” is declared but never read.

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

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 avg → math.avg, lowest → ta.lowest, highest → ta.highest, atr → ta.atr, tostring → str.tostring.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 10: input(type = input.string) → input.string()
  • Line 11: input(type = input.string) → input.string()
  • Line 12: input(type = input.integer) → input.int()
  • Line 13: input(type = input.float) → input.float()
  • Line 14: input(type = input.float) → input.float()
15 more edits
  • Line 15: input(type = input.bool) → input.bool()
  • Line 16: input(type = input.bool) → input.bool()
  • Line 17: input(type = input.bool) → input.bool()
  • Line 18: input(type = input.color) → input.color()
  • Line 19: input(type = input.color) → input.color()
  • Line 20: input(type = input.integer) → input.int()
  • Line 21: input(type = input.bool) → input.bool()
  • Line 22: input(type = input.bool) → input.bool()
  • Line 23: avg → math.avg
  • Line 23: lowest → ta.lowest
  • Line 23: highest → ta.highest
  • Line 26: avg → math.avg
  • Line 52: atr → ta.atr
  • Line 105: text is reserved in v5: renamed text_
  • Line 127: tostring → str.tostring
⋯// © M3RZI-//@version=4+//@version=5strategy("Ichimoku Strategy", overlay = true)⋯displacement = input(26, minval=1, title="Displacement", group = "Ichimoku Settings")-entryStrategy = input(title = "Entry Strategy", defval = "Ichimoku", options = ["Ichimoku"], type =  input.string, group = "Entry Strategy")+entryStrategy = input.string(title = "Entry Strategy", defval = "Ichimoku", options = ["Ichimoku"], group = "Entry Strategy")-exitStrategy = input(title = "Exit Strategy", defval = "Ichimoku", options = ["Ichimoku","ATR Pullback"], type = input.string, group = "Position Exit Settings")+exitStrategy = input.string(title = "Exit Strategy", defval = "Ichimoku", options = ["Ichimoku","ATR Pullback"], group = "Position Exit Settings")-exitATRLength = input(14, title = "ATR Length", minval = 1 ,type = input.integer, group = "Position Exit Settings")+exitATRLength = input.int(14, title = "ATR Length", minval = 1 , group = "Position Exit Settings")-exitATRMult = input(2, title = "ATR Multiplier", minval = 0.1 , step = 0.1 ,type = input.float, group = "Position Exit Settings")+exitATRMult = input.float(2, title = "ATR Multiplier", minval = 0.1 , step = 0.1 , group = "Position Exit Settings")-riskReward = input(2, title = "Risk Reward Ratio", minval = 0.1 , step = 0.1 ,type = input.float, group = "Position Exit Settings")+riskReward = input.float(2, title = "Risk Reward Ratio", minval = 0.1 , step = 0.1 , group = "Position Exit Settings")-closeLagBelow = input(true, title = "Close long position if lagging span crosses below the price", type = input.bool, group = "Position Exit Settings")+closeLagBelow = input.bool(true, title = "Close long position if lagging span crosses below the price", group = "Position Exit Settings")-closelagAbove = input(true, title = "Close short position if lagging span crosses above the price", type = input.bool, group = "Position Exit Settings")+closelagAbove = input.bool(true, title = "Close short position if lagging span crosses above the price", group = "Position Exit Settings")-showDash = input(true, title = "Show Dashboard", type = input.bool, group = "Dashboard Options")+showDash = input.bool(true, title = "Show Dashboard", group = "Dashboard Options")-colorDash = input(color.new(#696969, 80), title = "Background Color", type = input.color, inline = "Dash Colors", group = "Dashboard Options")+colorDash = input.color(color.new(#696969, 80), title = "Background Color", inline = "Dash Colors", group = "Dashboard Options")-colorTextDash = input(color.new(#FFFFFF,0), title = "Text Color", type = input.color, inline = "Dash Colors", group = "Dashboard Options")+colorTextDash = input.color(color.new(#FFFFFF,0), title = "Text Color", inline = "Dash Colors", group = "Dashboard Options")-distance = input(30, title = "Bars Distance (to rigth)", minval = 1 ,type = input.integer, group = "Dashboard Options")+distance = input.int(30, title = "Bars Distance (to rigth)", minval = 1 , group = "Dashboard Options")-showSignals = input(true, title = "Show Signals (long/short)", type = input.bool, group = "Extra Options")+showSignals = input.bool(true, title = "Show Signals (long/short)", group = "Extra Options")-showTargets = input(true, title = "Show Targets (Profit/Loss)", type = input.bool, group = "Extra Options")+showTargets = input.bool(true, title = "Show Targets (Profit/Loss)", group = "Extra Options")-donchian(len) => avg(lowest(len), highest(len))+donchian(len) => math.avg(ta.lowest(len), ta.highest(len))conversionLine = donchian(conversionPeriods)baseLine = donchian(basePeriods)-leadLine1 = avg(conversionLine, baseLine)+leadLine1 = math.avg(conversionLine, baseLine)leadLine2 = donchian(laggingSpan2Periods)⋯var pullPrice = 0.0-atrExit = atr(exitATRLength)+atrExit = ta.atr(exitATRLength)if conditionLong⋯decision(condition) =>-    var text = ""+    var text_ = ""    if condition-        text := "🟢"+        text_ := "🟢"    else-        text := "🔴"+        text_ := "🔴"position = time+((time-time[1])*distance)⋯     +"\n\n---------------Extra---------------"-     +"\n\nUnrealized P&L(%): "+tostring(PandL),+     +"\n\nUnrealized P&L(%): "+str.tostring(PandL),     xloc = xloc.bar_time, textalign = text.align_left, style = label.style_label_left, color = colorDash, textcolor = colorTextDash)⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 6: input() → input.int()
  • Line 7: input() → input.int()
  • Line 8: input() → input.int()
  • Line 9: input() → input.int()
⋯//ICHIMOKU--------conversionPeriods = input(9, minval=1, title="Conversion Line Length", group = "Ichimoku Settings")+conversionPeriods = input.int(9, minval=1, title="Conversion Line Length", group = "Ichimoku Settings")-basePeriods = input(26, minval=1, title="Base Line Length", group = "Ichimoku Settings")+basePeriods = input.int(26, minval=1, title="Base Line Length", group = "Ichimoku Settings")-laggingSpan2Periods = input(52, minval=1, title="Lagging Span 2 Length", group = "Ichimoku Settings")+laggingSpan2Periods = input.int(52, minval=1, title="Lagging Span 2 Length", group = "Ichimoku Settings")-displacement = input(26, minval=1, title="Displacement", group = "Ichimoku Settings")+displacement = input.int(26, minval=1, title="Displacement", group = "Ichimoku Settings")entryStrategy = input.string(title = "Entry Strategy", defval = "Ichimoku", options = ["Ichimoku"], group = "Entry Strategy")⋯

Does it run in Pine Script v6?

No

The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 13 before, 0 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © M3RZI-//@version=5+//@version=6strategy("Ichimoku Strategy", overlay = true)⋯

Settings

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

SettingDefaultType and rangeFeeds
Ichimoku Settings
Conversion Line Length9int · min 1conversionLine
Base Line Length26int · min 1baseLine
Lagging Span 2 Length52int · min 1leadLine2
Displacement26int · min 1closeAbvCloud lagSpanAbvCloud closeBlwCloud lagSpanBlwCloud loss Lead 1 Lead 2 close Long close Short line 86 line 95 Lagging Span
Entry Strategy
Entry StrategyIchimokustring · options ["Ichimoku"]unused
Position Exit Settings
Exit StrategyIchimokustring · options ["Ichimoku","ATR Pullback"]line 59 line 75
ATR Length14int (written input.integer) · min 1atrExit
ATR Multiplier2float · min 0.1 · step 0.1loss
Risk Reward Ratio2float · min 0.1 · step 0.1profit
Close long position if lagging span crosses below the pricetrueboolclose Long line 86
Close short position if lagging span crosses above the pricetrueboolclose Short line 95
Dashboard Options
Show Dashboardtrueboolline 112
Background Colorcolor.new(#696969, 80)colordashBoard
Text Colorcolor.new(#FFFFFF,0)colordashBoard
Bars Distance (to rigth)30int (written input.integer) · min 1position
Extra Options
Show Signals (long/short)trueboolLong Signal Short Signal
Show Targets (Profit/Loss)trueboolTake profit Middle Line Stop Loss

What it calculates

  • ATR (atr, ta.atr in v5)ATR Length (14)atrExit · line 52

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.

high · low · closehigh · low · closeprice dataexitATRLengthATR Lengthsetting · 14conversionPeriodsConversion Line Lengthsetting · 9basePeriodsBase Line Lengthsetting · 26laggingSpan2PeriodsLagging Span 2 Lengthsetting · 52openopenprice datariskRewardRisk Reward Ratiosetting · 2displacementDisplacementsetting · 26exitATRMultATR Multipliersetting · 2timetimeprice datadistanceBars Distance (to rigth)setting · 30closecloseprice datalowlowprice datahighhighprice dataatrExitATR→ atrExitconversionLineconversionLinevaluebaseLinebaseLinevalueleadLine1leadLine1valueleadLine2leadLine2valueprofitprofitvaluecurrentcurrentvaluelosslossvaluepositionpositionvaluePandLPandLvalueconditionLongconditionLongconditionconditionShortconditionShortconditionconAbvBase, conBlwBaseconAbvBase · conBlwBase2 conditionscloudGreen, cloudRedcloudGreen · cloudRed2 conditionscloseAbvCloud, closeBlwCloudcloseAbvCloud · closeBl…2 conditionslagSpanAbvCloud, lagSpanBlwCloudlagSpanAbvCloud · lagSp…2 conditionsdashBoardColourdashBoardentry:LongOpen Longstrategy.entryexit:Long exitexit Long exitstrategy.exitentry:ShortOpen Shortstrategy.entryexit:Short exitexit Short exitstrategy.exitclose:LongClose Longstrategy.closeclose:ShortClose Shortstrategy.closeplotshape:131Long Signalplotshapeplotshape:132Short Signalplotshapeplot:133Take profitplotplot:134Middle Lineplotplot:135Stop Lossplotfill:Profit BackgroundProfit Backgroundfillfill:Loss BackgroundLoss Backgroundfillplot:138Conversion Lineplotplot:139Base Lineplotplot:140Lagging Spanplotplot:141Lead 1plotplot:143Lead 2plotfill:Lead 1 and 2 BackgroundLead 1 and 2 Backgroundfill

Order rules

OrderFires whenBy defaultLine
Open Long longconditionLongOn67
Exit Long exit stop and limitconditionLongOn68
Open Short shortconditionShortOn83
Exit Short exit stop and limitconditionShortOn84
Close LongcloseLagBelow and open < close[displacement + 1]On89
Close Longhigh[1] >= profit or low[1] <= lossOn93
Close ShortcloselagAbove and open > close[displacement + 1]On98
Close Shortlow[1] <= profit or high[1] >= lossOn102

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.

3/3trades 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+80.9%+102.5%1346%1.20148.2%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+108.9%+5.5%1136%2.5831.3%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−3.4%+9.8%850%0.707.9%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+1.3%+8.4%1155%1.531.7%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.1%+16.7%933%0.930.9%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.0%+21.5%944%1.340.1%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+2.4%+148.3%978%5.501.1%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+0.1%+17.1%922%1.220.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 market10%−$41,043.50
Sideways market1250%$121,957.00
Falling market0—$0.00

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

How bad could the drawdown be?

3,897.7%

The 95th percentile of the worst drawdown when the same 13 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 103.2% to 3,897.7%; the tick is what actually happened, 146.1%. Order luck alone moves it this much.

0%4,482%
All 13 trades
SideEntryExitBarsP&L
long22 May 2024 70,148.3015 Jun 2024 66,044.0024−$41,043.50
short25 Jun 2024 60,293.305 Jul 2024 54,401.4010$58,919.10
long27 Jul 2024 67,908.001 Aug 2024 63,336.905−$45,710.50
short8 Aug 2024 55,133.808 Aug 2024 62,741.500−$76,077.20
long25 Sep 2024 64,262.7010 Oct 2024 59,215.0015−$50,477.00
short24 Feb 2025 96,258.0025 Feb 2025 86,547.801$97,102.00
long25 Apr 2025 93,980.5022 May 2025 111,160.0027$171,793.00
short7 Sep 2025 110,188.0016 Sep 2025 115,350.009−$51,617.30
long6 Oct 2025 123,482.0010 Oct 2025 111,778.004−$117,045.00
short16 Oct 2025 110,763.0017 Oct 2025 107,355.001$34,078.90
long2 May 2026 78,231.1020 May 2026 76,834.4018−$13,967.70
short3 Jun 2026 66,760.8025 Jun 2026 58,655.0022$81,058.40
long21 Aug 2026 73,027.0018 Sep 2026 76,417.0028$33,899.90

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
Ichimoku Long and Short Strategy this page—v4 strategy+80.9%13148.2%
SOJA PIVOT by ParaBellum68atrv4 strategy+3.3%918.2%
Volatility System by EduardoMattjeatrv5 strategy+150.2%221.5%
ATR Stop Buy Strategy by phobo3satrv4 strategyNo trades on this market
VBand Strategy by Saravanan_Ragavanatrv4 strategyNo trades on this market
Volatility Breakout Strategy [Angel Algo] by AngelAlgoatrv5 strategy+3.1%183.6%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 51 msYes 1,000 bars in 116 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/// © M3RZI//@version=4strategy("Ichimoku Strategy", overlay = true)//ICHIMOKU-------conversionPeriods = input(9, minval=1, title="Conversion Line Length", group = "Ichimoku Settings")basePeriods = input(26, minval=1, title="Base Line Length", group = "Ichimoku Settings")laggingSpan2Periods = input(52, minval=1, title="Lagging Span 2 Length", group = "Ichimoku Settings")displacement = input(26, minval=1, title="Displacement", group = "Ichimoku Settings")entryStrategy = input(title = "Entry Strategy", defval = "Ichimoku", options = ["Ichimoku"], type =  input.string, group = "Entry Strategy")exitStrategy = input(title = "Exit Strategy", defval = "Ichimoku", options = ["Ichimoku","ATR Pullback"], type = input.string, group = "Position Exit Settings")exitATRLength = input(14, title = "ATR Length", minval = 1 ,type = input.integer, group = "Position Exit Settings")exitATRMult = input(2, title = "ATR Multiplier", minval = 0.1 , step = 0.1 ,type = input.float, group = "Position Exit Settings")riskReward = input(2, title = "Risk Reward Ratio", minval = 0.1 , step = 0.1 ,type = input.float, group = "Position Exit Settings")closeLagBelow = input(true, title = "Close long position if lagging span crosses below the price", type = input.bool, group = "Position Exit Settings")closelagAbove = input(true, title = "Close short position if lagging span crosses above the price", type = input.bool, group = "Position Exit Settings")showDash = input(true, title = "Show Dashboard", type = input.bool, group = "Dashboard Options")colorDash = input(color.new(#696969, 80), title = "Background Color", type = input.color, inline = "Dash Colors", group = "Dashboard Options")colorTextDash = input(color.new(#FFFFFF,0), title = "Text Color", type = input.color, inline = "Dash Colors", group = "Dashboard Options")distance = input(30, title = "Bars Distance (to rigth)", minval = 1 ,type = input.integer, group = "Dashboard Options")showSignals = input(true, title = "Show Signals (long/short)", type = input.bool, group = "Extra Options")showTargets = input(true, title = "Show Targets (Profit/Loss)", type = input.bool, group = "Extra Options")donchian(len) => avg(lowest(len), highest(len))conversionLine = donchian(conversionPeriods)baseLine = donchian(basePeriods)leadLine1 = avg(conversionLine, baseLine)leadLine2 = donchian(laggingSpan2Periods)//---------------------var long = falsevar short = falsevar signalLong = falsevar signalShort = false//LONG conAbvBase = conversionLine > baseLine cloudGreen = leadLine1 > leadLine2 closeAbvCloud = open > leadLine1[displacement] and open > leadLine2[displacement] lagSpanAbvCloud = close > leadLine1[displacement*2] and close > leadLine2[displacement*2] conditionLong = not long and conAbvBase and cloudGreen and closeAbvCloud and lagSpanAbvCloud //SHORTconBlwBase = conversionLine < baseLine cloudRed = leadLine2 > leadLine1 closeBlwCloud = open < leadLine1[displacement] and open < leadLine2[displacement] lagSpanBlwCloud = close < leadLine1[displacement*2] and close < leadLine2[displacement*2] conditionShort = not short and conBlwBase and cloudRed and closeBlwCloud and lagSpanBlwCloud var drawing = falsevar waitingLong = falsevar waitingShort = falsevar profit = 0.0var current = 0.0var loss = 0.0var pullPrice = 0.0atrExit = atr(exitATRLength)if conditionLong    long := true    short := false    signalLong := true    signalShort := false    drawing := true    if exitStrategy == "Ichimoku"        loss := leadLine2[displacement] < leadLine1[displacement] ? leadLine2[displacement] : leadLine1[displacement]        profit := open + ((open - loss) * riskReward)        current := open    else        loss := open - atrExit * exitATRMult        current := open        profit := open + (open - loss) * riskReward    strategy.entry("Long", strategy.long, 10 ,alert_message = "Long Position Open")    strategy.exit("Long exit", "Long", limit = profit, stop = loss, alert_message = "Long Position Close")if conditionShort    short := true    long := false    signalShort := true    signalLong := false    drawing := true    if exitStrategy == "Ichimoku"        loss := leadLine2[displacement] > leadLine1[displacement] ? leadLine2[displacement] : leadLine1[displacement]        profit := open - ((loss - open) * riskReward)        current := open    else         loss := open + atrExit * exitATRMult        current := open        profit := open - (loss - open) * riskReward    strategy.entry("Short", strategy.short, 10 , alert_message = "Short Position Open")    strategy.exit("Short exit","Short", limit = profit, stop = loss, alert_message = "Short Position Close")if long    if closeLagBelow and open < close[displacement + 1]        drawing := false        signalLong := false        strategy.close("Long", alert_message = "Long Closed by Lagging Span Crossing Below Price")    else if high[1] >= profit or low[1] <= loss        drawing := false        signalLong := false        strategy.close("Long", alert_message = "Long Closed")if short     if closelagAbove and open > close[displacement + 1]        drawing := false        signalShort := false        strategy.close("Short", alert_message = "Short Closed by Lagging Span Crossing Above Price")    else if low[1] <= profit  or high[1] >= loss        drawing := false        signalShort := false        strategy.close("Short", alert_message = "Short Closed")        decision(condition) =>    var text = ""    if condition        text := "🟢"    else        text := "🔴"position = time+((time-time[1])*distance)PandL = signalLong ? ((open-current)/current)*100 : signalShort ? (((open-current)/current)*100)*-1 : 0.0if showDash    label dashBoard = label.new(position,open,     text = "-----------Long conditions-----------"     +"\n\n"+decision(signalLong)+" Long position is open"     +"\n\n"+decision(conAbvBase)+" Conversion line above base line"     +"\n\n"+decision(cloudGreen)+" Cloud is green"     +"\n\n"+decision(closeAbvCloud)+" Price closed above cloud"     +"\n\n"+decision(lagSpanAbvCloud)+" Lagging span above cloud"     +"\n\n-----------Short conditions-----------"     +"\n\n"+decision(signalShort)+" Short position is open"     +"\n\n"+decision(conBlwBase)+" Conversion line below base line"     +"\n\n"+decision(cloudRed)+" Cloud is red"     +"\n\n"+decision(closeBlwCloud)+" Price closed below cloud"     +"\n\n"+decision(lagSpanBlwCloud)+" Lagging span below cloud"     +"\n\n---------------Extra---------------"     +"\n\nUnrealized P&L(%): "+tostring(PandL),     xloc = xloc.bar_time, textalign = text.align_left, style = label.style_label_left, color = colorDash, textcolor = colorTextDash)    label.delete(dashBoard[1])//DRAWINGplotshape(showSignals ? conditionLong : na, title = "Long Signal", location=location.belowbar,style=shape.labelup,color=color.green,textcolor=color.white,size=size.small,text="Long")plotshape(showSignals ? conditionShort : na, title = "Short Signal", location=location.abovebar,style=shape.labeldown,color=color.red,textcolor=color.white,size=size.small,text="Short")profitLine = plot(showTargets ? drawing ? profit : na : na, title = "Take profit", color = color.green, style = plot.style_linebr)currentLine =plot(showTargets ? drawing ? current : na : na, title = "Middle Line", color = color.white, style = plot.style_linebr)lossLine = plot(showTargets ? drawing ? loss : na : na, title = "Stop Loss", color = color.red, style = plot.style_linebr)fill(currentLine,profitLine, title = "Profit Background" ,color = color.new(color.green,75))fill(currentLine,lossLine, title = "Loss Background" ,color = color.new(color.red,75))plot(conversionLine, color = #0496ff, title = "Conversion Line")plot(baseLine, color = color.yellow, title = "Base Line")plot(close, offset = -displacement + 1, color = color.purple, title = "Lagging Span")p1 = plot(leadLine1, offset = displacement - 1, color=color.green,     title="Lead 1")p2 = plot(leadLine2, offset = displacement - 1, color=color.red,     title="Lead 2")fill(p1, p2, title = "Lead 1 and 2 Background" ,color = leadLine1 > leadLine2 ? color.green : color.red)//------NOTE FOR ALERTS//IF YOU WANT TO RECIVE A ALERT JUST FOLLOW THE NEXT STEPS://1.-GO TO ALERTS AND CLICK IN "CREATE NEW ALERT"//2.-IN CONDITION  CHOOSE THE "ICHIMOKU STRATEGY"//3.-GIVE THE ALERT A NAME//4.-IN MESSAGE YOU ARE GOING TO WRITE "{{strategy.order.alert_message}}", WITH THIS WHEN A SHORT OR LONG SIGNAL APPEAR WILL SHOW THE "alert_message" IN THE ALERT.//THE alert_message IS DEFINED IN THE "strategy.entry" and "strategy.exit"//------NOTE IF YOU WANT TO USE A BOT WITH THIS STRATEGY//THIS IS A STRATEGY SO YOU ONLY CAN RECIVE ALERTS FROM THE "strategy.entry" AND "strategy.exit" BUT THIS ARE ONLY IN ONE ALERT//SO IF YOU WANT TO USE A BOTH WITH THE STRATEGY FOLLOW THE NEXT STEPS://1.-ALREADY HAVE A BOT CREATED//2.-LOCATE  YOUR WEBHOOK AND COMMANDS FOR THE BOT //3.-IN THE "alert_message" OF THE "strategy.entry (LINE 95)" YOU WILL PASTE THE COMMAND OF YOUR BOT FOR ENTER A LONG AND IN THE "strategy.exit (LINE 96)" THAT ARE BELOW IN THE "alert_message" PASTE THE COMMAND THAT IS FOR CLOSE THE LONG POSITION//4.-YOU WILL DO THE SAME FOR THE "strategy.entry (LINE 109)" AND THE "strategy.exit (LINE 110)" BUT THIS TIME WITH THE COMMAND OF OPEN A SHORT AND CLOSE A SHORT//5.-AFTER THE PREVIOUS STEPS GO TO ALERTS AND CLICK IN "CREATE NEW ALERT"//6.-IN CONDITION CHOOSE THE "ICHIMOKU STRATEGY"//7.-SELECT "URL from webhook"//8.-GIVE THE ALERT A NAME//9.-IN MESSAGE WRITE "{{strategy.order.alert_message}}"//10.-NOW WITH ALL THIS EACH TIME A SIGNAL APPEAR IN THE STRATEGY THIS WILL SEND THE COMMAND TO YOUR BOT TO OPEN OR CLOSE A LONG OR SHORT////------ANOTHER IMPORTANT NOTE FOR PEOPLE THAT WANT TO USE A BOT//I NOW THAT I'M SO BAD EXPLAINING THINGS SO WATCH THE FOLLOWING VIDEO THAT EXPLAINS BETTER THAN ME, ITS FROM THE CHANNEL "The Art of Trading"//AND ALSO U CAN CHECK HIS TRADINGVIEW ACCOUNT, HE CREATE AN AMAZING SCRIPT FOR THE COMMUNITY AND CHECK HIS CHANNEL TO LEARN PINE SCRIPT//https://www.youtube.com/watch?v=-d_rFRd3o-0//https://es.tradingview.com/u/ZenAndTheArtOfTrading/#published-charts