Zeal Terminal Open Zeal Terminal

Pine Script v5 · Strategy

X48 - Strategy - MA Type Cross + TPSL - Future&Spot - V.2

A Pine Script v5 strategy built on EMA or SMA or WMA or HMA or RMA or VWMA (pricestrategy, 18), RSI (close, 14) and Crossover (vrsi, 70). It has 13 order rules, 4 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade commits 20 in cash and pays 0.1 commission. 47 settings; defaults include Source Multi MA close, Fast MA Length 18 and Fast MA 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 X48 - Strategy - MA Type Cross + TPSL - Future&Spot - V.2 repaint?
Yes
At least one pattern in the source can repaint: higher-timeframe data.
Does X48 - Strategy - MA Type Cross + TPSL - Future&Spot - V.2 run in Pine Script v6?
Not tested
The v5 script does not run in Zeal Terminal's engine (Pine Script v5 Error at @L344:C0: no source was supplied for the library 'X4815162342/X48_LibaryStrategyStatus/2'. Libraries cannot be fetched from TradingView; supply the source in the 'libraries' option. No libraries were supplied.), so this step could not be checked. The v6 version is shown for reference and is not offered as a download.
Does X48 - Strategy - MA Type Cross + TPSL - Future&Spot - V.2 use a stop loss?
Yes
strategy.exit sets a stop on line 244, 246, 249.
Does X48 - Strategy - MA Type Cross + TPSL - Future&Spot - V.2 run in Zeal Terminal?
No
Not yet: it imports the library X4815162342/X48_LibaryStrategyStatus/2, whose source is not available here, so it does not run here
Does not run in Zeal Terminal yetIt imports the library X4815162342/X48_LibaryStrategyStatus/2, whose source is not available here, so it does not run here. The settings, logic and review below are read from the source, which does not need a run.

Review

What a careful reader of this script would point out, found by checking the source.

  • Likely bug

    ta.ema(close, 21) ignores the settings line 107

    Line 107 hard-codes 21 where line 39 uses “Fast MA Length”. Changing those settings moves one band but not this one.

    ta.ema(close,21)ta.ema(close, ma1strategy)
  • Likely bug

    ta.ema(close, 144) ignores the settings line 108

    Line 108 hard-codes 144 where line 39 uses “Fast MA Length”. Changing those settings moves one band but not this one.

    ta.ema(close,144)ta.ema(close, ma1strategy)
  • Likely bug

    ta.ema(close, 233) ignores the settings line 109

    Line 109 hard-codes 233 where line 39 uses “Fast MA Length”. Changing those settings moves one band but not this one.

    ta.ema(close,233)ta.ema(close, ma1strategy)
  • Likely bug

    ta.ema(srccdc, 2) ignores the settings line 267

    Line 267 hard-codes 2 where line 39 uses “Fast MA Length”. Changing those settings moves one band but not this one.

    ta.ema(srccdc, 2)ta.ema(srccdc, ma1strategy)
  • Likely bug

    ta.sma(high, 34) ignores the settings line 110

    Line 110 hard-codes 34 where line 40 uses “Fast MA Length”. Changing those settings moves one band but not this one.

    ta.sma(high,34)ta.sma(high, ma1strategy)
  • Likely bug

    ta.sma(close, 34) ignores the settings line 111

    Line 111 hard-codes 34 where line 40 uses “Fast MA Length”. Changing those settings moves one band but not this one.

    ta.sma(close,34)ta.sma(close, ma1strategy)
  • Likely bug

    ta.sma(low, 34) ignores the settings line 112

    Line 112 hard-codes 34 where line 40 uses “Fast MA Length”. Changing those settings moves one band but not this one.

    ta.sma(low,34)ta.sma(low, ma1strategy)
  • Likely bug

    ta.crossover(delta, 0) ignores the settings line 100

    Line 100 hard-codes 0 where line 87 uses “RSI OB”. Changing those settings moves one band but not this one.

    ta.crossover(delta, 0)ta.crossover(delta, OverBought)
  • Likely bug

    ta.crossunder(delta, 0) ignores the settings line 101

    Line 101 hard-codes 0 where line 88 uses “RSI OS”. Changing those settings moves one band but not this one.

    ta.crossunder(delta, 0)ta.crossunder(delta, OverSold)
  • Check

    1 setting does nothing

    “Alert Message for BOT” is declared but never read.

Settings

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

