Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

Guerilla Fear-Greed Index Strategy

A Pine Script v4 strategy built on EMA (naaim, 10). 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 no commission. 17 settings; defaults include MA Length 10, NAAIM Weight 50 and NAAIM Fear Threshold 50.

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 Guerilla Fear-Greed Index Strategy repaint?
Yes
At least one pattern in the source can repaint: intrabar recalculation.
How did Guerilla Fear-Greed Index Strategy 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.
Can Guerilla Fear-Greed Index Strategy be converted to Pine Script v5?
Not tested
The steps are shown below, but neither version placed a trade on any market tested, so there was nothing to compare and no download is offered.
Does Guerilla Fear-Greed Index Strategy use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does Guerilla Fear-Greed Index Strategy run in Zeal Terminal?
Yes
It compiles in 13 ms and runs 1,000 bars in 52 ms, in the browser.

BTCUSDT · 1D · default settings

  • HLine
  • HLine
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOctHLine$10,000$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. The live re-run is not offered here: the script requests QUANDL:NAAIM/NAAIM W, USI:PCCE D, which this page cannot load in your browser.

Needs QUANDL:NAAIM/NAAIM W data, not available: not a Binance spot market Needs USI:PCCE 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, $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.

  • Check

    Every trade uses all the equity

    default_qty_value is 100% of equity.

  • Note

    No slippage

    Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.

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 security → request.security, ema → ta.ema.

v4 → v5

Not verified

Neither version placed a trade on any of the 8 markets, so there was nothing to compare.

  • Line 3: //@version=4 → //@version=5
  • Line 10: security → request.security
  • Line 11: ema → ta.ema
  • Line 17: security → request.security
  • Line 18: ema → ta.ema
  • Line 39: ema → ta.ema
⋯// © calebsandfort-//@version=4+//@version=5strategy(title = "Guerilla Fear/Greed Index Strategy", shorttitle = "GFGI Strat", overlay=false, default_qty_type=strategy.percent_of_equity, default_qty_value=100, initial_capital=10000, calc_on_every_tick=true)⋯naaim_greed_threshold = input(title="NAAIM Greed Threshold", defval=90)-naaim = security("QUANDL:NAAIM/NAAIM", "W", close)+naaim = request.security("QUANDL:NAAIM/NAAIM", "W", close)-naaimMa = ema(naaim, maLength)+naaimMa = ta.ema(naaim, maLength)naaimComponent = (naaimMa < naaim_fear_threshold ? 0 : naaimMa > naaim_greed_threshold ? 100 : ((naaimMa - naaim_fear_threshold)/(naaim_greed_threshold - naaim_fear_threshold)) * 100) * naaim_weight⋯pcce_greed_threshold = input(title="EPCR Greed Threshold", defval=.55)-pcce = security ("USI:PCCE", "D", close)+pcce = request.security ("USI:PCCE", "D", close)-pcceMa = ema(pcce, maLength)+pcceMa = ta.ema(pcce, maLength)pcceComponent = (pcceMa > pcce_fear_threshold ? 0 : pcceMa < pcce_greed_threshold ? 100 : ((pcce_fear_threshold - pcceMa)/(pcce_fear_threshold - pcce_greed_threshold)) * 100) * pcce_weight⋯gfgiMaLength = input(title="GFGI MA Length", defval=21)-gfgiMa = ema(gfgi, gfgiMaLength)+gfgiMa = ta.ema(gfgi, gfgiMaLength)gfgiMaColor = gfgiMa < 10 ? color1 : gfgiMa < 20 ? color2 : gfgiMa < 30 ? color3 : gfgiMa < 40 ? color4 :gfgiMa < 50 ? color5 :gfgiMa < 60 ? color6 :gfgiMa < 70 ? color7 : gfgiMa < 80 ? color8 : gfgiMa < 90 ? color9 : color10⋯

Clean v5

Not verified

Neither version placed a trade on any of the 8 markets, so there was nothing to compare.

  • Line 5: input() → input.int()
  • Line 7: input() → input.int()
  • Line 8: input() → input.int()
  • Line 9: input() → input.int()
  • Line 14: input() → input.int()
  • Line 15: input() → input.float()
