Pine Script v5 · Strategy
Monthly Returns of a Strategy in a Chart
A Pine Script v5 strategy built on Pivothigh (2, 1) and Pivotlow (2, 1). It has 2 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 25% of equity and pays 0.1% commission. 11 settings; defaults include Left Bars 2, Right Bars 1 and Precision 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 Monthly Returns of a Strategy in a Chart repaint?
- Yes
- At least one pattern in the source can repaint: intrabar recalculation.
- How did Monthly Returns of a Strategy in a Chart do on BTCUSDT 1D with default settings?
- +21.02%
- From 26 Jan 2024 to 21 Oct 2026, over 76 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
- Does Monthly Returns of a Strategy in a Chart 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: 76 before, 76 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
- Does Monthly Returns of a Strategy in a Chart use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Monthly Returns of a Strategy in a Chart run in Zeal Terminal?
- Yes
- It compiles in 67 ms and runs 1,000 bars in 104 ms, in the browser.
BTCUSDT · 1D · default settings
- Plot
- Plot
- Winning trade
- Losing trade
- Equity
- Buy and hold
| 7 | Monthly P&L | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 0 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -3 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| -7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| FEB 24 | MAR 24 | APR 24 | MAY 24 | JUN 24 | JUL 24 | AUG 24 | SEP 24 | OCT 24 | NOV 24 | DEC 24 | JAN 25 | FEB 25 | MAR 25 | APR 25 | MAY 25 | JUN 25 | JUL 25 | AUG 25 | SEP 25 | OCT 25 | NOV 25 | DEC 25 | JAN 26 | FEB 26 | MAR 26 | APR 26 | MAY 26 | JUN 26 | JUL 26 | AUG 26 | SEP 26 | OCT 26 | |||||||||||||||||||||||||||||||||||
- Net profit
- +21.02%
- $210,214.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 76
- 28 won · 48 lost
- Profitable
- 36.8%
- of closed trades
- Profit factor
- 1.37
- gross profit ÷ gross loss
- Max drawdown
- 13.02%
- −$153,358.00
One run with the author's default settings, $1,000,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 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 |
|---|---|---|---|
| Left Bars | 2 | int | swh swl |
| Right Bars | 1 | int | swh swl |
| Precision | 2 | int | line 145 |
| Plot Setting | |||
| Plot Location | Bottom Center | string · options ["Top Right" , "Middle Right" , "Bottom Right" , "Top Center", "Middle Center", "Bottom Center", "Top Left" , "Middle Left" , "Bottom Left" ] | plt |
| Bar Height | 0.3 | float · min 0.2 · step 0.01 | line 107 line 109 |
| Bar Width | 1.15 | float · min 1 · step 0.01 | line 107 line 109 line 119 line 150 line 165 |
| Background | #696969 | color | plt line 106 line 160 |
| Border | color.silver | color | plt barCol line 163 |
| Text | color.white | color | plt line 115 line 122 line 130 line 150 line 173 |
| UP | color.green | color | barCol |
| DOWN | color.red | color | barCol |
What it calculates
- PivothighLeft Bars (2), Right Bars (1)
swh · line 34 - PivotlowLeft Bars (2), Right Bars (1)
swl · line 35
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 PivRevLE long | (le) | On | 45 |
| Open PivRevSE short | (se) | On | 47 |
Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.
Does it repaint?
Yes
At least one pattern in the source can repaint; it is marked Check below.
- ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
- ClearFuture-bar referencesNo negative history offsets such as close[-1].
- CheckIntrabar recalculationcalc_on_every_tick = true. Live values can differ from history.
- ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.
The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.
Other markets
The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | +21.0% | +102.5% | 76 | 37% | 1.37 | 13.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | −1.8% | +5.5% | 98 | 28% | 0.92 | 5.8% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | +22.1% | +9.8% | 77 | 38% | 1.23 | 15.8% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | −0.7% | +8.4% | 92 | 29% | 0.97 | 7.8% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −4.8% | +16.7% | 84 | 39% | 0.95 | 22.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +0.5% | +21.5% | 96 | 33% | 1.01 | 8.9% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −17.2% | +148.3% | 81 | 32% | 0.78 | 34.4% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | +2.4% | +17.1% | 95 | 35% | 1.11 | 5.1% | 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 | 30 | 30% | −$14,183.60 |
| Sideways market | 30 | 53% | $228,807.00 |
| Falling market | 16 | 19% | −$4,105.08 |
Rising and falling mean the market moved more than 15% over the 90 bars before entry.
How bad could the drawdown be?
17.4%
The 95th percentile of the worst drawdown when the same 76 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 7.5% to 17.4%; the tick is what actually happened, 12.9%. Order luck alone moves it this much.
All 76 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 7 Feb 2024 43,569.80 | 23 Feb 2024 50,625.00 | 16 | $39,901.90 |
| short | 23 Feb 2024 50,625.00 | 26 Feb 2024 52,985.00 | 3 | −$12,688.60 |
| long | 26 Feb 2024 52,985.00 | 15 Mar 2024 67,024.90 | 18 | $67,841.00 |
| short | 15 Mar 2024 67,024.90 | 25 Mar 2024 68,240.50 | 10 | −$5,620.51 |
| long | 25 Mar 2024 68,240.50 | 12 Apr 2024 67,518.00 | 18 | −$3,436.34 |
| short | 12 Apr 2024 67,518.00 | 21 Apr 2024 65,450.00 | 9 | $7,846.43 |
| long | 21 Apr 2024 65,450.00 | 27 Apr 2024 62,794.00 | 6 | −$11,646.30 |
| short | 27 Apr 2024 62,794.00 | 6 May 2024 64,734.00 | 9 | −$8,934.91 |
| long | 6 May 2024 64,734.00 | 31 May 2024 67,124.60 | 25 | $9,382.65 |
| short | 31 May 2024 67,124.60 | 4 Jun 2024 70,687.60 | 4 | −$14,981.30 |
| long | 4 Jun 2024 70,687.60 | 11 Jun 2024 68,420.00 | 7 | −$9,145.63 |
| short | 11 Jun 2024 68,420.00 | 13 Jul 2024 59,650.00 | 32 | $33,533.60 |
| long | 13 Jul 2024 59,650.00 | 1 Aug 2024 63,456.70 | 19 | $16,951.50 |
| short | 1 Aug 2024 63,456.70 | 20 Aug 2024 60,285.00 | 19 | $13,371.80 |
| long | 20 Aug 2024 60,285.00 | 30 Aug 2024 57,860.00 | 10 | −$11,867.10 |
| short | 30 Aug 2024 57,860.00 | 12 Sep 2024 58,088.00 | 13 | −$1,659.58 |
| long | 12 Sep 2024 58,088.00 | 1 Oct 2024 62,670.00 | 19 | $21,343.70 |
| short | 1 Oct 2024 62,670.00 | 6 Oct 2024 62,484.90 | 5 | $270.95 |
| long | 6 Oct 2024 62,484.90 | 10 Oct 2024 59,828.10 | 4 | −$12,581.60 |
| short | 10 Oct 2024 59,828.10 | 14 Oct 2024 63,480.00 | 4 | −$17,679.20 |
| long | 14 Oct 2024 63,480.00 | 3 Nov 2024 68,820.10 | 20 | $22,606.90 |
| short | 3 Nov 2024 68,820.10 | 6 Nov 2024 73,620.10 | 3 | −$20,187.50 |
| long | 6 Nov 2024 73,620.10 | 5 Dec 2024 93,578.20 | 29 | $75,213.80 |
| short | 5 Dec 2024 93,578.20 | 14 Dec 2024 102,540.00 | 9 | −$29,262.20 |
| long | 14 Dec 2024 102,540.00 | 20 Dec 2024 94,150.00 | 6 | −$24,102.70 |
| short | 20 Dec 2024 94,150.00 | 2 Jan 2025 96,250.00 | 13 | −$6,889.95 |
| long | 2 Jan 2025 96,250.00 | 9 Jan 2025 91,530.40 | 7 | −$14,298.10 |
| short | 9 Jan 2025 91,530.40 | 17 Jan 2025 102,724.00 | 8 | −$34,611.20 |
| long | 17 Jan 2025 102,724.00 | 27 Jan 2025 99,550.00 | 10 | −$8,844.21 |
| short | 27 Jan 2025 99,550.00 | 14 Feb 2025 98,478.40 | 18 | $2,340.81 |
| long | 14 Feb 2025 98,478.40 | 18 Feb 2025 94,088.20 | 4 | −$12,406.20 |
| short | 18 Feb 2025 94,088.20 | 21 Feb 2025 98,826.00 | 3 | −$13,802.80 |
| long | 21 Feb 2025 98,826.00 | 24 Feb 2025 94,871.90 | 3 | −$10,877.20 |
| short | 24 Feb 2025 94,871.90 | 14 Mar 2025 84,539.90 | 18 | $27,501.00 |
| long | 14 Mar 2025 84,539.90 | 3 Apr 2025 81,278.50 | 20 | −$10,753.30 |
| short | 3 Apr 2025 81,278.50 | 11 Apr 2025 83,588.00 | 8 | −$7,952.67 |
| long | 11 Apr 2025 83,588.00 | 29 May 2025 106,601.00 | 48 | $71,391.30 |
| short | 29 May 2025 106,601.00 | 9 Jun 2025 106,795.00 | 11 | −$1,058.92 |
| long | 9 Jun 2025 106,795.00 | 20 Jun 2025 103,371.00 | 11 | −$9,409.46 |
| short | 20 Jun 2025 103,371.00 | 25 Jun 2025 106,525.00 | 5 | −$8,926.18 |
| long | 25 Jun 2025 106,525.00 | 20 Jul 2025 116,813.00 | 25 | $25,657.80 |
| short | 20 Jul 2025 116,813.00 | 7 Aug 2025 115,720.00 | 18 | $2,049.64 |
| long | 7 Aug 2025 115,720.00 | 18 Aug 2025 116,804.00 | 11 | $2,050.03 |
| short | 18 Aug 2025 116,804.00 | 5 Sep 2025 112,575.00 | 18 | $9,554.93 |
| long | 5 Sep 2025 112,575.00 | 22 Sep 2025 114,384.00 | 17 | $3,964.85 |
| short | 22 Sep 2025 114,384.00 | 1 Oct 2025 117,900.00 | 9 | −$9,260.93 |
| long | 1 Oct 2025 117,900.00 | 9 Oct 2025 120,575.00 | 8 | $5,830.56 |
| short | 9 Oct 2025 120,575.00 | 26 Oct 2025 112,105.00 | 17 | $19,323.60 |
| long | 26 Oct 2025 112,105.00 | 30 Oct 2025 106,667.00 | 4 | −$14,447.90 |
| short | 30 Oct 2025 106,667.00 | 26 Nov 2025 89,228.00 | 27 | $46,001.80 |
| long | 26 Nov 2025 89,228.00 | 7 Dec 2025 88,056.00 | 11 | −$4,463.30 |
| short | 7 Dec 2025 88,056.00 | 9 Dec 2025 94,150.00 | 2 | −$20,939.90 |
| long | 9 Dec 2025 94,150.00 | 14 Dec 2025 89,260.60 | 5 | −$15,653.20 |
| short | 14 Dec 2025 89,260.60 | 22 Dec 2025 90,365.90 | 8 | −$4,094.18 |
| long | 22 Dec 2025 90,365.90 | 18 Jan 2026 94,293.40 | 27 | $11,763.60 |
| short | 18 Jan 2026 94,293.40 | 25 Feb 2026 68,698.70 | 38 | $77,207.30 |
| long | 25 Feb 2026 68,698.70 | 21 Mar 2026 68,793.30 | 24 | −$192.40 |
| short | 21 Mar 2026 68,793.30 | 25 Mar 2026 71,817.10 | 4 | −$14,110.10 |
| long | 25 Mar 2026 71,817.10 | 27 Mar 2026 67,360.60 | 2 | −$19,370.70 |
| short | 27 Mar 2026 67,360.60 | 6 Apr 2026 69,310.00 | 10 | −$9,228.41 |
| long | 6 Apr 2026 69,310.00 | 13 May 2026 79,181.50 | 37 | $41,308.40 |
| short | 13 May 2026 79,181.50 | 12 Jun 2026 64,234.70 | 30 | $57,187.60 |
| long | 12 Jun 2026 64,234.70 | 23 Jun 2026 62,272.10 | 11 | −$10,385.90 |
| short | 23 Jun 2026 62,272.10 | 14 Jul 2026 64,692.80 | 21 | −$13,024.20 |
| long | 14 Jul 2026 64,692.80 | 27 Jul 2026 63,739.70 | 13 | −$5,281.73 |
| short | 27 Jul 2026 63,739.70 | 7 Aug 2026 65,025.20 | 11 | −$6,958.62 |
| long | 7 Aug 2026 65,025.20 | 13 Aug 2026 63,238.00 | 6 | −$9,153.23 |
| short | 13 Aug 2026 63,238.00 | 19 Aug 2026 65,474.50 | 6 | −$11,514.40 |
| long | 19 Aug 2026 65,474.50 | 1 Sep 2026 76,888.00 | 13 | $52,609.40 |
| short | 1 Sep 2026 76,888.00 | 3 Sep 2026 81,478.90 | 2 | −$19,754.90 |
| long | 3 Sep 2026 81,478.90 | 10 Sep 2026 77,620.00 | 7 | −$15,642.60 |
| short | 10 Sep 2026 77,620.00 | 18 Sep 2026 79,600.00 | 8 | −$8,526.36 |
| long | 18 Sep 2026 79,600.00 | 28 Sep 2026 82,874.90 | 10 | $12,122.80 |
| short | 28 Sep 2026 82,874.90 | 2 Oct 2026 85,650.00 | 4 | −$11,062.10 |
| long | 2 Oct 2026 85,650.00 | 8 Oct 2026 82,563.00 | 6 | −$11,700.30 |
| short | 8 Oct 2026 82,563.00 | 21 Oct 2026 84,352.00 | 13 | −$7,222.82 |
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 |
|---|---|---|---|---|---|
| Monthly Returns of a Strategy in a Chart this page | — | v5 strategy | +21.0% | 76 | 13.0% |
| Pivot Point Breakout by EduardoMattje | pivotlow pivothigh | v5 strategy | +93.0% | 25 | 32.3% |
| ZigZag by Zeal Terminal | pivothigh pivotlow | v5 indicator | indicator | ||
| RSI Centered Pivots by OztheWoz | pivotlow pivothigh | v4 strategy | +98.0% | 4 | 160.2% |
| ABCD Strategy by kerok3g | pivothigh pivotlow | v5 strategy | −2.7% | 4 | 3.0% |
| Steven Primo's bollinger bands strategy by EduardoMattje | pivothigh pivotlow | v5 strategy | −17.7% | 15 | 28.2% |
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?
No
The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 76 before, 76 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.
⋯// © QuantNomad-//@version=5+//@version=6strategy("Monthly Returns in a Chart", overlay = true, ⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 67 ms | Yes 1,000 bars in 104 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/// © QuantNomad//@version=5strategy("Monthly Returns in a Chart", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 25, calc_on_every_tick = true, commission_type = strategy.commission.percent, commission_value = 0.1)// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|// | INPUTS |// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|leftBars = input.int(2, title = "Left Bars" )rightBars = input.int(1, title = "Right Bars")prec = input.int(2, title = "Precision" )// Plot LocationinPlotPos = input.string(title="Plot Location", defval= "Bottom Center", options =["Top Right" , "Middle Right" , "Bottom Right" , "Top Center", "Middle Center", "Bottom Center", "Top Left" , "Middle Left" , "Bottom Left" ], group= "Plot Setting")// Bar SizebarHigh = input.float(0.3, "Bar Height", minval = 0.2, step= 0.01, group = "Plot Setting")barWdth = input.float(1.15, "Bar Width" , minval = 1, step= 0.01, group = "Plot Setting")// Plot ColorpltCol = input.color(#696969, title="Background ", group = "Plot Setting", inline = "1")borCol = input.color(color.silver, title="Border ", group = "Plot Setting", inline = "2")txtCol = input.color(color.white, title="Text ", group = "Plot Setting", inline = "3")// Bar ColorposCol = input.color(color.green, title=" UP ", group = "Plot Setting", inline = "1")negCol = input.color(color.red, title=" DOWN", group = "Plot Setting", inline = "2")// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|// | CALCULATION |// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|// +++++++++++++++++++++++++++++++++++ STRATEGY// Pivot Points swh = ta.pivothigh(leftBars, rightBars)swl = ta.pivotlow(leftBars, rightBars)hprice = 0.0hprice := not na(swh) ? swh : hprice[1]lprice = 0.0lprice := not na(swl) ? swl : lprice[1]le = falsele := not na(swh) ? true : (le[1] and high > hprice ? false : le[1])se = falsese := not na(swl) ? true : (se[1] and low < lprice ? false : se[1])if (le) strategy.entry("PivRevLE", strategy.long, comment="PivRevLE", stop=hprice + syminfo.mintick)if (se) strategy.entry("PivRevSE", strategy.short, comment="PivRevSE", stop=lprice - syminfo.mintick)plot(hprice, color = color.green, linewidth = 2)plot(lprice, color = color.red, linewidth = 2)// +++++++++++++++++++++++++++++++++++ OUTPUT ARRAYnew_month = month(time) != month(time[1])bar_pnl = strategy.equity / strategy.equity[1] - 1cur_month_pnl = 0.0// Current Monthly P&Lcur_month_pnl := new_month ? 0.0 : (1 + cur_month_pnl[1]) * (1 + bar_pnl) - 1 // Arrays to store Yearly and Monthly P&Lsvar month_pnl = array.new_float(0)var month_time = array.new_int(0)last_computed = falseif (not na(cur_month_pnl[1]) and (new_month or barstate.islast)) if (last_computed[1]) array.pop(month_pnl) array.pop(month_time) array.push(month_pnl , 100 * cur_month_pnl[1]) array.push(month_time, time[1])last_computed := barstate.islast ? true : nz(last_computed[1])if array.size(month_pnl) > 71 array.shift(month_pnl) array.shift(month_time)// Find the Maximum Number for Plot ScalescalCoef = 32/math.max(math.abs(array.min(month_pnl)), math.abs(array.max(month_pnl)))// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|// | TABLE |// |++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|// Get months NamemonNme(m) => mnth = array.from("JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC") array.get(mnth, m-1)// Get Table PositionpltPos(p) => switch p "Top Right" => position.top_right "Middle Right" => position.middle_right "Bottom Right" => position.bottom_right "Top Center" => position.top_center "Middle Center" => position.middle_center "Bottom Center" => position.bottom_center "Top Left" => position.top_left "Middle Left" => position.middle_left => position.bottom_left// Find Number of ColumnsnumCol = array.size(month_pnl) * 2 + 2 < 10 ? 10 : array.size(month_pnl) * 2 + 2// Set Up Plot Tablevar plt = table.new(position.bottom_left, 1 , 1)plt := table.new(pltPos(inPlotPos), numCol, 69, bgcolor = color.new(pltCol, 50), frame_width = 1, frame_color = borCol, border_width = 0, border_color = color.new(txtCol, 100))// Plot CellpltCell (x, y, w, h, col, tt) => table.cell(plt, x, y, width = w, height = h, bgcolor = col) table.cell_set_tooltip(plt, x, y, tt)// Plot ColumnspltCol (x, y, k, col, tt) => pltCell(x, y > 0 ? 33 - k : y < 0 ? 35 - k : 33, barWdth, barHigh, color.new(col, 0), tt) pltCell(x, y > 0 ? 35 + k : y < 0 ? 33 + k : 33, barWdth, barHigh, color.new(col, 100), tt)// Label Y-Axis IncrementsyInc(y, val) => table.cell(plt, 0, y-2, text = str.tostring(val, "#.#"), text_halign = text.align_center, text_valign = text.align_center, text_color = txtCol, text_size = size.small, width = 1.5, height = 0.2) table.merge_cells(plt, 0, y-2, 0, y+2)// Plot TitlepltTtl(x, xf, txt, txtCol) => table.cell(plt, x, 0, width = barWdth, height = 2, bgcolor = color.new(color.black, 100), text_halign = text.align_center, text_valign = text.align_top, text = txt, text_color = txtCol, text_size = size.small) table.merge_cells(plt, x, 0, xf, 0)if barstate.islast if array.size(month_pnl) > 0 // Reset Table. for i = 0 to numCol - 1 for j = 0 to 68 pltCell(i, j, 0.001, 0.001, color.new(txtCol, 100), "") w = 0 for i = 1 to array.size(month_pnl) * 2 + 1 if i%2 == 0 barCol = array.get(month_pnl, w) > 0 ? posCol : array.get(month_pnl, w) < 0 ? negCol : borCol //Plot Columns if scalCoef * array.get(month_pnl, w) == 0 pltCol(i, array.get(month_pnl, w), 0, barCol, "") else for k = 0 to math.round(scalCoef * array.get(month_pnl, w)) pltCol(i, array.get(month_pnl, w), k, barCol, str.tostring(math.round(array.get(month_pnl, w), prec)) + "\n" + monNme(month(array.get(month_time, w))) + "-" + str.tostring(year(array.get(month_time, w)))) // X-Axis Increments table.cell(plt, i, 68, width = barWdth, text_color = txtCol, text = monNme(month(array.get(month_time, w))) + "\n" + str.tostring(year(array.get(month_time, w)) - 2000), text_size = size.tiny) table.merge_cells(plt, i, 68, i+1, 68) w := w + 1 else for j = 0 to 68 pltCell(i, j, 0.05, 0.001, color.new(pltCol, 94), "") if i >= 2 and i <= array.size(month_pnl) * 2 pltCell(i, 34, 0.05, 0.005, borCol, "") // Y-Axis Increments table.cell(plt, 0, 1, width = barWdth, height = 1) yInc( 2, math.ceil( 32/scalCoef)) yInc(18, math.round(16/scalCoef)) yInc(34, 0/scalCoef) yInc(49, math.round(-16/scalCoef)) yInc(66, math.floor(-32/scalCoef)) // Title pltTtl( 1, 8, "Monthly P&L", txtCol)