Pine Script v4 · Strategy
[Advanced] Hilega-Milega Indicator
A Pine Script v4 strategy built on RSI (close, 9), Crossover (rsi, myWMA) and Crossunder (rsi, myWMA). It has 25 order rules, 8 entries among them, and trades long only with the default settings. Exits use a stop loss and a profit target. Each trade commits 100 in cash and pays 0.1% commission. 28 settings; defaults include Length: 9, Level: 50 and O-BOUGHT 70.
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 [Advanced] Hilega-Milega Indicator repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did [Advanced] Hilega-Milega Indicator 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 [Advanced] Hilega-Milega Indicator 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 [Advanced] Hilega-Milega Indicator use a stop loss?
- Yes
- strategy.exit sets a stop on line 176.
- Does [Advanced] Hilega-Milega Indicator run in Zeal Terminal?
- Yes
- It compiles in 51 ms and runs 1,000 bars in 139 ms, in the browser.
BTCUSDT · 1D · default settings
- Plot
- Plot
- Plot
- UP Level
- Mid Level
- DN Level
- Winning trade
- Losing trade
- Equity
- Buy and hold
- 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.
-
Check
2 settings do nothing
“RSI)”, “With MA Signal)” are declared but never read.
-
Note
3 settings have no label
In the settings dialog ma_type2 (line 33), withMA_type (line 148), with_MALen (line 149) 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.
Upgrade and export
Written in Pine Script v4. The upgrade to v5 takes 1 step, one per version, each applied to the result of the one before. A last clean-v5 pass then types the settings and moves when = into if blocks, which v6 requires. Every step runs before and after on the same candles in Zeal Terminal's engine; a step whose results differ is shown but not offered as a download. Upgrades preserve behaviour: bugs are fixed in the Review, never silently here.
- Upgrading to v5 renames sma → ta.sma, ema → ta.ema, wma → ta.wma, vwma → ta.vwma, rsi → ta.rsi, crossover → ta.crossover, crossunder → ta.crossunder.
v4 → v5
Not verifiedNeither 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: sma → ta.sma
- Line 7: ema → ta.ema
- Line 8: wma → ta.wma
- Line 9: vwma → ta.vwma
38 more edits
- Line 12: sma → ta.sma
- Line 13: ema → ta.ema
- Line 14: wma → ta.wma
- Line 15: vwma → ta.vwma
- Line 18: sma → ta.sma
- Line 19: ema → ta.ema
- Line 20: wma → ta.wma
- Line 21: vwma → ta.vwma
- Line 24: input(type = input.integer) → input.int()
- Line 25: input(type = input.integer) → input.int()
- Line 27: input(type = input.integer) → input.int()
- Line 28: input(type = input.integer) → input.int()
- Line 31: input(type = input.integer) → input.int()
- Line 34: input(type = input.integer) → input.int()
- Line 36: input(type = input.time) → input.time()
- Line 37: input(type = input.time) → input.time()
- Line 40: rsi → ta.rsi
- Line 57: crossover → ta.crossover
- Line 59: crossunder → ta.crossunder
- Line 70: crossover → ta.crossover
- Line 72: crossunder → ta.crossunder
- Line 83: crossover → ta.crossover
- Line 83: crossover → ta.crossover
- Line 84: crossunder → ta.crossunder
- Line 84: crossunder → ta.crossunder
- Line 95: crossover → ta.crossover
- Line 97: crossunder → ta.crossunder
- Line 107: crossover → ta.crossover
- Line 109: crossunder → ta.crossunder
- Line 132: crossover → ta.crossover
- Line 133: crossunder → ta.crossunder
- Line 134: crossunder → ta.crossunder
- Line 136: crossunder → ta.crossunder
- Line 149: input(type = input.integer) → input.int()
- Line 152: input(type = input.float) → input.float()
- Line 153: input(type = input.float) → input.float()
- Line 158: crossover → ta.crossover
- Line 159: crossunder → ta.crossunder
⋯// © HamidBox-//@version=4+//@version=5strategy("H-M By HamidBox-YT", default_qty_type=strategy.cash, default_qty_value= 100, initial_capital=100, currency='USD', commission_type=strategy.commission.percent, commission_value=0.1)-ma(source, length, type) =>+ma(source, length, type_) =>- type == "SMA" ? sma(source , length) :+ type_ == "SMA" ? ta.sma(source , length) :- type == "EMA" ? ema(source , length) :+ type_ == "EMA" ? ta.ema(source , length) :- type == "WMA" ? wma(source , length) :+ type_ == "WMA" ? ta.wma(source , length) :- type == "VWMA" ? vwma(source , length) :+ type_ == "VWMA" ? ta.vwma(source , length) : na-WMA(source, length, type) =>+WMA(source, length, type_) =>- type == "SMA" ? sma(source , length) :+ type_ == "SMA" ? ta.sma(source , length) :- type == "EMA" ? ema(source , length) :+ type_ == "EMA" ? ta.ema(source , length) :- type == "WMA" ? wma(source , length) :+ type_ == "WMA" ? ta.wma(source , length) :- type == "VWMA" ? vwma(source , length) :+ type_ == "VWMA" ? ta.vwma(source , length) : na-WithMA(source, length, type) =>+WithMA(source, length, type_) =>- type == "SMA" ? sma(source , length) :+ type_ == "SMA" ? ta.sma(source , length) :- type == "EMA" ? ema(source , length) :+ type_ == "EMA" ? ta.ema(source , length) :- type == "WMA" ? wma(source , length) :+ type_ == "WMA" ? ta.wma(source , length) :- type == "VWMA" ? vwma(source , length) :+ type_ == "VWMA" ? ta.vwma(source , length) : narsi_inline = input(true , title="RSI Value)", inline="rsi")-rsiLength = input(title="Length:", type=input.integer, defval=9, minval=1, inline="rsi")+rsiLength = input.int(title="Length:", defval=9, minval=1, inline="rsi")-rsiLineM = input(title="Level:", type=input.integer, defval=50, minval=1, inline="rsi")+rsiLineM = input.int(title="Level:", defval=50, minval=1, inline="rsi")rsi_OSOBinline = input(true , title="RSI)", inline="rsiosob")-rsiLineU = input(title="O-BOUGHT", type=input.integer, defval=70, minval=1, inline="rsiosob")+rsiLineU = input.int(title="O-BOUGHT", defval=70, minval=1, inline="rsiosob")-rsiLineD = input(title="O-SOLD", type=input.integer, defval=30, minval=1, inline="rsiosob")+rsiLineD = input.int(title="O-SOLD", defval=30, minval=1, inline="rsiosob")ma_inline = input(true , title="Price-MA)", inline="ma")ma_type = input(title="Type", defval="EMA", options=["EMA","SMA","WMA","VWMA"], inline="ma")-emaLength = input(title="Length", type=input.integer, defval=3, inline="ma")+emaLength = input.int(title="Length", defval=3, inline="ma")wma_inline = input(true , title="Trending-MA)", inline="wma")ma_type2 = input(title="", defval="WMA", options=["EMA","SMA","WMA","VWMA"], inline="wma")-wmaLength = input(title="Length", type=input.integer, defval=21, inline="wma")+wmaLength = input.int(title="Length", defval=21, inline="wma")////////////////////////////////////////////////////////////////////////////////-startTime = input(title="Start Time", type = input.time, defval = timestamp("01 Jan 2021 00:00 +0000"), group="Backtest Time Period")+startTime = input.time(title="Start Time", defval = timestamp("01 Jan 2021 00:00 +0000"), group="Backtest Time Period")-endTime = input(title="End Time", type = input.time, defval = timestamp("01 Jan 2200 00:00 +0000"), group="Backtest Time Period")+endTime = input.time(title="End Time", defval = timestamp("01 Jan 2200 00:00 +0000"), group="Backtest Time Period")inDateRange = (time >= startTime) and (time < endTime)////////////////////////////////////////////////////////////////////////////////-rsi = rsi(close , rsiLength)+rsi = ta.rsi(close , rsiLength)r = plot(rsi_inline ? rsi : na, color=color.yellow, linewidth=2)⋯RSI_Cross = input(false, "RSI x Trending-MA", inline="wma_cross",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUT-rsiBuySignal = crossover(rsi , myWMA)+rsiBuySignal = ta.crossover(rsi , myWMA)plotshape(RSI_Cross ? rsiBuySignal : na, title="RSI Crossover", style=shape.labelup, location=location.bottom, color=color.green)-rsiSellSignal = crossunder(rsi , myWMA) +rsiSellSignal = ta.crossunder(rsi , myWMA) plotshape(RSI_Cross ? rsiSellSignal : na, title="RSI Crossunder", style=shape.labeldown, location=location.top, color=color.red)⋯MA_Cross = input(false, "MA x Trendin-MA",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUT-maBuySignal = crossover(EMA, myWMA)+maBuySignal = ta.crossover(EMA, myWMA)plotshape(MA_Cross ? maBuySignal : na, title="MA Cross", style=shape.circle, location=location.bottom, color=color.lime)-maSellSignal = crossunder(EMA , myWMA) +maSellSignal = ta.crossunder(EMA , myWMA) plotshape(MA_Cross ? maSellSignal : na, title="RSI Crossunder", style=shape.circle, location=location.top, color=color.maroon)⋯Mix = input(false, "RSI + EMA x Trending-MA",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUT-rsi_ma_buy = crossover(rsi , myWMA) and crossover(EMA, myWMA)+rsi_ma_buy = ta.crossover(rsi , myWMA) and ta.crossover(EMA, myWMA)-rsi_ma_sell = crossunder(rsi , myWMA) and crossunder(EMA, myWMA)+rsi_ma_sell = ta.crossunder(rsi , myWMA) and ta.crossunder(EMA, myWMA)plotshape(Mix ? rsi_ma_buy : na, title="RSI Crossunder", style=shape.circle, location=location.bottom, color=color.lime, size=size.tiny)⋯wma_cross = input(false, "Trending-MA x 50",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUT-wma_buy = crossover(myWMA , rsiLineM)+wma_buy = ta.crossover(myWMA , rsiLineM)plotshape(wma_cross ? wma_buy : na, title="WMA Cross", style=shape.diamond, location=location.bottom, color=color.aqua)-wma_sell = crossunder(myWMA , rsiLineM)+wma_sell = ta.crossunder(myWMA , rsiLineM)plotshape(wma_cross ? wma_sell : na, title="WMA Cross", style=shape.diamond, location=location.top, color=color.aqua)⋯rsi_50 = input(false, "RSI x 50",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUT-rsi_50_buy = crossover(rsi , rsiLineM)+rsi_50_buy = ta.crossover(rsi , rsiLineM)plotshape(rsi_50 ? rsi_50_buy : na, title="WMA Cross", style=shape.cross, location=location.bottom, color=color.purple)-rsi_50_sell = crossunder(rsi , rsiLineM)+rsi_50_sell = ta.crossunder(rsi , rsiLineM)plotshape(rsi_50 ? rsi_50_sell : na, title="WMA Cross", style=shape.cross, location=location.top, color=color.purple)⋯rsi_OB_OS = input(false, "RSI Over Sold/Bought",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUT-rsiBuy = crossover(rsi , rsiLineD)+rsiBuy = ta.crossover(rsi , rsiLineD)-rsiSell = crossunder(rsi, rsiLineU)+rsiSell = ta.crossunder(rsi, rsiLineU)-rsiExit = crossunder(rsi, rsiLineD)+rsiExit = ta.crossunder(rsi, rsiLineD)plotshape(rsi_OB_OS ? rsiBuy : na, title="RSI OB", style=shape.cross, location=location.bottom, color=color.purple)-plotshape(rsi_OB_OS ? crossunder(rsi, rsiLineU) : na, title="RSI OS", style=shape.cross, location=location.top, color=color.purple)+plotshape(rsi_OB_OS ? ta.crossunder(rsi, rsiLineU) : na, title="RSI OS", style=shape.cross, location=location.top, color=color.purple)plotshape(rsi_OB_OS ? rsiExit : na, title="RSI OS", style=shape.cross, location=location.bottom, color=color.red)⋯withMA_type = input(title="", defval="SMA", options=["EMA","SMA","WMA","VWMA"], inline="WITH MA", group="With MA")-with_MALen = input(title="", defval=9, type=input.integer, inline="WITH MA", group="With MA")+with_MALen = input.int(title="", defval=9, inline="WITH MA", group="With MA")// TAKE-PROFIT / STOP-LOSS Stop_Take_Vis = input(true, "TP-SL")-LongSLValue = input(title="SL %", type=input.float, defval=3, minval=0.5) * 0.01+LongSLValue = input.float(title="SL %", defval=3, minval=0.5) * 0.01-LongTPValue = input(title="TP %", type=input.float, defval=15, minval=0.5) * 0.01+LongTPValue = input.float(title="TP %", defval=15, minval=0.5) * 0.01LongSLDetermine = strategy.position_avg_price * (1 - LongSLValue)⋯with_ma = WithMA(close, with_MALen, withMA_type)-Close_buy_MA = crossover(close , with_ma)+Close_buy_MA = ta.crossover(close , with_ma)-Close_sell_MA = crossunder(close , with_ma)+Close_sell_MA = ta.crossunder(close , with_ma)// PLOT OPTION⋯Clean v5
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 23: input() → input.bool()
- Line 26: input() → input.bool()
- Line 29: input() → input.bool()
- Line 30: input() → input.string()
- Line 32: input() → input.bool()
- Line 33: input() → input.string()
11 more edits
- Line 56: input() → input.bool()
- Line 69: input() → input.bool()
- Line 82: input() → input.bool()
- Line 94: input() → input.bool()
- Line 106: input() → input.bool()
- Line 119: input() → input.bool()
- Line 131: input() → input.bool()
- Line 147: input() → input.bool()
- Line 148: input() → input.string()
- Line 151: input() → input.bool()
- Line 161: input() → input.bool()
⋯ na-rsi_inline = input(true , title="RSI Value)", inline="rsi")+rsi_inline = input.bool(true , title="RSI Value)", inline="rsi")rsiLength = input.int(title="Length:", defval=9, minval=1, inline="rsi")rsiLineM = input.int(title="Level:", defval=50, minval=1, inline="rsi")-rsi_OSOBinline = input(true , title="RSI)", inline="rsiosob")+rsi_OSOBinline = input.bool(true , title="RSI)", inline="rsiosob")rsiLineU = input.int(title="O-BOUGHT", defval=70, minval=1, inline="rsiosob")rsiLineD = input.int(title="O-SOLD", defval=30, minval=1, inline="rsiosob")-ma_inline = input(true , title="Price-MA)", inline="ma")+ma_inline = input.bool(true , title="Price-MA)", inline="ma")-ma_type = input(title="Type", defval="EMA", options=["EMA","SMA","WMA","VWMA"], inline="ma")+ma_type = input.string(title="Type", defval="EMA", options=["EMA","SMA","WMA","VWMA"], inline="ma")emaLength = input.int(title="Length", defval=3, inline="ma")-wma_inline = input(true , title="Trending-MA)", inline="wma")+wma_inline = input.bool(true , title="Trending-MA)", inline="wma")-ma_type2 = input(title="", defval="WMA", options=["EMA","SMA","WMA","VWMA"], inline="wma")+ma_type2 = input.string(title="", defval="WMA", options=["EMA","SMA","WMA","VWMA"], inline="wma")wmaLength = input.int(title="Length", defval=21, inline="wma")⋯///////////////////////////////////////////////////////////////////////////////-RSI_Cross = input(false, "RSI x Trending-MA", inline="wma_cross",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUT+RSI_Cross = input.bool(false, "RSI x Trending-MA", inline="wma_cross",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUTrsiBuySignal = ta.crossover(rsi , myWMA)⋯////////////////////////////////////////////////////////////////////////////////-MA_Cross = input(false, "MA x Trendin-MA",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUT+MA_Cross = input.bool(false, "MA x Trendin-MA",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUTmaBuySignal = ta.crossover(EMA, myWMA)⋯////////////////////////////////////////////////////////////////////////////////-Mix = input(false, "RSI + EMA x Trending-MA",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUT+Mix = input.bool(false, "RSI + EMA x Trending-MA",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUTrsi_ma_buy = ta.crossover(rsi , myWMA) and ta.crossover(EMA, myWMA)⋯////////////////////////////////////////////////////////////////////////////////-wma_cross = input(false, "Trending-MA x 50",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUT+wma_cross = input.bool(false, "Trending-MA x 50",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUTwma_buy = ta.crossover(myWMA , rsiLineM)⋯////////////////////////////////////////////////////////////////////////////////-rsi_50 = input(false, "RSI x 50",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUT+rsi_50 = input.bool(false, "RSI x 50",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUTrsi_50_buy = ta.crossover(rsi , rsiLineM)⋯////////////////////////////////////////////////////////////////////////////////-RSI_OS_OB = input(false, "RSI OS/OB x Trending-MA",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUT+RSI_OS_OB = input.bool(false, "RSI OS/OB x Trending-MA",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUTrsi_OB_buy = (rsi < rsiLineD or rsi[1] < rsiLineD[1] or rsi[2] < rsiLineD[2] or rsi[3] < rsiLineD[3] or rsi[4] < rsiLineD[4] or rsi[5] < rsiLineD[5]) and rsiBuySignal ⋯////////////////////////////////////////////////////////////////////////////////-rsi_OB_OS = input(false, "RSI Over Sold/Bought",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUT+rsi_OB_OS = input.bool(false, "RSI Over Sold/Bought",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUTrsiBuy = ta.crossover(rsi , rsiLineD)⋯////////////////////////////////////////////////////////////////////////////////-With_MA_Vis = input(true , title="With MA Signal)", inline="WITH MA", group="With MA")+With_MA_Vis = input.bool(true , title="With MA Signal)", inline="WITH MA", group="With MA")-withMA_type = input(title="", defval="SMA", options=["EMA","SMA","WMA","VWMA"], inline="WITH MA", group="With MA")+withMA_type = input.string(title="", defval="SMA", options=["EMA","SMA","WMA","VWMA"], inline="WITH MA", group="With MA")with_MALen = input.int(title="", defval=9, inline="WITH MA", group="With MA")// TAKE-PROFIT / STOP-LOSS -Stop_Take_Vis = input(true, "TP-SL")+Stop_Take_Vis = input.bool(true, "TP-SL")LongSLValue = input.float(title="SL %", defval=3, minval=0.5) * 0.01⋯// PLOT OPTION-WithMaSignal = input(false, "MA + RSI x Trending-MA",group="With MA") // INPUT+WithMaSignal = input.bool(false, "MA + RSI x Trending-MA",group="With MA") // INPUT// CONDITION IN VARIABLE⋯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("H-M By HamidBox-YT", default_qty_type=strategy.cash, default_qty_value= 100, initial_capital=100, currency='USD', commission_type=strategy.commission.percent, commission_value=0.1)⋯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 |
|---|---|---|---|
| RSI Value) | true | bool | r plot |
| Length: | 9 | int (written input.integer) · min 1 | rsi |
| Level: | 50 | int (written input.integer) · min 1 | Mid Level wma_buy wma_sell rsi_50_buy rsi_50_sell |
| RSI) | true | bool | unused |
| O-BOUGHT | 70 | int (written input.integer) · min 1 | UP Level rsi_OS_sell rsiSell RSI OS |
| O-SOLD | 30 | int (written input.integer) · min 1 | DN Level rsi_OB_buy rsiBuy rsiExit |
| Price-MA) | true | bool | e plot |
| Type | EMA | string · options ["EMA","SMA","WMA","VWMA"] | EMA |
| Length | 3 | int (written input.integer) | EMA |
| Trending-MA) | true | bool | w plot |
| MA type2 (no label in the script) | WMA | string · options ["EMA","SMA","WMA","VWMA"] | myWMA |
| Length | 21 | int (written input.integer) | myWMA |
| TP-SL | true | bool | exit BUY line 175 |
| SL % | 3 | float · min 0.5 | LongSLDetermine |
| TP % | 15 | float · min 0.5 | LongTPDetermine |
| Backtest Time Period | |||
| Start Time | timestamp("01 Jan 2021 00:00 +0000") | time | inDateRange |
| End Time | timestamp("01 Jan 2200 00:00 +0000") | time | inDateRange |
| 👇 🚦 --- Backtesting Signals Type --- 🚦 | |||
| RSI x Trending-MA | false | bool | entry RSIxWMA close RSIxWMA RSI Crossover RSI Crossunder line 61 line 63 |
| MA x Trendin-MA | false | bool | entry MAxWMA close MAxWMA MA Cross RSI Crossunder line 74 line 76 |
| RSI + EMA x Trending-MA | false | bool | entry RSI+EMA x WMA close RSI+EMA x WMA RSI Crossunder line 87 line 89 |
| Trending-MA x 50 | false | bool | entry WMA x 50 close WMA x 50 WMA Cross line 99 line 101 |
| RSI x 50 | false | bool | entry RSI Cross 50 close RSI Cross 50 WMA Cross line 111 line 113 |
| RSI OS/OB x Trending-MA | false | bool | entry RSI-OBOS x WMA close RSI-OBOS x WMA RSI OB + Cross RSI OS + Cross line 124 line 126 |
| RSI Over Sold/Bought | false | bool | entry RSI OB close RSI OB RSI OB RSI OS line 138 line 140 |
| With MA | |||
| With MA Signal) | true | bool | unused |
| With MA type (no label in the script) | SMA | string · options ["EMA","SMA","WMA","VWMA"] | with_ma |
| With MALen (no label in the script) | 9 | int (written input.integer) | with_ma |
| MA + RSI x Trending-MA | false | bool | withMA_RSI_BUY withMA_RSI_SELL With MA |
What it calculates
- RSI (
rsi,ta.rsiin v5)close, Length: (9)rsi · line 40 - Crossover (
crossover,ta.crossoverin v5)rsi, myWMArsiBuySignal · line 57 - Crossunder (
crossunder,ta.crossunderin v5)rsi, myWMArsiSellSignal · line 59 - Crossover (
crossover,ta.crossoverin v5)EMA, myWMAmaBuySignal · line 70 - Crossunder (
crossunder,ta.crossunderin v5)EMA, myWMAmaSellSignal · line 72 - Crossover (
crossover,ta.crossoverin v5)myWMA, Level: (50)wma_buy · line 95 - Crossunder (
crossunder,ta.crossunderin v5)myWMA, Level: (50)wma_sell · line 97 - Crossover (
crossover,ta.crossoverin v5)rsi, Level: (50)rsi_50_buy · line 107 - Crossunder (
crossunder,ta.crossunderin v5)rsi, Level: (50)rsi_50_sell · line 109 - Crossover (
crossover,ta.crossoverin v5)rsi, O-SOLD (30)rsiBuy · line 132 - Crossunder (
crossunder,ta.crossunderin v5)rsi, O-BOUGHT (70)rsiSell · line 133 - Crossunder (
crossunder,ta.crossunderin v5)rsi, O-SOLD (30)rsiExit · line 134 - Crossover (
crossover,ta.crossoverin v5)close, with_maClose_buy_MA · line 158 - Crossunder (
crossunder,ta.crossunderin v5)close, with_maClose_sell_MA · line 159
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 86 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 RSIxWMA long | rsiBuySignal and RSI_Cross and inDateRange | On | 62 |
| Close RSIxWMA | rsiSellSignal and RSI_Cross and inDateRange | On | 64 |
| Close | (not inDateRange) | On | 66 |
| Open MAxWMA long | maBuySignal and MA_Cross and inDateRange | On | 75 |
| Close MAxWMA | maSellSignal and MA_Cross and inDateRange | On | 77 |
| Close | (not inDateRange) | On | 79 |
| Open RSI+EMA x WMA long | rsi_ma_buy and Mix and inDateRange | On | 88 |
| Close RSI+EMA x WMA | rsi_ma_sell and Mix and inDateRange | On | 90 |
| Close | (not inDateRange) | On | 92 |
| Open WMA x 50 long | wma_buy and wma_cross and inDateRange | On | 100 |
| Close WMA x 50 | wma_sell and wma_cross and inDateRange | On | 102 |
| Close | (not inDateRange) | On | 104 |
| Open RSI Cross 50 long | rsi_50_buy and rsi_50 and inDateRange | On | 112 |
| Close RSI Cross 50 | rsi_50_sell and rsi_50 and inDateRange | On | 114 |
| Close | (not inDateRange) | On | 116 |
| Open RSI-OBOS x WMA long | rsi_OB_buy and RSI_OS_OB and inDateRange | On | 125 |
| Close RSI-OBOS x WMA | rsi_OS_sell and RSI_OS_OB and inDateRange | On | 127 |
| Close | (not inDateRange) | On | 129 |
| Open RSI OB long | rsiBuy and rsi_OB_OS and inDateRange | On | 139 |
| Close RSI OB | (rsiSell or rsiExit) and rsi_OB_OS and inDateRange | On | 141 |
| Close | (not inDateRange) | On | 143 |
| Open MA + RSIxWMA long | withMA_RSI_BUY | On | 169 |
| Close MA + RSIxWMA | withMA_RSI_SELL | On | 171 |
| Close | (not inDateRange) | On | 173 |
| Exit BUY stop and limit | (strategy.position_size > 0) and Stop_Take_Vis | On | 176 |
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.
- 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 | 0.0% | +102.5% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BTCUSDT 4h | 0.0% | +5.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| ETHUSDT 1D | 0.0% | +9.8% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| ETHUSDT 4h | 0.0% | +8.4% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| SOLUSDT 1D | 0.0% | +16.7% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| SOLUSDT 4h | 0.0% | +21.5% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
| BNBUSDT 1D | 0.0% | +148.3% | 0 | 0% | — | 0.0% | 26 Jan 2024 – 21 Oct 2026 |
| BNBUSDT 4h | 0.0% | +17.1% | 0 | 0% | — | 0.0% | 8 May 2026 – 21 Oct 2026 |
Backtests are simulations on historical data and are not investment advice.
Settings heatmap
Two settings that feed the entry signal, moved around their defaults. The best in-sample pair (Length: 5, O-SOLD 15) made 0.0% before 26 Dec 2025 and 0.0% after it, against 0.0% for the defaults. 0% of the 56 combinations made money in-sample and 0% out-of-sample.
| O-SOLD ↓ · Length: → | 5 | 6 | 8 | 9 | 11 | 13 | 15 |
|---|---|---|---|---|---|---|---|
| 15 | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 18 | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 21 | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 26 | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 30 | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 36 | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 42 | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 51 | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| O-SOLD ↓ · Length: → | 5 | 6 | 8 | 9 | 11 | 13 | 15 |
|---|---|---|---|---|---|---|---|
| 15 | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 18 | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 21 | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 26 | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 30 | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 36 | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 42 | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
| 51 | 0% | 0% | 0% | 0% | 0% | 0% | 0% |
Net P&L of trades opened in each period, as a share of starting capital. marks the defaults and the best in-sample cell. Hover a cell for its trade count. 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.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| [Advanced] Hilega-Milega Indicator this page | — | v4 strategy | 0.0% | 0 | 0.0% |
| Triple RSI strategy by Trade_by_DB | rsi | v5 strategy | +3.2% | 2 | 3.3% |
| Hobbiecode - RSI + Close previous day by hobbiecode | rsi | v5 strategy | +1.2% | 63 | 4.2% |
| dirt cheap yet elegant RSI Strategy by SparkyFlary | rsi | v4 strategy | −11.4% | 8 | 20.5% |
| RSI Classic Strategy (by Coinrule) by Coinrule | rsi | v4 strategy | +7.5% | 6 | 7.2% |
| RSITrendStrategy by email_analysts | rsi | v4 strategy | +69.2% | 22 | 38.6% |
Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 51 ms | Yes 1,000 bars in 139 ms | Not measured |
| PineTS | No 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("H-M By HamidBox-YT", default_qty_type=strategy.cash, default_qty_value= 100, initial_capital=100, currency='USD', commission_type=strategy.commission.percent, commission_value=0.1)ma(source, length, type) => type == "SMA" ? sma(source , length) : type == "EMA" ? ema(source , length) : type == "WMA" ? wma(source , length) : type == "VWMA" ? vwma(source , length) : naWMA(source, length, type) => type == "SMA" ? sma(source , length) : type == "EMA" ? ema(source , length) : type == "WMA" ? wma(source , length) : type == "VWMA" ? vwma(source , length) : naWithMA(source, length, type) => type == "SMA" ? sma(source , length) : type == "EMA" ? ema(source , length) : type == "WMA" ? wma(source , length) : type == "VWMA" ? vwma(source , length) : narsi_inline = input(true , title="RSI Value)", inline="rsi")rsiLength = input(title="Length:", type=input.integer, defval=9, minval=1, inline="rsi")rsiLineM = input(title="Level:", type=input.integer, defval=50, minval=1, inline="rsi")rsi_OSOBinline = input(true , title="RSI)", inline="rsiosob")rsiLineU = input(title="O-BOUGHT", type=input.integer, defval=70, minval=1, inline="rsiosob")rsiLineD = input(title="O-SOLD", type=input.integer, defval=30, minval=1, inline="rsiosob")ma_inline = input(true , title="Price-MA)", inline="ma")ma_type = input(title="Type", defval="EMA", options=["EMA","SMA","WMA","VWMA"], inline="ma")emaLength = input(title="Length", type=input.integer, defval=3, inline="ma")wma_inline = input(true , title="Trending-MA)", inline="wma")ma_type2 = input(title="", defval="WMA", options=["EMA","SMA","WMA","VWMA"], inline="wma")wmaLength = input(title="Length", type=input.integer, defval=21, inline="wma")////////////////////////////////////////////////////////////////////////////////startTime = input(title="Start Time", type = input.time, defval = timestamp("01 Jan 2021 00:00 +0000"), group="Backtest Time Period")endTime = input(title="End Time", type = input.time, defval = timestamp("01 Jan 2200 00:00 +0000"), group="Backtest Time Period")inDateRange = (time >= startTime) and (time < endTime)////////////////////////////////////////////////////////////////////////////////rsi = rsi(close , rsiLength)r = plot(rsi_inline ? rsi : na, color=color.yellow, linewidth=2)EMA = ma(rsi, emaLength, ma_type)e = plot(ma_inline ? EMA : na, color=color.lime)myWMA = ma(rsi, wmaLength, ma_type2)w = plot(wma_inline ? myWMA : na, color=color.white, linewidth=2)up = hline(rsiLineU, title='UP Level', linewidth=1, color=color.red, linestyle=hline.style_dotted)mid = hline(rsiLineM, title='Mid Level', linewidth=2, color=color.white, linestyle=hline.style_dotted)dn = hline(rsiLineD, title='DN Level', linewidth=1, color=color.green, linestyle=hline.style_dotted)col_e_w = EMA > myWMA ? color.new(color.green , 85) : color.new(color.red , 85)col_r_w = rsi > myWMA ? color.new(color.green , 85) : color.new(color.red , 85)fill(e , w, color=col_e_w)fill(r , w, color=col_r_w)//////////////////////////////////////////////////////////////////////////////////Signals = input(true,group="👇 🚦 --- Backtesting Signals Type --- 🚦 ")///////////////////////////////////////////////////////////////////////////////RSI_Cross = input(false, "RSI x Trending-MA", inline="wma_cross",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUTrsiBuySignal = crossover(rsi , myWMA)plotshape(RSI_Cross ? rsiBuySignal : na, title="RSI Crossover", style=shape.labelup, location=location.bottom, color=color.green)rsiSellSignal = crossunder(rsi , myWMA) plotshape(RSI_Cross ? rsiSellSignal : na, title="RSI Crossunder", style=shape.labeldown, location=location.top, color=color.red)if rsiBuySignal and RSI_Cross and inDateRange strategy.entry("RSIxWMA", strategy.long)if rsiSellSignal and RSI_Cross and inDateRange strategy.close("RSIxWMA", comment="x")if (not inDateRange) strategy.close_all() ////////////////////////////////////////////////////////////////////////////////MA_Cross = input(false, "MA x Trendin-MA",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUTmaBuySignal = crossover(EMA, myWMA)plotshape(MA_Cross ? maBuySignal : na, title="MA Cross", style=shape.circle, location=location.bottom, color=color.lime)maSellSignal = crossunder(EMA , myWMA) plotshape(MA_Cross ? maSellSignal : na, title="RSI Crossunder", style=shape.circle, location=location.top, color=color.maroon)if maBuySignal and MA_Cross and inDateRange strategy.entry("MAxWMA", strategy.long)if maSellSignal and MA_Cross and inDateRange strategy.close("MAxWMA", comment="x")if (not inDateRange) strategy.close_all() ////////////////////////////////////////////////////////////////////////////////Mix = input(false, "RSI + EMA x Trending-MA",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUTrsi_ma_buy = crossover(rsi , myWMA) and crossover(EMA, myWMA)rsi_ma_sell = crossunder(rsi , myWMA) and crossunder(EMA, myWMA)plotshape(Mix ? rsi_ma_buy : na, title="RSI Crossunder", style=shape.circle, location=location.bottom, color=color.lime, size=size.tiny)plotshape(Mix ? rsi_ma_sell : na, title="RSI Crossunder", style=shape.circle, location=location.top, color=color.yellow, size=size.tiny)if rsi_ma_buy and Mix and inDateRange strategy.entry("RSI+EMA x WMA", strategy.long)if rsi_ma_sell and Mix and inDateRange strategy.close("RSI+EMA x WMA", comment="x")if (not inDateRange) strategy.close_all()////////////////////////////////////////////////////////////////////////////////wma_cross = input(false, "Trending-MA x 50",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUTwma_buy = crossover(myWMA , rsiLineM)plotshape(wma_cross ? wma_buy : na, title="WMA Cross", style=shape.diamond, location=location.bottom, color=color.aqua)wma_sell = crossunder(myWMA , rsiLineM)plotshape(wma_cross ? wma_sell : na, title="WMA Cross", style=shape.diamond, location=location.top, color=color.aqua)if wma_buy and wma_cross and inDateRange strategy.entry("WMA x 50", strategy.long)if wma_sell and wma_cross and inDateRange strategy.close("WMA x 50", comment="x")if (not inDateRange) strategy.close_all()////////////////////////////////////////////////////////////////////////////////rsi_50 = input(false, "RSI x 50",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUTrsi_50_buy = crossover(rsi , rsiLineM)plotshape(rsi_50 ? rsi_50_buy : na, title="WMA Cross", style=shape.cross, location=location.bottom, color=color.purple)rsi_50_sell = crossunder(rsi , rsiLineM)plotshape(rsi_50 ? rsi_50_sell : na, title="WMA Cross", style=shape.cross, location=location.top, color=color.purple)if rsi_50_buy and rsi_50 and inDateRange strategy.entry("RSI Cross 50", strategy.long)if rsi_50_sell and rsi_50 and inDateRange strategy.close("RSI Cross 50", comment="x")if (not inDateRange) strategy.close_all() ////////////////////////////////////////////////////////////////////////////////RSI_OS_OB = input(false, "RSI OS/OB x Trending-MA",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUTrsi_OB_buy = (rsi < rsiLineD or rsi[1] < rsiLineD[1] or rsi[2] < rsiLineD[2] or rsi[3] < rsiLineD[3] or rsi[4] < rsiLineD[4] or rsi[5] < rsiLineD[5]) and rsiBuySignal plotshape(RSI_OS_OB ? rsi_OB_buy : na, title="RSI OB + Cross", style=shape.circle, location=location.bottom, color=color.lime, size=size.tiny)rsi_OS_sell = (rsi > rsiLineU or rsi[1] > rsiLineU[1] or rsi[2] > rsiLineU[2] or rsi[3] > rsiLineU[3] or rsi[4] > rsiLineU[4] or rsi[5] > rsiLineU[5]) and maSellSignal plotshape(RSI_OS_OB ? rsi_OS_sell : na, title="RSI OS + Cross", style=shape.circle, location=location.top, color=color.red, size=size.tiny)if rsi_OB_buy and RSI_OS_OB and inDateRange strategy.entry("RSI-OBOS x WMA", strategy.long)if rsi_OS_sell and RSI_OS_OB and inDateRange strategy.close("RSI-OBOS x WMA", comment="x")if (not inDateRange) strategy.close_all()////////////////////////////////////////////////////////////////////////////////rsi_OB_OS = input(false, "RSI Over Sold/Bought",group="👇 🚦 --- Backtesting Signals Type --- 🚦 ") // INPUTrsiBuy = crossover(rsi , rsiLineD)rsiSell = crossunder(rsi, rsiLineU)rsiExit = crossunder(rsi, rsiLineD)plotshape(rsi_OB_OS ? rsiBuy : na, title="RSI OB", style=shape.cross, location=location.bottom, color=color.purple)plotshape(rsi_OB_OS ? crossunder(rsi, rsiLineU) : na, title="RSI OS", style=shape.cross, location=location.top, color=color.purple)plotshape(rsi_OB_OS ? rsiExit : na, title="RSI OS", style=shape.cross, location=location.bottom, color=color.red)if rsiBuy and rsi_OB_OS and inDateRange strategy.entry("RSI OB", strategy.long)if (rsiSell or rsiExit) and rsi_OB_OS and inDateRange strategy.close("RSI OB", comment="x")if (not inDateRange) strategy.close_all() ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////With_MA_Vis = input(true , title="With MA Signal)", inline="WITH MA", group="With MA")withMA_type = input(title="", defval="SMA", options=["EMA","SMA","WMA","VWMA"], inline="WITH MA", group="With MA")with_MALen = input(title="", defval=9, type=input.integer, inline="WITH MA", group="With MA")// TAKE-PROFIT / STOP-LOSS Stop_Take_Vis = input(true, "TP-SL")LongSLValue = input(title="SL %", type=input.float, defval=3, minval=0.5) * 0.01LongTPValue = input(title="TP %", type=input.float, defval=15, minval=0.5) * 0.01LongSLDetermine = strategy.position_avg_price * (1 - LongSLValue)LongTPDetermine = strategy.position_avg_price * (1 + LongTPValue)//////////////////////////with_ma = WithMA(close, with_MALen, withMA_type)Close_buy_MA = crossover(close , with_ma)Close_sell_MA = crossunder(close , with_ma)// PLOT OPTIONWithMaSignal = input(false, "MA + RSI x Trending-MA",group="With MA") // INPUT// CONDITION IN VARIABLEwithMA_RSI_BUY = (Close_buy_MA and rsiBuySignal) and WithMaSignal and inDateRangewithMA_RSI_SELL = (Close_sell_MA and rsiSellSignal) and WithMaSignal and inDateRange// PLOT INGplotshape(WithMaSignal ? withMA_RSI_BUY : na, title="With MA", style=shape.diamond, location=location.bottom, color=color.aqua)plotshape(WithMaSignal ? withMA_RSI_SELL : na, title="With MA", style=shape.diamond, location=location.top, color=color.aqua)if withMA_RSI_BUY strategy.entry("MA + RSIxWMA", strategy.long)if withMA_RSI_SELL strategy.close("MA + RSIxWMA", comment="x")if (not inDateRange) strategy.close_all()// FOR SL - TPif (strategy.position_size > 0) and Stop_Take_Vis strategy.exit("BUY", stop=LongSLDetermine, limit=LongTPDetermine)