11 more edits
  • Line 16: input() → input.float()
  • Line 21: input() → input.int()
  • Line 22: input() → input.int()
  • Line 38: input() → input.int()
  • Line 42: input() → input.int()
  • Line 43: input() → input.int()
  • Line 44: input() → input.int()
  • Line 47: input() → input.bool()
  • Line 48: input() → input.int()
  • Line 49: input() → input.int()
  • Line 50: input() → input.int()
⋯strategy(title = "Guerilla Fear/Greed Index Strategy", shorttitle = "GFGI Strat", overlay=false, default_qty_type=strategy.percent_of_equity, default_qty_value=100, initial_capital=10000, calc_on_every_tick=true)-maLength = input(title="MA Length", defval=10)+maLength = input.int(title="MA Length", defval=10)/////////////////////NAAIM Component/////////////////////-naaim_weight = input(title="NAAIM Weight", defval=50) / 100+naaim_weight = input.int(title="NAAIM Weight", defval=50) / 100-naaim_fear_threshold = input(title="NAAIM Fear Threshold", defval=50)+naaim_fear_threshold = input.int(title="NAAIM Fear Threshold", defval=50)-naaim_greed_threshold = input(title="NAAIM Greed Threshold", defval=90)+naaim_greed_threshold = input.int(title="NAAIM Greed Threshold", defval=90)naaim = request.security("QUANDL:NAAIM/NAAIM", "W", close)⋯/////////////////////Equity Put/Call Ratio Component/////////////////////-pcce_weight = input(title="EPCR Weight", defval=50) / 100+pcce_weight = input.int(title="EPCR Weight", defval=50) / 100-pcce_fear_threshold = input(title="EPCR Fear Threshold", defval=.7)+pcce_fear_threshold = input.float(title="EPCR Fear Threshold", defval=.7)-pcce_greed_threshold = input(title="EPCR Greed Threshold", defval=.55)+pcce_greed_threshold = input.float(title="EPCR Greed Threshold", defval=.55)pcce = request.security ("USI:PCCE", "D", close)⋯/////////////////////Guerilla Fear/Greed Index/////////////////////-buyLevel = input(title="Buy Level", defval=40)+buyLevel = input.int(title="Buy Level", defval=40)-sellLevel = input(title="Sell Level", defval=65)+sellLevel = input.int(title="Sell Level", defval=65)buyHline = hline(buyLevel, color = color.gray, linestyle = hline.style_dashed)⋯plot(gfgi, color=gfgiColor, linewidth = 2)-gfgiMaLength = input(title="GFGI MA Length", defval=21)+gfgiMaLength = input.int(title="GFGI MA Length", defval=21)gfgiMa = ta.ema(gfgi, gfgiMaLength)⋯plot(gfgiMa, color=gfgiMaColor, style=plot.style_circles)-startDate = input(title="Start Date", defval=1, minval=1, maxval=31)+startDate = input.int(title="Start Date", defval=1, minval=1, maxval=31)-startMonth = input(title="Start Month", defval=1, minval=1, maxval=12)+startMonth = input.int(title="Start Month", defval=1, minval=1, maxval=12)-startYear = input(title="Start Year", defval=2015, minval=1800, maxval=2100)+startYear = input.int(title="Start Year", defval=2015, 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(title="Use Close Date", defval=true)+useCloseDate = input.bool(title="Use Close Date", defval=true)-closeDay = input(title="Close Day", defval=20, minval=1, maxval=31)+closeDay = input.int(title="Close Day", defval=20, minval=1, maxval=31)-closeMonth = input(title="Close Month", defval=11, minval=1, maxval=12)+closeMonth = input.int(title="Close Month", defval=11, minval=1, maxval=12)-closeYear = input(title="Close Year", defval=2020, minval=1800, maxval=2100)  +closeYear = input.int(title="Close Year", defval=2020, minval=1800, maxval=2100)  // See if this bar's time happened on/after end date⋯

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.

⋯// © calebsandfort-//@version=5+//@version=6strategy(title = "Guerilla Fear/Greed Index Strategy", shorttitle = "GFGI Strat", overlay=false, default_qty_type=strategy.percent_of_equity, default_qty_value=100, initial_capital=10000, calc_on_every_tick=true)⋯

