Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

3LS - 3 Line Strike Strategy [Kintsugi Trading]

A Pine Script v5 strategy built on SMA (volume, 30) and ATR (14). It has 6 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays no commission. 34 settings; defaults include Stop Loss Strategy Fix PIP Size, ATR Period 14 and ATR Multiplier 2.0.

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 3LS - 3 Line Strike Strategy [Kintsugi Trading] repaint?
Yes
At least one pattern in the source can repaint: intrabar recalculation.
How did 3LS - 3 Line Strike Strategy [Kintsugi Trading] do on BTCUSDT 1D with default settings?
−2.04%
From 26 Jan 2024 to 21 Oct 2026, over 3 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
What alerts does 3LS - 3 Line Strike Strategy [Kintsugi Trading] have?
4
"e=" + broker + " b=long q=" + str.tostring(tradePositionSize) + " s=" + pair + " t=" + (av_limitOrder ? "stop fp=" + str.tostring(close) : "market") + " fsl=" + str.tostring(longStop) + setTp; alertString; "e=" + broker + " b=short q=" + str.tostring(tradePositionSize) + " s=" + pair + " t=" + (av_limitOrder ? "stop fp=" + str.tostring(close) : "market") + " fsl=" + str.tostring(shortStop) + setTp; alertString.
Does 3LS - 3 Line Strike Strategy [Kintsugi Trading] run in Pine Script v6?
Yes
Same 3 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. The v6 script can be downloaded below.
Does 3LS - 3 Line Strike Strategy [Kintsugi Trading] use a stop loss?
Yes
strategy.exit sets a stop on line 186, 193, 213, 244.

BTCUSDT · 1D · default settings

  • VSA Status
  • VSA Label
  • 3 Line Strike Up
  • 3 Line Strike Down
  • MA Fast
  • MA Slow
  • Long Entry Price
  • Long TP Price
  • Long Stop Price
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct$9,796$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. The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market. The live re-run is not offered here: the script requests AUDUSD D, which this page cannot load in your browser.

Needs AUDUSD D data, not available: AUDUSD is not on Binance Values that depend on it are empty on this chart.

Net profit
−2.04%
−$203.92
Buy and hold
+102.5%
same period
Closed trades
3
1 won · 2 lost
Profitable
33.3%
of closed trades
Profit factor
0.49
gross profit ÷ gross loss
Max drawdown
2.24%
−$224.39

One run with the author's default settings, $10,000 starting capital, commission as the script sets it. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.

Review

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

  • Likely bug

    ta.atr(14) ignores the settings line 132

    Line 132 hard-codes 14 where line 150 uses “ATR Period”. Changing those settings moves one band but not this one.

    ta.atr(14)ta.atr(atrPeriod)
  • 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.

Settings

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

