Pine Script v4 · Strategy
DMI Modified Strategy
A Pine Script v4 strategy built on SMA or EMA or WMA or HMA (src, 9), SMA (src, 9) and Change or Highest (up_band,len). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 10000 in cash and pays no commission. 5 settings; defaults include Length 9, Smoothing length 9 and Moving Average Type EMA.
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 DMI Modified Strategy repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 9 of 9 trades.
- How did DMI Modified Strategy do on BTCUSDT 1D with default settings?
- +42.42%
- From 26 Jan 2024 to 21 Oct 2026, over 39 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can DMI Modified 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 DMI Modified Strategy use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does DMI Modified Strategy run in Zeal Terminal?
- Yes
- It compiles in 23 ms and runs 1,000 bars in 64 ms, in the browser.
BTCUSDT · 1D · default settings
- DI+-
- 0-Line
- Shape
- Shape
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +42.42%
- $4,241.80
- Buy and hold
- +102.5%
- same period
- Closed trades
- 39
- 13 won · 26 lost
- Profitable
- 33.3%
- of closed trades
- Profit factor
- 1.27
- gross profit ÷ gross loss
- Max drawdown
- 45.67%
- −$6,359.46
One run with the author's default settings, $10,000 starting capital, commission as the script sets it. A short 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.
-
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 93, 94, 95, 97. The upgraded version below moves each call inside an if block.
-
Note
Uses transp =, which v5 removed line 86
transp = on line 86, 98, 99. v5 folds the transparency into the colour with color.new(c, transp).
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 sma → ta.sma, ema → ta.ema, wma → ta.wma, hma → ta.hma, change → ta.change, highest → ta.highest, lowest → ta.lowest, rma → ta.rma, crossover → ta.crossover, crossunder → ta.crossunder.
- 4 strategy calls use the when = argument (line 93, 94, 95, 97). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
v4 → v5
VerifiedSame 39 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 1: //@version=4 → //@version=5
- Line 37: sma → ta.sma
- Line 41: sma → ta.sma
- Line 45: ema → ta.ema
- Line 48: wma → ta.wma
- Line 51: hma → ta.hma
15 more edits
- Line 73: change → ta.change
- Line 73: highest → ta.highest
- Line 74: change → ta.change
- Line 74: lowest → ta.lowest
- Line 75: rma → ta.rma
- Line 75: tr → ta.tr
- Line 76: rma → ta.rma
- Line 77: rma → ta.rma
- Line 86: transp = 60 → color.new(color.white, 60)
- Line 95: strategy.entry(…, true) → strategy.entry(…, strategy.long)
- Line 97: strategy.entry(…, false) → strategy.entry(…, strategy.short)
- Line 98: crossover → ta.crossover
- Line 98: transp = 65 → color.new(color.lime, 65)
- Line 99: crossunder → ta.crossunder
- Line 99: transp = 65 → color.new(color.red, 65)
-//@version=4+//@version=5strategy(shorttitle="DMI Modified Strategy", title="DMI Modified Strategy", overlay=true,default_qty_type=strategy.cash, default_qty_value=10000, initial_capital=10000)⋯ if ma_select == "SMA"- ma := sma(src, length)+ ma := ta.sma(src, length) ma⋯ smma = float (0.0)- smaval=sma(src, length)+ smaval=ta.sma(src, length) smma := na(smma[1]) ? smaval : (smma[1] * (length - 1) + src) / length⋯ if ma_select == "EMA"- ma := ema(src, length)+ ma := ta.ema(src, length) ma if ma_select == "WMA"- ma := wma(src, length)+ ma := ta.wma(src, length) ma if ma_select == "HMA"- ma := hma(src,length)+ ma := ta.hma(src,length) ma⋯dirmov(len,up_band,low_band) =>- up = change(highest(up_band,len)) + up = ta.change(ta.highest(up_band,len)) - down = -change(lowest(low_band,len))+ down = -ta.change(ta.lowest(low_band,len))- truerange = rma(tr, len)+ truerange = ta.rma(ta.tr, len)- plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / truerange)+ plus = fixnan(100 * ta.rma(up > down and up > 0 ? up : 0, len) / truerange)- minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, len) / truerange)+ minus = fixnan(100 * ta.rma(down > up and down > 0 ? down : 0, len) / truerange) [plus, minus]⋯barcolor(color_bars ? colors : na)-zero_line=plot(0, color=color.white, title="0-Line",transp=60)+zero_line=plot(0, color=color.new(color.white, 60), title="0-Line")fill (dmi,zero_line,color=colors)⋯strategy.close("long",when=short,comment=closeStatus)-strategy.entry("long", true, when = long)+strategy.entry("long", strategy.long, when = long)if (allow_short)- strategy.entry("short",false, when = short)+ strategy.entry("short",strategy.short, when = short)-plotshape(crossover(result,0) ? result : na, style=shape.circle, color=color.lime,location=location.absolute,size=size.tiny,transp=65)+plotshape(ta.crossover(result,0) ? result : na, style=shape.circle, color=color.new(color.lime, 65),location=location.absolute,size=size.tiny)-plotshape(crossunder(result,0) ? result : na, style=shape.circle, color=color.red,location=location.absolute,size=size.tiny,transp=65)+plotshape(ta.crossunder(result,0) ? result : na, style=shape.circle, color=color.new(color.red, 65),location=location.absolute,size=size.tiny)Same 39 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 27: input() → input.int()
- Line 28: input() → input.int()
- Line 29: input() → input.string()
- Line 30: input() → input.bool()
- Line 66: input() → input.bool()
- Line 93: when = long → if block
3 more edits
- Line 94: when = short → if block
- Line 95: when = long → if block
- Line 97: when = short → if block
⋯// Like if you like and Enjoy! Follow for more upcoming indicators/strategies: https://www.tradingview.com/u/dman103/#published-scripts-length = input(9, title="Length", minval=0)+length = input.int(9, title="Length", minval=0)-smoothing_length=input(9, title="Smoothing length")+smoothing_length=input.int(9, title="Smoothing length")-ma_select = input(title="Moving Average Type", defval="EMA", options=["NONE","SMA","SMMA" ,"EMA", "WMA", "HMA", "JMA"])+ma_select = input.string(title="Moving Average Type", defval="EMA", options=["NONE","SMA","SMMA" ,"EMA", "WMA", "HMA", "JMA"])-allow_short = input(true,title="Allow Short")+allow_short = input.bool(true,title="Allow Short")MA_selector(src, length) =>⋯ ma-color_bars=input(false,title="Color bars")+color_bars=input.bool(false,title="Color bars")// Colors⋯//, comment=strategy.position_size<0 ? closeStatus : na)-strategy.close("short",when=long,comment=closeStatus)+if long+ strategy.close("short",comment=closeStatus)-strategy.close("long",when=short,comment=closeStatus)+if short+ strategy.close("long",comment=closeStatus)-strategy.entry("long", strategy.long, when = long)+if long+ strategy.entry("long", strategy.long)if (allow_short)- strategy.entry("short",strategy.short, when = short)+ if short+ strategy.entry("short",strategy.short)plotshape(ta.crossover(result,0) ? result : na, style=shape.circle, color=color.new(color.lime, 65),location=location.absolute,size=size.tiny)⋯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: 39 before, 6 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.
-//@version=5+//@version=6strategy(shorttitle="DMI Modified Strategy", title="DMI Modified Strategy", overlay=true,default_qty_type=strategy.cash, default_qty_value=10000, initial_capital=10000)⋯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 |
|---|---|---|---|
| Length | 9 | int · min 0 | ma smma smaval beta plus minus |
| Smoothing length | 9 | int | result |
| Moving Average Type | EMA | string · options ["NONE","SMA","SMMA" ,"EMA", "WMA", "HMA", "JMA"] | line 33 line 36 line 39 line 44 line 47 line 50 line 53 |
| Allow Short | true | bool | entry short line 96 |
| Color bars | false | bool | barcolor |
What it calculates
- SMA / EMA / WMA / HMA (
sma,ta.smain v5)src, Length (9)ma · line 34 - SMA (
sma,ta.smain v5)src, Length (9)smaval · line 41 - Change / Highest (
change,ta.changein v5)highest(up_band,len)up · line 73 - Change / Lowest (
change,ta.changein v5)lowest(low_band,len)down · line 74 - RMA (
rma,ta.rmain v5)tr, lentruerange · line 75
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 |
|---|---|---|---|
| Close short | longresult > 0 and result>result[1] | On | 93 |
| Close long | shortresult< 0 and result<result[1] | On | 94 |
| Open long long | longresult > 0 and result>result[1] | On | 95 |
| Open short short | shortresult< 0 and result<result[1] | On | 97 |
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 | +42.4% | +102.5% | 39 | 33% | 1.27 | 45.7% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −2.4% | +5.5% | 44 | 25% | 0.96 | 28.4% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +133.1% | +9.8% | 29 | 45% | 1.83 | 48.2% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +14.0% | +8.4% | 42 | 26% | 1.20 | 21.3% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | +23.1% | +16.7% | 37 | 35% | 1.09 | 82.8% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +31.0% | +21.5% | 38 | 32% | 1.45 | 18.1% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +33.0% | +148.3% | 39 | 31% | 1.21 | 77.5% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −9.3% | +17.1% | 42 | 29% | 0.81 | 23.9% | 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 | 12 | 33% | $1,757.78 |
| Sideways market | 19 | 37% | $2,877.50 |
| Falling market | 8 | 25% | −$393.48 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
55.0%
The 95th percentile of the worst drawdown when the same 39 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 28.4% to 55.0%; the tick is what actually happened, 38.2%. Order luck alone moves it this much.
All 39 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 14 Feb 2024 49,699.60 | 15 Apr 2024 65,661.90 | 61 | $3,211.75 |
| short | 15 Apr 2024 65,661.90 | 20 May 2024 66,274.00 | 35 | −$93.23 |
| long | 20 May 2024 66,274.00 | 17 Jun 2024 66,676.90 | 28 | $60.79 |
| short | 17 Jun 2024 66,676.90 | 19 Jul 2024 63,987.90 | 32 | $403.28 |
| long | 19 Jul 2024 63,987.90 | 6 Aug 2024 54,018.80 | 18 | −$1,557.97 |
| short | 6 Aug 2024 54,018.80 | 28 Aug 2024 59,415.00 | 22 | −$998.95 |
| long | 28 Aug 2024 59,415.00 | 5 Sep 2024 57,970.90 | 8 | −$243.05 |
| short | 5 Sep 2024 57,970.90 | 20 Sep 2024 62,948.00 | 15 | −$858.55 |
| long | 20 Sep 2024 62,948.00 | 11 Oct 2024 60,326.40 | 21 | −$416.47 |
| short | 11 Oct 2024 60,326.40 | 16 Oct 2024 67,074.10 | 5 | −$1,118.54 |
| long | 16 Oct 2024 67,074.10 | 5 Jan 2025 98,220.50 | 81 | $4,643.57 |
| short | 5 Jan 2025 98,220.50 | 7 Jan 2025 102,236.00 | 2 | −$408.78 |
| long | 7 Jan 2025 102,236.00 | 4 Feb 2025 101,329.00 | 28 | −$88.73 |
| short | 4 Feb 2025 101,329.00 | 28 Mar 2025 87,232.00 | 52 | $1,391.17 |
| long | 28 Mar 2025 87,232.00 | 30 Mar 2025 82,648.50 | 2 | −$525.44 |
| short | 30 Mar 2025 82,648.50 | 23 Apr 2025 93,443.00 | 24 | −$1,306.07 |
| long | 23 Apr 2025 93,443.00 | 8 Jun 2025 105,552.00 | 46 | $1,295.89 |
| short | 8 Jun 2025 105,552.00 | 11 Jun 2025 110,274.00 | 3 | −$447.38 |
| long | 11 Jun 2025 110,274.00 | 23 Jun 2025 100,964.00 | 12 | −$844.30 |
| short | 23 Jun 2025 100,964.00 | 7 Jul 2025 109,204.00 | 14 | −$816.13 |
| long | 7 Jul 2025 109,204.00 | 4 Aug 2025 114,209.00 | 28 | $458.31 |
| short | 4 Aug 2025 114,209.00 | 12 Aug 2025 118,686.00 | 8 | −$392.02 |
| long | 12 Aug 2025 118,686.00 | 24 Aug 2025 115,438.00 | 12 | −$273.66 |
| short | 24 Aug 2025 115,438.00 | 14 Sep 2025 115,918.00 | 21 | −$41.60 |
| long | 14 Sep 2025 115,918.00 | 26 Sep 2025 108,994.00 | 12 | −$597.30 |
| short | 26 Sep 2025 108,994.00 | 4 Oct 2025 122,232.00 | 8 | −$1,214.53 |
| long | 4 Oct 2025 122,232.00 | 14 Oct 2025 115,166.00 | 10 | −$578.10 |
| short | 14 Oct 2025 115,166.00 | 1 Nov 2025 109,608.00 | 18 | $482.61 |
| long | 1 Nov 2025 109,608.00 | 4 Nov 2025 106,583.00 | 3 | −$275.98 |
| short | 4 Nov 2025 106,583.00 | 6 Jan 2026 93,859.70 | 63 | $1,193.75 |
| long | 6 Jan 2026 93,859.70 | 27 Jan 2026 88,347.10 | 21 | −$587.33 |
| short | 27 Jan 2026 88,347.10 | 10 Mar 2026 68,432.20 | 42 | $2,254.17 |
| long | 10 Mar 2026 68,432.20 | 28 Mar 2026 66,407.30 | 18 | −$295.90 |
| short | 28 Mar 2026 66,407.30 | 9 Apr 2026 71,069.90 | 12 | −$702.13 |
| long | 9 Apr 2026 71,069.90 | 21 May 2026 77,552.20 | 42 | $912.10 |
| short | 21 May 2026 77,552.20 | 16 Jul 2026 64,756.30 | 56 | $1,649.98 |
| long | 16 Jul 2026 64,756.30 | 14 Aug 2026 63,490.90 | 29 | −$195.41 |
| short | 14 Aug 2026 63,490.90 | 20 Aug 2026 69,334.80 | 6 | −$920.43 |
| long | 20 Aug 2026 69,334.80 | 12 Oct 2026 83,773.10 | 53 | $2,082.41 |
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 |
|---|---|---|---|---|---|
| DMI Modified Strategy this page | — | v4 strategy | +42.4% | 39 | 45.7% |
| MACD Willy Strategy by PtGambler | rma sma ema highest lowest wma | v5 strategy | No trades on this market | ||
| Bagheri IG Ether by Bagheri_IG | ema highest lowest rma sma | v4 strategy | +0.0% | 3 | 0.0% |
| Bagheri IG Ether v2 by Bagheri_IG | ema highest lowest rma sma | v4 strategy | −0.0% | 2 | 0.0% |
| Swing Multi Moving Averages Crypto and Stocks Strategy by exlux99 | ema wma highest lowest sma | v5 strategy | +60.2% | 22 | 13.1% |
| Ultra Moving Average Rating Trend Strategy by exlux99 | ema wma highest lowest sma rma hma | v5 strategy | +2.8% | 5 | 2.4% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 23 ms | With a workaround 1,000 bars in 64 ms | Not measured |
| PineTS | No v5 and v6 only | — | Not measured |
Zeal Terminal's engine currently reads an order side written as true, false as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 95, 97) so the engine trades the way the script says.
“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report. PineTS runs Pine Script v5 and v6 only.
Source
Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.
//@version=4strategy(shorttitle="DMI Modified Strategy", title="DMI Modified Strategy", overlay=true,default_qty_type=strategy.cash, default_qty_value=10000, initial_capital=10000)// This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License https://creativecommons.org/licenses/by-sa/4.0/// © dman103// As promised a strategy of my DMI Modified indicator! (See link below for indicator).// === How does it work? ===// Instead of plotting the positive direction of +DI and negative direction for -DI, we subtract the +DI with the -DI on scales of 100 to -100.// The result is plotted with a oscillator to identify the current trend.// DMI Modified supports multiple moving averages (default is EMA with length of 9). You can disable moving averages smoothing in settings.//== About the Strategy ==// Buys when the line crosses over the Zero line.// Sells when the line crosses under the Zero line.// The DMI modified strategy is pretty much clean, without any filtering besides the DMI Modified and a moving average to smooth it.// Works best to catch a trend and more suitable for 1 hour and above time frame. Stay tuned for updates.// == Oscillator Colors ==// GREEN : Strong Up Trend as DMI Modified is above zero line and DMI modified is ascending.// LIGHT GREEN: Still up trend but weakening as DMI modified is above zero but descending. // RED: Strong Downtrend as DMI Modified is below zero line and DMI modified is descending.// LIGHT RED: Still down trending but weakening as DMI modified is below zero but ascending.// == Notes ==// Short is enabled by default.// Can also be used to find divergences.// Bar coloring is disabled by default// == Links ==// DMI modified indicator: https://www.tradingview.com/script/CbDXEyDN-DMI-Modified/// Like if you like and Enjoy! Follow for more upcoming indicators/strategies: https://www.tradingview.com/u/dman103/#published-scriptslength = input(9, title="Length", minval=0)smoothing_length=input(9, title="Smoothing length")ma_select = input(title="Moving Average Type", defval="EMA", options=["NONE","SMA","SMMA" ,"EMA", "WMA", "HMA", "JMA"])allow_short = input(true,title="Allow Short")MA_selector(src, length) => ma = 0.0 if ma_select == "NONE" ma:=src ma if ma_select == "SMA" ma := sma(src, length) ma if ma_select == "SMMA" smma = float (0.0) smaval=sma(src, length) smma := na(smma[1]) ? smaval : (smma[1] * (length - 1) + src) / length ma := smma if ma_select == "EMA" ma := ema(src, length) ma if ma_select == "WMA" ma := wma(src, length) ma if ma_select == "HMA" ma := hma(src,length) ma if ma_select == "JMA" beta = 0.45*(length-1)/(0.45*(length-1)+2) alpha = beta tmp0 = 0.0, tmp1 = 0.0, tmp2 = 0.0, tmp3 = 0.0, tmp4 = 0.0 tmp0 := (1-alpha)*src + alpha*nz(tmp0[1]) tmp1 := (src - tmp0[0])*(1-beta) + beta*nz(tmp1[1]) tmp2 := tmp0[0] + tmp1[0] tmp3 := (tmp2[0] - nz(tmp4[1]))*((1-alpha)*(1-alpha)) + (alpha*alpha)*nz(tmp3[1]) tmp4 := nz(tmp4[1]) + tmp3[0] ma := tmp4 ma macolor_bars=input(false,title="Color bars")// Colorscol_grow_above = #26A69Acol_grow_below = #FFCDD2col_fall_above = #AAFFDBcol_fall_below = #EF5350dirmov(len,up_band,low_band) => up = change(highest(up_band,len)) down = -change(lowest(low_band,len)) truerange = rma(tr, len) plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / truerange) minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, len) / truerange) [plus, minus][plus, minus]= dirmov(length,high,low)result= plus-minusresult:=MA_selector(result,smoothing_length)closeStatus = strategy.openprofit > 0 ? "win" : "lose"colors= result > 0 and result>result[1] ? col_grow_above : result > 0 and result<result[1] ? col_fall_above : result<0 and result>result[1] ? col_grow_below : result<0 and result<result[1] ? col_fall_below : color.whitedmi=plot(result, style=plot.style_line, color=colors, linewidth=2, title="DI+-")barcolor(color_bars ? colors : na)zero_line=plot(0, color=color.white, title="0-Line",transp=60)fill (dmi,zero_line,color=colors)long = result > 0 and result>result[1]short = result< 0 and result<result[1]// strategy.entry("B", true,when=long)// strategy.entry("S",false,when=short)//, comment=strategy.position_size<0 ? closeStatus : na)strategy.close("short",when=long,comment=closeStatus)strategy.close("long",when=short,comment=closeStatus)strategy.entry("long", true, when = long)if (allow_short) strategy.entry("short",false, when = short)plotshape(crossover(result,0) ? result : na, style=shape.circle, color=color.lime,location=location.absolute,size=size.tiny,transp=65)plotshape(crossunder(result,0) ? result : na, style=shape.circle, color=color.red,location=location.absolute,size=size.tiny,transp=65)