Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Strategy

Bitcoin Scalping Strategy (Sampled with- PMARP+MADRID MA RIBBON)

A Pine Script v5 strategy built on Change (_ma), EMA or SMA (src, 05) and RSI (close, 14). It has 6 order rules, 2 entries among them, and trades long and short with the default settings. Exits use a stop loss and a profit target. Each trade commits 1000 in cash and pays no commission. 30 settings; defaults include Price source close, Indicator.... s_pmarp and PMAR length 20.

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 Bitcoin Scalping Strategy (Sampled with- PMARP+MADRID MA RIBBON) repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 22 of 22 trades.
How did Bitcoin Scalping Strategy (Sampled with- PMARP+MADRID MA RIBBON) do on BTCUSDT 1D with default settings?
−3.02%
From 26 Jan 2024 to 21 Oct 2026, over 72 closed trades, against +102.5% for buy and hold. A backtest, not investment advice.
Does Bitcoin Scalping Strategy (Sampled with- PMARP+MADRID MA RIBBON) run in Pine Script v6?
Yes
Same 72 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. The v6 script can be downloaded below.
Does Bitcoin Scalping Strategy (Sampled with- PMARP+MADRID MA RIBBON) use a stop loss?
Yes
strategy.exit sets a stop on line 509, 511.
Does Bitcoin Scalping Strategy (Sampled with- PMARP+MADRID MA RIBBON) run in Zeal Terminal?
Yes
It compiles in 195 ms and runs 1,000 bars in 514 ms, in the browser.

BTCUSDT · 1D · default settings

  • Scale high
  • Midline
  • Scale low
  • Plot line
  • Signal line
  • High alert level
  • Low alert level
  • Top Line
  • Bottom Line
  • Winning trade
  • Losing trade
  • Exit at a stop or limit price
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (28)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOctLimit exit at 94,594.00Limit exit at 86,637.20Limit exit at 84,739.80Limit exit at 76,968.20Limit exit at 62,909.90Limit exit at 60,884.60Scale high$948$2,025Equity from $1,000
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits, and squares exits filled at a stop or limit price. Lines are what the script plots.
Net profit
−3.02%
−$30.17
Buy and hold
+102.5%
same period
Closed trades
72
67 won · 5 lost
Profitable
93.1%
of closed trades
Profit factor
0.98
gross profit ÷ gross loss
Max drawdown
45.43%
−$519.28

One run with the author's default settings, $1,000 starting capital, commission as the script sets it. A long position was still open at the last bar. 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 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
Main Properties
Price sourceclosesourcema pmar pmarp
Indicator....s_pmarpstring · options [ s_pmar, s_pmarp ]pmarpOn
PMAR length20int · min 1ma pmarp
MA type...VWMAstring · options [ 'SMA', 'EMA', 'HMA', 'RMA', 'VWMA' ]ma pmarp
Line plot settings
Color typeSpectrumstring · options [ 'Spectrum', 'Solid' ]c_plotline c_hi_alert c_lo_alert c_bg Historical PMAR high
Spectrums_BGRstring · options [ s_BR, s_BGR ]c_plotline c_bg Historical PMAR high
Solid color#FFFF00colorc_plotline c_bg Historical PMAR high
Line width1int · min 1 · max 4Plot line Historical PMAR high
Lookback350int · min 1 · max 1900pmarp
Signal MA Settings
Signal MAtrueboolSignal line
MA length20int · min 1signal_ma
MA typeSMAstring · options [ 'SMA', 'EMA', 'HMA', 'RMA', 'VWMA' ]signal_ma
Color typeSolidstring · options [ 'Spectrum', 'Solid' ]c_plotsig
Spectrums_BGRstring · options [ s_BR, s_BGR ]c_plotsig c_hi_alert c_lo_alert
Solid colorcolor.whitecolorc_plotsig c_hi_alert c_lo_alert
Line width1int · min 1 · max 4Signal line
Visual Alert Level Settings
Hi PMARP alert level99float · min 0.1 · max 100 · step 0.01hi_alert hi_alertc High alert level
Lo PMARP alert level1float · min 0.1 · max 100 · step 0.01lo_alert Low alert level
Hi PMAR alert level.2.7float · min 0.1 · max 100 · step 0.01hi_alert hi_alertc High alert level
Lo PMAR alert level.0.7float · min 0.1 · max 100 · step 0.01lo_alert Low alert level
Hi alert line.trueboolHigh alert level bgcolor
Lo alert line.trueboolLow alert level bgcolor
Hi signal barstrueboolbgcolor
Lo signal barstrueboolbgcolor
Expnential MAtrueboolma05 ma10 ma15 ma20 ma25 ma30 ma35 ma40 ma45 ma50 ma55 ma60 ma65 ma70 ma75 ma80 ma85 ma90 ma100
Take Profit and Stop Loss
Take Profit1floatTake_S Take_L
Stop Loss27.75floatStop_L Stop_S
Top and Bottom Lines
Top Line75intH1P hline
Bottom Line20intH2P hline
Transparancy of FIll05intH3B

What it calculates

  • Change_madiffMA · line 244
  • EMA / SMAsrc, 05ma05 · line 256
  • EMA / SMAsrc, 10ma10 · line 257
  • EMA / SMAsrc, 15ma15 · line 258
  • EMA / SMAsrc, 20ma20 · line 259
  • EMA / SMAsrc, 25ma25 · line 260
  • EMA / SMAsrc, 30ma30 · line 261
  • EMA / SMAsrc, 35ma35 · line 262
  • EMA / SMAsrc, 40ma40 · line 263
  • EMA / SMAsrc, 45ma45 · line 264
  • EMA / SMAsrc, 50ma50 · line 265
  • EMA / SMAsrc, 55ma55 · line 266
  • EMA / SMAsrc, 60ma60 · line 267
  • EMA / SMAsrc, 65ma65 · line 268
  • EMA / SMAsrc, 70ma70 · line 269
  • EMA / SMAsrc, 75ma75 · line 270
  • EMA / SMAsrc, 80ma80 · line 271
  • EMA / SMAsrc, 85ma85 · line 272
  • EMA / SMAsrc, 90ma90 · line 273
  • EMA / SMAsrc, 100ma100 · line 274
  • Changema05Diffma1 · line 329
  • Changema10Diffma2 · line 330
  • Changema15Diffma3 · line 331
  • Changema20Diffma4 · line 332
  • Changema25Diffma5 · line 333
  • Changema30Diffma6 · line 334
  • Changema35Diffma7 · line 335
  • Changema40Diffma8 · line 336
  • Changema45Diffma9 · line 337
  • Changema50Diffma10 · line 338
  • Changema55Diffma11 · line 339
  • Changema60Diffma12 · line 340
  • Changema65Diffma13 · line 341
  • Changema70Diffma14 · line 342
  • Changema75Diffma15 · line 343
  • Changema80Diffma16 · line 344
  • Changema85Diffma17 · line 345
  • Changema90Diffma18 · line 346
  • RSIclose, 14r · line 464
  • Stochclose, 14, 1, 3s · line 465

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.

The script has 218 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.

Order rules

OrderFires whenBy defaultLine
Open Long long(lime_Long) and not (noREL) and not (noENGL) and not (rP)On473
Open Short short(red_Short) and not (noRES)On475
Close Longstrategy.position_size > 0 and pmarp >= 99 and red_Short == trueOn489
Close Shortstrategy.position_size < 0 and pmarp <= 01On491
Exit Close Long stop and limitstrategy.position_size > 0On509
Exit Close Short stop and limitstrategy.position_size < 0On511

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, and the live replay matched history.

