Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

50 Pips A Day Strategy - Kaspricci

A Pine Script v5 strategy built on ATR (14). It has 9 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 commits 100% of equity and pays no commission. 21 settings; defaults include Opening Time 0700-0800:23456, Trading Time 0800-2000:23456 and Source for Buy Stop order high.

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 50 Pips A Day Strategy - Kaspricci repaint?
Yes
At least one pattern in the source can repaint: intrabar recalculation.
How did 50 Pips A Day Strategy - Kaspricci do on BTCUSDT 1D with default settings?
Not measured
It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its code limits trading to a session window, which can leave these candles out. It closed no trades on the other markets either. A backtest, not investment advice.
Does 50 Pips A Day Strategy - Kaspricci run in Pine Script v6?
Not tested
Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download.
Does 50 Pips A Day Strategy - Kaspricci use a stop loss?
Yes
strategy.exit sets a stop on line 127, 129.
Does 50 Pips A Day Strategy - Kaspricci run in Zeal Terminal?
Yes
It compiles in 49 ms and runs 1,000 bars in 122 ms, in the browser.

BTCUSDT · 1D · default settings

  • ATR
  • 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 (21)
0.0050,000100,000AprJulOct2025AprJulOct2026AprJulOct$1,000$2,025Equity from $1,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. The script plots nothing itself; the lines and the lower pane are its own calculations, drawn for reference. 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.
Net profit
0.00%
$0.00
Buy and hold
+102.5%
same period
Closed trades
0
0 won · 0 lost
Profitable
0.0%
of closed trades
Profit factor
—
gross profit ÷ gross loss
Max drawdown
0.00%
$0.00

One run with the author's default settings, $1,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.

  • Check

    No commission

    The backtest assumes free trading. Results on any real exchange will be lower.

  • Check

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • Note

    6 settings have no label

    In the settings dialog useRiskMagmt (line 23), rsikCapital (line 25), i_apiEnterLong (line 62), i_apiExitLong (line 63), i_apiEnterShort (line 64), i_apiExitShort (line 65) show an empty name. The labels on this page come from the variable names.

Settings

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

SettingDefaultType and rangeFeeds
Entry Seettings
Opening TimeGMT timezone0700-0800:23456sessionopeningTime
Trading TimeCombined timeframe of London and New York Stock Exchange opening hours from 7:00 - 15:30 GMT and 13:30 - 20:00 GMT0800-2000:23456sessiontradingTime
Source for Buy Stop orderhighsourceopeningHigh
+ Pips:2.0float · min 0 · step 0.1buyStopPrice
Source for Sell Stop orderlowsourceopeningLow
- Pips:2.0float · min 0 · step 0.1sellStopPrice
Cancel pending order when new trade entered?This will cancel the reamaining order, once the first trade has been entered.trueboolcancel currentTradeID + "L" cancel currentTradeID + "S" line 141
Trade Seettings
Stop Loss TypeFIXstring · options ["ATR", "FIX"]stopLoss takeProfit
ATR: Length 14int · min 1stopLoss
Factor multiplier for ATR value2.0float · min 0 · step 0.05stopLoss
TP RationMultiplier for Take Profit calculation2.0float · min 0 · step 0.05takeProfit
FIX: Stop Loss 15.0float · min 0 · step 0.5stopLoss
Take Profitin pips50.0float · min 0 · step 0.5takeProfit
Use Risk Magmt (no label in the script)falseboolquantity
Risk in % This will overwrite quantity from startegy settings and calculate the trade size based on stop loss and risk percent1.0float · min 0.0 · step 0.5riskAmount takeAmount1 takeAmount2 takeAmountFull
Rsik Capital (no label in the script)This will overwrite quantity from startegy settings and calculate the trade size based on stop loss and risk percentBalancestring · options ["Balance", "Initial"]baseCapital
Apply Lot sizingWhen enabled, the quantity will be rounded to the minimum lot size of 1000 (0.01 lots)trueboolriskBasedQty
Alert Settings
I api Enter Long (no label in the script)Enter Long - 3commas,alerteron etctext_areaentry tradeID + "L"
I api Exit Long (no label in the script)Exit Long - 3commas,alerteron etctext_areaexit tradeID + "SL" close currentTradeID + "L"
I api Enter Short (no label in the script)Enter Short - 3commas,alerteron etctext_areaentry tradeID + "S"
I api Exit Short (no label in the script)Exit Short - 3commas,alerteron etctext_areaexit tradeID + "SL" close currentTradeID + "S"

