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
- 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.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Main Properties | |||
| Price source | close | source | ma pmar pmarp |
| Indicator.... | s_pmarp | string · options [ s_pmar, s_pmarp ] | pmarpOn |
| PMAR length | 20 | int · min 1 | ma pmarp |
| MA type... | VWMA | string · options [ 'SMA', 'EMA', 'HMA', 'RMA', 'VWMA' ] | ma pmarp |
| Line plot settings | |||
| Color type | Spectrum | string · options [ 'Spectrum', 'Solid' ] | c_plotline c_hi_alert c_lo_alert c_bg Historical PMAR high |
| Spectrum | s_BGR | string · options [ s_BR, s_BGR ] | c_plotline c_bg Historical PMAR high |
| Solid color | #FFFF00 | color | c_plotline c_bg Historical PMAR high |
| Line width | 1 | int · min 1 · max 4 | Plot line Historical PMAR high |
| Lookback | 350 | int · min 1 · max 1900 | pmarp |
| Signal MA Settings | |||
| Signal MA | true | bool | Signal line |
| MA length | 20 | int · min 1 | signal_ma |
| MA type | SMA | string · options [ 'SMA', 'EMA', 'HMA', 'RMA', 'VWMA' ] | signal_ma |
| Color type | Solid | string · options [ 'Spectrum', 'Solid' ] | c_plotsig |
| Spectrum | s_BGR | string · options [ s_BR, s_BGR ] | c_plotsig c_hi_alert c_lo_alert |
| Solid color | color.white | color | c_plotsig c_hi_alert c_lo_alert |
| Line width | 1 | int · min 1 · max 4 | Signal line |
| Visual Alert Level Settings | |||
| Hi PMARP alert level | 99 | float · min 0.1 · max 100 · step 0.01 | hi_alert hi_alertc High alert level |
| Lo PMARP alert level | 1 | float · min 0.1 · max 100 · step 0.01 | lo_alert Low alert level |
| Hi PMAR alert level. | 2.7 | float · min 0.1 · max 100 · step 0.01 | hi_alert hi_alertc High alert level |
| Lo PMAR alert level. | 0.7 | float · min 0.1 · max 100 · step 0.01 | lo_alert Low alert level |
| Hi alert line. | true | bool | High alert level bgcolor |
| Lo alert line. | true | bool | Low alert level bgcolor |
| Hi signal bars | true | bool | bgcolor |
| Lo signal bars | true | bool | bgcolor |
| Expnential MA | true | bool | ma05 ma10 ma15 ma20 ma25 ma30 ma35 ma40 ma45 ma50 ma55 ma60 ma65 ma70 ma75 ma80 ma85 ma90 ma100 |
| Take Profit and Stop Loss | |||
| Take Profit | 1 | float | Take_S Take_L |
| Stop Loss | 27.75 | float | Stop_L Stop_S |
| Top and Bottom Lines | |||
| Top Line | 75 | int | H1P hline |
| Bottom Line | 20 | int | H2P hline |
| Transparancy of FIll | 05 | int | H3B |
What it calculates
- Change_ma
diffMA · line 244 - EMA / SMAsrc, 05
ma05 · line 256 - EMA / SMAsrc, 10
ma10 · line 257 - EMA / SMAsrc, 15
ma15 · line 258 - EMA / SMAsrc, 20
ma20 · line 259 - EMA / SMAsrc, 25
ma25 · line 260 - EMA / SMAsrc, 30
ma30 · line 261 - EMA / SMAsrc, 35
ma35 · line 262 - EMA / SMAsrc, 40
ma40 · line 263 - EMA / SMAsrc, 45
ma45 · line 264 - EMA / SMAsrc, 50
ma50 · line 265 - EMA / SMAsrc, 55
ma55 · line 266 - EMA / SMAsrc, 60
ma60 · line 267 - EMA / SMAsrc, 65
ma65 · line 268 - EMA / SMAsrc, 70
ma70 · line 269 - EMA / SMAsrc, 75
ma75 · line 270 - EMA / SMAsrc, 80
ma80 · line 271 - EMA / SMAsrc, 85
ma85 · line 272 - EMA / SMAsrc, 90
ma90 · line 273 - EMA / SMAsrc, 100
ma100 · line 274 - Changema05
Diffma1 · line 329 - Changema10
Diffma2 · line 330 - Changema15
Diffma3 · line 331 - Changema20
Diffma4 · line 332 - Changema25
Diffma5 · line 333 - Changema30
Diffma6 · line 334 - Changema35
Diffma7 · line 335 - Changema40
Diffma8 · line 336 - Changema45
Diffma9 · line 337 - Changema50
Diffma10 · line 338 - Changema55
Diffma11 · line 339 - Changema60
Diffma12 · line 340 - Changema65
Diffma13 · line 341 - Changema70
Diffma14 · line 342 - Changema75
Diffma15 · line 343 - Changema80
Diffma16 · line 344 - Changema85
Diffma17 · line 345 - Changema90
Diffma18 · line 346 - RSIclose, 14
r · line 464 - Stochclose, 14, 1, 3
s · 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
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open Long long | (lime_Long) and not (noREL) and not (noENGL) and not (rP) | On | 473 |
| Open Short short | (red_Short) and not (noRES) | On | 475 |
| Close Long | strategy.position_size > 0 and pmarp >= 99 and red_Short == true | On | 489 |
| Close Short | strategy.position_size < 0 and pmarp <= 01 | On | 491 |
| Exit Close Long stop and limit | strategy.position_size > 0 | On | 509 |
| Exit Close Short stop and limit | strategy.position_size < 0 | On | 511 |
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.
- 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.
| Market | Net | Buy and hold | Trades | Won | Profit factor | Max drawdown | Period |
|---|---|---|---|---|---|---|---|
| BTCUSDT 1D | −3.0% | +102.5% | 72 | 93% | 0.98 | 45.4% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | +6.7% | +5.5% | 45 | 87% | 1.17 | 24.7% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | −27.1% | +9.8% | 75 | 91% | 0.86 | 92.6% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | +43.2% | +8.4% | 60 | 97% | 2.83 | 14.7% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | −63.1% | +16.7% | 86 | 90% | 0.74 | 135.6% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | +23.1% | +21.5% | 64 | 94% | 1.40 | 26.6% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | −14.0% | +148.3% | 66 | 92% | 0.89 | 82.4% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | −14.3% | +17.1% | 35 | 89% | 0.72 | 40.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 bars | Trades | Won | P&L |
|---|---|---|---|
| Rising market | 20 | 100% | $391.08 |
| Sideways market | 23 | 83% | −$799.29 |
| Falling market | 29 | 97% | $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.
All 72 trades
| Side | Entry | Exit | Bars | P&L |
|---|---|---|---|---|
| long | 16 May 2024 66,206.50 | 17 May 2024 66,868.60 | 1 | $10.00 |
| long | 18 May 2024 67,024.00 | 19 May 2024 67,694.20 | 1 | $10.00 |
| long | 20 May 2024 66,274.00 | 21 May 2024 71,446.60 | 1 | $78.05 |
| long | 23 May 2024 69,166.60 | 27 May 2024 69,858.30 | 4 | $10.00 |
| long | 28 May 2024 69,436.40 | 3 Jun 2024 70,130.80 | 6 | $10.00 |
| long | 4 Jun 2024 68,809.90 | 5 Jun 2024 70,537.80 | 1 | $25.11 |
| long | 29 Jul 2024 68,249.90 | 5 Aug 2024 49,310.50 | 7 | −$277.50 |
| short | 15 Aug 2024 58,683.40 | 16 Aug 2024 57,541.10 | 1 | $19.47 |
| short | 19 Aug 2024 58,427.30 | 30 Aug 2024 57,843.10 | 11 | $10.00 |
| short | 31 Aug 2024 59,124.00 | 1 Sep 2024 58,532.80 | 1 | $10.00 |
| short | 2 Sep 2024 57,301.80 | 4 Sep 2024 56,728.80 | 2 | $10.00 |
| short | 5 Sep 2024 57,970.90 | 6 Sep 2024 56,180.00 | 1 | $30.89 |
| short | 7 Sep 2024 53,963.00 | 18 Oct 2024 68,937.70 | 41 | −$277.50 |
| long | 19 Oct 2024 68,428.00 | 20 Oct 2024 69,112.30 | 1 | $10.00 |
| long | 21 Oct 2024 69,032.00 | 28 Oct 2024 69,722.30 | 7 | $10.00 |
| long | 6 Nov 2024 69,372.00 | 7 Nov 2024 75,572.00 | 1 | $89.37 |
| long | 14 Nov 2024 90,375.20 | 15 Nov 2024 91,279.00 | 1 | $10.00 |
| long | 16 Nov 2024 91,032.10 | 18 Nov 2024 91,942.40 | 2 | $10.00 |
| long | 19 Nov 2024 90,464.10 | 20 Nov 2024 92,310.80 | 1 | $20.41 |
| long | 25 Nov 2024 97,900.10 | 4 Dec 2024 98,879.10 | 9 | $10.00 |
| long | 7 Dec 2024 99,740.80 | 8 Dec 2024 100,738.00 | 1 | $10.00 |
| long | 12 Dec 2024 101,125.00 | 14 Dec 2024 102,136.00 | 2 | $10.00 |
| long | 16 Dec 2024 104,464.00 | 17 Dec 2024 106,059.00 | 1 | $15.27 |
| long | 18 Jan 2025 104,077.00 | 19 Jan 2025 105,118.00 | 1 | $10.00 |
| long | 21 Jan 2025 102,260.00 | 22 Jan 2025 106,144.00 | 1 | $37.98 |
| long | 24 Jan 2025 103,910.00 | 25 Jan 2025 104,949.00 | 1 | $10.00 |
| long | 30 Jan 2025 103,733.00 | 31 Jan 2025 104,771.00 | 1 | $10.00 |
| short | 6 Apr 2025 83,538.00 | 7 Apr 2025 78,430.00 | 1 | $61.15 |
| short | 8 Apr 2025 79,163.20 | 9 Apr 2025 76,322.40 | 1 | $35.89 |
| short | 11 Apr 2025 79,607.30 | 8 May 2025 101,698.00 | 27 | −$277.50 |
| long | 11 May 2025 104,810.00 | 18 May 2025 105,858.00 | 7 | $10.00 |
| long | 19 May 2025 106,454.00 | 21 May 2025 107,519.00 | 2 | $10.00 |
| long | 28 Jun 2025 107,048.00 | 29 Jun 2025 108,118.00 | 1 | $10.00 |
| long | 3 Jul 2025 108,850.00 | 9 Jul 2025 109,938.00 | 6 | $10.00 |
| long | 14 Jul 2025 119,087.00 | 17 Jul 2025 120,278.00 | 3 | $10.00 |
| long | 11 Aug 2025 119,294.00 | 13 Aug 2025 120,487.00 | 2 | $10.00 |
| long | 15 Sep 2025 115,268.00 | 16 Sep 2025 116,421.00 | 1 | $10.00 |
| long | 19 Sep 2025 117,074.00 | 1 Oct 2025 118,244.00 | 12 | $10.00 |
| long | 2 Oct 2025 118,595.00 | 3 Oct 2025 120,529.00 | 1 | $16.31 |
| long | 9 Oct 2025 123,306.00 | 14 Nov 2025 99,692.00 | 36 | −$191.51 |
| short | 14 Nov 2025 99,692.00 | 15 Nov 2025 94,594.00 limit | 1 | $51.14 |
| short | 16 Nov 2025 95,596.20 | 17 Nov 2025 94,261.40 | 1 | $13.96 |
| short | 18 Nov 2025 92,215.10 | 19 Nov 2025 91,293.00 | 1 | $10.00 |
| short | 20 Nov 2025 91,555.00 | 21 Nov 2025 86,637.20 limit | 1 | $53.71 |
| short | 22 Nov 2025 85,129.40 | 23 Nov 2025 84,739.80 limit | 1 | $4.58 |
| short | 24 Nov 2025 86,830.00 | 1 Dec 2025 85,961.70 | 7 | $10.00 |
| short | 2 Dec 2025 86,286.00 | 15 Dec 2025 85,423.10 | 13 | $10.00 |
| short | 16 Dec 2025 86,432.10 | 17 Dec 2025 85,567.80 | 1 | $10.00 |
| short | 18 Dec 2025 86,243.20 | 19 Dec 2025 85,380.80 | 1 | $10.00 |
| short | 24 Dec 2025 87,486.00 | 25 Jan 2026 86,611.10 | 32 | $10.00 |
| short | 26 Jan 2026 86,670.40 | 29 Jan 2026 85,803.60 | 3 | $10.00 |
| short | 30 Jan 2026 84,650.20 | 31 Jan 2026 83,803.60 | 1 | $10.00 |
| short | 1 Feb 2026 78,741.10 | 2 Feb 2026 76,968.20 limit | 1 | $22.52 |
| short | 3 Feb 2026 78,738.60 | 4 Feb 2026 75,770.20 | 1 | $37.70 |
| short | 5 Feb 2026 73,165.80 | 6 Feb 2026 62,909.90 limit | 1 | $140.17 |
| short | 7 Feb 2026 70,580.30 | 8 Feb 2026 69,289.40 | 1 | $18.29 |
| short | 9 Feb 2026 70,330.40 | 10 Feb 2026 69,627.10 | 1 | $10.00 |
| short | 11 Feb 2026 68,841.30 | 12 Feb 2026 67,082.50 | 1 | $25.55 |
| short | 13 Feb 2026 66,272.20 | 23 Feb 2026 65,609.40 | 10 | $10.00 |
| short | 24 Feb 2026 64,656.00 | 25 Feb 2026 64,009.40 | 1 | $10.00 |
| short | 28 Feb 2026 65,872.10 | 1 Mar 2026 65,213.40 | 1 | $10.00 |
| short | 2 Mar 2026 65,776.50 | 29 Mar 2026 65,118.70 | 27 | $10.00 |
| short | 30 Mar 2026 66,010.90 | 3 Jun 2026 65,350.80 | 65 | $10.00 |
| short | 4 Jun 2026 64,142.80 | 5 Jun 2026 63,501.30 | 1 | $10.00 |
| short | 6 Jun 2026 61,056.50 | 7 Jun 2026 60,884.60 limit | 1 | $2.81 |
| short | 8 Jun 2026 63,332.00 | 9 Jun 2026 62,698.70 | 1 | $10.00 |
| short | 10 Jun 2026 61,730.00 | 24 Jun 2026 61,112.70 | 14 | $10.00 |
| short | 25 Jun 2026 61,078.00 | 26 Jun 2026 59,794.60 | 1 | $21.01 |
| short | 27 Jun 2026 60,097.30 | 28 Jun 2026 59,496.30 | 1 | $10.00 |
| short | 29 Jun 2026 59,577.00 | 30 Jun 2026 58,981.20 | 1 | $10.00 |
| short | 1 Jul 2026 58,624.70 | 21 Aug 2026 74,893.10 | 51 | −$277.50 |
| long | 6 Sep 2026 79,831.80 | 18 Sep 2026 80,630.10 | 12 | $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.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| Bitcoin Scalping Strategy (Sampled with- PMARP+MADRID MA RIBBON) this page | — | v5 strategy | −3.0% | 72 | 45.4% |
| RSI Mean Reversion Bot Strategy by Solutions1978 | rsi ema stoch sma | v4 strategy | No trades on this market | ||
| MACD, RSI, & RVOL Strategy by BobBarker42069 | rsi ema sma | v4 strategy | +32.6% | 1 | 1.5% |
| IFR2 - RSI2 by jocker.soad | rsi sma ema | v4 strategy | No trades on this market | ||
| Vin's Playzone Strategy by Vvaz_ | ema rsi sma | v5 strategy | −908.1% | 21 | 3,570.5% |
| Stoch-RSI 4h-1h-15min by MoonFlag | ema rsi sma stoch | v4 strategy | No 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.
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.
⋯// © 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
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 195 ms | Yes 1,000 bars in 514 ms | Not measured |
| PineTS | Not tested | Not tested | Not measured |
“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report.
Source
Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © 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 )