Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

AUTOMATIC GRID BOT STRATEGY [ilovealgotrading]

A Pine Script v5 strategy with no technical-analysis calculation. It has 62 order rules, 30 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade commits 1% of equity and pays 0.075% commission. 24 settings; defaults include Range High price: 0.00, Range Low price: 0.00 and Trade Direction BOTH.

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 AUTOMATIC GRID BOT STRATEGY [ilovealgotrading] repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did AUTOMATIC GRID BOT STRATEGY [ilovealgotrading] 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 AUTOMATIC GRID BOT STRATEGY [ilovealgotrading] 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 AUTOMATIC GRID BOT STRATEGY [ilovealgotrading] use a stop loss?
Yes
strategy.exit sets a stop on line 213, 283.
Does AUTOMATIC GRID BOT STRATEGY [ilovealgotrading] run in Zeal Terminal?
Yes
It compiles in 287 ms and runs 1,000 bars in 366 ms, in the browser.

BTCUSDT · 1D · default settings

  • Plot
  • Plot
  • Plot
  • Plot
  • Plot
  • Plot
  • Plot
  • Plot
  • Plot
  • Plot
  • Plot
  • Plot
  • Plot
  • Plot
  • Plot
  • Plot
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (24)
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. Lines are what the script plots. The script plots 3 more series than are drawn here. Zeal Terminal's engine currently reads an order side written as direction = strategy.long, direction = strategy.short as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 210, 216, 222, 228, 235, 243 and more) so the engine trades the way the script says.
Table drawn by the script, as it stood on the last bar
Open positionsOpen profitTotal tradesTotal profitCurrent equity
0$00$0$1000
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

    1 setting does nothing

    “Show Stop Price” is declared but never read.

  • Check

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • Note

    6 settings have no label

    In the settings dialog Long_message (line 62), Long_Exit_message (line 63), Long_Stop_message (line 64), Short_message (line 65), Short_Exit_message (line 66), Short_Stop_message (line 67) show an empty name. The labels on this page come from the variable names.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

Settings

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

SettingDefaultType and rangeFeeds
⏰ BACKTEST DATE ⏰
Start_Datetimestamp('1 nov 2022 13:30 +0000')timeinDateRange
End_Datetimestamp('20 oct 2030 13:30 +0000')timeinDateRange
➡️ HIGH GRID PRICE ⬅️
Range High price: Top grid price.0.00pricehigh_price_stop grid_range percent_change 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 line 344 plot
➡️ LOW GRID PRICE ⬅️
Range Low price: Bottom grid price.0.00pricelow_price_stop grid_range percent_change grid_10 grid_20 line 278 plot
🎯 TRADE DIRECTION 🎯
Trade DirectionBOTHstring · options ['LONG', 'SHORT', 'BOTH']line 208 line 241 line 278 line 344
⛔️ Strategy STOP Settings ⛔️
Use StopLossfalseboolclose_all close_all line 340 line 404
Close Bot After Stop LossDont open new positions after stop lossfalseboolline 39
Use StopLoss Where HIGH and LOW GRID PRICEtrueboolline 56
High STOP Price: Top STOP price.99999priceclose_all line 404 plot
Low STOP Price: Bottom STOP price.0.00priceclose_all line 340 plot
🤖 ALGO TRADE ALERTS 🤖
$ Per Position100intqty_new
Long message (no label in the script)stringentry L_1 entry L_2 entry L_3 entry L_4 entry L_5 entry L_6 entry L_7 entry L_8 entry L_9 entry L_10
Long Exit message (no label in the script)stringexit E_1 exit E_2 exit E_3 exit E_4 exit E_5 exit E_6 exit E_7 exit E_8 exit E_9 exit E_10
Long Stop message (no label in the script)stringclose_all
Short message (no label in the script)stringentry S_1 entry S_2 entry S_3 entry S_4 entry S_5 entry S_6 entry S_7 entry S_8 entry S_9 entry S_10
Short Exit message (no label in the script)stringexit ES_1 exit ES_2 exit ES_3 exit ES_4 exit ES_5 exit ES_6 exit ES_7 exit ES_8 exit ES_9 exit ES_10
Short Stop message (no label in the script)stringclose_all
GRID CONFIGURATION
10 grid levels10 grid levelsfalseboolline 140 line 208 line 241 line 428 line 439
20 grid levels20 grid levelstrueboolline 163 line 278 line 344 line 498 line 519
📈 Graphics Settings 📈
Show Stop Pricetrueboolunused
Show Grid Levels BGtrueboolline 428 line 498
🔳 TABLE Settings 🔳
Show Tabletrueboolline 606
Table LocationTop Rightstringdashboard_loc
Table SizeNormalstringdashboard_size

What it calculates

No technical-analysis calculation: the script works on prices and settings directly.

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

Order rules

