Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Fair Value Strategy - ekmll

A Pine Script v5 strategy with no technical-analysis calculation. It has 16 order rules, 8 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. 14 settings; defaults include Fair Value Index SPX, Strategy Long/Short and Scalar 1.1.

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 Fair Value Strategy - ekmll repaint?
Yes
At least one pattern in the source can repaint: intrabar recalculation.
How did Fair Value Strategy - ekmll do on BTCUSDT 1D with default settings?
Not measured
It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its code limits trading to a date window, which can leave this period out. It closed no trades on the other markets either. A backtest, not investment advice.
Does Fair Value Strategy - ekmll run in Pine Script v6?
Not tested
Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download.
Does Fair Value Strategy - ekmll use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Fair Value Strategy - ekmll run in Zeal Terminal?
Yes
It compiles in 33 ms and runs 1,000 bars in 42 ms, in the browser.

BTCUSDT · 1D · default settings

  • Zero
  • Overbought
  • Oversold
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOctZero$1,000,000$2,025,273Equity from $1,000,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots. The live re-run is not offered here: the script requests (WALCL - WTREGEN - RRPONTSYD) D, SPX D, which this page cannot load in your browser.

Needs (WALCL - WTREGEN - RRPONTSYD) D data, not available: not a Binance spot market Needs SPX D data, not available: not a Binance spot market Values that depend on it are empty on this chart.

Net profit
0.00%
$0.00
Buy and hold
+102.5%
same period
Closed trades
0
0 won · 0 lost
Profitable
0.0%
of closed trades
Profit factor
—
gross profit ÷ gross loss
Max drawdown
0.00%
$0.00

One run with the author's default settings, $1,000,000 starting capital, commission as the script sets it. 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.

  • 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.

Settings

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

SettingDefaultType and rangeFeeds
Fair Value IndexSPXstringindex
StrategyLong/Shortstringline 37 line 54 line 67
Scalar1.1floatindex_fair_value
Subtractor1425int · step 25index_fair_value
OB Threshold0int · step 25overbought_signal Overbought
OS Threshold-175int · step 25oversold_signal Oversold
Inversefalseboolline 38 line 55 line 68
Start Day20int · min 1 · max 31afterStartDate
Start Month12int · min 1 · max 12afterStartDate
Start Year2021int · min 1800 · max 2100afterStartDate
Use Close Datetrueboolentry Short close Short close Long close Short close Long close Long close Short close Short close Long line 41 line 43 line 51 line 59 line 65 line 72 line 78
Close Day20int · min 1 · max 31afterEndDate
Close Month12int · min 1 · max 12afterEndDate
Close Year2024int · min 1800 · max 2100afterEndDate

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.

closecloseprice datascalarScalarsetting · 1.1subtractorSubtractorsetting · 1425fv_index_tickerFair Value Indexsetting · SPXtimetimeprice datastartYearStart Yearsetting · 2021startMonthStart Monthsetting · 12startDateStart Daysetting · 20closeYearClose Yearsetting · 2024closeMonthClose Monthsetting · 12closeDayClose Daysetting · 20ob_thresholdOB Thresholdsetting · 0os_thresholdOS Thresholdsetting · -175net_liquidity, qtynet_liquidity · qty2 valuesindex_fair_valueindex_fair_valuevalueindexindexvaluediffdiffvalueqty_adjqty_adjvalueafterStartDateafterStartDateconditionafterEndDateafterEndDateconditionoverbought_signaloverbought_signalconditionoversold_signaloversold_signalconditionentry:LongOpen Longstrategy.entryentry:ShortOpen Shortstrategy.entryclose:ShortClose Shortstrategy.closeclose:LongClose Longstrategy.closeplotchar:24plotcharplotcharplot:28Spreadplothline:29Zerohlinehline:30Overboughthlinehline:31Oversoldhlinebarcolor:34barcolorbarcolor

Order rules

OrderFires whenBy defaultLine
Open Long long(overbought_signal and afterStartDate)On40
Open Short short((afterStartDate and oversold_signal) or (useCloseDate and afterEndDate))On42
Close Short(useCloseDate and afterEndDate)On44
Close Long(useCloseDate and afterEndDate)On45
Open Short short(overbought_signal and afterStartDate)On48
Open Long long(afterStartDate and oversold_signal)On50
Close Short(useCloseDate and afterEndDate)On52
Close Long(useCloseDate and afterEndDate)On53
Open Long long(overbought_signal and afterStartDate)On57
Close Long((afterStartDate and oversold_signal) or (useCloseDate and afterEndDate))On60
Open Short short(overbought_signal and afterStartDate)On63
Close Short((afterStartDate and oversold_signal) or (useCloseDate and afterEndDate))On66
Open Short short(oversold_signal and afterStartDate)On70
Close Short((afterStartDate and overbought_signal) or (useCloseDate and afterEndDate))On73
Open Long long(oversold_signal and afterStartDate)On76
Close Long((afterStartDate and overbought_signal) or (useCloseDate and afterEndDate))On79

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.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • ClearHigher-timeframe data2 request.security call(s), none with lookahead on.
  • 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

