Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Bagheri IG Ether

A Pine Script v4 strategy built on EMA (close, 49), Change (ma, 185) and Highest (43). It has 4 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. 14 settings; defaults include Take Profit 3000, Stop Loss 3443 and ROC Length 185.

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 Bagheri IG Ether 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 Bagheri IG Ether do on BTCUSDT 1D with default settings?
+0.03%
From 26 Jan 2024 to 21 Oct 2026, over 3 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Bagheri IG Ether 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 @L32:C17: No value assigned to the `transp` parameter in color.new()), so no v5 download is offered; the edits are shown below.
Does Bagheri IG Ether use a stop loss?
Yes
strategy.exit sets a stop on line 65, 66.
Does Bagheri IG Ether run in Zeal Terminal?
Yes
It compiles in 21 ms and runs 1,000 bars in 85 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • Plot
  • Plot
  • 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 (14)
╔═══════╗40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$100,026$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. Zeal Terminal's engine currently reads an order side written as long = true, long = false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 62, 63) so the engine trades the way the script says.
Net profit
+0.03%
$25.57
Buy and hold
+102.5%
same period
Closed trades
3
2 won · 1 lost
Profitable
66.7%
of closed trades
Profit factor
1.74
gross profit ÷ gross loss
Max drawdown
0.03%
−$34.43

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.

  • Likely bug

    ema(close, wmaBP_period) ignores the settings line 35

    Line 35 hard-codes close where line 11 uses “Source”. Changing those settings moves one band but not this one.

    ema(close, wmaBP_period)ema(src, wmaBP_period)
  • 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 62, 63. The upgraded version below moves each call inside an if block.

  • Note

    Uses transp =, which v5 removed line 32

    transp = on line 32, 78, 79. v5 folds the transparency into the colour with color.new(c, transp).

  • Note

    Uses long =, which v5 renamed line 62

    long = on line 62, 63. 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 ema → ta.ema, change → ta.change, highest → ta.highest, lowest → ta.lowest, avg → math.avg, rma → ta.rma, sma → ta.sma, tostring → str.tostring.
  • 2 strategy calls use the when = argument (line 62, 63). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Differs

The v5 version does not run in Zeal Terminal's engine: Pine Script v5 Error at @L32:C17: No value assigned to the `transp` parameter in color.new()

  • Line 3: //@version=4 → //@version=5
  • Line 8: input(type = input.integer) → input.int()
  • Line 9: input(type = input.integer) → input.int()
  • Line 10: input(type = input.source) → input.source()
  • Line 11: ema → ta.ema
  • Line 12: change → ta.change
17 more edits
  • Line 25: highest → ta.highest
  • Line 26: lowest → ta.lowest
  • Line 27: avg → math.avg
  • Line 32: transp = 90 removed: the call sets no colour to fold it into, so its default colour loses the transparency
  • Line 35: ema → ta.ema
  • Line 40: rma → ta.rma
  • Line 46: sma → ta.sma
  • Line 62: long = true → direction = strategy.long
  • Line 63: long = false → direction = strategy.short
  • Line 78: transp = 90 removed: the call sets no colour to fold it into, so its default colour loses the transparency
  • Line 79: transp = 90 removed: the call sets no colour to fold it into, so its default colour loses the transparency
  • Line 83: input(type = input.float) → input.float()
  • Line 100: tostring → str.tostring
  • Line 101: tostring → str.tostring
  • Line 102: tostring → str.tostring
  • Line 103: tostring → str.tostring
  • Line 104: tostring → str.tostring