SettingDefaultType and rangeFeeds
Risk Management
Show Risk/Reward AreatrueboolLong Entry Price Long TP Price Long Stop Price Short Entry Price Short TP Price Short Stop Price
Enter Long Positiontrueboolentry Long line 197
Enter Short Positiontrueboolentry Short line 229
Stop Loss StrategyFix PIP Sizestring · options ["ATR Trail","ATR Trail-Stop","Fix PIP Size"]longStop longTp shortStop shortTp exit Long Exit exit Short Exit exit Long Exit exit Short Exit line 180 line 187 line 212 line 243
ATR PeriodUses on ATR Trail-stop14intatrValue
ATR MultiplierUses on ATR Trail-stop2.0float · step 0.1longStop shortStop tempStop
Risk/Reward Ratio1.0float · min 0.1 · step 0.1longTp shortTp
Additional Stop PIP Size3intlongStop shortStop
Session
Session Filter Active?falseboolsessionFilterResult Trade Session
Timezone: e.g. \'America/New_York\', \'Asia/Tokyo\', \'GMT-4\', \'GMT+9\'...GMTstringin_session_one
Trade Session: 0900-1600sessionin_session_one
MA
MA Cloud Filltrueboolfill
MA Period Fast21intmaValue1
MA Period Slow55intmaValue2
VSA
Show VSA Status?trueboolVSA Status VSA Label
Moving Average30int · min 1ma0
MA-1 Multiplier0.5float · step 0.1ma1
MA-2 Multiplier1.5float · step 0.1ma2
MA-3 Multiplier3.0float · step 0.1ma3
3 Line Strike
Show Bearish KT Signaltruebool3 Line Strike Down
Show Bullish KT Signaltruebool3 Line Strike Up
Risk Calculation
Use Custom Risktrueboolline 166
% Risk Per TradeThis value used only for backtest results not for auto trading.2.0float · min 0.1 · step 0.1totalRisk
AutoView Settings [OANDA]
Use AutoView?If turned on then the alerts this script generates will use AutoView syntax for auto-trading (WARNING: USE AT OWN RISK! RESEARCH THE DANGERS)falseboolline 182 line 189 line 204 line 215 line 236 line 247
Use Oanda Demo?If turned on then oandapractice broker prefix will be used for AutoView alerts (demo account). If turned off then live account will be usedtrueboolbroker
Use Limit Order?If turned on then AutoView will use limit orders. If turned off then market orders will be usedtrueboolline 127 alert
Account BalanceYour account balance (used for calculating position size)1000.0float · step 100riskAmount
Account CurrencyYour account balance currency (used for calculating position size)USDstring · options ["AUD", "CAD", "CHF", "EUR", "GBP", "JPY", "NZD", "USD"]accountSameAsCounterCurrency accountSameAsBaseCurrency conversionCurrencyPair
Risk Per Trade %Your risk per trade as a % of your account balance2.0float · step 0.5riskAmount
PineConnector Settings
Use PineConnector?Use PineConnector Alerts? (WARNING: USE AT OWN RISK! RESEARCH THE DANGERS)trueboolline 184 line 191 line 207 line 225 line 239 line 256
License IDThis is your PineConnector license IDIDstringline 122 line 124
Risk Per TradeThis is how much to risk per trade (% of balance or lots - based on PC settings)1float · step 0.5line 122
MetaTrader PrefixThis is your broker\'s MetaTrader symbol prefix (leave blank if there is none)stringsymbol
MetaTrader SuffixThis is your broker\'s MetaTrader symbol suffix (leave blank if there is none)stringsymbol

What it calculates

  • SMAvolume, Moving Average (30)ma0 · line 26
  • ATR14atr · line 132
  • ATRATR Period (14)atrValue · line 150
  • SMAclose, MA Period Fast (21)maValue1 · line 156
  • SMAclose, MA Period Slow (55)maValue2 · line 157

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 89 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.

Order rules

OrderFires whenBy defaultLine
Exit Long Exit stop and limit(stopType == "ATR Trail-Stop" or stopType == "ATR Trail") and strategy.position_size > 0On186
Exit Short Exit stop and limit(stopType == "ATR Trail-Stop" or stopType == "ATR Trail") and strategy.position_size < 0On193
Open Long longlongCond and takeLong and sessionFilterResult and strategy.position_size == 0 and barstate.isconfirmed and strategy.equity > 0On211
Exit Long Exit stop and limitstopType != "ATR Trail"On213
Open Short shortshortCond and takeShort and sessionFilterResult and strategy.position_size == 0 and barstate.isconfirmed and strategy.equity > 0On242
Exit Short Exit stop and limitstopType != "ATR Trail"On244

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

Alerts

AlertCallMessageLine
(no title)alert"e=" + broker + " b=long q=" + str.tostring(tradePositionSize) + " s=" + pair + " t=" + (av_limitOrder ? "stop fp=" + str.tostring(close) : "market") + " fsl=" + str.tostring(longStop) + setTp217
(no title)alertalertString227
(no title)alert"e=" + broker + " b=short q=" + str.tostring(tradePositionSize) + " s=" + pair + " t=" + (av_limitOrder ? "stop fp=" + str.tostring(close) : "market") + " fsl=" + str.tostring(shortStop) + setTp249
(no title)alertalertString258

