Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

VFI strategy [based on VFI indicator published by UTS]

A Pine Script v4 strategy built on SMA or EMA or WMA or ALMA (sig, len), Stdev (inter, 30) and EMA (close, 200). It has 3 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 is one contract and pays no commission. 18 settings; defaults include Length 8, Coef 0.2 and Volume Cutoff 2.5.

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 VFI strategy [based on VFI indicator published by UTS] repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did VFI strategy [based on VFI indicator published by UTS] do on BTCUSDT 1D with default settings?
+181.41%
From 26 Jan 2024 to 21 Oct 2026, over 8 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Can VFI strategy [based on VFI indicator published by UTS] be converted to Pine Script v5?
Yes
The upgrade takes 1 step, from v4; each was run before and after on the same candles with identical results, and the v5 script can be downloaded below.
Does VFI strategy [based on VFI indicator published by UTS] use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does VFI strategy [based on VFI indicator published by UTS] run in Zeal Terminal?
Yes
It compiles in 19 ms and runs 1,000 bars in 85 ms, in the browser.

BTCUSDT · 1D · default settings

  • VFI
  • Plot
  • Buy Line
  • Sell Line
  • MA
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (18)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOctVFI$28,135$20,253Equity from $10,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. Zeal Terminal's engine currently reads an order side written as long = true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 91) so the engine trades the way the script says.
Net profit
+181.41%
$18,141.30
Buy and hold
+102.5%
same period
Closed trades
8
6 won · 2 lost
Profitable
75.0%
of closed trades
Profit factor
1.79
gross profit ÷ gross loss
Max drawdown
154.24%
−$49,324.10

One run with the author's default settings, $10,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.

  • Note

    Uses an argument v6 removed

    when = on line 91, 93, 97. The upgraded version below moves each call inside an if block.

  • Note

    Uses iff(), which v5 removed line 72

    iff() on line 72, 72. v5 writes it as the ternary c ? a : b.

  • Note

    Uses transp =, which v5 removed line 87

    transp = on line 87. v5 folds the transparency into the colour with color.new(c, transp).

  • Note

    Uses long =, which v5 renamed line 91

    long = on line 91. v5 writes it as direction = strategy.long or strategy.short.

Upgrade and export

Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.

  • Upgrading to v5 renames sma → ta.sma, ema → ta.ema, wma → ta.wma, alma → ta.alma, log → math.log, stdev → ta.stdev, min → math.min, sum → math.sum, crossover → ta.crossover, crossunder → ta.crossunder.
  • 3 strategy calls use the when = argument (line 91, 93, 97). It is deprecated in v5 and removed in v6, where each call moves inside an if block.

v4 → v5

Verified

Same 8 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 6: //@version=4 → //@version=5
  • Line 55: sma → ta.sma
  • Line 57: ema → ta.ema
  • Line 59: wma → ta.wma
  • Line 61: alma → ta.alma
  • Line 65: log → math.log
14 more edits
  • Line 65: log → math.log
  • Line 66: stdev → ta.stdev
  • Line 70: min → math.min
  • Line 72: iff(c, a, b) → (c ? a : b)
  • Line 72: iff(c, a, b) → (c ? a : b)
  • Line 73: sum → math.sum
  • Line 78: ema → ta.ema
  • Line 79: ema → ta.ema
  • Line 80: ema → ta.ema
  • Line 87: transp = 75 → color.new(color_osc, 75)
  • Line 91: long = true → direction = strategy.long
  • Line 91: crossover → ta.crossover
  • Line 93: crossunder → ta.crossunder
  • Line 97: crossunder → ta.crossunder
