Pine Script v4 · Strategy
Grid System With Fake Martingale
A Pine Script v4 strategy built on Change (strategy.losstrades). It has 4 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade is one contract and pays no commission. 4 settings; defaults include Point 1., Order Size 1 and Martingale Multiplier 2..
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 System With Fake Martingale repaint?
- No
- No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 299 of 299 trades.
- How did Grid System With Fake Martingale do on BTCUSDT 1D with default settings?
- +0.50%
- From 26 Jan 2024 to 21 Oct 2026, over 997 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Can Grid System With Fake Martingale be converted to Pine Script v5?
- Yes
- The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
- Does Grid System With Fake Martingale use a stop loss?
- Yes
- strategy.exit sets a stop on line 26, 29.
- Does Grid System With Fake Martingale run in Zeal Terminal?
- Yes
- It compiles in 13 ms and runs 1,000 bars in 58 ms, in the browser.
BTCUSDT · 1D · default settings
- Equity
- Maximum
- Winning trade
- Losing trade
- Equity
- Buy and hold
- Net profit
- +0.50%
- $496.94
- Buy and hold
- +102.5%
- same period
- Closed trades
- 997
- 498 won · 499 lost
- Profitable
- 49.9%
- of closed trades
- Profit factor
- 1.21
- gross profit ÷ gross loss
- Max drawdown
- 1.44%
- −$1,442.64
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.
-
Check
No commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Note
1 setting has no label
In the settings dialog point (line 5) shows 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.
-
Note
Uses transp =, which v5 removed line 37
transp = on line 37, 38. v5 folds the transparency into the colour with color.new(c, transp).
Upgrade and export
Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.
- Upgrading to v5 renames change → ta.change, max → math.max.
v4 → v5
VerifiedSame 997 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 3: //@version=4 → //@version=5
- Line 15: change → ta.change
- Line 16: change → ta.change
- Line 34: max → math.max
- Line 37: transp = 0 → color.new(#2196f3, 0)
- Line 38: transp = 0 → color.new(css, 0)
⋯// © alexgrover-//@version=4+//@version=5strategy("Grid System With Fake Martingale",process_orders_on_close=true)⋯size = 0.-loss = change(strategy.losstrades)+loss = ta.change(strategy.losstrades)-win = change(strategy.wintrades)+win = ta.change(strategy.wintrades)if anti⋯rmax = 0.-rmax := max(eq,nz(rmax[1]))+rmax := math.max(eq,nz(rmax[1]))//----css = eq > cap ? #0cb51a : #e65100-a = plot(eq,"Equity",#2196f3,2,transp=0)+a = plot(eq,"Equity",color.new(#2196f3, 0),2)-b = plot(rmax,"Maximum",css,2,transp=0)+b = plot(rmax,"Maximum",color.new(css, 0),2)fill(a,b,css,80)Same 997 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.
- Line 5: input() → input.float()
- Line 6: input() → input.int()
- Line 7: input() → input.float()
- Line 8: input() → input.bool()
⋯strategy("Grid System With Fake Martingale",process_orders_on_close=true)-point = input(1.)+point = input.float(1.)-os = input(1,"Order Size")+os = input.int(1,"Order Size")-mf = input(2.,"Martingale Multiplier")+mf = input.float(2.,"Martingale Multiplier")-anti = input(false,"Anti Martingale")+anti = input.bool(false,"Anti Martingale")//------------------------------------------------------------------------------⋯Does it run in Pine Script v6?
No
The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 997 before, 781 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯// © alexgrover-//@version=5+//@version=6strategy("Grid System With Fake Martingale",process_orders_on_close=true)⋯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 |
|---|---|---|---|
| Point (no label in the script) | 1. | float | baseline upper lower |
| Order Size | 1 | int | size entry Buy entry Sell |
| Martingale Multiplier | 2. | float | size |
| Anti Martingale | false | bool | line 17 |
What it calculates
- Change (
change,ta.changein v5)strategy.losstradesloss · line 15 - Change (
change,ta.changein v5)strategy.wintradeswin · line 16
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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open Buy long | baseline > baseline[1] and strategy.opentrades == 0 | On | 25 |
| Exit buy/tp/sl stop and limit | baseline > baseline[1] and strategy.opentrades == 0 | On | 26 |
| Open Sell short | baseline < baseline[1] and strategy.opentrades == 0 | On | 28 |
| Exit sell/tp/sl stop and limit | baseline < baseline[1] and strategy.opentrades == 0 | On | 29 |
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.5% | +102.5% | 997 | 50% | 1.21 | 1.4% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +0.5% | +5.5% | 994 | 52% | 1.29 | 0.3% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −1.8% | +9.8% | 490 | 50% | 0.35 | 3.9% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +0.3% | +8.4% | 592 | 49% | 1.19 | 0.3% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −0.2% | +16.7% | 90 | 54% | 0.32 | 0.3% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.0% | +21.5% | 91 | 59% | 1.63 | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −0.2% | +148.3% | 120 | 40% | 0.77 | 0.8% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −0.3% | +17.1% | 17 | 18% | 0.08 | 0.4% | 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 | 343 | 50% | $280.94 |
| Sideways market | 430 | 50% | $99.00 |
| Falling market | 224 | 50% | $117.00 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
1.0%
The 95th percentile of the worst drawdown when the same 997 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 0.5% to 1.0%; the tick is what actually happened, 1.0%. Order luck alone moves it this much.
The first 150 of 997 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 27 Jan 2024 42,120.60 | 28 Jan 2024 42,119.60 | 1 | −$1.00 |
| short | 28 Jan 2024 42,031.10 | 29 Jan 2024 42,029.10 | 1 | $2.00 |
| long | 29 Jan 2024 43,302.70 | 30 Jan 2024 43,303.70 | 1 | $1.00 |
| short | 30 Jan 2024 42,941.10 | 31 Jan 2024 42,940.10 | 1 | $1.00 |
| short | 31 Jan 2024 42,580.00 | 1 Feb 2024 42,579.00 | 1 | $1.00 |
| long | 1 Feb 2024 43,082.90 | 2 Feb 2024 43,083.90 | 1 | $1.00 |
| long | 2 Feb 2024 43,200.00 | 3 Feb 2024 43,201.00 | 1 | $1.00 |
| short | 3 Feb 2024 43,011.10 | 4 Feb 2024 43,012.10 | 1 | −$1.00 |
| short | 4 Feb 2024 42,582.90 | 5 Feb 2024 42,580.90 | 1 | $2.00 |
| long | 5 Feb 2024 42,708.70 | 6 Feb 2024 42,707.70 | 1 | −$1.00 |
| long | 6 Feb 2024 43,098.90 | 7 Feb 2024 43,096.90 | 1 | −$2.00 |
| long | 7 Feb 2024 44,349.60 | 8 Feb 2024 44,345.60 | 1 | −$4.00 |
| long | 8 Feb 2024 45,288.70 | 9 Feb 2024 45,280.70 | 1 | −$8.00 |
| long | 9 Feb 2024 47,132.80 | 10 Feb 2024 47,116.80 | 1 | −$16.00 |
| long | 10 Feb 2024 47,751.10 | 11 Feb 2024 47,719.10 | 1 | −$32.00 |
| long | 11 Feb 2024 48,300.00 | 12 Feb 2024 48,236.00 | 1 | −$64.00 |
| long | 12 Feb 2024 49,917.30 | 13 Feb 2024 50,045.30 | 1 | $128.00 |
| short | 13 Feb 2024 49,699.60 | 14 Feb 2024 49,698.60 | 1 | $1.00 |
| long | 14 Feb 2024 51,795.20 | 15 Feb 2024 51,794.20 | 1 | −$1.00 |
| long | 15 Feb 2024 51,880.00 | 16 Feb 2024 51,878.00 | 1 | −$2.00 |
| long | 16 Feb 2024 52,124.10 | 17 Feb 2024 52,128.10 | 1 | $4.00 |
| short | 17 Feb 2024 51,642.60 | 18 Feb 2024 51,641.60 | 1 | $1.00 |
| long | 18 Feb 2024 52,137.70 | 19 Feb 2024 52,138.70 | 1 | $1.00 |
| short | 19 Feb 2024 51,774.70 | 20 Feb 2024 51,773.70 | 1 | $1.00 |
| long | 20 Feb 2024 52,258.80 | 21 Feb 2024 52,259.80 | 1 | $1.00 |
| short | 21 Feb 2024 51,849.40 | 22 Feb 2024 51,850.40 | 1 | −$1.00 |
| short | 22 Feb 2024 51,288.40 | 23 Feb 2024 51,290.40 | 1 | −$2.00 |
| short | 23 Feb 2024 50,744.20 | 24 Feb 2024 50,740.20 | 1 | $4.00 |
| long | 24 Feb 2024 51,568.20 | 25 Feb 2024 51,567.20 | 1 | −$1.00 |
| long | 25 Feb 2024 51,728.80 | 26 Feb 2024 51,726.80 | 1 | −$2.00 |
| long | 26 Feb 2024 54,476.50 | 27 Feb 2024 54,472.50 | 1 | −$4.00 |
| long | 27 Feb 2024 57,037.30 | 28 Feb 2024 57,029.30 | 1 | −$8.00 |
| long | 28 Feb 2024 62,432.10 | 29 Feb 2024 62,448.10 | 1 | $16.00 |
| short | 29 Feb 2024 61,131.00 | 1 Mar 2024 61,130.00 | 1 | $1.00 |
| long | 1 Mar 2024 62,387.90 | 2 Mar 2024 62,388.90 | 1 | $1.00 |
| short | 2 Mar 2024 61,987.30 | 3 Mar 2024 61,986.30 | 1 | $1.00 |
| long | 3 Mar 2024 63,114.00 | 4 Mar 2024 63,113.00 | 1 | −$1.00 |
| long | 4 Mar 2024 68,245.70 | 5 Mar 2024 68,247.70 | 1 | $2.00 |
| short | 5 Mar 2024 63,724.00 | 6 Mar 2024 63,723.00 | 1 | $1.00 |
| long | 6 Mar 2024 66,074.00 | 7 Mar 2024 66,073.00 | 1 | −$1.00 |
| long | 7 Mar 2024 66,823.20 | 8 Mar 2024 66,821.20 | 1 | −$2.00 |
| long | 8 Mar 2024 68,124.20 | 9 Mar 2024 68,120.20 | 1 | −$4.00 |
| long | 9 Mar 2024 68,313.30 | 10 Mar 2024 68,305.30 | 1 | −$8.00 |
| long | 10 Mar 2024 68,955.90 | 11 Mar 2024 68,939.90 | 1 | −$16.00 |
| long | 11 Mar 2024 72,078.10 | 12 Mar 2024 72,110.10 | 1 | $32.00 |
| short | 12 Mar 2024 71,452.00 | 13 Mar 2024 71,451.00 | 1 | $1.00 |
| long | 13 Mar 2024 73,072.40 | 14 Mar 2024 73,073.40 | 1 | $1.00 |
| short | 14 Mar 2024 71,388.90 | 15 Mar 2024 71,389.90 | 1 | −$1.00 |
| short | 15 Mar 2024 69,499.90 | 16 Mar 2024 69,501.90 | 1 | −$2.00 |
| short | 16 Mar 2024 65,300.60 | 17 Mar 2024 65,296.60 | 1 | $4.00 |
| long | 17 Mar 2024 68,393.50 | 18 Mar 2024 68,394.50 | 1 | $1.00 |
| short | 18 Mar 2024 67,610.00 | 19 Mar 2024 67,611.00 | 1 | −$1.00 |
| short | 19 Mar 2024 61,937.40 | 20 Mar 2024 61,935.40 | 1 | $2.00 |
| long | 20 Mar 2024 67,840.50 | 21 Mar 2024 67,841.50 | 1 | $1.00 |
| short | 21 Mar 2024 65,501.30 | 22 Mar 2024 65,502.30 | 1 | −$1.00 |
| short | 22 Mar 2024 63,796.60 | 23 Mar 2024 63,794.60 | 1 | $2.00 |
| long | 23 Mar 2024 63,990.00 | 24 Mar 2024 63,989.00 | 1 | −$1.00 |
| long | 24 Mar 2024 67,210.00 | 25 Mar 2024 67,208.00 | 1 | −$2.00 |
| long | 25 Mar 2024 69,880.00 | 26 Mar 2024 69,876.00 | 1 | −$4.00 |
| long | 26 Mar 2024 69,988.00 | 27 Mar 2024 69,980.00 | 1 | −$8.00 |
| short | 27 Mar 2024 69,470.00 | 28 Mar 2024 69,454.00 | 1 | $16.00 |
| long | 28 Mar 2024 70,780.60 | 29 Mar 2024 70,781.60 | 1 | $1.00 |
| short | 29 Mar 2024 69,850.50 | 30 Mar 2024 69,849.50 | 1 | $1.00 |
| short | 30 Mar 2024 69,582.20 | 31 Mar 2024 69,581.20 | 1 | $1.00 |
| long | 31 Mar 2024 71,280.00 | 1 Apr 2024 71,281.00 | 1 | $1.00 |
| short | 1 Apr 2024 69,649.80 | 2 Apr 2024 69,650.80 | 1 | −$1.00 |
| short | 2 Apr 2024 65,464.00 | 3 Apr 2024 65,462.00 | 1 | $2.00 |
| long | 3 Apr 2024 65,963.30 | 4 Apr 2024 65,962.30 | 1 | −$1.00 |
| long | 4 Apr 2024 68,487.80 | 5 Apr 2024 68,489.80 | 1 | $2.00 |
| short | 5 Apr 2024 67,820.60 | 6 Apr 2024 67,819.60 | 1 | $1.00 |
| long | 6 Apr 2024 68,896.00 | 7 Apr 2024 68,895.00 | 1 | −$1.00 |
| long | 7 Apr 2024 69,360.40 | 8 Apr 2024 69,358.40 | 1 | −$2.00 |
| long | 8 Apr 2024 71,620.00 | 9 Apr 2024 71,624.00 | 1 | $4.00 |
| short | 9 Apr 2024 69,146.00 | 10 Apr 2024 69,145.00 | 1 | $1.00 |
| long | 10 Apr 2024 70,631.10 | 11 Apr 2024 70,632.10 | 1 | $1.00 |
| short | 11 Apr 2024 70,006.20 | 12 Apr 2024 70,007.20 | 1 | −$1.00 |
| short | 12 Apr 2024 67,116.50 | 13 Apr 2024 67,118.50 | 1 | −$2.00 |
| short | 13 Apr 2024 63,924.50 | 14 Apr 2024 63,920.50 | 1 | $4.00 |
| long | 14 Apr 2024 65,661.80 | 15 Apr 2024 65,662.80 | 1 | $1.00 |
| short | 15 Apr 2024 63,420.00 | 16 Apr 2024 63,421.00 | 1 | −$1.00 |
| long | 16 Apr 2024 63,793.40 | 17 Apr 2024 63,795.40 | 1 | $2.00 |
| short | 17 Apr 2024 61,277.40 | 18 Apr 2024 61,276.40 | 1 | $1.00 |
| long | 18 Apr 2024 63,470.10 | 19 Apr 2024 63,471.10 | 1 | $1.00 |
| long | 19 Apr 2024 63,818.00 | 20 Apr 2024 63,817.00 | 1 | −$1.00 |
| long | 20 Apr 2024 64,940.60 | 21 Apr 2024 64,938.60 | 1 | −$2.00 |
| long | 22 Apr 2024 66,819.30 | 23 Apr 2024 66,823.30 | 1 | $4.00 |
| short | 23 Apr 2024 66,414.00 | 24 Apr 2024 66,415.00 | 1 | −$1.00 |
| short | 24 Apr 2024 64,289.60 | 25 Apr 2024 64,291.60 | 1 | −$2.00 |
| long | 25 Apr 2024 64,498.30 | 26 Apr 2024 64,502.30 | 1 | $4.00 |
| short | 26 Apr 2024 63,770.00 | 27 Apr 2024 63,771.00 | 1 | −$1.00 |
| short | 27 Apr 2024 63,462.00 | 28 Apr 2024 63,460.00 | 1 | $2.00 |
| short | 28 Apr 2024 63,118.60 | 29 Apr 2024 63,119.60 | 1 | −$1.00 |
| long | 29 Apr 2024 63,866.00 | 30 Apr 2024 63,868.00 | 1 | $2.00 |
| short | 30 Apr 2024 60,672.00 | 1 May 2024 60,673.00 | 1 | −$1.00 |
| short | 1 May 2024 58,365.00 | 2 May 2024 58,367.00 | 1 | −$2.00 |
| long | 2 May 2024 59,060.60 | 3 May 2024 59,056.60 | 1 | −$4.00 |
| long | 3 May 2024 62,882.00 | 4 May 2024 62,874.00 | 1 | −$8.00 |
| long | 4 May 2024 63,892.00 | 5 May 2024 63,908.00 | 1 | $16.00 |
| long | 5 May 2024 64,012.00 | 6 May 2024 64,011.00 | 1 | −$1.00 |
| short | 6 May 2024 63,165.20 | 7 May 2024 63,163.20 | 1 | $2.00 |
| short | 7 May 2024 62,312.10 | 8 May 2024 62,313.10 | 1 | −$1.00 |
| short | 8 May 2024 61,193.00 | 9 May 2024 61,191.00 | 1 | $2.00 |
| long | 9 May 2024 63,074.00 | 10 May 2024 63,075.00 | 1 | $1.00 |
| short | 10 May 2024 60,800.00 | 11 May 2024 60,799.00 | 1 | $1.00 |
| long | 11 May 2024 60,826.00 | 12 May 2024 60,825.00 | 1 | −$1.00 |
| long | 12 May 2024 61,484.00 | 13 May 2024 61,482.00 | 1 | −$2.00 |
| long | 13 May 2024 62,940.10 | 14 May 2024 62,944.10 | 1 | $4.00 |
| short | 14 May 2024 61,577.50 | 15 May 2024 61,576.50 | 1 | $1.00 |
| long | 15 May 2024 66,206.50 | 16 May 2024 66,207.50 | 1 | $1.00 |
| short | 16 May 2024 65,235.20 | 17 May 2024 65,234.20 | 1 | $1.00 |
| long | 17 May 2024 67,024.00 | 18 May 2024 67,025.00 | 1 | $1.00 |
| short | 18 May 2024 66,915.20 | 19 May 2024 66,916.20 | 1 | −$1.00 |
| short | 19 May 2024 66,274.00 | 20 May 2024 66,272.00 | 1 | $2.00 |
| long | 20 May 2024 71,446.60 | 21 May 2024 71,447.60 | 1 | $1.00 |
| short | 21 May 2024 70,148.30 | 22 May 2024 70,149.30 | 1 | −$1.00 |
| short | 22 May 2024 69,166.60 | 23 May 2024 69,168.60 | 1 | −$2.00 |
| short | 23 May 2024 67,969.60 | 24 May 2024 67,973.60 | 1 | −$4.00 |
| long | 24 May 2024 68,550.00 | 25 May 2024 68,542.00 | 1 | −$8.00 |
| long | 25 May 2024 69,290.60 | 26 May 2024 69,306.60 | 1 | $16.00 |
| short | 26 May 2024 68,507.70 | 27 May 2024 68,506.70 | 1 | $1.00 |
| long | 27 May 2024 69,436.40 | 28 May 2024 69,437.40 | 1 | $1.00 |
| short | 28 May 2024 68,398.40 | 29 May 2024 68,399.40 | 1 | −$1.00 |
| short | 29 May 2024 67,652.40 | 30 May 2024 67,650.40 | 1 | $2.00 |
| long | 30 May 2024 68,352.20 | 31 May 2024 68,353.20 | 1 | $1.00 |
| short | 31 May 2024 67,540.00 | 1 Jun 2024 67,539.00 | 1 | $1.00 |
| long | 1 Jun 2024 67,766.90 | 2 Jun 2024 67,765.90 | 1 | −$1.00 |
| short | 2 Jun 2024 67,765.60 | 3 Jun 2024 67,763.60 | 1 | $2.00 |
| long | 3 Jun 2024 68,809.90 | 4 Jun 2024 68,808.90 | 1 | −$1.00 |
| long | 4 Jun 2024 70,537.80 | 5 Jun 2024 70,535.80 | 1 | −$2.00 |
| long | 5 Jun 2024 71,108.00 | 6 Jun 2024 71,112.00 | 1 | $4.00 |
| short | 6 Jun 2024 70,799.10 | 7 Jun 2024 70,800.10 | 1 | −$1.00 |
| short | 7 Jun 2024 69,355.60 | 8 Jun 2024 69,353.60 | 1 | $2.00 |
| short | 8 Jun 2024 69,310.50 | 9 Jun 2024 69,309.50 | 1 | $1.00 |
| long | 9 Jun 2024 69,648.10 | 10 Jun 2024 69,647.10 | 1 | −$1.00 |
| short | 10 Jun 2024 69,540.00 | 11 Jun 2024 69,542.00 | 1 | −$2.00 |
| short | 11 Jun 2024 67,314.20 | 12 Jun 2024 67,310.20 | 1 | $4.00 |
| long | 12 Jun 2024 68,264.00 | 13 Jun 2024 68,265.00 | 1 | $1.00 |
| short | 13 Jun 2024 66,773.00 | 14 Jun 2024 66,774.00 | 1 | −$1.00 |
| short | 14 Jun 2024 66,044.00 | 15 Jun 2024 66,042.00 | 1 | $2.00 |
| long | 15 Jun 2024 66,228.30 | 16 Jun 2024 66,227.30 | 1 | −$1.00 |
| long | 16 Jun 2024 66,676.90 | 17 Jun 2024 66,678.90 | 1 | $2.00 |
| short | 17 Jun 2024 66,504.30 | 18 Jun 2024 66,505.30 | 1 | −$1.00 |
| short | 18 Jun 2024 65,175.30 | 19 Jun 2024 65,173.30 | 1 | $2.00 |
| short | 19 Jun 2024 64,974.40 | 20 Jun 2024 64,973.40 | 1 | $1.00 |
| short | 20 Jun 2024 64,870.00 | 21 Jun 2024 64,871.00 | 1 | −$1.00 |
| short | 21 Jun 2024 64,143.60 | 22 Jun 2024 64,141.60 | 1 | $2.00 |
| long | 22 Jun 2024 64,262.00 | 23 Jun 2024 64,263.00 | 1 | $1.00 |
| short | 23 Jun 2024 63,210.00 | 24 Jun 2024 63,211.00 | 1 | −$1.00 |
| short | 24 Jun 2024 60,293.30 | 25 Jun 2024 60,291.30 | 1 | $2.00 |
| long | 25 Jun 2024 61,806.00 | 26 Jun 2024 61,807.00 | 1 | $1.00 |
Similar scripts
No other indicator or strategy here shares enough of its calculations.
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 13 ms | Yes 1,000 bars in 58 ms | Not measured |
| PineTS | No v5 and v6 only | — | 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. PineTS runs Pine Script v5 and v6 only.
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 work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License https://creativecommons.org/licenses/by-sa/4.0/// © alexgrover//@version=4strategy("Grid System With Fake Martingale",process_orders_on_close=true)point = input(1.)os = input(1,"Order Size")mf = input(2.,"Martingale Multiplier")anti = input(false,"Anti Martingale")//------------------------------------------------------------------------------baseline = 0.baseline := nz(close > baseline[1] + point or close < baseline[1] - point ? close : baseline[1],close)//------------------------------------------------------------------------------size = 0.loss = change(strategy.losstrades)win = change(strategy.wintrades)if anti size := win ? size[1]*mf : loss ? 1 : nz(size[1],os)else size := loss ? size[1]*mf : win ? 1 : nz(size[1],os)upper = baseline + point*sizelower = baseline - point*size//------------------------------------------------------------------------------if baseline > baseline[1] and strategy.opentrades == 0 strategy.entry("Buy",strategy.long,qty=os) strategy.exit("buy/tp/sl","Buy",stop=lower,limit=upper)if baseline < baseline[1] and strategy.opentrades == 0 strategy.entry("Sell",strategy.short,qty=os) strategy.exit("sell/tp/sl","Sell",stop=upper,limit=lower)//------------------------------------------------------------------------------cap = strategy.initial_capitaleq = strategy.equityrmax = 0.rmax := max(eq,nz(rmax[1]))//----css = eq > cap ? #0cb51a : #e65100a = plot(eq,"Equity",#2196f3,2,transp=0)b = plot(rmax,"Maximum",css,2,transp=0)fill(a,b,css,80)