Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Volume and Moving average,will this model working in real-trade-

A Pine Script v4 strategy built on SMA (close, 1), RSI (close, 14) and Stdev (close, 20). It has 9 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 is one contract and pays 0.1% commission. 15 settings; defaults include Length1 1, Length3 3 and Length7 7.

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 Volume and Moving average,will this model working in real-trade- 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 Volume and Moving average,will this model working in real-trade- do on BTCUSDT 1D with default settings?
−157,995.00%
From 26 Jan 2024 to 21 Oct 2026, over 10 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can Volume and Moving average,will this model working in real-trade- 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 Volume and Moving average,will this model working in real-trade- use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Volume and Moving average,will this model working in real-trade- run in Zeal Terminal?
Yes
It compiles in 30 ms and runs 1,000 bars in 65 ms, in the browser.

BTCUSDT · 1D · default settings

  • Basis
  • Upper
  • Lower
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (15)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$-1,771$2Equity from $1
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.
Net profit
−157,995.00%
−$1,579.95
Buy and hold
+102.5%
same period
Closed trades
10
7 won · 3 lost
Profitable
70.0%
of closed trades
Profit factor
0.51
gross profit ÷ gross loss
Max drawdown
4,752.14%
−$2,897.76

One run with the author's default settings, $1 starting capital, commission as the script sets it. A long 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.

  • Note

    8 settings have no label

    In the settings dialog length1 (line 6), length3 (line 7), length7 (line 8), length14 (line 9), length20 (line 10), length60 (line 11), length120 (line 12), length (line 31) 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 iff(), which v5 removed line 22

    iff() on line 22, 23, 24. 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 sma → ta.sma, rsi → ta.rsi, stdev → ta.stdev, highest → ta.highest, valuewhen → ta.valuewhen, crossunder → ta.crossunder.

v4 → v5

Verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 13: sma → ta.sma
  • Line 14: sma → ta.sma
  • Line 15: sma → ta.sma
  • Line 16: sma → ta.sma
  • Line 17: sma → ta.sma
18 more edits
  • Line 18: sma → ta.sma
  • Line 19: sma → ta.sma
  • Line 20: rsi → ta.rsi
  • Line 22: iff(c, a, b) → (c ? a : b)
  • Line 23: iff(c, a, b) → (c ? a : b)
  • Line 24: iff(c, a, b) → (c ? a : b)
  • Line 25: input(type = input.integer) → input.int()
  • Line 26: input(type = input.integer) → input.int()
  • Line 28: sma → ta.sma
  • Line 29: sma → ta.sma
  • Line 36: sma → ta.sma
  • Line 37: stdev → ta.stdev
  • Line 40: stdev → ta.stdev
  • Line 43: stdev → ta.stdev
  • Line 46: input(type = input.integer) → input.int()
  • Line 57: highest → ta.highest
  • Line 59: valuewhen → ta.valuewhen
  • Line 77: crossunder → ta.crossunder
