Pine Script v5 · Strategy
Financial Ratios Fundamental Strategy
A Pine Script v5 strategy with no technical-analysis calculation. It has 2 order rules, 1 entry among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 100% of equity and pays 0.1% commission. It has no settings.
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 Financial Ratios Fundamental Strategy repaint?
- No
- No repainting patterns were found in the source.
- Does Financial Ratios Fundamental Strategy run in Pine Script v6?
- Not tested
- The v5 script does not run in Zeal Terminal's engine (request.financial: no data was supplied for 'SYMBOL|TOTAL_CURRENT_ASSETS|FQ'. This engine cannot fetch it from TradingView — provide it with ctx.provideRequestData("financial", "SYMBOL|TOTAL_CURRENT_ASSETS|FQ", samples).), so this step could not be checked. The v6 version is shown for reference and is not offered as a download.
- Does Financial Ratios Fundamental Strategy use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does Financial Ratios Fundamental Strategy run in Zeal Terminal?
- No
- Not yet: request.financial: no data was supplied for 'SYMBOL|TOTAL_CURRENT_ASSETS|FQ'. This engine cannot fetch it from TradingView — provide it with ctx.provideRequestData("financial", "SYMBOL|TOTAL_CURRENT_ASSETS|FQ", 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
Every trade uses all the equity
default_qty_value is 100% of equity.
-
Note
Uses an argument v6 removed
when = on line 128, 129. 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.
The script declares no settings.
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 | ( long_tot or long_tot[1] ) | On | 128 |
| Close long | long_tot_exitcurrent_ratio < current_ratio[1] or interest_ratio > interest_ratio[1] or payable_turnover < payable_turnover[1] or gross_margin > gross_margin[1] | On | 129 |
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.
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].
- ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
- 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 128, 129). 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.financial: no data was supplied for 'SYMBOL|TOTAL_CURRENT_ASSETS|FQ'. This engine cannot fetch it from TradingView — provide it with ctx.provideRequestData("financial", "SYMBOL|TOTAL_CURRENT_ASSETS|FQ", samples).), so this step could not be checked.
- Line 128: when = ( long_tot or long_tot[1] ) → if block
- Line 129: when = long_tot_exit → if block
⋯// plot(DEBT_TO_REVENUE)-strategy.entry("long",strategy.long,when= ( long_tot or long_tot[1] ))+if ( long_tot or long_tot[1] )+ strategy.entry("long",strategy.long)-strategy.close("long",when= long_tot_exit )+if long_tot_exit+ strategy.close("long" )Does it run in Pine Script v6?
Not tested
The v5 script does not run in Zeal Terminal's engine (request.financial: no data was supplied for 'SYMBOL|TOTAL_CURRENT_ASSETS|FQ'. This engine cannot fetch it from TradingView — provide it with ctx.provideRequestData("financial", "SYMBOL|TOTAL_CURRENT_ASSETS|FQ", 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.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/-//@version=5+//@version=6//exlux99⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | No Request.financial: no data was supplied for 'SYMBOL|TOTAL_CURRENT_ASSETS|FQ'. This engine cannot fetch it from TradingView — provide it with ctx.provideRequestData("financial", "SYMBOL|TOTAL_CURRENT_ASSETS|FQ", 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///@version=5//exlux99strategy('Financial Ratios', overlay=true,initial_capital = 1000000, default_qty_type= strategy.percent_of_equity, default_qty_value = 100, calc_on_order_fills=false, slippage=0,commission_type=strategy.commission.percent,commission_value=0.1)//Current ratio: Current Assets / Current LiabilitiesTOTAL_CURRENT_ASSETS = request.financial(syminfo.tickerid, "TOTAL_CURRENT_ASSETS", "FQ")TOTAL_CURRENT_LIABILITIES = request.financial(syminfo.tickerid, "TOTAL_CURRENT_LIABILITIES", "FQ")current_ratio = TOTAL_CURRENT_ASSETS/ TOTAL_CURRENT_LIABILITIES// plot(current_ratio)//Quick ratio (Acid-test ratio): (Current Assets – Inventories – Prepaid Expenses) / Current LiabilitiesPREPAID_EXPENSES = request.financial(syminfo.tickerid, "PREPAID_EXPENSES", "FQ")INVENTORY_FINISHED_GOODS = request.financial(syminfo.tickerid, "INVENTORY_FINISHED_GOODS", "FQ")quick_ratio = (TOTAL_CURRENT_ASSETS - INVENTORY_FINISHED_GOODS - PREPAID_EXPENSES) / TOTAL_CURRENT_LIABILITIES// plot(quick_ratio, color=color.white)//Cash ratio: Cash and cash equivalents / Current LiabilitiesCASH_N_EQUIVALENTS = request.financial(syminfo.tickerid, "CASH_N_EQUIVALENTS", "FQ")cash_ratio = CASH_N_EQUIVALENTS / TOTAL_CURRENT_LIABILITIES// plot(cash_ratio, color=color.orange)long_liquidity = current_ratio > current_ratio[1] and quick_ratio > quick_ratio[1] //and cash_ratio > cash_ratio[1]long_exit_liquidity = current_ratio < current_ratio[1] and quick_ratio < quick_ratio[1] //or cash_ratio < cash_ratio[1]//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Leverage ratios//Debt ratio: Total Debt / Total AssetsTOTAL_DEBT= request.financial(syminfo.tickerid, "TOTAL_DEBT", "FQ")TOTAL_ASSETS = request.financial(syminfo.tickerid, "TOTAL_ASSETS", "FQ")debt_ratio = TOTAL_DEBT / TOTAL_ASSETS//plot(debt_ratio)//Debt to equity ratio: Total Debt / Total EquityTOTAL_EQUITY= request.financial(syminfo.tickerid, "TOTAL_EQUITY", "FQ")debt_equity_ratio = TOTAL_DEBT / TOTAL_EQUITY//plot(debt_equity_ratio,color=color.white)//Interest coverage ratio: EBIT / Interest expensesEBIT = request.financial(syminfo.tickerid, "EBIT", "FQ")INTEREST_EXPENSE_ON_DEBT = request.financial(syminfo.tickerid, "INTEREST_EXPENSE_ON_DEBT", "FQ")interest_ratio = EBIT / INTEREST_EXPENSE_ON_DEBT//plot(interest_ratio, color=color.orange)long_leverage = debt_ratio < debt_ratio[1] and debt_equity_ratio< debt_equity_ratio[1] //or interest_ratio < interest_ratio[1]long_exit_leverage = debt_ratio > debt_ratio[1] and debt_equity_ratio > debt_equity_ratio[1] //or interest_ratio > interest_ratio[1] ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Efficiency ratios//Asset turnover ratio: Net sales / Average total assetsSALES_OF_BUSINESS =request.financial(syminfo.tickerid, "TOTAL_REVENUE", "FQ")asset_turnover_ratio = SALES_OF_BUSINESS / TOTAL_ASSETS// plot(asset_turnover_ratio)//Inventory turnover: Cost of goods sold / Average value of inventory// COST_OF_GOODS= request.financial(syminfo.tickerid, "COST_OF_GOODS", "FQ")// TOTAL_INVENTORY = request.financial(syminfo.tickerid, "TOTAL_INVENTORY", "FQ")// inventory_turnover = COST_OF_GOODS/ TOTAL_INVENTORYINVENT_TO_REVENUE = request.financial(syminfo.tickerid, "INVENT_TO_REVENUE", "FQ")// plot(INVENT_TO_REVENUE,color=color.white)//Payables turnover ratio: Cost of Goods sold (or net credit purchases) / Average Accounts PayableCOST_OF_GOODS = request.financial(syminfo.tickerid, "COST_OF_GOODS", "FQ")ACCOUNTS_PAYABLE= request.financial(syminfo.tickerid, "ACCOUNTS_PAYABLE", "FQ")payable_turnover = COST_OF_GOODS / ACCOUNTS_PAYABLE// plot(payable_turnover,color=color.orange)//Receivables turnover ratio: Net credit sales / Average accounts receivablelong_Efficiency = asset_turnover_ratio > asset_turnover_ratio[1] and payable_turnover > payable_turnover[1] //and INVENT_TO_REVENUE > INVENT_TO_REVENUE[1]long_exit_Efficiency = asset_turnover_ratio < asset_turnover_ratio[1] and payable_turnover < payable_turnover[1]// and INVENT_TO_REVENUE < INVENT_TO_REVENUE[1]////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Profitability ratios//Gross margin: Gross profit / Net salesGROSS_PROFIT = request.financial(syminfo.tickerid, "GROSS_PROFIT", "FQ")SALES = request.financial(syminfo.tickerid, "TOTAL_REVENUE", "FQ")gross_margin = GROSS_PROFIT / SALES// plot(gross_margin)//Operating margin: Operating income / Net salesOPER_INCOME = request.financial(syminfo.tickerid, "OPER_INCOME", "FQ")operating_margin = OPER_INCOME/ SALES// plot(operating_margin, color=color.white)//Return on assets (ROA): Net income / Total assetsNET_INCOME= request.financial(syminfo.tickerid, "NET_INCOME", "FQ")roa = NET_INCOME/TOTAL_ASSETS//plot(roa, color=color.orange) //Return on equity (ROE): Net income / Total equityroe = NET_INCOME / TOTAL_EQUITY//plot(roe, color=color.purple)long_profitability = (gross_margin > gross_margin[1] and operating_margin>operating_margin[1] )//and roe > roe[1] and roa > roa[1] ) // or ( roe > roe[1] and roa > roa[1] ) long_exit_profitability = (gross_margin < gross_margin[1] and operating_margin<operating_margin[1] ) //or roe < roe[1] or roa < roa[1]) // or ( roe < roe[1] and roa < roa[1])//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////5) Market Value ratios//Earnings per share ratio (EPS): (Net Income – Preferred Dividends) / End-of-Period Common Shares OutstandingPREFERRED_DIVIDENDS = request.financial(syminfo.tickerid, "PREFERRED_DIVIDENDS", "FQ")TOTAL_SHARES_OUTSTANDING = request.financial(syminfo.tickerid, "TOTAL_SHARES_OUTSTANDING", "FQ")eps_ratio = (NET_INCOME - PREFERRED_DIVIDENDS)/TOTAL_SHARES_OUTSTANDING// plot(eps_ratio)// //Price earnings ratio (P/E): Share price / Earnings per share// EPS = request.financial(syminfo.tickerid, "EARNINGS_PER_SHARE", "FQ")// closex = request.security(syminfo.tickerid, "M", close)// PE_RATIO = closex / eps_ratio// plot(PE_RATIO,color=color.white) //Book value per share ratio: (Total Equity – Preferred Equity) / Total shares outstandingCOMMON_EQUITY_TOTAL = request.financial(syminfo.tickerid, "COMMON_EQUITY_TOTAL", "FQ")preferred_equity = TOTAL_EQUITY - COMMON_EQUITY_TOTALTSO = request.financial(syminfo.tickerid, "TOTAL_SHARES_OUTSTANDING", "FQ")book_value = (TOTAL_EQUITY - preferred_equity)/TSO// plot(book_value, color=color.white)//Dividend yield ratio: Dividend per share / Share priceDIVIDENDS_YIELD = request.financial(syminfo.tickerid, "DIVIDENDS_YIELD", "FQ")// plot(DIVIDENDS_YIELD,color=color.orange)long_market = DIVIDENDS_YIELD > DIVIDENDS_YIELD[1] and eps_ratio > eps_ratio[1] and book_value > book_value[1]long_exit_market = DIVIDENDS_YIELD < DIVIDENDS_YIELD[1] and eps_ratio < eps_ratio[1] and book_value < book_value[1]//and (current_ratio > current_ratio[1] )//and interest_ratio < interest_ratio[1]//and payable_turnover > payable_turnover[1]//and gross_margin > gross_margin[1]//long_tot = (long_liquidity or long_leverage or long_Efficiency or long_profitability ) // or long_market long_tot = current_ratio > current_ratio[1] or interest_ratio < interest_ratio[1] or payable_turnover > payable_turnover[1] or gross_margin > gross_margin[1]long_tot_exit = current_ratio < current_ratio[1] or interest_ratio > interest_ratio[1] or payable_turnover < payable_turnover[1] or gross_margin > gross_margin[1]// plot(current_ratio)// plot(interest_ratio, color=color.white)// plot(payable_turnover, color=color.orange)// plot(gross_margin, color=color.purple)// DEBT_TO_REVENUE = request.financial(syminfo.tickerid, "SPRINGATE_SCORE", "FQ")// plot(DEBT_TO_REVENUE)strategy.entry("long",strategy.long,when= ( long_tot or long_tot[1] ))strategy.close("long",when= long_tot_exit )