Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

GRID SPOT TRADING ALGORITHM - GRID BOT TRADING STRATEGY

A Pine Script v5 strategy built on RSI (close, 14). It has 47 order rules and no entry of its own. Exits use a profit target and no stop loss. Each trade commits 1% of equity and pays 0.10% commission. 12 settings; defaults include Start date: 1, Start month: 1 and Start year: 2022.

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 GRID SPOT TRADING ALGORITHM - GRID BOT TRADING STRATEGY repaint?
Yes
At least one pattern in the source can repaint: intrabar recalculation.
How did GRID SPOT TRADING ALGORITHM - GRID BOT TRADING STRATEGY 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 date window, which can leave this period out. It closed no trades on the other markets either. A backtest, not investment advice.
Does GRID SPOT TRADING ALGORITHM - GRID BOT TRADING STRATEGY run in Pine Script v6?
No
The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L224:C3: cannot use 'float' as a condition — Pine Script v6 does not cast 'int' or 'float' to 'bool' implicitly. Wrap it in bool(). The v6 version is shown for reference and is not offered as a download.
Does GRID SPOT TRADING ALGORITHM - GRID BOT TRADING STRATEGY use a stop loss?
No
Its exits set a profit target but no stop.
Does GRID SPOT TRADING ALGORITHM - GRID BOT TRADING STRATEGY run in Zeal Terminal?
Yes
It compiles in 198 ms and runs 1,000 bars in 297 ms, in the browser.

BTCUSDT · 1D · default settings

  • 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 (12)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOctRSI$10,000$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. The script plots nothing itself; the lines and the lower pane are its own calculations, drawn for reference. Zeal Terminal's engine currently reads an order side written as direction = strategy.long as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 209, 210, 211, 212, 213, 265 and more) so the engine trades the way the script says.
Table drawn by the script, as it stood on the last bar
Developed by The Quant Science™
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, $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.

  • Check

    No stop loss

    strategy.exit is used without a stop, loss or trailing stop.

  • Check

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • 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
BACKTESTING PERIOD
Start date: 1int · min 1 · max 31inDateRange
Start month: 1int · min 1 · max 12inDateRange
Start year: 2022int · min 1800 · max 2100inDateRange
End date: 31int · min 1 · max 31inDateRange
End month: 12int · min 1 · max 12inDateRange
End year: 2022int · min 1800 · max 2100inDateRange
HIGH PRICE GRID
High price: Top grid price.0.00pricegrid_range grid_1 grid_2 grid_3 grid_4 grid_5 grid_6 grid_7 grid_8 grid_9 grid_10 grid_11 grid_12 grid_13 grid_14 grid_15 grid_16 grid_17 grid_18 grid_19
LOW PRICE GRID
Low price: Bottom grid price.0.00pricegrid_range grid_10 grid_20 last_long
GRID CONFIGURATION
Grid: 10Create a 10 levels grid.falseboolcancel O #1 cancel O #2 cancel O #3 cancel O #4 cancel O #5 exit C #1 exit C #2 exit C #3 exit C #4 line 123 line 206 line 214 line 216 line 218 line 220 line 222 line 224 line 231 line 238 line 245 line 259 line 380 line 393
Grid: 20Create a 20 levels grid.falseboolcancel O #1 cancel O #2 cancel O #3 cancel O #4 cancel O #5 cancel O #6 cancel O #7 cancel O #8 cancel O #9 cancel O #10 exit C #1 exit C #2 exit C #3 exit C #4 exit C #5 exit C #6 exit C #7 exit C #8 exit C #9 exit C #10 line 136 line 262 line 275 line 277 line 279 line 281 line 283 line 285 line 287 line 289 line 291 line 293 line 295 line 302 line 309 line 316 line 323 line 330 line 337 line 344 line 351 line 358 line 365 line 456 line 479
STOP LOSS CONFIGURATION
Active grid destroyerDestroy the grid when price crossunder the stop loss level.falseboolline 259 line 365 line 391 line 404 line 477 line 500
Destroy level: Stop loss price level. Always set this value below the low price grid.0.00pricegrid_destroyed_ten grid_destroyed_twenty close_all Grid Destroyed !!! close_all Grid Destroyed !!! line 260 line 366