SettingDefaultType and rangeFeeds
SPOT SETTING
SPOT MODESPOT = Disable Short Positionfalseboolclose Long entry Short close Long close Long entry Short line 212 line 214 line 224 line 226 line 228 line 242 line 247 line 251 line 257
Multi MA SETTING
Source Multi MANormal Line = Close \nSmooth Line = ohlc4closesourcepricestrategy vrsi
Show Fast MA LinetrueboolFast MA
Show Slow MA LinetrueboolSlow MA
Fast MA Length18intprice1strategy
Fast MA TypeSMA / EMA / WMA / HMA / RMA / VWMAEMAstring · options ['SMA', 'EMA', 'WMA', 'HMA', 'RMA', 'VWMA']price1strategy
Slow MA Length34intprice3strategy
Slow MA TypeSMA / EMA / WMA / HMA / RMA / VWMAEMAstring · options ['SMA', 'EMA', 'WMA', 'HMA', 'RMA', 'VWMA']price3strategy
MIDDLE 3MA SETTING
MA MIDDLE MODEStrategy Is\nMA Fast > MA Slow = Long\nEMA Fast < MA Mid = ShortfalseboolMiddle MA Middle MA line 206 line 217
Middle MA Length24intprice2strategy
Middle MA TypeSMA / EMA / WMA / HMA / RMA / VWMAEMAstring · options ['SMA', 'EMA', 'WMA', 'HMA', 'RMA', 'VWMA']price2strategy
Bot Setting \n >> If You Dont Use Bot Just Pass It
Alert Message for BOTAlert For X48-BOT > Copy and Paste To Alert FunctionText_Alert_Futurevalueunused
Bot PassPassphrase Must Be Same as X48-BOT1234stringAlert_OpenLong Alert_OpenShort Alert_StopLosslong Alert_StopLossshort
leverage"NOTHING" to do with Position size For Command To X48-BOT Only125int · min 1Alert_OpenLong Alert_OpenShort Alert_StopLosslong Alert_StopLossshort
Bot Long Command1.OpenLong\n2.AutoLong\n***If AutoLong = Close(100%) First > Open Long Position AutoAutoLongstringAlert_OpenLong
Bot Short Command1.OpenShort\n2.AutoShort\n***If AutoShort = Close(100%) First > Open Short Position AutoAutoShortstringAlert_OpenShort
Future/Spot Command1. bnfuture = FUTURE MODE\n2. bnspot = SPOT MODE\n 3.bncombo = EZ 2in1 OrderbnfuturestringAlert_OpenLong Alert_OpenShort Alert_StopLosslong Alert_StopLossshort
RSI SETTING >> COMFIRM RSI BEFORE OPEN POSITION
RSI MODEIf Mode On = Use RSI Strategy With Long and Short\n >> RSI Confirm Before Open PositionfalseboolRSIUP RSIDOWN
RSI SETTING >> PLOT RSI SIGNAL OB OS
RSI Length14intvrsi
RSI OBLil Cross Symbol70intRSIUP
RSI OSLil Diamond Symbol30intRSIDOWN
MACD SETTING
MACD MODE = MACD Cross SignalIf Mode On = Use MACD Strategy for Signal When Cross Up and Cross DownfalseboolmacdTPl macdTPs
MACD Fast12intMACD
MACD Slow26intMACD
MACD Length18intaMACD
SURF&DIVING SETTING
SURFING&DIVING MODEHow To Use\n3 Dot Waves CrossUp Purple Line = Bullish Trend\n3 Dot Waves CrossDown Purple Line = Bearish Trend\n\nBig Blue Dot is Surfing Zone\nCandle Price Close > Surfing Zone = Lil Bullish\nCandle Price Clsoe < Surfing Zone = Lil BearishfalseboolplotshowSurf surfing_21 surfing_h surfing_c surfing_l diving_144 diving_233
Show Surfing & Diving SignalPlot Symbol of Lil Trend By Surfing ManfalseboolplotshowSurf plotshape
AUTO TP/SL
Mode AUTO TP/SLIf Mode On = Use TP/SL\nIf Mode Off = Turn Off TP/SL Effect\nTP = 1000%+ for nonlimit TP Length \nSL = 1-100% if 100% Its Mean Liq. Positiontrueboolline 169 line 241
TP [LONG] %Disable = 0 (non limit profit)0floattakeprofit takeprofit_ll line 176 line 180
TP [SHORT] %Disable = 0 (non limit profit)0floattakeprofit takeprofit_ss line 188 line 192
Auto Stop Loss %Disable = 0 (non limit Stop Loss)0floatstoploss line 171 line 174 line 183 line 186
🅾️ CALLBACK Trailing Stop ModeBreakOut Length For Who's Want Fast Trailing But This Low Profit But More Time For TP\nIt's Can Combo With Breakout and 15mfalseboolline 250
1️⃣ Length CallBack5int · min 1 · max 1000upBound downBound
🅾️ BreakOut Trailing CALLBACK [%]Binance Callback = 5%, Now You Can Customize Your Callback ><25float · min 0.01 · max 999.99SL_LongBO SL_ShortBO
INPUT BACKTEST TIME RANGE
StartStart Backtest YYYY/MM/DDtimestamp("01 Jan 1945 00:00 +0000")timeline 205
EndEnd Backtest YYYY/MM/DDtimestamp("01 Jan 2074 23:59 +0000")timeline 205
Bar Paint Color Red/Blue/Yellow/Green
Data ArrayJust Bar Paint Only\nNo Effect For EMA/SMA Lineohlc4sourceAPcdc
SWING SETTING
SWING MODEIf Mode On = Plot Swing High and Swing LowtrueboolTop Levels Bottom Levels Top Levels 2 Bottom Levels 2 plot
Pivot Length Left Hand Side6int · min 1pvthi_ pvtlo_
Pivot Length Right Hand Side6int · min 1pvthi_ pvtlo_ stopLevel Top Levels Bottom Levels
Show Recent Low Stop?trueboolplotStopLevel
TRAILING TP/SL SETTING
TRAILING MODEWhen Candle Price Close > or < Trailing Line\nShould TP or SL by Your PositionfalseboolTrailingTP/SL
BACKGROUND PAINT SETTING
BACKGROUND PAINT MODEJust Fill Background Color and Paint Line Between SpacetrueboolFast MA Middle MA Fast MA
PNL MONITOR SETTING
Monitor Profit&Losstrueboolline 350
Positionbottom_centerstring · options ['top_right','middle_right','bottom_right','top_center','middle_center','bottom_center','middle_left','bottom_left']line 350
sizeautostring · options ['auto','tiny','small','normal']line 350
Color Net (no label in the script)color.bluecolorline 350

What it calculates

  • EMA / SMA / WMA / HMA / RMA / VWMApricestrategy, Fast MA Length (18) · chosen by Fast MA Typeprice1strategy · line 38
  • EMA / SMA / WMA / HMA / RMA / VWMApricestrategy, Middle MA Length (24) · chosen by Middle MA Typeprice2strategy · line 46
  • EMA / SMA / WMA / HMA / RMA / VWMApricestrategy, Slow MA Length (34) · chosen by Slow MA Typeprice3strategy · line 54
  • RSISource Multi MA (close), RSI Length (14)vrsi · line 86
  • Crossovervrsi, RSI OB (70)RSIUP · line 87
  • Crossundervrsi, RSI OS (30)RSIDOWN · line 88
  • EMAclose, MACD Fast (12)MACD · line 97
  • EMAMACD, MACD Length (18)aMACD · line 98
  • Crossoverdelta, 0macdTPl · line 100
  • Crossunderdelta, 0macdTPs · line 101
  • EMAclose, 21surfing_21 · line 107
  • EMAclose, 144diving_144 · line 108
  • EMAclose, 233diving_233 · line 109
  • SMAhigh, 34surfing_h · line 110
  • SMAclose, 34surfing_c · line 111
  • SMAlow, 34surfing_l · line 112
  • Crossoverclose, surfing_21surfingup · line 113
  • Crossunderclose, surfing_21surfingdown · line 114
  • Highesthigh, 1️⃣ Length CallBack (5)upBound · line 135
  • Lowestlow, 1️⃣ Length CallBack (5)downBound · line 136
  • Crossoverprice1strategy, price3strategylongCondition · line 218
  • Crossunderprice1strategy, price3strategyshortCondition · line 222
  • Crossunderprice1strategy, price2strategyStopshortCondition · line 223
  • EMAData Array (ohlc4), 2APcdc · line 267
  • Pivothighhigh, Pivot Length Left Hand Side (6), Pivot Length Right Hand Side (6)pvthi_ · line 299
  • Pivotlowlow, Pivot Length Left Hand Side (6), Pivot Length Right Hand Side (6)pvtlo_ · line 300
  • Valuewhenpvtlo_, low[pvtLenR], 0stopLevel · line 319

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.

The script has 104 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.

Order rules