Settings

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

SettingDefaultType and rangeFeeds
MA Length10intnaaimMa pcceMa
NAAIM Weight50intnaaimComponent
NAAIM Fear Threshold50intnaaimComponent
NAAIM Greed Threshold90intnaaimComponent
EPCR Weight50intpcceComponent
EPCR Fear Threshold.7floatpcceComponent
EPCR Greed Threshold.55floatpcceComponent
Buy Level40intbuyHline Bull hline
Sell Level65intsellHline Bear hline
GFGI MA Length21intgfgiMa
Start Date1int · min 1 · max 31afterStartDate
Start Month1int · min 1 · max 12afterStartDate
Start Year2015int · min 1800 · max 2100afterStartDate
Use Close Datetrueboolclose Long line 59
Close Day20int · min 1 · max 31afterEndDate
Close Month11int · min 1 · max 12afterEndDate
Close Year2020int · min 1800 · max 2100afterEndDate

What it calculates

  • EMA (ema, ta.ema in v5)naaim, MA Length (10)naaimMa · line 11
  • EMA (ema, ta.ema in v5)pcce, MA Length (10)pcceMa · line 18
  • EMA (ema, ta.ema in v5)gfgi, GFGI MA Length (21)gfgiMa · line 39

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.

maLengthMA Lengthsetting · 10gfgiMaLengthGFGI MA Lengthsetting · 21closecloseprice datanaaim_fear_thresholdNAAIM Fear Thresholdsetting · 50naaim_greed_thresholdNAAIM Greed Thresholdsetting · 90naaim_weightNAAIM Weightsetting · 50pcce_fear_thresholdEPCR Fear Thresholdsetting · .7pcce_greed_thresholdEPCR Greed Thresholdsetting · .55pcce_weightEPCR Weightsetting · 50timetimeprice datastartYearStart Yearsetting · 2015startMonthStart Monthsetting · 1startDateStart Datesetting · 1closeYearClose Yearsetting · 2020closeMonthClose Monthsetting · 11closeDayClose Daysetting · 20buyLevelBuy Levelsetting · 40sellLevelSell Levelsetting · 65naaimMaEMA→ naaimMapcceMaEMA→ pcceMagfgiMaEMA→ gfgiManaaim, pccenaaim · pcce2 valuesnaaimComponentnaaimComponentvaluepcceComponentpcceComponentvaluegfgigfgivaluegfgiColorgfgiColorvaluegfgiMaColorgfgiMaColorvalueafterStartDateafterStartDateconditionafterEndDateafterEndDateconditionBullBullconditionBearBearconditioncolor1, color2, color3, color4, color5, color6, color7, color8, color9, color10Colourcolor1 · color2 +8entry:LongOpen Longstrategy.entryclose:LongClose Longstrategy.closehline:23hlinehlinehline:24hlinehlineplot:37plotplotplot:41plotplot

Order rules

OrderFires whenBy defaultLine
Open Long long(Bull and afterStartDate)On57
Close Long((afterStartDate and Bear) or (useCloseDate and afterEndDate))On60

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 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 QUANDL:NAAIM/NAAIM W, USI:PCCE 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

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