What it calculates

  • RSIclose, 14rsi · line 191

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

Order rules

OrderFires whenBy defaultLine
order O #1 longtrigger_entry and strategy.opentrades == 0On209
order O #2 longtrigger_entry and strategy.opentrades == 0On210
order O #3 longtrigger_entry and strategy.opentrades == 0On211
order O #4 longtrigger_entry and strategy.opentrades == 0On212
order O #5 longtrigger_entry and strategy.opentrades == 0On213
cancel O #1close < grid_6 and ten_grid == trueOn215
cancel O #2close < grid_7 and ten_grid == trueOn217
cancel O #3close < grid_8 and ten_grid == trueOn219
cancel O #4close < grid_9 and ten_grid == trueOn221
cancel O #5close < grid_10 and ten_grid == trueOn223
Exit C #1 limitgrid_5 and ten_grid == trueOn225
Exit C #2 limitgrid_4 and ten_grid == trueOn232
Exit C #3 limitgrid_3 and ten_grid == trueOn239
Exit C #4 limitgrid_2 and ten_grid == trueOn246
Exit C #5 limitgrid_1On253
Close Grid Destroyed !!! ta.crossunder(low, stop_level)On261
order O #1 longtrigger_entry and strategy.opentrades == 0On265
order O #2 longtrigger_entry and strategy.opentrades == 0On266
order O #3 longtrigger_entry and strategy.opentrades == 0On267
order O #4 longtrigger_entry and strategy.opentrades == 0On268
order O #5 longtrigger_entry and strategy.opentrades == 0On269
order O #6 longtrigger_entry and strategy.opentrades == 0On270
order O #7 longtrigger_entry and strategy.opentrades == 0On271
order O #8 longtrigger_entry and strategy.opentrades == 0On272
order O #9 longtrigger_entry and strategy.opentrades == 0On273
order O #10 longtrigger_entry and strategy.opentrades == 0On274
cancel O #1close < grid_11 and tewnty_grid == trueOn276
cancel O #2close < grid_12 and tewnty_grid == trueOn278
cancel O #3close < grid_13 and tewnty_grid == trueOn280
cancel O #4close < grid_14 and tewnty_grid == trueOn282
cancel O #5close < grid_15 and tewnty_grid == trueOn284
cancel O #6close < grid_16 and tewnty_grid == trueOn286
cancel O #7close < grid_17 and tewnty_grid == trueOn288
cancel O #8close < grid_18 and tewnty_grid == trueOn290
cancel O #9close < grid_19 and tewnty_grid == trueOn292
cancel O #10close < grid_20 and tewnty_grid == trueOn294
Exit C #1 limitgrid_10 and tewnty_grid == trueOn296
Exit C #2 limitgrid_9 and tewnty_grid == trueOn303
Exit C #3 limitgrid_8 and tewnty_grid == trueOn310
Exit C #4 limitgrid_7 and tewnty_grid == trueOn317
Exit C #5 limitgrid_6 and tewnty_grid == trueOn324
Exit C #6 limitgrid_5 and tewnty_grid == trueOn331
Exit C #7 limitgrid_4 and tewnty_grid == trueOn338
Exit C #8 limitgrid_3 and tewnty_grid == trueOn345
Exit C #9 limitgrid_2 and tewnty_grid == trueOn352
Exit C #10 limitgrid_1 and tewnty_grid == trueOn359
Close Grid Destroyed !!! ta.crossunder(low, stop_level)On367

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 measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • 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
GRID SPOT TRADING ALGORITHM - GRID BOT TRADING STRATEGY this page—v5 strategy0.0%00.0%
Triple RSI strategy by Trade_by_DBrsiv5 strategy+3.2%23.3%
Hobbiecode - RSI + Close previous day by hobbiecodersiv5 strategy+1.2%634.2%
dirt cheap yet elegant RSI Strategy by SparkyFlaryrsiv4 strategy−11.4%820.5%
RSI Classic Strategy (by Coinrule) by Coinrulersiv4 strategy+7.5%67.2%
RSITrendStrategy by email_analystsrsiv4 strategy+69.2%2238.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?