What it calculates

  • ATR ATR: Length (14) · chosen by Stop Loss TypestopLoss · line 27

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.

high · low · closehigh · low · closeprice datastopLossTypeStop Loss Typesetting · FIXatrLength ATR: Length setting · 14atrFactorFactor setting · 2.0fixStopLoss FIX: Stop Loss setting · 15.0openingSessionOpening Timesetting · 0700-0800:23456tradingSessionTrading Timesetting · 0800-2000:23456takeProfitRatio TP Rationsetting · 2.0fixTakeProfitTake Profitsetting · 50.0rsikCapitalRsik Capitalsetting · BalanceriskPercentRisk in % setting · 1.0buyStopGap + Pips:setting · 2.0sellStopGap - Pips:setting · 2.0highhighprice datalowlowprice datastopLossATR→ stopLoss · by Stop Loss TypeopeningTimeopeningTimevaluetradingTimetradingTimevaluetakeProfittakeProfitvaluebaseCapitalbaseCapitalvalueriskAmountriskAmountvaluetickValue, tradeID, currentTradeIDtickValue · tradeID +13 valuesriskBasedQtyriskBasedQtyvaluequantityquantityvaluebuyStopPricebuyStopPricevaluesellStopPricesellStopPricevaluelongSLlongSLvaluelongTP1, longTP2, longTPFulllongTP1 · longTP2 +13 valuesshortSLshortSLvalueshortTP1, shortTP2, shortTPFullshortTP1 · shortTP2 +13 valuestakeAmount1, takeAmount2, takeAmountFulltakeAmount1 · takeAmoun…3 values_value_valuevalueopeningHighopeningHighvalueopeningLowopeningLowvalueinTradingTimeinTradingTimeconditioninOpeningTimeinOpeningTimeconditionentry:tradeID + "L"Open tradeID + "L"strategy.entryexit:tradeID + "SL"exit tradeID + "SL"strategy.exitentry:tradeID + "S"Open tradeID + "S"strategy.entrycancel_all:cancel_all strategy.cancel_allclose:currentTradeID + "L"Close currentTradeID + …strategy.closeclose:currentTradeID + "S"Close currentTradeID + …strategy.closecancel:currentTradeID + "L"cancel currentTradeID +…strategy.cancelcancel:currentTradeID + "S"cancel currentTradeID +…strategy.cancelplot:46Buy Stop Priceplotplot:47Sell Stop Priceplot

Order rules

OrderFires whenBy defaultLine
Open tradeID + "L" longbarstate.isconfirmed and inTradingTime and not inTradingTime[1]On126
Exit tradeID + "SL" stop and limitbarstate.isconfirmed and inTradingTime and not inTradingTime[1]On127
Open tradeID + "S" shortbarstate.isconfirmed and inTradingTime and not inTradingTime[1]On128
Exit tradeID + "SL" stop and limitbarstate.isconfirmed and inTradingTime and not inTradingTime[1]On129
cancel_all barstate.isconfirmed and not inTradingTime and inTradingTime[1]On136
Close currentTradeID + "L"barstate.isconfirmed and not inTradingTime and inTradingTime[1]On138
Close currentTradeID + "S"barstate.isconfirmed and not inTradingTime and inTradingTime[1]On139
cancel currentTradeID + "L"strategy.opentrades > 0 and closePendingOn143
cancel currentTradeID + "S"strategy.opentrades > 0 and closePendingOn144

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.

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 dataThe script requests no other symbol or timeframe.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • CheckIntrabar recalculationcalc_on_every_tick = true. Live values can differ from history.
  • 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 1D0.0%+102.5%00%—0.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h0.0%+5.5%00%—0.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D0.0%+9.8%00%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h0.0%+8.4%00%—0.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D0.0%+16.7%00%—0.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h0.0%+21.5%00%—0.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D0.0%+148.3%00%—0.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h0.0%+17.1%00%—0.0%8 May 2026 – 21 Oct 2026

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

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
50 Pips A Day Strategy - Kaspricci this page—v5 strategy0.0%00.0%
SOJA PIVOT by ParaBellum68atrv4 strategy+3.3%918.2%
Volatility System by EduardoMattjeatrv5 strategy+150.2%221.5%
ATR Stop Buy Strategy by phobo3satrv4 strategyNo trades on this market
VBand Strategy by Saravanan_Ragavanatrv4 strategyNo trades on this market
Volatility Breakout Strategy [Angel Algo] by AngelAlgoatrv5 strategy+3.1%183.6%

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.

  • No v6-only features. v6 is not needed to run this script.