Does it repaint?

Yes

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

Not measuredAn engine gap, not the scriptThe script acts only when barstate.isconfirmed is true, which Zeal Terminal's engine never reports during a live replay (it does not run a bar's closing update in live mode), so the replay cannot test this script. The answer comes from the checks on the source alone.
  • ClearHigher-timeframe data1 request.security call(s), none with lookahead on.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • CheckIntrabar recalculationcalc_on_every_tick = true. Live values can differ from history.
  • ClearOrder timingprocess_orders_on_close = true: orders fill at the signal bar's close.

The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.

Other markets

Not run on other markets: the script requests AUDUSD D, and that data is not available here (AUDUSD is not on Binance). Its results would rest on empty values.

The trades

By market direction

At entry, last 90 barsTradesWonP&L
Rising market250%−$4.00
Sideways market10%−$199.92
Falling market0—$0.00

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

How bad could the drawdown be?

4.0%

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

0%5%
All 3 trades
SideEntryExitBarsP&L
long3 Feb 2025 101,329.0025 Feb 2025 91,230.7022−$200.00
long23 Jun 2025 105,334.009 Jul 2025 111,055.0016$196.00
long12 Oct 2025 114,959.0016 Oct 2025 109,565.004−$199.92

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
3LS - 3 Line Strike Strategy [Kintsugi Trading] this page—v5 strategy−2.0%32.2%
I11L - Better Buy Low Volatility or High Volatility- by I11Latr smav5 strategy+19.2%8337.4%
Vortex Cross w-MA Confirmation by DraftVentureatr smav5 strategy+2.4%524.7%
Configurable Multi MA Crossover Voting System by levieuxsma atrv5 strategy+28.5%539.4%
Swing Trend Strategy by Inkedlausma atrv5 strategy+11.2%516.2%
SSL Backtester With ATR SL TP and Money Management by JBTrippinsma atrv4 strategy+8.5%553.9%

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.

  • 7 settings use the untyped input() (line 6, 7, 8, 10, 13, 17, 97). 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

VerifiedDownload the v5 script

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

  • Line 6: input() → input.bool()
  • Line 7: input() → input.bool()
  • Line 8: input() → input.bool()
  • Line 10: input() → input.int()
  • Line 13: input() → input.int()
  • Line 17: input() → input.bool()
  • Line 97: input() → input.bool()
⋯//INPUTS-showRiskReward = input(true,title="Show Risk/Reward Area",group="Risk Management")+showRiskReward = input.bool(true,title="Show Risk/Reward Area",group="Risk Management")-takeLong = input(true, title="Enter Long Position",group="Risk Management")+takeLong = input.bool(true, title="Enter Long Position",group="Risk Management")-takeShort = input(true, title="Enter Short Position",group="Risk Management")+takeShort = input.bool(true, title="Enter Short Position",group="Risk Management")stopType = input.string("Fix PIP Size",title="Stop Loss Strategy",options=["ATR Trail","ATR Trail-Stop","Fix PIP Size"], group="Risk Management")-atrPeriod = input(14,title="ATR Period",group="Risk Management",tooltip="Uses on ATR Trail-stop")+atrPeriod = input.int(14,title="ATR Period",group="Risk Management",tooltip="Uses on ATR Trail-stop")atrMultip = input.float(2.0,step=0.1,title="ATR Multiplier",group="Risk Management",tooltip="Uses on ATR Trail-stop")riskMultip = input.float(1.0,title="Risk/Reward Ratio",minval=0.1,step=0.1,group="Risk Management")-stopTickSize = input(3,title="Additional Stop PIP Size",group="Risk Management")*syminfo.mintick*10+stopTickSize = input.int(3,title="Additional Stop PIP Size",group="Risk Management")*syminfo.mintick*10isSessionFilterActive = input.bool(false,title="Session Filter Active?",group="Session")⋯sessionOneRange = input.session(title='Trade Session: ', defval='0900-1600', group='Session')-maFill = input(true,title="MA Cloud Fill",group="MA")+maFill = input.bool(true,title="MA Cloud Fill",group="MA")maPeriod1 = input.int(21,title="MA Period Fast",group="MA")⋯//}-useCustomRisk = input(true,title="Use Custom Risk",group="Risk Calculation")+useCustomRisk = input.bool(true,title="Use Custom Risk",group="Risk Calculation")maxPercRisk = input.float(2.0,step=0.1,minval=0.1,title="% Risk Per Trade",group="Risk Calculation",tooltip="This value used only for backtest results not for auto trading.")/100⋯