⋯// © mbagheri746-//@version=4+//@version=5strategy("Bagheri IG Ether", overlay=true, margin_long=100, margin_short=100)⋯//_________________ RoC Definition _________________-rocLength = input(title="ROC Length", type=input.integer, minval=1, defval=185)+rocLength = input.int(title="ROC Length", minval=1, defval=185)-smoothingLength = input(title="Smoothing Length", type=input.integer, minval=1, defval=49)+smoothingLength = input.int(title="Smoothing Length", minval=1, defval=49)-src = input(title="Source", type=input.source, defval=close)+src = input.source(title="Source", defval=close)-ma = ema(src, smoothingLength)+ma = ta.ema(src, smoothingLength)-mom = change(ma, rocLength)+mom = ta.change(ma, rocLength)sroc = nz(ma[rocLength]) == 0⋯offset_bar = input(90,minval=0, title ="Offset Bars")-upper = highest(length1)+upper = ta.highest(length1)-lower = lowest(length2)+lower = ta.lowest(length2)-basis = avg(upper, lower)+basis = math.avg(upper, lower)DC_UP_Band = upper[offset_bar]⋯u = plot(DC_UP_Band, style=plot.style_line, linewidth=1, color=color.aqua)-fill(l,u,color = color.new(color.aqua,transp = 90))+fill(l,u,color = color.new(color.aqua))//_________________ Bears Power _________________wmaBP_period = input(61,minval=1,title="BearsP WMA Period")-line_wma = ema(close, wmaBP_period)+line_wma = ta.ema(close, wmaBP_period)BP = low - line_wma⋯BOP=(close - open) / (high - low)-SBOP = rma(BOP, ES_BoP)+SBOP = ta.rma(BOP, ES_BoP)//_________________ Alligator _________________⋯sma_shift = input(37, minval = 1 , title = "SMA Shift")-sma_primary = sma(close,sma_period)+sma_primary = ta.sma(close,sma_period)SMA_sh = sma_primary[sma_shift]⋯//_________________ OPEN POSITION __________________//-strategy.entry(id = "BUY", long = true , when = MA_Lcnd and ROC_Lcnd and DC_Lcnd and BP_Lcnd and BOP_Lcnd)+strategy.entry(id = "BUY", direction = strategy.long , when = MA_Lcnd and ROC_Lcnd and DC_Lcnd and BP_Lcnd and BOP_Lcnd)-strategy.entry(id = "SELL", long = false , when = MA_Scnd and ROC_Scnd and DC_Scnd and BP_Scnd and BOP_Scnd)+strategy.entry(id = "SELL", direction = strategy.short , when = MA_Scnd and ROC_Scnd and DC_Scnd and BP_Scnd and BOP_Scnd)//_________________ CLOSE POSITION __________________//⋯Pline = plot(pos_price != 0.0 ? pos_price : na, title="Stop Loss", color=color.gray, trackprice = true, show_last = 1)-fill(Tline , Pline, color = color.new(color.green,transp = 90))+fill(Tline , Pline, color = color.new(color.green))-fill(Sline , Pline, color = color.new(color.red,transp = 90))+fill(Sline , Pline, color = color.new(color.red))//_________________ Alert __________________//⋯//_________________ Label __________________//-inMyPrice           = input(title="My Price", type=input.float, defval=0)+inMyPrice           = input.float(title="My Price", defval=0)inLabelStyle        = input(title="Label Style", options=["Upper Right", "Lower Right"], defval="Lower Right")⋯      "Pos: "  +posDir +"\n" +-      "Pos Price: "+tostring(strategy.position_avg_price) +"\n" ++      "Pos Price: "+str.tostring(strategy.position_avg_price) +"\n" +-      "Pos PnL: "  +tostring(posPnL, "0.00") + "%" +"\n" ++      "Pos PnL: "  +str.tostring(posPnL, "0.00") + "%" +"\n" +-      "Profit: "  +tostring(strategy.openprofit, "0.00") + "$" +"\n" ++      "Profit: "  +str.tostring(strategy.openprofit, "0.00") + "$" +"\n" +-      "TP: "  +tostring(TP_line, "0.00") +"\n" ++      "TP: "  +str.tostring(TP_line, "0.00") +"\n" +-      "SL: "  +tostring(SL_line, "0.00") +"\n" ++      "SL: "  +str.tostring(SL_line, "0.00") +"\n" +      "╚═══════╝")

Clean v5

Not verified