⋯// © KAIST291-//@version=4+//@version=5strategy("prototype",initial_capital=1,commission_type=strategy.commission.percent,commission_value=0.1, format=format.volume, precision=0,overlay=true)⋯length120=input(120)-ma1= sma(close,length1)+ma1= ta.sma(close,length1)-ma3= sma(close,length3)+ma3= ta.sma(close,length3)-ma7= sma(close,length7)+ma7= ta.sma(close,length7)-ma14=sma(close,length14)+ma14=ta.sma(close,length14)-ma20=sma(close,length20)+ma20=ta.sma(close,length20)-ma60=sma(close,length60)+ma60=ta.sma(close,length60)-ma120=sma(close,length120)+ma120=ta.sma(close,length120)-rsi=rsi(close,14)+rsi=ta.rsi(close,14)// BUYING VOLUME AND SELLING VOLUME //-BV = iff( (high==low), 0, volume*(close-low)/(high-low))+BV = ( (high==low) ? 0 : volume*(close-low)/(high-low))-SV = iff( (high==low), 0, volume*(high-close)/(high-low))+SV = ( (high==low) ? 0 : volume*(high-close)/(high-low))-vol = iff(volume > 0, volume, 1)+vol = (volume > 0 ? volume : 1)-dailyLength = input(title = "Daily MA length", type = input.integer, defval = 50, minval = 1, maxval = 100)+dailyLength = input.int(title = "Daily MA length", defval = 50, minval = 1, maxval = 100)-weeklyLength = input(title = "Weekly MA length", type = input.integer, defval = 10, minval = 1, maxval = 100)+weeklyLength = input.int(title = "Weekly MA length", defval = 10, minval = 1, maxval = 100)//------------------------------------------------------------Davgvol = sma(volume, dailyLength)+Davgvol = ta.sma(volume, dailyLength)-Wavgvol = sma(volume, weeklyLength)+Wavgvol = ta.sma(volume, weeklyLength)//-----------------------------------------------------------⋯mult3= input(1.0, minval=0.001, maxval=50, title="exp1")-basis = sma(src, length)+basis = ta.sma(src, length)-dev = mult * stdev(src, length)+dev = mult * ta.stdev(src, length)upper = basis + devlower = basis - dev-dev2= mult2 * stdev(src, length)+dev2= mult2 * ta.stdev(src, length)Supper= basis + dev2Slower= basis - dev2-dev3= mult3 * stdev(src, length)+dev3= mult3 * ta.stdev(src, length)upper1= basis + dev3lower1= basis - dev3-offset = input(0, "Offset", type = input.integer, minval = -500, maxval = 500)+offset = input.int(0, "Offset", minval = -500, maxval = 500)plot(basis, "Basis", color=#FF6D00, offset = offset)⋯bear=(close<Slower and close<lower and SV>BV and SV>Wavgvol)-hi=highest(exit,10)+hi=ta.highest(exit,10)imInATrade = strategy.position_size != 0-highestPriceAfterEntry = valuewhen(imInATrade, high, 0)+highestPriceAfterEntry = ta.valuewhen(imInATrade, high, 0)// STRATEGY LONG //⋯//////////////////////////////////////////////////////////////////////////////////-if (bear and close<ma3 and crossunder(ma60,ma120))+if (bear and close<ma3 and ta.crossunder(ma60,ma120))    strategy.entry("Short",strategy.short,0.1)⋯

Clean v5

VerifiedDownload the v5 script

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

  • Line 6: input() → input.int()
  • Line 7: input() → input.int()
  • Line 8: input() → input.int()
  • Line 9: input() → input.int()
  • Line 10: input() → input.int()
  • Line 11: input() → input.int()
6 more edits
  • Line 12: input() → input.int()
  • Line 31: input() → input.int()
  • Line 32: input() → input.source()
  • Line 33: input() → input.float()
  • Line 34: input() → input.float()
  • Line 35: input() → input.float()
⋯// SETTING //-length1=input(1)+length1=input.int(1)-length3=input(3)+length3=input.int(3)-length7=input(7)+length7=input.int(7)-length14=input(14)+length14=input.int(14)-length20=input(20)+length20=input.int(20)-length60=input(60)+length60=input.int(60)-length120=input(120)+length120=input.int(120)ma1= ta.sma(close,length1)⋯//------------------------------------------------------------length = input(20, minval=1)+length = input.int(20, minval=1)-src = input(close, title="Source")+src = input.source(close, title="Source")-mult = input(2.0, minval=0.001, maxval=50, title="StdDev")+mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev")-mult2= input(1.5, minval=0.001, maxval=50, title="exp")+mult2= input.float(1.5, minval=0.001, maxval=50, title="exp")-mult3= input(1.0, minval=0.001, maxval=50, title="exp1")+mult3= input.float(1.0, minval=0.001, maxval=50, title="exp1")basis = ta.sma(src, length)⋯

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: 10 before, 0 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © KAIST291-//@version=5+//@version=6strategy("prototype",initial_capital=1,commission_type=strategy.commission.percent,commission_value=0.1, format=format.volume, precision=0,overlay=true)⋯

Settings

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

SettingDefaultType and rangeFeeds
Length1 (no label in the script)1intma1
Length3 (no label in the script)3intma3
Length7 (no label in the script)7intma7
Length14 (no label in the script)14intma14
Length20 (no label in the script)20intma20
Length60 (no label in the script)60intma60
Length120 (no label in the script)120intma120
Daily MA length50int (written input.integer) · min 1 · max 100Davgvol
Weekly MA length10int (written input.integer) · min 1 · max 100Wavgvol
Length (no label in the script)20int · min 1basis dev dev2 dev3
Sourceclosesourcebasis dev dev2 dev3
StdDev2.0float · min 0.001 · max 50dev
exp1.5float · min 0.001 · max 50dev2
exp11.0float · min 0.001 · max 50dev3
Offset0int (written input.integer) · min -500 · max 500Upper Lower Basis