22/22trades identical when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. Orders are decided once per closed bar, so nothing can change mid-bar.
  • 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−3.0%+102.5%7293%0.9845.4%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h+6.7%+5.5%4587%1.1724.7%8 May 2026 – 21 Oct 2026
ETHUSDT 1D−27.1%+9.8%7591%0.8692.6%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h+43.2%+8.4%6097%2.8314.7%8 May 2026 – 21 Oct 2026
SOLUSDT 1D−63.1%+16.7%8690%0.74135.6%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h+23.1%+21.5%6494%1.4026.6%8 May 2026 – 21 Oct 2026
BNBUSDT 1D−14.0%+148.3%6692%0.8982.4%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h−14.3%+17.1%3589%0.7240.9%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 market20100%$391.08
Sideways market2383%−$799.29
Falling market2997%$378.04

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

How bad could the drawdown be?

65.2%

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

0%75%
All 72 trades
SideEntryExitBarsP&L
long16 May 2024 66,206.5017 May 2024 66,868.601$10.00
long18 May 2024 67,024.0019 May 2024 67,694.201$10.00
long20 May 2024 66,274.0021 May 2024 71,446.601$78.05
long23 May 2024 69,166.6027 May 2024 69,858.304$10.00
long28 May 2024 69,436.403 Jun 2024 70,130.806$10.00
long4 Jun 2024 68,809.905 Jun 2024 70,537.801$25.11
long29 Jul 2024 68,249.905 Aug 2024 49,310.507−$277.50
short15 Aug 2024 58,683.4016 Aug 2024 57,541.101$19.47
short19 Aug 2024 58,427.3030 Aug 2024 57,843.1011$10.00
short31 Aug 2024 59,124.001 Sep 2024 58,532.801$10.00
short2 Sep 2024 57,301.804 Sep 2024 56,728.802$10.00
short5 Sep 2024 57,970.906 Sep 2024 56,180.001$30.89
short7 Sep 2024 53,963.0018 Oct 2024 68,937.7041−$277.50
long19 Oct 2024 68,428.0020 Oct 2024 69,112.301$10.00
long21 Oct 2024 69,032.0028 Oct 2024 69,722.307$10.00
long6 Nov 2024 69,372.007 Nov 2024 75,572.001$89.37
long14 Nov 2024 90,375.2015 Nov 2024 91,279.001$10.00
long16 Nov 2024 91,032.1018 Nov 2024 91,942.402$10.00
long19 Nov 2024 90,464.1020 Nov 2024 92,310.801$20.41
long25 Nov 2024 97,900.104 Dec 2024 98,879.109$10.00
long7 Dec 2024 99,740.808 Dec 2024 100,738.001$10.00
long12 Dec 2024 101,125.0014 Dec 2024 102,136.002$10.00
long16 Dec 2024 104,464.0017 Dec 2024 106,059.001$15.27
long18 Jan 2025 104,077.0019 Jan 2025 105,118.001$10.00
long21 Jan 2025 102,260.0022 Jan 2025 106,144.001$37.98
long24 Jan 2025 103,910.0025 Jan 2025 104,949.001$10.00
long30 Jan 2025 103,733.0031 Jan 2025 104,771.001$10.00
short6 Apr 2025 83,538.007 Apr 2025 78,430.001$61.15
short8 Apr 2025 79,163.209 Apr 2025 76,322.401$35.89
short11 Apr 2025 79,607.308 May 2025 101,698.0027−$277.50
long11 May 2025 104,810.0018 May 2025 105,858.007$10.00
long19 May 2025 106,454.0021 May 2025 107,519.002$10.00
long28 Jun 2025 107,048.0029 Jun 2025 108,118.001$10.00
long3 Jul 2025 108,850.009 Jul 2025 109,938.006$10.00
long14 Jul 2025 119,087.0017 Jul 2025 120,278.003$10.00
long11 Aug 2025 119,294.0013 Aug 2025 120,487.002$10.00
long15 Sep 2025 115,268.0016 Sep 2025 116,421.001$10.00
long19 Sep 2025 117,074.001 Oct 2025 118,244.0012$10.00
long2 Oct 2025 118,595.003 Oct 2025 120,529.001$16.31
long9 Oct 2025 123,306.0014 Nov 2025 99,692.0036−$191.51
short14 Nov 2025 99,692.0015 Nov 2025 94,594.00 limit1$51.14
short16 Nov 2025 95,596.2017 Nov 2025 94,261.401$13.96
short18 Nov 2025 92,215.1019 Nov 2025 91,293.001$10.00
short20 Nov 2025 91,555.0021 Nov 2025 86,637.20 limit1$53.71
short22 Nov 2025 85,129.4023 Nov 2025 84,739.80 limit1$4.58
short24 Nov 2025 86,830.001 Dec 2025 85,961.707$10.00
short2 Dec 2025 86,286.0015 Dec 2025 85,423.1013$10.00
short16 Dec 2025 86,432.1017 Dec 2025 85,567.801$10.00
short18 Dec 2025 86,243.2019 Dec 2025 85,380.801$10.00
short24 Dec 2025 87,486.0025 Jan 2026 86,611.1032$10.00
short26 Jan 2026 86,670.4029 Jan 2026 85,803.603$10.00
short30 Jan 2026 84,650.2031 Jan 2026 83,803.601$10.00
short1 Feb 2026 78,741.102 Feb 2026 76,968.20 limit1$22.52
short3 Feb 2026 78,738.604 Feb 2026 75,770.201$37.70
short5 Feb 2026 73,165.806 Feb 2026 62,909.90 limit1$140.17
short7 Feb 2026 70,580.308 Feb 2026 69,289.401$18.29
short9 Feb 2026 70,330.4010 Feb 2026 69,627.101$10.00
short11 Feb 2026 68,841.3012 Feb 2026 67,082.501$25.55
short13 Feb 2026 66,272.2023 Feb 2026 65,609.4010$10.00
short24 Feb 2026 64,656.0025 Feb 2026 64,009.401$10.00
short28 Feb 2026 65,872.101 Mar 2026 65,213.401$10.00
short2 Mar 2026 65,776.5029 Mar 2026 65,118.7027$10.00
short30 Mar 2026 66,010.903 Jun 2026 65,350.8065$10.00
short4 Jun 2026 64,142.805 Jun 2026 63,501.301$10.00
short6 Jun 2026 61,056.507 Jun 2026 60,884.60 limit1$2.81
short8 Jun 2026 63,332.009 Jun 2026 62,698.701$10.00
short10 Jun 2026 61,730.0024 Jun 2026 61,112.7014$10.00
short25 Jun 2026 61,078.0026 Jun 2026 59,794.601$21.01
short27 Jun 2026 60,097.3028 Jun 2026 59,496.301$10.00
short29 Jun 2026 59,577.0030 Jun 2026 58,981.201$10.00
short1 Jul 2026 58,624.7021 Aug 2026 74,893.1051−$277.50
long6 Sep 2026 79,831.8018 Sep 2026 80,630.1012$10.00

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
Bitcoin Scalping Strategy (Sampled with- PMARP+MADRID MA RIBBON) this page—v5 strategy−3.0%7245.4%
RSI Mean Reversion Bot Strategy by Solutions1978rsi ema stoch smav4 strategyNo trades on this market
MACD, RSI, & RVOL Strategy by BobBarker42069rsi ema smav4 strategy+32.6%11.5%
IFR2 - RSI2 by jocker.soadrsi sma emav4 strategyNo trades on this market
Vin's Playzone Strategy by Vvaz_ema rsi smav5 strategy−908.1%213,570.5%
Stoch-RSI 4h-1h-15min by MoonFlagema rsi sma stochv4 strategyNo trades on this market

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.

  • 1 setting uses the untyped input() (line 253). It still compiles in v6; input.int, input.float or input.source state the type.
  • No v6-only features. v6 is not needed to run this script.