⋯// I have added buy line and sell line to the indicator  and tested  SPY stock/index on one hour chart-//@version=4+//@version=5strategy(title="VFI  strategy [based on VFI indicator published by  UTS]", overlay=false,pyramiding=2, default_qty_type=strategy.fixed,    initial_capital=10000, currency=currency.USD)⋯    if t == kSma            // Simple-        ma := sma(sig, len)+        ma := ta.sma(sig, len)    if t == kEma            // Exponential-        ma := ema(sig, len)+        ma := ta.ema(sig, len)    if t == kWma            // Weighted-        ma := wma(sig, len)+        ma := ta.wma(sig, len)    if t == kAlma           // Arnaud Legoux-        ma := alma(sig, len, vfi_almaOffset, vfi_almaSigma)+        ma := ta.alma(sig, len, vfi_almaOffset, vfi_almaSigma)    ma⋯    avg = nz(hlc3)-    inter = log(avg) - log(avg[1])+    inter = math.log(avg) - math.log(avg[1])-    vInter = stdev(inter, 30)+    vInter = ta.stdev(inter, 30)    cutOff = coef * vInter * close⋯    vMax = vAve * vCoef-    vC = min(volume, vMax)+    vC = math.min(volume, vMax)    mf = avg - avg[1]-    vCp = iff(mf > cutOff, vC, iff(mf < -cutOff, -vC, 0))+    vCp = (mf > cutOff ? vC : (mf < -cutOff ? -vC : 0))-    sVfi = sum(vCp, fviPeriod) / vAve+    sVfi = math.sum(vCp, fviPeriod) / vAve    vfi = smooth(smoothType, sVfi, smoothLen)⋯value_ma = smooth(vfi_maType, value_vfi, vfi_maLength)-longEMAval= ema(close, vfi_longEMA)+longEMAval= ta.ema(close, vfi_longEMA)-shortEMAval1= ema(close, vfi_shortEMA1)+shortEMAval1= ta.ema(close, vfi_shortEMA1)-shortEMAval2= ema(close, vfi_shortEMA2)+shortEMAval2= ta.ema(close, vfi_shortEMA2)color_vfi = vfi_showTrend ? vfi_trendColor(value_vfi) : vfi_color(value_vfi)⋯plot_fill = plot(0, color=color_vfi, editable=false)-fill(plot_vfi, plot_fill, title="Oscillator Fill", color=color_osc, transp=75) +fill(plot_vfi, plot_fill, title="Oscillator Fill", color=color.new(color_osc, 75)) hline(vfi_buyLine, color=color.green, title="Buy Line", linewidth=2, linestyle=hline.style_dashed)⋯plot(value_ma, title="MA", color=color_ma, linewidth=2)-strategy.entry(id="VFI LE", long=true,  when=crossover(value_vfi,vfi_buyLine)  and ( shortEMAval1 >= longEMAval  ))+strategy.entry(id="VFI LE", direction = strategy.long,  when=ta.crossover(value_vfi,vfi_buyLine)  and ( shortEMAval1 >= longEMAval  ))//strategy.close(id="VFI LE", comment="Exit",   when=crossunder(value_vfi,vfi_sellLine))-strategy.close(id="VFI LE", comment="TP Exit",   when=crossunder(value_vfi,vfi_sellLine) and close>strategy.position_avg_price)+strategy.close(id="VFI LE", comment="TP Exit",   when=ta.crossunder(value_vfi,vfi_sellLine) and close>strategy.position_avg_price)//strategy.close(id="VFI LE", comment="Exit",   when=  (shortEMAval1 > shortEMAval2 )  and crossunder(close, shortEMAval2))⋯stopLossVal =   strategy.position_avg_price -  (strategy.position_avg_price*stopLoss*0.01) -strategy.close(id="VFI LE", comment="SL Exit",   when=crossunder(value_vfi,vfi_sellLine) and close < stopLossVal)+strategy.close(id="VFI LE", comment="SL Exit",   when=ta.crossunder(value_vfi,vfi_sellLine) and close < stopLossVal)

Clean v5

VerifiedDownload the v5 script

Same 8 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine.

  • Line 18: input() → input.int()
  • Line 19: input() → input.float()
  • Line 20: input() → input.float()
  • Line 21: input() → input.int()
  • Line 24: input() → input.int()
  • Line 25: input() → input.int()
13 more edits
  • Line 26: input() → input.int()
  • Line 28: input() → input.int()
  • Line 29: input() → input.int()
  • Line 30: input() → input.int()
  • Line 31: input() → input.bool()
  • Line 32: input() → input.bool()
  • Line 33: input() → input.bool()
  • Line 35: input() → input.int()
  • Line 36: input() → input.float()
  • Line 37: input() → input.float()
  • Line 91: when = ta.crossover(value_vfi,vfi_buyLine) and ( shortEMAval1 >= longEMAval ) → if block
  • Line 93: when = ta.crossunder(value_vfi,vfi_sellLine) and close>strategy.position_avg_price → if block
  • Line 97: when = ta.crossunder(value_vfi,vfi_sellLine) and close < stopLossVal → if block