OrderFires whenBy defaultLine
Open L_1 longlong_1 and strategy.opentrades == 0 and inDateRange and stop_close_all == ""On210
Exit E_1 stop and limitstrategy.opentrades == 1On213
Open L_2 longlong_2 and strategy.opentrades == 1 and inDateRange and stop_close_all == ""On216
Exit E_2 limitstrategy.opentrades == 2On219
Open L_3 longlong_3 and strategy.opentrades == 2 and inDateRange and stop_close_all == ""On222
Exit E_3 limitstrategy.opentrades == 3On225
Open L_4 longlong_4 and strategy.opentrades == 3 and inDateRange and stop_close_all == ""On228
Exit E_4 limitstrategy.opentrades == 4On232
Open L_5 longlong_5 and strategy.opentrades == 4 and inDateRange and stop_close_all == ""On235
Exit E_5 limitstrategy.opentrades == 5On238
Open S_1 shortshort_1 and strategy.opentrades == 0 and inDateRange and stop_close_all == ""On243
Exit ES_1 limitstrategy.opentrades == 1On246
Open S_2 shortshort_2 and strategy.opentrades == 1 and inDateRange and stop_close_all == ""On249
Exit ES_2 limitstrategy.opentrades == 2On253
Open S_3 shortshort_3 and strategy.opentrades == 2 and inDateRange and stop_close_all == ""On256
Exit ES_3 limitstrategy.opentrades == 3On259
Open S_4 shortshort_4 and strategy.opentrades == 3 and inDateRange and stop_close_all == ""On262
Exit ES_4 limitstrategy.opentrades == 4On266
Open S_5 shortshort_5 and strategy.opentrades == 4 and inDateRange and stop_close_all == ""On269
Exit ES_5 limitstrategy.opentrades == 5On272
Open L_1 longlong_1 and strategy.opentrades == 0 and inDateRange and stop_close_all == ""On280
Exit E_1 stop and limitstrategy.opentrades == 1On283
Open L_2 longlong_2 and strategy.opentrades == 1 and inDateRange and close < strategy.opentrades.entry_price(strategy.opentrades - 1) * (1-percent_change) and stop_close_all == ""On286
Exit E_2 limitstrategy.opentrades == 2On289
Open L_3 longlong_3 and strategy.opentrades == 2 and inDateRange and close < strategy.opentrades.entry_price(strategy.opentrades - 1) * (1-percent_change) and stop_close_all == ""On292
Exit E_3 limitstrategy.opentrades == 3On295
Open L_4 longlong_4 and strategy.opentrades == 3 and inDateRange and close < strategy.opentrades.entry_price(strategy.opentrades - 1) * (1-percent_change) and stop_close_all == ""On298
Exit E_4 limitstrategy.opentrades == 4On302
Open L_5 longlong_5 and strategy.opentrades == 4 and inDateRange and close < strategy.opentrades.entry_price(strategy.opentrades - 1) * (1-percent_change) and stop_close_all == ""On305
Exit E_5 limitstrategy.opentrades == 5On308
Open L_6 longlong_6 and strategy.opentrades == 5 and inDateRange and close < strategy.opentrades.entry_price(strategy.opentrades - 1) * (1-percent_change) and stop_close_all == ""On311
Exit E_6 limitstrategy.opentrades == 6On314
Open L_7 longlong_7 and strategy.opentrades == 6 and inDateRange and close < strategy.opentrades.entry_price(strategy.opentrades - 1) * (1-percent_change) and stop_close_all == ""On317
Exit E_7 limitstrategy.opentrades == 7On320
Open L_8 longlong_8 and strategy.opentrades == 7 and inDateRange and close < strategy.opentrades.entry_price(strategy.opentrades - 1) * (1-percent_change) and stop_close_all == ""On323
Exit E_8 limitstrategy.opentrades == 8On326
Open L_9 longlong_9 and strategy.opentrades == 8 and inDateRange and close < strategy.opentrades.entry_price(strategy.opentrades - 1) * (1-percent_change) and stop_close_all == ""On329
Exit E_9 limitstrategy.opentrades == 9On332
Open L_10 longlong_10 and strategy.opentrades == 9 and inDateRange and close < strategy.opentrades.entry_price(strategy.opentrades - 1) * (1-percent_change) and stop_close_all == ""On335
Exit E_10 limitstrategy.opentrades == 10On338
Close use_stop and low < low_price_stop and strategy.position_size > 0On341
Open S_1 shortshort_1 and strategy.opentrades == 0 and inDateRange and stop_close_all == ""On346
Exit ES_1 limitstrategy.opentrades == 1On349
Open S_2 shortshort_2 and strategy.opentrades == 1 and inDateRange and close > strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change) and stop_close_all == ""On352
Exit ES_2 limitstrategy.opentrades == 2On355
Open S_3 shortshort_3 and strategy.opentrades == 2 and inDateRange and close > strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change) and stop_close_all == ""On358
Exit ES_3 limitstrategy.opentrades == 3On362
Open S_4 shortshort_4 and strategy.opentrades == 3 and inDateRange and close > strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change) and stop_close_all == ""On365
Exit ES_4 limitstrategy.opentrades == 4On369
Open S_5 shortshort_5 and strategy.opentrades == 4 and inDateRange and close > strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change) and stop_close_all == ""On372
Exit ES_5 limitstrategy.opentrades == 5On375
Open S_6 shortshort_6 and strategy.opentrades == 5 and inDateRange and close > strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change) and stop_close_all == ""On379
Exit ES_6 limitstrategy.opentrades == 6On382
Open S_7 shortshort_7 and strategy.opentrades == 6 and inDateRange and close > strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change) and stop_close_all == ""On385
Exit ES_7 limitstrategy.opentrades == 7On387
Open S_8 shortshort_8 and strategy.opentrades == 7 and inDateRange and close > strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change) and stop_close_all == ""On390
Exit ES_8 limitstrategy.opentrades == 8On392
Open S_9 shortshort_9 and strategy.opentrades == 8 and inDateRange and close > strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change) and stop_close_all == ""On395
Exit ES_9 limitstrategy.opentrades == 9On397
Open S_10 shortshort_10 and strategy.opentrades == 9 and inDateRange and close > strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change) and stop_close_all == ""On400
Exit ES_10 limitstrategy.opentrades == 10On402
Close use_stop and high > high_price_stop and strategy.position_size < 0On405

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

Does it repaint?

No

No repainting patterns in the source.

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].
  • ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
  • ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.

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

Other markets

The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 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

No other indicator or strategy here shares enough of its calculations.

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.

  • 6 settings use the untyped input() (line 62, 63, 64, 65, 66, 67). 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

Neither version placed a trade on any of the 8 markets, so there was nothing to compare.

  • Line 62: input() → input.string()
  • Line 63: input() → input.string()
  • Line 64: input() → input.string()
  • Line 65: input() → input.string()
  • Line 66: input() → input.string()
  • Line 67: input() → input.string()
