Pine Script v5 · Strategy
Swing Stock designed for Monthly-Yearly Trading
A Pine Script v5 strategy with no technical-analysis calculation. It has 3 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 is one contract and pays no commission. 6 settings; defaults include From Day 1, From Month 1 and From Year 2000.
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 Swing Stock designed for Monthly-Yearly Trading repaint?
- Yes
- At least one pattern in the source can repaint: intrabar recalculation.
- Does Swing Stock designed for Monthly-Yearly Trading run in Pine Script v6?
- Not tested
- The v5 script does not run in Zeal Terminal's engine (request.quandl: no data was supplied for 'FRED/PCE|0'. This engine cannot fetch it from TradingView — provide it with ctx.provideRequestData("quandl", "FRED/PCE|0", samples).), so this step could not be checked. The v6 version is shown for reference and is not offered as a download.
- Does Swing Stock designed for Monthly-Yearly Trading use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Swing Stock designed for Monthly-Yearly Trading run in Zeal Terminal?
- No
- Not yet: request.quandl: no data was supplied for 'FRED/PCE|0'. This engine cannot fetch it from TradingView — provide it with ctx.provideRequestData("quandl", "FRED/PCE|0", samples).
Review
What a careful reader of this script would point out, found by checking the source.
-
Check
No stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
Check
No commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Note
No slippage
Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.
-
Note
Uses an argument v6 removed
when = on line 49, 50. The upgraded version below moves each call inside an if block.
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 |
|---|---|---|---|
| Time Condition | |||
| From Day | 1 | int · min 1 · max 31 | startDate |
| From Month | 1 | int · min 1 · max 12 | startDate |
| From Year | 2000 | int · min 1970 | startDate |
| To Day | 31 | int · min 1 · max 31 | finishDate |
| To Month | 12 | int · min 1 · max 12 | finishDate |
| To Year | 2025 | int · min 1970 | finishDate |
What it calculates
No technical-analysis calculation: the script works on prices and settings directly.
Signal flow
How price data and settings reach the orders. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open long long | longlong_rgdp or long_gdp | On | 49 |
| Open short short | shortshort_gdp or short_rgdp | On | 50 |
| Close | (not time_cond) | On | 52 |
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.
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 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.
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.
- 2 strategy calls use the when = argument (line 49, 50). It is deprecated in v5 and removed in v6, where each call moves inside an if block.
- No v6-only features. v6 is not needed to run this script.
Clean v5
Not verifiedThe v5 script does not run in Zeal Terminal's engine (request.quandl: no data was supplied for 'FRED/PCE|0'. This engine cannot fetch it from TradingView — provide it with ctx.provideRequestData("quandl", "FRED/PCE|0", samples).), so this step could not be checked.
- Line 49: when = long → if block
- Line 50: when = short → if block
⋯if(time_cond)- strategy.entry("long",strategy.long,when=long )+ if long+ strategy.entry("long",strategy.long )- strategy.entry('short',strategy.short,when=short)+ if short+ strategy.entry('short',strategy.short)if(not time_cond)⋯Does it run in Pine Script v6?
Not tested
The v5 script does not run in Zeal Terminal's engine (request.quandl: no data was supplied for 'FRED/PCE|0'. This engine cannot fetch it from TradingView — provide it with ctx.provideRequestData("quandl", "FRED/PCE|0", samples).), 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.
⋯// © exlux99-//@version=5+//@version=6strategy(title="World Indicators Testing", overlay=true, calc_on_every_tick=true )⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | No Request.quandl: no data was supplied for 'FRED/PCE|0'. This engine cannot fetch it from TradingView — provide it with ctx.provideRequestData("quandl", "FRED/PCE|0", samples). | 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/// © exlux99//@version=5strategy(title="World Indicators Testing", overlay=true, calc_on_every_tick=true )// Personal Consumption Expenditures// FRED/PCE// Real Retail and Food Services Sales// FRED/RRSFS// Leading Index for the United States// FRED/USSLIND// All Employees: Total Nonfarm Payrolls// FRED/PAYEMS// Real Gross Domestic Product// FRED/GDPC1// Gross Domestic Product// FRED/GDPpce= request.quandl('FRED/PCE', barmerge.gaps_off,0)long_pce = pce>pce[1]short_pce =pce<pce[1]rrfss=request.quandl('FRED/RRSFS', barmerge.gaps_off,0)long_rrfss = rrfss>rrfss[1]short_rrfss = rrfss<rrfss[1]li=request.quandl('FRED/USSLIND', barmerge.gaps_off,0)long_li = li>0short_li = li<0ae=request.quandl('FRED/PAYEMS', barmerge.gaps_off,0)long_ae= ae>ae[1]short_ae = ae<ae[1]rgdp=request.quandl('FRED/GDPC1', barmerge.gaps_off,0)long_rgdp = rgdp>rgdp[1]short_rgdp = rgdp<rgdp[1]gdp=request.quandl('FRED/GDP', barmerge.gaps_off,0)long_gdp=gdp>gdp[1]short_gdp=gdp<gdp[1]long= long_rgdp or long_gdp //or long_rrfssshort = short_gdp or short_rgdp// or short_rrfssfromDay = input.int(defval=1, title='From Day', minval=1, maxval=31, group="Time Condition")fromMonth = input.int(defval=1, title='From Month', minval=1, maxval=12, group="Time Condition")fromYear = input.int(defval=2000, title='From Year', minval=1970, group="Time Condition")//monday and session // To Date InputstoDay = input.int(defval=31, title='To Day', minval=1, maxval=31, group="Time Condition")toMonth = input.int(defval=12, title='To Month', minval=1, maxval=12, group="Time Condition")toYear = input.int(defval=2025, title='To Year', minval=1970, group="Time Condition")startDate = timestamp(fromYear, fromMonth, fromDay, 00, 00)finishDate = timestamp(toYear, toMonth, toDay, 00, 00)time_cond = time >= startDate and time <= finishDateif(time_cond) strategy.entry("long",strategy.long,when=long ) strategy.entry('short',strategy.short,when=short)if(not time_cond) strategy.close_all()