Zeal Terminal Open Zeal Terminal

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).
Does not run in Zeal Terminal yetRequest.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). 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

    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.

SettingDefaultType and rangeFeeds
Time Condition
From Day1int · min 1 · max 31startDate
From Month1int · min 1 · max 12startDate
From Year2000int · min 1970startDate
To Day31int · min 1 · max 31finishDate
To Month12int · min 1 · max 12finishDate
To Year2025int · min 1970finishDate

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.

fromYearFrom Yearsetting · 2000fromMonthFrom Monthsetting · 1fromDayFrom Daysetting · 1toYearTo Yearsetting · 2025toMonthTo Monthsetting · 12toDayTo Daysetting · 31timetimeprice datapce, rrfss, li, ae, rgdp, gdppce · rrfss +46 valuesstartDatestartDatevaluefinishDatefinishDatevaluelonglongconditionshortshortconditiontime_condtime_condconditionlong_pce, short_pce, long_rrfss, short_rrfss, long_li, short_li, long_ae, short_ae, long_rgdp, short_rgdp, long_gdp, short_gdplong_pce · short_pce +1012 conditionsentry:longOpen longstrategy.entryentry:shortOpen shortstrategy.entryclose_all:close_all strategy.close_all

Order rules

OrderFires whenBy defaultLine
Open long longlonglong_rgdp or long_gdpOn49
Open short shortshortshort_gdp or short_rgdpOn50
Close (not time_cond)On52

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 verified

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.

  • 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

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2No 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
PineTSNot testedNot testedNot 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()