⋯// ###########################################################################################-Long_message = input("", group = " ############# 🤖 ALGO TRADE ALERTS 🤖 ############ ")+Long_message = input.string("", group = " ############# 🤖 ALGO TRADE ALERTS 🤖 ############ ")-Long_Exit_message = input("", group = " ############# 🤖 ALGO TRADE ALERTS 🤖 ############ ")+Long_Exit_message = input.string("", group = " ############# 🤖 ALGO TRADE ALERTS 🤖 ############ ")-Long_Stop_message = input("", group = " ############# 🤖 ALGO TRADE ALERTS 🤖 ############ ")+Long_Stop_message = input.string("", group = " ############# 🤖 ALGO TRADE ALERTS 🤖 ############ ")-Short_message = input("", group = " ############# 🤖 ALGO TRADE ALERTS 🤖 ############ ")+Short_message = input.string("", group = " ############# 🤖 ALGO TRADE ALERTS 🤖 ############ ")-Short_Exit_message = input("", group = " ############# 🤖 ALGO TRADE ALERTS 🤖 ############ ")+Short_Exit_message = input.string("", group = " ############# 🤖 ALGO TRADE ALERTS 🤖 ############ ")-Short_Stop_message = input("", group = " ############# 🤖 ALGO TRADE ALERTS 🤖 ############ ")+Short_Stop_message = input.string("", group = " ############# 🤖 ALGO TRADE ALERTS 🤖 ############ ")// ###########################################################################################⋯

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.

⋯// First of all I want to say thank you to © thequantscience. -//@version=5+//@version=6strategy(⋯

Where it runs

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