What it calculates

  • SMA (sma, ta.sma in v5)close, Length1 (1)ma1 · line 13
  • SMA (sma, ta.sma in v5)close, Length3 (3)ma3 · line 14
  • SMA (sma, ta.sma in v5)close, Length7 (7)ma7 · line 15
  • SMA (sma, ta.sma in v5)close, Length14 (14)ma14 · line 16
  • SMA (sma, ta.sma in v5)close, Length20 (20)ma20 · line 17
  • SMA (sma, ta.sma in v5)close, Length60 (60)ma60 · line 18
  • SMA (sma, ta.sma in v5)close, Length120 (120)ma120 · line 19
  • RSI (rsi, ta.rsi in v5)close, 14rsi · line 20
  • SMA (sma, ta.sma in v5)volume, Daily MA length (50)Davgvol · line 28
  • SMA (sma, ta.sma in v5)volume, Weekly MA length (10)Wavgvol · line 29
  • SMA (sma, ta.sma in v5)Source (close), Length (20)basis · line 36
  • Stdev (stdev, ta.stdev in v5)Source (close), Length (20)dev · line 37
  • Stdev (stdev, ta.stdev in v5)Source (close), Length (20)dev2 · line 40
  • Stdev (stdev, ta.stdev in v5)Source (close), Length (20)dev3 · line 43
  • Highest (highest, ta.highest in v5)exit, 10hi · line 57
  • Valuewhen (valuewhen, ta.valuewhen in v5)imInATrade, high, 0highestPriceAfterEntry · line 59

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 datalength1Length1setting · 1length3Length3setting · 3length7Length7setting · 7length14Length14setting · 14length20Length20setting · 20length60Length60setting · 60length120Length120setting · 120volumevolumeprice datadailyLengthDaily MA lengthsetting · 50weeklyLengthWeekly MA lengthsetting · 10lengthLengthsetting · 20multStdDevsetting · 2.0mult2expsetting · 1.5mult3exp1setting · 1.0highhighprice datalowlowprice datama1SMA→ ma1ma3SMA→ ma3ma7SMA→ ma7ma14SMA→ ma14ma20SMA→ ma20ma60SMA→ ma60ma120SMA→ ma120rsiRSI→ rsiDavgvolSMA→ DavgvolWavgvolSMA→ WavgvolbasisSMA→ basisdevStdev→ devdev2Stdev→ dev2dev3Stdev→ dev3hiHighest→ hihighestPriceAfterEntryValuewhen→ highestPriceAfterEntryupper, lowerupper · lower2 valuesSupper, SlowerSupper · Slower2 valuesupper1, lower1upper1 · lower12 valuesexitexitvaluebullbullconditionbearbearconditionBV, SVBV · SV2 conditionsvolvolconditionbull2bull2conditionbuxbuxconditionimInATradeimInATradeconditionentry:LongOpen Longstrategy.entryclose:LongClose Longstrategy.closeentry:ShortOpen Shortstrategy.entryclose:ShortClose Shortstrategy.closeplot:47Basisplotplot:48Upperplotplot:49Lowerplotfill:BackgroundBackgroundfill

Order rules

OrderFires whenBy defaultLine
Open Long long(bull and close>ma3 and ma20>ma60 and rsi<75)On62
Close Long(strategy.position_avg_price*1.05<close)On64
Close Long(highestPriceAfterEntry*0.999<close and close>strategy.position_avg_price*1.002)On66
Close Long(highestPriceAfterEntry*0.997<close and close>strategy.position_avg_price*1.002)On68
Close Long(highestPriceAfterEntry*0.995<close and close>strategy.position_avg_price*1.002)On70
Close Long(strategy.openprofit < strategy.position_avg_price*0.9-close)On72
Close Long(strategy.position_avg_price*0.9 > close)On74
Open Short short(bear and close<ma3 and crossunder(ma60,ma120))On78
Close Short(strategy.position_avg_price*0.95>close)On81

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.

