Zeal Terminal Open in Zeal Terminal

Pine Script v4 · Strategy

MACD 5 iN 1 [Pro-Tool]

A Pine Script v4 strategy built on SMA or EMA (close, 12), Crossover (MACD, Signal) and Crossunder (MACD, Signal). It has 11 order rules, 5 entries among them, and trades long only with the default settings. Exits wait for a signal; there is no stop loss. Each trade commits 100 in cash and pays 0.1 commission. 49 settings; defaults include MACD Fast 12, MACD Slow 26 and Signal Line 9.

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 MACD 5 iN 1 [Pro-Tool] repaint?
No
No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
How did MACD 5 iN 1 [Pro-Tool] do on BTCUSDT 1D with default settings?
Not measured
It closed no trades there from 26 Jan 2024 to 21 Oct 2026 with the default settings, so there is no result to report. Its code limits trading to a date window, which can leave this period out. It closed no trades on the other markets either. A backtest, not investment advice.
Can MACD 5 iN 1 [Pro-Tool] be converted to Pine Script v5?
Not tested
The steps are shown below, but neither version placed a trade on any market tested, so there was nothing to compare and no download is offered.
Does MACD 5 iN 1 [Pro-Tool] use a stop loss?
No
Every exit waits for a signal; nothing limits a losing trade before it fires.
Does MACD 5 iN 1 [Pro-Tool] run in Zeal Terminal?
Yes
It compiles in 73 ms and runs 1,000 bars in 257 ms, in the browser.

BTCUSDT · 1D · default settings

  • MACD OB
  • Histogram
  • MACD
  • Signal
  • c-over
  • c-under
  • Regular Bullish
  • Hidden Bullish
  • Regular Bearish
  • Hidden Bearish
  • Winning trade
  • Losing trade
  • Equity
  • Buy and hold
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (37)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOctMACD OB$100$203Equity from $100
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Triangles mark entries; circles mark exits. Lines are what the script plots.
Net profit
0.00%
$0.00
Buy and hold
+102.5%
same period
Closed trades
0
0 won · 0 lost
Profitable
0.0%
of closed trades
Profit factor
—
gross profit ÷ gross loss
Max drawdown
0.00%
$0.00

One run with the author's default settings, $100 starting capital, commission as the script sets it. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.

Review

What a careful reader of this script would point out, found by checking the source and the backtest.

  • Likely bug

    ema(close, MA_signal_len) ignores the settings line 53

    Line 53 hard-codes close where line 28 uses “Source ”. Changing those settings moves one band but not this one.

    ema(close , MA_signal_len)ema(macd_Source, MA_signal_len)
  • Likely bug

    ema(close, MA_signal_len) ignores the settings line 56

    Line 56 hard-codes close where line 28 uses “Source ”. Changing those settings moves one band but not this one.

    ema(close , MA_signal_len)ema(macd_Source, MA_signal_len)
  • Likely bug

    ema(close, MA_zone_len) ignores the settings line 64

    Line 64 hard-codes close where line 28 uses “Source ”. Changing those settings moves one band but not this one.

    ema(close , MA_zone_len)ema(macd_Source, MA_zone_len)
  • Likely bug

    ema(close, MA_zone_len) ignores the settings line 67

    Line 67 hard-codes close where line 28 uses “Source ”. Changing those settings moves one band but not this one.

    ema(close , MA_zone_len)ema(macd_Source, MA_zone_len)
  • Check

    No stop loss

    Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.

  • Note

    6 settings have no label

    In the settings dialog MACD_OB_LVL (line 46), MA_signal_len (line 50), MA_signal_type (line 51), MA_zone_len (line 61), MA_zone_type (line 62), macd_cross_width (line 175) show an empty name. The labels on this page come from the variable names.

  • Note

    No slippage

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

  • Note

    Uses transp =, which v5 removed line 247

    transp = on line 247, 255, 273, 281, 302, 310, 328, 336. v5 folds the transparency into the colour with color.new(c, transp).

Upgrade and export

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

  • Upgrading to v5 renames ema → ta.ema, sma → ta.sma, rma → ta.rma, wma → ta.wma, vwma → ta.vwma, crossover → ta.crossover, crossunder → ta.crossunder, rsi → ta.rsi, pivotlow → ta.pivotlow, pivothigh → ta.pivothigh, barssince → ta.barssince, valuewhen → ta.valuewhen, highest → ta.highest, lowest → ta.lowest.

v4 → v5

Not verified

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

  • Line 3: //@version=4 → //@version=5
  • Line 5: type is reserved in v5: renamed type_
  • Line 6: ema → ta.ema
  • Line 7: sma → ta.sma
  • Line 8: rma → ta.rma
  • Line 9: wma → ta.wma
85 more edits
  • Line 10: vwma → ta.vwma
  • Line 13: ema → ta.ema
  • Line 14: sma → ta.sma
  • Line 15: rma → ta.rma
  • Line 16: wma → ta.wma
  • Line 17: vwma → ta.vwma
  • Line 20: input(type = input.integer) → input.int()
  • Line 21: input(type = input.integer) → input.int()
  • Line 22: input(type = input.integer) → input.int()
  • Line 23: input(type = input.source) → input.source()
  • Line 24: input(type = input.string) → input.string()
  • Line 25: input(type = input.string) → input.string()
  • Line 28: sma → ta.sma
  • Line 28: ema → ta.ema
  • Line 29: sma → ta.sma
  • Line 29: ema → ta.ema
  • Line 31: sma → ta.sma
  • Line 31: ema → ta.ema
  • Line 37: crossover → ta.crossover
  • Line 38: crossunder → ta.crossunder
  • Line 39: crossover → ta.crossover
  • Line 40: crossunder → ta.crossunder
  • Line 46: input(type = input.float) → input.float()
  • Line 50: input(type = input.integer) → input.int()
  • Line 53: ema → ta.ema
  • Line 54: ema → ta.ema
  • Line 56: ema → ta.ema
  • Line 57: ema → ta.ema
  • Line 57: ema → ta.ema
  • Line 57: ema → ta.ema
  • Line 61: input(type = input.integer) → input.int()
  • Line 64: ema → ta.ema
  • Line 65: ema → ta.ema
  • Line 67: ema → ta.ema
  • Line 68: ema → ta.ema
  • Line 68: ema → ta.ema
  • Line 68: ema → ta.ema
  • Line 73: input(type = input.integer) → input.int()
  • Line 74: input(type = input.integer) → input.int()
  • Line 75: input(type = input.integer) → input.int()
  • Line 76: rsi → ta.rsi
  • Line 79: input(type = input.time) → input.time()
  • Line 80: input(type = input.time) → input.time()
  • Line 144: crossunder → ta.crossunder
  • Line 144: crossunder → ta.crossunder
  • Line 144: crossunder → ta.crossunder
  • Line 144: crossunder → ta.crossunder
  • Line 144: crossunder → ta.crossunder
  • Line 144: crossunder → ta.crossunder
  • Line 144: crossunder → ta.crossunder
  • Line 159: input(type = input.integer) → input.int()
  • Line 160: input(type = input.color) → input.color()
  • Line 161: input(type = input.color) → input.color()
  • Line 162: input(type = input.integer) → input.int()
  • Line 163: input(type = input.color) → input.color()
  • Line 164: input(type = input.color) → input.color()
  • Line 167: input(type = input.color) → input.color()
  • Line 168: input(type = input.color) → input.color()
  • Line 169: input(type = input.color) → input.color()
  • Line 170: input(type = input.color) → input.color()
  • Line 176: input(type = input.color) → input.color()
  • Line 177: input(type = input.color) → input.color()
  • Line 180: input(type = input.color) → input.color()
  • Line 181: input(type = input.color) → input.color()
  • Line 231: pivotlow → ta.pivotlow
  • Line 232: pivothigh → ta.pivothigh
  • Line 234: barssince → ta.barssince
  • Line 239: valuewhen → ta.valuewhen
  • Line 241: valuewhen → ta.valuewhen
  • Line 242: highest → ta.highest
  • Line 247: transp = 0 → color.new((bullCond ? bullColor : noneColor), 0)
  • Line 255: transp = 0 → color.new(bullColor, 0)
  • Line 269: valuewhen → ta.valuewhen
  • Line 271: valuewhen → ta.valuewhen
  • Line 273: transp = 0 → color.new((hiddenBullCond ? hiddenBullColor : noneColor), 0)
  • Line 281: transp = 0 → color.new(bullColor, 0)
  • Line 295: valuewhen → ta.valuewhen
  • Line 296: lowest → ta.lowest
  • Line 300: valuewhen → ta.valuewhen
  • Line 302: transp = 0 → color.new((bearCond ? bearColor : noneColor), 0)
  • Line 310: transp = 0 → color.new(bearColor, 0)
  • Line 324: valuewhen → ta.valuewhen
  • Line 326: valuewhen → ta.valuewhen
  • Line 328: transp = 0 → color.new((hiddenBearCond ? hiddenBearColor : noneColor), 0)
  • Line 336: transp = 0 → color.new(bearColor, 0)