No

The v6 version does not run in Zeal Terminal's engine: Pine Script v6 Error at @L224:C3: cannot use 'float' as a condition — Pine Script v6 does not cast 'int' or 'float' to 'bool' implicitly. Wrap it in bool(). The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯initial_grid_amount = 10000-//@version=5+//@version=6strategy(⋯

Where it runs

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

Zeal Terminal's engine currently reads an order side written as direction = strategy.long as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 209, 210, 211, 212, 213, 265 and more) so the engine trades the way the script says.

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

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/// © thequantscience//  ██████╗ ██████╗ ██╗██████╗     ███████╗██████╗  ██████╗ ████████╗     █████╗ ██╗      ██████╗  ██████╗ ██████╗ ██╗████████╗██╗  ██╗███╗   ███╗//  ██╔════╝ ██╔══██╗██║██╔══██╗    ██╔════╝██╔══██╗██╔═══██╗╚══██╔══╝    ██╔══██╗██║     ██╔════╝ ██╔═══██╗██╔══██╗██║╚══██╔══╝██║  ██║████╗ ████║//  ██║  ███╗██████╔╝██║██║  ██║    ███████╗██████╔╝██║   ██║   ██║       ███████║██║     ██║  ███╗██║   ██║██████╔╝██║   ██║   ███████║██╔████╔██║//  ██║   ██║██╔══██╗██║██║  ██║    ╚════██║██╔═══╝ ██║   ██║   ██║       ██╔══██║██║     ██║   ██║██║   ██║██╔══██╗██║   ██║   ██╔══██║██║╚██╔╝██║//  ╚██████╔╝██║  ██║██║██████╔╝    ███████║██║     ╚██████╔╝   ██║       ██║  ██║███████╗╚██████╔╝╚██████╔╝██║  ██║██║   ██║   ██║  ██║██║ ╚═╝ ██║//   ╚═════╝ ╚═╝  ╚═╝╚═╝╚═════╝     ╚══════╝╚═╝      ╚═════╝    ╚═╝       ╚═╝  ╚═╝╚══════╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚═╝   ╚═╝   ╚═╝  ╚═╝╚═╝     ╚═╝                                                                                                                                               initial_grid_amount = 10000//@version=5strategy(     title = 'Grid Spot Trading Algorithm - The Quant Science™',      overlay = true,     calc_on_every_tick = true,     initial_capital = initial_grid_amount,      commission_type = strategy.commission.percent,      commission_value = 0.10,      pyramiding = 20,     default_qty_type = strategy.percent_of_equity,     close_entries_rule = 'ANY'     )/////////////////////////////// Design by The Quant Science ™  //////////////////////////////////////----------------------------------------------------------------------------------------------------------//------------------------------------- Grid Spot Trading Algorithm ----------------------------------------//----------------------------------------------------------------------------------------------------------// HOW IT WORKS: 3Commas Grid Bot Strategy for spot asset, based on multiple dinamic trigger start condition.//----------------------------------------------------------------------------------------------------------// SET UP: Select the high price, select the low price, select the trigger entry condition. // Extra feature: adjust date range.//----------------------------------------------------------------------------------------------------------// Upgrade 2.00 (2022.30.07) // Upgrade 3.00 (2022.11.11)// Upgrade 4.00 (2022.20.01)/////////////////////////////// ALGORITHM BACKTEST SOURCE CODE ////////////////////////////////////startDate = input.int(title="Start date: ",     defval=1, minval=1, maxval=31,           group = '############# BACKTESTING PERIOD #############')startMonth = input.int(title="Start month: ",     defval=1, minval=1, maxval=12,           group = '############# BACKTESTING PERIOD #############')startYear = input.int(title="Start year: ",     defval=2022, minval=1800, maxval=2100,           group = '############# BACKTESTING PERIOD #############')endDate = input.int(title="End date: ",     defval=31, minval=1, maxval=31,           group = '############# BACKTESTING PERIOD #############')endMonth = input.int(title="End month: ",     defval=12, minval=1, maxval=12,           group = '############# BACKTESTING PERIOD #############')endYear = input.int(title="End year: ",     defval=2022, minval=1800, maxval=2100,           group = '############# BACKTESTING PERIOD #############')inDateRange = (time >= timestamp(syminfo.timezone, startYear,         startMonth, startDate, 0, 0)) and     (time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0))// #########################################################################################################high_price = input.price(      defval = 0.00,       title = 'High price: ',      group = " ################# HIGH PRICE GRID ################ ",       confirm = true,      tooltip = "Top grid price."      )low_price = input.price(      defval = 0.00,       title = 'Low price: ',      group = " ################# LOW PRICE GRID ################# ",       confirm = true,      tooltip = "Bottom grid price."      )ten_grid = input.bool(     defval = false,     title = "Grid: 10",     group = " ############## GRID CONFIGURATION ############## ",     tooltip = "Create a 10 levels grid.",     confirm = true     )tewnty_grid = input.bool(     defval = false,     title = "Grid: 20",     group = " ############## GRID CONFIGURATION ############## ",     tooltip = "Create a 20 levels grid.",     confirm = true     )grid_destroyer = input.bool(     defval = false,     title = "Active grid destroyer",     group = " ############ STOP LOSS CONFIGURATION ############ ",     tooltip = "Destroy the grid when price crossunder the stop loss level.",     confirm = false     )stop_level = input.price(      defval = 0.00,       title = 'Destroy level: ',      group = " ############ STOP LOSS CONFIGURATION ############ ",       confirm = false,      tooltip = "Stop loss price level. Always set this value below the low price grid."      )// #########################################################################################################grid_range = high_price - low_pricevar float grid_1 = 0var float grid_2 = 0var float grid_3 = 0var float grid_4 = 0var float grid_5 = 0var float grid_6 = 0var float grid_7 = 0var float grid_8 = 0var float grid_9 = 0var float grid_10 = 0var float grid_11 = 0var float grid_12 = 0var float grid_13 = 0var float grid_14 = 0var float grid_15 = 0var float grid_16 = 0var float grid_17 = 0var float grid_18 = 0var float grid_19 = 0var float grid_20 = 0var float factor = 0 if ten_grid == true    factor := grid_range / 9    grid_1 := (high_price)     grid_2 := (high_price - (factor * 1))     grid_3 := (high_price - (factor * 2))     grid_4 := (high_price - (factor * 3))     grid_5 := (high_price - (factor * 4))     grid_6 := (high_price - (factor * 5))     grid_7 := (high_price - (factor * 6))     grid_8 := (high_price - (factor * 7))     grid_9 := (high_price - (factor * 8))    grid_10 := (low_price)    if tewnty_grid == true    factor := grid_range / 19    grid_1 := (high_price)     grid_2 := (high_price - (factor * 1))     grid_3 := (high_price - (factor * 2))     grid_4 := (high_price - (factor * 3))     grid_5 := (high_price - (factor * 4))     grid_6 := (high_price - (factor * 5))     grid_7 := (high_price - (factor * 6))     grid_8 := (high_price - (factor * 7))     grid_9 := (high_price - (factor * 8))     grid_10 := (high_price - (factor * 9))     grid_11 := (high_price - (factor * 10))     grid_12 := (high_price - (factor * 11))     grid_13 := (high_price - (factor * 12))     grid_14 := (high_price - (factor * 13))     grid_15 := (high_price - (factor * 14))     grid_16 := (high_price - (factor * 15))     grid_17 := (high_price - (factor * 16))     grid_18 := (high_price - (factor * 17))     grid_19 := (high_price - (factor * 18))    grid_20 := (low_price)// #########################################################################################################var tb = table.new(position.bottom_left, 1, 1, bgcolor = color.new(color.blue, 90))if barstate.isfirst    table.cell(tb, 0, 0,       'Developed by The Quant Science™'      ,text_size = size.normal      ,text_color = color.new(color.blue, 20))// #########################################################################################################long_1 = ta.crossunder(low, grid_1) and inDateRangelong_2 = ta.crossunder(low, grid_2) and inDateRangelong_3 = ta.crossunder(low, grid_3) and inDateRangelong_4 = ta.crossunder(low, grid_4) and inDateRangelong_5 = ta.crossunder(low, grid_5) and inDateRangelong_6 = ta.crossunder(low, grid_6) and inDateRangelong_7 = ta.crossunder(low, grid_7) and inDateRangelong_8 = ta.crossunder(low, grid_8) and inDateRangelong_9 = ta.crossunder(low, grid_9) and inDateRangelong_10 = ta.crossunder(low, grid_10) and inDateRangelong_11 = ta.crossunder(low, grid_11) and inDateRangelong_12 = ta.crossunder(low, grid_12) and inDateRangelong_13 = ta.crossunder(low, grid_13) and inDateRangelong_14 = ta.crossunder(low, grid_14) and inDateRangelong_15 = ta.crossunder(low, grid_15) and inDateRangelong_16 = ta.crossunder(low, grid_16) and inDateRangelong_17 = ta.crossunder(low, grid_17) and inDateRangelong_18 = ta.crossunder(low, grid_18) and inDateRangelong_19 = ta.crossunder(low, grid_19) and inDateRangelast_long = ta.crossunder(low, low_price) and inDateRange// #########################################################################################################// Change the default trigger start condition with your personal and custom start condition// Code the condition inside the local function below. // Define a indicator condition or another specific condition .....// Example with RSI calculating on close bar, and last 14 previous bar data rsi = ta.rsi(close, 14)// Create a local function for the trigger start condition TriggerGrid() =>    trigger_rsi = ta.crossover(rsi, 75) and inDateRange // Define the specific condition     trigger_rsi trigger_entry = TriggerGrid() // Assign the condition to the "trigger_entry" variable// ANOTHER EASY EXAMPLE WITH OVERSOLD RSI CONDITION ....//TriggerGrid() =>        //trigger_rsi = ta.crossunder(rsi, 35) // Crossunder the RSI 35 value...        //trigger_rsi //trigger_entry = TriggerGrid() // Assign the condition to the "trigger_entry" variable// #########################################################################################################var float lots = 0 if ten_grid == true and inDateRange    lots := (initial_grid_amount / close) / 10    if trigger_entry and strategy.opentrades == 0         strategy.order(id = "O #1", direction = strategy.long, qty = lots, limit = grid_6)        strategy.order(id = "O #2", direction = strategy.long, qty = lots, limit = grid_7)        strategy.order(id = "O #3", direction = strategy.long, qty = lots, limit = grid_8)        strategy.order(id = "O #4", direction = strategy.long, qty = lots, limit = grid_9)        strategy.order(id = "O #5", direction = strategy.long, qty = lots, limit = grid_10)if close < grid_6 and ten_grid == true    strategy.cancel("O #1")if close < grid_7 and ten_grid == true    strategy.cancel("O #2")if close < grid_8 and ten_grid == true    strategy.cancel("O #3")if close < grid_9 and ten_grid == true    strategy.cancel("O #4")if close < grid_10 and ten_grid == true    strategy.cancel("O #5")if grid_5 and ten_grid == true    strategy.exit(           id = "C #1",            from_entry = "O #1",           qty = 100,            limit = grid_5           )if grid_4 and ten_grid == true    strategy.exit(           id = "C #2",            from_entry = "O #2",           qty = 100,            limit = grid_4           )if grid_3 and ten_grid == true    strategy.exit(           id = "C #3",            from_entry = "O #3",           qty = 100,            limit = grid_3           )if grid_2 and ten_grid == true    strategy.exit(           id = "C #4",            from_entry = "O #4",           qty = 100,            limit = grid_2           )if grid_1    strategy.exit(           id = "C #5",            from_entry = "O #5",           qty = 100,            limit = grid_1           )if ten_grid == true and grid_destroyer == true     if ta.crossunder(low, stop_level)        strategy.close_all(" Grid Destroyed !!! ") if tewnty_grid == true and inDateRange    lots := (initial_grid_amount / close) / 20    if trigger_entry and strategy.opentrades == 0         strategy.order(id = "O #1", direction = strategy.long, qty = lots, limit = grid_11)        strategy.order(id = "O #2", direction = strategy.long, qty = lots, limit = grid_12)        strategy.order(id = "O #3", direction = strategy.long, qty = lots, limit = grid_13)        strategy.order(id = "O #4", direction = strategy.long, qty = lots, limit = grid_14)        strategy.order(id = "O #5", direction = strategy.long, qty = lots, limit = grid_15)        strategy.order(id = "O #6", direction = strategy.long, qty = lots, limit = grid_16)        strategy.order(id = "O #7", direction = strategy.long, qty = lots, limit = grid_17)        strategy.order(id = "O #8", direction = strategy.long, qty = lots, limit = grid_18)        strategy.order(id = "O #9", direction = strategy.long, qty = lots, limit = grid_19)        strategy.order(id = "O #10", direction = strategy.long, qty = lots, limit = grid_20)if close < grid_11 and tewnty_grid == true    strategy.cancel("O #1")if close < grid_12 and tewnty_grid == true    strategy.cancel("O #2")if close < grid_13 and tewnty_grid == true    strategy.cancel("O #3")if close < grid_14 and tewnty_grid == true    strategy.cancel("O #4")if close < grid_15 and tewnty_grid == true    strategy.cancel("O #5")if close < grid_16 and tewnty_grid == true    strategy.cancel("O #6")if close < grid_17 and tewnty_grid == true    strategy.cancel("O #7")if close < grid_18 and tewnty_grid == true    strategy.cancel("O #8")if close < grid_19 and tewnty_grid == true    strategy.cancel("O #9")if close < grid_20 and tewnty_grid == true    strategy.cancel("O #10")if grid_10 and tewnty_grid == true    strategy.exit(           id = "C #1",            from_entry = "O #1",           qty = 100,            limit = grid_10           )if grid_9 and tewnty_grid == true    strategy.exit(           id = "C #2",            from_entry = "O #2",           qty = 100,            limit = grid_9           )if grid_8 and tewnty_grid == true    strategy.exit(           id = "C #3",            from_entry = "O #3",           qty = 100,            limit = grid_8           )if grid_7 and tewnty_grid == true    strategy.exit(           id = "C #4",            from_entry = "O #4",           qty = 100,            limit = grid_7           )if grid_6 and tewnty_grid == true    strategy.exit(           id = "C #5",            from_entry = "O #5",           qty = 100,            limit = grid_6           )if grid_5 and tewnty_grid == true    strategy.exit(           id = "C #6",            from_entry = "O #6",           qty = 100,            limit = grid_5           )if grid_4 and tewnty_grid == true    strategy.exit(           id = "C #7",            from_entry = "O #7",           qty = 100,            limit = grid_4           )if grid_3 and tewnty_grid == true    strategy.exit(           id = "C #8",            from_entry = "O #8",           qty = 100,            limit = grid_3           )if grid_2 and tewnty_grid == true    strategy.exit(           id = "C #9",            from_entry = "O #9",           qty = 100,            limit = grid_2           )if grid_1 and tewnty_grid == true    strategy.exit(           id = "C #10",            from_entry = "O #10",           qty = 100,            limit = grid_1           )if tewnty_grid == true and grid_destroyer == true     if ta.crossunder(low, stop_level)        strategy.close_all(" Grid Destroyed !!! ") // #########################################################################################################var float new_ten_grid_1 = 0 var float new_ten_grid_2 = 0 var float new_ten_grid_3 = 0 var float new_ten_grid_4 = 0 var float new_ten_grid_5 = 0 var float new_ten_grid_6 = 0 var float new_ten_grid_7 = 0 var float new_ten_grid_8 = 0 var float new_ten_grid_9 = 0 var float new_ten_grid_10 = 0 var float grid_destroyed_ten = 0 if ten_grid == true    new_ten_grid_1 := grid_1    new_ten_grid_2 := grid_2    new_ten_grid_3 := grid_3    new_ten_grid_4 := grid_4    new_ten_grid_5 := grid_5    new_ten_grid_6 := grid_6    new_ten_grid_7 := grid_7    new_ten_grid_8 := grid_8    new_ten_grid_9 := grid_9    new_ten_grid_10 := grid_10    if grid_destroyer == true         grid_destroyed_ten := stop_levelelse if ten_grid == false    new_ten_grid_1 := na    new_ten_grid_2 := na    new_ten_grid_3 := na    new_ten_grid_4 := na    new_ten_grid_5 := na    new_ten_grid_6 := na    new_ten_grid_7 := na    new_ten_grid_8 := na    new_ten_grid_9 := na    new_ten_grid_10 := na    if grid_destroyer == false         grid_destroyed_ten := nafill(plot(new_ten_grid_1, color = color.new(color.green, 90)),      plot(new_ten_grid_2, color = color.new(color.green, 90)),          color = color.new(color.green, 90))fill(plot(new_ten_grid_2, color = color.new(color.green, 85)),      plot(new_ten_grid_3, color = color.new(color.green, 85)),          color = color.new(color.green, 85))fill(plot(new_ten_grid_3, color = color.new(color.green, 80)),      plot(new_ten_grid_4, color = color.new(color.green, 80)),          color = color.new(color.green, 80))fill(plot(new_ten_grid_4, color = color.new(color.green, 70)),      plot(new_ten_grid_5, color = color.new(color.green, 70)),          color = color.new(color.green, 70))fill(plot(new_ten_grid_5, color = color.new(color.green, 60)),      plot(new_ten_grid_6, color = color.new(color.green, 60)),          color = color.new(color.green, 60))fill(plot(new_ten_grid_6, color = color.new(color.red, 60)),      plot(new_ten_grid_7, color = color.new(color.red, 60)),          color = color.new(color.red, 60))fill(plot(new_ten_grid_7, color = color.new(color.red, 70)),      plot(new_ten_grid_8, color = color.new(color.red, 70)),          color = color.new(color.red, 70))fill(plot(new_ten_grid_8, color = color.new(color.red, 80)),      plot(new_ten_grid_9, color = color.new(color.red, 80)),          color = color.new(color.red, 80))fill(plot(new_ten_grid_9, color = color.new(color.red, 85)),      plot(new_ten_grid_10, color = color.new(color.red, 85)),          color = color.new(color.red, 85))plot(grid_destroyed_ten, color = color.new(color.red, 80), linewidth = 10)// #########################################################################################################var float new_twenty_grid_1 = 0 var float new_twenty_grid_2 = 0 var float new_twenty_grid_3 = 0 var float new_twenty_grid_4 = 0 var float new_twenty_grid_5 = 0 var float new_twenty_grid_6 = 0 var float new_twenty_grid_7 = 0 var float new_twenty_grid_8 = 0 var float new_twenty_grid_9 = 0 var float new_twenty_grid_10 = 0 var float new_twenty_grid_11 = 0 var float new_twenty_grid_12 = 0 var float new_twenty_grid_13 = 0 var float new_twenty_grid_14 = 0 var float new_twenty_grid_15 = 0 var float new_twenty_grid_16 = 0 var float new_twenty_grid_17 = 0 var float new_twenty_grid_18 = 0 var float new_twenty_grid_19 = 0 var float new_twenty_grid_20 = 0 var float grid_destroyed_twenty = 0if tewnty_grid == true    new_twenty_grid_1 := grid_1    new_twenty_grid_2 := grid_2    new_twenty_grid_3 := grid_3    new_twenty_grid_4 := grid_4    new_twenty_grid_5 := grid_5    new_twenty_grid_6 := grid_6    new_twenty_grid_7 := grid_7    new_twenty_grid_8 := grid_8    new_twenty_grid_9 := grid_9    new_twenty_grid_10 := grid_10    new_twenty_grid_11 := grid_11    new_twenty_grid_12 := grid_12    new_twenty_grid_13 := grid_13    new_twenty_grid_14 := grid_14    new_twenty_grid_15 := grid_15    new_twenty_grid_16 := grid_16    new_twenty_grid_17 := grid_17    new_twenty_grid_18 := grid_18    new_twenty_grid_19 := grid_19    new_twenty_grid_20 := grid_20    if grid_destroyer == true         grid_destroyed_twenty := stop_levelelse if tewnty_grid == false    new_twenty_grid_1 := na    new_twenty_grid_2 := na    new_twenty_grid_3 := na    new_twenty_grid_4 := na    new_twenty_grid_5 := na    new_twenty_grid_6 := na    new_twenty_grid_7 := na    new_twenty_grid_8 := na    new_twenty_grid_9 := na    new_twenty_grid_10 := na    new_twenty_grid_11 := na    new_twenty_grid_12 := na    new_twenty_grid_13 := na    new_twenty_grid_14 := na    new_twenty_grid_15 := na    new_twenty_grid_16 := na    new_twenty_grid_17 := na    new_twenty_grid_18 := na    new_twenty_grid_19 := na    new_twenty_grid_20 := na    if grid_destroyer == false         grid_destroyed_twenty := nafill(plot(new_twenty_grid_1, color = color.new(color.green, 90)),      plot(new_twenty_grid_2, color = color.new(color.green, 90)),          color = color.new(color.green, 90))fill(plot(new_twenty_grid_2, color = color.new(color.green, 85)),      plot(new_twenty_grid_3, color = color.new(color.green, 85)),          color = color.new(color.green, 85))fill(plot(new_twenty_grid_3, color = color.new(color.green, 80)),      plot(new_twenty_grid_4, color = color.new(color.green, 80)),          color = color.new(color.green, 80))fill(plot(new_twenty_grid_4, color = color.new(color.green, 70)),      plot(new_twenty_grid_5, color = color.new(color.green, 70)),          color = color.new(color.green, 70))fill(plot(new_twenty_grid_5, color = color.new(color.green, 60)),      plot(new_twenty_grid_6, color = color.new(color.green, 60)),          color = color.new(color.green, 60))fill(plot(new_twenty_grid_6, color = color.new(color.green, 60)),      plot(new_twenty_grid_7, color = color.new(color.green, 60)),          color = color.new(color.green, 60))fill(plot(new_twenty_grid_7, color = color.new(color.green, 70)),      plot(new_twenty_grid_8, color = color.new(color.green, 70)),          color = color.new(color.green, 70))fill(plot(new_twenty_grid_8, color = color.new(color.green, 80)),      plot(new_twenty_grid_9, color = color.new(color.green, 80)),          color = color.new(color.green, 80))fill(plot(new_twenty_grid_9, color = color.new(color.green, 85)),      plot(new_twenty_grid_10, color = color.new(color.green, 85)),          color = color.new(color.green, 85))fill(plot(new_twenty_grid_10, color = color.new(color.red, 90)),      plot(new_twenty_grid_11, color = color.new(color.red, 90)),          color = color.new(color.red, 90))fill(plot(new_twenty_grid_11, color = color.new(color.red, 85)),      plot(new_twenty_grid_12, color = color.new(color.red, 85)),          color = color.new(color.red, 85))fill(plot(new_twenty_grid_12, color = color.new(color.red, 80)),      plot(new_twenty_grid_13, color = color.new(color.red, 80)),          color = color.new(color.red, 80))fill(plot(new_twenty_grid_13, color = color.new(color.red, 70)),      plot(new_twenty_grid_14, color = color.new(color.red, 70)),          color = color.new(color.red, 70))fill(plot(new_twenty_grid_14, color = color.new(color.red, 60)),      plot(new_twenty_grid_15, color = color.new(color.red, 60)),          color = color.new(color.red, 60))fill(plot(new_twenty_grid_15, color = color.new(color.red, 60)),      plot(new_twenty_grid_16, color = color.new(color.red, 60)),          color = color.new(color.red, 60))fill(plot(new_twenty_grid_16, color = color.new(color.red, 70)),      plot(new_twenty_grid_17, color = color.new(color.red, 70)),          color = color.new(color.red, 70))fill(plot(new_twenty_grid_17, color = color.new(color.red, 80)),      plot(new_twenty_grid_18, color = color.new(color.red, 80)),          color = color.new(color.red, 80))fill(plot(new_twenty_grid_18, color = color.new(color.red, 85)),      plot(new_twenty_grid_19, color = color.new(color.red, 85)),          color = color.new(color.red, 85))fill(plot(new_twenty_grid_19, color = color.new(color.red, 85)),      plot(new_twenty_grid_20, color = color.new(color.red, 85)),          color = color.new(color.red, 85))plot(grid_destroyed_twenty, color = color.new(color.red, 80), linewidth = 10)// #########################################################################################################