The v5 script does not run in Zeal Terminal's engine (Pine Script v5 Error at @L32:C17: No value assigned to the `transp` parameter in color.new()), so this step could not be checked.

  • Line 5: input() → input.int()
  • Line 6: input() → input.int()
  • Line 22: input() → input.int()
  • Line 23: input() → input.int()
  • Line 24: input() → input.int()
  • Line 34: input() → input.int()
6 more edits
  • Line 38: input() → input.int()
  • Line 44: input() → input.int()
  • Line 45: input() → input.int()
  • Line 62: when = MA_Lcnd and ROC_Lcnd and DC_Lcnd and BP_Lcnd and BOP_Lcnd → if block
  • Line 63: when = MA_Scnd and ROC_Scnd and DC_Scnd and BP_Scnd and BOP_Scnd → if block
  • Line 84: input() → input.string()
⋯strategy("Bagheri IG Ether", overlay=true, margin_long=100, margin_short=100)-TP = input(3000, minval = 1 , title ="Take Profit")+TP = input.int(3000, minval = 1 , title ="Take Profit")-SL = input(3443, minval = 1 , title ="Stop Loss")+SL = input.int(3443, minval = 1 , title ="Stop Loss")//_________________ RoC Definition _________________⋯//_________________ Donchian Channel _________________-length1 = input(43, minval=1, title="Upper Channel")+length1 = input.int(43, minval=1, title="Upper Channel")-length2 = input(43, minval=1, title="Lower Channel")+length2 = input.int(43, minval=1, title="Lower Channel")-offset_bar = input(90,minval=0, title ="Offset Bars")+offset_bar = input.int(90,minval=0, title ="Offset Bars")upper = ta.highest(length1)⋯//_________________ Bears Power _________________-wmaBP_period = input(61,minval=1,title="BearsP WMA Period")+wmaBP_period = input.int(61,minval=1,title="BearsP WMA Period")line_wma = ta.ema(close, wmaBP_period)⋯//_________________ Balance of Power _________________-ES_BoP=input(15, title="BoP Exponential Smoothing")+ES_BoP=input.int(15, title="BoP Exponential Smoothing")BOP=(close - open) / (high - low)⋯//_________________ Moving Average _________________-sma_period = input(74, minval = 1 , title = "SMA Period")+sma_period = input.int(74, minval = 1 , title = "SMA Period")-sma_shift = input(37, minval = 1 , title = "SMA Shift")+sma_shift = input.int(37, minval = 1 , title = "SMA Shift")sma_primary = ta.sma(close,sma_period)⋯//_________________ OPEN POSITION __________________//-strategy.entry(id = "BUY", direction = strategy.long , when = MA_Lcnd and ROC_Lcnd and DC_Lcnd and BP_Lcnd and BOP_Lcnd)+if MA_Lcnd and ROC_Lcnd and DC_Lcnd and BP_Lcnd and BOP_Lcnd+    strategy.entry(id = "BUY", direction = strategy.long )-strategy.entry(id = "SELL", direction = strategy.short , when = MA_Scnd and ROC_Scnd and DC_Scnd and BP_Scnd and BOP_Scnd)+if MA_Scnd and ROC_Scnd and DC_Scnd and BP_Scnd and BOP_Scnd+    strategy.entry(id = "SELL", direction = strategy.short )//_________________ CLOSE POSITION __________________//⋯inMyPrice           = input.float(title="My Price", defval=0)-inLabelStyle        = input(title="Label Style", options=["Upper Right", "Lower Right"], defval="Lower Right")+inLabelStyle        = input.string(title="Label Style", options=["Upper Right", "Lower Right"], defval="Lower Right")posColor = color.new(color.green, 25)⋯

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 @L32: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.

⋯// © mbagheri746-//@version=5+//@version=6strategy("Bagheri IG Ether", overlay=true, margin_long=100, margin_short=100)⋯

Settings

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