ScriptSharesTypeNetTradesMax drawdown
Guerilla Fear-Greed Index Strategy this page—v4 strategy0.0%00.0%
EMA Slope AyE by fajardoarelysemav4 strategyNo trades on this market
ROoT by realisticDove62527emav5 strategy−4.7%2259.4%
sachin5986 by mohitesachin78emav4 strategy+32.1%3517.6%
sonu1997 by Sonu1997emav4 strategy+960.7%21,103.8%
Moving Average Crossover by Muh4mm4demav4 strategy+19,990.1%301,274.2%

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 13 msYes 1,000 bars in 52 msNot measured
PineTSNo v5 and v6 only—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. 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/// © calebsandfort//@version=4strategy(title = "Guerilla Fear/Greed Index Strategy", shorttitle = "GFGI Strat", overlay=false, default_qty_type=strategy.percent_of_equity, default_qty_value=100, initial_capital=10000, calc_on_every_tick=true)maLength = input(title="MA Length", defval=10)/////////////////////NAAIM Component/////////////////////naaim_weight = input(title="NAAIM Weight", defval=50) / 100naaim_fear_threshold = input(title="NAAIM Fear Threshold", defval=50)naaim_greed_threshold = input(title="NAAIM Greed Threshold", defval=90)naaim = security("QUANDL:NAAIM/NAAIM", "W", close)naaimMa = ema(naaim, maLength)naaimComponent = (naaimMa < naaim_fear_threshold ? 0 : naaimMa > naaim_greed_threshold ? 100 : ((naaimMa - naaim_fear_threshold)/(naaim_greed_threshold - naaim_fear_threshold)) * 100) * naaim_weight/////////////////////Equity Put/Call Ratio Component/////////////////////pcce_weight = input(title="EPCR Weight", defval=50) / 100pcce_fear_threshold = input(title="EPCR Fear Threshold", defval=.7)pcce_greed_threshold = input(title="EPCR Greed Threshold", defval=.55)pcce = security ("USI:PCCE", "D", close)pcceMa = ema(pcce, maLength)pcceComponent = (pcceMa > pcce_fear_threshold ? 0 : pcceMa < pcce_greed_threshold ? 100 : ((pcce_fear_threshold - pcceMa)/(pcce_fear_threshold - pcce_greed_threshold)) * 100) * pcce_weight/////////////////////Guerilla Fear/Greed Index/////////////////////buyLevel = input(title="Buy Level", defval=40)sellLevel = input(title="Sell Level", defval=65)buyHline = hline(buyLevel, color = color.gray, linestyle = hline.style_dashed)sellHline = hline(sellLevel, color = color.gray, linestyle = hline.style_dashed)gfgi = naaimComponent + pcceComponentcolor1 = #ff0000color2 = #ff6400color3 = #ff9900color4 = #ffc700color5 = #fff200color6 = #d3e100color7 = #a9cf00color8 = #7fbd00color9 = #54aa00color10 = #1e9600gfgiColor = gfgi < 10 ? color1 : gfgi < 20 ? color2 : gfgi < 30 ? color3 : gfgi < 40 ? color4 :gfgi < 50 ? color5 :gfgi < 60 ? color6 :gfgi < 70 ? color7 : gfgi < 80 ? color8 : gfgi < 90 ? color9 : color10plot(gfgi, color=gfgiColor, linewidth = 2)gfgiMaLength = input(title="GFGI MA Length", defval=21)gfgiMa = ema(gfgi, gfgiMaLength)gfgiMaColor = gfgiMa < 10 ? color1 : gfgiMa < 20 ? color2 : gfgiMa < 30 ? color3 : gfgiMa < 40 ? color4 :gfgiMa < 50 ? color5 :gfgiMa < 60 ? color6 :gfgiMa < 70 ? color7 : gfgiMa < 80 ? color8 : gfgiMa < 90 ? color9 : color10plot(gfgiMa, color=gfgiMaColor, style=plot.style_circles)startDate = input(title="Start Date", defval=1, minval=1, maxval=31)startMonth = input(title="Start Month", defval=1, minval=1, maxval=12)startYear = input(title="Start Year", defval=2015, 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(title="Use Close Date", defval=true)closeDay = input(title="Close Day", defval=20, minval=1, maxval=31)closeMonth = input(title="Close Month", defval=11, minval=1, maxval=12)closeYear = input(title="Close Year", defval=2020, minval=1800, maxval=2100)  // See if this bar's time happened on/after end dateafterEndDate = year == closeYear and month == closeMonth and dayofmonth == closeDayBull = gfgiMa[1] < buyLevel and (gfgiMa[0] > gfgiMa[1]) and (gfgiMa[2] > gfgiMa[1])Bear = gfgiMa[1] > sellLevel and (gfgiMa[0] < gfgiMa[1]) and (gfgiMa[2] < gfgiMa[1])///Entries and Exits//if (Bull and afterStartDate)    strategy.entry("Long", strategy.long, comment = "LE")    if ((afterStartDate and Bear) or (useCloseDate and afterEndDate))    strategy.close("Long", qty_percent=100, comment="close")