⋯// © HamidBox-//@version=4+//@version=5strategy("MACD [5-in-1] V2", default_qty_type=strategy.cash, default_qty_value=100, initial_capital=100, currency='USD', commission_value=0.1)-matype_zone(src, len, type) =>+matype_zone(src, len, type_) =>-    type == "EMA" ? ema(src, len) :+    type_ == "EMA" ? ta.ema(src, len) :-     type == "SMA" ? sma(src, len) :+     type_ == "SMA" ? ta.sma(src, len) :-     type == "RMA" ? rma(src, len) : +     type_ == "RMA" ? ta.rma(src, len) : -     type == "WMA" ? wma(src, len) : +     type_ == "WMA" ? ta.wma(src, len) : -     type == "VWMA" ? vwma(src, len) :+     type_ == "VWMA" ? ta.vwma(src, len) :     na-matype_signal(src, len, type) =>+matype_signal(src, len, type_) =>-    type == "EMA" ? ema(src, len) :+    type_ == "EMA" ? ta.ema(src, len) :-     type == "SMA" ? sma(src, len) :+     type_ == "SMA" ? ta.sma(src, len) :-     type == "RMA" ? rma(src, len) : +     type_ == "RMA" ? ta.rma(src, len) : -     type == "WMA" ? wma(src, len) : +     type_ == "WMA" ? ta.wma(src, len) : -     type == "VWMA" ? vwma(src, len) :+     type_ == "VWMA" ? ta.vwma(src, len) :     na// MACD INPUTS ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////-macd_FastLength     = input(title="MACD Fast", defval=12, minval=1, type=input.integer, inline="fastslow")                      ///+macd_FastLength     = input.int(title="MACD Fast", defval=12, minval=1, inline="fastslow")                      ///-macd_SlowLength     = input(title="MACD Slow ", defval=26, minval=1, type=input.integer, inline="fastslow")                     ///+macd_SlowLength     = input.int(title="MACD Slow ", defval=26, minval=1, inline="fastslow")                     ///-macd_signalLen      = input(title="Signal Line", defval=9, minval=1, type=input.integer, inline="signalsrc")                    ///+macd_signalLen      = input.int(title="Signal Line", defval=9, minval=1, inline="signalsrc")                    ///-macd_Source         = input(title="Source      ", defval=close, type=input.source, inline="signalsrc")                          ///+macd_Source         = input.source(title="Source      ", defval=close, inline="signalsrc")                          ///-MACD_Line           = input(title="Oscilattor ", defval="EMA", type=input.string, options=["EMA" , "SMA"], inline="matype")     ///+MACD_Line           = input.string(title="Oscilattor ", defval="EMA", options=["EMA" , "SMA"], inline="matype")     ///-SignalLine          = input(title="Signal       ", defval="EMA", type=input.string, options=["EMA" , "SMA"], inline="matype")   ///+SignalLine          = input.string(title="Signal       ", defval="EMA", options=["EMA" , "SMA"], inline="matype")   ///                                                                                                                                ///// MACD SETUP /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////-macd_Fast           = MACD_Line == "SMA" ? sma(macd_Source , macd_FastLength) : ema(macd_Source , macd_FastLength)      ///+macd_Fast           = MACD_Line == "SMA" ? ta.sma(macd_Source , macd_FastLength) : ta.ema(macd_Source , macd_FastLength)      ///-macd_Slow           = MACD_Line == "SMA" ? sma(macd_Source , macd_SlowLength) : ema(macd_Source , macd_SlowLength)      ///+macd_Slow           = MACD_Line == "SMA" ? ta.sma(macd_Source , macd_SlowLength) : ta.ema(macd_Source , macd_SlowLength)      ///MACD                = macd_Fast - macd_Slow                                                                             ///-Signal              = SignalLine == "SMA" ? sma(MACD, macd_signalLen) : ema(MACD, macd_signalLen)                       ///+Signal              = SignalLine == "SMA" ? ta.sma(MACD, macd_signalLen) : ta.ema(MACD, macd_signalLen)                       ///histogram           = MACD - Signal                                                                                     ///⋯macd_less_signal    = MACD < Signal                                           //-macd_crsovr_signal  = crossover(MACD , Signal) ? MACD : na      // FOR MACD CROSS DOT PLOTING //+macd_crsovr_signal  = ta.crossover(MACD , Signal) ? MACD : na      // FOR MACD CROSS DOT PLOTING //-macd_crsndr_signal  = crossunder(MACD , Signal) ? MACD : na     // FOR MACD CROSS DOT PLOTING //                 +macd_crsndr_signal  = ta.crossunder(MACD , Signal) ? MACD : na     // FOR MACD CROSS DOT PLOTING //                 -macd_crsovr         = crossover(MACD , Signal)                                //+macd_crsovr         = ta.crossover(MACD , Signal)                                //-macd_crsndr         = crossunder(MACD , Signal)                               //+macd_crsndr         = ta.crossunder(MACD , Signal)                               //////////////////////////////////////////////////////////////////////////////////⋯MACD_OB             = input(false, "Stgy №2:👉 MACD + OverBought ", inline="obs", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="MACD also work as OverBought & OverSold system, same like RSI or other indicators who have OB/OS system, so i added OB-Level in MACD,\nso simple rule is: if MACD Lines is Above OB-Level, we will not take any trade, we only follow MACD signals when MACD-Lines will Below OB-Level")-MACD_OB_LVL         = input(title="", defval=0.0, type=input.float, inline="obs", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="MACD also work as OverBought & OverSold system, same like RSI or other indicators who have OB/OS system, so i added OB-Level in MACD,\nso simple rule is: if MACD Lines is Above OB-Level, we will not take any trade, we only follow MACD signals when MACD-Lines will Below OB-Level") +MACD_OB_LVL         = input.float(title="", defval=0.0, inline="obs", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="MACD also work as OverBought & OverSold system, same like RSI or other indicators who have OB/OS system, so i added OB-Level in MACD,\nso simple rule is: if MACD Lines is Above OB-Level, we will not take any trade, we only follow MACD signals when MACD-Lines will Below OB-Level") hline(MACD_OB_LVL, color=color.red, title="MACD OB", linestyle=hline.style_dashed)⋯MACD_close          = input(false, "Stgy №3:👉 MACD + Close         ", inline="MAsignal", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="🚦🚦🚦 Condition 🚦🚦🚦\n\nBUY RULES\n1st: MACD CrossOver Signal Line\n2nd: Close (Greater) Than Moving Average\n\nSELL RULES\n1st: MACD CrossUnder Signal Line\n2nd: Close (Less) Than Moving Average\n\nExplanation: When (MACD Cross Signal Line) and also Market current Candle Close or previous 1st-4th any Candle will have close greater than Moving Average (You Choose: EMA or SMA etc...)\n🚦NOTE: in this Condition only Singal Moving Average work => (Slow MA),")-MA_signal_len       = input(title="", defval=21, type=input.integer, inline="MAsignal", group="CHOOSE YOUR DESIRE SIGNAL")    //      // +MA_signal_len       = input.int(title="", defval=21, inline="MAsignal", group="CHOOSE YOUR DESIRE SIGNAL")    //      // MA_signal_type      = input(title="", defval="EMA", options=["SMA" , "EMA" , "RMA", "WMA" , "VWMA" , "DEMA", "TEMA"], inline="MAsignal", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="🚦🚦🚦 Condition 🚦🚦🚦\n\nBUY RULES\n1st: MACD CrossOver Signal Line\n2nd: Close (Greater) Than Moving Average\n\nSELL RULES\n1st: MACD CrossUnder Signal Line\n2nd: Close (Less) Than Moving Average\n\nExplanation: When (MACD Cross Signal Line) and also Market current Candle Close will have close greater than Moving Average (You Choose: EMA or SMA etc...)")     //      //dema = if MA_signal_type == "DEMA"-    ema = ema(close , MA_signal_len)+    ema = ta.ema(close , MA_signal_len)-    2 * ema - ema(ema , MA_signal_len)+    2 * ema - ta.ema(ema , MA_signal_len)tema = if MA_signal_type == "TEMA"-    ema = ema(close , MA_signal_len)+    ema = ta.ema(close , MA_signal_len)-    3 * (ema - ema(ema, MA_signal_len)) + ema(ema(ema, MA_signal_len), MA_signal_len)+    3 * (ema - ta.ema(ema, MA_signal_len)) + ta.ema(ta.ema(ema, MA_signal_len), MA_signal_len)MA_signal           = matype_zone(close, MA_signal_len, MA_signal_type)⋯MACD_ZONE           = input(false, "Stgy №4:👉 MACD + MA-ZONE    ", inline="MAZONE", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="🚦🚦🚦 Condition 🚦🚦🚦\n\nBUY RULES:\n1st: MACD CrossOver Signal Line\n2nd: Close (Greater) than (MA-ZONE)\n\nSELL RULES:\n1st: MACD CrossUnder Signal Line\n2nd: Close (Less) than (MA-ZONE)")-MA_zone_len         = input(title="", defval=21, type=input.integer, inline="MAZONE", group="CHOOSE YOUR DESIRE SIGNAL")+MA_zone_len         = input.int(title="", defval=21, inline="MAZONE", group="CHOOSE YOUR DESIRE SIGNAL")MA_zone_type        = input(title="", defval="EMA", options=["SMA" , "EMA" , "RMA", "WMA" , "VWMA" , "DEMA", "TEMA"], inline="MAZONE", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="🚦🚦🚦 Condition 🚦🚦🚦\n\nBUY RULES:\n1st: MACD CrossOver Signal Line\n2nd: Close (Greater) than (MA-ZONE)\n\nSELL RULES:\n1st: MACD CrossUnder Signal Line\n2nd: Close (Less) than (MA-ZONE)")dema2 = if MA_zone_type == "DEMA"-    ema = ema(close , MA_zone_len)+    ema = ta.ema(close , MA_zone_len)-    2 * ema - ema(ema , MA_zone_len)+    2 * ema - ta.ema(ema , MA_zone_len)tema2 = if MA_zone_type == "TEMA"-    ema = ema(close , MA_zone_len)+    ema = ta.ema(close , MA_zone_len)-    3 * (ema - ema(ema, MA_zone_len)) + ema(ema(ema, MA_zone_len), MA_zone_len)+    3 * (ema - ta.ema(ema, MA_zone_len)) + ta.ema(ta.ema(ema, MA_zone_len), MA_zone_len)MA_zone_srcHi       = matype_signal(high, MA_zone_len, MA_zone_type)                                                                                        //      //⋯MACD_wid_rsiOB      = input(false, "Stgy №5:👉 MACD + RSI-OB", group="CHOOSE YOUR DESIRE SIGNAL")-rsilen              = input(title="Length", defval=14, type=input.integer, inline="rsi", group="CHOOSE YOUR DESIRE SIGNAL")+rsilen              = input.int(title="Length", defval=14, inline="rsi", group="CHOOSE YOUR DESIRE SIGNAL")-rsi_ent_value       = input(title="Entry", defval=50, type=input.integer, minval=1, inline="rsi", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="🚦🚦🚦 Condition 🚦🚦🚦\n\nBUY Rule\nMACD Crossover Signal\nRSI Greater then Entry Level (You Choose)\n\n🚦🚦🚦 Explanation 🚦🚦🚦\nWe have RSI with 2 Levels,\n1st: Entry Level\n2nd: No-Entry Level\n\nEntry level:\nfor never want to BUY trade when RSI is Below our specific Level, like you want open Trade when RSI above 50 level or 30 level etc... \n\nNo-Entry Level:\nthis is same as (Entry Level) Condition, as we know RSI-70 level use for OverBought, and its mean market will go down after RSI-OB level, and thats why we can set overbought level for NO-ENTRY when Market is on OverBought area.")+rsi_ent_value       = input.int(title="Entry", defval=50, minval=1, inline="rsi", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="🚦🚦🚦 Condition 🚦🚦🚦\n\nBUY Rule\nMACD Crossover Signal\nRSI Greater then Entry Level (You Choose)\n\n🚦🚦🚦 Explanation 🚦🚦🚦\nWe have RSI with 2 Levels,\n1st: Entry Level\n2nd: No-Entry Level\n\nEntry level:\nfor never want to BUY trade when RSI is Below our specific Level, like you want open Trade when RSI above 50 level or 30 level etc... \n\nNo-Entry Level:\nthis is same as (Entry Level) Condition, as we know RSI-70 level use for OverBought, and its mean market will go down after RSI-OB level, and thats why we can set overbought level for NO-ENTRY when Market is on OverBought area.")-rsi_ob_value        = input(title="No-Entry", defval=70, minval=1, type=input.integer, inline="rsi", group="CHOOSE YOUR DESIRE SIGNAL")   +rsi_ob_value        = input.int(title="No-Entry", defval=70, minval=1, inline="rsi", group="CHOOSE YOUR DESIRE SIGNAL")   -RSI                 = rsi(close , rsilen)+RSI                 = ta.rsi(close , rsilen)//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////-startTime           =       input(title="Start Time                           ", type = input.time, defval = timestamp("01 Jan 2021 00:00 +0000"), inline="Backtesting Time Period")+startTime           =       input.time(title="Start Time                           ", defval = timestamp("01 Jan 2021 00:00 +0000"), inline="Backtesting Time Period")-endTime             =       input(title="End Time                          ", type = input.time, defval = timestamp("01 Jan 2022 00:00 +0000"))+endTime             =       input.time(title="End Time                          ", defval = timestamp("01 Jan 2022 00:00 +0000"))inDateRange         =       (time >= startTime) and (time < endTime)⋯MACD_rsi_EnSell         = RSI < rsi_ent_value           ////-MACD_rsi_Ex       = crossunder(RSI , rsi_ob_value) or crossunder(RSI[1] , rsi_ob_value[1]) or crossunder(RSI[2] , rsi_ob_value[2]) or crossunder(RSI[3] , rsi_ob_value[3]) or crossunder(RSI[4] , rsi_ob_value[4]) or crossunder(RSI[5] , rsi_ob_value[5]) or crossunder(RSI[6] , rsi_ob_value[6])         ////+MACD_rsi_Ex       = ta.crossunder(RSI , rsi_ob_value) or ta.crossunder(RSI[1] , rsi_ob_value[1]) or ta.crossunder(RSI[2] , rsi_ob_value[2]) or ta.crossunder(RSI[3] , rsi_ob_value[3]) or ta.crossunder(RSI[4] , rsi_ob_value[4]) or ta.crossunder(RSI[5] , rsi_ob_value[5]) or ta.crossunder(RSI[6] , rsi_ob_value[6])         ////                                                                            ////⋯// ( Colors of [MACD and Signal-Line] )-MACD_width          = input(title="MACD Line               ", defval=2, minval=1, type=input.integer, group="🚦🚦macd Width & Colors setting🚦🚦", inline="macdColor")+MACD_width          = input.int(title="MACD Line               ", defval=2, minval=1, group="🚦🚦macd Width & Colors setting🚦🚦", inline="macdColor")-MACD_color_High     = input(#11ff00, title="", type=input.color, group="🚦🚦macd Width & Colors setting🚦🚦", inline="macdColor")+MACD_color_High     = input.color(#11ff00, title="", group="🚦🚦macd Width & Colors setting🚦🚦", inline="macdColor")-MACD_color_Low      = input(#e91e63, title="", type=input.color, group="🚦🚦macd Width & Colors setting🚦🚦", inline="macdColor")+MACD_color_Low      = input.color(#e91e63, title="", group="🚦🚦macd Width & Colors setting🚦🚦", inline="macdColor")-signal_width        = input(title="Signal Line               ", defval=2, minval=1, type=input.integer, group="🚦🚦macd Width & Colors setting🚦🚦", inline="signal")+signal_width        = input.int(title="Signal Line               ", defval=2, minval=1, group="🚦🚦macd Width & Colors setting🚦🚦", inline="signal")-signalLine_col_hi   = input(#ffeb3b, title="", type=input.color, inline="signal", group="🚦🚦macd Width & Colors setting🚦🚦")+signalLine_col_hi   = input.color(#ffeb3b, title="", inline="signal", group="🚦🚦macd Width & Colors setting🚦🚦")-signalLine_col_lo   = input(#ffeb3b, title="", type=input.color, inline="signal", group="🚦🚦macd Width & Colors setting🚦🚦")+signalLine_col_lo   = input.color(#ffeb3b, title="", inline="signal", group="🚦🚦macd Width & Colors setting🚦🚦")// ((Histogram Color)) /////////////////////////////////////////////////////////macd_hist_on        = input(true, "Histogram        ", inline="hist", group="🚦🚦macd Width & Colors setting🚦🚦")-BuyStrongHist       = input(#26A69A, title="", type=input.color, inline="hist", group="🚦🚦macd Width & Colors setting🚦🚦")+BuyStrongHist       = input.color(#26A69A, title="", inline="hist", group="🚦🚦macd Width & Colors setting🚦🚦")-BuyWeakHist         = input(#B2DFDB, title="", type=input.color, inline="hist", group="🚦🚦macd Width & Colors setting🚦🚦")+BuyWeakHist         = input.color(#B2DFDB, title="", inline="hist", group="🚦🚦macd Width & Colors setting🚦🚦")-SellWeakHist        = input(#FFCDD2, title="✨", type=input.color, inline="hist", group="🚦🚦macd Width & Colors setting🚦🚦")+SellWeakHist        = input.color(#FFCDD2, title="✨", inline="hist", group="🚦🚦macd Width & Colors setting🚦🚦")-SellStrongHist      = input(#FF5252, title="", type=input.color, inline="hist", group="🚦🚦macd Width & Colors setting🚦🚦")+SellStrongHist      = input.color(#FF5252, title="", inline="hist", group="🚦🚦macd Width & Colors setting🚦🚦")// ((FOR HISTOGRAM COLOR CONDITION))⋯macd_cross_width    = input(defval=5, title="", inline="dot", group="🚦🚦macd Width & Colors setting🚦🚦")-dot_crsovr_col      = input(#ffffff, title="", type=input.color, inline="dot", group="🚦🚦macd Width & Colors setting🚦🚦")+dot_crsovr_col      = input.color(#ffffff, title="", inline="dot", group="🚦🚦macd Width & Colors setting🚦🚦")-dot_crsndr_col      = input(color.new(#e91e63, 0), title="", type=input.color, inline="dot", group="🚦🚦macd Width & Colors setting🚦🚦")+dot_crsndr_col      = input.color(color.new(#e91e63, 0), title="", inline="dot", group="🚦🚦macd Width & Colors setting🚦🚦")// (( MACD ZONE COLOR ))zone_on             = input(true, "Zone Color        ", inline="zone", group="🚦🚦macd Width & Colors setting🚦🚦")-zone_crsovr_col     = input(color.new(color.lime, 70), title="", type=input.color, inline="zone", group="🚦🚦macd Width & Colors setting🚦🚦")+zone_crsovr_col     = input.color(color.new(color.lime, 70), title="", inline="zone", group="🚦🚦macd Width & Colors setting🚦🚦")-zone_crsndr_col     = input(color.new(#e91e63, 70), title="", type=input.color, inline="zone", group="🚦🚦macd Width & Colors setting🚦🚦")+zone_crsndr_col     = input.color(color.new(#e91e63, 70), title="", inline="zone", group="🚦🚦macd Width & Colors setting🚦🚦")///////////////////////////////////////// ((FOR MACD LINE COLOR CONDITION))⋯osc = MACD-plFound = na(pivotlow(osc, lbL, lbR)) ? false : true+plFound = na(ta.pivotlow(osc, lbL, lbR)) ? false : true-phFound = na(pivothigh(osc, lbL, lbR)) ? false : true+phFound = na(ta.pivothigh(osc, lbL, lbR)) ? false : true_inRange(cond) =>-    bars = barssince(cond == true)+    bars = ta.barssince(cond == true)    rangeLower <= bars and bars <= rangeUpper⋯// Osc: Higher Low-oscHL = osc[lbR] > valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1]) and  osc[lbR] < 0+oscHL = osc[lbR] > ta.valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1]) and  osc[lbR] < 0// Price: Lower Low-priceLL         = low[lbR] < valuewhen(plFound, low[lbR], 1)+priceLL         = low[lbR] < ta.valuewhen(plFound, low[lbR], 1)-priceHHZero     = highest(osc, lbL+lbR+5)+priceHHZero     = ta.highest(osc, lbL+lbR+5)LineDisplay     = input(false, "Line Display", inline="line", group=" ▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁")⋯     linewidth=2,-     color=(bullCond ? bullColor : noneColor),-     transp=0+     color=color.new((bullCond ? bullColor : noneColor), 0)     )⋯     location=location.absolute,-     color=bullColor,+     color=color.new(bullColor, 0),-     textcolor=textColor,-     transp=0+     textcolor=textColor     )⋯// Osc: Lower Low-oscLL = osc[lbR] < valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1])+oscLL = osc[lbR] < ta.valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1])// Price: Higher Low-priceHL = low[lbR] > valuewhen(plFound, low[lbR], 1)+priceHL = low[lbR] > ta.valuewhen(plFound, low[lbR], 1)hiddenBullCond = plotHiddenBull and priceHL and oscLL and plFound⋯     linewidth=2,-     color=(hiddenBullCond ? hiddenBullColor : noneColor),-     transp=0+     color=color.new((hiddenBullCond ? hiddenBullColor : noneColor), 0)     )⋯     location=location.absolute,-     color=bullColor,+     color=color.new(bullColor, 0),-     textcolor=textColor,-     transp=0+     textcolor=textColor     )⋯// Osc: Lower High-oscLH = osc[lbR] < valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1])  and osc[lbR] > 0+oscLH = osc[lbR] < ta.valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1])  and osc[lbR] > 0-priceLLZero =  lowest(osc, lbL+lbR+5) +priceLLZero =  ta.lowest(osc, lbL+lbR+5) //plot(priceLLZero,title="priceLLZero", color=color.red)⋯// Price: Higher High-priceHH = high[lbR] > valuewhen(phFound, high[lbR], 1)+priceHH = high[lbR] > ta.valuewhen(phFound, high[lbR], 1)bearCond = plotBear and priceHH and oscLH and phFound and bearzero⋯     linewidth=2,-     color=(bearCond ? bearColor : noneColor),-     transp=0+     color=color.new((bearCond ? bearColor : noneColor), 0)     )⋯     location=location.absolute,-     color=bearColor,+     color=color.new(bearColor, 0),-     textcolor=textColor,-     transp=0+     textcolor=textColor     )⋯// Osc: Higher High-oscHH = osc[lbR] > valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1])+oscHH = osc[lbR] > ta.valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1])// Price: Lower High-priceLH = high[lbR] < valuewhen(phFound, high[lbR], 1)+priceLH = high[lbR] < ta.valuewhen(phFound, high[lbR], 1)hiddenBearCond = plotHiddenBear and priceLH and oscHH and phFound⋯     linewidth=2,-     color=(hiddenBearCond ? hiddenBearColor : noneColor),-     transp=0+     color=color.new((hiddenBearCond ? hiddenBearColor : noneColor), 0)     )⋯     location=location.absolute,-     color=bearColor,+     color=color.new(bearColor, 0),-     textcolor=textColor,-     transp=0+     textcolor=textColor     )