Clean v5

Verified

Nothing to change.

Does it run in Pine Script v6?

Not tested

Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © Kaspricci-//@version=5+//@version=6strategy("50 Pips A Day Strategy - Kaspricci", overlay=true, initial_capital = 1000, currency = currency.USD, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, margin_long = 0, margin_short = 0, calc_on_every_tick = true, calc_on_order_fills = false, slippage = 0, close_entries_rule = "ANY")⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 49 msWith a workaround 1,000 bars in 122 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/// © Kaspricci//@version=5strategy("50 Pips A Day Strategy - Kaspricci", overlay=true, initial_capital = 1000, currency = currency.USD, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, margin_long = 0, margin_short = 0, calc_on_every_tick = true, calc_on_order_fills = false, slippage = 0, close_entries_rule = "ANY")headlineEntry   = "Entry Seettings"tooltipTF       = "Combined timeframe of London and New York Stock Exchange opening hours from 7:00 - 15:30 GMT and 13:30 - 20:00 GMT"openingSession  = input.session(defval="0700-0800:23456", title="Opening Time", group=headlineEntry, tooltip="GMT timezone")openingTime     = time(timeframe.period, openingSession, "GMT")tradingSession  = input.session(defval="0800-2000:23456", title="Trading Time", group=headlineEntry, tooltip=tooltipTF)tradingTime     = time(timeframe.period, tradingSession, "GMT")buyStopSource   = input.source( defval = high, title = "Source for Buy Stop order", inline = "B", group=headlineEntry)buyStopGap      = input.float(  defval = 2.0, minval = 0, step = 0.1, title = " + Pips:", inline = "B", group=headlineEntry)sellStopSource  = input.source( defval = low, title = "Source for Sell Stop order", inline = "S", group=headlineEntry)sellStopGap     = input.float(  defval = 2.0, minval = 0, step = 0.1, title = " - Pips:", inline = "S", group=headlineEntry)closePending    = input.bool(   defval = true, group = headlineEntry, title = "Cancel pending order when new trade entered?", tooltip = "This will cancel the reamaining order, once the first trade has been entered.")headlineTrade   = "Trade Seettings"stopLossType    = input.string(defval = "FIX", title = "Stop Loss Type", options = ["ATR", "FIX"], group = headlineTrade)atrLength       = input.int(defval = 14, title = "   ATR: Length        ",   inline = "ATR", group = headlineTrade, minval = 1)atrFactor       = input.float(defval = 2.0, title = "Factor        ", inline = "ATR", group = headlineTrade, tooltip = "multiplier for ATR value", minval = 0, step = 0.05)takeProfitRatio = input.float(defval = 2.0, title = "            TP Ration", group = headlineTrade, tooltip = "Multiplier for Take Profit calculation", minval = 0, step = 0.05)fixStopLoss     = input.float(defval = 15.0, title = "   FIX: Stop Loss    ",   inline = "FIX", group = headlineTrade, minval = 0, step = 0.5) * 10 // need this in ticksfixTakeProfit   = input.float(defval = 50.0, title = "Take Profit", inline = "FIX", group = headlineTrade, tooltip = "in pips", minval = 0, step = 0.5) * 10 // need this in ticksuseRiskMagmt    = input.bool(  title = "", defval = false, group = headlineTrade, inline = "RM")riskPercent     = input.float( title = "Risk in %       ", defval = 1.0, minval = 0.0, step = 0.5, group = headlineTrade, inline = "RM", tooltip = "This will overwrite quantity from startegy settings and calculate the trade size based on stop loss and risk percent") / 100rsikCapital     = input.string(defval = "Balance",                     group = headlineTrade, inline = "RM",    title = "",                          options = ["Balance", "Initial"], tooltip = "This will overwrite quantity from startegy settings and calculate the trade size based on stop loss and risk percent")applyLotSizing  = input.bool(defval = true, title = "Apply Lot sizing", tooltip = "When enabled, the quantity will be rounded to the minimum lot size of 1000 (0.01 lots)")stopLoss        = switch stopLossType    "ATR" => math.round(ta.atr(atrLength) * atrFactor / syminfo.mintick, 0)    "FIX" => fixStopLosstakeProfit      = switch stopLossType    "ATR" => math.round(stopLoss * takeProfitRatio, 0)    "FIX" => fixTakeProfit// calculate quantitybaseCapital = switch rsikCapital    "Balance" => strategy.initial_capital + strategy.netprofit    "Initial" => strategy.initial_capitalriskAmount      = strategy.convert_to_symbol(baseCapital * riskPercent)tickValue       = syminfo.pointvalue * syminfo.mintickriskBasedQty    = riskAmount / stopLoss / tickValueriskBasedQty    := applyLotSizing ? math.round(riskBasedQty / 100000, 2) * 100000 : riskBasedQtyquantity        = useRiskMagmt ? riskBasedQty : na // if NaN the default from strategy settings will be usedinTradingTime   = not na(tradingTime)inOpeningTime   = not na(openingTime)var float buyStopPrice  = navar float sellStopPrice = naplot(inTradingTime ? buyStopPrice  : na, title = "Buy Stop Price",  color = color.green, style = plot.style_linebr)plot(inTradingTime ? sellStopPrice : na, title = "Sell Stop Price", color = color.red,   style = plot.style_linebr)///////////////////////////////////////////////////////////////////////////////// api bot valueslongSL          = buyStopPrice - stopLoss * syminfo.minticklongTP1         = buyStopPrice + takeProfit * syminfo.mintick * 0.5 // 50% of total take profitlongTP2         = buyStopPrice + takeProfit * syminfo.mintick // same as fulllongTPFull      = buyStopPrice + takeProfit * syminfo.mintickshortSL         = sellStopPrice + stopLoss * syminfo.mintickshortTP1        = sellStopPrice - takeProfit * syminfo.mintick * 0.5 // 50% of total take profitshortTP2        = sellStopPrice - takeProfit * syminfo.mintickshortTPFull     = sellStopPrice - takeProfit * syminfo.minticktakeAmount1     = riskPercent / 2takeAmount2     = riskPercenttakeAmountFull  = riskPercentheadlineAlerts  = "Alert Settings"i_apiEnterLong  = input.text_area('Enter Long - 3commas,alerteron etc', 'API Entry - Long',   group = headlineAlerts)i_apiExitLong   = input.text_area('Exit Long - 3commas,alerteron etc', 'API Exit - Long',     group = headlineAlerts)i_apiEnterShort = input.text_area('Enter Short - 3commas,alerteron etc', 'API Entry - Short', group = headlineAlerts)i_apiExitShort  = input.text_area('Exit Short - 3commas,alerteron etc', 'API Exit - Short',   group = headlineAlerts)// #nl# => New line// #side# => Buy or Sell (Long or Short)// #symbol# => The ticker e.g. BTCUSDTf_replaceKeys (_str) =>    _value = _str    _value := str.replace_all(_value, "#nl#", "\n")//    _value := str.replace_all(_value, "#side#", "\n") // does not make sense to me...    _value := str.replace_all(_value, "#symbol#", syminfo.ticker)// #LongSL# => Long Stop loss// #LongTP1# => Long Take Profit 1// #LongTP2# => Long Take Profit 2// #LongTPFULL# => Long Take Profit in FULL// #TakeAmount1# => Percent to remove from trade on hitting TP1// #TakeAmount2# => Percent to remove from trade on hitting TP2// #TakeAmountFULL# => Percent to remove from trade on hitting TP3 (should be 100%)f_replaceLongTokens (_str, _sl, _tp1, _tp2, _tpFull, _ta1, _ta2, _taFull) =>    _value = _str    _value := str.replace_all(_value, "#LongSL#", str.tostring(_sl))    _value := str.replace_all(_value, "#LongTP1#", str.tostring(_tp1))    _value := str.replace_all(_value, "#LongTP2#", str.tostring(_tp2))    _value := str.replace_all(_value, "#LongTPFULL#", str.tostring(_tpFull))    _value := str.replace_all(_value, "#TakeAmount1#", str.tostring(_ta1))    _value := str.replace_all(_value, "#TakeAmount2#", str.tostring(_ta2))    _value := str.replace_all(_value, "#TakeAmountFULL#", str.tostring(_taFull))// #ShortSL# => Short Stop loss// #ShortTP1# => Short Take Profit 1// #ShortTP2# => Short Take Profit 2// #ShortTPFULL# => Short Take Profit in FULL// #TakeAmount1# => Percent to remove from trade on hitting TP1// #TakeAmount2# => Percent to remove from trade on hitting TP2// #TakeAmountFULL# => Percent to remove from trade on hitting TP3 (should be 100%)f_replaceShortTokens (_str, _sl, _tp1, _tp2, _tpFull, _ta1, _ta2, _taFull) =>    _value = _str    _value := str.replace_all(_value, "#ShortSL#", str.tostring(_sl))    _value := str.replace_all(_value, "#ShortTP1#", str.tostring(_tp1))    _value := str.replace_all(_value, "#ShortTP2#", str.tostring(_tp2))    _value := str.replace_all(_value, "#ShortTPFULL#", str.tostring(_tpFull))    _value := str.replace_all(_value, "#TakeAmount1#", str.tostring(_ta1))    _value := str.replace_all(_value, "#TakeAmount2#", str.tostring(_ta2))    _value := str.replace_all(_value, "#TakeAmountFULL#", str.tostring(_taFull))i_apiEnterLong  := f_replaceKeys (i_apiEnterLong)i_apiEnterLong  := f_replaceLongTokens (i_apiEnterLong, longSL, longTP1, longTP2, longTPFull, takeAmount1, takeAmount2, takeAmountFull)i_apiExitLong   := f_replaceKeys (i_apiExitLong)i_apiExitLong   := f_replaceLongTokens (i_apiExitLong, longSL, longTP1, longTP2, longTPFull, takeAmount1, takeAmount2, takeAmountFull)i_apiEnterShort := f_replaceKeys (i_apiEnterShort)i_apiEnterShort := f_replaceShortTokens (i_apiEnterShort, shortSL, shortTP1, shortTP2, shortTPFull, takeAmount1, takeAmount2, takeAmountFull)i_apiExitShort  := f_replaceKeys (i_apiExitShort)i_apiExitShort  := f_replaceShortTokens (i_apiExitShort, shortSL, shortTP1, shortTP2, shortTPFull, takeAmount1, takeAmount2, takeAmountFull)// ----- handline trade entries and exits --------------------------------------------------------------------------------------------------------------------------var float openingHigh = navar float openingLow  = na// determine high and low druing opening sessionif barstate.isconfirmed and inOpeningTime    openingHigh     := math.max(buyStopSource,  nz(openingHigh[1], buyStopSource))    openingLow      := math.min(sellStopSource, nz(openingLow[1],  sellStopSource))    buyStopPrice  := openingHigh + buyStopGap * 10 * syminfo.mintick    sellStopPrice := openingLow - sellStopGap * 10 * syminfo.mintick// as soon as the trading session starts calculate stop prices based on high / low of first closing candle, create pending ordersif barstate.isconfirmed and inTradingTime and not inTradingTime[1]    tradeID = str.tostring(strategy.closedtrades + strategy.opentrades + 1)    strategy.entry(tradeID + "L", strategy.long, qty = quantity, stop = buyStopPrice, comment = "Long: " + tradeID, alert_message = i_apiEnterLong)    strategy.exit(tradeID + "SL", tradeID + "L", profit = takeProfit, loss = stopLoss, comment_loss = "SL", comment_profit = "TP", alert_message = i_apiExitLong)    strategy.entry(tradeID + "S", strategy.short, qty = quantity, stop = sellStopPrice, comment = "Short: " + tradeID, alert_message = i_apiEnterShort)    strategy.exit(tradeID + "SL", tradeID + "S", profit = takeProfit, loss = stopLoss, comment_loss = "SL", comment_profit = "TP", alert_message = i_apiExitShort)// once the session is gone, reset prices and cancel all remaining pending orders, close open ordersif barstate.isconfirmed and not inTradingTime and inTradingTime[1]    buyStopPrice    := na    sellStopPrice   := na    openingHigh     := na    openingLow      := na    strategy.cancel_all()    currentTradeID = str.tostring(strategy.closedtrades + strategy.opentrades)    strategy.close(currentTradeID + "L", immediately = true, comment = "L: session end", alert_message = i_apiExitLong)    strategy.close(currentTradeID + "S", immediately = true, comment = "S: session end", alert_message = i_apiExitShort)// as soon as the first pending order has been entered the remaing pending order shall be cancelled if strategy.opentrades > 0 and closePending    currentTradeID = str.tostring(strategy.closedtrades + strategy.opentrades)    strategy.cancel(currentTradeID + "L")    strategy.cancel(currentTradeID + "S")