OrderFires whenBy defaultLine
Open Long longlongConditionOn209
Close LongshortCondition and SMODE == trueOn213
Open Short shortshortCondition and SMODE == falseOn215
Open Long longlongConditionOn220
Close LongStopshortCondition and SMODE == trueOn225
Close LongStopshortCondition and SMODE == falseOn227
Open Short shortshortCondition and SMODE == falseOn229
Exit Exit stop and limitstrategy.position_size > 0On244
Exit Exit stop and limitstrategy.position_size < 0On246
Exit Exit stop and limitstrategy.position_size > 0On249
Close LongSL_LongBO and strategy.position_size > 0On253
Close ShortSL_ShortBO and strategy.position_size < 0On255
Close LongSL_LongBO and strategy.position_size > 0On259

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Does it repaint?

Yes

At least one pattern in the source can repaint; it is marked Check below.

The live replay needs a run, and this script does not run in Zeal Terminal yet; the answer comes from the checks on the source alone.

  • CheckHigher-timeframe data7 request.security call(s) use lookahead_on (line 324, 325, 326, 327, 328, 329, 330). Without a [1] offset this reads future bars in history.
  • 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.

Similar scripts

Indicators and strategies built from the same calculations.

ScriptSharesTypeNetTradesMax drawdown
TICK Scalping strategy, SPY 1 min by PtGamblerrma ema wma sma pivotlow pivothigh rsi lowest highestv5 strategyNo trades on this market
VuManChu Cipher B + Divergences Strategy by nattichai001valuewhen ema lowest highest rsi sma rma wmav4 strategy+76.6%17518.4%
MACD 5 iN 1 [Pro-Tool] by HamidBoxsma ema rsi pivotlow pivothigh highest lowestv4 strategyNo trades on this market
VXD Supercycle by Vvaz_ema sma pivothigh pivotlow valuewhen highest lowest rsiv5 strategydoes not run in Zeal Terminal
Ultra Moving Average Rating Trend Strategy by exlux99ema wma highest lowest sma rma vwma hmav5 strategy+2.8%52.4%

Upgrade and export

Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.

  • 14 settings use the untyped input() (line 26, 31, 34, 36, 63, 83, 84, 85, 94, 95, 96, 115, 266, 297). It still compiles in v6; input.int, input.float or input.source state the type.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

Not verified

The v5 script does not run in Zeal Terminal's engine (Pine Script v5 Error at @L344:C0: no source was supplied for the library 'X4815162342/X48_LibaryStrategyStatus/2'. Libraries cannot be fetched from TradingView; supply the source in the 'libraries' option. No libraries were supplied.), so this step could not be checked.

  • Line 26: input() → input.source()
  • Line 31: input() → input.int()
  • Line 34: input() → input.int()
  • Line 36: input() → input.int()
  • Line 83: input() → input.int()
  • Line 84: input() → input.int()
7 more edits
  • Line 85: input() → input.int()
  • Line 94: input() → input.int()
  • Line 95: input() → input.int()
  • Line 96: input() → input.int()
  • Line 115: input() → input.bool()
  • Line 266: input() → input.source()
  • Line 297: input() → input.bool()
⋯/////////// Normal Setting ////////////////-srcstrategy = input(close, title='Source Multi MA', group = '= Multi MA SETTING =', tooltip = 'Normal Line = Close \nSmooth Line = ohlc4')+srcstrategy = input.source(close, title='Source Multi MA', group = '= Multi MA SETTING =', tooltip = 'Normal Line = Close \nSmooth Line = ohlc4')///////////// EMA/SMA SETTING /////////////⋯slowSW = input.bool(title='Show Slow MA Line', defval=true, group = '= Multi MA SETTING =')-ma1strategy = input(18, title='Fast MA Length', group = '= Multi MA SETTING =')+ma1strategy = input.int(18, title='Fast MA Length', group = '= Multi MA SETTING =')type1strategy = input.string('EMA', 'Fast MA Type', options=['SMA', 'EMA', 'WMA', 'HMA', 'RMA', 'VWMA'], group = '= Multi MA SETTING =', tooltip = 'SMA / EMA / WMA / HMA / RMA / VWMA')MA2_MODE = input.bool(title="MA MIDDLE MODE", defval=false, group = '= MIDDLE 3MA SETTING =', tooltip = 'Strategy Is\nMA Fast > MA Slow = Long\nEMA Fast < MA Mid = Short')-ma2strategy = input(24, title='Middle MA Length', group = '= MIDDLE 3MA SETTING =')+ma2strategy = input.int(24, title='Middle MA Length', group = '= MIDDLE 3MA SETTING =')type2strategy = input.string('EMA', 'Middle MA Type', options=['SMA', 'EMA', 'WMA', 'HMA', 'RMA', 'VWMA'], group = '= MIDDLE 3MA SETTING =', tooltip = 'SMA / EMA / WMA / HMA / RMA / VWMA')-ma3strategy = input(34, title='Slow MA Length', group = '= Multi MA SETTING =')+ma3strategy = input.int(34, title='Slow MA Length', group = '= Multi MA SETTING =')type3strategy = input.string('EMA', 'Slow MA Type', options=['SMA', 'EMA', 'WMA', 'HMA', 'RMA', 'VWMA'], group = '= Multi MA SETTING =', tooltip = 'SMA / EMA / WMA / HMA / RMA / VWMA')⋯//if RSI_MODE == true-RSILength = input(14, title='RSI Length', group = '= RSI SETTING >> PLOT RSI SIGNAL OB OS =')+RSILength = input.int(14, title='RSI Length', group = '= RSI SETTING >> PLOT RSI SIGNAL OB OS =')-OverBought = input(70, title='RSI OB', group = '= RSI SETTING >> PLOT RSI SIGNAL OB OS =', tooltip = 'Lil Cross Symbol')+OverBought = input.int(70, title='RSI OB', group = '= RSI SETTING >> PLOT RSI SIGNAL OB OS =', tooltip = 'Lil Cross Symbol')-OverSold = input(30, title='RSI OS', group = '= RSI SETTING >> PLOT RSI SIGNAL OB OS =', tooltip = 'Lil Diamond Symbol')+OverSold = input.int(30, title='RSI OS', group = '= RSI SETTING >> PLOT RSI SIGNAL OB OS =', tooltip = 'Lil Diamond Symbol')vrsi = ta.rsi(srcstrategy, RSILength)⋯//if MACD_MODE_SIG == true-MACDfastLength = input(12, title='MACD Fast', group = '= MACD SETTING =')+MACDfastLength = input.int(12, title='MACD Fast', group = '= MACD SETTING =')-MACDslowlength = input(26, title='MACD Slow', group = '= MACD SETTING =')+MACDslowlength = input.int(26, title='MACD Slow', group = '= MACD SETTING =')-MACDLength = input(18, title='MACD Length', group = '= MACD SETTING =')+MACDLength = input.int(18, title='MACD Length', group = '= MACD SETTING =')MACD = ta.ema(close, MACDfastLength) - ta.ema(close, MACDslowlength)⋯surfingdown = ta.crossunder(close,surfing_21)-showSurf = input(false, title='Show Surfing & Diving Signal', group = '= SURF&DIVING SETTING =', tooltip = 'Plot Symbol of Lil Trend By Surfing Man')+showSurf = input.bool(false, title='Show Surfing & Diving Signal', group = '= SURF&DIVING SETTING =', tooltip = 'Plot Symbol of Lil Trend By Surfing Man')plotshowSurf = SURF_DIVE_MODE == true ? showSurf : na⋯////////////////////////////////////////////////////////////////////////////////////////////////////////////////-srccdc = input(title='Data Array', defval=ohlc4, group="Bar Paint Color Red/Blue/Yellow/Green", tooltip = 'Just Bar Paint Only\nNo Effect For EMA/SMA Line')+srccdc = input.source(title='Data Array', defval=ohlc4, group="Bar Paint Color Red/Blue/Yellow/Green", tooltip = 'Just Bar Paint Only\nNo Effect For EMA/SMA Line')APcdc = ta.ema(srccdc, 2)⋯pvtLenR = input.int(6, minval=1, title='Pivot Length Right Hand Side', group = '= SWING SETTING =')-showStop = input(true, title='Show Recent Low Stop?', group = '= SWING SETTING =')+showStop = input.bool(true, title='Show Recent Low Stop?', group = '= SWING SETTING =')// Get High and Low Pivot Points⋯

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 @L344:C0: no source was supplied for the library 'X4815162342/X48_LibaryStrategyStatus/2'. Libraries cannot be fetched from TradingView; supply the source in the 'libraries' option. No libraries were supplied.), 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.