Clean v5

Not verified

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

  • Line 43: input() → input.bool()
  • Line 45: input() → input.bool()
  • Line 49: input() → input.bool()
  • Line 51: input() → input.string()
  • Line 60: input() → input.bool()
  • Line 62: input() → input.string()
15 more edits
  • Line 72: input() → input.bool()
  • Line 82: input() → input.string()
  • Line 83: input() → input.string()
  • Line 166: input() → input.bool()
  • Line 174: input() → input.bool()
  • Line 175: input() → input.int()
  • Line 179: input() → input.bool()
  • Line 215: input() → input.bool()
  • Line 216: input() → input.int()
  • Line 217: input() → input.int()
  • Line 218: input() → input.int()
  • Line 219: input() → input.int()
  • Line 220: input() → input.bool()
  • Line 222: input() → input.bool()
  • Line 243: input() → input.bool()
⋯// Choose your Desire Signal ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////-MACD_crs_signal     = input(false, "Stgy №1:👉 MACD CrossOver", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="🚦🚦🚦 Condition 🚦🚦🚦\nBUY: MACD CrossOver Signal Line\nSELL: MACD CrossUnder Signal Line\nDefault Signal")+MACD_crs_signal     = input.bool(false, "Stgy №1:👉 MACD CrossOver", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="🚦🚦🚦 Condition 🚦🚦🚦\nBUY: MACD CrossOver Signal Line\nSELL: MACD CrossUnder Signal Line\nDefault Signal")/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////-MACD_OB             = input(false, "Stgy №2:👉 MACD + OverBought ", inline="obs", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="MACD also work as OverBought & OverSold system, same like RSI or other indicators who have OB/OS system, so i added OB-Level in MACD,\nso simple rule is: if MACD Lines is Above OB-Level, we will not take any trade, we only follow MACD signals when MACD-Lines will Below OB-Level")+MACD_OB             = input.bool(false, "Stgy №2:👉 MACD + OverBought ", inline="obs", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="MACD also work as OverBought & OverSold system, same like RSI or other indicators who have OB/OS system, so i added OB-Level in MACD,\nso simple rule is: if MACD Lines is Above OB-Level, we will not take any trade, we only follow MACD signals when MACD-Lines will Below OB-Level")MACD_OB_LVL         = input.float(title="", defval=0.0, inline="obs", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="MACD also work as OverBought & OverSold system, same like RSI or other indicators who have OB/OS system, so i added OB-Level in MACD,\nso simple rule is: if MACD Lines is Above OB-Level, we will not take any trade, we only follow MACD signals when MACD-Lines will Below OB-Level") ⋯/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////-MACD_close          = input(false, "Stgy №3:👉 MACD + Close         ", inline="MAsignal", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="🚦🚦🚦 Condition 🚦🚦🚦\n\nBUY RULES\n1st: MACD CrossOver Signal Line\n2nd: Close (Greater) Than Moving Average\n\nSELL RULES\n1st: MACD CrossUnder Signal Line\n2nd: Close (Less) Than Moving Average\n\nExplanation: When (MACD Cross Signal Line) and also Market current Candle Close or previous 1st-4th any Candle will have close greater than Moving Average (You Choose: EMA or SMA etc...)\n🚦NOTE: in this Condition only Singal Moving Average work => (Slow MA),")+MACD_close          = input.bool(false, "Stgy №3:👉 MACD + Close         ", inline="MAsignal", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="🚦🚦🚦 Condition 🚦🚦🚦\n\nBUY RULES\n1st: MACD CrossOver Signal Line\n2nd: Close (Greater) Than Moving Average\n\nSELL RULES\n1st: MACD CrossUnder Signal Line\n2nd: Close (Less) Than Moving Average\n\nExplanation: When (MACD Cross Signal Line) and also Market current Candle Close or previous 1st-4th any Candle will have close greater than Moving Average (You Choose: EMA or SMA etc...)\n🚦NOTE: in this Condition only Singal Moving Average work => (Slow MA),")MA_signal_len       = input.int(title="", defval=21, inline="MAsignal", group="CHOOSE YOUR DESIRE SIGNAL")    //      // -MA_signal_type      = input(title="", defval="EMA", options=["SMA" , "EMA" , "RMA", "WMA" , "VWMA" , "DEMA", "TEMA"], inline="MAsignal", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="🚦🚦🚦 Condition 🚦🚦🚦\n\nBUY RULES\n1st: MACD CrossOver Signal Line\n2nd: Close (Greater) Than Moving Average\n\nSELL RULES\n1st: MACD CrossUnder Signal Line\n2nd: Close (Less) Than Moving Average\n\nExplanation: When (MACD Cross Signal Line) and also Market current Candle Close will have close greater than Moving Average (You Choose: EMA or SMA etc...)")     //      //+MA_signal_type      = input.string(title="", defval="EMA", options=["SMA" , "EMA" , "RMA", "WMA" , "VWMA" , "DEMA", "TEMA"], inline="MAsignal", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="🚦🚦🚦 Condition 🚦🚦🚦\n\nBUY RULES\n1st: MACD CrossOver Signal Line\n2nd: Close (Greater) Than Moving Average\n\nSELL RULES\n1st: MACD CrossUnder Signal Line\n2nd: Close (Less) Than Moving Average\n\nExplanation: When (MACD Cross Signal Line) and also Market current Candle Close will have close greater than Moving Average (You Choose: EMA or SMA etc...)")     //      //dema = if MA_signal_type == "DEMA"⋯/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////-MACD_ZONE           = input(false, "Stgy №4:👉 MACD + MA-ZONE    ", inline="MAZONE", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="🚦🚦🚦 Condition 🚦🚦🚦\n\nBUY RULES:\n1st: MACD CrossOver Signal Line\n2nd: Close (Greater) than (MA-ZONE)\n\nSELL RULES:\n1st: MACD CrossUnder Signal Line\n2nd: Close (Less) than (MA-ZONE)")+MACD_ZONE           = input.bool(false, "Stgy №4:👉 MACD + MA-ZONE    ", inline="MAZONE", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="🚦🚦🚦 Condition 🚦🚦🚦\n\nBUY RULES:\n1st: MACD CrossOver Signal Line\n2nd: Close (Greater) than (MA-ZONE)\n\nSELL RULES:\n1st: MACD CrossUnder Signal Line\n2nd: Close (Less) than (MA-ZONE)")MA_zone_len         = input.int(title="", defval=21, inline="MAZONE", group="CHOOSE YOUR DESIRE SIGNAL")-MA_zone_type        = input(title="", defval="EMA", options=["SMA" , "EMA" , "RMA", "WMA" , "VWMA" , "DEMA", "TEMA"], inline="MAZONE", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="🚦🚦🚦 Condition 🚦🚦🚦\n\nBUY RULES:\n1st: MACD CrossOver Signal Line\n2nd: Close (Greater) than (MA-ZONE)\n\nSELL RULES:\n1st: MACD CrossUnder Signal Line\n2nd: Close (Less) than (MA-ZONE)")+MA_zone_type        = input.string(title="", defval="EMA", options=["SMA" , "EMA" , "RMA", "WMA" , "VWMA" , "DEMA", "TEMA"], inline="MAZONE", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="🚦🚦🚦 Condition 🚦🚦🚦\n\nBUY RULES:\n1st: MACD CrossOver Signal Line\n2nd: Close (Greater) than (MA-ZONE)\n\nSELL RULES:\n1st: MACD CrossUnder Signal Line\n2nd: Close (Less) than (MA-ZONE)")dema2 = if MA_zone_type == "DEMA"⋯/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////-MACD_wid_rsiOB      = input(false, "Stgy №5:👉 MACD + RSI-OB", group="CHOOSE YOUR DESIRE SIGNAL")+MACD_wid_rsiOB      = input.bool(false, "Stgy №5:👉 MACD + RSI-OB", group="CHOOSE YOUR DESIRE SIGNAL")rsilen              = input.int(title="Length", defval=14, inline="rsi", group="CHOOSE YOUR DESIRE SIGNAL")⋯inDateRange         =       (time >= startTime) and (time < endTime)-bot_id = input(title="BOT ID       ", defval='', inline="bot", group="BOT SECTION")+bot_id = input.string(title="BOT ID       ", defval='', inline="bot", group="BOT SECTION")-email_token = input(title="  Token", defval='', inline="bot", group="BOT SECTION")+email_token = input.string(title="  Token", defval='', inline="bot", group="BOT SECTION")enter_msg = '{ "message_type": "bot", "bot_id":'+ bot_id + ', "email_token": "'+ email_token + '", "delay_seconds": 0 }'⋯// ((Histogram Color)) /////////////////////////////////////////////////////////-macd_hist_on        = input(true, "Histogram        ", inline="hist", group="🚦🚦macd Width & Colors setting🚦🚦")+macd_hist_on        = input.bool(true, "Histogram        ", inline="hist", group="🚦🚦macd Width & Colors setting🚦🚦")BuyStrongHist       = input.color(#26A69A, title="", inline="hist", group="🚦🚦macd Width & Colors setting🚦🚦")⋯// (( CROSSOVER DOT) ///////////////////////////////////////////////////////////-macd_crsovr_dot_on  = input(true, "Cross               ", inline="dot", group="🚦🚦macd Width & Colors setting🚦🚦")+macd_crsovr_dot_on  = input.bool(true, "Cross               ", inline="dot", group="🚦🚦macd Width & Colors setting🚦🚦")-macd_cross_width    = input(defval=5, title="", inline="dot", group="🚦🚦macd Width & Colors setting🚦🚦")+macd_cross_width    = input.int(defval=5, title="", inline="dot", group="🚦🚦macd Width & Colors setting🚦🚦")dot_crsovr_col      = input.color(#ffffff, title="", inline="dot", group="🚦🚦macd Width & Colors setting🚦🚦")⋯// (( MACD ZONE COLOR ))-zone_on             = input(true, "Zone Color        ", inline="zone", group="🚦🚦macd Width & Colors setting🚦🚦")+zone_on             = input.bool(true, "Zone Color        ", inline="zone", group="🚦🚦macd Width & Colors setting🚦🚦")zone_crsovr_col     = input.color(color.new(color.lime, 70), title="", inline="zone", group="🚦🚦macd Width & Colors setting🚦🚦")⋯///////////////////////////////////////////////////////////////////////////////-donttouchzero = input(title="Want DVG when line below 0  ?        ", defval=true, inline="line", group=" ▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁")+donttouchzero = input.bool(title="Want DVG when line below 0  ?        ", defval=true, inline="line", group=" ▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁")-lbR = input(title="Pivot Lookback Right", defval=5, group=" ▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁")+lbR = input.int(title="Pivot Lookback Right", defval=5, group=" ▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁")-lbL = input(title="Pivot Lookback Left", defval=5, group=" ▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁")+lbL = input.int(title="Pivot Lookback Left", defval=5, group=" ▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁")-rangeUpper = input(title="Max of Lookback Range", defval=60, group=" ▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁")+rangeUpper = input.int(title="Max of Lookback Range", defval=60, group=" ▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁")-rangeLower = input(title="Min of Lookback Range", defval=5, group=" ▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁")+rangeLower = input.int(title="Min of Lookback Range", defval=5, group=" ▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁")-plotBull = input(title="ON/OFF Bullish DVG", defval=true, group=" ▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁")+plotBull = input.bool(title="ON/OFF Bullish DVG", defval=true, group=" ▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁")plotHiddenBull = false-plotBear = input(title="ON/OFF Bearish DVG", defval=true, group=" ▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁")+plotBear = input.bool(title="ON/OFF Bearish DVG", defval=true, group=" ▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁")plotHiddenBear = false⋯priceHHZero     = ta.highest(osc, lbL+lbR+5)-LineDisplay     = input(false, "Line Display", inline="line", group=" ▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁")+LineDisplay     = input.bool(false, "Line Display", inline="line", group=" ▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁")plot(LineDisplay ? priceHHZero : na, title="priceHHZero", color=color.lime)⋯

