Zeal Terminal Open Zeal Terminal

Pine Script v5 · Strategy

Hulk Grid Algorithm - The Quant Science

A Pine Script v5 strategy built on Crossunder (close, destroyall). It has 26 order rules, 10 entries among them, and trades long only with the default settings. Exits use a profit target and no stop loss. Each trade commits 1% of equity and pays 0.07% commission. 11 settings; defaults include Start Date 1, Start Month 1 and Start Year 2018.

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 Hulk Grid Algorithm - The Quant Science repaint?
No
No repainting patterns were found in the source.
Does Hulk Grid Algorithm - The Quant Science run in Pine Script v6?
Not tested
The v5 script does not run in Zeal Terminal's engine (WRONG TIMEFRAME: Please select an intraday timeframe when use this strategy backtesting.), so this step could not be checked. The v6 version is shown for reference and is not offered as a download.
Does Hulk Grid Algorithm - The Quant Science use a stop loss?
No
Its exits set a profit target but no stop.
Does Hulk Grid Algorithm - The Quant Science run in Zeal Terminal?
No
Not yet: WRONG TIMEFRAME: Please select an intraday timeframe when use this strategy backtesting.
Does not run in Zeal Terminal yetWRONG TIMEFRAME: Please select an intraday timeframe when use this strategy backtesting. The settings, logic and review below are read from the source, which does not need a run.

Review

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

  • Check

    No stop loss

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

  • Check

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • Note

    No slippage

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

Settings

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

SettingDefaultType and rangeFeeds
DATE PERIOD CONFIGURATION
Start Date1int · min 1 · max 31inDateRange
Start Month1int · min 1 · max 12inDateRange
Start Year2018int · min 1800 · max 2100inDateRange
End Date12int · min 1 · max 31inDateRange
End Month3int · min 1 · max 12inDateRange
End Year2022int · min 1800 · max 2100inDateRange
STRATEGY CONFIGURATION
Enable StrategyCreate grid backtesting.falseboolexit C #1 exit C #2 exit C #3 exit C #4 exit C #5 exit C #6 exit C #7 exit C #8 exit C #9 exit C #10 line 65 line 97 line 108 line 123 line 141 line 143 line 145 line 147 line 149 line 151 line 153 line 155 line 157 line 159
Stop Loss: 2.00float · step 0.10destroyall
Take Profit: 2.00float · step 0.10takeprofitlevel
Minimum Bars: 3int · step 1period
Size Grid Range: 200.00float · step 1.00trigger

What it calculates

  • Crossunderclose, destroyalldes_function · line 120

Signal flow

How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.

The script has 89 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.

Order rules

OrderFires whenBy defaultLine
Open O #1 longclose > new_ten_grid_1On126
Open O #2 longclose > new_ten_grid_1On127
Open O #3 longclose > new_ten_grid_1On128
Open O #4 longclose > new_ten_grid_1On129
Open O #5 longclose > new_ten_grid_1On130
Open O #6 longclose < new_ten_grid_1On132
Open O #7 longclose < new_ten_grid_1On133
Open O #8 longclose < new_ten_grid_1On134
Open O #9 longclose < new_ten_grid_1On135
Open O #10 longclose < new_ten_grid_1On136
cancel_all close > takeprofitlevelOn138
cancel_all close < destroyallOn140
Exit C #1 limitnew_ten_grid_2 and ten_grid == trueOn142
Exit C #2 limitnew_ten_grid_3 and ten_grid == trueOn144
Exit C #3 limitnew_ten_grid_4 and ten_grid == trueOn146
Exit C #4 limitnew_ten_grid_5 and ten_grid == trueOn148
Exit C #5 limittakeprofitlevel and ten_grid == trueOn150
Exit C #6 limitnew_ten_grid_5 and ten_grid == trueOn152
Exit C #7 limitnew_ten_grid_6 and ten_grid == trueOn154
Exit C #8 limitnew_ten_grid_7 and ten_grid == trueOn156
Exit C #9 limitnew_ten_grid_8 and ten_grid == trueOn158
Exit C #10 limitnew_ten_grid_9 and ten_grid == trueOn160
Close Destroyed Griddes_functionOn162
cancel_all des_functionOn163
Close Dayli Session Endsession.islastbar_regularOn165
cancel_all session.islastbar_regularOn167

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.

