Pine Script v4 · Strategy
High-low crypto strategy with MACD-PSAR-ATR-EWave
A Pine Script v4 strategy built on SMA or EMA (close, 12), CCI (close, 20) and SMA (tr, 5). 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. 19 settings; defaults include Fast Length 12, Slow Length 26 and Source close.
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 High-low crypto strategy with MACD-PSAR-ATR-EWave repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 4 of 4 trades.
- How did High-low crypto strategy with MACD-PSAR-ATR-EWave do on BTCUSDT 1D with default settings?
- +15.93%
- From 26 Jan 2024 to 21 Oct 2026, over 17 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can High-low crypto strategy with MACD-PSAR-ATR-EWave 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 High-low crypto strategy with MACD-PSAR-ATR-EWave use a stop loss?
- Yes
- strategy.exit sets a stop on line 121, 123.
- Does High-low crypto strategy with MACD-PSAR-ATR-EWave run in Zeal Terminal?
- Yes
- It compiles in 40 ms and runs 1,000 bars in 62 ms, in the browser.
BTCUSDT · 1D · default settings
- SMA
- SMA
- SMA
- SMA
- SMA
- SMA
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +15.93%
- $15,932.60
- Buy and hold
- +102.5%
- same period
- Closed trades
- 17
- 2 won · 15 lost
- Profitable
- 11.8%
- of closed trades
- Profit factor
- 3.44
- gross profit ÷ gross loss
- Max drawdown
- 3.16%
- −$3,777.93
One run with the author's default settings, $100,000 starting capital, commission as the script sets it. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.
Review
What a careful reader of this script would point out, found by checking the source and the backtest.
-
Check
No commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Note
7 settings have no label
In the settings dialog start (line 12), increment (line 13), maximum (line 14), CCI (line 80), ATR (line 81), sma1length (line 108), sma2length (line 109) 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 119, 120. The upgraded version below moves each call inside an if block.
-
Note
Uses iff(), which v5 removed line 111
iff() on line 111. v5 writes it as the ternary c ? a : b.
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 max → math.max, min → math.min, sma → ta.sma, ema → ta.ema, cci → ta.cci.
- 2 strategy calls use the when = argument (line 119, 120). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
VerifiedSame 17 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 5: input(type = input.integer) → input.int()
- Line 6: input(type = input.integer) → input.int()
- Line 7: input(type = input.source) → input.source()
- Line 8: input(type = input.integer) → input.int()
- Line 9: input(type = input.bool) → input.bool()
28 more edits
- Line 10: input(type = input.bool) → input.bool()
- Line 46: max → math.max
- Line 53: min → math.min
- Line 60: min → math.min
- Line 64: min → math.min
- Line 66: min → math.min
- Line 68: min → math.min
- Line 70: max → math.max
- Line 72: max → math.max
- Line 75: sma → ta.sma
- Line 75: ema → ta.ema
- Line 76: sma → ta.sma
- Line 76: ema → ta.ema
- Line 78: sma → ta.sma
- Line 78: ema → ta.ema
- Line 84: cci → ta.cci
- Line 86: sma → ta.sma
- Line 86: tr → ta.tr
- Line 87: sma → ta.sma
- Line 87: tr → ta.tr
- Line 110: input(type = input.bool) → input.bool()
- Line 111: iff(c, a, b) → (c ? a : b)
- Line 111: sma → ta.sma
- Line 111: sma → ta.sma
- Line 111: sma → ta.sma
- Line 111: sma → ta.sma
- Line 119: strategy.entry(…, 1) → strategy.entry(…, strategy.long)
- Line 120: strategy.entry(…, 0) → strategy.entry(…, strategy.short)
⋯// © SoftKill21-//@version=4+//@version=5strategy("Crypto strategy high/low", overlay=true)-fast_length = input(title="Fast Length", type=input.integer, defval=12)+fast_length = input.int(title="Fast Length", defval=12)-slow_length = input(title="Slow Length", type=input.integer, defval=26)+slow_length = input.int(title="Slow Length", defval=26)-src = input(title="Source", type=input.source, defval=close)+src = input.source(title="Source", defval=close)-signal_length = input(title="Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 9)+signal_length = input.int(title="Signal Smoothing", minval = 1, maxval = 50, defval = 9)-sma_source = input(title="Simple MA(Oscillator)", type=input.bool, defval=true)+sma_source = input.bool(title="Simple MA(Oscillator)", defval=true)-sma_signal = input(title="Simple MA(Signal Line)", type=input.bool, defval=false)+sma_signal = input.bool(title="Simple MA(Signal Line)", defval=false)//sar⋯ uptrend := false- SAR := max(EP, high)+ SAR := math.max(EP, high) EP := low⋯ uptrend := true- SAR := min(EP, low)+ SAR := math.min(EP, low) EP := high⋯ EP := high- AF := min(AF + increment, maximum)+ AF := math.min(AF + increment, maximum) else⋯ EP := low- AF := min(AF + increment, maximum)+ AF := math.min(AF + increment, maximum) if uptrend- SAR := min(SAR, low[1])+ SAR := math.min(SAR, low[1]) if bar_index > 1- SAR := min(SAR, low[2])+ SAR := math.min(SAR, low[2]) else- SAR := max(SAR, high[1])+ SAR := math.max(SAR, high[1]) if bar_index > 1- SAR := max(SAR, high[2])+ SAR := math.max(SAR, high[2]) nextBarSAR := SAR + AF * (EP - SAR)// Calculating-fast_ma = sma_source ? sma(src, fast_length) : ema(src, fast_length)+fast_ma = sma_source ? ta.sma(src, fast_length) : ta.ema(src, fast_length)-slow_ma = sma_source ? sma(src, slow_length) : ema(src, slow_length)+slow_ma = sma_source ? ta.sma(src, slow_length) : ta.ema(src, slow_length)macd = fast_ma - slow_ma-signal = sma_signal ? sma(macd, signal_length) : ema(macd, signal_length)+signal = sma_signal ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length)hist = macd - signal⋯original=input(true,title='original coloring')-thisCCI = cci(close, CCI)+thisCCI = ta.cci(close, CCI)lastCCI = nz(thisCCI[1])-bufferDn= high + Multiplier * sma(tr,ATR)+bufferDn= high + Multiplier * ta.sma(ta.tr,ATR)-bufferUp= low - Multiplier * sma(tr,ATR)+bufferUp= low - Multiplier * ta.sma(ta.tr,ATR)if (thisCCI >= 0 and lastCCI < 0) ⋯sma2length = input(35)-UsePercent = input(title="Show Dif as percent of current Candle", type=input.bool, defval=true)+UsePercent = input.bool(title="Show Dif as percent of current Candle", defval=true)-smadif=iff(UsePercent,(sma(srce, sma1length) - sma(srce, sma2length)) / srce * 100, sma(srce, sma1length) - sma(srce, sma2length))+smadif=(UsePercent ? (ta.sma(srce, sma1length) - ta.sma(srce, sma2length)) / srce * 100 : ta.sma(srce, sma1length) - ta.sma(srce, sma2length))col=smadif <= 0 ? color.red : color.green⋯sl=input(0.005, title="sl")-strategy.entry("long",1,when=longC)+strategy.entry("long",strategy.long,when=longC)-strategy.entry("short",0,when=shortC)+strategy.entry("short",strategy.short,when=shortC)strategy.exit("x_long", "long" ,loss = close * sl / syminfo.mintick, profit = close * tp / syminfo.mintick , alert_message = "closelong")⋯Same 17 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 12: input() → input.float()
- Line 13: input() → input.float()
- Line 14: input() → input.float()
- Line 80: input() → input.int()
- Line 81: input() → input.int()
- Line 82: input() → input.int()
8 more edits
- Line 83: input() → input.bool()
- Line 107: input() → input.source()
- Line 108: input() → input.int()
- Line 109: input() → input.int()
- Line 117: input() → input.float()
- Line 118: input() → input.float()
- Line 119: when = longC → if block
- Line 120: when = shortC → if block
⋯//sar-start = input(0.02)+start = input.float(0.02)-increment = input(0.02)+increment = input.float(0.02)-maximum = input(0.2)+maximum = input.float(0.2)var bool uptrend = na⋯hist = macd - signal-CCI = input(20)+CCI = input.int(20)-ATR = input(5)+ATR = input.int(5)-Multiplier=input(1,title='ATR Multiplier')+Multiplier=input.int(1,title='ATR Multiplier')-original=input(true,title='original coloring')+original=input.bool(true,title='original coloring')thisCCI = ta.cci(close, CCI)⋯//elliot wave-srce = input(close, title="source")+srce = input.source(close, title="source")-sma1length = input(5)+sma1length = input.int(5)-sma2length = input(35)+sma2length = input.int(35)UsePercent = input.bool(title="Show Dif as percent of current Candle", defval=true)⋯//shortC = low < low[1] and low[1] < low[2] and low[2] < low[3] and low[3] < low[4] and close[4] < low[5]-tp=input(0.15, title="tp")+tp=input.float(0.15, title="tp")-sl=input(0.005, title="sl")+sl=input.float(0.005, title="sl")-strategy.entry("long",strategy.long,when=longC)+if longC+ strategy.entry("long",strategy.long)-strategy.entry("short",strategy.short,when=shortC)+if shortC+ strategy.entry("short",strategy.short)strategy.exit("x_long", "long" ,loss = close * sl / syminfo.mintick, profit = close * tp / syminfo.mintick , alert_message = "closelong")⋯Does it run in Pine Script v6?
No
The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L15:C0: a 'bool' cannot be 'na' in Pine Script v6 — declare it as true or false. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯// © SoftKill21-//@version=5+//@version=6strategy("Crypto strategy high/low", overlay=true)⋯Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Fast Length | 12 | int (written input.integer) | fast_ma |
| Slow Length | 26 | int (written input.integer) | slow_ma |
| Source | close | source | fast_ma slow_ma |
| Signal Smoothing | 9 | int (written input.integer) · min 1 · max 50 | signal |
| Simple MA(Oscillator) | true | bool | fast_ma slow_ma |
| Simple MA(Signal Line) | false | bool | signal |
| Start (no label in the script) | 0.02 | float | SAR AF |
| Increment (no label in the script) | 0.02 | float | AF |
| Maximum (no label in the script) | 0.2 | float | AF |
| CCI (no label in the script) | 20 | int | thisCCI |
| ATR (no label in the script) | 5 | int | bufferDn bufferUp |
| ATR Multiplier | 1 | int | bufferDn bufferUp |
| original coloring | true | bool | swap4 |
| source | close | source | smadif |
| Sma1length (no label in the script) | 5 | int | smadif |
| Sma2length (no label in the script) | 35 | int | smadif |
| Show Dif as percent of current Candle | true | bool | smadif |
| tp | 0.15 | float | exit x_long exit x_short |
| sl | 0.005 | float | exit x_long exit x_short |
What it calculates
- SMA / EMA (
sma,ta.smain v5)Source (close), Fast Length (12)fast_ma · line 75 - SMA / EMA (
sma,ta.smain v5)Source (close), Slow Length (26)slow_ma · line 76 - SMA / EMA (
sma,ta.smain v5)macd, Signal Smoothing (9)signal · line 78 - CCI (
cci,ta.cciin v5)close, CCI (20)thisCCI · line 84 - SMA (
sma,ta.smain v5)tr, ATR (5)bufferDn · line 86 - SMA (
sma,ta.smain v5)tr, ATR (5)bufferUp · line 87 - SMA (
sma,ta.smain v5)source (close), Sma1length (5)smadif · line 111
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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open long long | longC | On | 119 |
| Open short short | shortC | On | 120 |
| Exit x_long stop and limit | every bar | On | 121 |
| Exit x_short stop and limit | every bar | On | 123 |
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.
- 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | +15.9% | +102.5% | 17 | 12% | 3.44 | 3.2% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +8.0% | +5.5% | 13 | 15% | 2.96 | 2.2% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −0.2% | +9.8% | 12 | 0% | 0.00 | 0.2% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −0.1% | +8.4% | 8 | 0% | 0.00 | 0.1% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −0.0% | +16.7% | 19 | 0% | 0.00 | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | −0.0% | +21.5% | 10 | 0% | 0.00 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −0.1% | +148.3% | 18 | 0% | 0.00 | 0.1% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −0.0% | +17.1% | 12 | 0% | 0.00 | 0.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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 8 | 13% | $10,393.40 |
| Sideways market | 6 | 17% | $6,892.11 |
| Falling market | 3 | 0% | −$1,352.82 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
5.2%
The 95th percentile of the worst drawdown when the same 17 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 2.4% to 5.2%; the tick is what actually happened, 3.2%. Order luck alone moves it this much.
All 17 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 16 Jul 2024 64,724.10 | 16 Jul 2024 64,400.40 | 0 | −$323.63 |
| long | 17 Jul 2024 65,044.00 | 17 Jul 2024 64,718.80 | 0 | −$325.22 |
| short | 2 Aug 2024 65,354.00 | 5 Aug 2024 56,629.90 | 3 | $8,724.15 |
| short | 3 Oct 2024 60,649.30 | 3 Oct 2024 60,952.50 | 0 | −$303.25 |
| short | 4 Oct 2024 60,752.70 | 4 Oct 2024 61,056.50 | 0 | −$303.77 |
| short | 21 Dec 2024 97,805.40 | 21 Dec 2024 98,294.50 | 0 | −$489.03 |
| long | 17 Jan 2025 99,987.30 | 27 Jan 2025 99,474.20 | 10 | −$513.10 |
| short | 3 Feb 2025 97,700.60 | 3 Feb 2025 98,189.10 | 0 | −$488.51 |
| short | 4 Feb 2025 101,329.00 | 25 Feb 2025 87,595.60 | 21 | $13,732.90 |
| short | 1 Jun 2025 104,592.00 | 1 Jun 2025 105,115.00 | 0 | −$522.96 |
| short | 3 Aug 2025 112,546.00 | 3 Aug 2025 113,109.00 | 0 | −$562.74 |
| long | 11 Sep 2025 113,960.00 | 22 Sep 2025 113,384.00 | 11 | −$576.17 |
| long | 10 Dec 2025 92,678.80 | 10 Dec 2025 92,215.40 | 0 | −$463.40 |
| short | 21 Jan 2026 88,427.70 | 21 Jan 2026 88,869.80 | 0 | −$442.14 |
| short | 22 Jan 2026 89,454.70 | 22 Jan 2026 89,902.00 | 0 | −$447.28 |
| short | 19 May 2026 77,001.90 | 19 May 2026 77,386.90 | 0 | −$385.01 |
| short | 16 Sep 2026 75,644.50 | 16 Sep 2026 76,022.70 | 0 | −$378.23 |
Similar scripts
Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| High-low crypto strategy with MACD-PSAR-ATR-EWave this page | — | v4 strategy | +15.9% | 17 | 3.2% |
| Momentum Explosion 2CCI RSI by capam | ema sma cci | v4 strategy | +24.1% | 6 | 42.3% |
| MACD Long Strat by TheGrindToday | ema sma | v4 strategy | +24.0% | 79 | 20.1% |
| Stock trending strategy by exlux99 | ema sma | v4 strategy | +35.3% | 21 | 14.7% |
| 4-Hour Stochastic EMA Trend by slymnturkoglu | ema sma | v4 strategy | No trades on this market | ||
| 4X EMA and volume strategy by SoftKill21 | ema sma | v4 strategy | +1.8% | 3 | 25.8% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 40 ms | With a workaround 1,000 bars in 62 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
Zeal Terminal's engine currently reads an order side written as 1, 0 as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 119, 120) 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/// © SoftKill21//@version=4strategy("Crypto strategy high/low", overlay=true)fast_length = input(title="Fast Length", type=input.integer, defval=12)slow_length = input(title="Slow Length", type=input.integer, defval=26)src = input(title="Source", type=input.source, defval=close)signal_length = input(title="Signal Smoothing", type=input.integer, minval = 1, maxval = 50, defval = 9)sma_source = input(title="Simple MA(Oscillator)", type=input.bool, defval=true)sma_signal = input(title="Simple MA(Signal Line)", type=input.bool, defval=false)//sarstart = input(0.02)increment = input(0.02)maximum = input(0.2)var bool uptrend = navar float EP = navar float SAR = navar float AF = startvar float nextBarSAR = naif bar_index > 0 firstTrendBar = false SAR := nextBarSAR if bar_index == 1 float prevSAR = na float prevEP = na lowPrev = low[1] highPrev = high[1] closeCur = close closePrev = close[1] if closeCur > closePrev uptrend := true EP := high prevSAR := lowPrev prevEP := high else uptrend := false EP := low prevSAR := highPrev prevEP := low firstTrendBar := true SAR := prevSAR + start * (prevEP - prevSAR) if uptrend if SAR > low firstTrendBar := true uptrend := false SAR := max(EP, high) EP := low AF := start else if SAR < high firstTrendBar := true uptrend := true SAR := min(EP, low) EP := high AF := start if not firstTrendBar if uptrend if high > EP EP := high AF := min(AF + increment, maximum) else if low < EP EP := low AF := min(AF + increment, maximum) if uptrend SAR := min(SAR, low[1]) if bar_index > 1 SAR := min(SAR, low[2]) else SAR := max(SAR, high[1]) if bar_index > 1 SAR := max(SAR, high[2]) nextBarSAR := SAR + AF * (EP - SAR)// Calculatingfast_ma = sma_source ? sma(src, fast_length) : ema(src, fast_length)slow_ma = sma_source ? sma(src, slow_length) : ema(src, slow_length)macd = fast_ma - slow_masignal = sma_signal ? sma(macd, signal_length) : ema(macd, signal_length)hist = macd - signalCCI = input(20)ATR = input(5)Multiplier=input(1,title='ATR Multiplier')original=input(true,title='original coloring')thisCCI = cci(close, CCI)lastCCI = nz(thisCCI[1])bufferDn= high + Multiplier * sma(tr,ATR)bufferUp= low - Multiplier * sma(tr,ATR)if (thisCCI >= 0 and lastCCI < 0) bufferUp := bufferDn[1]if (thisCCI <= 0 and lastCCI > 0) bufferDn := bufferUp[1]if (thisCCI >= 0) if (bufferUp < bufferUp[1]) bufferUp := bufferUp[1]else if (thisCCI <= 0) if (bufferDn > bufferDn[1]) bufferDn := bufferDn[1]x=0.0x:=thisCCI >= 0 ?bufferUp:thisCCI <= 0 ?bufferDn:x[1]swap=0.0swap:=x>x[1]?1:x<x[1]?-1:swap[1]swap2=swap==1?color.lime:color.redswap3=thisCCI >=0 ?color.lime:color.redswap4=original?swap3:swap2//elliot wavesrce = input(close, title="source")sma1length = input(5)sma2length = input(35)UsePercent = input(title="Show Dif as percent of current Candle", type=input.bool, defval=true)smadif=iff(UsePercent,(sma(srce, sma1length) - sma(srce, sma2length)) / srce * 100, sma(srce, sma1length) - sma(srce, sma2length))col=smadif <= 0 ? color.red : color.greenlongC = high > high[1] and high[1] > high[2] and close[2] > high[3] and hist > 0 and uptrend and smadif < 0 and swap4==color.lime //longC = high > high[1] and high[1] > high[2] and high[2] > high[3] and high[3] > high[4] and close[4] > high[5]shortC = low < low[1] and low[1] < low[2] and close[2] < low[3] and hist < 0 and not uptrend and smadif > 0 and swap4==color.red //shortC = low < low[1] and low[1] < low[2] and low[2] < low[3] and low[3] < low[4] and close[4] < low[5]tp=input(0.15, title="tp")sl=input(0.005, title="sl")strategy.entry("long",1,when=longC)strategy.entry("short",0,when=shortC)strategy.exit("x_long", "long" ,loss = close * sl / syminfo.mintick, profit = close * tp / syminfo.mintick , alert_message = "closelong")//strategy.entry("short",0, when= loss = close * sl / syminfo.mintick)strategy.exit("x_short", "short" , loss = close * sl / syminfo.mintick, profit = close * tp / syminfo.mintick,alert_message = "closeshort")//strategy.entry("long",1, when = loss = close * sl / syminfo.mintick)//strategy.close("long",when= hist < 0)//strategy.close("short", when= hist > 0)