Does it run in Pine Script v6?

Yes

Same 3 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.

Download the v6 script

⋯// © KintsugiTrading-//@version=5+//@version=6strategy(title="3LS | 3 Line Strike Strategy [Kintsugi Trading]", overlay=true, process_orders_on_close=true, calc_on_every_tick=true, initial_capital=10000)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 153 msWith a workaround 1,000 bars in 211 msNot measured
PineTSNot testedNot testedNot measured

The engine's host API cannot yet declare a chart's symbol and timeframe, so this page sets them on the engine directly for each market.

“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/// © KintsugiTrading//@version=5strategy(title="3LS | 3 Line Strike Strategy [Kintsugi Trading]", overlay=true, process_orders_on_close=true, calc_on_every_tick=true, initial_capital=10000)//INPUTSshowRiskReward = input(true,title="Show Risk/Reward Area",group="Risk Management")takeLong = input(true, title="Enter Long Position",group="Risk Management")takeShort = input(true, title="Enter Short Position",group="Risk Management")stopType = input.string("Fix PIP Size",title="Stop Loss Strategy",options=["ATR Trail","ATR Trail-Stop","Fix PIP Size"], group="Risk Management")atrPeriod = input(14,title="ATR Period",group="Risk Management",tooltip="Uses on ATR Trail-stop")atrMultip = input.float(2.0,step=0.1,title="ATR Multiplier",group="Risk Management",tooltip="Uses on ATR Trail-stop")riskMultip = input.float(1.0,title="Risk/Reward Ratio",minval=0.1,step=0.1,group="Risk Management")stopTickSize = input(3,title="Additional Stop PIP Size",group="Risk Management")*syminfo.mintick*10isSessionFilterActive = input.bool(false,title="Session Filter Active?",group="Session")i_tz = input.string('GMT', title='Timezone: ', tooltip='e.g. \'America/New_York\', \'Asia/Tokyo\', \'GMT-4\', \'GMT+9\'...', group='Session')sessionOneRange = input.session(title='Trade Session: ', defval='0900-1600', group='Session')maFill = input(true,title="MA Cloud Fill",group="MA")maPeriod1 = input.int(21,title="MA Period Fast",group="MA")maPeriod2 = input.int(55,title="MA Period Slow",group="MA")//VSA{showVsa = input.bool(true,title="Show VSA Status?",group="VSA")ma0_length = input.int(30, "Moving Average", minval=1, group="VSA")ma1_length = input.float(0.5,step=0.1,title="MA-1 Multiplier",group="VSA")ma2_length = input.float(1.5,step=0.1,title="MA-2 Multiplier",group="VSA")ma3_length = input.float(3.0,step=0.1,title="MA-3 Multiplier",group="VSA")ma0 = ta.sma(volume, ma0_length)ma1 = ma0 * ma1_lengthma2 = ma0 * ma2_lengthma3 = ma0 * ma3_lengthhistColor = volume < ma1 ? color.navy  : volume < ma2 ? color.green  : volume < ma3 ? color.yellow : volume > ma3 ? color.red  : color.gray       volumeEntryCond = volume > ma2plotshape(showVsa ? -1 : na, color=histColor, style=shape.square, location=location.bottom, size=size.auto, title='VSA Status')plotshape(showVsa ? -1 : na, color=histColor, textcolor=histColor, text='VSA Status', style=shape.square, location=location.bottom, size=size.auto, title='VSA Label', show_last=1, offset=0)//}//3LS{showBear3LS = input.bool(title='Show Bearish KT Signal', defval=true, group='3 Line Strike')showBull3LS = input.bool(title='Show Bullish KT Signal', defval=true, group='3 Line Strike')getCandleColorIndex(barIndex) =>    int ret = na    if (close[barIndex] > open[barIndex])        ret := 1    else if (close[barIndex] < open[barIndex])        ret := -1    else        ret := 0    ret// Check for engulfing candlesisEngulfing(checkBearish) =>    // In an effort to try and make this a bit more consistent, we're going to calculate and compare the candle body sizes    // to inform the engulfing or not decision, and only use the open vs close comparisons to identify the candle "color"    ret = false    sizePrevCandle = close[1] - open[1] // negative numbers = red, positive numbers = green, 0 = doji    sizeCurrentCandle = close - open    // negative numbers = red, positive numbers = green, 0 = doji    isCurrentLagerThanPrevious = (math.abs(sizeCurrentCandle) > math.abs(sizePrevCandle)) ? true : false    // We now have the core info to evaluate engulfing candles    switch checkBearish        true =>             // Check for bearish engulfing (green candle followed by a larger red candle)            isGreenToRed = ((getCandleColorIndex(0) < 0) and (getCandleColorIndex(1) > 0)) ? true : false            ret := (isCurrentLagerThanPrevious and isGreenToRed) ? true : false        false =>             // Check for bullish engulfing (red candle followed by a larger green candle)            isRedToGreen = ((getCandleColorIndex(0) > 0) and (getCandleColorIndex(1) < 0)) ? true : false            ret := (isCurrentLagerThanPrevious and isRedToGreen) ? true : false        => ret := false // This should be impossible to trigger...    ret//// Helper functions that wraps the isEngulfing above...isBearishEngulfuing() =>    ret = isEngulfing(true)    ret//isBullishEngulfuing() =>    ret = isEngulfing(false)    ret//// Functions to check for 3 consecutive candles of one color, followed by an engulfing candle of the opposite color//// Bearish 3LS = 3 green candles immediately followed by a bearish engulfing candleis3LSBear() =>    ret = false    is3LineSetup = ((getCandleColorIndex(1) > 0) and (getCandleColorIndex(2) > 0) and (getCandleColorIndex(3) > 0)) ? true : false    ret := (is3LineSetup and isBearishEngulfuing()) ? true : false    ret//// Bullish 3LS = 3 red candles immediately followed by a bullish engulfing candleis3LSBull() =>    ret = false    is3LineSetup = ((getCandleColorIndex(1) < 0) and (getCandleColorIndex(2) < 0) and (getCandleColorIndex(3) < 0)) ? true : false    ret := (is3LineSetup and isBullishEngulfuing()) ? true : false    retis3LSBearSig = is3LSBear()is3LSBullSig = is3LSBull()plotshape(showBull3LS ? is3LSBullSig : na, style=shape.triangleup, color=color.rgb(0, 255, 0, 0), location=location.belowbar, size=size.small, text='KT-Bull', title='3 Line Strike Up')plotshape(showBear3LS ? is3LSBearSig : na, style=shape.triangledown, color=color.rgb(255, 0, 0, 0), location=location.abovebar, size=size.small, text='KT-Bear', title='3 Line Strike Down')//}useCustomRisk = input(true,title="Use Custom Risk",group="Risk Calculation")maxPercRisk = input.float(2.0,step=0.1,minval=0.1,title="% Risk Per Trade",group="Risk Calculation",tooltip="This value used only for backtest results not for auto trading.")/100// AutoView Settingsvar g_av            = "AutoView Settings [OANDA]"av_use              = input.bool(title="Use AutoView?", defval=false, group=g_av, tooltip="If turned on then the alerts this script generates will use AutoView syntax for auto-trading (WARNING: USE AT OWN RISK! RESEARCH THE DANGERS)")av_oandaDemo        = input.bool(title="Use Oanda Demo?", defval=true, group=g_av, tooltip="If turned on then oandapractice broker prefix will be used for AutoView alerts (demo account). If turned off then live account will be used")av_limitOrder       = input.bool(title="Use Limit Order?", defval=true, group=g_av, tooltip="If turned on then AutoView will use limit orders. If turned off then market orders will be used")av_accountBalance   = input.float(title="Account Balance", defval=1000.0, step=100, group=g_av, tooltip="Your account balance (used for calculating position size)")av_accountCurrency  = input.string(title="Account Currency", defval="USD", options=["AUD", "CAD", "CHF", "EUR", "GBP", "JPY", "NZD", "USD"], group=g_av, tooltip="Your account balance currency (used for calculating position size)")av_riskPerTrade     = input.float(title="Risk Per Trade %", defval=2.0, step=0.5, group=g_av, tooltip="Your risk per trade as a % of your account balance")// PineConnector Settingsvar g_pc = 'PineConnector Settings'pc_use = input.bool(title='Use PineConnector?', defval=true, group=g_pc, tooltip='Use PineConnector Alerts? (WARNING: USE AT OWN RISK! RESEARCH THE DANGERS)')pc_id = input.string(title='License ID', defval='ID', group=g_pc, tooltip='This is your PineConnector license ID')pc_risk = input.float(title='Risk Per Trade', defval=1, step=0.5, group=g_pc, tooltip='This is how much to risk per trade (% of balance or lots - based on PC settings)')pc_prefix = input.string(title='MetaTrader Prefix', defval='', group=g_pc, tooltip='This is your broker\'s MetaTrader symbol prefix (leave blank if there is none)')pc_suffix = input.string(title='MetaTrader Suffix', defval='', group=g_pc, tooltip='This is your broker\'s MetaTrader symbol suffix (leave blank if there is none)')// Generate PineConnector alert stringvar symbol = pc_prefix + syminfo.ticker + pc_suffixvar broker = av_oandaDemo ? "oandapractice" : "oanda"var pair = syminfo.basecurrency + "/" + syminfo.currencypc_entry_alert(direction, entry, sl, tp) =>    order_price = entry    tp_value = na(tp) == false ? ',tp=' + str.tostring(tp) : ""    price = 'price=' + str.tostring(order_price)    pc_id + ',' + direction  + ',' + symbol + ',' + price + ',sl=' + str.tostring(sl) + tp_value + ',risk=' + str.tostring(pc_risk)pc_exit_alert(direction) =>    pc_id + ',' + direction  + ',' + symbolav_entry_alert(side, qty, entry, sl, tp)=>    tp_value = na(tp) == false ? " ftp=" + str.tostring(tp) : ""    "e=" + broker + " b="+side+" q=" + str.tostring(qty) + " s=" + pair+ " t=" + (av_limitOrder ? "limit fp=" + str.tostring(entry) : "market")+ " fsl=" + str.tostring(sl)+ tp_valueav_exit_alert(side) =>    "e=" + broker + " s=" + pair +" c=position b="+side//AUTOTRADE//DETERMINE POSITION SIZEatr = ta.atr(14)toWhole(number) =>    returnVal = atr < 1.0 ? (number / syminfo.mintick) / (10 / syminfo.pointvalue) : number    returnVal := atr >= 1.0 and atr < 100.0 and syminfo.currency == "JPY" ? returnVal * 100 : returnVal    var tradePositionSize = 0.0accountSameAsCounterCurrency = av_accountCurrency == syminfo.currencyaccountSameAsBaseCurrency = av_accountCurrency == syminfo.basecurrencyaccountNeitherCurrency = not accountSameAsCounterCurrency and not accountSameAsBaseCurrencyconversionCurrencyPair = accountSameAsCounterCurrency ? syminfo.tickerid : accountNeitherCurrency ? av_accountCurrency + syminfo.currency : av_accountCurrency + syminfo.currencyconversionCurrencyRate = request.security(symbol=syminfo.type == "forex" ? conversionCurrencyPair : "AUDUSD", timeframe="D", expression=close)getPositionSize(stopLossSizePoints) =>    riskAmount = (av_accountBalance * (av_riskPerTrade / 100)) * (accountSameAsBaseCurrency or accountNeitherCurrency ? conversionCurrencyRate : 1.0)    riskPerPoint = (stopLossSizePoints * syminfo.pointvalue)    positionSize = (riskAmount / riskPerPoint) / syminfo.mintick    math.round(positionSize)//CALCS//ATRatrValue = ta.atr(atrPeriod)//Sessionsin_session_one = time(timeframe.period, sessionOneRange,i_tz)sessionOneActive = in_session_one and timeframe.multiplier <= 1440sessionFilterResult = isSessionFilterActive ? sessionOneActive : true//MAmaValue1 = ta.sma(close,maPeriod1)maValue2 = ta.sma(close,maPeriod2)//STRATEGYvar float longStop = na,var float longRisk = na,var float longTp = navar float shortStop = na,var float shortRisk = na,var float shortTp = nastring entryAlertString = "", string exitAlertString = ""fix_long_exit = "Exit LONG"fix_short_exit = "Exit SHORT"var float positionSize = 1calcPositionSize(unitRisk)=>    if useCustomRisk == false        1    else        totalRisk = strategy.equity *maxPercRisk        math.round(totalRisk/unitRisk,6)//FUNCTIONcalcAtrTrailStop(side)=>    if side == "long"        tempStop = close - (atrValue * atrMultip)        (tempStop > longStop and tempStop < close) ? tempStop : longStop    else        tempStop = close + (atrValue * atrMultip)        (tempStop < shortStop and tempStop > close) ? tempStop : shortStop//ATR TRAIL-STOPif (stopType == "ATR Trail-Stop" or stopType == "ATR Trail") and strategy.position_size > 0    longStop := calcAtrTrailStop("long")    if av_use        exitAlertString := av_exit_alert('long')    else if pc_use        exitAlertString := pc_exit_alert('closelong')    strategy.exit('Long Exit', 'Long', comment="EXIT LONG", stop=longStop, limit=longTp, alert_message=exitAlertString)if (stopType == "ATR Trail-Stop" or stopType == "ATR Trail") and strategy.position_size < 0     shortStop := calcAtrTrailStop("short")    if av_use        exitAlertString := av_exit_alert('short')    else if pc_use        exitAlertString := pc_exit_alert('closeshort')    strategy.exit('Short Exit', 'Short', comment="EXIT SHORT", stop=shortStop, limit=shortTp, alert_message=exitAlertString)//LONGlongCond = is3LSBullSig and volumeEntryCond and maValue1 > maValue2shortCond = is3LSBearSig and volumeEntryCond and maValue1 < maValue2 if longCond and takeLong and sessionFilterResult and strategy.position_size == 0 and barstate.isconfirmed and strategy.equity > 0    longStop := stopType == "Fix PIP Size" ? low - stopTickSize : close - (atrValue*atrMultip)    longRisk := (close - longStop)     longTp :=   stopType != "ATR Trail" ?  close + (riskMultip*longRisk) : na    longStopDistance = close - longStop    positionSize := calcPositionSize(longRisk)         if av_use        entryAlertString := av_entry_alert("long",tradePositionSize,close,longStop,longTp)        exitAlertString := fix_long_exit    else if pc_use        entryAlertString := pc_entry_alert("buy", close, longStop, longTp)        exitAlertString := fix_long_exit            strategy.entry("Long",strategy.long,comment="LONG", qty=positionSize, alert_message=entryAlertString)    if stopType != "ATR Trail"        strategy.exit("Long Exit","Long", comment="EXIT LONG", stop=longStop, limit=longTp, alert_message=exitAlertString)     tradePositionSize := getPositionSize(toWhole(longStopDistance) * 10)    if av_use        setTp = na(longTp) == false ? " ftp=" + str.tostring(longTp) : ""        alert(message="e=" + broker + " b=long q="         + str.tostring(tradePositionSize)          + " s=" + pair         + " t=" + (av_limitOrder ? "stop fp=" + str.tostring(close) : "market")         + " fsl=" + str.tostring(longStop)         + setTp,          freq=alert.freq_once_per_bar)        if pc_use        alertString = pc_entry_alert('buystop', close, longStop, longTp)        alert(alertString, alert.freq_once_per_bar_close)//SHORTif shortCond and takeShort and sessionFilterResult and strategy.position_size == 0 and barstate.isconfirmed and strategy.equity > 0    shortStop := stopType == "Fix PIP Size" ? high + stopTickSize : close + (atrValue*atrMultip)    shortRisk := (shortStop - close)    shortTp := stopType != "ATR Trail" ? close - (riskMultip*shortRisk) : na    shortStopDistance = math.abs(close-shortStop)    positionSize := calcPositionSize(shortRisk)        if av_use        entryAlertString := av_entry_alert("short",tradePositionSize,close,shortStop,shortTp)        exitAlertString := fix_short_exit    else if pc_use        entryAlertString := pc_entry_alert('sell', close, shortStop, shortTp)        exitAlertString := fix_short_exit     strategy.entry("Short",strategy.short,comment="SHORT", qty=positionSize, alert_message=entryAlertString)    if stopType != "ATR Trail"        strategy.exit("Short Exit","Short", comment="EXIT SHORT", stop=shortStop, limit=shortTp, alert_message=exitAlertString)          tradePositionSize := getPositionSize(toWhole(shortStopDistance) * 10)    if av_use        setTp = na(shortTp) == false ? " ftp=" + str.tostring(shortTp) : ""        alert(message="e=" + broker + " b=short q="         + str.tostring(tradePositionSize)         + " s=" + pair         + " t=" + (av_limitOrder ? "stop fp=" + str.tostring(close) : "market")         + " fsl=" + str.tostring(shortStop)         + setTp,         freq=alert.freq_once_per_bar)     if pc_use        alertString = pc_entry_alert('sellstop', close, shortStop, shortTp)        alert(alertString, alert.freq_once_per_bar_close)//PLOTSp1=plot(maValue1,title="MA Fast",color=color.green,linewidth=1)p2=plot(maValue2,title="MA Slow",color=color.red,linewidth=1)fill(p1,p2, color=maFill ? maValue1 > maValue2 ? color.new(color.green,90) : color.new(color.red,90) : color.new(color.black,100))L1 = plot(showRiskReward and strategy.position_size > 0 ? strategy.position_avg_price : na, color=color.green, linewidth=1, style=plot.style_linebr, title="Long Entry Price")L2 = plot(showRiskReward and strategy.position_size > 0 ? longTp : na, color=color.green, linewidth=1, style=plot.style_linebr, title="Long TP Price")L3 = plot(showRiskReward and strategy.position_size > 0 ? longStop : na, color=color.red, linewidth=1, style=plot.style_linebr, title="Long Stop Price")S1 = plot(showRiskReward and strategy.position_size < 0 ? strategy.position_avg_price : na, color=color.teal, linewidth=1, style=plot.style_linebr, title="Short Entry Price")S2 = plot(showRiskReward and strategy.position_size < 0 ? shortTp : na , color=color.teal, linewidth=1, style=plot.style_linebr, title="Short TP Price")S3 = plot(showRiskReward and strategy.position_size < 0 ? shortStop : na, color=color.maroon, linewidth=1, style=plot.style_linebr, title="Short Stop Price")fill(L1,L2,color=color.new(color.green,90))fill(L1,L3,color=color.new(color.red,90))fill(S1,S2,color=color.new(color.teal,90))fill(S1,S3,color=color.new(color.maroon,90))bgcolor(sessionOneActive and isSessionFilterActive ? color.new(color.orange,90) : na, title="Trade Session")var table nameDisplay = table.new(position.middle_center, 1, 1, bgcolor = color.white, frame_width = 0)if barstate.isconfirmed and math.round(strategy.equity,0) <= 0    table.cell(nameDisplay, 0, 0, "Total Equity dropped below ZERO.\nThese parameters are not useful.",text_color=color.white, bgcolor=color.red)