SettingDefaultType and rangeFeeds
Take Profit3000int · min 1TP_line exit CLOSE BUY exit CLOSE SELL
Stop Loss3443int · min 1SL_line exit CLOSE BUY exit CLOSE SELL
ROC Length185int (written input.integer) · min 1mom sroc
Smoothing Length49int (written input.integer) · min 1ma
Sourceclosesourcema
Upper Channel43int · min 1upper
Lower Channel43int · min 1lower
Offset Bars90int · min 0DC_UP_Band DC_LW_Band
BearsP WMA Period61int · min 1line_wma
BoP Exponential Smoothing15intSBOP
SMA Period74int · min 1sma_primary
SMA Shift37int · min 1SMA_sh
My Price0floatmyPnL
Label StyleLower Rightstring · options ["Upper Right", "Lower Right"]lb

What it calculates

  • EMA (ema, ta.ema in v5)Source (close), Smoothing Length (49)ma · line 11
  • Change (change, ta.change in v5)ma, ROC Length (185)mom · line 12
  • Highest (highest, ta.highest in v5)Upper Channel (43)upper · line 25
  • Lowest (lowest, ta.lowest in v5)Lower Channel (43)lower · line 26
  • EMA (ema, ta.ema in v5)close, BearsP WMA Period (61)line_wma · line 35
  • RMA (rma, ta.rma in v5)BOP, BoP Exponential Smoothing (15)SBOP · line 40
  • SMA (sma, ta.sma in v5)close, SMA Period (74)sma_primary · line 46

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 datasmoothingLengthSmoothing Lengthsetting · 49rocLengthROC Lengthsetting · 185length1Upper Channelsetting · 43length2Lower Channelsetting · 43wmaBP_periodBearsP WMA Periodsetting · 61ES_BoPBoP Exponential Smoothi…setting · 15sma_periodSMA Periodsetting · 74offset_barOffset Barssetting · 90lowlowprice datahighhighprice dataopenopenprice datasma_shiftSMA Shiftsetting · 37TPTake Profitsetting · 3000SLStop Losssetting · 3443inMyPriceMy Pricesetting · 0inLabelStyleLabel Stylesetting · Lower RightmaEMA→ mamomChange→ momupperHighest→ upperlowerLowest→ lowerline_wmaEMA→ line_wmaSBOPRMA→ SBOPsma_primarySMA→ sma_primarysrocsrocvaluebasisbasisvalueDC_UP_BandDC_UP_BandvalueDC_LW_BandDC_LW_BandvalueBPBPvalueBOPBOPvalueSMA_shSMA_shvaluecurrentPL, pos_price, open_pos, posDircurrentPL · pos_price +24 valuesTP_lineTP_linevalueSL_lineSL_linevalueposPnLposPnLvalueposColposColvaluemyPnLmyPnLvaluelblbvalueMA_Lcnd, MA_ScndMA_Lcnd · MA_Scnd2 conditionsROC_Lcnd, ROC_ScndROC_Lcnd · ROC_Scnd2 conditionsDC_LcndDC_LcndconditionBP_Lcnd, BP_ScndBP_Lcnd · BP_Scnd2 conditionsBOP_Lcnd, BOP_ScndBOP_Lcnd · BOP_Scnd2 conditionsDC_ScndDC_ScndconditionposColor, negColor, dftColorColourposColor · negColor +1entry:BUYOpen BUYstrategy.entryentry:SELLOpen SELLstrategy.entryexit:CLOSE BUYexit CLOSE BUYstrategy.exitexit:CLOSE SELLexit CLOSE SELLstrategy.exitplot:30plotplotplot:31plotplotfill:32Fillfill × 3plot:48plotplotplot:75Take Profitplotplot:76Stop Lossplotplot:77Stop Lossplotfill:78Fillfill × 3fill:79Fillfill × 3

Order rules