⋯// Input-vfi_length = input(8, title="Length", minval=1)  //default 130+vfi_length = input.int(8, title="Length", minval=1)  //default 130-vfi_coef = input(0.2, title="Coef", minval=0.1)+vfi_coef = input.float(0.2, title="Coef", minval=0.1)-vfi_volCutoff = input(2.5, title="Volume Cutoff", minval=0.1)+vfi_volCutoff = input.float(2.5, title="Volume Cutoff", minval=0.1)-vfi_smoothLen = input(3, title="Smoothing Period", minval=1)+vfi_smoothLen = input.int(3, title="Smoothing Period", minval=1)vfi_smoothType = input(kEma, title="Smoothing Type", options=[kAlma, kEma, kSma, kWma])//These are adde by me for the strategy purpose  BEGIN-vfi_buyLine = input(-4, title="Buy Line", minval=-10)+vfi_buyLine = input.int(-4, title="Buy Line", minval=-10)-vfi_sellLine = input(5, title="Sell Line", minval=-10)+vfi_sellLine = input.int(5, title="Sell Line", minval=-10)-stopLoss = input(title="Stop Loss%", defval=5, minval=1)+stopLoss = input.int(title="Stop Loss%", defval=5, minval=1)//These are adde by me for the strategy purpose  END-vfi_longEMA = input(200, title="Long EMA", minval=1)+vfi_longEMA = input.int(200, title="Long EMA", minval=1)-vfi_shortEMA1 = input(50, title="short EMA1", minval=1)+vfi_shortEMA1 = input.int(50, title="short EMA1", minval=1)-vfi_shortEMA2 = input(9, title="short EM2A", minval=1)+vfi_shortEMA2 = input.int(9, title="short EM2A", minval=1)-vfi_showTrend = input(false, title="Visualize Trend")+vfi_showTrend = input.bool(false, title="Visualize Trend")-vfi_showFill = input(true, title="Apply Filling")+vfi_showFill = input.bool(true, title="Apply Filling")-vfi_showMa = input(true, title="Show Moving Average")+vfi_showMa = input.bool(true, title="Show Moving Average")vfi_maType = input(kSma, title="Moving Average Type", options=[kAlma, kEma, kSma, kWma])-vfi_maLength = input(30, title="Moving Average Length", minval=1)+vfi_maLength = input.int(30, title="Moving Average Length", minval=1)-vfi_almaOffset = input(0.85, title="• ALMA - Offset (global setting)", minval=0.0, maxval=1.0, step=0.05) // more smoothness (closer to 1) vs. more responsiveness (closer to 0)+vfi_almaOffset = input.float(0.85, title="• ALMA - Offset (global setting)", minval=0.0, maxval=1.0, step=0.05) // more smoothness (closer to 1) vs. more responsiveness (closer to 0)-vfi_almaSigma = input(6.0, title="• ALMA - Sigma (global setting)", minval=0.0, step=0.05) // the larger sigma the smoother ALMA+vfi_almaSigma = input.float(6.0, title="• ALMA - Sigma (global setting)", minval=0.0, step=0.05) // the larger sigma the smoother ALMA// Functionality⋯plot(value_ma, title="MA", color=color_ma, linewidth=2)-strategy.entry(id="VFI LE", direction = strategy.long,  when=ta.crossover(value_vfi,vfi_buyLine)  and ( shortEMAval1 >= longEMAval  ))+if ta.crossover(value_vfi,vfi_buyLine)  and ( shortEMAval1 >= longEMAval  )+    strategy.entry(id="VFI LE", direction = strategy.long)//strategy.close(id="VFI LE", comment="Exit",   when=crossunder(value_vfi,vfi_sellLine))-strategy.close(id="VFI LE", comment="TP Exit",   when=ta.crossunder(value_vfi,vfi_sellLine) and close>strategy.position_avg_price)+if ta.crossunder(value_vfi,vfi_sellLine) and close>strategy.position_avg_price+    strategy.close(id="VFI LE", comment="TP Exit")//strategy.close(id="VFI LE", comment="Exit",   when=  (shortEMAval1 > shortEMAval2 )  and crossunder(close, shortEMAval2))⋯stopLossVal =   strategy.position_avg_price -  (strategy.position_avg_price*stopLoss*0.01) -strategy.close(id="VFI LE", comment="SL Exit",   when=ta.crossunder(value_vfi,vfi_sellLine) and close < stopLossVal)+if ta.crossunder(value_vfi,vfi_sellLine) and close < stopLossVal+    strategy.close(id="VFI LE", comment="SL Exit")

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: 8 before, 0 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.