Clean v5

VerifiedDownload the v5 script

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

  • Line 253: input() → input.bool()
⋯// ────────────────────[ Input Parameters ]-i_exp = input(true, title='Expnential MA')+i_exp = input.bool(true, title='Expnential MA')// ────────────────────[ Processing ]⋯

Does it run in Pine Script v6?

Yes

Same 72 trades and the same P&L on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.

Download the v6 script

⋯// © CheatCode1-//@version=5+//@version=6strategy("PMAR and Madrid MA Strategy Excecuted by @CheatCode1", overlay=false, margin_long=0, margin_short=0, default_qty_type = strategy.cash, initial_capital = 1000, pyramiding = 0, default_qty_value = 1000, max_bars_back = 100)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 195 msYes 1,000 bars in 514 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/// © CheatCode1//@version=5strategy("PMAR and Madrid MA Strategy Excecuted by @CheatCode1", overlay=false, margin_long=0, margin_short=0, default_qty_type = strategy.cash, initial_capital = 1000, pyramiding = 0, default_qty_value = 1000, max_bars_back = 100)//// THIS IS PMARP, AN INDiCATOR CREATED BY @THE_CARETAKER, I DO NOT TAKE CREDIT FOR ANY SCRIPT WRITTEN UNTIL THE START OF THE NEXT INDICATOR. PLEASE REFER TO @The_Caretaker FOR QUESTIONS REGARDING THE PMAR/PMARP INDICATOR. THANK YOU!    //// THIS IS PMARP, AN INDiCATOR CREATED BY @THE_CARETAKER, I DO NOT TAKE CREDIT FOR ANY SCRiPT WRITTEN UNTIL THE START OF THE NEXT INDICATOR. PLEASE REFER TO @The_Caretaker FOR QUESTIONS REGARDING THE PMAR/PMARP INDICATOR. THANK YOU!    //// THIS IS PMARP, AN INDiCATOR CREATED BY @THE_CARETAKER, I DO NOT TAKE CREDIT FOR ANY SCRIPT WRITTEN UNTIL THE START OF THE NEXT INDICATOR. PLEASE REFER TO @The_Caretaker FOR QUESTIONS REGARDING THE PMAR/PMARP INDICATOR. THANK YOU!// @version=5//// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// @author = The_Caretaker// © The_Caretaker//// Much respect to Eric Crown for this idea.// // Feel free to reuse or develop this script further, please drop me a note below if you find it useful./////////////////////////////////////////////////////////////////////////////////// Input default variable declarationsvar string s_pmarp = 'Price Moving Average Ratio Percentile'var string s_pmar  = 'Price Moving Average Ratio'var string s_BGR   = 'Blue Green Red'var string s_BR    = 'Blue Red'var float pmarHigh = 0.0///////////////////////////////////////////////////////////////////////////////// Inputsi_src_price         = input.source  ( close,        'Price source',                                                                         inline='1',     group='Main Properties')i_p_type_line       = input.string  ( s_pmarp,      'Indicator....',            options=[ s_pmar, s_pmarp ],                                inline='2',     group='Main Properties')i_ma_len            = input.int     ( 20,           'PMAR length',              minval=1,                                                   inline='3',     group='Main Properties')i_ma_typ            = input.string  ( 'VWMA',       'MA type...',               options=[ 'SMA', 'EMA', 'HMA', 'RMA', 'VWMA' ],             inline='3',     group='Main Properties')i_c_typ_line        = input.string  ( 'Spectrum',   'Color type',               options=[ 'Spectrum', 'Solid' ],                            inline='1',     group='Line plot settings')i_c_typ_spctrm_line = input.string  ( s_BGR,        'Spectrum',                 options=[ s_BR, s_BGR ],                                    inline='1',     group='Line plot settings')i_c_solid_line      = input.color   ( #FFFF00,      'Solid color',                                                                          inline='1',     group='Line plot settings')i_p_width_line      = input.int     ( 1,            'Line width',               minval=1, maxval=4,                                         inline='2',     group='Line plot settings')i_pmarp_lookback    = input.int     ( 350,          'Lookback',                 minval=1, maxval=1900,                                      inline='2',     group='Line plot settings')i_show_signal_ma    = input.bool    ( true,         'Signal MA',                                                                            inline='0',     group='Signal MA Settings')i_signal_ma_Len     = input.int     ( 20,           'MA length',                minval=1,                                                   inline='1',     group='Signal MA Settings')i_signal_ma_typ     = input.string  ( 'SMA',        'MA type',                  options=[ 'SMA', 'EMA', 'HMA', 'RMA', 'VWMA' ],             inline='1',     group='Signal MA Settings')i_c_typ_sig         = input.string  ( 'Solid',      'Color type',               options=[ 'Spectrum', 'Solid' ],                            inline='2',     group='Signal MA Settings')i_c_typ_spctrm_sig  = input.string  ( s_BGR,        'Spectrum',                 options=[ s_BR, s_BGR ],                                    inline='2',     group='Signal MA Settings')i_c_solid_sig       = input.color   ( color.white,  'Solid color',                                                                          inline='2',     group='Signal MA Settings')i_p_width_sig       = input.int     ( 1,            'Line width',               minval=1, maxval=4,                                         inline='3',     group='Signal MA Settings')i_hi_alert_pmarp    = input.float   ( 99,           'Hi PMARP alert level',     minval=0.1, maxval=100, step=0.01,                          inline='6',     group='Visual Alert Level Settings')i_lo_alert_pmarp    = input.float   ( 1,            'Lo PMARP alert level',     minval=0.1, maxval=100, step=0.01,                          inline='6',     group='Visual Alert Level Settings')i_hi_alert_pmar     = input.float   ( 2.7,          'Hi PMAR alert level.',     minval=0.1, maxval=100, step=0.01,                          inline='7',     group='Visual Alert Level Settings')i_lo_alert_pmar     = input.float   ( 0.7,          'Lo PMAR alert level.',     minval=0.1, maxval=100, step=0.01,                          inline='7',     group='Visual Alert Level Settings')i_hi_alert_line_on  = input.bool    ( true,         'Hi alert line.',                                                                       inline='8',     group='Visual Alert Level Settings')i_lo_alert_line_on  = input.bool    ( true,         'Lo alert line.',                                                                       inline='8',     group='Visual Alert Level Settings')i_bg_hi_signal_on   = input.bool    ( true,         'Hi signal bars',                                                                       inline='9',     group='Visual Alert Level Settings')i_bg_lo_signal_on   = input.bool    ( true,         'Lo signal bars',                                                                       inline='9',     group='Visual Alert Level Settings')///////////////////////////////////////////////////////////////////////////////// variable declarationsvar c_prcntSpctrm1 = array.new_color ( na )if barstate.isfirst    array.push ( c_prcntSpctrm1, #0000FF ),    array.push ( c_prcntSpctrm1, #000AFF ), array.push ( c_prcntSpctrm1, #0014FF ), array.push ( c_prcntSpctrm1, #001FFF ), array.push ( c_prcntSpctrm1, #0029FF ), array.push ( c_prcntSpctrm1, #0033FF ),    array.push ( c_prcntSpctrm1, #003DFF ), array.push ( c_prcntSpctrm1, #0047FF ), array.push ( c_prcntSpctrm1, #0052FF ), array.push ( c_prcntSpctrm1, #005CFF ), array.push ( c_prcntSpctrm1, #0066FF ),    array.push ( c_prcntSpctrm1, #0070FF ), array.push ( c_prcntSpctrm1, #007AFF ), array.push ( c_prcntSpctrm1, #0085FF ), array.push ( c_prcntSpctrm1, #008FFF ), array.push ( c_prcntSpctrm1, #0099FF ),     array.push ( c_prcntSpctrm1, #00A3FF ), array.push ( c_prcntSpctrm1, #00ADFF ), array.push ( c_prcntSpctrm1, #00B8FF ), array.push ( c_prcntSpctrm1, #00C2FF ), array.push ( c_prcntSpctrm1, #00CCFF ),     array.push ( c_prcntSpctrm1, #00D6FF ), array.push ( c_prcntSpctrm1, #00E0FF ), array.push ( c_prcntSpctrm1, #00EBFF ), array.push ( c_prcntSpctrm1, #00F5FF ), array.push ( c_prcntSpctrm1, #00FFFF ),     array.push ( c_prcntSpctrm1, #00FFF5 ), array.push ( c_prcntSpctrm1, #00FFEB ), array.push ( c_prcntSpctrm1, #00FFE0 ), array.push ( c_prcntSpctrm1, #00FFD6 ), array.push ( c_prcntSpctrm1, #00FFCC ),     array.push ( c_prcntSpctrm1, #00FFC2 ), array.push ( c_prcntSpctrm1, #00FFB8 ), array.push ( c_prcntSpctrm1, #00FFAD ), array.push ( c_prcntSpctrm1, #00FFA3 ), array.push ( c_prcntSpctrm1, #00FF99 ),     array.push ( c_prcntSpctrm1, #00FF8F ), array.push ( c_prcntSpctrm1, #00FF85 ), array.push ( c_prcntSpctrm1, #00FF7A ), array.push ( c_prcntSpctrm1, #00FF70 ), array.push ( c_prcntSpctrm1, #00FF66 ),     array.push ( c_prcntSpctrm1, #00FF5C ), array.push ( c_prcntSpctrm1, #00FF52 ), array.push ( c_prcntSpctrm1, #00FF47 ), array.push ( c_prcntSpctrm1, #00FF3D ), array.push ( c_prcntSpctrm1, #00FF33 ),     array.push ( c_prcntSpctrm1, #00FF29 ), array.push ( c_prcntSpctrm1, #00FF1F ), array.push ( c_prcntSpctrm1, #00FF14 ), array.push ( c_prcntSpctrm1, #00FF0A ), array.push ( c_prcntSpctrm1, #00FF00 ),     array.push ( c_prcntSpctrm1, #0AFF00 ), array.push ( c_prcntSpctrm1, #14FF00 ), array.push ( c_prcntSpctrm1, #1FFF00 ), array.push ( c_prcntSpctrm1, #29FF00 ), array.push ( c_prcntSpctrm1, #33FF00 ),     array.push ( c_prcntSpctrm1, #3DFF00 ), array.push ( c_prcntSpctrm1, #47FF00 ), array.push ( c_prcntSpctrm1, #52FF00 ), array.push ( c_prcntSpctrm1, #5CFF00 ), array.push ( c_prcntSpctrm1, #66FF00 ),     array.push ( c_prcntSpctrm1, #70FF00 ), array.push ( c_prcntSpctrm1, #7AFF00 ), array.push ( c_prcntSpctrm1, #85FF00 ), array.push ( c_prcntSpctrm1, #8FFF00 ), array.push ( c_prcntSpctrm1, #99FF00 ),     array.push ( c_prcntSpctrm1, #A3FF00 ), array.push ( c_prcntSpctrm1, #ADFF00 ), array.push ( c_prcntSpctrm1, #B8FF00 ), array.push ( c_prcntSpctrm1, #C2FF00 ), array.push ( c_prcntSpctrm1, #CCFF00 ),     array.push ( c_prcntSpctrm1, #D6FF00 ), array.push ( c_prcntSpctrm1, #E0FF00 ), array.push ( c_prcntSpctrm1, #EBFF00 ), array.push ( c_prcntSpctrm1, #F5FF00 ), array.push ( c_prcntSpctrm1, #FFFF00 ),     array.push ( c_prcntSpctrm1, #FFF500 ), array.push ( c_prcntSpctrm1, #FFEB00 ), array.push ( c_prcntSpctrm1, #FFE000 ), array.push ( c_prcntSpctrm1, #FFD600 ), array.push ( c_prcntSpctrm1, #FFCC00 ),     array.push ( c_prcntSpctrm1, #FFC200 ), array.push ( c_prcntSpctrm1, #FFB800 ), array.push ( c_prcntSpctrm1, #FFAD00 ), array.push ( c_prcntSpctrm1, #FFA300 ), array.push ( c_prcntSpctrm1, #FF9900 ),     array.push ( c_prcntSpctrm1, #FF8F00 ), array.push ( c_prcntSpctrm1, #FF8500 ), array.push ( c_prcntSpctrm1, #FF7A00 ), array.push ( c_prcntSpctrm1, #FF7000 ), array.push ( c_prcntSpctrm1, #FF6600 ),     array.push ( c_prcntSpctrm1, #FF5C00 ), array.push ( c_prcntSpctrm1, #FF5200 ), array.push ( c_prcntSpctrm1, #FF4700 ), array.push ( c_prcntSpctrm1, #FF3D00 ), array.push ( c_prcntSpctrm1, #FF3300 ),     array.push ( c_prcntSpctrm1, #FF2900 ), array.push ( c_prcntSpctrm1, #FF1F00 ), array.push ( c_prcntSpctrm1, #FF1400 ), array.push ( c_prcntSpctrm1, #FF0000 ), array.push ( c_prcntSpctrm1, #FF0000 )var c_prcntSpctrm2 = array.new_color ( na )if barstate.isfirst    array.push ( c_prcntSpctrm2, #0000FF ),    array.push ( c_prcntSpctrm2, #0200FC ), array.push ( c_prcntSpctrm2, #0500F9 ), array.push ( c_prcntSpctrm2, #0700F7 ), array.push ( c_prcntSpctrm2, #0A00F4 ), array.push ( c_prcntSpctrm2, #0C00F2 ),     array.push ( c_prcntSpctrm2, #0F00EF ), array.push ( c_prcntSpctrm2, #1100ED ), array.push ( c_prcntSpctrm2, #1400EA ), array.push ( c_prcntSpctrm2, #1600E8 ), array.push ( c_prcntSpctrm2, #1900E5 ),     array.push ( c_prcntSpctrm2, #1C00E2 ), array.push ( c_prcntSpctrm2, #1E00E0 ), array.push ( c_prcntSpctrm2, #2100DD ), array.push ( c_prcntSpctrm2, #2300DB ), array.push ( c_prcntSpctrm2, #2600D8 ),    array.push ( c_prcntSpctrm2, #2800D6 ), array.push ( c_prcntSpctrm2, #2B00D3 ), array.push ( c_prcntSpctrm2, #2D00D1 ), array.push ( c_prcntSpctrm2, #3000CE ), array.push ( c_prcntSpctrm2, #3300CC ),    array.push ( c_prcntSpctrm2, #3500C9 ), array.push ( c_prcntSpctrm2, #3800C6 ), array.push ( c_prcntSpctrm2, #3A00C4 ), array.push ( c_prcntSpctrm2, #3D00C1 ), array.push ( c_prcntSpctrm2, #3F00BF ),     array.push ( c_prcntSpctrm2, #4200BC ), array.push ( c_prcntSpctrm2, #4400BA ), array.push ( c_prcntSpctrm2, #4700B7 ), array.push ( c_prcntSpctrm2, #4900B5 ), array.push ( c_prcntSpctrm2, #4C00B2 ),    array.push ( c_prcntSpctrm2, #4F00AF ), array.push ( c_prcntSpctrm2, #5100AD ), array.push ( c_prcntSpctrm2, #5400AA ), array.push ( c_prcntSpctrm2, #5600A8 ), array.push ( c_prcntSpctrm2, #5900A5 ),     array.push ( c_prcntSpctrm2, #5B00A3 ), array.push ( c_prcntSpctrm2, #5E00A0 ), array.push ( c_prcntSpctrm2, #60009E ), array.push ( c_prcntSpctrm2, #63009B ), array.push ( c_prcntSpctrm2, #660099 ),    array.push ( c_prcntSpctrm2, #680096 ), array.push ( c_prcntSpctrm2, #6B0093 ), array.push ( c_prcntSpctrm2, #6D0091 ), array.push ( c_prcntSpctrm2, #70008E ), array.push ( c_prcntSpctrm2, #72008C ),     array.push ( c_prcntSpctrm2, #750089 ), array.push ( c_prcntSpctrm2, #770087 ), array.push ( c_prcntSpctrm2, #7A0084 ), array.push ( c_prcntSpctrm2, #7C0082 ), array.push ( c_prcntSpctrm2, #7F007F ),    array.push ( c_prcntSpctrm2, #82007C ), array.push ( c_prcntSpctrm2, #84007A ), array.push ( c_prcntSpctrm2, #870077 ), array.push ( c_prcntSpctrm2, #890075 ), array.push ( c_prcntSpctrm2, #8C0072 ),     array.push ( c_prcntSpctrm2, #8E0070 ), array.push ( c_prcntSpctrm2, #91006D ), array.push ( c_prcntSpctrm2, #93006B ), array.push ( c_prcntSpctrm2, #960068 ), array.push ( c_prcntSpctrm2, #990066 ),    array.push ( c_prcntSpctrm2, #9B0063 ), array.push ( c_prcntSpctrm2, #9E0060 ), array.push ( c_prcntSpctrm2, #A0005E ), array.push ( c_prcntSpctrm2, #A3005B ), array.push ( c_prcntSpctrm2, #A50059 ),     array.push ( c_prcntSpctrm2, #A80056 ), array.push ( c_prcntSpctrm2, #AA0054 ), array.push ( c_prcntSpctrm2, #AD0051 ), array.push ( c_prcntSpctrm2, #AF004F ), array.push ( c_prcntSpctrm2, #B2004C ),     array.push ( c_prcntSpctrm2, #B50049 ), array.push ( c_prcntSpctrm2, #B70047 ), array.push ( c_prcntSpctrm2, #BA0044 ), array.push ( c_prcntSpctrm2, #BC0042 ), array.push ( c_prcntSpctrm2, #BF003F ),     array.push ( c_prcntSpctrm2, #C1003D ), array.push ( c_prcntSpctrm2, #C4003A ), array.push ( c_prcntSpctrm2, #C60038 ), array.push ( c_prcntSpctrm2, #C90035 ), array.push ( c_prcntSpctrm2, #CC0033 ),    array.push ( c_prcntSpctrm2, #CE0030 ), array.push ( c_prcntSpctrm2, #D1002D ), array.push ( c_prcntSpctrm2, #D3002B ), array.push ( c_prcntSpctrm2, #D60028 ), array.push ( c_prcntSpctrm2, #D80026 ),     array.push ( c_prcntSpctrm2, #DB0023 ), array.push ( c_prcntSpctrm2, #DD0021 ), array.push ( c_prcntSpctrm2, #E0001E ), array.push ( c_prcntSpctrm2, #E2001C ), array.push ( c_prcntSpctrm2, #E50019 ),    array.push ( c_prcntSpctrm2, #E80016 ), array.push ( c_prcntSpctrm2, #EA0014 ), array.push ( c_prcntSpctrm2, #ED0011 ), array.push ( c_prcntSpctrm2, #EF000F ), array.push ( c_prcntSpctrm2, #F2000C ),     array.push ( c_prcntSpctrm2, #F4000A ), array.push ( c_prcntSpctrm2, #F70007 ), array.push ( c_prcntSpctrm2, #F90005 ), array.push ( c_prcntSpctrm2, #FC0002 ), array.push ( c_prcntSpctrm2, #FF0000 )///////////////////////////////////////////////////////////////////////////////// Function Declarationsf_prior_sum ( _P, _X ) =>    math.sum ( _P[1], _X - 1 )f_ma_val ( _P, _typ, _len ) =>    _typ == 'SMA' ? ta.sma ( _P, _len ) : _typ == 'EMA' ? ta.ema ( _P, _len ) : _typ == 'RMA' ? ta.rma ( _P, _len ) : _typ == 'HMA' ? ta.hma ( _P, _len ) : ta.vwma ( _P, _len )f_pmarp ( _price, _pmarLen, _pmarpLen, _type ) =>    _pmar = math.abs ( _price / f_ma_val ( _price, _type, _pmarLen ))    _pmarpSum = 0    _len = bar_index < _pmarpLen ? bar_index : _pmarpLen    for i = 1 to _len by 1        _pmarpSum += ( _pmar[i] > _pmar ? 0 : 1 )        _pmarpSum    _return = bar_index >= _pmarLen ? _pmarpSum / _len * 100 : naf_clrSlct ( _percent, _select, _type, _solid, _array1, _array2 ) =>    _select == 'Solid' ? _solid : array.get ( _type == 'Blue Green Red' ? _array1 : _array2, math.round ( _percent ))/////////////////////////////////////////////////////////////////////////////// // calculationspmarpOn     = i_p_type_line == 'Price Moving Average Ratio Percentile'ma          = f_ma_val ( i_src_price, i_ma_typ, i_ma_len )pmar        = i_src_price / mapmarp       = f_pmarp ( i_src_price, i_ma_len, i_pmarp_lookback, i_ma_typ )pmarHigh := pmar > pmarHigh ? pmar : pmarHighc_pmar      = ( pmar / pmarHigh )*100plotline    = pmarpOn ? pmarp : pmarc_plotline  = f_clrSlct ( pmarpOn ? plotline : c_pmar,  i_c_typ_line,    i_c_typ_spctrm_line, i_c_solid_line, c_prcntSpctrm1, c_prcntSpctrm2 )signal_ma   = f_ma_val  ( plotline,  i_signal_ma_typ, i_signal_ma_Len )c_plotsig   = f_clrSlct ( signal_ma, i_c_typ_sig,     i_c_typ_spctrm_sig,  i_c_solid_sig,  c_prcntSpctrm1, c_prcntSpctrm2 )hi_alert    = pmarpOn ? i_hi_alert_pmarp : i_hi_alert_pmarlo_alert    = pmarpOn ? i_lo_alert_pmarp : i_lo_alert_pmarhi_alertc   = pmarpOn ? i_hi_alert_pmarp : i_hi_alert_pmar > pmarHigh ? 100 : ( i_hi_alert_pmar / pmarHigh ) * 100c_hi_alert  = f_clrSlct ( hi_alertc, i_c_typ_line, i_c_typ_spctrm_sig,  i_c_solid_sig,  c_prcntSpctrm1, c_prcntSpctrm2 )c_lo_alert  = f_clrSlct ( lo_alert, i_c_typ_line, i_c_typ_spctrm_sig,  i_c_solid_sig,  c_prcntSpctrm1, c_prcntSpctrm2 )c_bg        = color.new ( f_clrSlct ( pmarp,    i_c_typ_line, i_c_typ_spctrm_line, i_c_solid_line, c_prcntSpctrm1, c_prcntSpctrm2 ), 50 )p_hi_alert  = plotline > hi_alertp_lo_alert  = plotline < lo_alert///////////////////////////////////////////////////////////////////////////////// Line Plotp_scaleHi   = plot ( pmarpOn ? 100 : na, 'Scale high', #ff0000, style = plot.style_line )p_midLine   = plot ( pmarpOn ? 50  : na, 'Midline',   #555555, style = plot.style_line )p_scaleLo   = plot ( pmarpOn ? 0   : na, 'Scale low',  #0000ff, style = plot.style_line )plot ( plotline, 'Plot line', c_plotline, i_p_width_line, editable=false )plot ( pmarpOn ? na : pmarHigh, 'Historical PMAR high', f_clrSlct ( 100, i_c_typ_line, i_c_typ_spctrm_line, i_c_solid_line, c_prcntSpctrm1, c_prcntSpctrm2 ), i_p_width_line, editable=false )plot ( i_show_signal_ma ? signal_ma : na, 'Signal line', c_plotsig, i_p_width_sig, editable=false )plot ( i_hi_alert_line_on and pmarpOn ? i_hi_alert_pmarp : i_hi_alert_pmar, 'High alert level', c_hi_alert, style = plot.style_line )plot ( i_lo_alert_line_on and pmarpOn ? i_lo_alert_pmarp : i_lo_alert_pmar, 'Low alert level', c_lo_alert, style = plot.style_line )bgcolor ( p_hi_alert and i_hi_alert_line_on and i_bg_hi_signal_on ? c_bg : na )bgcolor ( p_lo_alert and i_lo_alert_line_on and i_bg_lo_signal_on ? c_bg : na )///////////////////////////////////////////////////////////////////////////////// End// THIS IS PMARP, AN INDiCATOR CREATED BY @THE_CARETAKER, I DO NOT TAKE CREDIT FOR ANY CODE WRITTEN ABOVE HERE. PLEASE REFER TO @The_Caretaker FOR QUESTIONS REGARDING THE PMAR/PMARP INDICATOR. THANK YOU!// THIS IS PMARP, AN INDiCATOR CREATED BY @THE_CARETAKER, I DO NOT TAKE CREDIT FOR ANY CODE WRITTEN ABOVE HERE. PLEASE REFER TO @The_Caretaker FOR QUESTIONS REGARDING THE PMAR/PMARP INDICATOR. THANK YOU!//    //    //    // THIS IS MADRID MOVING AVERAGE RIBBON, AN INDICATOR CREATED BY @Madrid. I DO NOT TAKE ANY CREDIT FOR THE SCRIPT BELOW UNTIL THE END OF THE INDICATOR IS STATED. FOR ANY QUESTIONS PLEASE REFER TO @Madrid REGARDING THE MADRID MOVING AVERAGE RIBBON INDICATOR, THANK YOU!    //// THIS IS MADRID MOVING AVERAGE RIBBON, AN INDICATOR CREATED BY @Madrid. I DO NOT TAKE ANY CREDIT FOR THE SCRIPT BELOW UNTIL THE END OF THE INDICATOR IS STATED. FOR ANY QUESTIONS PLEASE REFER TO @Madrid REGARDING THE MADRID MOVING AVERAGE RIBBON INDICATOR, THANK YOU!    //// THIS IS MADRID MOVING AVERAGE RIBBON, AN INDICATOR CREATED BY @Madrid. I DO NOT TAKE ANY CREDIT FOR THE SCRIPT BELOW UNTIL THE END OF THE INDICATOR IS STATED. FOR ANY QUESTIONS PLEASE REFER TO @Madrid REGARDING THE MADRID MOVING AVERAGE RIBBON INDICATOR, THANK YOU!// ╔══════════════════════════════════════════════════════════════════════════════╗// ║                                                                              ║// ║ © Madrid : 141017TH2251                                                      ║// ║                                                                              // ║ Rev. 210306SA1836 : Upgrade to Pinescript 4                                  ║// ║                                                                              ║// ║ Madrid Moving Average Ribbon                                                 ║// ║                                                                              ║// ║ This plots a moving average ribbon, either exponential or standard.          ║// ║ This study is best viewed with a dark background.  It provides an easy       ║// ║ and fast way to determine the trend direction and possible reversals.        ║// ║                                                                              ║// ║ Lime : Uptrend. Long trading                                                 ║// ║ Green : Reentry (buy the dip) or downtrend reversal warning                  ║// ║ Red : Downtrend. Short trading                                               ║// ║ Maroon : Short Reentry (sell the peak) or uptrend reversal warning           ║// ║                                                                              ║// ║ To best determine if this is a reentry point or a trend reversal             ║// ║ the MMARB (Madrid Moving Average Ribbon Bar) study is used.                  ║// ║ This is the bar located at the bottom.  This bar signals when a              ║// ║ current trend reentry is found (partially filled with opposite dark color)   ║// ║ or when a trend reversal is ahead (filled with the opposite color.           ║// ║                                                                              ║// ║ This source code is subject to the terms of the Mozilla Public License 2.0   ║// ║ at https://mozilla.org/MPL/2.0/                                              ║// ║                                                                              ║// ╚══════════════════════════════════════════════════════════════════════════════╝// ╔══════════════════════════════════════╗// ║                                      ║// ║            CONSTANTS                 ║// ║                                      ║// ╚══════════════════════════════════════╝PHI = (1 + math.sqrt(5)) / 2PI = 104348 / 33215BULL = 1BEAR = -1NONE = 0// ╔══════════════════════════════════════╗// ║                                      ║// ║            Colors                    ║// ║                                      ║// ╚══════════════════════════════════════╝// v3 Style GradientGRN01 = #7CFC00GRN02 = #32CD32GRN03 = #228B22GRN04 = #006400GRN05 = #008000GRN06 = #093507RED01 = #FF4500RED02 = #FF0000RED03 = #B22222RED04 = #8B0000RED05 = #800000RED06 = #330d06// ──────────[ v3 Style Colors ]AQUA = #00FFFFBLACK = #000000BLUE = #0000FFFUCHSIA = #FF00FFGRAY = #808080GREEN = #008000LIME = #00FF00MAROON = #800000NAVY = #000080OLIVE = #808000ORANGE = #FF7F00PURPLE = #800080RUBI = #FF0000SILVER = #C0C0C0TEAL = #008080YELLOW = #FFFF00WHITE = #FFFFFF// ╔══════════════════════════════════════╗// ║                                      ║// ║            functions ()              ║// ║                                      ║// ╚══════════════════════════════════════╝// ──────────[ Moving Average Color ]//  maColor(_ma, _maRef) =>    diffMA = ta.change(_ma)    macol = diffMA >= 0 and _ma > _maRef ? LIME : diffMA < 0 and _ma > _maRef ? MAROON : diffMA <= 0 and _ma < _maRef ? RUBI : diffMA >= 0 and _ma < _maRef ? GREEN : GRAY    macol// ╔══════════════════════════════════════════════════════════════════════════════╗// ║                                                                              ║// ║                                main ( )                                      ║// ║                                                                              ║// ╚══════════════════════════════════════════════════════════════════════════════╝// ────────────────────[ Input Parameters ]i_exp = input(true, title='Expnential MA')// ────────────────────[ Processing ]src = closema05 = i_exp ? ta.ema(src, 05) : ta.sma(src, 05)ma10 = i_exp ? ta.ema(src, 10) : ta.sma(src, 10)ma15 = i_exp ? ta.ema(src, 15) : ta.sma(src, 15)ma20 = i_exp ? ta.ema(src, 20) : ta.sma(src, 20)ma25 = i_exp ? ta.ema(src, 25) : ta.sma(src, 25)ma30 = i_exp ? ta.ema(src, 30) : ta.sma(src, 30)ma35 = i_exp ? ta.ema(src, 35) : ta.sma(src, 35)ma40 = i_exp ? ta.ema(src, 40) : ta.sma(src, 40)ma45 = i_exp ? ta.ema(src, 45) : ta.sma(src, 45)ma50 = i_exp ? ta.ema(src, 50) : ta.sma(src, 50)ma55 = i_exp ? ta.ema(src, 55) : ta.sma(src, 55)ma60 = i_exp ? ta.ema(src, 60) : ta.sma(src, 60)ma65 = i_exp ? ta.ema(src, 65) : ta.sma(src, 65)ma70 = i_exp ? ta.ema(src, 70) : ta.sma(src, 70)ma75 = i_exp ? ta.ema(src, 75) : ta.sma(src, 75)ma80 = i_exp ? ta.ema(src, 80) : ta.sma(src, 80)ma85 = i_exp ? ta.ema(src, 85) : ta.sma(src, 85)ma90 = i_exp ? ta.ema(src, 90) : ta.sma(src, 90)ma100 = i_exp ? ta.ema(src, 100) : ta.sma(src, 100)// ╔══════════════════════════════════════════════════════════════════════════════╗// ║                                                                              ║// ║                That's all Folks !                                            ║// ║                                                                              ║// ╚══════════════════════════════════════════════════════════════════════════════╝// THIS IS MADRID MOVING AVERAGE RIBBON, AN INDICATOR CREATED BY @Madrid. I DO NOT TAKE ANY CREDIT FOR THE SCRIPT ABOVE. FOR ANY QUESTIONS PLEASE REFER TO @Madrid REGARDING THE MADRID MOVING AVERAGE RIBBON INDICATOR, THANK YOU!    //// THIS IS MADRID MOVING AVERAGE RIBBON, AN INDICATOR CREATED BY @Madrid. I DO NOT TAKE ANY CREDIT FOR THE SCRIPT ABOVE. FOR ANY QUESTIONS PLEASE REFER TO @Madrid REGARDING THE MADRID MOVING AVERAGE RIBBON INDICATOR, THANK YOU!    //// THIS IS MADRID MOVING AVERAGE RIBBON, AN INDICATOR CREATED BY @Madrid. I DO NOT TAKE ANY CREDIT FOR THE SCRIPT ABOVE. FOR ANY QUESTIONS PLEASE REFER TO @Madrid REGARDING THE MADRID MOVING AVERAGE RIBBON INDICATOR, THANK YOU!//THE SCRIPT BELOW WAS COMPLETED BY @CHEATCODE1 (Myself) LET ME KNOW IF YOU GUYS WANT MORE COLLAB STRATEGIES AND SUBSCRIBE!! THANKS :)    ////THE SCRIPT BELOW WAS COMPLETED BY @CHEATCODE1 (Myself) LET ME KNOW IF YOU GUYS WANT MORE COLLAB STRATEGIES AND SUBSCRIBE!! THANKS :)    ////THE SCRIPT BELOW WAS COMPLETED BY @CHEATCODE1 (Myself) LET ME KNOW IF YOU GUYS WANT MORE COLLAB STRATEGIES AND SUBSCRIBE!! THANKS :)//Lime color conditions when truegreenMA_1 = ma05 > ma100greenMA_2 = ma10 > ma100greenMA_3 = ma15 > ma100greenMA_4 = ma20 > ma100 greenMA_5 = ma25 > ma100greenMA_6 = ma30 > ma100greenMA_7 = ma35 > ma100greenMA_8 = ma40 > ma100greenMA_9 = ma45 > ma100greenMA_10 = ma50 > ma100greenMA_11 = ma55 > ma100greenMA_12 = ma60 > ma100greenMA_13 = ma65 > ma100greenMA_14 = ma70 > ma100greenMA_15 = ma75 > ma100greenMA_16 = ma80 > ma100greenMA_17 = ma85 > ma100greenMA_18 = ma90 > ma100//Red color redMA_1 = ma05 < ma100redMA_2 = ma10 < ma100redMA_3 = ma15 < ma100redMA_4 = ma20 < ma100 redMA_5 = ma25 < ma100redMA_6 = ma30 < ma100redMA_7 = ma35 < ma100redMA_8 = ma40 < ma100redMA_9 = ma45 < ma100redMA_10 = ma50 < ma100redMA_11 = ma55 < ma100redMA_12 = ma60 < ma100redMA_13 = ma65 < ma100redMA_14 = ma70 < ma100redMA_15 = ma75 < ma100redMA_16 = ma80 < ma100redMA_17 = ma85 < ma100redMA_18 = ma90 < ma100// Difference of color Diffma1 = ta.change(ma05)Diffma2 = ta.change(ma10)Diffma3 = ta.change(ma15)Diffma4 = ta.change(ma20)Diffma5 = ta.change(ma25)Diffma6 = ta.change(ma30)Diffma7 = ta.change(ma35)Diffma8 = ta.change(ma40)Diffma9 = ta.change(ma45)Diffma10 = ta.change(ma50)Diffma11 = ta.change(ma55)Diffma12 = ta.change(ma60)Diffma13 = ta.change(ma65)Diffma14 = ta.change(ma70)Diffma15 = ta.change(ma75)Diffma16 = ta.change(ma80)Diffma17 = ta.change(ma85)Diffma18 = ta.change(ma90)//Positive difference valuesDiffma1P = ta.change(ma05) >= 0Diffma2P = ta.change(ma10) >= 0Diffma3P = ta.change(ma15) >= 0Diffma4P = ta.change(ma20) >= 0Diffma5P = ta.change(ma25) >= 0Diffma6P = ta.change(ma30) >= 0Diffma7P = ta.change(ma35) >= 0Diffma8P = ta.change(ma40) >= 0Diffma9P = ta.change(ma45) >= 0Diffma10P = ta.change(ma50) >= 0Diffma11P = ta.change(ma55) >= 0Diffma12P = ta.change(ma60) >= 0Diffma13P = ta.change(ma65) >= 0Diffma14P = ta.change(ma70) >= 0Diffma15P = ta.change(ma75) >= 0Diffma16P = ta.change(ma80) >= 0Diffma17P = ta.change(ma85) >= 0Diffma18P = ta.change(ma90) >= 0//Negative difference valuesDiffma1N = ta.change(ma05) < 0Diffma2N = ta.change(ma10) < 0Diffma3N = ta.change(ma15) < 0Diffma4N = ta.change(ma20) < 0Diffma5N = ta.change(ma25) < 0Diffma6N = ta.change(ma30) < 0Diffma7N = ta.change(ma35) < 0Diffma8N = ta.change(ma40) < 0Diffma9N = ta.change(ma45) < 0Diffma10N = ta.change(ma50) < 0Diffma11N = ta.change(ma55) < 0Diffma12N = ta.change(ma60) < 0Diffma13N = ta.change(ma65) < 0Diffma14N = ta.change(ma70) < 0Diffma15N = ta.change(ma75) < 0Diffma16N = ta.change(ma80) < 0Diffma17N = ta.change(ma85) < 0 Diffma18N = ta.change(ma90) < 0// Reverse enginnered color boolean'sLime1 = Diffma1P and greenMA_1Red1 = Diffma1N and redMA_1Maroon1 = Diffma1N and greenMA_1Green1 = Diffma1P and redMA_1Lime2 = Diffma2P and greenMA_2Red2 = Diffma2N and redMA_2Maroon2 = Diffma2N and greenMA_2Green2 = Diffma2P and redMA_2Lime3 = Diffma3P and greenMA_3Red3 = Diffma3N and redMA_3Maroon3 = Diffma3N and greenMA_3Green3 = Diffma3P and redMA_3Lime4 = Diffma4P and greenMA_4Red4 = Diffma4N and redMA_4Maroon4 = Diffma4N and greenMA_4Green4 = Diffma4P and redMA_4Lime5 = Diffma5P and greenMA_5Red5 = Diffma5N and redMA_5Maroon5 = Diffma5N and greenMA_5Green5 = Diffma5P and redMA_5Lime6 = Diffma6P and greenMA_6Red6 = Diffma6N and redMA_6Maroon6 = Diffma6N and greenMA_6Green6 = Diffma6P and redMA_6Lime7 = Diffma7P and greenMA_7Red7 = Diffma7N and redMA_7Maroon7 = Diffma7N and greenMA_7Green7 = Diffma7P and redMA_7Lime8 = Diffma8P and greenMA_8Red8 = Diffma8N and redMA_8Maroon8 = Diffma8N and greenMA_8Green8 = Diffma8P and redMA_8Lime9 = Diffma9P and greenMA_9Red9 = Diffma9N and redMA_9Maroon9 = Diffma9N and greenMA_9Green9 = Diffma9P and redMA_9Lime10 = Diffma10P and greenMA_10Red10 = Diffma10N and redMA_10Maroon10 = Diffma10N and greenMA_10Green10 = Diffma10P and redMA_10Lime11 = Diffma11P and greenMA_11Red11 = Diffma11N and redMA_11Maroon11 = Diffma11N and greenMA_11Green11 = Diffma11P and redMA_11Lime12 = Diffma12P and greenMA_12Red12 = Diffma12N and redMA_12Maroon12 = Diffma12N and greenMA_12Green12 = Diffma12P and redMA_12Lime13 = Diffma13P and greenMA_13Red13 = Diffma13N and redMA_13Maroon13 = Diffma13N and greenMA_13Green13 = Diffma13P and redMA_13Lime14 = Diffma14P and greenMA_14Red14 = Diffma14N and redMA_14Maroon14 = Diffma14N and greenMA_14Green14 = Diffma14P and redMA_14Lime15 = Diffma15P and greenMA_15Red15 = Diffma15N and redMA_15Maroon15 = Diffma15N and greenMA_15Green15 = Diffma15P and redMA_15Lime16 = Diffma16P and greenMA_16Red16 = Diffma16N and redMA_16Maroon16 = Diffma16N and greenMA_16Green16 = Diffma16P and redMA_16Lime17 = Diffma17P and greenMA_17Red17 = Diffma17N and redMA_17Maroon17 = Diffma17N and greenMA_17Green17 = Diffma17P and redMA_17Lime18 = Diffma18P and greenMA_18Red18 = Diffma18N and redMA_18Maroon18 = Diffma18N and greenMA_18Green18 = Diffma18P and redMA_18//combination of Lime/Red conditions when truelime_Long = Lime1 and Lime2 and Lime3 and Lime4 and Lime5 and Lime6 and Lime7 and Lime8 and Lime9 and Lime10 and Lime11 and Lime12 and Lime13 and Lime14 and Lime15 and Lime16 and Lime17 and Lime18red_Short = Red1 and Red2 and Red3 and Red4 and Red5 and Red6 and Red7 and Red8 and Red9 and Red10 and Red12 and Red12 and Red13 and Red14 and Red15 and Red16 and Red17 and Red18maroon_Short = Maroon1 and Maroon2 and Maroon3 and Maroon4 and Maroon5 and Maroon6 and Maroon7 and Maroon8 and Maroon9 and Maroon10 and Maroon11 and Maroon12 and Maroon13 and Maroon14 and Maroon15 and Maroon16 and Maroon17 and Maroon18green_Long = Green1 and Green2 and Green3 and Green4 and Green5 and Green6 and Green7 and Green8 and Green9 and Green10 and Green11 and Green12 and Green13 and Green14 and Green15 and Green16 and Green17 and Green18//rsistoch values /r= ta.rsi(close, 14)s = ta.stoch(close, 14,1,3)rP = r <= 55rM = r >= 75noREL = strategy.opentrades == 0 and strategy.position_size > 0noRES = strategy.opentrades == 0 and strategy.position_size < 0noENGL = close[1] > open[1] //Entry executionsif (lime_Long) and not (noREL) and not (noENGL) and not (rP)    strategy.entry("Long", strategy.long)if (red_Short) and not (noRES)    strategy.entry("Short", strategy.short)//Stop Loss/ Take Profit Variablesentry_index() =>    strategy.opentrades > 0 ? (bar_index - strategy.opentrades.entry_bar_index(strategy.closedtrades + 1)) : na    StopLoss() =>        if entry_index() != 0 and strategy.position_size > 0         low[1]    else if entry_index() != 0 and strategy.position_size < 0        high[1]     else        na//Exit excecutionsif strategy.position_size > 0 and pmarp >= 99 and red_Short == true    strategy.close("Long")if strategy.position_size < 0 and pmarp <= 01    strategy.close("Short")    // if strategy.position_size > 0 //     strategy.exit("Stop Loss", stop = StopLoss())// if strategy.position_size < 0//     strategy.exit("Stop Loss", stop = StopLoss())// Fixed percentiles for profit takingtakeP = input.float(1, title='Take Profit', group = 'Take Profit and Stop Loss') / 100stopL = input.float(27.75, title = 'Stop Loss', group = 'Take Profit and Stop Loss')/100// Pre DirectionalityStop_L = strategy.position_avg_price * (1 - stopL)Stop_S = strategy.position_avg_price * (1 + stopL)Take_S= strategy.position_avg_price * (1 - takeP)Take_L = strategy.position_avg_price * (1 + takeP)          //Post Excecutionif strategy.position_size > 0    strategy.exit("Close Long", limit=Take_L, stop = Stop_L)if strategy.position_size < 0    strategy.exit("Close Short", limit=Take_S, stop = Stop_S)    //Custom HLine RequestH1 = input.int( 75, 'Top Line', 51, 100, group = 'Top and Bottom Lines', inline = '1' )H2 = input.int( 20, 'Bottom Line', 0, 49, group = 'Top and Bottom Lines', inline = '1' )H3A = input.int(05, ' Transparancy of FIll', 1, 99, group = 'Top and Bottom Lines', inline = '1')H3B = 100 - H3AH1P = hline(H1, 'Top Line', #5BE14D, hline.style_dotted, 2, true )H2P = hline(H2, 'Bottom Line', #E14D60, hline.style_dotted, 2, true )fill(H1P, H2P, color.new(#E1CB5F,H3B), 'Line fills', editable = true )