OrderFires whenBy defaultLine
Open BUY longMA_Lcnd and ROC_Lcnd and DC_Lcnd and BP_Lcnd and BOP_LcndOn62
Open SELL shortMA_Scnd and ROC_Scnd and DC_Scnd and BP_Scnd and BOP_ScndOn63
Exit CLOSE BUY stop and limitevery barOn65
Exit CLOSE SELL stop and limitevery barOn66

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+0.0%+102.5%367%1.740.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−0.0%+5.5%10%0.000.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−0.0%+9.8%250%0.870.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−0.0%+8.4%10%0.000.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−0.0%+16.7%250%0.870.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h−0.0%+21.5%10%0.000.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+0.1%+148.3%2100%—0.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−0.0%+17.1%10%0.000.0%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 market0—$0.00
Sideways market367%$25.57
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?

0.0%

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

0%1%
All 3 trades
SideEntryExitBarsP&L
short30 Aug 2025 108,377.0030 Aug 2025 108,412.000−$34.43
long1 May 2026 76,346.601 May 2026 76,376.600$30.00
long21 Aug 2026 73,027.0021 Aug 2026 73,057.000$30.00

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
Bagheri IG Ether this page—v4 strategy+0.0%30.0%
Bagheri IG Ether v2 by Bagheri_IGema highest lowest rma smav4 strategy−0.0%20.0%
MACD Willy Strategy by PtGamblerrma sma ema highest lowestv5 strategyNo trades on this market
Forex bot full strategy with risk management by exlux99lowest highest ema smav4 strategy−26.4%1138.9%
LowFinder_PyraMider_V2 by A3Shrma ema sma highestv5 strategy+1.9%150.8%
PB Trend Scalper by PatrickGwynBuckleyema rma highest lowestv5 strategy−16.9%1068.3%

Where it runs

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

