Pine Script v5 · Strategy
BankNifty_Bullish_Intraday
A Pine Script v5 strategy built on MACD (close[0], 12), RSI (close, 14) and DMI (14, 14). It has 2 order rules, 2 entries among them, and trades long and short with the default settings. Exits wait for a signal; there is no stop loss. Each trade is one contract and pays no commission. 3 settings; defaults include Stochastic Length 14, %K Smoothing 3 and %D Smoothing 3.
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 BankNifty_Bullish_Intraday repaint?
- No
- No repainting patterns were found in the source. The live replay was not measured: it had no trades to compare.
- How did BankNifty_Bullish_Intraday 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; it opened a short position that was still open on the last bar, so there is no result to report. It closed no trades on the other markets either. A backtest, not investment advice.
- Does BankNifty_Bullish_Intraday run in Pine Script v6?
- No
- The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 0 before, 2 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download.
- Does BankNifty_Bullish_Intraday use a stop loss?
- No
- Every exit waits for a signal; nothing limits a losing trade before it fires.
- Does BankNifty_Bullish_Intraday run in Zeal Terminal?
- Yes
- It compiles in 12 ms and runs 1,000 bars in 31 ms, in the browser.
BTCUSDT · 1D · default settings
- Winning trade
- Losing trade
- Equity
- Buy and hold
Needs BINANCE:BTCUSDT 5 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Needs BINANCE:BTCUSDT 15 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Needs BINANCE:BTCUSDT 60 data, not available: a lower timeframe than the chart; the engine does not evaluate intrabar data Values that depend on it are empty on this chart.
- Net profit
- 0.00%
- $0.00
- Buy and hold
- +102.5%
- same period
- Closed trades
- 0
- 0 won · 0 lost
- Profitable
- 0.0%
- of closed trades
- Profit factor
- —
- gross profit ÷ gross loss
- Max drawdown
- 8.36%
- −$83,616.80
One run with the author's default settings, $1,000,000 starting capital, commission as the script sets it. A short position was still open at the last bar. A single backtest says little about future results and is not a recommendation. Backtests are simulations on historical data and are not investment advice.
Review
What a careful reader of this script would point out, found by checking the source and the backtest.
-
Check
No stop loss
Every exit waits for a signal. Nothing limits a losing trade before the exit condition fires.
-
Check
No commission
The backtest assumes free trading. Results on any real exchange will be lower.
-
Note
No slippage
Fills are assumed at the exact open price. Add slippage in the properties for a more realistic test.
Settings
Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.
| Setting | Default | Type and range | Feeds |
|---|---|---|---|
| Stochastic Length | 14 | int | k |
| %K Smoothing | 3 | int | k |
| %D Smoothing | 3 | int | d |
What it calculates
- MACDclose[0], 12, 26, 9
macdLine · line 22 - MACDclose[0], 12, 26, 9
signalLine · line 22 - MACDclose[0], 12, 26, 9
histLine · line 22 - RSIclose, 14
xRSI · line 29 - DMI14, 14
diplus · line 32 - DMI14, 14
diminus · line 32 - DMI14, 14
adx · line 32 - SMA / Stochta.stoch(close, high, low, StochLength), %K Smoothing (3)
k · line 36 - SMAk, %D Smoothing (3)
d · line 37 - BBclose, 20, 2
middle · line 40 - BBclose, 20, 2
upper · line 40 - BBclose, 20, 2
lower · line 40
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.
Order rules
| Order | Fires when | By default | Line |
|---|---|---|---|
| Open Buy long | (longCondition) | On | 67 |
| Open BuySquareoff short | (shortCondition) | On | 70 |
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 data3 request.security call(s), none with lookahead on.
- 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
Not run on other markets: the script requests BINANCE:BTCUSDT 5, BINANCE:BTCUSDT 15, BINANCE:BTCUSDT 60, and that data is not available here (a lower timeframe than the chart; the engine does not evaluate intrabar data; a lower timeframe than the chart; the engine does not evaluate intrabar data; a lower timeframe than the chart; the engine does not evaluate intrabar data). Its results would rest on empty values.
Similar scripts
Indicators and strategies built from the same calculations, run on BTCUSDT 1D with their own defaults so they can be compared directly.
| Script | Shares | Type | Net | Trades | Max drawdown |
|---|---|---|---|---|---|
| BankNifty_Bullish_Intraday this page | — | v5 strategy | 0.0% | 0 | 8.4% |
| BankNifty_Bearish_Intraday by makarandpatil | macd rsi dmi sma bb | v5 strategy | No trades on this market | ||
| adx efi 50 ema channel, trend pullback by trent777brown | bb macd dmi rsi sma stoch | v5 strategy | No trades on this market | ||
| PowerX by jwitt98 by jwitt98 | rsi sma macd | v5 strategy | +107.9% | 78 | 107.8% |
| Bollinger Bands strategy with RSI and MACD v1.0 by juliangonzaconde | rsi macd bb | v4 strategy | No trades on this market | ||
| Simple Buy-Sell Strategy by BlockchainSpecialists | sma macd rsi | v4 strategy | +43.7% | 6 | 15.5% |
Upgrade and export
Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.
- 3 settings use the untyped input() (line 14, 15, 16). It still compiles in v6; input.int, input.float or input.source state the type.
- No v6-only features. v6 is not needed to run this script.
Clean v5
Not verifiedNeither version placed a trade on any of the 8 markets, so there was nothing to compare.
- Line 14: input() → input.int()
- Line 15: input() → input.int()
- Line 16: input() → input.int()
⋯// Variables-StochLength = input(14, title="Stochastic Length")+StochLength = input.int(14, title="Stochastic Length")-smoothK = input(3, title="%K Smoothing")+smoothK = input.int(3, title="%K Smoothing")-smoothD = input(3, title="%D Smoothing")+smoothD = input.int(3, title="%D Smoothing") ⋯Does it run in Pine Script v6?
No
The v6 version runs in Zeal Terminal's engine, but its results differ from the v5 version: Trades differ: 0 before, 2 after on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. It is shown for reference and is not offered as a download. It differs from the v5 version by 1 edit.
⋯// The script is made for testing purposes only and is in beta mode. Please use at own risk.-//@version=5+//@version=6strategy("BankNifty_Bullish_Intraday", overlay=true, margin_long = 100, margin_short = 100)⋯Where it runs
| Engine | Compiles | Runs | Matches TradingView |
|---|---|---|---|
| Zeal Terminal · OpenPineScript v2 | Yes 12 ms | Yes 1,000 bars in 31 ms | Not measured |
| PineTS | Not tested | Not tested | Not measured |
“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report.
Source
Copied verbatim from the author's published script, with its licence header intact. The author may have updated the original since this snapshot.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © makarandpatil// This strategy is for Bank Nifty instrument and for intraday purpose only// It checks for various indicators and gives a buy signal when all conditions are met // Bank Nifty when in momentum gives 100-200 points in spot in 5-15 min which is how long the trade duration should be// Issues - The custom script as per TradingView Pinescripting has an issue of repaint// More information on repainting issue in this link - https://www.tradingview.com/pine-script-docs/en/v5/concepts/Repainting.html// Use the script alert only to get notified, however check all the parameters individually before taking the trade// Also, please perform a backtesting and deep backtesting of this strategy to see if the strategy gave correct buy signals in the past// The script is made for testing purposes only and is in beta mode. Please use at own risk.//@version=5strategy("BankNifty_Bullish_Intraday", overlay=true, margin_long = 100, margin_short = 100)// VariablesStochLength = input(14, title="Stochastic Length")smoothK = input(3, title="%K Smoothing")smoothD = input(3, title="%D Smoothing") //INDICATOR CALCULATIONS // 1. MACD[macdLine, signalLine, histLine] = ta.macd(close[0],12,26,9) macd5 = request.security(syminfo.tickerid, "5", macdLine)macd15 = request.security(syminfo.tickerid,"15",macdLine)macd60 = request.security(syminfo.tickerid,"60",macdLine) // 2. RSI CalculationxRSI = ta.rsi(close, 14) // 3. ADX calculation[diplus, diminus, adx] = ta.dmi(14,14)// plot(adx,color = color.black) // 4. Stochastic Calculationk = ta.sma(ta.stoch(close, high, low, StochLength), smoothK)d = ta.sma(k, smoothD) // 5. Bollinger Band calculation[middle, upper, lower] = ta.bb(close, 20, 2) //CONDITIONS // 1. Conditions for MACDmacd5Uptick = macd5[0] > macd5[1]macd15Uptick = macd15[0] > macd15[1]macd60Uptick = macd60[0] >= macd60[1] // 2. Condition for xRSIRSIStrong = xRSI > 60 // 3. Condition for ADXADXUngali = adx >= 12 // 4. Condition for StochasticStochPCO = k > d // 5. Condition for Bollinger BandBBCU = upper > upper [1] //Evaluate the long condition// longCondition = macd5Uptick and macd15Uptick and RSIStrong and ADXUngali and StochPCO and BBCUlongCondition = macd5[0] > 0 and macd5Uptick and macd15Uptick and macd60Uptick and RSIStrong and ADXUngali and StochPCO and BBCU// longCondition = macd5Uptick and macd15Uptick and RSIStrong and ADXUngali and StochPCO and BBCUif (longCondition) strategy.entry("Buy", strategy.long,alert_message = "BankNifty_Buy_Momentum")shortCondition = close < ta.ema(close,5)if (shortCondition) strategy.entry("BuySquareoff", strategy.short, alert_message = "BankNifty_Closed_Below_5EMA")