Zeal Terminal's engine currently reads an order side written as direction = strategy.long, direction = strategy.short as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 210, 216, 222, 228, 235, 243 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/// © lovealgotrading// First of all I want to say thank you to © thequantscience. //@version=5strategy(     title = 'AUTOMATIC GRID BOT STRATEGY [lovealgotrading]',      overlay = true,     commission_type = strategy.commission.percent,      commission_value = 0.075,      pyramiding = 20,     default_qty_type = strategy.percent_of_equity,     close_entries_rule = 'ANY',     initial_capital = 1000     )/////////////////////////////// ALGORITHM BACKTEST SOURCE CODE ////////////////////////////////////startDate  = input.time(defval=timestamp('1 nov 2022 13:30 +0000'), title='Start_Date', group = " ############# ⏰ BACKTEST DATE ⏰ ############ " )endDate = input.time(defval=timestamp('20 oct  2030 13:30 +0000'), title='End_Date', group = " ############# ⏰ BACKTEST DATE ⏰ ############ " )inDateRange  = time > startDate  and time < endDatehigh_price = input.price(      defval = 0.00,       title = 'Range High price: ',      group = " ############## ➡️ HIGH GRID PRICE  ⬅️ ############ ",       confirm = true,      tooltip = "Top grid price."      )low_price = input.price(      defval = 0.00,       title = 'Range Low price: ',      group = " ############## ➡️ LOW GRID PRICE  ⬅️ ############# ",       confirm = true,      tooltip = "Bottom grid price."      )// ###########################################################################################trade_direction = input.string(title='Trade Direction', group = " ##############🎯 TRADE DIRECTION 🎯############# ", options=['LONG', 'SHORT', 'BOTH'], defval='BOTH')// ###########################################################################################use_stop = input.bool(defval = false , title = "Use StopLoss", group = " ############# ⛔️ Strategy STOP Settings ⛔️ ############ ")close_bot_after_stop = input.bool(defval = false , title = "Close Bot After Stop Loss",tooltip = "Dont open new positions after stop loss", group = " ############# ⛔️ Strategy STOP Settings ⛔️ ############ ")stop_close_all = ""if stop_close_all[1] != "" and close_bot_after_stop    stop_close_all := "DONT"use_stop_default = input.bool(defval = true , title = "Use StopLoss Where HIGH and LOW GRID PRICE", group = " ############# ⛔️ Strategy STOP Settings ⛔️ ############ ")high_price_stop = input.price(      defval = 99999,       title = 'High STOP Price: ',      group =  " ############# ⛔️ Strategy STOP Settings ⛔️ ############ ",       confirm = false,      tooltip = "Top STOP price."      )low_price_stop = input.price(      defval = 0.00,       title = 'Low STOP Price: ',      group =  " ############# ⛔️ Strategy STOP Settings ⛔️ ############ ",       confirm = false,      tooltip = "Bottom STOP price."      )if use_stop_default     high_price_stop := high_price    low_price_stop := low_price// ###########################################################################################dolar = input.int(defval = 100, title = "$ Per Position", group = " ############# 🤖 ALGO TRADE ALERTS 🤖 ############ ")// ###########################################################################################Long_message = input("", group = " ############# 🤖 ALGO TRADE ALERTS 🤖 ############ ")Long_Exit_message = input("", group = " ############# 🤖 ALGO TRADE ALERTS 🤖 ############ ")Long_Stop_message = input("", group = " ############# 🤖 ALGO TRADE ALERTS 🤖 ############ ")Short_message = input("", group = " ############# 🤖 ALGO TRADE ALERTS 🤖 ############ ")Short_Exit_message = input("", group = " ############# 🤖 ALGO TRADE ALERTS 🤖 ############ ")Short_Stop_message = input("", group = " ############# 🤖 ALGO TRADE ALERTS 🤖 ############ ")// ###########################################################################################float qty_new = dolar / close if close > 5000     qty_new :=  math.round(dolar / close, 3)else if close < 5000 and close > 200    qty_new :=  math.round(dolar / close, 2)else if close < 200 and close > 50    qty_new :=  math.round(dolar / close, 1)else if close < 50    qty_new :=  math.round(dolar / close, 0)// ###########################################################################################ten_grid = input.bool(     defval = false,     title = "10 grid levels",     group = " ############ GRID CONFIGURATION ############ ",     tooltip = "10 grid levels",     confirm = true     )tewnty_grid = input.bool(     defval = true,     title = "20 grid levels",     group = " ############ GRID CONFIGURATION ############ ",     tooltip = "20 grid levels",     confirm = true     )// ###########################################################################################show_stop_res = input.bool(true, title = "Show Stop Price",group = " ############# 📈 Graphics Settings 📈 ########### ")show_grid_level_bg = input.bool(true, title = "Show Grid Levels BG",group = " ############# 📈 Graphics Settings 📈 ########### ")// ###########################################################################################grid_range = high_price - low_pricepercent_change = ((high_price - low_price) / low_price) * (1.00 / 9.00)var 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 long_1 = falselong_2 = falselong_3 = falselong_4 = falselong_5 = falselong_6 = falselong_7 = falselong_8 = falselong_9 = falselong_10 = falseshort_1 = falseshort_2 = falseshort_3 = falseshort_4 = falseshort_5 = falseshort_6 = falseshort_7 = falseshort_8 = falseshort_9 = falseshort_10 = falseif ten_grid == true    percent_change := ((high_price - low_price) / low_price) * (1.00 / 9.00)    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)    long_1 := ta.crossunder(close, ((grid_5+grid_6)/2))     long_2 := ta.crossunder(close, ((grid_6+grid_7)/2))     long_3 := ta.crossunder(close, ((grid_7+grid_8)/2))     long_4 := ta.crossunder(close, ((grid_8+grid_9)/2))     long_5 := ta.crossunder(close, ((grid_9+grid_10)/2))     short_1 := ta.crossover(close, ((grid_6+grid_5)/2))    short_2 := ta.crossover(close, ((grid_5+grid_4)/2))    short_3 := ta.crossover(close, ((grid_4+grid_3)/2))    short_4 := ta.crossover(close, ((grid_3+grid_2)/2))    short_5 := ta.crossover(close, ((grid_2+grid_1)/2))if tewnty_grid == true    percent_change := ((high_price - low_price) / low_price) * (1.00 / 19.00)    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)    long_1 := close < ((grid_10+grid_11)/2)    long_2 := close < ((grid_11+grid_12)/2)    long_3 := close < ((grid_12+grid_13)/2)    long_4 := close < ((grid_13+grid_14)/2)    long_5 := close < ((grid_14+grid_15)/2)     long_6 := close < ((grid_15+grid_16)/2)     long_7 := close < ((grid_16+grid_17)/2)     long_8 := close < ((grid_17+grid_18)/2)     long_9 := close < ((grid_18+grid_19)/2)     long_10 := close < ((grid_19+grid_20)/2)     short_10 := close >((grid_1+grid_2)/2)    short_9 := close >((grid_2+grid_3)/2)    short_8 := close >((grid_3+grid_4)/2)    short_7 := close >((grid_4+grid_5)/2)    short_6 := close >((grid_5+grid_6)/2)    short_5 := close >((grid_6+grid_7)/2)    short_4 := close >((grid_7+grid_8)/2)    short_3 := close >((grid_8+grid_9)/2)    short_2 := close >((grid_9+grid_10)/2)    short_1 := close > ((grid_10+grid_11)/2)// ###########################################################################################// ###########################################################################################if ten_grid and ( trade_direction == 'LONG' or trade_direction == 'BOTH')    if long_1 and strategy.opentrades == 0  and inDateRange  and stop_close_all == ""        strategy.entry(id = "L_1",  direction =   strategy.long,alert_message = Long_message,  qty = qty_new   )             if strategy.opentrades == 1         strategy.exit(id = "E_1",from_entry = "L_1", qty_percent = 100,alert_message =Long_Exit_message,stop = 0, limit = strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))               if long_2 and strategy.opentrades == 1  and inDateRange    and stop_close_all == ""        strategy.entry(id = "L_2",   direction =   strategy.long,alert_message = Long_message,  qty = qty_new  )                       if strategy.opentrades == 2        strategy.exit(id = "E_2",from_entry = "L_2", qty_percent = 100,alert_message =Long_Exit_message, limit = strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))               if long_3 and strategy.opentrades == 2  and inDateRange  and stop_close_all == ""        strategy.entry(id = "L_3",  direction =   strategy.long,alert_message = Long_message, qty = qty_new  )                        if strategy.opentrades == 3        strategy.exit(id = "E_3",from_entry = "L_3", qty_percent = 100,alert_message =Long_Exit_message,limit = strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))                if long_4 and strategy.opentrades == 3  and inDateRange    and stop_close_all == ""        strategy.entry(id = "L_4",  direction =   strategy.long,alert_message = Long_message, qty = qty_new  )                                    if strategy.opentrades == 4        strategy.exit(id = "E_4",from_entry = "L_4", qty_percent = 100,alert_message =Long_Exit_message,limit = strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))                if long_5 and strategy.opentrades == 4  and inDateRange  and stop_close_all == ""        strategy.entry(id = "L_5",   direction =   strategy.long,alert_message = Long_message,  qty = qty_new  )                       if strategy.opentrades == 5        strategy.exit(id = "E_5",from_entry = "L_5", qty_percent = 100,alert_message =Long_Exit_message, limit = strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))    // ###########################################################################################if ten_grid and ( trade_direction == 'SHORT' or trade_direction == 'BOTH')    if short_1 and strategy.opentrades == 0  and inDateRange   and stop_close_all == ""        strategy.entry(id = "S_1",  direction =  strategy.short,alert_message = Short_message, qty = qty_new   )                            if strategy.opentrades == 1        strategy.exit(id = "ES_1",from_entry = "S_1", qty_percent = 100,alert_message =Short_Exit_message, limit = strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))                if short_2 and strategy.opentrades == 1  and inDateRange   and stop_close_all == ""        strategy.entry(id = "S_2",direction =  strategy.short,alert_message = Short_message,  qty = qty_new   )                                if strategy.opentrades == 2        strategy.exit(id = "ES_2",from_entry = "S_2", qty_percent = 100,alert_message =Short_Exit_message, limit = strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))                if short_3 and strategy.opentrades == 2  and inDateRange   and stop_close_all == ""        strategy.entry(id = "S_3",   direction =  strategy.short,alert_message = Short_message,  qty = qty_new   )                                   if strategy.opentrades == 3         strategy.exit(id = "ES_3",from_entry = "S_3", qty_percent = 100,alert_message =Short_Exit_message, limit = strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))                if short_4 and strategy.opentrades == 3  and inDateRange   and stop_close_all == ""        strategy.entry(id = "S_4",   direction =  strategy.short,alert_message = Short_message, qty = qty_new    )                                        if strategy.opentrades == 4         strategy.exit(id = "ES_4",from_entry = "S_4", qty_percent = 100,alert_message =Short_Exit_message,limit = strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))                if short_5 and strategy.opentrades == 4  and inDateRange   and stop_close_all == ""        strategy.entry(id = "S_5",  direction =  strategy.short,alert_message = Short_message,  qty = qty_new   )                        if strategy.opentrades == 5         strategy.exit(id = "ES_5",from_entry = "S_5", qty_percent = 100,alert_message =Short_Exit_message, limit = strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))    // ###########################################################################################// ###########################################################################################long_exit_price = str.tostring(math.round_to_mintick(close*(1+percent_change)))short_exit_price = str.tostring(math.round_to_mintick(close*(1-percent_change))) if  tewnty_grid and close > low_price and ( trade_direction == 'LONG' or trade_direction == 'BOTH')    if long_1 and strategy.opentrades == 0  and inDateRange  and stop_close_all == ""        strategy.entry(id = "L_1",  direction =  strategy.long,alert_message = Long_message,  qty = qty_new    )             if strategy.opentrades == 1         strategy.exit(id = "E_1",from_entry = "L_1", qty_percent = 100,alert_message = Long_Exit_message,stop = 0, limit = strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))               if long_2 and strategy.opentrades == 1  and inDateRange   and close < strategy.opentrades.entry_price(strategy.opentrades - 1) * (1-percent_change) and stop_close_all == ""        strategy.entry(id = "L_2",   direction =  strategy.long,alert_message = Long_message,  qty = qty_new   )                       if strategy.opentrades == 2        strategy.exit(id = "E_2",from_entry = "L_2", qty_percent = 100,alert_message =Long_Exit_message, limit = strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))               if long_3 and strategy.opentrades == 2  and inDateRange   and close < strategy.opentrades.entry_price(strategy.opentrades - 1) * (1-percent_change) and stop_close_all == ""        strategy.entry(id = "L_3",  direction =  strategy.long,alert_message = Long_message, qty = qty_new   )                        if strategy.opentrades == 3        strategy.exit(id = "E_3",from_entry = "L_3", qty_percent = 100,alert_message =Long_Exit_message,limit = strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))                if long_4 and strategy.opentrades == 3  and inDateRange   and close < strategy.opentrades.entry_price(strategy.opentrades - 1) * (1-percent_change) and stop_close_all == ""        strategy.entry(id = "L_4",  direction =  strategy.long,alert_message = Long_message, qty = qty_new   )                                    if strategy.opentrades == 4        strategy.exit(id = "E_4",from_entry = "L_4", qty_percent = 100,alert_message =Long_Exit_message,limit = strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))                if long_5 and strategy.opentrades == 4  and inDateRange   and close < strategy.opentrades.entry_price(strategy.opentrades - 1) * (1-percent_change) and stop_close_all == ""        strategy.entry(id = "L_5",   direction =  strategy.long,alert_message = Long_message,  qty = qty_new   )                       if strategy.opentrades == 5        strategy.exit(id = "E_5",from_entry = "L_5", qty_percent = 100,alert_message =Long_Exit_message, limit = strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))        if long_6 and strategy.opentrades == 5  and inDateRange   and close < strategy.opentrades.entry_price(strategy.opentrades - 1) * (1-percent_change) and stop_close_all == ""        strategy.entry(id = "L_6",   direction =  strategy.long,alert_message = Long_message,  qty = qty_new   )                       if strategy.opentrades == 6        strategy.exit(id = "E_6",from_entry = "L_6", qty_percent = 100,alert_message =Long_Exit_message, limit = strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))        if long_7 and strategy.opentrades == 6  and inDateRange   and close < strategy.opentrades.entry_price(strategy.opentrades - 1) * (1-percent_change) and stop_close_all == ""        strategy.entry(id = "L_7",   direction =  strategy.long,alert_message = Long_message,  qty = qty_new   )                       if strategy.opentrades == 7        strategy.exit(id = "E_7",from_entry = "L_7", qty_percent = 100,alert_message =Long_Exit_message, limit = strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))        if long_8 and strategy.opentrades == 7  and inDateRange   and close < strategy.opentrades.entry_price(strategy.opentrades - 1) * (1-percent_change) and stop_close_all == ""        strategy.entry(id = "L_8",   direction =  strategy.long,alert_message = Long_message,  qty = qty_new   )                       if strategy.opentrades == 8        strategy.exit(id = "E_8",from_entry = "L_8", qty_percent = 100,alert_message =Long_Exit_message, limit = strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))        if long_9 and strategy.opentrades == 8  and inDateRange   and close < strategy.opentrades.entry_price(strategy.opentrades - 1) * (1-percent_change) and stop_close_all == ""        strategy.entry(id = "L_9",   direction =  strategy.long,alert_message = Long_message,  qty = qty_new   )                       if strategy.opentrades == 9        strategy.exit(id = "E_9",from_entry = "L_9", qty_percent = 100,alert_message =Long_Exit_message, limit = strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))                         if long_10 and strategy.opentrades == 9  and inDateRange   and close < strategy.opentrades.entry_price(strategy.opentrades - 1) * (1-percent_change) and stop_close_all == ""        strategy.entry(id = "L_10",   direction =  strategy.long,alert_message = Long_message,  qty = qty_new   )                       if strategy.opentrades == 10        strategy.exit(id = "E_10",from_entry = "L_10", qty_percent = 100,alert_message =Long_Exit_message, limit = strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change))// ##### STOP LOSS CODES  #####if  use_stop and   low < low_price_stop and strategy.position_size > 0    strategy.close_all(alert_message =Long_Stop_message, immediately = true)    stop_close_all := "DONT"// ###########################################################################################if tewnty_grid and close < high_price and ( trade_direction == 'SHORT' or trade_direction == 'BOTH')    if short_1 and strategy.opentrades == 0  and inDateRange   and stop_close_all == ""        strategy.entry(id = "S_1",  direction =  strategy.short,alert_message = Short_message, qty = qty_new    )                        if strategy.opentrades == 1        strategy.exit(id = "ES_1",from_entry = "S_1", qty_percent = 100,alert_message =Short_Exit_message, limit = strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))                if short_2 and strategy.opentrades == 1  and inDateRange   and close > strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change) and stop_close_all == ""        strategy.entry(id = "S_2",direction =  strategy.short,alert_message = Short_message,  qty = qty_new    )                                       if strategy.opentrades == 2        strategy.exit(id = "ES_2",from_entry = "S_2", qty_percent = 100,alert_message =Short_Exit_message, limit = strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))                if short_3 and strategy.opentrades == 2  and inDateRange   and close > strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change) and stop_close_all == ""        strategy.entry(id = "S_3",   direction =  strategy.short,alert_message = Short_message,  qty = qty_new    )                                    if strategy.opentrades == 3         strategy.exit(id = "ES_3",from_entry = "S_3", qty_percent = 100,alert_message =Short_Exit_message, limit = strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))                if short_4 and strategy.opentrades == 3  and inDateRange   and close > strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change) and stop_close_all == ""        strategy.entry(id = "S_4",   direction =  strategy.short,alert_message = Short_message, qty = qty_new     )                                        if strategy.opentrades == 4         strategy.exit(id = "ES_4",from_entry = "S_4", qty_percent = 100,alert_message =Short_Exit_message,limit = strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))                if short_5 and strategy.opentrades == 4  and inDateRange   and close > strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change) and stop_close_all == ""        strategy.entry(id = "S_5",  direction =  strategy.short,alert_message = Short_message,  qty = qty_new    )                        if strategy.opentrades == 5         strategy.exit(id = "ES_5",from_entry = "S_5", qty_percent = 100,alert_message =Short_Exit_message, limit = strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))            if short_6 and strategy.opentrades == 5  and inDateRange   and close > strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change) and stop_close_all == ""        strategy.entry(id = "S_6",  direction =  strategy.short,alert_message = Short_message,  qty = qty_new    )                        if strategy.opentrades == 6         strategy.exit(id = "ES_6",from_entry = "S_6", qty_percent = 100,alert_message =Short_Exit_message, limit = strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))            if short_7 and strategy.opentrades == 6  and inDateRange   and close > strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change) and stop_close_all == ""        strategy.entry(id = "S_7",  direction =  strategy.short,alert_message = Short_message,  qty = qty_new    )                 if strategy.opentrades == 7         strategy.exit(id = "ES_7",from_entry = "S_7", qty_percent = 100,alert_message =Short_Exit_message, limit = strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))           if short_8 and strategy.opentrades == 7  and inDateRange   and close > strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change) and stop_close_all == ""        strategy.entry(id = "S_8",  direction =  strategy.short,alert_message = Short_message,  qty = qty_new    )                 if strategy.opentrades == 8         strategy.exit(id = "ES_8",from_entry = "S_8", qty_percent = 100,alert_message =Short_Exit_message, limit = strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))        if short_9 and strategy.opentrades == 8  and inDateRange   and close > strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change) and stop_close_all == ""        strategy.entry(id = "S_9",  direction =  strategy.short,alert_message = Short_message,  qty = qty_new    )                 if strategy.opentrades == 9         strategy.exit(id = "ES_9",from_entry = "S_9", qty_percent = 100,alert_message =Short_Exit_message, limit = strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))        if short_10 and strategy.opentrades == 9  and inDateRange   and close > strategy.opentrades.entry_price(strategy.opentrades - 1) * (1+percent_change) and stop_close_all == ""        strategy.entry(id = "S_10",  direction =  strategy.short,alert_message = Short_message,  qty = qty_new    )                 if strategy.opentrades == 10        strategy.exit(id = "ES_10",from_entry = "S_10", qty_percent = 100,alert_message =Short_Exit_message, limit = strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change))// ###########################################################################################if  use_stop and  high > high_price_stop and strategy.position_size < 0    strategy.close_all(alert_message =Short_Stop_message, immediately = true)    stop_close_all := "DONT"bgcolor(stop_close_all == "DONT" and stop_close_all[1] != "DONT" ? color.rgb(255, 42, 42) : na )//// ########################################################################// Plot Functionsplot(strategy.position_size < 0 ? strategy.opentrades.entry_price(strategy.opentrades - 1)*(1-percent_change) : na , color= color.rgb(247, 85, 85), linewidth= 1, style=plot.style_cross)plot(strategy.position_size > 0 ? strategy.opentrades.entry_price(strategy.opentrades - 1)*(1+percent_change) : na , color= color.rgb(136, 247, 85), linewidth= 1, style=plot.style_cross)plot(inDateRange ? high_price_stop : na, color= color.rgb(255, 37, 37), linewidth =4 )plot(inDateRange ? low_price_stop : na, color= color.rgb(255, 34, 37), linewidth =4 )plot(inDateRange ? high_price : na, color= color.rgb(0, 0, 0), linewidth =3 )plot(inDateRange ? low_price : na, color= color.rgb(255, 255, 255), linewidth =3 )plot(inDateRange ? (high_price + low_price) / 2 : na , color= color.rgb(0, 68, 255), linewidth = 2 )// ###########################################################################################var float new_ten_grid_1 = na var float new_ten_grid_2 = na var float new_ten_grid_3 = na var float new_ten_grid_4 = na var float new_ten_grid_5 = na var float new_ten_grid_6 = na var float new_ten_grid_7 = na var float new_ten_grid_8 = na var float new_ten_grid_9 = na var float new_ten_grid_10 = na if ten_grid == true and show_grid_level_bg and inDateRange     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_10else 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 := nafill(plot(inDateRange ? new_ten_grid_1 : na , color = color.new(color.green, 90)),      plot(inDateRange ? new_ten_grid_2 : na , color = color.new(color.green, 90)),          color = color.new(color.green, 90))fill(plot(inDateRange ?  new_ten_grid_2 : na , color = color.new(color.green, 85)),      plot(inDateRange ? new_ten_grid_3 : na , color = color.new(color.green, 85)),          color = color.new(color.green, 85))fill(plot(inDateRange ? new_ten_grid_3 : na , color = color.new(color.green, 80)),      plot(inDateRange ? new_ten_grid_4 : na , color = color.new(color.green, 80)),          color = color.new(color.green, 80))fill(plot(inDateRange ? new_ten_grid_4 : na , color = color.new(color.green, 70)),      plot(inDateRange ? new_ten_grid_5 : na , color = color.new(color.green, 70)),          color = color.new(color.green, 70))fill(plot(inDateRange ?  new_ten_grid_5 : na , color = color.new(color.green, 60)),      plot(inDateRange ? new_ten_grid_6 : na, color = color.new(color.green, 60)),          color = color.new(color.green, 60))fill(plot(inDateRange ? new_ten_grid_6 : na, color = color.new(color.red, 60)),      plot(inDateRange ? new_ten_grid_7 : na, color = color.new(color.red, 60)),          color = color.new(color.red, 60))fill(plot(inDateRange ? new_ten_grid_7 : na, color = color.new(color.red, 70)),      plot(inDateRange ? new_ten_grid_8 : na, color = color.new(color.red, 70)),          color = color.new(color.red, 70))fill(plot(inDateRange ? new_ten_grid_8 : na, color = color.new(color.red, 80)),      plot(inDateRange ? new_ten_grid_9 : na, color = color.new(color.red, 80)),          color = color.new(color.red, 80))fill(plot(inDateRange ? new_ten_grid_9 : na, color = color.new(color.red, 85)),      plot(inDateRange ? new_ten_grid_10 : na, color = color.new(color.red, 85)),          color = color.new(color.red, 85))// // ###########################################################################################var float new_twenty_grid_1 = na var float new_twenty_grid_2 = na var float new_twenty_grid_3 = na var float new_twenty_grid_4 = na var float new_twenty_grid_5 = na var float new_twenty_grid_6 = na var float new_twenty_grid_7 = na var float new_twenty_grid_8 = na var float new_twenty_grid_9 = na var float new_twenty_grid_10 = na var float new_twenty_grid_11 = na var float new_twenty_grid_12 = na var float new_twenty_grid_13 = na var float new_twenty_grid_14 = na var float new_twenty_grid_15 = na var float new_twenty_grid_16 = na var float new_twenty_grid_17 = na var float new_twenty_grid_18 = na var float new_twenty_grid_19 = na var float new_twenty_grid_20 = na if tewnty_grid == true and show_grid_level_bg and inDateRange     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_20else 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 := nafill(plot(inDateRange ? new_twenty_grid_1 : na , color = color.new(color.green, 90)),      plot(inDateRange ? new_twenty_grid_2 : na , color = color.new(color.green, 90)),          color = color.new(color.green, 90))fill(plot(inDateRange ? new_twenty_grid_2 : na , color = color.new(color.green, 85)),      plot(inDateRange ? new_twenty_grid_3 : na , color = color.new(color.green, 85)),          color = color.new(color.green, 85))fill(plot(inDateRange ? new_twenty_grid_3 : na , color = color.new(color.green, 80)),      plot(inDateRange ? new_twenty_grid_4 : na , color = color.new(color.green, 80)),          color = color.new(color.green, 80))fill(plot(inDateRange ? new_twenty_grid_4 : na , color = color.new(color.green, 70)),      plot(inDateRange ? new_twenty_grid_5 : na , color = color.new(color.green, 70)),          color = color.new(color.green, 70))fill(plot(inDateRange ? new_twenty_grid_5 : na , color = color.new(color.green, 60)),      plot(inDateRange ? new_twenty_grid_6 : na , color = color.new(color.green, 60)),          color = color.new(color.green, 60))fill(plot(inDateRange ? new_twenty_grid_6 : na , color = color.new(color.green, 60)),      plot(inDateRange ? new_twenty_grid_7 : na , color = color.new(color.green, 60)),          color = color.new(color.green, 60))fill(plot(inDateRange ? new_twenty_grid_7 : na , color = color.new(color.green, 70)),      plot(inDateRange ? new_twenty_grid_8 : na , color = color.new(color.green, 70)),          color = color.new(color.green, 70))fill(plot(inDateRange ? new_twenty_grid_8 : na , color = color.new(color.green, 80)),      plot(inDateRange ? new_twenty_grid_9 : na , color = color.new(color.green, 80)),          color = color.new(color.green, 80))fill(plot(inDateRange ? new_twenty_grid_9 : na , color = color.new(color.green, 85)),      plot(inDateRange ? new_twenty_grid_10 : na , color = color.new(color.green, 85)),          color = color.new(color.green, 85))fill(plot(inDateRange ? new_twenty_grid_10 : na , color = color.new(color.red, 90)),      plot(inDateRange ? new_twenty_grid_11 : na , color = color.new(color.red, 90)),          color = color.new(color.red, 90))fill(plot(inDateRange ? new_twenty_grid_11 : na , color = color.new(color.red, 85)),      plot(inDateRange ? new_twenty_grid_12 : na , color = color.new(color.red, 85)),          color = color.new(color.red, 85))fill(plot(inDateRange ? new_twenty_grid_12 : na , color = color.new(color.red, 80)),      plot(inDateRange ? new_twenty_grid_13 : na , color = color.new(color.red, 80)),          color = color.new(color.red, 80))fill(plot(inDateRange ? new_twenty_grid_13 : na , color = color.new(color.red, 70)),      plot(inDateRange ? new_twenty_grid_14 : na , color = color.new(color.red, 70)),          color = color.new(color.red, 70))fill(plot(inDateRange ? new_twenty_grid_14 : na , color = color.new(color.red, 60)),      plot(inDateRange ? new_twenty_grid_15 : na , color = color.new(color.red, 60)),          color = color.new(color.red, 60))fill(plot(inDateRange ? new_twenty_grid_15 : na , color = color.new(color.red, 60)),      plot(inDateRange ? new_twenty_grid_16 : na , color = color.new(color.red, 60)),          color = color.new(color.red, 60))fill(plot(inDateRange ? new_twenty_grid_16 : na , color = color.new(color.red, 70)),      plot(inDateRange ? new_twenty_grid_17 : na , color = color.new(color.red, 70)),          color = color.new(color.red, 70))fill(plot(inDateRange ? new_twenty_grid_17 : na , color = color.new(color.red, 80)),      plot(inDateRange ? new_twenty_grid_18 : na , color = color.new(color.red, 80)),          color = color.new(color.red, 80))fill(plot(inDateRange ? new_twenty_grid_18 : na , color = color.new(color.red, 85)),      plot(inDateRange ? new_twenty_grid_19 : na , color = color.new(color.red, 85)),          color = color.new(color.red, 85))fill(plot(inDateRange ? new_twenty_grid_19 : na , color = color.new(color.red, 85)),      plot(inDateRange ? new_twenty_grid_20 : na , color = color.new(color.red, 85)),          color = color.new(color.red, 85))// // ###########################################################################################//###############################################################################################//------------------------------Table//###############################################################################################showDashboard     = input.bool(true, "Show Table", group=" ############# 🔳 TABLE Settings 🔳 ############ ")locationDashboard = input.string("Top Right", "Table Location", ["Top Right", "Middle Right", "Bottom Right", "Top Center", "Middle Center", "Bottom Center", "Top Left", "Middle Left", "Bottom Left"], group=" ############# 🔳 TABLE Settings 🔳 ############ ")sizeDashboard     = input.string("Normal", "Table Size", ["Large", "Normal", "Small", "Tiny"], group=" ############# 🔳 TABLE Settings 🔳 ############ ")var dashboard_loc  = locationDashboard == "Top Right" ? position.top_right : locationDashboard == "Middle Right" ? position.middle_right : locationDashboard == "Bottom Right" ? position.bottom_right : locationDashboard == "Top Center" ? position.top_center : locationDashboard == "Middle Center" ? position.middle_center : locationDashboard == "Bottom Center" ? position.bottom_center : locationDashboard == "Top Left" ? position.top_left : locationDashboard == "Middle Left" ? position.middle_left : position.bottom_leftvar dashboard_size = sizeDashboard == "Large" ? size.large : sizeDashboard == "Normal" ? size.normal : sizeDashboard == "Small" ? size.small : size.tinyif showDashboard    var myTable =  table.new(position = dashboard_loc, columns = 5, rows = 2,bgcolor = color.white, border_width = 1, frame_color = color.rgb(25, 150, 25), frame_width = 3, border_color = color.rgb(25, 150, 25))     table.cell(table_id = myTable, column = 0, row = 0, text = "Open positions"      , text_color = color.white, bgcolor = color.orange, text_size=dashboard_size)    table.cell(table_id = myTable, column = 1, row = 0, text = "Open profit"         , text_color = color.white, bgcolor = color.orange, text_size=dashboard_size)    table.cell(table_id = myTable, column = 2, row = 0, text = "Total trades"        , text_color = color.white, bgcolor = color.orange, text_size=dashboard_size)    table.cell(table_id = myTable, column = 3, row = 0, text = "Total profit"        , text_color = color.white, bgcolor = color.orange, text_size=dashboard_size)    table.cell(table_id = myTable, column = 4, row = 0, text = "Current equity"      , text_color = color.white, bgcolor = color.orange, text_size=dashboard_size)    table.cell(table_id = myTable, column = 0, row = 1, text =       str.tostring(strategy.opentrades)                                                                                      , text_font_family = font.family_monospace, text_size=dashboard_size)    table.cell(table_id = myTable, column = 1, row = 1, text = "$" + str.tostring(math.round(strategy.openprofit, 1)) , bgcolor = strategy.openprofit >= 0 ? color.green : color.red  , text_font_family = font.family_monospace, text_size=dashboard_size)    table.cell(table_id = myTable, column = 2, row = 1, text =       str.tostring(strategy.closedtrades)                                                                                    , text_font_family = font.family_monospace, text_size=dashboard_size)    table.cell(table_id = myTable, column = 3, row = 1, text = "$" + str.tostring(math.round(strategy.netprofit, 1)) , bgcolor = strategy.netprofit  >= 0 ? color.green : color.red  , text_font_family = font.family_monospace, text_size=dashboard_size)    table.cell(table_id = myTable, column = 4, row = 1, text = "$" + str.tostring(math.round(strategy.equity, 1)) , bgcolor = strategy.equity     >= 0 ? color.green : color.red  , text_font_family = font.family_monospace, text_size=dashboard_size)