Does it run in Pine Script v6?

Not tested

Neither version placed a trade on any of the 8 markets, so there was nothing to compare. The v6 version is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.

⋯// © HamidBox-//@version=5+//@version=6strategy("MACD [5-in-1] V2", default_qty_type=strategy.cash, default_qty_value=100, initial_capital=100, currency='USD', commission_value=0.1)⋯

Settings

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

SettingDefaultType and rangeFeeds
MACD Fast12int (written input.integer) · min 1macd_Fast
MACD Slow 26int (written input.integer) · min 1macd_Slow
Signal Line9int (written input.integer) · min 1Signal
Source closesourcemacd_Fast macd_Slow
Oscilattor EMAstring · options ["EMA" , "SMA"]macd_Fast macd_Slow
Signal EMAstring · options ["EMA" , "SMA"]Signal
Start Time timestamp("01 Jan 2021 00:00 +0000")timeinDateRange
End Time timestamp("01 Jan 2022 00:00 +0000")timeinDateRange
CHOOSE YOUR DESIRE SIGNAL
Stgy №1:👉 MACD CrossOver🚦🚦🚦 Condition 🚦🚦🚦\nBUY: MACD CrossOver Signal Line\nSELL: MACD CrossUnder Signal Line\nDefault Signalfalseboolentry BUY1 close BUY1 line 91 line 93
Stgy №2:👉 MACD + OverBought MACD also work as OverBought & OverSold system, same like RSI or other indicators who have OB/OS system, so i added OB-Level in MACD,\nso simple rule is: if MACD Lines is Above OB-Level, we will not take any trade, we only follow MACD signals when MACD-Lines will Below OB-Levelfalseboolentry BUY2 close BUY2 line 107 line 109
MACD OB LVL (no label in the script)MACD also work as OverBought & OverSold system, same like RSI or other indicators who have OB/OS system, so i added OB-Level in MACD,\nso simple rule is: if MACD Lines is Above OB-Level, we will not take any trade, we only follow MACD signals when MACD-Lines will Below OB-Level0.0floatonly_Trade_when MACD OB
Stgy №3:👉 MACD + Close 🚦🚦🚦 Condition 🚦🚦🚦\n\nBUY RULES\n1st: MACD CrossOver Signal Line\n2nd: Close (Greater) Than Moving Average\n\nSELL RULES\n1st: MACD CrossUnder Signal Line\n2nd: Close (Less) Than Moving Average\n\nExplanation: When (MACD Cross Signal Line) and also Market current Candle Close or previous 1st-4th any Candle will have close greater than Moving Average (You Choose: EMA or SMA etc...)\n🚦NOTE: in this Condition only Singal Moving Average work => (Slow MA),falseboolentry BUY3 close BUY3 line 121 line 123
MA signal len (no label in the script)21int (written input.integer)dema tema MA_signal ema
MA signal type (no label in the script)🚦🚦🚦 Condition 🚦🚦🚦\n\nBUY RULES\n1st: MACD CrossOver Signal Line\n2nd: Close (Greater) Than Moving Average\n\nSELL RULES\n1st: MACD CrossUnder Signal Line\n2nd: Close (Less) Than Moving Average\n\nExplanation: When (MACD Cross Signal Line) and also Market current Candle Close will have close greater than Moving Average (You Choose: EMA or SMA etc...)EMAstring · options ["SMA" , "EMA" , "RMA", "WMA" , "VWMA" , "DEMA", "TEMA"]dema tema MA_signal
Stgy №4:👉 MACD + MA-ZONE 🚦🚦🚦 Condition 🚦🚦🚦\n\nBUY RULES:\n1st: MACD CrossOver Signal Line\n2nd: Close (Greater) than (MA-ZONE)\n\nSELL RULES:\n1st: MACD CrossUnder Signal Line\n2nd: Close (Less) than (MA-ZONE)falseboolentry BUY4 close BUY4 line 136 line 138
MA zone len (no label in the script)21int (written input.integer)ema dema2 tema2 MA_zone_srcHi MA_zone_srcLO
MA zone type (no label in the script)🚦🚦🚦 Condition 🚦🚦🚦\n\nBUY RULES:\n1st: MACD CrossOver Signal Line\n2nd: Close (Greater) than (MA-ZONE)\n\nSELL RULES:\n1st: MACD CrossUnder Signal Line\n2nd: Close (Less) than (MA-ZONE)EMAstring · options ["SMA" , "EMA" , "RMA", "WMA" , "VWMA" , "DEMA", "TEMA"]dema2 tema2 MA_zone_srcHi MA_zone_srcLO
Stgy №5:👉 MACD + RSI-OBfalseboolentry BUY5 close BUY5 line 149 line 151
Length14int (written input.integer)RSI
Entry🚦🚦🚦 Condition 🚦🚦🚦\n\nBUY Rule\nMACD Crossover Signal\nRSI Greater then Entry Level (You Choose)\n\n🚦🚦🚦 Explanation 🚦🚦🚦\nWe have RSI with 2 Levels,\n1st: Entry Level\n2nd: No-Entry Level\n\nEntry level:\nfor never want to BUY trade when RSI is Below our specific Level, like you want open Trade when RSI above 50 level or 30 level etc... \n\nNo-Entry Level:\nthis is same as (Entry Level) Condition, as we know RSI-70 level use for OverBought, and its mean market will go down after RSI-OB level, and thats why we can set overbought level for NO-ENTRY when Market is on OverBought area.50int (written input.integer) · min 1MACD_rsi_EnBuy MACD_rsi_EnSell
No-Entry70int (written input.integer) · min 1MACD_rsi_EnBuy MACD_rsi_Ex
BOT SECTION
BOT ID stringenter_msg exit_msg
Tokenstringenter_msg exit_msg
🚦🚦macd Width & Colors setting🚦🚦
MACD Line 2int (written input.integer) · min 1MACD
MACD color High (no label in the script)#11ff00colorMACD_line_col
MACD color Low (no label in the script)#e91e63colorMACD_line_col
Signal Line 2int (written input.integer) · min 1Signal
Signal Line col hi (no label in the script)#ffeb3bcolorsignal_line_col
Signal Line col lo (no label in the script)#ffeb3bcolorsignal_line_col
Histogram trueboolHistogram
Buy Strong Hist (no label in the script)#26A69Acolorhist_col
Buy Weak Hist (no label in the script)#B2DFDBcolorhist_col
✨#FFCDD2colorhist_col
Sell Strong Hist (no label in the script)#FF5252colorhist_col
Cross trueboolc-over c-under
Macd cross width (no label in the script)5intc-over c-under
Dot crsovr col (no label in the script)#ffffffcolorMACD_Dot_col
Dot crsndr col (no label in the script)color.new(#e91e63, 0)colorMACD_Dot_col
Zone Color trueboolzone_crsovr_plot
Zone crsovr col (no label in the script)color.new(color.lime, 70)colorzone_crsovr_plot
Zone crsndr col (no label in the script)color.new(#e91e63, 70)colorzone_crsovr_plot
▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁
Want DVG when line below 0 ? trueboolblowzero bearzero
Pivot Lookback Right5intplFound phFound oscHL priceLL priceHHZero oscLL priceHL oscLH priceLLZero priceHH oscHH priceLH Regular Bullish Regular Bullish Label Hidden Bullish Hidden Bullish Label Regular Bearish Regular Bearish Label Hidden Bearish Hidden Bearish Label
Pivot Lookback Left5intplFound phFound priceHHZero priceLLZero
Max of Lookback Range60intline 235
Min of Lookback Range5intline 235
ON/OFF Bullish DVGtrueboolbullCond
ON/OFF Bearish DVGtrueboolbearCond
Line DisplayfalseboolpriceHHZero

What it calculates

  • SMA / EMA (sma, ta.sma in v5)Source (close), MACD Fast (12) · chosen by Oscilattor macd_Fast · line 28
  • SMA / EMA (sma, ta.sma in v5)Source (close), MACD Slow (26) · chosen by Oscilattor macd_Slow · line 29
  • SMA / EMA (sma, ta.sma in v5)MACD, Signal Line (9) · chosen by Signal Signal · line 31
  • Crossover (crossover, ta.crossover in v5)MACD, Signalmacd_crsovr_signal · line 37
  • Crossunder (crossunder, ta.crossunder in v5)MACD, Signalmacd_crsndr_signal · line 38
  • Crossover (crossover, ta.crossover in v5)MACD, Signalmacd_crsovr · line 39
  • Crossunder (crossunder, ta.crossunder in v5)MACD, Signalmacd_crsndr · line 40
  • EMA (ema, ta.ema in v5)close, MA zone len (21)ema · line 67
  • RSI (rsi, ta.rsi in v5)close, Length (14)RSI · line 76
  • Pivotlow (pivotlow, ta.pivotlow in v5)osc, Pivot Lookback Left (5), Pivot Lookback Right (5)plFound · line 231
  • Pivothigh (pivothigh, ta.pivothigh in v5)osc, Pivot Lookback Left (5), Pivot Lookback Right (5)phFound · line 232
  • Highest (highest, ta.highest in v5)osc, lbL+lbR+5priceHHZero · line 242
  • Lowest (lowest, ta.lowest in v5)osc, lbL+lbR+5priceLLZero · line 296

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 93 named inputs, calculations, conditions and outputs, too many to draw legibly here; the tables above list them.

Order rules

OrderFires whenBy defaultLine
Open BUY1 longmacd_crsovr and MACD_crs_signal and inDateRangeOn92
Close BUY1macd_crsndr and MACD_crs_signal and inDateRangeOn94
Open BUY2 longmacd_ob_buy and MACD_OB and inDateRangeOn108
Close BUY2macd_ob_sell and MACD_OB and inDateRangeOn110
Open BUY3 longmacd_close_buy and MACD_close and inDateRangeOn122
Close BUY3macd_close_sell and MACD_close and inDateRangeOn124
Open BUY4 longmacd_zone_buy and MACD_ZONE and inDateRangeOn137
Close BUY4macd_zone_sell and MACD_ZONE and inDateRangeOn139
Open BUY5 longmacd_crsovr and MACD_rsi_EnBuy and MACD_wid_rsiOB and inDateRangeOn150
Close BUY5macd_crsndr and MACD_wid_rsiOB and inDateRangeOn152
Close (not inDateRange)On155

Each order is guarded by the setting shown. “Off” orders never fire unless that setting is switched on.

Does it repaint?

No

No repainting patterns in the source.

Not measuredNo trades to compareThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, but neither the live nor the historical run produced any trades in them, so the replay says nothing either way.
  • ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • ClearIntrabar recalculationNo varip, calc_on_every_tick or realtime-only state. Orders are decided once per closed bar.
  • ClearOrder timingOrders fill at the next bar's open, after the signal bar has closed.

The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.

Other markets

The same script with default settings on 8 Binance markets. Each row is a separate backtest over the most recent 1,000 bars.

MarketNetBuy and holdTradesWonProfit factorMax drawdownPeriod
BTCUSDT 1D0.0%+102.5%00%—0.0%26 Jan 2024 – 21 Oct 2026
BTCUSDT 4h0.0%+5.5%00%—0.0%8 May 2026 – 21 Oct 2026
ETHUSDT 1D0.0%+9.8%00%—0.0%26 Jan 2024 – 21 Oct 2026
ETHUSDT 4h0.0%+8.4%00%—0.0%8 May 2026 – 21 Oct 2026
SOLUSDT 1D0.0%+16.7%00%—0.0%26 Jan 2024 – 21 Oct 2026
SOLUSDT 4h0.0%+21.5%00%—0.0%8 May 2026 – 21 Oct 2026
BNBUSDT 1D0.0%+148.3%00%—0.0%26 Jan 2024 – 21 Oct 2026
BNBUSDT 4h0.0%+17.1%00%—0.0%8 May 2026 – 21 Oct 2026

Backtests are simulations on historical data and are not investment advice.

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
MACD 5 iN 1 [Pro-Tool] this page—v4 strategy0.0%00.0%
X48 - Strategy - MA Type Cross + TPSL - Future&Spot - V.2 by X4815162342ema rsi sma highest lowest pivothigh pivotlowv5 strategydoes not run in Zeal Terminal
RSI Overbought Oversold Divergence Strategy w- Buy-Sell Signals by imal_maxema sma lowest highest rsi pivotlowv5 strategydoes not run in Zeal Terminal
sma RSI & sudden buy and sell Strategy v1 by samwillingtonema rsi highest lowest smav5 strategy+7.6%153.7%
[DS]Entry_Exit_TRADE.V01-Strategy by DalmarSantosema pivothigh pivotlow highest lowestv4 strategy+72.5%3931.7%
TICK Scalping strategy, SPY 1 min by PtGamblerema sma pivotlow pivothigh rsi lowest highestv5 strategyNo trades on this market

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 73 msYes 1,000 bars in 257 msNot measured
PineTSNo v5 and v6 only—Not measured

“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report. PineTS runs Pine Script v5 and v6 only.

Source

Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © HamidBox//@version=4strategy("MACD [5-in-1] V2", default_qty_type=strategy.cash, default_qty_value=100, initial_capital=100, currency='USD', commission_value=0.1)matype_zone(src, len, type) =>    type == "EMA" ? ema(src, len) :     type == "SMA" ? sma(src, len) :     type == "RMA" ? rma(src, len) :      type == "WMA" ? wma(src, len) :      type == "VWMA" ? vwma(src, len) :     namatype_signal(src, len, type) =>    type == "EMA" ? ema(src, len) :     type == "SMA" ? sma(src, len) :     type == "RMA" ? rma(src, len) :      type == "WMA" ? wma(src, len) :      type == "VWMA" ? vwma(src, len) :     na// MACD INPUTS ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////macd_FastLength     = input(title="MACD Fast", defval=12, minval=1, type=input.integer, inline="fastslow")                      ///macd_SlowLength     = input(title="MACD Slow ", defval=26, minval=1, type=input.integer, inline="fastslow")                     ///macd_signalLen      = input(title="Signal Line", defval=9, minval=1, type=input.integer, inline="signalsrc")                    ///macd_Source         = input(title="Source      ", defval=close, type=input.source, inline="signalsrc")                          ///MACD_Line           = input(title="Oscilattor ", defval="EMA", type=input.string, options=["EMA" , "SMA"], inline="matype")     ///SignalLine          = input(title="Signal       ", defval="EMA", type=input.string, options=["EMA" , "SMA"], inline="matype")   ///                                                                                                                                ///// MACD SETUP /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////macd_Fast           = MACD_Line == "SMA" ? sma(macd_Source , macd_FastLength) : ema(macd_Source , macd_FastLength)      ///macd_Slow           = MACD_Line == "SMA" ? sma(macd_Source , macd_SlowLength) : ema(macd_Source , macd_SlowLength)      ///MACD                = macd_Fast - macd_Slow                                                                             ///Signal              = SignalLine == "SMA" ? sma(MACD, macd_signalLen) : ema(MACD, macd_signalLen)                       ///histogram           = MACD - Signal                                                                                     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// MACD CONDITIONS SECTION /////////////////////////////////////////////////////macd_grtr_signal    = MACD > Signal                                           //macd_less_signal    = MACD < Signal                                           //macd_crsovr_signal  = crossover(MACD , Signal) ? MACD : na      // FOR MACD CROSS DOT PLOTING //macd_crsndr_signal  = crossunder(MACD , Signal) ? MACD : na     // FOR MACD CROSS DOT PLOTING //                 macd_crsovr         = crossover(MACD , Signal)                                //macd_crsndr         = crossunder(MACD , Signal)                               //////////////////////////////////////////////////////////////////////////////////// Choose your Desire Signal ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////MACD_crs_signal     = input(false, "Stgy №1:👉 MACD CrossOver", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="🚦🚦🚦 Condition 🚦🚦🚦\nBUY: MACD CrossOver Signal Line\nSELL: MACD CrossUnder Signal Line\nDefault Signal")/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////MACD_OB             = input(false, "Stgy №2:👉 MACD + OverBought ", inline="obs", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="MACD also work as OverBought & OverSold system, same like RSI or other indicators who have OB/OS system, so i added OB-Level in MACD,\nso simple rule is: if MACD Lines is Above OB-Level, we will not take any trade, we only follow MACD signals when MACD-Lines will Below OB-Level")MACD_OB_LVL         = input(title="", defval=0.0, type=input.float, inline="obs", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="MACD also work as OverBought & OverSold system, same like RSI or other indicators who have OB/OS system, so i added OB-Level in MACD,\nso simple rule is: if MACD Lines is Above OB-Level, we will not take any trade, we only follow MACD signals when MACD-Lines will Below OB-Level") hline(MACD_OB_LVL, color=color.red, title="MACD OB", linestyle=hline.style_dashed)/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////MACD_close          = input(false, "Stgy №3:👉 MACD + Close         ", inline="MAsignal", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="🚦🚦🚦 Condition 🚦🚦🚦\n\nBUY RULES\n1st: MACD CrossOver Signal Line\n2nd: Close (Greater) Than Moving Average\n\nSELL RULES\n1st: MACD CrossUnder Signal Line\n2nd: Close (Less) Than Moving Average\n\nExplanation: When (MACD Cross Signal Line) and also Market current Candle Close or previous 1st-4th any Candle will have close greater than Moving Average (You Choose: EMA or SMA etc...)\n🚦NOTE: in this Condition only Singal Moving Average work => (Slow MA),")MA_signal_len       = input(title="", defval=21, type=input.integer, inline="MAsignal", group="CHOOSE YOUR DESIRE SIGNAL")    //      // MA_signal_type      = input(title="", defval="EMA", options=["SMA" , "EMA" , "RMA", "WMA" , "VWMA" , "DEMA", "TEMA"], inline="MAsignal", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="🚦🚦🚦 Condition 🚦🚦🚦\n\nBUY RULES\n1st: MACD CrossOver Signal Line\n2nd: Close (Greater) Than Moving Average\n\nSELL RULES\n1st: MACD CrossUnder Signal Line\n2nd: Close (Less) Than Moving Average\n\nExplanation: When (MACD Cross Signal Line) and also Market current Candle Close will have close greater than Moving Average (You Choose: EMA or SMA etc...)")     //      //dema = if MA_signal_type == "DEMA"    ema = ema(close , MA_signal_len)    2 * ema - ema(ema , MA_signal_len)tema = if MA_signal_type == "TEMA"    ema = ema(close , MA_signal_len)    3 * (ema - ema(ema, MA_signal_len)) + ema(ema(ema, MA_signal_len), MA_signal_len)MA_signal           = matype_zone(close, MA_signal_len, MA_signal_type)/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////MACD_ZONE           = input(false, "Stgy №4:👉 MACD + MA-ZONE    ", inline="MAZONE", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="🚦🚦🚦 Condition 🚦🚦🚦\n\nBUY RULES:\n1st: MACD CrossOver Signal Line\n2nd: Close (Greater) than (MA-ZONE)\n\nSELL RULES:\n1st: MACD CrossUnder Signal Line\n2nd: Close (Less) than (MA-ZONE)")MA_zone_len         = input(title="", defval=21, type=input.integer, inline="MAZONE", group="CHOOSE YOUR DESIRE SIGNAL")MA_zone_type        = input(title="", defval="EMA", options=["SMA" , "EMA" , "RMA", "WMA" , "VWMA" , "DEMA", "TEMA"], inline="MAZONE", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="🚦🚦🚦 Condition 🚦🚦🚦\n\nBUY RULES:\n1st: MACD CrossOver Signal Line\n2nd: Close (Greater) than (MA-ZONE)\n\nSELL RULES:\n1st: MACD CrossUnder Signal Line\n2nd: Close (Less) than (MA-ZONE)")dema2 = if MA_zone_type == "DEMA"    ema = ema(close , MA_zone_len)    2 * ema - ema(ema , MA_zone_len)tema2 = if MA_zone_type == "TEMA"    ema = ema(close , MA_zone_len)    3 * (ema - ema(ema, MA_zone_len)) + ema(ema(ema, MA_zone_len), MA_zone_len)MA_zone_srcHi       = matype_signal(high, MA_zone_len, MA_zone_type)                                                                                        //      //MA_zone_srcLO       = matype_signal(low, MA_zone_len, MA_zone_type)/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////MACD_wid_rsiOB      = input(false, "Stgy №5:👉 MACD + RSI-OB", group="CHOOSE YOUR DESIRE SIGNAL")rsilen              = input(title="Length", defval=14, type=input.integer, inline="rsi", group="CHOOSE YOUR DESIRE SIGNAL")rsi_ent_value       = input(title="Entry", defval=50, type=input.integer, minval=1, inline="rsi", group="CHOOSE YOUR DESIRE SIGNAL", tooltip="🚦🚦🚦 Condition 🚦🚦🚦\n\nBUY Rule\nMACD Crossover Signal\nRSI Greater then Entry Level (You Choose)\n\n🚦🚦🚦 Explanation 🚦🚦🚦\nWe have RSI with 2 Levels,\n1st: Entry Level\n2nd: No-Entry Level\n\nEntry level:\nfor never want to BUY trade when RSI is Below our specific Level, like you want open Trade when RSI above 50 level or 30 level etc... \n\nNo-Entry Level:\nthis is same as (Entry Level) Condition, as we know RSI-70 level use for OverBought, and its mean market will go down after RSI-OB level, and thats why we can set overbought level for NO-ENTRY when Market is on OverBought area.")rsi_ob_value        = input(title="No-Entry", defval=70, minval=1, type=input.integer, inline="rsi", group="CHOOSE YOUR DESIRE SIGNAL")   RSI                 = rsi(close , rsilen)//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////startTime           =       input(title="Start Time                           ", type = input.time, defval = timestamp("01 Jan 2021 00:00 +0000"), inline="Backtesting Time Period")endTime             =       input(title="End Time                          ", type = input.time, defval = timestamp("01 Jan 2022 00:00 +0000"))inDateRange         =       (time >= startTime) and (time < endTime)bot_id = input(title="BOT ID       ", defval='', inline="bot", group="BOT SECTION")email_token = input(title="  Token", defval='', inline="bot", group="BOT SECTION")enter_msg = '{ "message_type": "bot", "bot_id":'+ bot_id + ', "email_token": "'+ email_token + '", "delay_seconds": 0 }'exit_msg = '{ "message_type": "bot", "bot_id":'+ bot_id + ', "email_token": "'+ email_token + '", "delay_seconds": 0 , "action": "close_at_market_price_all"}'// COPY PASTE THIS MSG TO TRADINGVIEW// {{strategy.order.alert_message}}// Stgy №1:👉 MACD Cross Signal CONDITION //////////////////////////////////////// ENTRY EXIT SECTION //////////////////////////////////////////////////////////// (( MACD + CLOSE ))                                                       ////if macd_crsovr and MACD_crs_signal and inDateRange                   ////    strategy.entry("BUY1", strategy.long, comment="S#1", alert_message=enter_msg)                     ////if macd_crsndr and MACD_crs_signal and inDateRange                  ////    strategy.close("BUY1", comment="x", alert_message=exit_msg)                                      ////////////////////////////////////////////////////////////////////////////////////// // Stgy №1 Ploting // plotshape(MACD_crs_signal ? macd_crsovr : na, title="Stgy Sign", color=color.blue, style=shape.labelup, text="MACD", textcolor=color.white, location=location.bottom)// plotshape(MACD_crs_signal ? macd_crsndr : na, title="Stgy Sign", color=color.maroon, style=shape.labeldown, text="MACD-x", textcolor=color.white, location=location.top)// ////////////////////////////////////////////////////////////////////////////////// Stgy №2:👉 MACD + OverBought CONDITION //////////////////////////////////////only_Trade_when     = MACD < MACD_OB_LVL and Signal < MACD_OB_LVL           ////macd_ob_buy         = macd_crsovr and only_Trade_when                       ////macd_ob_sell        = macd_crsndr                                           ////////////////////////////////////////////////////////////////////////////////////// ENTRY EXIT SECTION //////////////////////////////////////////////////////////// (( MACD + ZONE ))                                                        ////if macd_ob_buy and MACD_OB and inDateRange                                  ////    strategy.entry("BUY2", strategy.long, comment="S#2", alert_message=enter_msg)                     ////if macd_ob_sell and MACD_OB and inDateRange                                 ////    strategy.close("BUY2", comment="x", alert_message=exit_msg)                                      ////////////////////////////////////////////////////////////////////////////////////// plotshape(MACD_OB ? macd_ob_buy : na, title="Stgy Sign", color=color.blue, style=shape.labelup, text="M+OB", textcolor=color.white, location=location.bottom)// plotshape(MACD_OB ? macd_ob_sell : na, title="Stgy Sign", color=color.maroon, style=shape.labeldown, text="M+OB-x", textcolor=color.white, location=location.top)// ////////////////////////////////////////////////////////////////////////////////// Stgy №3:👉 MACD + CLOSE CONDITION ///////////////////////////////////////////macd_close_buy       = macd_crsovr and ( ( close > MA_signal or (close[1] > MA_signal[1]) or (close[2] > MA_signal[2]) or (close[3] > MA_signal[3]) )    or    ( close > dema  or (close[1] > dema[1]) or (close[2] > dema[2]) or (close[3] > dema[3]) )    or    ( close > tema  or (close[1] > tema[1]) or (close[2] > tema[2]) or (close[3] > tema[3]) ) ) macd_close_sell      = macd_crsndr and ( ( close > MA_signal or (close[1] < MA_signal[1]) or (close[2] < MA_signal[2]) or (close[3] < MA_signal[3]) )    or    ( close < dema  or (close[1] < dema[1]) or (close[2] < dema[2]) or (close[3] < dema[3]) )    or    ( close < tema  or (close[1] < tema[1]) or (close[2] < tema[2]) or (close[3] < tema[3]) ) )                  ////////////////////////////////////////////////////////////////////////////////////// ENTRY EXIT SECTION //////////////////////////////////////////////////////////// (( MACD + CLOSE ))                                                       ////if macd_close_buy and MACD_close and inDateRange                            ////    strategy.entry("BUY3", strategy.long, comment="S#3", alert_message=enter_msg)                     ////if macd_close_sell and MACD_close and inDateRange                           ////    strategy.close("BUY3", comment="x", alert_message=exit_msg)                                      ////////////////////////////////////////////////////////////////////////////////////// // Stgy №3 Ploting // plotshape(MACD_close ? macd_close_buy : na, title="Stgy Sign", color=color.blue, style=shape.labelup, text="MACD", textcolor=color.white, location=location.bottom)// plotshape(MACD_close ? macd_close_sell : na, title="Stgy Sign", color=color.maroon, style=shape.labeldown, text="MACD-x", textcolor=color.white, location=location.top)// ////////////////////////////////////////////////////////////////////////////////// Stgy №3:👉 MACD + MA-ZONE MACD + ZONE CONDITION /////////////////////////////macd_zone_buy       = macd_crsovr and ( ( close > MA_zone_srcHi or (close[1] > MA_zone_srcHi[1]) or (close[2] > MA_zone_srcHi[2]) or (close[3] > MA_zone_srcHi[3]) )    or      ( close > dema2 or (close[1] > dema2[1]) or (close[2] > dema2[2]) or (close[3] > dema2[3]) )    or      ( close > tema2 or (close[1] > tema2[1]) or (close[2] > tema2[2]) or (close[3] > tema2[3]) )   )            ////macd_zone_sell      = macd_crsndr and ( ( close < MA_zone_srcHi or (close[1] < MA_zone_srcHi[1]) or (close[2] < MA_zone_srcHi[2]) or (close[3] < MA_zone_srcHi[3]) )    or      ( close < dema2 or (close[1] < dema2[1]) or (close[2] < dema2[2]) or (close[3] < dema2[3]) )    or      ( close < tema2 or (close[1] < tema2[1]) or (close[2] < tema2[2]) or (close[3] < tema2[3]) )   )           ////////////////////////////////////////////////////////////////////////////////////// ENTRY EXIT SECTION //////////////////////////////////////////////////////////// (( MACD + ZONE ))                                                        ////if macd_zone_buy and MACD_ZONE and inDateRange                              ////    strategy.entry("BUY4", strategy.long, comment="S#4", alert_message=enter_msg)                     ////if macd_zone_sell and MACD_ZONE and inDateRange                             ////    strategy.close("BUY4", comment="x", alert_message=exit_msg)                                      ////////////////////////////////////////////////////////////////////////////////////// Stgy №5:👉 MACD + RSI-OB CONDITION //////////////////////////////////////////MACD_rsi_EnBuy         = RSI > rsi_ent_value and RSI < rsi_ob_value         ////MACD_rsi_EnSell         = RSI < rsi_ent_value           ////MACD_rsi_Ex       = crossunder(RSI , rsi_ob_value) or crossunder(RSI[1] , rsi_ob_value[1]) or crossunder(RSI[2] , rsi_ob_value[2]) or crossunder(RSI[3] , rsi_ob_value[3]) or crossunder(RSI[4] , rsi_ob_value[4]) or crossunder(RSI[5] , rsi_ob_value[5]) or crossunder(RSI[6] , rsi_ob_value[6])         ////                                                                            ////////////////////////////////////////////////////////////////////////////////////// ENTRY EXIT SECTION //////////////////////////////////////////////////////////// ((MACD + RSI-OB ))                                                       ////if macd_crsovr and MACD_rsi_EnBuy and MACD_wid_rsiOB and inDateRange        ////    strategy.entry("BUY5", strategy.long, comment="S#5", alert_message=enter_msg)                     ////if macd_crsndr and MACD_wid_rsiOB and inDateRange                           ////    strategy.close("BUY5", comment="x", alert_message=exit_msg)                                      ////////////////////////////////////////////////////////////////////////////////////if (not inDateRange)           ///    strategy.close_all()       /////////////////////////////////////// MACD COLORS SECTION /////////////////////////////////////////////////////////// ( Colors of [MACD and Signal-Line] )MACD_width          = input(title="MACD Line               ", defval=2, minval=1, type=input.integer, group="🚦🚦macd Width & Colors setting🚦🚦", inline="macdColor")MACD_color_High     = input(#11ff00, title="", type=input.color, group="🚦🚦macd Width & Colors setting🚦🚦", inline="macdColor")MACD_color_Low      = input(#e91e63, title="", type=input.color, group="🚦🚦macd Width & Colors setting🚦🚦", inline="macdColor")signal_width        = input(title="Signal Line               ", defval=2, minval=1, type=input.integer, group="🚦🚦macd Width & Colors setting🚦🚦", inline="signal")signalLine_col_hi   = input(#ffeb3b, title="", type=input.color, inline="signal", group="🚦🚦macd Width & Colors setting🚦🚦")signalLine_col_lo   = input(#ffeb3b, title="", type=input.color, inline="signal", group="🚦🚦macd Width & Colors setting🚦🚦")// ((Histogram Color)) /////////////////////////////////////////////////////////macd_hist_on        = input(true, "Histogram        ", inline="hist", group="🚦🚦macd Width & Colors setting🚦🚦")BuyStrongHist       = input(#26A69A, title="", type=input.color, inline="hist", group="🚦🚦macd Width & Colors setting🚦🚦")BuyWeakHist         = input(#B2DFDB, title="", type=input.color, inline="hist", group="🚦🚦macd Width & Colors setting🚦🚦")SellWeakHist        = input(#FFCDD2, title="✨", type=input.color, inline="hist", group="🚦🚦macd Width & Colors setting🚦🚦")SellStrongHist      = input(#FF5252, title="", type=input.color, inline="hist", group="🚦🚦macd Width & Colors setting🚦🚦")// ((FOR HISTOGRAM COLOR CONDITION))hist_col            = (histogram >= 0 ? (histogram[1] < histogram ? BuyStrongHist : BuyWeakHist) : histogram[1] < histogram ? SellWeakHist : SellStrongHist)// (( CROSSOVER DOT) ///////////////////////////////////////////////////////////macd_crsovr_dot_on  = input(true, "Cross               ", inline="dot", group="🚦🚦macd Width & Colors setting🚦🚦")macd_cross_width    = input(defval=5, title="", inline="dot", group="🚦🚦macd Width & Colors setting🚦🚦")dot_crsovr_col      = input(#ffffff, title="", type=input.color, inline="dot", group="🚦🚦macd Width & Colors setting🚦🚦")dot_crsndr_col      = input(color.new(#e91e63, 0), title="", type=input.color, inline="dot", group="🚦🚦macd Width & Colors setting🚦🚦")// (( MACD ZONE COLOR ))zone_on             = input(true, "Zone Color        ", inline="zone", group="🚦🚦macd Width & Colors setting🚦🚦")zone_crsovr_col     = input(color.new(color.lime, 70), title="", type=input.color, inline="zone", group="🚦🚦macd Width & Colors setting🚦🚦")zone_crsndr_col     = input(color.new(#e91e63, 70), title="", type=input.color, inline="zone", group="🚦🚦macd Width & Colors setting🚦🚦")///////////////////////////////////////// ((FOR MACD LINE COLOR CONDITION))MACD_line_col = if macd_grtr_signal    //    MACD_color_High                    //else                                   //    if macd_less_signal                //        MACD_color_Low                 /////////////////////////////////////////// ((FOR SIGNAL LINE COLOR CONDITION))signal_line_col = if macd_grtr_signal  //    signalLine_col_hi                  //else                                   //    if macd_less_signal                //        signalLine_col_lo              /////////////////////////////////////////// ((FOR MACD CROSS DOTs COLOR CONDITION))MACD_Dot_col = if macd_crsovr_signal   //    dot_crsovr_col                     //else                                   //    if macd_crsndr_signal              //        dot_crsndr_col                 ///////////////////////////////////////////////////////////////////////////////////////////////////zone_crsovr_plot = if macd_grtr_signal  and zone_on // ((For Zone Color Comdition + On/Off)) ///    zone_crsovr_col                                 ///////////////////////////////////////////else                                                //    if macd_less_signal and zone_on                 //        zone_crsndr_col                             ////////////////////////////////////////////////////////// MACD PLOTING //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////histplot    = plot(macd_hist_on ? histogram : na, title="Histogram", color=hist_col, style=plot.style_columns)macdplot    = plot(MACD, title="MACD", color=MACD_line_col, linewidth=MACD_width)signalplot  = plot(Signal, title="Signal", color=signal_line_col, linewidth=signal_width)fill(macdplot , signalplot, color=zone_crsovr_plot)plot(macd_crsovr_dot_on ? macd_crsovr_signal : na,  title="c-over", style=plot.style_circles, color=MACD_Dot_col, linewidth=macd_cross_width)plot(macd_crsovr_dot_on ? macd_crsndr_signal : na,  title="c-under", style=plot.style_circles, color=MACD_Dot_col, linewidth=macd_cross_width)///////////////////////////////////////////////////////////////////////////////donttouchzero = input(title="Want DVG when line below 0  ?        ", defval=true, inline="line", group=" ▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁")lbR = input(title="Pivot Lookback Right", defval=5, group=" ▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁")lbL = input(title="Pivot Lookback Left", defval=5, group=" ▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁")rangeUpper = input(title="Max of Lookback Range", defval=60, group=" ▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁")rangeLower = input(title="Min of Lookback Range", defval=5, group=" ▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁")plotBull = input(title="ON/OFF Bullish DVG", defval=true, group=" ▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁")plotHiddenBull = falseplotBear = input(title="ON/OFF Bearish DVG", defval=true, group=" ▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁")plotHiddenBear = falsebearColor = color.redbullColor = color.greenhiddenBullColor = color.new(color.green, 80)hiddenBearColor = color.new(color.red, 80)textColor = color.whitenoneColor = color.new(color.white, 100)osc = MACDplFound = na(pivotlow(osc, lbL, lbR)) ? false : truephFound = na(pivothigh(osc, lbL, lbR)) ? false : true_inRange(cond) =>    bars = barssince(cond == true)    rangeLower <= bars and bars <= rangeUpper//------------------------------------------------------------------------------// Regular Bullish// Osc: Higher LowoscHL = osc[lbR] > valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1]) and  osc[lbR] < 0// Price: Lower LowpriceLL         = low[lbR] < valuewhen(plFound, low[lbR], 1)priceHHZero     = highest(osc, lbL+lbR+5)LineDisplay     = input(false, "Line Display", inline="line", group=" ▁▂▃▄▅▆▇▉ MACD DIVERGENCE ▉▇▆▅▄▃▂▁")plot(LineDisplay ? priceHHZero : na, title="priceHHZero", color=color.lime)blowzero = donttouchzero ? priceHHZero < 0 : truebullCond = plotBull and priceLL and oscHL and plFound and blowzeroplot(     plFound ? osc[lbR] : na,     offset=-lbR,     title="Regular Bullish",     linewidth=2,     color=(bullCond ? bullColor : noneColor),     transp=0     )plotshape(     bullCond ? osc[lbR] : na,     offset=-lbR,     title="Regular Bullish Label",     text=" Bull ",     style=shape.labelup,     location=location.absolute,     color=bullColor,     textcolor=textColor,     transp=0     )//------------------------------------------------------------------------------// Hidden Bullish// Osc: Lower LowoscLL = osc[lbR] < valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1])// Price: Higher LowpriceHL = low[lbR] > valuewhen(plFound, low[lbR], 1)hiddenBullCond = plotHiddenBull and priceHL and oscLL and plFoundplot(     plFound ? osc[lbR] : na,     offset=-lbR,     title="Hidden Bullish",     linewidth=2,     color=(hiddenBullCond ? hiddenBullColor : noneColor),     transp=0     )plotshape(     hiddenBullCond ? osc[lbR] : na,     offset=-lbR,     title="Hidden Bullish Label",     text=" H Bull ",     style=shape.labelup,     location=location.absolute,     color=bullColor,     textcolor=textColor,     transp=0     )//------------------------------------------------------------------------------// Regular Bearish// Osc: Lower HighoscLH = osc[lbR] < valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1])  and osc[lbR] > 0priceLLZero =  lowest(osc, lbL+lbR+5) //plot(priceLLZero,title="priceLLZero", color=color.red)bearzero = donttouchzero ? priceLLZero > 0 : true// Price: Higher HighpriceHH = high[lbR] > valuewhen(phFound, high[lbR], 1)bearCond = plotBear and priceHH and oscLH and phFound and bearzeroplot(     phFound ? osc[lbR] : na,     offset=-lbR,     title="Regular Bearish",     linewidth=2,     color=(bearCond ? bearColor : noneColor),     transp=0     )plotshape(     bearCond ? osc[lbR] : na,     offset=-lbR,     title="Regular Bearish Label",     text=" Bear ",     style=shape.labeldown,     location=location.absolute,     color=bearColor,     textcolor=textColor,     transp=0     )//------------------------------------------------------------------------------// Hidden Bearish// Osc: Higher HighoscHH = osc[lbR] > valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1])// Price: Lower HighpriceLH = high[lbR] < valuewhen(phFound, high[lbR], 1)hiddenBearCond = plotHiddenBear and priceLH and oscHH and phFoundplot(     phFound ? osc[lbR] : na,     offset=-lbR,     title="Hidden Bearish",     linewidth=2,     color=(hiddenBearCond ? hiddenBearColor : noneColor),     transp=0     )plotshape(     hiddenBearCond ? osc[lbR] : na,     offset=-lbR,     title="Hidden Bearish Label",     text=" H Bear ",     style=shape.labeldown,     location=location.absolute,     color=bearColor,     textcolor=textColor,     transp=0     )