Zeal Terminal's engine currently reads an order side written as long = true, long = false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 62, 63) 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.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © mbagheri746//@version=4strategy("Bagheri IG Ether", overlay=true, margin_long=100, margin_short=100)TP = input(3000, minval = 1 , title ="Take Profit")SL = input(3443, minval = 1 , title ="Stop Loss")//_________________ RoC Definition _________________rocLength = input(title="ROC Length", type=input.integer, minval=1, defval=185)smoothingLength = input(title="Smoothing Length", type=input.integer, minval=1, defval=49)src = input(title="Source", type=input.source, defval=close)ma = ema(src, smoothingLength)mom = change(ma, rocLength)sroc = nz(ma[rocLength]) == 0     ? 100     : mom == 0         ? 0         : 100 * mom / ma[rocLength]//srocColor = sroc >= 0 ? #0ebb23 : color.red//plot(sroc, title="SROC", linewidth=2, color=srocColor, transp=0)//hline(0, title="Zero Level", linestyle=hline.style_dotted, color=#989898)//_________________ Donchian Channel _________________length1 = input(43, minval=1, title="Upper Channel")length2 = input(43, minval=1, title="Lower Channel")offset_bar = input(90,minval=0, title ="Offset Bars")upper = highest(length1)lower = lowest(length2)basis = avg(upper, lower)DC_UP_Band = upper[offset_bar]DC_LW_Band = lower[offset_bar]l = plot(DC_LW_Band, style=plot.style_line, linewidth=1, color=color.red)u = plot(DC_UP_Band, style=plot.style_line, linewidth=1, color=color.aqua)fill(l,u,color = color.new(color.aqua,transp = 90))//_________________ Bears Power _________________wmaBP_period = input(61,minval=1,title="BearsP WMA Period")line_wma = ema(close, wmaBP_period)BP = low - line_wma//_________________ Balance of Power _________________ES_BoP=input(15, title="BoP Exponential Smoothing")BOP=(close - open) / (high - low)SBOP = rma(BOP, ES_BoP)//_________________ Alligator _________________//_________________ CCI _________________//_________________ Moving Average _________________sma_period = input(74, minval = 1 , title = "SMA Period")sma_shift = input(37, minval = 1 , title = "SMA Shift")sma_primary = sma(close,sma_period)SMA_sh = sma_primary[sma_shift]plot(SMA_sh, style=plot.style_line, linewidth=2, color=color.yellow)//_________________ Long Entry Conditions _________________//MA_Lcnd = SMA_sh > low and SMA_sh < highROC_Lcnd = sroc < 0DC_Lcnd = open < DC_LW_BandBP_Lcnd = BP[1] < BP[0] and BP[1] < BP[2]BOP_Lcnd = SBOP[1] < SBOP[0]//_________________ Short Entry Conditions _________________//MA_Scnd = SMA_sh > low and SMA_sh < highROC_Scnd = sroc > 0DC_Scnd = open > DC_UP_BandBP_Scnd = BP[1] > BP[0] and BP[1] > BP[2]BOP_Scnd = SBOP[1] > SBOP[0]//_________________ OPEN POSITION __________________//strategy.entry(id = "BUY", long = true , when = MA_Lcnd and ROC_Lcnd and DC_Lcnd and BP_Lcnd and BOP_Lcnd)strategy.entry(id = "SELL", long = false , when = MA_Scnd and ROC_Scnd and DC_Scnd and BP_Scnd and BOP_Scnd)//_________________ CLOSE POSITION __________________//strategy.exit(id = "CLOSE BUY", from_entry = "BUY", profit = TP , loss = SL)strategy.exit(id = "CLOSE SELL", from_entry = "SELL" , profit = TP , loss = SL)//_________________ TP and SL Plot __________________//currentPL= strategy.openprofitpos_price = strategy.position_avg_priceopen_pos = strategy.position_sizeTP_line = (strategy.position_size  > 0) ? (pos_price + TP/100) : strategy.position_size < 0 ? (pos_price - TP/100) : 0.0SL_line = (strategy.position_size  > 0) ? (pos_price - SL/100) : strategy.position_size < 0 ? (pos_price + SL/100) : 0.0// hline(TP_line, title = "Take Profit", color = color.green , linestyle = hline.style_dotted, editable = false)// hline(SL_line, title = "Stop Loss", color = color.red , linestyle = hline.style_dotted, editable = false)Tline = plot(TP_line != 0.0 ? TP_line : na , title="Take Profit", color=color.green, trackprice = true, show_last = 1)Sline = plot(SL_line != 0.0 ? SL_line : na, title="Stop Loss", color=color.red, trackprice = true, show_last = 1)Pline = plot(pos_price != 0.0 ? pos_price : na, title="Stop Loss", color=color.gray, trackprice = true, show_last = 1)fill(Tline , Pline, color = color.new(color.green,transp = 90))fill(Sline , Pline, color = color.new(color.red,transp = 90))//_________________ Alert __________________////alertcondition(condition = , title = "Position Alerts", message = "Bagheri IG Ether\n Symbol: {{ticker}}\n Type: {{strategy.order.id}}")//_________________ Label __________________//inMyPrice           = input(title="My Price", type=input.float, defval=0)inLabelStyle        = input(title="Label Style", options=["Upper Right", "Lower Right"], defval="Lower Right")posColor = color.new(color.green, 25)negColor = color.new(color.red, 25)dftColor = color.new(color.aqua, 25)posPnL   = (strategy.position_size != 0) ? (close * 100 / strategy.position_avg_price - 100) : 0.0posDir   = (strategy.position_size  > 0) ? "long" : strategy.position_size < 0 ? "short" : "flat"posCol   = (strategy.openprofit > 0) ? posColor : (strategy.openprofit < 0) ? negColor : dftColormyPnL    = (inMyPrice != 0) ? (close * 100 / inMyPrice - 100) : 0.0var label lb = nalabel.delete(lb)lb := label.new(bar_index, close,   color=posCol,   style=inLabelStyle=="Lower Right"?label.style_label_upper_left:label.style_label_lower_left,   text=      "╔═══════╗" +"\n" +       "Pos: "  +posDir +"\n" +      "Pos Price: "+tostring(strategy.position_avg_price) +"\n" +      "Pos PnL: "  +tostring(posPnL, "0.00") + "%" +"\n" +      "Profit: "  +tostring(strategy.openprofit, "0.00") + "$" +"\n" +      "TP: "  +tostring(TP_line, "0.00") +"\n" +      "SL: "  +tostring(SL_line, "0.00") +"\n" +      "╚═══════╝")