Not run on other markets: the script requests (WALCL - WTREGEN - RRPONTSYD) D, SPX D, and that data is not available here (not a Binance spot market; not a Binance spot market). Its results would rest on empty values.

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

Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// ©ekmll-//@version=5+//@version=6strategy("Fair Value Strategy ekmll", overlay=false, initial_capital = 1000000, calc_on_every_tick = true)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 33 msYes 1,000 bars in 42 msNot 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/// ©ekmll//@version=5strategy("Fair Value Strategy ekmll", overlay=false, initial_capital = 1000000, calc_on_every_tick = true)fv_index_ticker = input.string("SPX", "Fair Value Index", ["SPX", "NDX", "RUT"])mode = input.string("Long/Short", "Strategy", ["Short Only", "Long Only", "Long/Short"])scalar = input.float(1.1, "Scalar", 0.0, 5.0, .1)subtractor = input.int(1425, "Subtractor", step = 25)ob_threshold = input.int(0, "OB Threshold", step = 25)os_threshold = input.int(-175, "OS Threshold", step = 25)inverse = input.bool(false, "Inverse")startDate = input.int(title="Start Day", defval=20, minval=1, maxval=31)startMonth = input.int(title="Start Month", defval=12, minval=1, maxval=12)startYear = input.int(title="Start Year", defval=2021, minval=1800, maxval=2100)// See if this bar's time happened on/after start dateafterStartDate = (time >= timestamp(syminfo.timezone, startYear, startMonth, startDate, 0, 0))useCloseDate = input.bool(true, title="Use Close Date")closeDay = input.int(title="Close Day", defval=20, minval=1, maxval=31)closeMonth = input.int(title="Close Month", defval=12, minval=1, maxval=12)closeYear = input.int(title="Close Year", defval=2024, minval=1800, maxval=2100)  // See if this bar's time happened on/after end dateafterEndDate = year == closeYear and month == closeMonth and dayofmonth == closeDaynet_liquidity = request.security("(WALCL - WTREGEN - RRPONTSYD)", "D", close)plotchar(net_liquidity, "net_liquidity", "", location.top)index_fair_value = net_liquidity/1000000000/scalar - subtractorindex = request.security(fv_index_ticker, "D", close)diff = index - index_fair_valueplot(index_fair_value > 0 ? diff : na, title = "Spread", color = color.blue, trackprice = true, linewidth = 2)hline(0, title='Zero', color=color.gray, linestyle=hline.style_dotted, linewidth=2)hline(ob_threshold, title='Overbought', color=color.red, linestyle=hline.style_dotted, linewidth=2)hline(os_threshold, title='Oversold', color=color.green, linestyle=hline.style_dotted, linewidth=2)overbought_signal = net_liquidity > 0.0 and (diff[1] < ob_threshold and diff[0] > ob_threshold)oversold_signal = net_liquidity > 0.0 and (diff[1] > os_threshold and diff[0] < os_threshold)barcolor(overbought_signal ? color.purple : oversold_signal ? color.blue : na)qty = (strategy.initial_capital + strategy.netprofit + strategy.openprofit)/closeqty_adj = strategy.opentrades > 0 ? math.abs(strategy.opentrades.size(0) * 1) : qty[0]if (mode == "Long/Short")    if (inverse)        if (overbought_signal and afterStartDate)            strategy.entry("Long", strategy.long, qty = qty[0], comment = "LE")                else if ((afterStartDate and oversold_signal) or (useCloseDate and afterEndDate))            strategy.entry("Short", strategy.short, qty = qty[0], comment = "SE")        else if (useCloseDate and afterEndDate)            strategy.close("Short", qty_percent=100, comment="close")            strategy.close("Long", qty_percent=100, comment="close")    else        if (overbought_signal and afterStartDate)            strategy.entry("Short", strategy.short, qty = qty[0], comment = "SE")        else if (afterStartDate and oversold_signal)            strategy.entry("Long", strategy.long, qty = qty[0], comment = "LE")        else if (useCloseDate and afterEndDate)            strategy.close("Short", qty_percent=100, comment="close")            strategy.close("Long", qty_percent=100, comment="close")else if (mode == "Short Only")    if (inverse)        if (overbought_signal and afterStartDate)            strategy.entry("Long", strategy.long, qty = qty[0], comment = "LE")                        if ((afterStartDate and oversold_signal) or (useCloseDate and afterEndDate))            strategy.close("Long", qty_percent=100, comment="close")    else        if (overbought_signal and afterStartDate)            strategy.entry("Short", strategy.short, qty = qty[0], comment = "SE")                        if ((afterStartDate and oversold_signal) or (useCloseDate and afterEndDate))            strategy.close("Short", qty_percent=100, comment="close")else if (mode == "Long Only")    if (inverse)        if (oversold_signal and afterStartDate)            strategy.entry("Short", strategy.short, qty = qty[0], comment = "SE")                        if ((afterStartDate and overbought_signal) or (useCloseDate and afterEndDate))            strategy.close("Short", qty_percent=100, comment="close")    else        if (oversold_signal and afterStartDate)            strategy.entry("Long", strategy.long, qty = qty[0], comment = "LE")                        if ((afterStartDate and overbought_signal) or (useCloseDate and afterEndDate))            strategy.close("Long", qty_percent=100, comment="close")