Pine Script v5 · Strategy
Grid Strategy with MA
A Pine Script v5 strategy built on EMA or SMA or HMA or WMA or RMA or Linreg (source, 100), EMA (source, 100) and SMA (source, 100). It has 30 order rules, 15 entries among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 10000 in cash and pays 0.04% commission. 5 settings; defaults include MA Length 100, MA Type SMA and Grid Logic ATR.
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 Strategy with MA repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 11 of 11 trades.
- How did Grid Strategy with MA do on BTCUSDT 1D with default settings?
- −0.20%
- From 26 Jan 2024 to 21 Oct 2026, over 61 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does Grid Strategy with MA run in Pine Script v6?
- Yes
- Same 61 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. The v6 script can be downloaded below.
- Does Grid Strategy with MA use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Grid Strategy with MA run in Zeal Terminal?
- Yes
- It compiles in 103 ms and runs 1,000 bars in 189 ms, in the browser.
BTCUSDT · 1D · default settings
- Plot
- Plot
- Plot
- Plot
- Plot
- Plot
- Plot
- Plot
- Plot
- Plot
- Plot
- Plot
- Plot
- Plot
- Plot
- Plot
- Net profit
- −0.20%
- −$200.27
- Buy and hold
- +102.5%
- same period
- Closed trades
- 61
- 31 won · 30 lost
- Profitable
- 50.8%
- of closed trades
- Profit factor
- 0.99
- gross profit ÷ gross loss
- Max drawdown
- 26.64%
- −$31,780.00
One run with the author's default settings, $100,000 starting capital, commission as the script sets it. A long position was still open at the last bar. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.
Review
What a careful reader of this script would point out, found by checking the source and the backtest.
-
Likely bug
The “ATR” option calculates EMA line 51
Choosing ATR in “Grid Logic” runs ta.ema, not ta.atr. Anyone picking ATR gets a different average from the one they asked for.
logic == 'ATR' ? ta.ema(logic == 'ATR' ? ta.atr( -
Likely bug
The “ATR” option calculates EMA line 52
Choosing ATR in “Grid Logic” runs ta.ema, not ta.atr. Anyone picking ATR gets a different average from the one they asked for.
logic == 'ATR' ? ta.ema(logic == 'ATR' ? ta.atr( -
Likely bug
The “ATR” option calculates EMA line 53
Choosing ATR in “Grid Logic” runs ta.ema, not ta.atr. Anyone picking ATR gets a different average from the one they asked for.
logic == 'ATR' ? ta.ema(logic == 'ATR' ? ta.atr( -
Likely bug
The “ATR” option calculates EMA line 54
Choosing ATR in “Grid Logic” runs ta.ema, not ta.atr. Anyone picking ATR gets a different average from the one they asked for.
logic == 'ATR' ? ta.ema(logic == 'ATR' ? ta.atr( -
Likely bug
The “ATR” option calculates EMA line 55
Choosing ATR in “Grid Logic” runs ta.ema, not ta.atr. Anyone picking ATR gets a different average from the one they asked for.
logic == 'ATR' ? ta.ema(logic == 'ATR' ? ta.atr( -
Likely bug
The “ATR” option calculates EMA line 56
Choosing ATR in “Grid Logic” runs ta.ema, not ta.atr. Anyone picking ATR gets a different average from the one they asked for.
logic == 'ATR' ? ta.ema(logic == 'ATR' ? ta.atr( -
Likely bug
The “ATR” option calculates EMA line 57
Choosing ATR in “Grid Logic” runs ta.ema, not ta.atr. Anyone picking ATR gets a different average from the one they asked for.
logic == 'ATR' ? ta.ema(logic == 'ATR' ? ta.atr( -
Likely bug
The “ATR” option calculates EMA line 58
Choosing ATR in “Grid Logic” runs ta.ema, not ta.atr. Anyone picking ATR gets a different average from the one they asked for.
logic == 'ATR' ? ta.ema(logic == 'ATR' ? ta.atr( -
Likely bug
The “ATR” option calculates EMA line 61
Choosing ATR in “Grid Logic” runs ta.ema, not ta.atr. Anyone picking ATR gets a different average from the one they asked for.
logic == 'ATR' ? ta.ema(logic == 'ATR' ? ta.atr( -
Likely bug
The “ATR” option calculates EMA line 62
Choosing ATR in “Grid Logic” runs ta.ema, not ta.atr. Anyone picking ATR gets a different average from the one they asked for.
logic == 'ATR' ? ta.ema(logic == 'ATR' ? ta.atr( -
Likely bug
The “ATR” option calculates EMA line 63
Choosing ATR in “Grid Logic” runs ta.ema, not ta.atr. Anyone picking ATR gets a different average from the one they asked for.
logic == 'ATR' ? ta.ema(logic == 'ATR' ? ta.atr( -
Likely bug
The “ATR” option calculates EMA line 64
Choosing ATR in “Grid Logic” runs ta.ema, not ta.atr. Anyone picking ATR gets a different average from the one they asked for.
logic == 'ATR' ? ta.ema(logic == 'ATR' ? ta.atr( -
Likely bug
The “ATR” option calculates EMA line 65
Choosing ATR in “Grid Logic” runs ta.ema, not ta.atr. Anyone picking ATR gets a different average from the one they asked for.
logic == 'ATR' ? ta.ema(logic == 'ATR' ? ta.atr( -
Likely bug
The “ATR” option calculates EMA line 66
Choosing ATR in “Grid Logic” runs ta.ema, not ta.atr. Anyone picking ATR gets a different average from the one they asked for.
logic == 'ATR' ? ta.ema(logic == 'ATR' ? ta.atr( -
Likely bug
The “ATR” option calculates EMA line 67
Choosing ATR in “Grid Logic” runs ta.ema, not ta.atr. Anyone picking ATR gets a different average from the one they asked for.
logic == 'ATR' ? ta.ema(logic == 'ATR' ? ta.atr( -
Likely bug
The “ATR” option calculates EMA line 68
Choosing ATR in “Grid Logic” runs ta.ema, not ta.atr. Anyone picking ATR gets a different average from the one they asked for.
logic == 'ATR' ? ta.ema(logic == 'ATR' ? ta.atr( -
Likely bug
ta.ema(main_plot + atr*(band_mult*1), 5) ignores the settings line 51
Line 51 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema(main_plot + atr*(band_mult*1), 5)ta.ema(main_plot + atr*(band_mult*1), length) -
Likely bug
ta.ema((main_plot*(1+band_mult*0.01*1)), 5) ignores the settings line 51
Line 51 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema((main_plot*(1+band_mult*0.01*1)), 5)ta.ema((main_plot*(1+band_mult*0.01*1)), length) -
Likely bug
ta.ema(main_plot + atr*(band_mult*2), 5) ignores the settings line 52
Line 52 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema(main_plot + atr*(band_mult*2), 5)ta.ema(main_plot + atr*(band_mult*2), length) -
Likely bug
ta.ema((main_plot*(1+band_mult*0.01*2)), 5) ignores the settings line 52
Line 52 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema((main_plot*(1+band_mult*0.01*2)), 5)ta.ema((main_plot*(1+band_mult*0.01*2)), length) -
Likely bug
ta.ema(main_plot + atr*(band_mult*3), 5) ignores the settings line 53
Line 53 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema(main_plot + atr*(band_mult*3), 5)ta.ema(main_plot + atr*(band_mult*3), length) -
Likely bug
ta.ema((main_plot*(1+band_mult*0.01*3)), 5) ignores the settings line 53
Line 53 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema((main_plot*(1+band_mult*0.01*3)), 5)ta.ema((main_plot*(1+band_mult*0.01*3)), length) -
Likely bug
ta.ema(main_plot + atr*(band_mult*4), 5) ignores the settings line 54
Line 54 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema(main_plot + atr*(band_mult*4), 5)ta.ema(main_plot + atr*(band_mult*4), length) -
Likely bug
ta.ema((main_plot*(1+band_mult*0.01*4)), 5) ignores the settings line 54
Line 54 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema((main_plot*(1+band_mult*0.01*4)), 5)ta.ema((main_plot*(1+band_mult*0.01*4)), length) -
Likely bug
ta.ema(main_plot + atr*(band_mult*5), 5) ignores the settings line 55
Line 55 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema(main_plot + atr*(band_mult*5), 5)ta.ema(main_plot + atr*(band_mult*5), length) -
Likely bug
ta.ema((main_plot*(1+band_mult*0.01*5)), 5) ignores the settings line 55
Line 55 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema((main_plot*(1+band_mult*0.01*5)), 5)ta.ema((main_plot*(1+band_mult*0.01*5)), length) -
Likely bug
ta.ema(main_plot + atr*(band_mult*6), 5) ignores the settings line 56
Line 56 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema(main_plot + atr*(band_mult*6), 5)ta.ema(main_plot + atr*(band_mult*6), length) -
Likely bug
ta.ema((main_plot*(1+band_mult*0.01*6)), 5) ignores the settings line 56
Line 56 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema((main_plot*(1+band_mult*0.01*6)), 5)ta.ema((main_plot*(1+band_mult*0.01*6)), length) -
Likely bug
ta.ema(main_plot + atr*(band_mult*7), 5) ignores the settings line 57
Line 57 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema(main_plot + atr*(band_mult*7), 5)ta.ema(main_plot + atr*(band_mult*7), length) -
Likely bug
ta.ema((main_plot*(1+band_mult*0.01*7)), 5) ignores the settings line 57
Line 57 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema((main_plot*(1+band_mult*0.01*7)), 5)ta.ema((main_plot*(1+band_mult*0.01*7)), length) -
Likely bug
ta.ema(main_plot + atr*(band_mult*8), 5) ignores the settings line 58
Line 58 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema(main_plot + atr*(band_mult*8), 5)ta.ema(main_plot + atr*(band_mult*8), length) -
Likely bug
ta.ema((main_plot*(1+band_mult*0.01*8)), 5) ignores the settings line 58
Line 58 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema((main_plot*(1+band_mult*0.01*8)), 5)ta.ema((main_plot*(1+band_mult*0.01*8)), length) -
Likely bug
ta.ema(main_plot - atr*(band_mult*1), 5) ignores the settings line 61
Line 61 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema(main_plot - atr*(band_mult*1), 5)ta.ema(main_plot - atr*(band_mult*1), length) -
Likely bug
ta.ema((main_plot*(1-band_mult*0.01*1)), 5) ignores the settings line 61
Line 61 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema((main_plot*(1-band_mult*0.01*1)), 5)ta.ema((main_plot*(1-band_mult*0.01*1)), length) -
Likely bug
ta.ema(main_plot - atr*(band_mult*2), 5) ignores the settings line 62
Line 62 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema(main_plot - atr*(band_mult*2), 5)ta.ema(main_plot - atr*(band_mult*2), length) -
Likely bug
ta.ema((main_plot*(1-band_mult*0.01*2)), 5) ignores the settings line 62
Line 62 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema((main_plot*(1-band_mult*0.01*2)), 5)ta.ema((main_plot*(1-band_mult*0.01*2)), length) -
Likely bug
ta.ema(main_plot - atr*(band_mult*3), 5) ignores the settings line 63
Line 63 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema(main_plot - atr*(band_mult*3), 5)ta.ema(main_plot - atr*(band_mult*3), length) -
Likely bug
ta.ema((main_plot*(1-band_mult*0.01*3)), 5) ignores the settings line 63
Line 63 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema((main_plot*(1-band_mult*0.01*3)), 5)ta.ema((main_plot*(1-band_mult*0.01*3)), length) -
Likely bug
ta.ema(main_plot - atr*(band_mult*4), 5) ignores the settings line 64
Line 64 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema(main_plot - atr*(band_mult*4), 5)ta.ema(main_plot - atr*(band_mult*4), length) -
Likely bug
ta.ema((main_plot*(1-band_mult*0.01*4)), 5) ignores the settings line 64
Line 64 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema((main_plot*(1-band_mult*0.01*4)), 5)ta.ema((main_plot*(1-band_mult*0.01*4)), length) -
Likely bug
ta.ema(main_plot - atr*(band_mult*5), 5) ignores the settings line 65
Line 65 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema(main_plot - atr*(band_mult*5), 5)ta.ema(main_plot - atr*(band_mult*5), length) -
Likely bug
ta.ema((main_plot*(1-band_mult*0.01*5)), 5) ignores the settings line 65
Line 65 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema((main_plot*(1-band_mult*0.01*5)), 5)ta.ema((main_plot*(1-band_mult*0.01*5)), length) -
Likely bug
ta.ema(main_plot - atr*(band_mult*6), 5) ignores the settings line 66
Line 66 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema(main_plot - atr*(band_mult*6), 5)ta.ema(main_plot - atr*(band_mult*6), length) -
Likely bug
ta.ema((main_plot*(1-band_mult*0.01*6)), 5) ignores the settings line 66
Line 66 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema((main_plot*(1-band_mult*0.01*6)), 5)ta.ema((main_plot*(1-band_mult*0.01*6)), length) -
Likely bug
ta.ema(main_plot - atr*(band_mult*7), 5) ignores the settings line 67
Line 67 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema(main_plot - atr*(band_mult*7), 5)ta.ema(main_plot - atr*(band_mult*7), length) -
Likely bug
ta.ema((main_plot*(1-band_mult*0.01*7)), 5) ignores the settings line 67
Line 67 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema((main_plot*(1-band_mult*0.01*7)), 5)ta.ema((main_plot*(1-band_mult*0.01*7)), length) -
Likely bug
ta.ema(main_plot - atr*(band_mult*8), 5) ignores the settings line 68
Line 68 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema(main_plot - atr*(band_mult*8), 5)ta.ema(main_plot - atr*(band_mult*8), length) -
Likely bug
ta.ema((main_plot*(1-band_mult*0.01*8)), 5) ignores the settings line 68
Line 68 hard-codes 5 where line 32 uses “MA Length”. Changing those settings moves one band but not this one.
ta.ema((main_plot*(1-band_mult*0.01*8)), 5)ta.ema((main_plot*(1-band_mult*0.01*8)), length) -
Check
1 setting does nothing
“ATR Length” is declared but never read.
-
Check
No stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| MA | |||
| MA Length | 100 | int | maPrice ema sma main_plot atr |
| MA Type | SMA | string · options ['EMA', 'HMA', 'LSMA', 'RMA', 'SMA', 'WMA'] | main_plot |
| Grid Logic | ATR | string · options ['ATR', 'Percent'] | premium_zone_1 premium_zone_2 premium_zone_3 premium_zone_4 premium_zone_5 premium_zone_6 premium_zone_7 premium_zone_8 discount_zone_1 discount_zone_2 discount_zone_3 discount_zone_4 discount_zone_5 discount_zone_6 discount_zone_7 discount_zone_8 |
| Parameter | |||
| Band Multiplier/Percent | 2.5 | float · step 0.1 | premium_zone_1 premium_zone_2 premium_zone_3 premium_zone_4 premium_zone_5 premium_zone_6 premium_zone_7 premium_zone_8 discount_zone_1 discount_zone_2 discount_zone_3 discount_zone_4 discount_zone_5 discount_zone_6 discount_zone_7 discount_zone_8 |
| parameter | |||
| ATR Length | 100 | int | unused |
What it calculates
- EMA / SMA / HMA / WMA / RMA / Linregsource, MA Length (100)
maPrice · line 32 - EMAsource, MA Length (100)
ema · line 33 - SMAsource, MA Length (100)
sma · line 34 - ATRMA Length (100)
atr · line 50 - EMAmain_plot + atr*(band_mult*1), 5 · chosen by Grid Logic
premium_zone_1 · line 51 - EMAmain_plot + atr*(band_mult*2), 5 · chosen by Grid Logic
premium_zone_2 · line 52 - EMAmain_plot + atr*(band_mult*3), 5 · chosen by Grid Logic
premium_zone_3 · line 53 - EMAmain_plot + atr*(band_mult*4), 5 · chosen by Grid Logic
premium_zone_4 · line 54 - EMAmain_plot + atr*(band_mult*5), 5 · chosen by Grid Logic
premium_zone_5 · line 55 - EMAmain_plot + atr*(band_mult*6), 5 · chosen by Grid Logic
premium_zone_6 · line 56 - EMAmain_plot + atr*(band_mult*7), 5 · chosen by Grid Logic
premium_zone_7 · line 57 - EMAmain_plot + atr*(band_mult*8), 5 · chosen by Grid Logic
premium_zone_8 · line 58 - EMAmain_plot - atr*(band_mult*1), 5 · chosen by Grid Logic
discount_zone_1 · line 61 - EMAmain_plot - atr*(band_mult*2), 5 · chosen by Grid Logic
discount_zone_2 · line 62 - EMAmain_plot - atr*(band_mult*3), 5 · chosen by Grid Logic
discount_zone_3 · line 63 - EMAmain_plot - atr*(band_mult*4), 5 · chosen by Grid Logic
discount_zone_4 · line 64 - EMAmain_plot - atr*(band_mult*5), 5 · chosen by Grid Logic
discount_zone_5 · line 65 - EMAmain_plot - atr*(band_mult*6), 5 · chosen by Grid Logic
discount_zone_6 · line 66 - EMAmain_plot - atr*(band_mult*7), 5 · chosen by Grid Logic
discount_zone_7 · line 67 - EMAmain_plot - atr*(band_mult*8), 5 · chosen by Grid Logic
discount_zone_8 · line 68 - Crossunderlow, discount_zone_7
longCondition1 · line 119 - Crossunderlow, discount_zone_6
longCondition2 · line 120 - Crossunderlow, discount_zone_5
longCondition3 · line 121 - Crossunderlow, discount_zone_4
longCondition4 · line 122 - Crossunderlow, discount_zone_3
longCondition5 · line 123 - Crossunderlow, discount_zone_2
longCondition6 · line 124 - Crossunderlow, discount_zone_1
longCondition7 · line 125 - Crossunderlow, main_plot
longCondition8 · line 126 - Crossunderlow, premium_zone_1
longCondition9 · line 127 - Crossunderlow, premium_zone_2
longCondition10 · line 128 - Crossunderlow, premium_zone_3
longCondition11 · line 129 - Crossunderlow, premium_zone_4
longCondition12 · line 130 - Crossunderlow, premium_zone_5
longCondition13 · line 131 - Crossunderlow, premium_zone_6
longCondition14 · line 132 - Crossunderlow, premium_zone_7
longCondition15 · line 133 - Crossoverhigh, discount_zone_6
shortCondition1 · line 180 - Crossoverhigh, discount_zone_5
shortCondition2 · line 181 - Crossoverhigh, discount_zone_4
shortCondition3 · line 182 - Crossoverhigh, discount_zone_3
shortCondition4 · line 183 - Crossoverhigh, discount_zone_2
shortCondition5 · line 184 - Crossoverhigh, discount_zone_1
shortCondition6 · line 185 - Crossoverhigh, main_plot
shortCondition7 · line 186 - Crossoverhigh, premium_zone_1
shortCondition8 · line 187 - Crossoverhigh, premium_zone_2
shortCondition9 · line 188 - Crossoverhigh, premium_zone_3
shortCondition10 · line 189 - Crossoverhigh, premium_zone_4
shortCondition11 · line 190 - Crossoverhigh, premium_zone_5
shortCondition12 · line 191 - Crossoverhigh, premium_zone_6
shortCondition13 · line 192 - Crossoverhigh, premium_zone_7
shortCondition14 · line 193 - Crossoverhigh, premium_zone_8
shortCondition15 · line 194
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 119 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open Long1 long | (longCondition1) and order_1 == false | On | 135 |
| Open Long2 long | (longCondition2) and order_2 == false | On | 138 |
| Open Long3 long | (longCondition3) and order_3 == false | On | 141 |
| Open Long4 long | (longCondition4) and order_4 == false | On | 144 |
| Open Long5 long | (longCondition5) and order_5 == false | On | 147 |
| Open Long6 long | (longCondition6) and order_6 == false | On | 150 |
| Open Long7 long | (longCondition7) and order_7 == false | On | 153 |
| Open Long8 long | (longCondition8) and order_8 == false | On | 156 |
| Open Long9 long | (longCondition9) and order_9 == false | On | 159 |
| Open Long10 long | (longCondition10) and order_10 == false | On | 162 |
| Open Long11 long | (longCondition11) and order_11 == false | On | 165 |
| Open Long12 long | (longCondition12) and order_12 == false | On | 168 |
| Open Long13 long | (longCondition13) and order_13 == false | On | 171 |
| Open Long14 long | (longCondition14) and order_14 == false | On | 174 |
| Open Long14 long | (longCondition15) and order_15 == false | On | 177 |
| Close Long1 | (shortCondition1) and order_1 == true | On | 196 |
| Close Long2 | (shortCondition2) and order_2 == true | On | 199 |
| Close Long3 | (shortCondition3) and order_3 == true | On | 202 |
| Close Long4 | (shortCondition4) and order_4 == true | On | 205 |
| Close Long5 | (shortCondition5) and order_5 == true | On | 208 |
| Close Long6 | (shortCondition6) and order_6 == true | On | 211 |
| Close Long7 | (shortCondition7) and order_7 == true | On | 214 |
| Close Long8 | (shortCondition8) and order_8 == true | On | 217 |
| Close Long9 | (shortCondition9) and order_9 == true | On | 220 |
| Close Long10 | (shortCondition10) and order_10 == true | On | 223 |
| Close Long11 | (shortCondition11) and order_11 == true | On | 226 |
| Close Long12 | (shortCondition12) and order_12 == true | On | 229 |
| Close Long13 | (shortCondition13) and order_13 == true | On | 232 |
| Close Long14 | (shortCondition14) and order_14 == true | On | 235 |
| Close Long15 | (shortCondition15) and order_15 == true | On | 238 |
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, and the live replay matched history.
- 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 timingprocess_orders_on_close = true: orders fill at the signal bar's close.
The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.
Other markets
The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | −0.2% | +102.5% | 61 | 51% | 0.99 | 26.6% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +5.2% | +5.5% | 62 | 69% | 1.84 | 8.6% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −22.8% | +9.8% | 62 | 45% | 0.63 | 40.7% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +7.3% | +8.4% | 40 | 78% | 2.68 | 8.2% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −3.9% | +16.7% | 51 | 57% | 0.91 | 29.5% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +9.9% | +21.5% | 60 | 67% | 2.33 | 8.9% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | +1.9% | +148.3% | 67 | 63% | 1.05 | 27.4% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +3.0% | +17.1% | 59 | 61% | 1.43 | 8.6% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
The trades
By market direction
| At entry, last 90 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 18 | 39% | −$2,646.65 |
| Sideways market | 26 | 58% | −$1,866.30 |
| Falling market | 17 | 53% | $4,321.81 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
12.1%
The 95th percentile of the worst drawdown when the same 61 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 5.3% to 12.1%; the tick is what actually happened, 18.8%. Order luck alone moves it this much.
All 61 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 9 May 2024 63,074.00 | 20 May 2024 71,446.60 | 11 | $1,318.90 |
| long | 11 Jun 2024 67,314.20 | 15 Jul 2024 64,724.10 | 34 | −$392.62 |
| long | 24 Jun 2024 60,293.30 | 15 Jul 2024 64,724.10 | 21 | $75.78 |
| long | 24 Jun 2024 60,293.30 | 8 Aug 2024 61,686.00 | 45 | $199.65 |
| long | 4 Aug 2024 58,161.00 | 8 Aug 2024 61,686.00 | 4 | $127.13 |
| long | 4 Aug 2024 58,161.00 | 23 Aug 2024 64,037.20 | 19 | $788.87 |
| long | 5 Aug 2024 54,018.80 | 23 Aug 2024 64,037.20 | 18 | $364.58 |
| long | 5 Aug 2024 54,018.80 | 18 Sep 2024 61,760.00 | 44 | $1,143.13 |
| long | 4 Sep 2024 57,970.90 | 18 Sep 2024 61,760.00 | 14 | $89.58 |
| long | 4 Sep 2024 57,970.90 | 15 Oct 2024 67,074.10 | 41 | $1,344.92 |
| long | 21 Oct 2024 67,377.50 | 6 Nov 2024 75,572.00 | 16 | $1,207.72 |
| long | 25 Nov 2024 93,010.00 | 15 Dec 2024 104,464.00 | 20 | $1,173.34 |
| long | 25 Nov 2024 93,010.00 | 17 Jan 2025 104,077.00 | 53 | $47.96 |
| long | 5 Dec 2024 96,945.60 | 17 Jan 2025 104,077.00 | 43 | $727.36 |
| long | 19 Dec 2024 97,461.90 | 17 Jan 2025 104,077.00 | 29 | $3.47 |
| long | 19 Dec 2024 97,461.90 | 2 Mar 2025 94,270.00 | 73 | −$333.63 |
| long | 23 Dec 2024 94,881.50 | 2 Mar 2025 94,270.00 | 69 | −$11.32 |
| long | 23 Dec 2024 94,881.50 | 19 Mar 2025 86,845.90 | 86 | −$720.93 |
| long | 9 Jan 2025 92,552.50 | 19 Mar 2025 86,845.90 | 69 | −$221.42 |
| long | 9 Jan 2025 92,552.50 | 9 Apr 2025 82,615.20 | 90 | −$697.78 |
| long | 27 Jan 2025 102,083.00 | 9 Apr 2025 82,615.20 | 72 | −$1,105.93 |
| long | 27 Jan 2025 102,083.00 | 22 Apr 2025 93,443.00 | 85 | −$360.63 |
| long | 3 Feb 2025 101,329.00 | 22 Apr 2025 93,443.00 | 78 | −$568.58 |
| long | 3 Feb 2025 101,329.00 | 8 May 2025 103,262.00 | 94 | $50.52 |
| long | 25 Feb 2025 88,680.40 | 8 May 2025 103,262.00 | 72 | $1,035.60 |
| long | 25 Feb 2025 88,680.40 | 19 May 2025 105,574.00 | 83 | $695.59 |
| long | 28 Feb 2025 84,349.90 | 19 May 2025 105,574.00 | 80 | $1,196.84 |
| long | 28 Feb 2025 84,349.90 | 10 Jul 2025 116,010.00 | 132 | $1,956.68 |
| long | 10 Mar 2025 78,595.90 | 10 Jul 2025 116,010.00 | 122 | $1,301.08 |
| long | 10 Mar 2025 78,595.90 | 2 Oct 2025 120,529.00 | 206 | $3,687.77 |
| long | 10 Mar 2025 78,595.90 | 12 Oct 2025 114,959.00 | 216 | $155.12 |
| long | 7 Apr 2025 79,163.20 | 12 Oct 2025 114,959.00 | 188 | $3,014.51 |
| long | 7 Apr 2025 79,163.20 | 26 Oct 2025 114,559.00 | 202 | $1,480.69 |
| long | 20 Jun 2025 103,298.00 | 26 Oct 2025 114,559.00 | 128 | $564.33 |
| long | 20 Jun 2025 103,298.00 | 28 Nov 2025 90,890.70 | 161 | −$578.11 |
| long | 1 Aug 2025 113,298.00 | 28 Nov 2025 90,890.70 | 119 | −$1,600.39 |
| long | 1 Aug 2025 113,298.00 | 5 Jan 2026 93,859.70 | 157 | −$333.80 |
| long | 24 Aug 2025 113,494.00 | 5 Jan 2026 93,859.70 | 134 | −$1,737.26 |
| long | 10 Oct 2025 112,775.00 | 5 Jan 2026 93,859.70 | 87 | −$9.59 |
| long | 10 Oct 2025 112,775.00 | 14 Jan 2026 96,951.80 | 96 | −$1,402.45 |
| long | 10 Oct 2025 112,775.00 | 14 Jan 2026 96,951.80 | 96 | −$66.00 |
| long | 10 Oct 2025 112,775.00 | 25 Feb 2026 67,988.00 | 138 | −$3,791.62 |
| long | 16 Oct 2025 108,194.00 | 25 Feb 2026 67,988.00 | 132 | −$2,997.96 |
| long | 16 Oct 2025 108,194.00 | 13 Mar 2026 70,930.00 | 148 | −$671.76 |
| long | 30 Oct 2025 108,323.00 | 13 Mar 2026 70,930.00 | 134 | −$3,458.60 |
| long | 14 Nov 2025 94,594.00 | 13 Mar 2026 70,930.00 | 119 | −$396.05 |
| long | 14 Nov 2025 94,594.00 | 14 Apr 2026 74,131.60 | 151 | −$1,827.68 |
| long | 21 Nov 2025 85,129.40 | 14 Apr 2026 74,131.60 | 144 | −$266.16 |
| long | 21 Nov 2025 85,129.40 | 4 May 2026 79,861.00 | 164 | −$473.02 |
| long | 21 Nov 2025 85,129.40 | 15 Jun 2026 66,328.70 | 206 | −$89.29 |
| long | 20 Jan 2026 88,427.70 | 15 Jun 2026 66,328.70 | 146 | −$2,506.10 |
| long | 31 Jan 2026 78,741.10 | 15 Jun 2026 66,328.70 | 135 | −$573.16 |
| long | 31 Jan 2026 78,741.10 | 6 Jul 2026 64,042.00 | 156 | −$1,195.79 |
| long | 5 Feb 2026 62,909.90 | 6 Jul 2026 64,042.00 | 151 | $89.42 |
| long | 5 Feb 2026 62,909.90 | 19 Aug 2026 69,334.80 | 195 | $485.99 |
| long | 28 May 2026 73,617.50 | 19 Aug 2026 69,334.80 | 83 | −$319.07 |
| long | 28 May 2026 73,617.50 | 20 Aug 2026 73,025.10 | 84 | −$40.57 |
| long | 2 Jun 2026 66,760.80 | 20 Aug 2026 73,025.10 | 79 | $456.44 |
| long | 2 Jun 2026 66,760.80 | 21 Aug 2026 78,338.00 | 80 | $878.56 |
| long | 5 Jun 2026 61,056.50 | 21 Aug 2026 78,338.00 | 77 | $206.60 |
| long | 5 Jun 2026 61,056.50 | 21 Sep 2026 86,620.00 | 108 | $2,688.03 |
Similar scripts
Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Grid Strategy with MA this page | — | v5 strategy | −0.2% | 61 | 26.6% |
| Multi MA Trend Following Strategy Template by TradeAutomation | ema hma linreg rma sma wma atr | v5 strategy | +12.3% | 3 | 26.9% |
| Profit Maximizer PMax Strategy - Long-Short by melihtuna | sma atr ema linreg | v4 strategy | +16.2% | 4 | 27.8% |
| Strategy - Profit Maximizer by PMax by MartinCrespo | sma atr ema linreg | v4 strategy | No trades on this market | ||
| High-Low Channel Multi averages Crypto Swing strategy by exlux99 | sma ema wma rma linreg | v4 strategy | No trades on this market | ||
| Open Close Cross Strategy plus Explorer by roses27 | sma ema wma linreg atr | v4 strategy | does not run in Zeal Terminal | ||
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
VerifiedNothing to change.
Does it run in Pine Script v6?
Yes
Same 61 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.
⋯// © Seungdori_-//@version=5+//@version=6strategy("Grid Strategy with MA", overlay=true, initial_capital = 100000, default_qty_type = strategy.cash, default_qty_value = 10000, pyramiding = 10, process_orders_on_close = true, commission_type = strategy.commission.percent, commission_value = 0.04)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 103 ms | Yes 1,000 bars in 189 ms | Not measured |
| PineTS | Not tested | Not tested | Not measured |
“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/// © Seungdori_//@version=5strategy("Grid Strategy with MA", overlay=true, initial_capital = 100000, default_qty_type = strategy.cash, default_qty_value = 10000, pyramiding = 10, process_orders_on_close = true, commission_type = strategy.commission.percent, commission_value = 0.04)//Inputs//length = input.int(defval = 100, title = 'MA Length', group = 'MA')MA_Type = input.string("SMA", title="MA Type", options=['EMA', 'HMA', 'LSMA', 'RMA', 'SMA', 'WMA'],group = 'MA')logic = input.string(defval='ATR', title ='Grid Logic', options = ['ATR', 'Percent'])band_mult = input.float(2.5, step = 0.1, title = 'Band Multiplier/Percent', group = 'Parameter')atr_len = input.int(defval=100, title = 'ATR Length', group ='parameter')//Var//var int order_cond = 0var bool order_1 = falsevar bool order_2 = falsevar bool order_3 = falsevar bool order_4 = falsevar bool order_5 = falsevar bool order_6 = falsevar bool order_7 = falsevar bool order_8 = falsevar bool order_9 = falsevar bool order_10 = falsevar bool order_11 = falsevar bool order_12 = falsevar bool order_13 = falsevar bool order_14 = falsevar bool order_15 = false///////////////////////Region : Function///////////////////////getMA(source ,ma_type, length) => maPrice = ta.ema(source, length) ema = ta.ema(source, length) sma = ta.sma(source, length) if ma_type == 'SMA' maPrice := ta.sma(source, length) maPrice if ma_type == 'HMA' maPrice := ta.hma(source, length) maPrice if ma_type == 'WMA' maPrice := ta.wma(source, length) maPrice if ma_type == "RMA" maPrice := ta.rma(source, length) if ma_type == "LSMA" maPrice := ta.linreg(source, length, 0) maPricemain_plot = getMA(ohlc4, MA_Type, length)atr = ta.atr(length)premium_zone_1 = logic == 'ATR' ? ta.ema(main_plot + atr*(band_mult*1), 5) : ta.ema((main_plot*(1+band_mult*0.01*1)), 5)premium_zone_2 = logic == 'ATR' ? ta.ema(main_plot + atr*(band_mult*2), 5) : ta.ema((main_plot*(1+band_mult*0.01*2)), 5)premium_zone_3 = logic == 'ATR' ? ta.ema(main_plot + atr*(band_mult*3), 5) : ta.ema((main_plot*(1+band_mult*0.01*3)), 5)premium_zone_4 = logic == 'ATR' ? ta.ema(main_plot + atr*(band_mult*4), 5) : ta.ema((main_plot*(1+band_mult*0.01*4)), 5)premium_zone_5 = logic == 'ATR' ? ta.ema(main_plot + atr*(band_mult*5), 5) : ta.ema((main_plot*(1+band_mult*0.01*5)), 5)premium_zone_6 = logic == 'ATR' ? ta.ema(main_plot + atr*(band_mult*6), 5) : ta.ema((main_plot*(1+band_mult*0.01*6)), 5)premium_zone_7 = logic == 'ATR' ? ta.ema(main_plot + atr*(band_mult*7), 5) : ta.ema((main_plot*(1+band_mult*0.01*7)), 5)premium_zone_8 = logic == 'ATR' ? ta.ema(main_plot + atr*(band_mult*8), 5) : ta.ema((main_plot*(1+band_mult*0.01*8)), 5)//premium_zone_9 = ta.rma(main_plot + atr*(band_mult*9), 5)//premium_zone_10 = ta.rma(main_plot + atr*(band_mult*10), 5)discount_zone_1 = logic == 'ATR' ? ta.ema(main_plot - atr*(band_mult*1), 5) : ta.ema((main_plot*(1-band_mult*0.01*1)), 5)discount_zone_2 = logic == 'ATR' ? ta.ema(main_plot - atr*(band_mult*2), 5) : ta.ema((main_plot*(1-band_mult*0.01*2)), 5)discount_zone_3 = logic == 'ATR' ? ta.ema(main_plot - atr*(band_mult*3), 5) : ta.ema((main_plot*(1-band_mult*0.01*3)), 5)discount_zone_4 = logic == 'ATR' ? ta.ema(main_plot - atr*(band_mult*4), 5) : ta.ema((main_plot*(1-band_mult*0.01*4)), 5)discount_zone_5 = logic == 'ATR' ? ta.ema(main_plot - atr*(band_mult*5), 5) : ta.ema((main_plot*(1-band_mult*0.01*5)), 5)discount_zone_6 = logic == 'ATR' ? ta.ema(main_plot - atr*(band_mult*6), 5) : ta.ema((main_plot*(1-band_mult*0.01*6)), 5)discount_zone_7 = logic == 'ATR' ? ta.ema(main_plot - atr*(band_mult*7), 5) : ta.ema((main_plot*(1-band_mult*0.01*7)), 5)discount_zone_8 = logic == 'ATR' ? ta.ema(main_plot - atr*(band_mult*8), 5) : ta.ema((main_plot*(1-band_mult*0.01*8)), 5)//discount_zon_9 = ta.sma(main_plot - atr*(band_mult*9), 5)//discount_zone_10 =ta.sma( main_plot - atr*(band_mult*10), 5)//Region End//////////////////////// Region : Plots/////////////////////dis_low1 = plot(discount_zone_1, color=color.new(color.green, 80))dis_low2 = plot(discount_zone_2, color=color.new(color.green, 70))dis_low3 = plot(discount_zone_3, color=color.new(color.green, 60))dis_low4 = plot(discount_zone_4, color=color.new(color.green, 50))dis_low5 = plot(discount_zone_5, color=color.new(color.green, 40))dis_low6 = plot(discount_zone_6, color=color.new(color.green, 30))dis_low7 = plot(discount_zone_7, color=color.new(color.green, 20))dis_low8 = plot(discount_zone_8, color=color.new(color.green, 10))//dis_low9 = plot(discount_zone_9, color=color.new(color.green, 0))//dis_low10 = plot(discount_zone_10, color=color.new(color.green, 0))plot(main_plot, color =color.new(color.gray, 10))pre_up1 = plot(premium_zone_1, color=color.new(color.red, 80))pre_up2 = plot(premium_zone_2, color=color.new(color.red, 70))pre_up3 = plot(premium_zone_3, color=color.new(color.red, 60))pre_up4 = plot(premium_zone_4, color=color.new(color.red, 50))pre_up5 = plot(premium_zone_5, color=color.new(color.red, 40))pre_up6 = plot(premium_zone_6, color=color.new(color.red, 30))pre_up7 = plot(premium_zone_7, color=color.new(color.red, 20))pre_up8 = plot(premium_zone_8, color=color.new(color.red, 10))//pre_up9 = plot(premium_zone_9, color=color.new(color.red, 0))//pre_up10 = plot(premium_zone_10, color=color.new(color.red, 0))fill(dis_low1, dis_low2, color=color.new(color.green, 95))fill(dis_low2, dis_low3, color=color.new(color.green, 90))fill(dis_low3, dis_low4, color=color.new(color.green, 85))fill(dis_low4, dis_low5, color=color.new(color.green, 80))fill(dis_low5, dis_low6, color=color.new(color.green, 75))fill(dis_low6, dis_low7, color=color.new(color.green, 70))fill(dis_low7, dis_low8, color=color.new(color.green, 65))//fill(dis_low8, dis_low9, color=color.new(color.green, 60))//fill(dis_low9, dis_low10, color=color.new(color.green, 55))fill(pre_up1, pre_up2, color=color.new(color.red, 95))fill(pre_up2, pre_up3, color=color.new(color.red, 90))fill(pre_up3, pre_up4, color=color.new(color.red, 85))fill(pre_up4, pre_up5, color=color.new(color.red, 80))fill(pre_up5, pre_up6, color=color.new(color.red, 75))fill(pre_up6, pre_up7, color=color.new(color.red, 70))fill(pre_up7, pre_up8, color=color.new(color.red, 65))//fill(pre_up8, pre_up9, color=color.new(color.red, 60))//fill(pre_up9, pre_up10, color=color.new(color.red, 55))//Region End///////////////////////////Region : Strategies///////////////////////////Longs//longCondition1 = ta.crossunder(low, discount_zone_7)longCondition2 = ta.crossunder(low, discount_zone_6)longCondition3 = ta.crossunder(low, discount_zone_5)longCondition4 = ta.crossunder(low, discount_zone_4)longCondition5 = ta.crossunder(low, discount_zone_3)longCondition6 = ta.crossunder(low, discount_zone_2)longCondition7 = ta.crossunder(low, discount_zone_1)longCondition8 = ta.crossunder(low, main_plot)longCondition9 = ta.crossunder(low, premium_zone_1)longCondition10 = ta.crossunder(low, premium_zone_2)longCondition11 = ta.crossunder(low, premium_zone_3)longCondition12 = ta.crossunder(low, premium_zone_4)longCondition13 = ta.crossunder(low, premium_zone_5)longCondition14 = ta.crossunder(low, premium_zone_6)longCondition15 = ta.crossunder(low, premium_zone_7)if (longCondition1) and order_1 == false strategy.entry("Long1", strategy.long) order_1 := trueif (longCondition2) and order_2 == false strategy.entry("Long2", strategy.long) order_2 := trueif (longCondition3) and order_3 == false strategy.entry("Long3", strategy.long) order_3 := trueif (longCondition4) and order_4 == false strategy.entry("Long4", strategy.long) order_4 := trueif (longCondition5) and order_5 == false strategy.entry("Long5", strategy.long) order_5 := trueif (longCondition6) and order_6 == false strategy.entry("Long6", strategy.long) order_6 := trueif (longCondition7) and order_7 == false strategy.entry("Long7", strategy.long) order_7 := trueif (longCondition8) and order_8 == false strategy.entry("Long8", strategy.long) order_8 := trueif (longCondition9) and order_9 == false strategy.entry("Long9", strategy.long) order_9 := trueif (longCondition10) and order_10 == false strategy.entry("Long10", strategy.long) order_10 := trueif (longCondition11) and order_11 == false strategy.entry("Long11", strategy.long) order_11 := trueif (longCondition12) and order_12 == false strategy.entry("Long12", strategy.long) order_12 := trueif (longCondition13) and order_13 == false strategy.entry("Long13", strategy.long) order_13 := trueif (longCondition14) and order_14 == false strategy.entry("Long14", strategy.long) order_14 := trueif (longCondition15) and order_15 == false strategy.entry("Long14", strategy.long) order_15 := true//Close//shortCondition1 = ta.crossover(high, discount_zone_6)shortCondition2 = ta.crossover(high, discount_zone_5)shortCondition3 = ta.crossover(high, discount_zone_4)shortCondition4 = ta.crossover(high, discount_zone_3)shortCondition5 = ta.crossover(high, discount_zone_2)shortCondition6 = ta.crossover(high, discount_zone_1)shortCondition7 = ta.crossover(high, main_plot)shortCondition8 = ta.crossover(high, premium_zone_1)shortCondition9 = ta.crossover(high, premium_zone_2)shortCondition10 = ta.crossover(high, premium_zone_3)shortCondition11 = ta.crossover(high, premium_zone_4)shortCondition12 = ta.crossover(high, premium_zone_5)shortCondition13 = ta.crossover(high, premium_zone_6)shortCondition14 = ta.crossover(high, premium_zone_7)shortCondition15 = ta.crossover(high, premium_zone_8)if (shortCondition1) and order_1 == true strategy.close("Long1") order_1 := falseif (shortCondition2) and order_2 == true strategy.close("Long2") order_2 := falseif (shortCondition3) and order_3 == true strategy.close("Long3") order_3 := falseif (shortCondition4) and order_4 == true strategy.close("Long4") order_4 := falseif (shortCondition5) and order_5 == true strategy.close("Long5") order_5 := falseif (shortCondition6) and order_6 == true strategy.close("Long6") order_6 := falseif (shortCondition7) and order_7 == true strategy.close("Long7") order_7 := falseif (shortCondition8) and order_8 == true strategy.close("Long8") order_8 := falseif (shortCondition9) and order_9 == true strategy.close("Long9") order_9 := falseif (shortCondition10) and order_10 == true strategy.close("Long10") order_10 := falseif (shortCondition11) and order_11 == true strategy.close("Long11") order_11 := falseif (shortCondition12) and order_12 == true strategy.close("Long12") order_12 := falseif (shortCondition13) and order_13 == true strategy.close("Long13") order_13 := falseif (shortCondition14) and order_14 == true strategy.close("Long14") order_14 := falseif (shortCondition15) and order_15 == true strategy.close("Long15") order_15 := false