⋯// if you wanna try my bot auto trade X48-3in1-bot : Contact My Line ID : x4815x-//@version=5+//@version=6strategy('X48 - Strategy | MA Multi Type Cross + TPSL + Swing + Surfing&Diving| Future&Spot | V.3.6', overlay=true, default_qty_type=strategy.cash, default_qty_value=20, initial_capital=200, currency=currency.USD, commission_value=0.1, slippage = 0)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2No It imports the library X4815162342/X48_LibaryStrategyStatus/2, whose source is not available here, so it does not run hereNot measured
PineTSNot testedNot testedNot measured

Zeal Terminal's engine currently merges fill() calls that share a title, so it would draw 1 of this script's 2 fills; this page gives each call its own title to draw all of them.

“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.

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/// © X4815162342// Thank You For Open Source Code, This Strategy Ref. By 1.Simple Strategy Like MA Crossover For Long/Short or Spot Trade, 2. CDC Action Zone V.2 for BarPaint// This Strategy Mixing With MA Crossover Strategy and BarPaint By CDC Action Zone and TP/SL by Varbara// and Thanks For Original Source Swing H/L by @millerrh// How To Use Strategy : Setting EMA/SMA Crossover EMA/SMA, Any Value If You Want// For Long Position : Cross Up// For Short Position : Cross Down// Can Use With Spot Trade : Cross Up = Buy, Cross Down = Sell// In Setting// Intitial Capital = Ex. 200// Order Size = Should Be Money Management Not Use 100% of Capital Ex. 10% of Capital (200$) = Order Size 20$// StopLoss and Take Profit = If You Run Trend TF 4H+ or 1D+ You Can Change TP% = 1,000% for nonlimit and Stop Loss 5 - 20% from your order size//  Ex. Stoploss 15% = OrderSize / 100 x %SL = 20$/100 x 15% = 3$ Loss from order size 20$ (if you not set stop loss.)// Base Currency = (Your Currency) # Ex. USD// Commission = (Your Trading Fee) # Ex. Future Fee Can Check At Binance Fee Rate > https://www.binance.com/en/fee/schedule > Choose Your Fee Type, Ex. USD M Future (Regular User) = 0.02 (Maker), 0.04 (Taker)// Commission Symbol Type = %     # (Ref. By Binance Fee Rate)// Default Setting It's Realistic From Normal Life Ex. Capital 200$ / Ordersize 20$ (10%)/ Commission 0.1% (Buy+Sell) / Slippage = 2 / TP = 1000% (nonlimit) / SL = 15%/OrderSize// Low Risk But High Return, Good Luck// if you wanna try my bot auto trade X48-3in1-bot : Contact My Line ID : x4815x//@version=5strategy('X48 - Strategy | MA Multi Type Cross + TPSL + Swing + Surfing&Diving| Future&Spot | V.3.6', overlay=true, default_qty_type=strategy.cash, default_qty_value=20, initial_capital=200, currency=currency.USD, commission_value=0.1, slippage = 0)// 📌📌 Spot Mode 📌📌SMODE = input.bool(title="SPOT MODE", defval=false, group = '= SPOT SETTING =', tooltip = 'SPOT = Disable Short Position')/////////// Normal Setting ////////////////srcstrategy = input(close, title='Source Multi MA', group = '= Multi MA SETTING =', tooltip = 'Normal Line = Close \nSmooth Line = ohlc4')///////////// EMA/SMA SETTING /////////////pricestrategy = request.security(syminfo.tickerid, timeframe.period, srcstrategy)fastSW = input.bool(title='Show Fast MA Line', defval=true, group = '= Multi MA SETTING =')slowSW = input.bool(title='Show Slow MA Line', defval=true, group = '= Multi MA SETTING =')ma1strategy = input(18, title='Fast MA Length', group = '= Multi MA SETTING =')type1strategy = input.string('EMA', 'Fast MA Type', options=['SMA', 'EMA', 'WMA', 'HMA', 'RMA', 'VWMA'], group = '= Multi MA SETTING =', tooltip = 'SMA / EMA / WMA / HMA / RMA / VWMA')MA2_MODE = input.bool(title="MA MIDDLE MODE", defval=false, group = '= MIDDLE 3MA SETTING =', tooltip = 'Strategy Is\nMA Fast > MA Slow = Long\nEMA Fast < MA Mid = Short')ma2strategy = input(24, title='Middle MA Length', group = '= MIDDLE 3MA SETTING =')type2strategy = input.string('EMA', 'Middle MA Type', options=['SMA', 'EMA', 'WMA', 'HMA', 'RMA', 'VWMA'], group = '= MIDDLE 3MA SETTING =', tooltip = 'SMA / EMA / WMA / HMA / RMA / VWMA')ma3strategy = input(34, title='Slow MA Length', group = '= Multi MA SETTING =')type3strategy = input.string('EMA', 'Slow MA Type', options=['SMA', 'EMA', 'WMA', 'HMA', 'RMA', 'VWMA'], group = '= Multi MA SETTING =', tooltip = 'SMA / EMA / WMA / HMA / RMA / VWMA')price1strategy = switch type1strategy    "EMA" => ta.ema(pricestrategy, ma1strategy)    "SMA" => ta.sma(pricestrategy, ma1strategy)    "WMA" => ta.wma(pricestrategy, ma1strategy)    "HMA" => ta.hma(pricestrategy, ma1strategy)    "RMA" => ta.rma(pricestrategy, ma1strategy)    "VWMA" => ta.vwma(pricestrategy, ma1strategy)    price2strategy = switch type2strategy    "EMA" => ta.ema(pricestrategy, ma2strategy)    "SMA" => ta.sma(pricestrategy, ma2strategy)    "WMA" => ta.wma(pricestrategy, ma2strategy)    "HMA" => ta.hma(pricestrategy, ma2strategy)    "RMA" => ta.rma(pricestrategy, ma2strategy)    "VWMA" => ta.vwma(pricestrategy, ma2strategy)    price3strategy = switch type3strategy    "EMA" => ta.ema(pricestrategy, ma3strategy)    "SMA" => ta.sma(pricestrategy, ma3strategy)    "WMA" => ta.wma(pricestrategy, ma3strategy)    "HMA" => ta.hma(pricestrategy, ma3strategy)    "RMA" => ta.rma(pricestrategy, ma3strategy)    "VWMA" => ta.vwma(pricestrategy, ma3strategy)/////////////////////////////////////////////////////////////////////////////////////////////////////Text_Alert_Future = '{{strategy.order.alert_message}}'copy_Fu = input( defval= Text_Alert_Future ,    title="Alert Message for BOT", inline = '00'  ,group = '═ Bot Setting ═ \n >> If You Dont Use Bot Just Pass It' ,tooltip = 'Alert For X48-BOT > Copy and Paste To Alert Function')passphrase = input.string(defval='1234', title ='Bot Pass',group='═ Bot Setting ═ \n >> If You Dont Use Bot Just Pass It', tooltip = 'Passphrase Must Be Same as X48-BOT')leveragex  = input.int(125,title='leverage',group='═ Bot Setting ═ \n >> If You Dont Use Bot Just Pass It',tooltip='"NOTHING" to do with Position size For Command To X48-BOT Only',minval=1)longcommand = input.string(defval='AutoLong', title = 'Bot Long Command',group='═ Bot Setting ═ \n >> If You Dont Use Bot Just Pass It', tooltip = '1.OpenLong\n2.AutoLong\n***If AutoLong = Close(100%) First > Open Long Position Auto')shortcommand = input.string(defval='AutoShort', title = 'Bot Short Command',group='═ Bot Setting ═ \n >> If You Dont Use Bot Just Pass It', tooltip = '1.OpenShort\n2.AutoShort\n***If AutoShort = Close(100%) First > Open Short Position Auto')markettype = input.string(defval='bnfuture', title = 'Future/Spot Command',group='═ Bot Setting ═ \n >> If You Dont Use Bot Just Pass It', tooltip = '1. bnfuture = FUTURE MODE\n2. bnspot = SPOT MODE\n 3.bncombo = EZ 2in1 Order')//////////////// Strategy Alert For X4815162342 BOT ////////////////////////////// For Use Bot Can Change This Command By Your Self /////////////////////string Alert_OpenLong       = '{"ex":"'+markettype+'","side": "'+longcommand+'", "amount": "@{{strategy.order.contracts}}", "symbol": "{{ticker}}", "passphrase": "'+passphrase+'","leverage":"'+str.tostring(leveragex)+'"}'string Alert_OpenShort      = '{"ex":"'+markettype+'","side": "'+shortcommand+'", "amount": "@{{strategy.order.contracts}}", "symbol": "{{ticker}}", "passphrase": "'+passphrase+'","leverage":"'+str.tostring(leveragex)+'"}'//string Alert_LongTP         = '{"ex":"bnfuture","side": "CloseLong", "amount": "@{{strategy.order.contracts}}", "symbol": "{{ticker}}", "passphrase": "'+passphrase+'","leverage":"'+str.tostring(leveragex)+'"}'//string Alert_ShortTP        = '{"ex":"bnfuture","side": "CloseShort", "amount": "@{{strategy.order.contracts}}", "symbol": "{{ticker}}", "passphrase": "'+passphrase+'","leverage":"'+str.tostring(leveragex)+'"}'//var message_closelong       = '{"ex":"bnfuture","side": "CloseLong", "amount": "%100", "symbol": "{{ticker}}", "passphrase": "'+passphrase+'","leverage":"'+str.tostring(leveragex)+'"}'//var message_closeshort      = '{"ex":"bnfuture","side": "CloseShort", "amount": "%100", "symbol": "{{ticker}}", "passphrase": "'+passphrase+'","leverage":"'+str.tostring(leveragex)+'"}'string Alert_StopLosslong   = '{"ex":"'+markettype+'","side": "CloseLong", "amount": "%100", "symbol": "{{ticker}}", "passphrase": "'+passphrase+'","leverage":"'+str.tostring(leveragex)+'"}'string Alert_StopLossshort  = '{"ex":"'+markettype+'","side": "CloseShort", "amount": "%100", "symbol": "{{ticker}}", "passphrase": "'+passphrase+'","leverage":"'+str.tostring(leveragex)+'"}'///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////  RSI_MODE = input.bool(title="RSI MODE", defval=false, group = '= RSI SETTING >> COMFIRM RSI BEFORE OPEN POSITION =', tooltip = 'If Mode On = Use RSI Strategy With Long and Short\n >> RSI Confirm Before Open Position')//if RSI_MODE == trueRSILength = input(14, title='RSI Length', group = '= RSI SETTING >> PLOT RSI SIGNAL OB OS =')OverBought = input(70, title='RSI OB', group = '= RSI SETTING >> PLOT RSI SIGNAL OB OS =', tooltip = 'Lil Cross Symbol')OverSold = input(30, title='RSI OS', group = '= RSI SETTING >> PLOT RSI SIGNAL OB OS =', tooltip = 'Lil Diamond Symbol')vrsi = ta.rsi(srcstrategy, RSILength)RSIUP = ta.crossover(vrsi, OverBought)RSIDOWN = ta.crossunder(vrsi, OverSold)plotshape(RSI_MODE ? RSIUP : na, title='RSIUP', text = '⏰', color=color.new(color.yellow, 100), style=shape.circle, location=location.belowbar, size=size.tiny)  //plot for buy iconplotshape(RSI_MODE ? RSIDOWN : na, title='RSIDOWN', text = '☀️', color=color.new(color.red, 100), style=shape.circle, location=location.abovebar, size=size.tiny)  //plot for buy icon////////////////////////////////////////////////////////////////////////////////////////////////////////////////  MACD_MODE_SIG= input.bool(title="MACD MODE = MACD Cross Signal", defval=false, group = '= MACD SETTING =', tooltip = 'If Mode On = Use MACD Strategy for Signal When Cross Up and Cross Down')//if MACD_MODE_SIG == trueMACDfastLength = input(12, title='MACD Fast', group = '= MACD SETTING =')MACDslowlength = input(26, title='MACD Slow', group = '= MACD SETTING =')MACDLength = input(18, title='MACD Length', group = '= MACD SETTING =')MACD = ta.ema(close, MACDfastLength) - ta.ema(close, MACDslowlength)aMACD = ta.ema(MACD, MACDLength)delta = MACD - aMACDmacdTPl = (ta.crossover(delta, 0))macdTPs = (ta.crossunder(delta, 0))plotshape(MACD_MODE_SIG ? macdTPl : na, title='macdTPl', text = '💎', color=color.new(color.yellow, 100), style=shape.circle, location=location.belowbar, size=size.tiny)  //plot for buy iconplotshape(MACD_MODE_SIG ? macdTPs : na, title='macdTPs', text = '💎', color=color.new(color.red, 100), style=shape.circle, location=location.abovebar, size=size.tiny)  //plot for buy icon///////////////////////////////////////////////////////////////////////////////////////////////////////// Surfing and Diving /////////////SURF_DIVE_MODE = input.bool(title="SURFING&DIVING MODE", defval=false, group = '= SURF&DIVING SETTING =', tooltip = 'How To Use\n3 Dot Waves CrossUp Purple Line = Bullish Trend\n3 Dot Waves CrossDown Purple Line = Bearish Trend\n\nBig Blue Dot is Surfing Zone\nCandle Price Close > Surfing Zone = Lil Bullish\nCandle Price Clsoe < Surfing Zone = Lil Bearish')surfing_21 = ta.ema(close,21)diving_144 = ta.ema(close,144)diving_233 = ta.ema(close,233)surfing_h = ta.sma(high,34)surfing_c = ta.sma(close,34)surfing_l = ta.sma(low,34)surfingup = ta.crossover(close,surfing_21)surfingdown = ta.crossunder(close,surfing_21)showSurf = input(false, title='Show Surfing & Diving Signal', group = '= SURF&DIVING SETTING =', tooltip = 'Plot Symbol of Lil Trend By Surfing Man')plotshowSurf = SURF_DIVE_MODE == true ? showSurf : naplotshape(showSurf ? surfingup : na,'SurfingUp',location = location.belowbar,text = '🏄‍♂️')plotshape(showSurf ? surfingdown : na,'SurfingDown',location = location.abovebar,text = '🏄')plot(SURF_DIVE_MODE ? surfing_21 : na, 'surfing_21', color=color.new(#6EB0FF,20), linewidth = 1, style=plot.style_stepline_diamond)plot(SURF_DIVE_MODE ? surfing_h : na, 'surfing_h', color=color.aqua, linewidth = 1, style=plot.style_circles)plot(SURF_DIVE_MODE ? surfing_c : na, 'surfing_c', color=color.silver, linewidth = 1, style=plot.style_circles)plot(SURF_DIVE_MODE ? surfing_l : na, 'surfing_l', color=color.blue, linewidth = 1, style=plot.style_circles)plot(SURF_DIVE_MODE ? diving_144 : na, 'diving_144', color=color.purple, linewidth = 2, style=plot.style_line)plot(SURF_DIVE_MODE ? diving_233 : na, 'diving_233', color=#FF00FF, linewidth = 2, style=plot.style_line)///////////// Take Profit and Stop Loss Setting ////////////////////tpsl(percent) =>    strategy.position_avg_price * percent / 100 / syminfo.mintickmode = input.bool(title="Mode AUTO TP/SL", defval=true, group="= AUTO TP/SL =", tooltip = 'If Mode On = Use TP/SL\nIf Mode Off = Turn Off TP/SL Effect\nTP = 1000%+ for nonlimit TP Length \nSL = 1-100% if 100% Its Mean Liq. Position')tp_l = tpsl(input.float(0, title='TP [LONG] %', group="= AUTO TP/SL =", tooltip = 'Disable = 0 (non limit profit)'))tp_s = tpsl(input.float(0, title='TP [SHORT] %', group="= AUTO TP/SL =", tooltip = 'Disable = 0 (non limit profit)'))sl = tpsl(input.float(0, title='Auto Stop Loss %', group="= AUTO TP/SL =", tooltip = 'Disable = 0 (non limit Stop Loss)'))BOTrail_MODE = input.bool(defval = false, title = "🅾️ CALLBACK Trailing Stop Mode", group = "= AUTO TP/SL =", tooltip = "BreakOut Length For Who's Want Fast Trailing But This Low Profit But More Time For TP\nIt's Can Combo With Breakout and 15m")lengthBO = input.int(title="1️⃣ Length CallBack", minval=1, maxval=1000, defval=5, group = "= AUTO TP/SL =")triling_BO = input.float(title = "🅾️ BreakOut Trailing CALLBACK [%]", defval = 25, minval = 0.01, maxval = 999.99, group = "= AUTO TP/SL =", tooltip = "Binance Callback = 5%, Now You Can Customize Your Callback ><")upBound = ta.highest(high, lengthBO)downBound = ta.lowest(low, lengthBO)SL_LongBO = (close < (upBound-((upBound*triling_BO)/100)))SL_ShortBO = (close > (downBound+((downBound*triling_BO)/100)))calcStopLossPrice(OffsetPts) =>    if strategy.position_size > 0        strategy.position_avg_price - OffsetPts * syminfo.mintick    else if strategy.position_size < 0        strategy.position_avg_price + OffsetPts * syminfo.mintick    else        nacalcStopLossL_AlertPrice(OffsetPts) =>    strategy.position_avg_price - OffsetPts * syminfo.mintickcalcStopLossS_AlertPrice(OffsetPts) =>    strategy.position_avg_price + OffsetPts * syminfo.mintickcalcTakeProfitPrice(OffsetPts) =>    if strategy.position_size > 0        strategy.position_avg_price + OffsetPts * syminfo.mintick    else if strategy.position_size < 0        strategy.position_avg_price - OffsetPts * syminfo.mintick    else        nacalcTakeProfitL_AlertPrice(OffsetPts) =>    strategy.position_avg_price + OffsetPts * syminfo.mintickcalcTakeProfitS_AlertPrice(OffsetPts) =>    strategy.position_avg_price - OffsetPts * syminfo.mintickvar stoploss = 0.var stoploss_l = 0.var stoploss_s = 0.var takeprofit = 0.var takeprofit_l = 0.var takeprofit_s = 0.var takeprofit_ll = 0.var takeprofit_ss = 0.if mode == true    if (strategy.position_size > 0)        if sl > 0            stoploss := calcStopLossPrice(sl)            stoploss_l := stoploss        else if sl <= 0            stoploss := na        if tp_l > 0            takeprofit := tp_l            takeprofit_ll := close + ((close/100)*tp_l)            //takeprofit_s := na        else if tp_l <= 0            takeprofit := na    if (strategy.position_size < 0)        if sl > 0            stoploss := calcStopLossPrice(sl)            stoploss_s := stoploss        else if sl <= 0            stoploss := na        if tp_s > 0            takeprofit := tp_s            takeprofit_ss := close - ((close/100)*tp_s)            //takeprofit_l := na        else if tp_s <= 0            takeprofit := na    else if strategy.position_size == 0        stoploss := na        takeprofit := na        //takeprofit_l := calcTakeProfitL_AlertPrice(tp_l)        //takeprofit_s := calcTakeProfitS_AlertPrice(tp_s)        //stoploss_l := calcStopLossL_AlertPrice(sl)        //stoploss_s := calcStopLossS_AlertPrice(sl)//////////// INPUT BACKTEST RANGE ////////////////////////////////////////////////////var string BTR1         = '════════ INPUT BACKTEST TIME RANGE ════════'i_startTime             = input.time(defval = timestamp("01 Jan 1945 00:00 +0000"), title = "Start", inline="timestart", group=BTR1, tooltip = 'Start Backtest YYYY/MM/DD')i_endTime               = input.time(defval = timestamp("01 Jan 2074 23:59 +0000"), title = "End", inline="timeend", group=BTR1, tooltip = 'End Backtest YYYY/MM/DD')if time >= i_startTime and time <= i_endTime    if MA2_MODE == false        longCondition = ta.crossover(price1strategy, price3strategy)        if longCondition            strategy.entry('Long', strategy.long, alert_message = Alert_OpenLong, comment = "🌙")                shortCondition = ta.crossunder(price1strategy, price3strategy)        if shortCondition and SMODE == true            strategy.close('Long', qty_percent = 100, comment = '🎃')        if shortCondition and SMODE == false            strategy.entry('Short', strategy.short, alert_message = Alert_OpenShort, comment = "👻")        if MA2_MODE == true        longCondition = ta.crossover(price1strategy, price3strategy)        if longCondition            strategy.entry('Long', strategy.long, alert_message = Alert_OpenLong, comment = "🌙")                shortCondition = ta.crossunder(price1strategy, price3strategy)        StopshortCondition = ta.crossunder(price1strategy, price2strategy)        if StopshortCondition and SMODE == true            strategy.close('Long', qty_percent = 100, comment = '🎃')        if StopshortCondition and SMODE == false            strategy.close('Long', qty_percent = 100, comment = '🎃')        if shortCondition and SMODE == false            strategy.entry('Short', strategy.short, alert_message = Alert_OpenShort, comment = "👻")////////////////// Strategy Take Profit and Stop Loss Label Here ///////////////////    //if mode == true    //    if (strategy.position_size > 0)    //        stoploss := calcStopLossPrice(sl)    //        takeprofit := tp_l    //    if (strategy.position_size < 0)    //        stoploss := calcStopLossPrice(sl)    //        takeprofit := tp_s    //    else if strategy.position_size == 0    //        stoploss := na    //        takeprofit := naif mode == true    if SMODE == false        if strategy.position_size > 0            strategy.exit("Exit",'Long', qty_percent = 100 , profit = takeprofit, stop = stoploss, comment_profit = "TP💚L", comment_loss = "SL💚L", alert_message = Alert_StopLosslong)        if strategy.position_size < 0            strategy.exit("Exit",'Short', qty_percent = 100, profit = takeprofit, stop = stoploss, comment_profit = "TP❤️️S", comment_loss = "SL❤️️S", alert_message = Alert_StopLossshort)    else if SMODE == true        if strategy.position_size > 0            strategy.exit("Exit",'Long', qty_percent = 100 , profit = takeprofit, stop = stoploss, comment_profit = "TP💚L", comment_loss = "SL💚L", alert_message = Alert_StopLosslong)if BOTrail_MODE == true    if SMODE == false        if SL_LongBO and strategy.position_size > 0            strategy.close("Long", qty_percent = 100, comment = "❇️CALLBACK❇️", alert_message = Alert_StopLosslong)        if SL_ShortBO and strategy.position_size < 0            strategy.close("Short", qty_percent = 100, comment = "❇️CALLBACK❇️", alert_message = Alert_StopLossshort)        else if SMODE == true        if SL_LongBO and strategy.position_size > 0            strategy.close("Long", qty_percent = 100, comment = "❇️CALLBACK❇️", alert_message = Alert_StopLosslong)        //if strategy.position_size > 0        //    strategy.exit("Exit",'Long', profit = takeprofit, when = stoploss, alert_message = Alert_StopLosslong)        //  strategy.exit("Exit",'Long', profit = takeprofit, stop = stoploss, alert_message = Alert_StopLosslong)        //if strategy.position_size < 0        //    strategy.exit("Exit",'Short', profit = takeprofit, stop = stoploss, alert_message = Alert_StopLossshort)////////////////////////////////////////////////////////////////////////////////////////////////////////////////srccdc = input(title='Data Array', defval=ohlc4, group="Bar Paint Color Red/Blue/Yellow/Green", tooltip = 'Just Bar Paint Only\nNo Effect For EMA/SMA Line')APcdc = ta.ema(srccdc, 2)//////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ************** BarPaint ***********Bullish = price1strategy > price3strategyBearish = price1strategy < price3strategyGreen = Bullish and APcdc > price1strategyRed = Bearish and APcdc < price1strategyYellow = Bullish and APcdc < price1strategyBlue = Bearish and APcdc > price1strategyBuycdc = Bullish and Bearish[1]Sellcdc = Bearish and Bullish[1]//Plotbcolor = Green ? color.lime : Red ? color.red : Yellow ? color.yellow : Blue ? color.blue : color.whitebarcolor(color=bcolor)//plot(series=price1strategy, style=plot.style_line, title='1st MA', color=color.new(color.yellow, 0), linewidth=2)//plot(series=price2strategy, style=plot.style_line, title='2nd MA', color=color.new(color.blue, 0), linewidth=1)//plot(series=price3strategy, style=plot.style_line, title='3rd MA', color=color.new(color.red, 0), linewidth=2)FastL = plot(fastSW ? price1strategy : na, 'Fast MA', color=color.new(color.red, 0), style = plot.style_line, linewidth=2)MidL = plot(MA2_MODE ? price2strategy : na, 'Middle MA', color=color.new(color.blue, 0), style = plot.style_line, linewidth=2)SlowL = plot(slowSW ? price3strategy : na, 'Slow MA', color=color.new(color.yellow, 0), style = plot.style_line, linewidth=2)fillcolor = Bullish ? color.new(color.green,90) : Bearish ? color.new(color.red,90) : color.new(color.black,90) // fillcolor = Bullish ? color.green : Bearish ? color.red : color.black//fill(FastL, MidL, SlowL, fillcolor) // fill(price1strategy, price2strategy, price3strategy, fillcolor, transp=90)//longCondition2 = ta.crossover(price1strategy, price3strategy)//shortCondition2 = ta.crossunder(price1strategy, price2strategy)//plotshape(longCondition, title='buytag', text='🌙', color=color.new(color.green, 0), style=shape.labelup, location=location.belowbar, size=size.large, textcolor=color.new(color.white, 0))  //plot for buy icon//plotshape(shortCondition, title='selltag', text='👻', color=color.new(color.red, 0), style=shape.labeldown, location=location.abovebar, size=size.large, textcolor=color.new(color.white, 0))  //plot for sell icon// Swing PlotSwing_MODE = input.bool(title="SWING MODE", defval=true, group = '= SWING SETTING =', tooltip = 'If Mode On = Plot Swing High and Swing Low')pvtLenL = input.int(6, minval=1, title='Pivot Length Left Hand Side', group = '= SWING SETTING =')pvtLenR = input.int(6, minval=1, title='Pivot Length Right Hand Side', group = '= SWING SETTING =')showStop = input(true, title='Show Recent Low Stop?', group = '= SWING SETTING =')// Get High and Low Pivot Pointspvthi_ = ta.pivothigh(high, pvtLenL, pvtLenR)pvtlo_ = ta.pivotlow(low, pvtLenL, pvtLenR)// Force Pivot completion before plotting.Shunt = 1  //Wait for close before printing pivot? 1 for true 0 for flasemaxLvlLen = 0  //Maximum Extension Lengthpvthi = pvthi_[Shunt]pvtlo = pvtlo_[Shunt]// Count How many candles for current Pivot Level, If new reset.counthi = ta.barssince(not na(pvthi))countlo = ta.barssince(not na(pvtlo))pvthis = fixnan(pvthi)pvtlos = fixnan(pvtlo)hipc = ta.change(pvthis) != 0 ? na : color.maroonlopc = ta.change(pvtlos) != 0 ? na : color.green// Display Pivot linesplot(Swing_MODE ? maxLvlLen == 0 or counthi < maxLvlLen ? pvthis : na : na, color=hipc, linewidth=1, offset=-pvtLenR - Shunt, title='Top Levels')plot(Swing_MODE ? maxLvlLen == 0 or countlo < maxLvlLen ? pvtlos : na : na, color=lopc, linewidth=1, offset=-pvtLenR - Shunt, title='Bottom Levels')plot(Swing_MODE ? maxLvlLen == 0 or counthi < maxLvlLen ? pvthis : na : na, color=hipc, linewidth=1, offset=0, title='Top Levels 2')plot(Swing_MODE ? maxLvlLen == 0 or countlo < maxLvlLen ? pvtlos : na : na, color=lopc, linewidth=1, offset=0, title='Bottom Levels 2')// Stop LevelsstopLevel = ta.valuewhen(pvtlo_, low[pvtLenR], 0)plotStopLevel = showStop == true ? stopLevel : naplot(Swing_MODE  ? plotStopLevel : na, style=plot.style_linebr, color=color.new(color.orange, 50), show_last=1, linewidth=2, trackprice=true)//******************************************TRAILING_MODE = input.bool(title="TRAILING MODE", defval=false, group = '= TRAILING TP/SL SETTING =', tooltip = 'When Candle Price Close > or < Trailing Line\nShould TP or SL by Your Position')c480=request.security(syminfo.tickerid, "M", close, barmerge.gaps_off, barmerge.lookahead_on)c4801=request.security(syminfo.tickerid, "M", close[1], barmerge.gaps_off, barmerge.lookahead_on)c4802=request.security(syminfo.tickerid, "M", close[2], barmerge.gaps_off, barmerge.lookahead_on)c4803=request.security(syminfo.tickerid, "M", close[3], barmerge.gaps_off, barmerge.lookahead_on)c4804=request.security(syminfo.tickerid, "M", close[4], barmerge.gaps_off, barmerge.lookahead_on)c4805=request.security(syminfo.tickerid, "M", close[5], barmerge.gaps_off, barmerge.lookahead_on)h480=request.security(syminfo.tickerid, "480", high, barmerge.gaps_off, barmerge.lookahead_on)mc=(c480+c4801+c4802+c4803+c4804)/5plot(TRAILING_MODE ? mc : na, 'TrailingTP/SL', color=color.new(color.lime,0), style=plot.style_stepline, linewidth=2)//********* Background Paint ***********************BG_MODE = input.bool(title="BACKGROUND PAINT MODE", defval=true, group = '= BACKGROUND PAINT SETTING =', tooltip = 'Just Fill Background Color and Paint Line Between Space')prefillFast = plot(BG_MODE ? price1strategy : na, 'Fast MA', color=color.new(color.red, 100), style = plot.style_line, linewidth=2)prefillMid = plot(MA2_MODE ? BG_MODE ? price2strategy : na : na, 'Middle MA', color=color.new(color.blue, 100), style = plot.style_line, linewidth=2)prefillSlow = plot(BG_MODE ? price3strategy : na, 'Fast MA', color=color.new(color.yellow, 100), style = plot.style_line, linewidth=2)fcolor = price1strategy > price3strategy ? color.new(color.lime,70) : color.new(color.blue,70)fcolor2 = price1strategy > price2strategy ? color.new(color.lime,70) : color.new(color.red,70)fill(prefillFast,prefillSlow, color=fcolor, title='BACKGROUND PAINT')fill(prefillFast,prefillMid, color=fcolor2, title='BACKGROUND PAINT')// **********************************************//เรียกใช้  libraryimport X4815162342/X48_LibaryStrategyStatus/2 as fuLi //แสดงผล Backtestshow_Net = input.bool(true,'Monitor Profit&Loss', inline = 'Lnet', group = '= PNL MONITOR SETTING =')position_ = input.string('bottom_center','Position', options = ['top_right','middle_right','bottom_right','top_center','middle_center','bottom_center','middle_left','bottom_left'] , inline = 'Lnet')size_i = input.string('auto','size', options = ['auto','tiny','small','normal'] , inline = 'Lnet') color_Net = input.color(color.blue,"" , inline = 'Lnet')fuLi.NetProfit_Show(show_Net , position_ , size_i,  color_Net )