The live replay needs a run, and this script does not run in Zeal Terminal yet; the answer comes from the checks on the source alone.

  • ClearHigher-timeframe data3 request.security call(s), none with lookahead on.
  • 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.

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.

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

Clean v5

Verified

Nothing to change.

Does it run in Pine Script v6?

Not tested

The v5 script does not run in Zeal Terminal's engine (WRONG TIMEFRAME: Please select an intraday timeframe when use this strategy backtesting.), so this step could not be checked. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

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

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2No WRONG TIMEFRAME: Please select an intraday timeframe when use this strategy backtesting.Not measured
PineTSNot testedNot testedNot measured

Zeal Terminal's engine currently reads an order side written as direction = strategy.long as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (lines 126, 127, 128, 129, 130, 132 and more) so the engine trades the way the script says.

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

Source

Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © thequantscience//  ██╗  ██╗██╗   ██╗██╗     ██╗  ██╗     ██████╗ ██████╗ ██╗██████╗      █████╗ ██╗      ██████╗  ██████╗ ██████╗ ██╗████████╗██╗  ██╗███╗   ███╗//  ██║  ██║██║   ██║██║     ██║ ██╔╝    ██╔════╝ ██╔══██╗██║██╔══██╗    ██╔══██╗██║     ██╔════╝ ██╔═══██╗██╔══██╗██║╚══██╔══╝██║  ██║████╗ ████║//  ███████║██║   ██║██║     █████╔╝     ██║  ███╗██████╔╝██║██║  ██║    ███████║██║     ██║  ███╗██║   ██║██████╔╝██║   ██║   ███████║██╔████╔██║//  ██╔══██║██║   ██║██║     ██╔═██╗     ██║   ██║██╔══██╗██║██║  ██║    ██╔══██║██║     ██║   ██║██║   ██║██╔══██╗██║   ██║   ██╔══██║██║╚██╔╝██║//  ██║  ██║╚██████╔╝███████╗██║  ██╗    ╚██████╔╝██║  ██║██║██████╔╝    ██║  ██║███████╗╚██████╔╝╚██████╔╝██║  ██║██║   ██║   ██║  ██║██║ ╚═╝ ██║//  ╚═╝  ╚═╝ ╚═════╝ ╚══════╝╚═╝  ╚═╝     ╚═════╝ ╚═╝  ╚═╝╚═╝╚═════╝     ╚═╝  ╚═╝╚══════╝ ╚═════╝  ╚═════╝ ╚═╝  ╚═╝╚═╝   ╚═╝   ╚═╝  ╚═╝╚═╝     ╚═╝                                                                                                                                                                                     //@version=5strategy(     title = 'Hulk Grid Algorithm - The Quant Science',      overlay = true,     initial_capital = 1000,      commission_type = strategy.commission.percent,      commission_value = 0.07,      pyramiding = 10,     default_qty_type = strategy.percent_of_equity     )// #########################################################################################################if not timeframe.isintraday    runtime.error("WRONG TIMEFRAME: Please select an intraday timeframe when use this strategy backtesting.")// #########################################################################################################startDate   = input.int(title="Start Date", defval=1, minval=1, maxval=31, group = "DATE PERIOD CONFIGURATION")startMonth  = input.int(title="Start Month", defval=1, minval=1, maxval=12, group = "DATE PERIOD CONFIGURATION")startYear   = input.int(title="Start Year", defval=2018, minval=1800, maxval=2100, group = "DATE PERIOD CONFIGURATION")endDate     = input.int(title="End Date", defval=12, minval=1, maxval=31, group = "DATE PERIOD CONFIGURATION")endMonth    = input.int(title="End Month", defval=3, minval=1, maxval=12, group = "DATE PERIOD CONFIGURATION")endYear     = input.int(title="End Year", defval=2022, minval=1800, maxval=2100, group = "DATE PERIOD CONFIGURATION")inDateRange = (time >= timestamp(syminfo.timezone, startYear, startMonth, startDate, 0, 0)) and (time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0))// #########################################################################################################requestpastweekclose = request.security(syminfo.tickerid,  "D", close[1], gaps = barmerge.gaps_off) requestpastweekopen  = request.security(syminfo.tickerid,  "D", open[1],  gaps = barmerge.gaps_off)newday  = request.security(syminfo.tickerid,  "D", close,  gaps = barmerge.gaps_off)// #########################################################################################################ten_grid        = input.bool(defval = false, title = "Enable Strategy", tooltip = "Create grid backtesting.", group = "STRATEGY CONFIGURATION")stop_loss       = input.float(defval = 2.00, step = 0.10, title = "Stop Loss: ", group = "STRATEGY CONFIGURATION")take_profit     = input.float(defval = 2.00, step = 0.10, title = "Take Profit: ", group = "STRATEGY CONFIGURATION")period_num      = input.int(defval = 3, step = 1, title = "Minimum Bars: ", group = "STRATEGY CONFIGURATION")size_grid       = input.float(defval = 200.00, step = 1.00, title = "Size Grid Range: ", group = "STRATEGY CONFIGURATION")// #########################################################################################################var float high_start = 0 var float high_end   = 0 checking = requestpastweekclose > requestpastweekopen if checking==true    high_start := requestpastweekclose    high_end   := requestpastweekopengrid_range = high_start - high_endperiod = ta.barssince(ta.change(checking==true))==period_numTriggerGrid() =>    trigger = checking==true and period and grid_range > size_grid and close     triggertrigger_entry = TriggerGrid() 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 factor = 0 if ten_grid == true and trigger_entry==true and strategy.opentrades==0    factor := grid_range / 10    // UP GRID    grid_1  := (high_start)     grid_2  := (high_start + (factor * 1))     grid_3  := (high_start + (factor * 2))     grid_4  := (high_start + (factor * 3))     grid_5  := (high_start + (factor * 4))    // DOWN GRID    grid_6  := (high_start - (factor * 1))     grid_7  := (high_start - (factor * 2))     grid_8  := (high_start - (factor * 3))     grid_9  := (high_start - (factor * 4))    grid_10 := (high_start - (factor * 5))// #########################################################################################################var tb = table.new(position.bottom_left, 1, 1, bgcolor = color.new(#00ff08, 74))if barstate.isfirst    table.cell(tb, 0, 0,       'Developed by The Quant Science™'      ,text_size = size.normal      ,text_color = color.new(#00ff08, 21))// #########################################################################################################var float new_ten_grid_1  = 0 var float new_ten_grid_2  = 0 var float new_ten_grid_3  = 0 var float new_ten_grid_4  = 0 var float new_ten_grid_5  = 0 var float new_ten_grid_6  = 0 var float new_ten_grid_7  = 0 var float new_ten_grid_8  = 0 var float new_ten_grid_9  = 0 var float new_ten_grid_10 = 0 if ten_grid == true     new_ten_grid_1  := grid_1    new_ten_grid_2  := grid_2    new_ten_grid_3  := grid_3    new_ten_grid_4  := grid_4    new_ten_grid_5  := grid_5    new_ten_grid_6  := grid_6    new_ten_grid_7  := grid_7    new_ten_grid_8  := grid_8    new_ten_grid_9  := grid_9    new_ten_grid_10 := grid_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 := nadestroyall = new_ten_grid_10 - (new_ten_grid_10 * stop_loss / 100)des_function = ta.crossunder(close, destroyall)takeprofitlevel = new_ten_grid_5 + (new_ten_grid_5 * take_profit / 100)var float lots = 0 if trigger_entry==true and ten_grid==true and period and inDateRange    lots := (strategy.equity / close) / 5    if close > new_ten_grid_1        strategy.entry(id = "O #1",  direction = strategy.long, qty = lots, limit = new_ten_grid_1)        strategy.entry(id = "O #2",  direction = strategy.long, qty = lots, limit = new_ten_grid_2)        strategy.entry(id = "O #3",  direction = strategy.long, qty = lots, limit = new_ten_grid_3)        strategy.entry(id = "O #4",  direction = strategy.long, qty = lots, limit = new_ten_grid_4)        strategy.entry(id = "O #5",  direction = strategy.long, qty = lots, limit = new_ten_grid_5)    if close < new_ten_grid_1        strategy.entry(id = "O #6",  direction = strategy.long, qty = lots, limit = new_ten_grid_6)        strategy.entry(id = "O #7",  direction = strategy.long, qty = lots, limit = new_ten_grid_7)        strategy.entry(id = "O #8",  direction = strategy.long, qty = lots, limit = new_ten_grid_8)        strategy.entry(id = "O #9",  direction = strategy.long, qty = lots, limit = new_ten_grid_9)        strategy.entry(id = "O #10", direction = strategy.long, qty = lots, limit = new_ten_grid_10)    if close > takeprofitlevel        strategy.cancel_all()    if close < destroyall        strategy.cancel_all()if new_ten_grid_2 and ten_grid == true    strategy.exit(id = "C #1", from_entry = "O #1", qty = 100, limit = new_ten_grid_2)if new_ten_grid_3 and ten_grid == true    strategy.exit(id = "C #2", from_entry = "O #2", qty = 100, limit = new_ten_grid_3)if new_ten_grid_4 and ten_grid == true    strategy.exit(id = "C #3", from_entry = "O #3", qty = 100, limit = new_ten_grid_4)if new_ten_grid_5 and ten_grid == true    strategy.exit(id = "C #4", from_entry = "O #4", qty = 100, limit = new_ten_grid_5)if takeprofitlevel and ten_grid == true    strategy.exit(id = "C #5", from_entry = "O #5", qty = 100, limit = takeprofitlevel)if new_ten_grid_5 and ten_grid == true    strategy.exit(id = "C #6", from_entry = "O #6", qty = 100, limit = new_ten_grid_1)if new_ten_grid_6 and ten_grid == true    strategy.exit(id = "C #7", from_entry = "O #7", qty = 100, limit = new_ten_grid_6)if new_ten_grid_7 and ten_grid == true    strategy.exit(id = "C #8", from_entry = "O #8", qty = 100, limit = new_ten_grid_7)if new_ten_grid_8 and ten_grid == true    strategy.exit(id = "C #9", from_entry = "O #9", qty = 100, limit = new_ten_grid_8)if new_ten_grid_9 and ten_grid == true    strategy.exit(id = "C #10", from_entry = "O #10", qty = 100, limit = new_ten_grid_9)if des_function     strategy.close_all("Destroyed Grid")    strategy.cancel_all()if session.islastbar_regular    strategy.close_all("Dayli Session End")if session.islastbar_regular    strategy.cancel_all()// #########################################################################################################fill(plot(grid_1, color = color.new(color.rgb(0, 255, 132), 95)),      plot(grid_2, color = color.new(color.rgb(0, 255, 132), 95)),           color = color.new(#00ff08, 80))fill(plot(grid_2, color = color.new(color.rgb(0, 255, 132), 95)),       plot(grid_3, color = color.new(color.rgb(0, 255, 132), 95)),           color = color.new(#00ff08, 85))fill(plot(grid_3, color = color.new(color.rgb(0, 255, 132), 95)),       plot(grid_4, color = color.new(color.rgb(0, 255, 132), 95)),           color = color.new(#00ff08, 85))fill(plot(grid_4, color = color.new(color.rgb(0, 255, 132), 95)),      plot(grid_5, color = color.new(color.rgb(0, 255, 132), 95)),           color = color.new(#00ff08, 90))fill(plot(grid_1, color = color.new(color.rgb(0, 255, 132), 95)),       plot(grid_6, color = color.new(color.rgb(0, 255, 132), 95)),          color = color.new(#00ff08, 80))fill(plot(grid_6, color = color.new(color.rgb(0, 255, 132), 95)),       plot(grid_7, color = color.new(color.rgb(0, 255, 132), 95)),           color = color.new(#00ff08, 80))fill(plot(grid_7, color = color.new(color.rgb(0, 255, 132), 95)),      plot(grid_8, color = color.new(color.rgb(0, 255, 132), 95)),           color = color.new(#00ff08, 85))fill(plot(grid_8, color = color.new(color.rgb(0, 255, 132), 95)),       plot(grid_9, color = color.new(color.rgb(0, 255, 132), 95)),           color = color.new(#00ff08, 85))fill(plot(grid_9, color = color.new(color.rgb(0, 255, 132), 95)),      plot(grid_10, color = color.new(color.rgb(0, 255, 132), 95)),          color = color.new(#00ff08, 90))// #########################################################################################################