⋯// I have added buy line and sell line to the indicator  and tested  SPY stock/index on one hour chart-//@version=5+//@version=6strategy(title="VFI  strategy [based on VFI indicator published by  UTS]", overlay=false,pyramiding=2, default_qty_type=strategy.fixed,    initial_capital=10000, currency=currency.USD)⋯

Settings

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

SettingDefaultType and rangeFeeds
Length8int · min 1value_vfi
Coef0.2float · min 0.1value_vfi
Volume Cutoff2.5float · min 0.1value_vfi
Smoothing Period3int · min 1value_vfi
Smoothing TypekEmavalue · options [kAlma, kEma, kSma, kWma]value_vfi
Buy Line-4int · min -10Buy Line entry VFI LE
Sell Line5int · min -10Sell Line close VFI LE
Stop Loss%5int · min 1stopLossVal
Long EMA200int · min 1longEMAval
short EMA150int · min 1shortEMAval1
short EM2A9int · min 1shortEMAval2
Visualize Trendfalseboolcolor_vfi
Apply Fillingtrueboolcolor_osc
Show Moving Averagetrueboolcolor_ma
Moving Average TypekSmavalue · options [kAlma, kEma, kSma, kWma]value_ma
Moving Average Length30int · min 1value_ma
• ALMA - Offset (global setting)0.85float · min 0.0 · max 1.0 · step 0.05ma
• ALMA - Sigma (global setting)6.0float · min 0.0 · step 0.05ma

What it calculates

  • SMA / EMA / WMA / ALMA (sma, ta.sma in v5)sig, lenma · line 53
  • Stdev (stdev, ta.stdev in v5)inter, 30vInter · line 66
  • EMA (ema, ta.ema in v5)close, Long EMA (200)longEMAval · line 78
  • EMA (ema, ta.ema in v5)close, short EMA1 (50)shortEMAval1 · line 79
  • EMA (ema, ta.ema in v5)close, short EM2A (9)shortEMAval2 · line 80

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.