4/4trades 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−157,995.0%+102.5%1070%0.514,752.1%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h−30,512.3%+5.5%683%0.5718,335.1%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−11,814.3%+9.8%838%0.27400.6%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h−1,746.1%+8.4%683%0.42311.2%8 May 2026 – 21 Oct 2026
SOLUSDT 1D+234.4%+16.7%1070%1.3865.8%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+63.7%+21.5%6100%—31.1%8 May 2026 – 21 Oct 2026
BNBUSDT 1D+2,855.1%+148.3%1580%1.91391.2%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−101.3%+17.1%1292%0.85540.6%8 May 2026 – 21 Oct 2026

Backtests are simulations on historical data and are not investment advice.

Settings heatmap

Two settings that feed the entry signal, moved around their defaults. The best in-sample pair (Daily MA length 25, Weekly MA length 5) made −108,534.0% before 26 Dec 2025 and −14,640.1% after it, against −16,361.2% for the defaults. 0% of the 64 combinations made money in-sample and 25% out-of-sample.

Before 26 Dec 2025 · in-sample
Weekly MA length ↓ · Daily MA length →2530354350607085
5−108,534%−108,534%−108,534%−140,768%−140,768%−140,768%−140,768%−140,768%
6−108,534%−108,534%−108,534%−140,768%−140,768%−140,768%−140,768%−140,768%
7−108,534%−108,534%−108,534%−140,768%−140,768%−140,768%−140,768%−140,768%
9−108,534%−108,534%−108,534%−140,768%−140,768%−140,768%−140,768%−140,768%
10−108,534%−108,534%−108,534%−140,768%−140,768%−140,768%−140,768%−140,768%
12−108,534%−108,534%−108,534%−140,768%−140,768%−140,768%−140,768%−140,768%
14−108,534%−108,534%−108,534%−140,768%−140,768%−140,768%−140,768%−140,768%
17−108,534%−108,534%−108,534%−140,768%−140,768%−140,768%−140,768%−140,768%
From 26 Dec 2025 · out-of-sample
Weekly MA length ↓ · Daily MA length →2530354350607085
5−14,640%−14,640%−14,640%−14,640%−16,361%−16,361%+36,820%+36,820%
6−14,640%−14,640%−14,640%−14,640%−16,361%−16,361%+36,820%+36,820%
7−14,640%−14,640%−14,640%−14,640%−16,361%−16,361%+36,820%+36,820%
9−14,640%−14,640%−14,640%−14,640%−16,361%−16,361%+36,820%+36,820%
10−14,640%−14,640%−14,640%−14,640%−16,361%−16,361%+36,820%+36,820%
12−14,640%−14,640%−14,640%−14,640%−16,361%−16,361%+36,820%+36,820%
14−14,640%−14,640%−14,640%−14,640%−16,361%−16,361%+36,820%+36,820%
17−14,640%−14,640%−14,640%−14,640%−16,361%−16,361%+36,820%+36,820%

Net P&L of trades opened in each period, as a share of starting capital. marks the defaults and the best in-sample cell. Hover a cell for its trade count. Backtests are simulations on historical data and are not investment advice.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market367%−$692.80
Sideways market667%−$1,239.25
Falling market1100%$360.76

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

How bad could the drawdown be?

217,089.0%

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

0%249,652%
All 10 trades
SideEntryExitBarsP&L
long16 Oct 2024 67,074.1020 Oct 2024 68,378.004$116.84
long30 Oct 2024 72,736.409 Nov 2024 76,509.8010$362.41
long22 Jan 2025 106,144.009 Feb 2025 96,444.8018−$990.17
long11 Jul 2025 116,010.0014 Jul 2025 119,087.003$284.15
long14 Aug 2025 123,306.0026 Aug 2025 110,112.0012−$1,342.79
long3 Oct 2025 120,529.005 Oct 2025 122,391.002$161.87
long14 Jan 2026 95,414.0026 Jan 2026 86,670.4012−$892.57
long14 Apr 2026 74,418.0023 Apr 2026 78,178.209$360.76
long20 Aug 2026 69,334.8021 Aug 2026 73,027.001$354.99
long19 Sep 2026 80,883.9021 Sep 2026 81,178.002$13.21

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
Volume and Moving average,will this model working in real-trade- this page—v4 strategy−157,995.0%104,752.1%
Vix FIX - StochRSI Strategy by timjsma rsi highest stdevv5 strategy+1.0%2110.7%
Bollinger band & Volume based strategy V2 by Ayden_Csma rsi stdev valuewhenv4 strategy−0.1%50.2%
Bottom catch strategy by footlzsma stdev rsiv4 strategy+3.9%37.1%
Bull Trend Filtered StochRSI (BTFS) by SnarkyPuppyhighest rsi smav5 strategy+36.9%2121.5%
Madri by Mdemoiorsi sma stdevv4 strategy+25.0%436.4%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 30 msYes 1,000 bars in 65 msNot measured
PineTSNo v5 and v6 only—Not measured

