Zeal Terminal Open in Zeal Terminal

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
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (5)
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct$14,131$20,253Equity from $10,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. 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.
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

Verified

Same 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)

Clean v5

VerifiedDownload the v5 script

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.

SettingDefaultType and rangeFeeds
Length9int · min 0ma smma smaval beta plus minus
Smoothing length9intresult
Moving Average TypeEMAstring · options ["NONE","SMA","SMMA" ,"EMA", "WMA", "HMA", "JMA"]line 33 line 36 line 39 line 44 line 47 line 50 line 53
Allow Shorttrueboolentry short line 96
Color barsfalseboolbarcolor

What it calculates

  • SMA / EMA / WMA / HMA (sma, ta.sma in v5)src, Length (9)ma · line 34
  • SMA (sma, ta.sma in v5)src, Length (9)smaval · line 41
  • Change / Highest (change, ta.change in v5)highest(up_band,len)up · line 73
  • Change / Lowest (change, ta.change in v5)lowest(low_band,len)down · line 74
  • RMA (rma, ta.rma in 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.

lengthLengthsetting · 9lowlowprice datahighhighprice datasmoothing_lengthSmoothing lengthsetting · 9maSMA / EMA / WMA / HMA→ masmavalSMA→ smavalupChange / Highest→ updownChange / Lowest→ downtruerangeRMA→ truerangesmmasmmavaluebetabetavaluealphaalphavaluetmp0tmp0valuetmp1tmp1valuetmp2tmp2valuetmp3tmp3valuetmp4tmp4valueplus, minusplus · minus2 valuesresultresultvaluecloseStatuscloseStatusvaluelonglongconditionshortshortconditioncol_grow_above, col_grow_below, col_fall_above, col_fall_below, colorsColourcol_grow_above · col_grow_bel…close:shortClose shortstrategy.closeclose:longClose longstrategy.closeentry:longOpen longstrategy.entryentry:shortOpen shortstrategy.entryplot:84DI+-plotbarcolor:85barcolorbarcolorplot:860-Lineplotfill:87Fillfillplotshape:98plotshapeplotshapeplotshape:99plotshapeplotshape

Order rules

OrderFires whenBy defaultLine
Close shortlongresult > 0 and result>result[1]On93
Close longshortresult< 0 and result<result[1]On94
Open long longlongresult > 0 and result>result[1]On95
Open short shortshortresult< 0 and result<result[1]On97

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.

9/9trades 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+42.4%+102.5%3933%1.2745.7%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−2.4%+5.5%4425%0.9628.4%8 May 2026 – 21 Oct 2026
ETHUSDT 1D+133.1%+9.8%2945%1.8348.2%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+14.0%+8.4%4226%1.2021.3%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+23.1%+16.7%3735%1.0982.8%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+31.0%+21.5%3832%1.4518.1%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+33.0%+148.3%3931%1.2177.5%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−9.3%+17.1%4229%0.8123.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 barsTradesWonP&L
Rising market1233%$1,757.78
Sideways market1937%$2,877.50
Falling market825%−$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.

0%63%
All 39 trades
SideEntryExitBarsP&L
long14 Feb 2024 49,699.6015 Apr 2024 65,661.9061$3,211.75
short15 Apr 2024 65,661.9020 May 2024 66,274.0035−$93.23
long20 May 2024 66,274.0017 Jun 2024 66,676.9028$60.79
short17 Jun 2024 66,676.9019 Jul 2024 63,987.9032$403.28
long19 Jul 2024 63,987.906 Aug 2024 54,018.8018−$1,557.97
short6 Aug 2024 54,018.8028 Aug 2024 59,415.0022−$998.95
long28 Aug 2024 59,415.005 Sep 2024 57,970.908−$243.05
short5 Sep 2024 57,970.9020 Sep 2024 62,948.0015−$858.55
long20 Sep 2024 62,948.0011 Oct 2024 60,326.4021−$416.47
short11 Oct 2024 60,326.4016 Oct 2024 67,074.105−$1,118.54
long16 Oct 2024 67,074.105 Jan 2025 98,220.5081$4,643.57
short5 Jan 2025 98,220.507 Jan 2025 102,236.002−$408.78
long7 Jan 2025 102,236.004 Feb 2025 101,329.0028−$88.73
short4 Feb 2025 101,329.0028 Mar 2025 87,232.0052$1,391.17
long28 Mar 2025 87,232.0030 Mar 2025 82,648.502−$525.44
short30 Mar 2025 82,648.5023 Apr 2025 93,443.0024−$1,306.07
long23 Apr 2025 93,443.008 Jun 2025 105,552.0046$1,295.89
short8 Jun 2025 105,552.0011 Jun 2025 110,274.003−$447.38
long11 Jun 2025 110,274.0023 Jun 2025 100,964.0012−$844.30
short23 Jun 2025 100,964.007 Jul 2025 109,204.0014−$816.13
long7 Jul 2025 109,204.004 Aug 2025 114,209.0028$458.31
short4 Aug 2025 114,209.0012 Aug 2025 118,686.008−$392.02
long12 Aug 2025 118,686.0024 Aug 2025 115,438.0012−$273.66
short24 Aug 2025 115,438.0014 Sep 2025 115,918.0021−$41.60
long14 Sep 2025 115,918.0026 Sep 2025 108,994.0012−$597.30
short26 Sep 2025 108,994.004 Oct 2025 122,232.008−$1,214.53
long4 Oct 2025 122,232.0014 Oct 2025 115,166.0010−$578.10
short14 Oct 2025 115,166.001 Nov 2025 109,608.0018$482.61
long1 Nov 2025 109,608.004 Nov 2025 106,583.003−$275.98
short4 Nov 2025 106,583.006 Jan 2026 93,859.7063$1,193.75
long6 Jan 2026 93,859.7027 Jan 2026 88,347.1021−$587.33
short27 Jan 2026 88,347.1010 Mar 2026 68,432.2042$2,254.17
long10 Mar 2026 68,432.2028 Mar 2026 66,407.3018−$295.90
short28 Mar 2026 66,407.309 Apr 2026 71,069.9012−$702.13
long9 Apr 2026 71,069.9021 May 2026 77,552.2042$912.10
short21 May 2026 77,552.2016 Jul 2026 64,756.3056$1,649.98
long16 Jul 2026 64,756.3014 Aug 2026 63,490.9029−$195.41
short14 Aug 2026 63,490.9020 Aug 2026 69,334.806−$920.43
long20 Aug 2026 69,334.8012 Oct 2026 83,773.1053$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.

ScriptSharesTypeNetTradesMax drawdown
DMI Modified Strategy this page—v4 strategy+42.4%3945.7%
MACD Willy Strategy by PtGamblerrma sma ema highest lowest wmav5 strategyNo trades on this market
Bagheri IG Ether by Bagheri_IGema highest lowest rma smav4 strategy+0.0%30.0%
Bagheri IG Ether v2 by Bagheri_IGema highest lowest rma smav4 strategy−0.0%20.0%
Swing Multi Moving Averages Crypto and Stocks Strategy by exlux99ema wma highest lowest smav5 strategy+60.2%2213.1%
Ultra Moving Average Rating Trend Strategy by exlux99ema wma highest lowest sma rma hmav5 strategy+2.8%52.4%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 23 msWith a workaround 1,000 bars in 64 msNot measured
PineTSNo 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)