vfi_almaOffset• ALMA - Offset (global…setting · 0.85vfi_almaSigma• ALMA - Sigma (global …setting · 6.0closecloseprice datavfi_longEMALong EMAsetting · 200vfi_shortEMA1short EMA1setting · 50vfi_shortEMA2short EM2Asetting · 9hlc3hlc3price datavolumevolumeprice datavfi_lengthLengthsetting · 8vfi_smoothTypeSmoothing Typesetting · kEmavfi_smoothLenSmoothing Periodsetting · 3vfi_coefCoefsetting · 0.2vfi_volCutoffVolume Cutoffsetting · 2.5vfi_maTypeMoving Average Typesetting · kSmavfi_maLengthMoving Average Lengthsetting · 30stopLossStop Loss%setting · 5vfi_buyLineBuy Linesetting · -4vfi_sellLineSell Linesetting · 5maSMA / EMA / WMA / ALMA→ mavInterStdev→ vInterlongEMAvalEMA→ longEMAvalshortEMAval1EMA→ shortEMAval1shortEMAval2EMA→ shortEMAval2avgavgvalueinter, mfinter · mf2 valuescutOffcutOffvaluevAvevAvevaluevMaxvMaxvaluevCvCvaluesVfisVfivaluevfivfivaluevalue_vfivalue_vfivaluevalue_mavalue_mavaluecolor_vfi, color_osccolor_vfi · color_osc2 valuescolor_macolor_mavaluestopLossValstopLossValvaluevCpvCpconditionkMaColor, kNeutralColor, kBearColor, kBullColorColourkMaColor · kNeutralColor +2entry:VFI LEOpen VFI LEstrategy.entryclose:VFI LEClose VFI LEstrategy.closeplot:85VFIplotplot:86plotplotfill:Oscillator FillOscillator Fillfillhline:88Buy Linehlinehline:89Sell Linehlineplot:90MAplot

Order rules

OrderFires whenBy defaultLine
Open VFI LE longcrossover(value_vfi,vfi_buyLine) and ( shortEMAval1 >= longEMAval )On91
Close VFI LEcrossunder(value_vfi,vfi_sellLine) and close>strategy.position_avg_priceOn93
Close VFI LEcrossunder(value_vfi,vfi_sellLine) and close < stopLossValOn97

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.

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

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.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D+181.4%+102.5%875%1.79154.2%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+122.4%+5.5%771%16.0029.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−25.9%+9.8%633%0.2835.5%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+11.6%+8.4%888%205.585.1%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−1.3%+16.7%520%0.122.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+0.7%+21.5%989%67.440.2%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−0.8%+148.3%863%0.784.4%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h+1.0%+17.1%4100%—0.4%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 barsTradesWonP&L
Rising market2100%$28,275.60
Sideways market667%−$10,134.30
Falling market0—$0.00

Rising and falling mean the market moved more than 15% over the 90 bars before entry.

How bad could the drawdown be?

41.2%

The 95th percentile of the worst drawdown when the same 8 trades are reshuffled 5,000 times. The bar spans the 5th to 95th percentile, 26.3% to 41.2%; the tick is what actually happened, 41.2%. Order luck alone moves it this much.

0%47%
All 8 trades
SideEntryExitBarsP&L
long7 Mar 2025 89,931.901 May 2025 94,172.0055$4,240.12
long5 Jun 2025 104,697.0017 Jul 2025 118,630.0042$13,933.60
long7 Jun 2025 104,288.0017 Jul 2025 118,630.0040$14,342.00
long8 Aug 2025 117,472.0015 Aug 2025 118,295.007$823.07
long24 Aug 2025 115,438.0014 Sep 2025 115,918.0021$480.23
long30 Sep 2025 114,312.0010 Oct 2025 121,662.0010$7,350.44
long19 Oct 2025 107,185.007 Jan 2026 93,748.0080−$13,437.00
long8 Nov 2025 103,339.007 Jan 2026 93,748.0060−$9,591.12

Similar scripts

Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.

ScriptSharesTypeNetTradesMax drawdown
VFI strategy [based on VFI indicator published by UTS] this page—v4 strategy+181.4%8154.2%
Escaping of Rate from Avarage By Mustafa OZVER Strategy by Mustafaozverwma stdev emav4 strategy+122.0%9679.1%
Volume Weighted Bollinger Bands Strategy by Ankit_1618ema sma stdevv4 strategy+10.0%1527.5%
BB21_MA200_Strategy by mohaneeema sma stdevv4 strategyNo trades on this market
Super Breakout day trading by beststockalertstdev sma emav4 strategyNo trades on this market
Super Auto Breakout Day Trade Volatile stocks by beststockalertstdev sma emav4 strategy−6.1%5129.1%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 19 msWith a workaround 1,000 bars in 85 msNot measured
PineTSNo v5 and v6 only—Not measured

Zeal Terminal's engine currently reads an order side written as long = true as a short, whatever it says; this page passes the same side as strategy.long or strategy.short (line 91) so the engine trades the way the script says.

“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. PineTS runs Pine Script v5 and v6 only.

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/// © mohanee//This strategy is based on VFI indicator published by  UTS.  //more details of VFI indicator can be found at  [url=http://mkatsanos.com/VFI.html]http://mkatsanos.com/VFI.html[/url] // I have added buy line and sell line to the indicator  and tested  SPY stock/index on one hour chart//@version=4strategy(title="VFI  strategy [based on VFI indicator published by  UTS]", overlay=false,pyramiding=2, default_qty_type=strategy.fixed,    initial_capital=10000, currency=currency.USD)// ConstkMaColor = color.aquakNeutralColor = color.graykBearColor = color.redkBullColor = color.greenkAlma = "ALMA"kEma = "EMA"kSma = "SMA"kWma = "WMA"// Inputvfi_length = input(8, title="Length", minval=1)  //default 130vfi_coef = input(0.2, title="Coef", minval=0.1)vfi_volCutoff = input(2.5, title="Volume Cutoff", minval=0.1)vfi_smoothLen = input(3, title="Smoothing Period", minval=1)vfi_smoothType = input(kEma, title="Smoothing Type", options=[kAlma, kEma, kSma, kWma])//These are adde by me for the strategy purpose  BEGINvfi_buyLine = input(-4, title="Buy Line", minval=-10)vfi_sellLine = input(5, title="Sell Line", minval=-10)stopLoss = input(title="Stop Loss%", defval=5, minval=1)//These are adde by me for the strategy purpose  ENDvfi_longEMA = input(200, title="Long EMA", minval=1)vfi_shortEMA1 = input(50, title="short EMA1", minval=1)vfi_shortEMA2 = input(9, title="short EM2A", minval=1)vfi_showTrend = input(false, title="Visualize Trend")vfi_showFill = input(true, title="Apply Filling")vfi_showMa = input(true, title="Show Moving Average")vfi_maType = input(kSma, title="Moving Average Type", options=[kAlma, kEma, kSma, kWma])vfi_maLength = input(30, title="Moving Average Length", minval=1)vfi_almaOffset = input(0.85, title="• ALMA - Offset (global setting)", minval=0.0, maxval=1.0, step=0.05) // more smoothness (closer to 1) vs. more responsiveness (closer to 0)vfi_almaSigma = input(6.0, title="• ALMA - Sigma (global setting)", minval=0.0, step=0.05) // the larger sigma the smoother ALMA// FunctionalityisRising(sig) =>    sig > sig[1]    isFlat(sig) =>    sig == sig[1]vfi_trendColor(sig) =>    isFlat(sig) ? kNeutralColor : isRising(sig) ? kBullColor : kBearColor    vfi_color(sig) =>    isFlat(sig) ? kNeutralColor : sig > 0 ? kBullColor : kBearColor    osc_color(sig) =>    sig == 0 ? kNeutralColor : sig > 0 ? kBullColor : kBearColorsmooth(t, sig, len) =>    ma = float(sig)         // None    if t == kSma            // Simple        ma := sma(sig, len)    if t == kEma            // Exponential        ma := ema(sig, len)    if t == kWma            // Weighted        ma := wma(sig, len)    if t == kAlma           // Arnaud Legoux        ma := alma(sig, len, vfi_almaOffset, vfi_almaSigma)    macalc_vfi(fviPeriod, smoothType, smoothLen, coef, vCoef) =>    avg = nz(hlc3)    inter = log(avg) - log(avg[1])    vInter = stdev(inter, 30)    cutOff = coef * vInter * close    vAve = smooth(kSma, volume[1], fviPeriod)    vMax = vAve * vCoef    vC = min(volume, vMax)    mf = avg - avg[1]    vCp = iff(mf > cutOff, vC, iff(mf < -cutOff, -vC, 0))    sVfi = sum(vCp, fviPeriod) / vAve    vfi = smooth(smoothType, sVfi, smoothLen)    value_vfi = calc_vfi(vfi_length, vfi_smoothType, vfi_smoothLen, vfi_coef, vfi_volCutoff)value_ma = smooth(vfi_maType, value_vfi, vfi_maLength)longEMAval= ema(close, vfi_longEMA)shortEMAval1= ema(close, vfi_shortEMA1)shortEMAval2= ema(close, vfi_shortEMA2)color_vfi = vfi_showTrend ? vfi_trendColor(value_vfi) : vfi_color(value_vfi)color_osc = vfi_showFill ? osc_color(value_vfi) : nacolor_ma = vfi_showMa ? kMaColor : na// Drawingsplot_vfi = plot(value_vfi, title="VFI", color=color_vfi, linewidth=1)plot_fill = plot(0, color=color_vfi, editable=false)fill(plot_vfi, plot_fill, title="Oscillator Fill", color=color_osc, transp=75) hline(vfi_buyLine, color=color.green, title="Buy Line", linewidth=2, linestyle=hline.style_dashed)hline(vfi_sellLine, color=color.purple, title="Sell Line", linewidth=2, linestyle=hline.style_dashed)plot(value_ma, title="MA", color=color_ma, linewidth=2)strategy.entry(id="VFI LE", long=true,  when=crossover(value_vfi,vfi_buyLine)  and ( shortEMAval1 >= longEMAval  ))//strategy.close(id="VFI LE", comment="Exit",   when=crossunder(value_vfi,vfi_sellLine))strategy.close(id="VFI LE", comment="TP Exit",   when=crossunder(value_vfi,vfi_sellLine) and close>strategy.position_avg_price)//strategy.close(id="VFI LE", comment="Exit",   when=  (shortEMAval1 > shortEMAval2 )  and crossunder(close, shortEMAval2))//stoplossstopLossVal =   strategy.position_avg_price -  (strategy.position_avg_price*stopLoss*0.01) strategy.close(id="VFI LE", comment="SL Exit",   when=crossunder(value_vfi,vfi_sellLine) and close < stopLossVal)