“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report. PineTS runs Pine Script v5 and v6 only.

Source

Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © KAIST291//@version=4strategy("prototype",initial_capital=1,commission_type=strategy.commission.percent,commission_value=0.1, format=format.volume, precision=0,overlay=true)// SETTING //length1=input(1)length3=input(3)length7=input(7)length14=input(14)length20=input(20)length60=input(60)length120=input(120)ma1= sma(close,length1)ma3= sma(close,length3)ma7= sma(close,length7)ma14=sma(close,length14)ma20=sma(close,length20)ma60=sma(close,length60)ma120=sma(close,length120)rsi=rsi(close,14)// BUYING VOLUME AND SELLING VOLUME //BV = iff( (high==low), 0, volume*(close-low)/(high-low))SV = iff( (high==low), 0, volume*(high-close)/(high-low))vol = iff(volume > 0, volume, 1)dailyLength = input(title = "Daily MA length", type = input.integer, defval = 50, minval = 1, maxval = 100)weeklyLength = input(title = "Weekly MA length", type = input.integer, defval = 10, minval = 1, maxval = 100)//-----------------------------------------------------------Davgvol = sma(volume, dailyLength)Wavgvol = sma(volume, weeklyLength)//-----------------------------------------------------------length = input(20, minval=1)src = input(close, title="Source")mult = input(2.0, minval=0.001, maxval=50, title="StdDev")mult2= input(1.5, minval=0.001, maxval=50, title="exp")mult3= input(1.0, minval=0.001, maxval=50, title="exp1")basis = sma(src, length)dev = mult * stdev(src, length)upper = basis + devlower = basis - devdev2= mult2 * stdev(src, length)Supper= basis + dev2Slower= basis - dev2dev3= mult3 * stdev(src, length)upper1= basis + dev3lower1= basis - dev3offset = input(0, "Offset", type = input.integer, minval = -500, maxval = 500)plot(basis, "Basis", color=#FF6D00, offset = offset)p1 = plot(upper, "Upper", color=#2962FF, offset = offset)p2 = plot(lower, "Lower", color=#2962FF, offset = offset)fill(p1, p2, title = "Background", color=color.rgb(33, 150, 243, 95))//----------------------------------------------------exit=(close-strategy.position_avg_price / strategy.position_avg_price*100)bull=(close>Supper and high > upper and BV>SV and BV>Davgvol)bull2=(BV>SV and BV>Davgvol)bux =(close<Supper and close>Slower and volume<Wavgvol)bear=(close<Slower and close<lower and SV>BV and SV>Wavgvol)hi=highest(exit,10)imInATrade = strategy.position_size != 0highestPriceAfterEntry = valuewhen(imInATrade, high, 0)// STRATEGY LONG //if (bull and close>ma3 and ma20>ma60 and rsi<75)    strategy.entry("Long",strategy.long,0.1)if (strategy.position_avg_price*1.05<close)    strategy.close("Long",1)else if (highestPriceAfterEntry*0.999<close and close>strategy.position_avg_price*1.002)    strategy.close("Long",1)else if (highestPriceAfterEntry*0.997<close and close>strategy.position_avg_price*1.002)    strategy.close("Long",1)else if (highestPriceAfterEntry*0.995<close and close>strategy.position_avg_price*1.002)    strategy.close("Long",1)else if (strategy.openprofit < strategy.position_avg_price*0.9-close)    strategy.close("Long",1)else if (strategy.position_avg_price*0.9 > close)    strategy.close("Long",1)////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////if (bear and close<ma3 and crossunder(ma60,ma120))    strategy.entry("Short",strategy.short,0.1)    if (strategy.position_avg_price*0.95>close)    strategy.close("Short",1)