Trend-Following Strategy for NIFTY or BANK NIFTY//@version=5
strategy("Trend-Following Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=5)
// Input Parameters
macd_fast_length = input(12, title="MACD Fast Length")
macd_slow_length = input(26, title="MACD Slow Length")
macd_signal_length = input(9, title="MACD Signal Length")
sma_length = input(200, title="SMA Length")
atr_length = input(14, title="ATR Length")
atr_multiplier = input(1.5, title="ATR Stop Loss Multiplier")
// Calculate Indicators
= ta.macd(close, macd_fast_length, macd_slow_length, macd_signal_length)
sma = ta.sma(close, sma_length)
atr = ta.atr(atr_length)
// Define Conditions
longCondition = ta.crossover(macdLine, signalLine) and close > sma
shortCondition = ta.crossunder(macdLine, signalLine) and close < sma
// Stop Loss and Take Profit
longStopLoss = close - atr * atr_multiplier
shortStopLoss = close + atr * atr_multiplier
// Execute Trades
if (longCondition)
strategy.entry("Long", strategy.long)
strategy.exit("Long Exit", from_entry="Long", stop=longStopLoss)
if (shortCondition)
strategy.entry("Short", strategy.short)
strategy.exit("Short Exit", from_entry="Short", stop=shortStopLoss)
// Plot Indicators
plot(sma, color=color.blue, linewidth=2, title="200 SMA")
hline(0, "Zero Line", color=color.gray)
plot(macdLine, color=color.green, title="MACD Line")
plot(signalLine, color=color.red, title="Signal Line")
Penunjuk dan strategi
cá nhân//@version=5
strategy("Demo GPT - Supertrend", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=0.1, slippage=3)
// Inputs
Periods = input.int(10, title="ATR Period")
src = input.source(hl2, title="Source")
Multiplier = input.float(3.0, title="ATR Multiplier", step=0.1)
changeATR = input.bool(true, title="Change ATR Calculation Method ?")
showSignals = input.bool(true, title="Show Signals ?")
highlighting = input.bool(true, title="Highlighter On/Off ?")
emaPeriod = input.int(50, title="EMA Period")
bbLength = input.int(20, title="Bollinger Bands Length")
bbMultiplier = input.float(2.0, title="Bollinger Bands Multiplier")
// ATR Calculation
atr2 = ta.sma(ta.tr, Periods)
atr = changeATR ? ta.atr(Periods) : atr2
// Supertrend Calculation
up = src - (Multiplier * atr)
up1 = nz(up , up)
up := close > up1 ? math.max(up, up1) : up
dn = src + (Multiplier * atr)
dn1 = nz(dn , dn)
dn := close < dn1 ? math.min(dn, dn1) : dn
trend = 1
trend := nz(trend , trend)
trend := trend == -1 and close > dn1 ? 1 : trend == 1 and close < up1 ? -1 : trend
// Bollinger Bands Calculation
basis = ta.sma(close, bbLength)
deviation = ta.stdev(close, bbLength)
upperBand = basis + (bbMultiplier * deviation)
lowerBand = basis - (bbMultiplier * deviation)
// Plot Supertrend and Bollinger Bands
upPlot = plot(trend == 1 ? up : na, title="Up Trend", style=plot.style_line, linewidth=2, color=color.green)
dnPlot = plot(trend == 1 ? na : dn, title="Down Trend", style=plot.style_line, linewidth=2, color=color.red)
plot(upperBand, title="Upper Band", color=color.blue, linewidth=1)
plot(lowerBand, title="Lower Band", color=color.blue, linewidth=1)
plot(basis, title="BB Basis", color=color.gray, linewidth=1)
// Buy and Sell Signals
buySignal = close > upperBand
sellSignal = close < lowerBand
if (buySignal and showSignals)
strategy.entry("Buy", strategy.long)
if (sellSignal and showSignals)
strategy.close("Buy")
// Highlighting
mPlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0)
longFillColor = highlighting ? (trend == 1 ? color.new(color.green, 90) : na) : na
shortFillColor = highlighting ? (trend == -1 ? color.new(color.red, 90) : na) : na
fill(mPlot, upPlot, title="UpTrend Highlighter", color=longFillColor)
fill(mPlot, dnPlot, title="DownTrend Highlighter", color=shortFillColor)
// Date Range Filter
startDate = input.time(timestamp("2018-01-01 00:00"), title="Start Date")
endDate = input.time(timestamp("2069-12-31 23:59"), title="End Date")
inDateRange = (time >= startDate and time <= endDate)
if not inDateRange
strategy.close_all()
Mean Reversion Strategy//@version=5
strategy("Mean Reversion Strategy", overlay=true)
// User Inputs
length = input.int(20, title="SMA Length") // Moving Average length
stdDev = input.float(2.0, title="Standard Deviation Multiplier") // Bollinger Band deviation
rsiLength = input.int(14, title="RSI Length") // RSI calculation length
rsiOverbought = input.int(70, title="RSI Overbought Level") // RSI overbought threshold
rsiOversold = input.int(30, title="RSI Oversold Level") // RSI oversold threshold
// Bollinger Bands
sma = ta.sma(close, length) // Calculate the SMA
stdDevValue = ta.stdev(close, length) // Calculate Standard Deviation
upperBand = sma + stdDev * stdDevValue // Upper Bollinger Band
lowerBand = sma - stdDev * stdDevValue // Lower Bollinger Band
// RSI
rsi = ta.rsi(close, rsiLength) // Calculate RSI
// Plot Bollinger Bands
plot(sma, color=color.orange, title="SMA") // Plot SMA
plot(upperBand, color=color.red, title="Upper Bollinger Band") // Plot Upper Band
plot(lowerBand, color=color.green, title="Lower Bollinger Band") // Plot Lower Band
// Plot RSI Levels (Optional)
hline(rsiOverbought, "Overbought Level", color=color.red, linestyle=hline.style_dotted)
hline(rsiOversold, "Oversold Level", color=color.green, linestyle=hline.style_dotted)
// Buy and Sell Conditions
buyCondition = (close < lowerBand) and (rsi < rsiOversold) // Price below Lower Band and RSI Oversold
sellCondition = (close > upperBand) and (rsi > rsiOverbought) // Price above Upper Band and RSI Overbought
// Execute Strategy
if (buyCondition)
strategy.entry("Buy", strategy.long)
if (sellCondition)
strategy.entry("Sell", strategy.short)
// Optional: Plot Buy/Sell Signals
plotshape(series=buyCondition, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal")
plotshape(series=sellCondition, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal")
Trend Trader-Remastered StrategyOfficial Strategy for Trend Trader - Remastered
Indicator: Trend Trader-Remastered (TTR)
Overview:
The Trend Trader-Remastered is a refined and highly sophisticated implementation of the Parabolic SAR designed to create strategic buy and sell entry signals, alongside precision take profit and re-entry signals based on marked Bill Williams (BW) fractals. Built with a deep emphasis on clarity and accuracy, this indicator ensures that only relevant and meaningful signals are generated, eliminating any unnecessary entries or exits.
Please check the indicator details and updates via the link above.
Important Disclosure:
My primary objective is to provide realistic strategies and a code base for the TradingView Community. Therefore, the default settings of the strategy version of the indicator have been set to reflect realistic world trading scenarios and best practices.
Key Features:
Strategy execution date&time range.
Take Profit Reduction Rate: The percentage of progressive reduction on active position size for take profit signals.
Example:
TP Reduce: 10%
Entry Position Size: 100
TP1: 100 - 10 = 90
TP2: 90 - 9 = 81
Re-Entry When Rate: The percentage of position size on initial entry of the signal to determine re-entry.
Example:
RE When: 50%
Entry Position Size: 100
Re-Entry Condition: Active Position Size < 50
Re-Entry Fill Rate: The percentage of position size on initial entry of the signal to be completed.
Example:
RE Fill: 75%
Entry Position Size: 100
Active Position Size: 50
Re-Entry Order Size: 25
Final Active Position Size:75
Important: Even RE When condition is met, the active position size required to drop below RE Fill rate to trigger re-entry order.
Key Points:
'Process Orders on Close' is enabled as Take Profit and Re-Entry signals must be executed on candle close.
'Calculate on Every Tick' is enabled as entry signals are required to be executed within candle time.
'Initial Capital' has been set to 10,000 USD.
'Default Quantity Type' has been set to 'Percent of Equity'.
'Default Quantity' has been set to 10% as the best practice of investing 10% of the assets.
'Currency' has been set to USD.
'Commission Type' has been set to 'Commission Percent'
'Commission Value' has been set to 0.05% to reflect the most realistic results with a common taker fee value.
Bollinger Bands StrategyTrading anhand der Bollinger Bänder:
Pine Skript erstellt und eingefügt:
Kaufbedingung: Wenn der Preis das untere Band von unten nach oben kreuzt.
Verkaufbedingung: Wenn der Preis das obere Band von oben nach unten kreuzt.
mentor+json+v1.0This script implements a straightforward trend-following strategy based on moving averages (EMAs) and RSI confirmation. It is designed to help traders identify potential trend-based entry and exit points while managing risk with a customizable stop loss.
Key Features:
EMA Crossover: Buy signals occur when the short EMA crosses above the long EMA, and RSI is above a specified level. Sell signals are generated when the short EMA crosses below the long EMA, and RSI is below the specified level.
Stop Loss: A percentage-based stop loss is applied to all trades, ensuring effective risk management. The stop loss level is displayed as a dashed line on the chart.
Customization: Users can adjust the EMA lengths, RSI confirmation level, and stop loss percentage to match their trading strategy.
How to Use:
Add the script to your chart and adjust the inputs in the settings panel:
Short EMA Length: Determines the sensitivity of the short moving average.
Long EMA Length: Controls the trend-following component.
RSI Confirmation Level: Ensures trades are aligned with momentum.
Stop Loss (%): Defines the percentage level at which the stop loss is set.
Observe the buy and sell signals marked on the chart.
Use the stop loss line as a visual guide to manage risk for your trades.
Notes:
This script is intended for educational purposes and backtesting. Use it responsibly and in combination with other analysis techniques.
Always perform thorough backtesting and analysis before applying it to live trading.
Happy trading! 🚀
My strategy{ "secret": "eyJhbGciOiJIUzI1NiJ9.eyJzaWduYWxzX3NvdXJjZV9pZCI6MTA1NTM1fQ.LjhZON_V472svSJ-DYbE8zFstu01THnQ5pOiaFixEEY", "max_lag": "300", "timestamp": "{{timenow}}", "trigger_price": "{{close}}", "tv_exchange": "{{exchange}}", "tv_instrument": "{{ticker}}", "action": "{{strategy.order.action}}", "bot_uuid": "1eb94d98-de6e-4a1c-810c-edfc0a713306", "strategy_info": { "market_position": "{{strategy.market_position}}", "market_position_size": "{{strategy.market_position_size}}", "prev_market_position": "{{strategy.prev_market_position}}", "prev_market_position_size": "{{strategy.prev_market_position_size}}" }, "order": { "amount": "{{strategy.order.contracts}}", "currency_type": "base" }}
Hold Time With Percentage Drop Catastrophic ExitStrategy Name: Volatile Market Minimum-Hold & Catastrophic Drop Exit Strategy
Description:
This is a strategy designed to operate effectively within volatile trading environments, with specific rules that balance patience with protection from risk. It looks to capitalize on breakout conditions but provides a failsafe in the event of a sudden severe price decline.
Key Features:
Volatility-Based Entry Criteria:
This strategy is based on Bollinger Bands, ATR, VWAP, and MACD in trying to find breakout opportunities with increased volatility in the markets. It demands that the price go over the upper Bollinger Band when ATR indicates increased turbulence and that MACD signals upward momentum. In this way, it selects trades with high follow-through likelihoods, especially under trending conditions.
Minimum Holding Period:
Once a long position is initiated, the strategy imposes a strict "no-sell" period in bars. This means that, under normal circumstances, it will not close the position. This encourages the trade to mature, reducing the likelihood of premature exits caused by minor pullbacks or intraday noise.
Volume Confirmation:
A relative volume filter ensures that breakouts aren't occurring in low-liquidity conditions. In doing so, the strategy is only looking to enter when market participation is well above average, thereby increasing the odds of price moves being legitimate and sustainable.
Catastrophic Drop Exit:
The strategy includes a "catastrophic drop" mechanism to help mitigate severe, unexpected losses. If the price falls below a user-defined percentage of the entry price—sufficiently large to indicate a major market breakdown—it will override the minimum hold rule and immediately close the position. This helps protect capital if the market suddenly turns sharply negative.
User Configuration:
All the key parameters, which include the minimum hold duration, catastrophic drop percentage, Bollinger Band settings, MACD lengths, and ATR-based stop/target multiples, are user-editable. Traders can adjust the aggressiveness, holding time, and risk controls of the strategy to fit their specific risk tolerance, trading style, and the volatility profile of the markets in which they're participating.
Intended Use Case:
This strategy is more suitable for traders operating in more volatile markets, with frequent whipsaws and fast price moves. It tries to capture the upside of a volatile breakout while minimizing the downside from a sudden price collapse by balancing a forced hold period against the flexibility of a catastrophic drop exit.
Note:
This approach is in line with all automated or rules-based approaches: extensive backtesting and parameter optimization, followed by thorough forward-testing on paper, is very strongly advised before going into live market conditions. Also, adjust parameters to better suit your instrument of choice, timeframe, and your criteria of personal risk management.
ATM StrategyFOR STOP LOSS AND PROFIT by setting this strategy yopu can stop your trade on profit and loss whatever the number you decides.
Accumulated Adj. Close * Volume StrategyAccumulated Adj. Close * Volume Strategy
// Description:
// This script implements a trading strategy based on the accumulated product of adjusted close prices and volume.
// The main idea is to track the cumulative changes in adjusted close prices weighted by volume and compare them
// to a 150-period simple moving average (SMA). Buy and sell signals are generated based on the relationship
// between the cumulative value and its SMA. The script also includes a weekly time condition to limit trading
// frequency. Additionally, it visualizes the accumulated values, their SMAs, the strategy equity, and the
// volume as a histogram. The strategy uses 10% of the available capital for each trade.
Buy The Deep Final Version V3 -grid version"Buy The Deep Final Version V3" Indicator Description"
The "Buy The Deep Final Version V3" is an advanced trading strategy designed to help traders automate and optimize their entry, position sizing, and exit points in volatile markets. Below is a detailed explanation of its features, inputs, and functionality.
---
Key Features
1. Dynamic Position Sizing :
- Calculates position size dynamically based on the trader's initial capital, current profit, and leverage settings.
- Provides options for reinvesting profits or maintaining fixed position sizes.
2. Volatility-Based Entry :
- Identifies "buy-the-dip" opportunities based on a calculated volatility percentage (`val`).
3. Automated Take Profit and Stop Loss :
- Automatically sets take profit (`tp`) and stop loss (`tp22`) levels using predefined percentages, ensuring effective risk management.
4. SMA-Based Conditions :
- Utilizes a Simple Moving Average (SMA) as a baseline to determine whether to enter long positions.
5. Support for Additional Buy Levels :
- Allows dollar-cost averaging with multiple additional buy levels (`so1`, `so2`, etc.).
6. Leverage and Commission Customization :
- Users can set desired leverage and trading fees, which are incorporated into the calculations for precise execution.
7. Performance Tracking :
- Displays key metrics, including:
- Total profit and percentage
- Monthly and annual profit percentages
- Maximum drawdown (MDD)
- Win rate
- Includes a performance table and data window for real-time insights.
8. Time-Limited Testing :
- Allows users to test the strategy over specific time periods for refinement and validation.
---
"How It Works"
- Entry Conditions : The strategy identifies opportunities when the price crosses above the SMA or meets specific volatility thresholds.
- Position Sizing : Leverage and capital allocation are used to calculate optimal position sizes dynamically.
- Exit Points : Automated take profit or stop-loss orders minimize manual intervention.
---
Input Descriptions
This strategy provides various customizable input parameters to suit different trading needs. Each input is described below:
1. Initial Settings
- Profit Reinvest (`reinvest`) :
- Options: `True` or `False`
- Determines whether profits are reinvested to increase the size of subsequent trades.
- Long Buy % (`longper`) :
- Default: `6`
- Sets the percentage of initial capital to allocate for the first long position.
- Leverage (`lev`) :
- Default: `3`
- Sets the leverage multiplier for trades. For example, `3` means a 3x leverage is used.
- Fee % (`commission_value`) :
- Default: `0.044`
- Input the trading fee as a percentage. This value is factored into profit calculations.
- Decimal Places (`num`) :
- Default: `2`
- Determines how many decimal places are considered in calculations.
- Table Font Size (`texts`) :
- Default: `Normal`
- Sets the font size for the performance table. Options include `Tiny`, `Small`, `Normal`, and `Large`.
---
2. Volatility and Additional Buy Settings
- Volatility % (`val`) :
- Default: `-1.5`
- Sets the volatility percentage used to determine entry points.
- Additional Buy % (`so`) :
- Default: `-3`
- Defines the percentage drop at which additional buy orders are executed.
- Take Profit % (`tp`) :
- Default: `0.5`
- Specifies the percentage increase at which take profit orders are executed.
- Candle Count (`sl`) :
- Default: `1`
- Sets the number of candles to hold a position before closing it.
- Take Profit Stop-Loss % (`tp22`) :
- Default: `0.1`
- Sets the stop-loss threshold as a percentage below the average entry price.
- SMA Length (`len`) :
- Default: `48`
- Determines the period for calculating the Simple Moving Average (SMA).
---
3. Position Multipliers
- Position Multiplier Longline 4 (`long2_qty`) :
- Default: `1`
- Sets the size of the first additional buy position.
- Position Multiplier Longline 5 (`long3_qty`) :
- Default: `2`
- Sets the size of the second additional buy position.
- Position Multiplier Longline 4 (`long4_qty`) :
- Default: `4`
- Sets the size of the third additional buy position.
- Position Multiplier Longline 5 (`long5_qty`) :
- Default: `8`
- Sets the size of the fourth additional buy position.
---
BOS and Volume Strategy with ConfirmationHi all, im trying to build a strategy based on BOS. i ran into a problem when i saw the stoploss not working.
i hope someone could help me figure out the problem.
thanks
Three Moving Averages Strategythis is three moving averages strategy is good for day time frame best for swing trading , probability vary for 60 to 80 to increase the probability add other indictors . you can rsi or macd.
tf 5min signal 4 ema, stochastic and bollinger bands by GOENscalping in timeframe 5min with indicators ema5, ema20, ema100, ema200, stochastic 8,3,3 and Bollinger Bands
Bitcoin Exponential Profit Strategy### Strategy Description:
The **Bitcoin Trading Strategy** is an **Exponential Moving Average (EMA) crossover strategy** designed to identify bullish trends for Bitcoin.
1. **Indicators**:
- **Fast EMA (default 9 periods)**: Represents the short-term trend.
- **Slow EMA (default 21 periods)**: Represents the longer-term trend.
2. **Entry Condition**:
- A **bullish crossover** occurs when the Fast EMA crosses above the Slow EMA.
- The strategy enters a **long position** with a user-defined order size (default 0.01 BTC).
3. **Exit Conditions**:
- **Take Profit**: Closes the position when the profit target is reached (default $100).
- **Stop Loss**: Closes the position when the price drops below the stop loss level (default $50).
- **Bearish Crossunder**: Closes the position when the Fast EMA crosses below the Slow EMA.
4. **Visual Signals**:
- **BUY signals**: Displayed when a bullish crossover occurs.
- **SELL signals**: Displayed when a bearish crossunder occurs.
This strategy is optimized for trend-following behavior, ensuring positions are aligned with upward-moving trends while managing risk through clear stop-loss and take-profit levels.
Refined SMA/EMA Crossover with Ichimoku and 200 SMA FilterYour **Refined SMA/EMA Crossover with Ichimoku and 200 SMA Filter** strategy is a multi-faceted technical trading strategy that combines several key technical indicators to refine entry and exit points for trades. Here's a breakdown of the components and how they work together:
### 1. **SMA/EMA Crossover**
- **Simple Moving Average (SMA) & Exponential Moving Average (EMA) Crossover**:
- The core idea behind the crossover strategy is to use the relationship between two moving averages to generate buy or sell signals.
- **SMA** (Simple Moving Average) gives an average of past prices over a set period.
- **EMA** (Exponential Moving Average) places more weight on recent prices, making it more responsive to price movements.
- A **bullish crossover** occurs when a shorter period moving average (such as a 50-period EMA) crosses above a longer period moving average (such as a 200-period SMA), signaling a potential buy.
- A **bearish crossover** occurs when a shorter period moving average crosses below the longer period moving average, signaling a potential sell.
### 2. **Ichimoku Cloud**
- The **Ichimoku Cloud** is a versatile indicator that provides insight into trend direction, support and resistance levels, and momentum.
- **Cloud (Kumo)**: The space between the Senkou Span A and Senkou Span B lines. It helps identify whether the market is in an uptrend, downtrend, or consolidation.
- **Tenkan-sen** (Conversion Line) and **Kijun-sen** (Base Line): These lines are used for additional confirmation of trend direction.
- **Chikou Span**: A lagging line that is used to confirm the trend.
- The general trading rules based on the Ichimoku Cloud are:
- **Bullish Signal**: When the price is above the cloud and the Tenkan-sen crosses above the Kijun-sen.
- **Bearish Signal**: When the price is below the cloud and the Tenkan-sen crosses below the Kijun-sen.
### 3. **200 SMA Filter**
- The **200 SMA Filter** serves as a long-term trend filter.
- When the price is **above the 200 SMA**, it signals a long-term bullish trend, and you only look for buying opportunities.
- When the price is **below the 200 SMA**, it signals a long-term bearish trend, and you only look for selling opportunities.
- This filter helps to avoid counter-trend trades, aligning your positions with the broader market trend.
### **How the Strategy Works Together**
- **Trade Setup (Long Position)**
1. The **200 SMA Filter** must confirm an **uptrend** by ensuring that the price is above the 200 SMA.
2. A **bullish crossover** (e.g., the 50 EMA crossing above the 200 SMA) occurs.
3. **Ichimoku Cloud** confirms a bullish trend, with the price above the cloud and the Tenkan-sen crossing above the Kijun-sen.
4. You enter a **long trade** with this confluence of signals.
- **Trade Setup (Short Position)**
1. The **200 SMA Filter** must confirm a **downtrend** by ensuring the price is below the 200 SMA.
2. A **bearish crossover** (e.g., the 50 EMA crossing below the 200 SMA) occurs.
3. **Ichimoku Cloud** confirms a bearish trend, with the price below the cloud and the Tenkan-sen crossing below the Kijun-sen.
4. You enter a **short trade** with this confluence of signals.
### **Exit Strategy**
- Exits can be determined based on any of the following:
- **SMA/EMA crossover reversal**: Exit when the shorter-term moving average crosses back below the longer-term moving average for a long position or crosses above for a short position.
- **Ichimoku Cloud reversal**: If the price breaks through the cloud or the Tenkan-sen and Kijun-sen lines cross in the opposite direction.
- **Profit target or stop loss**: Setting predefined profit targets or using a trailing stop to lock in profits as the trade moves in your favor.
Summary of the Strategy
This strategy is designed to identify strong trends and avoid false signals by combining:
SMA/EMA crossovers for immediate market direction signals.
Ichimoku Cloud for confirming the strength and trend direction.
A 200
SMA filter to ensure trades align with the long-term trend.
By using these multiple indicators together, the strategy aims to refine entry and exit points, minimize risk, and increase the likelihood of successful trades.
Tomas Ratio Strategy with Multi-Timeframe AnalysisHello,
I would like to present my new indicator I have compiled together inspired by Calmar Ratio which is a ratio that measures gains vs losers but with a little twist.
Basically the idea is that if HLC3 is above HLC3 (or previous one) it will count as a gain and it will calculate the percentage of winners in last 720 hourly bars and then apply 168 hour standard deviation to the weekly average daily gains.
The idea is that you're supposed to buy if the thick blue line goes up and not buy if it goes down (signalized by the signal line). I liked that idea a lot, but I wanted to add an option to fire open and close signals. I have also added a logic that it not open more trades in relation the purple line which shows confidence in buying.
As input I recommend only adjusting the amount of points required to fire a signal. Note that the lower amount you put, the more open trades it will allow (and vice versa)
Feel free to remove that limiter if you want to. It works without it as well, this script is meant for inexperienced eye.
I will also publish a indicator script with this limiter removed and alerts added for you to test this strategy if you so choose to.
Also, I have added that the trades will enter only if price is above 720 period EMA
Disclaimer
This strategy is for educational purposes only and should not be considered financial advice. Always backtest thoroughly and adjust parameters based on your trading style and market conditions.
Made in collaboration with ChatGPT.
Swing High/Low Pivots Strategy [LV]The Swing High/Low Pivots Strategy was developed as a counter-momentum trading tool.
The strategy is suitable for any market and the default values used in the input settings menu are set for Bitcoin (best on 15min). These values, expressed in minimum ticks (or pips if symbol is Forex) make this tool perfectly adaptable to every symbol and/or timeframe.
Check tooltips in the settings menu for more details about every user input.
STRTEGY ENTRY & EXIT MECHANISMS:
Trades Entry based on the detection of swing highs and lows for short and long entries respectively, validated by:
- Limit orders placed after each new pivot level confirmation
- Moving averages trend filter (if enabled)
- No active trade currently open
Trades Exit when the price reaches take-profit or stop-loss level as defined in the settings menu. A double entry/second take-profit level can be enabled for partial exits, with dynamic stop-loss adjustment for the remaining position.
Enhanced Trade Precision:
By limiting entries to confirmed swing high (HH, LH) or swing low (HL, LL) pivot points, the strategy ensures that trades occur at levels of significant price reversals. This precision reduces the likelihood of entering trades in the midst of a trend or during uncertain price action.
Risk Management Optimization:
The strategy incorporates clearly defined stop-loss (SL) and take-profit (TP) levels derived from the pivot points. This structured approach minimizes potential losses while locking in profits, which is critical for consistent performance in volatile markets.
Trend Filtering for Better Entry:
The use of a configurable moving average filter adds a layer of trend validation. This prevents entering trades against the dominant market trend, increasing the probability of success for each trade.
Avoidance of Noise:
The lookback period (length parameter) confirms pivots only after a set number of bars, effectively filtering out market noise and ensuring that entries are based on reliable, well-defined price movements.
Adaptability Across Markets:
The strategy is versatile and can be applied across different markets (Forex, stocks, crypto) due to its dynamic use of ticks and pips converters. It adapts seamlessly to varying price scales and asset types.
Dual Quantity Entries:
The original and optionnal double-entry mechanism allows traders to capture both short-term and extended profits by scaling out of positions. This adaptive approach caters to varying risk appetites and market conditions.
Clear Visualization:
The plotted pivot points, entry limits, SL, and TP levels provide visual clarity, making it easy for traders to track the strategy's behavior and make informed decisions.
Automated Execution with Alerts:
Integrated alerts for both entries and exits ensure timely actions without the need for constant market monitoring, enhancing efficiency. Configurable alert messages are suitable for API use.
Any feedback, comments, or suggestions for improvement are always welcome.
Hope you enjoy!
R-based Strategy Template [Daveatt]Have you ever wondered how to properly track your trading performance based on risk rather than just profits?
This template solves that problem by implementing R-multiple tracking directly in TradingView's strategy tester.
This script is a tool that you must update with your own trading entry logic.
Quick notes
Before we dive in, I want to be clear: this is a template focused on R-multiple calculation and visualization.
I'm using a basic RSI strategy with dummy values just to demonstrate how the R tracking works. The actual trading signals aren't important here - you should replace them with your own strategy logic.
R multiple logic
Let's talk about what R-multiple means in practice.
Think of R as your initial risk per trade.
For instance, if you have a $10,000 account and you're risking 1% per trade, your 1R would be $100.
A trade that makes twice your risk would be +2R ($200), while hitting your stop loss would be -1R (-$100).
This way of measuring makes it much easier to evaluate your strategy's performance regardless of account size.
Whenever the SL is hit, we lose -1R
Proof showing the strategy tester whenever the SL is hit: i.imgur.com
The magic happens in how we calculate position sizes.
The script automatically determines the right position size to risk exactly your specified percentage on each trade.
This is done through a simple but powerful calculation:
risk_amount = (strategy.equity * (risk_per_trade_percent / 100))
sl_distance = math.abs(entry_price - sl_price)
position_size = risk_amount / (sl_distance * syminfo.pointvalue)
Limitations with lower timeframe gaps
This ensures that if your stop loss gets hit, you'll lose exactly the amount you intended to risk. No more, no less.
Well, could be more or less actually ... let's assume you're trading futures on a 15-minute chart but in the 1-minute chart there is a gap ... then your 15 minute SL won't get filled and you'll likely to not lose exactly -1R
This is annoying but it can't be fixed - and that's how trading works anyway.
Features
The template gives you flexibility in how you set your stop losses. You can use fixed points, ATR-based stops, percentage-based stops, or even tick-based stops.
Regardless of which method you choose, the position sizing will automatically adjust to maintain your desired risk per trade.
To help you track performance, I've added a comprehensive statistics table in the top right corner of your chart.
It shows you everything you need to know about your strategy's performance in terms of R-multiples: how many R you've won or lost, your win rate, average R per trade, and even your longest winning and losing streaks.
Happy trading!
And remember, measuring your performance in R-multiples is one of the most classical ways to evaluate and improve your trading strategies.
Daveatt
IU EMA Channel StrategyIU EMA Channel Strategy
Overview:
The IU EMA Channel Strategy is a simple yet effective trend-following strategy that uses two Exponential Moving Averages (EMAs) based on the high and low prices. It provides clear entry and exit signals by identifying price crossovers relative to the EMAs while incorporating a built-in Risk-to-Reward Ratio (RTR) for effective risk management.
Inputs ( Settings ):
- RTR (Risk-to-Reward Ratio): Define the ratio for risk-to-reward (default = 2).
- EMA Length: Adjust the length of the EMA channels (default = 100).
How the Strategy Works
1. EMA Channels:
- High-based EMA: EMA calculated on the high price.
- Low-based EMA: EMA calculated on the low price.
The area between these two EMAs creates a "channel" that visually highlights potential support and resistance zones.
2. Entry Rules:
- Long Entry: When the price closes above the high-based EMA (crossover).
- Short Entry: When the price closes below the low-based EMA (crossunder).
These entries ensure trades are taken in the direction of momentum.
3. Stop Loss (SL) and Take Profit (TP):
- Stop Loss:
- For long positions, the SL is set at the previous bar's low.
- For short positions, the SL is set at the previous bar's high.
- Take Profit:
- TP is automatically calculated using the Risk-to-Reward Ratio (RTR) you define.
- Example: If RTR = 2, the TP will be 2x the risk distance.
4. Exit Rules:
- Positions are closed at either the stop loss or the take profit level.
- The strategy manages exits automatically to enforce disciplined risk management.
Visual Features
1. EMA Channels:
- The high and low EMAs are dynamically color-coded:
- Green: Price is above the EMA (bullish condition).
- Red: Price is below the EMA (bearish condition).
- The area between the EMAs is shaded for better visual clarity.
2. Stop Loss and Take Profit Zones:
- SL and TP levels are plotted for both long and short positions.
- Zones are filled with:
- Red: Stop Loss area.
- Green: Take Profit area.
Be sure to manage your risk and position size properly.
DAILY Supertrend + EMA Crossover with RSI FilterThis strategy is a technical trading approach that combines multiple indicators—Supertrend, Exponential Moving Averages (EMAs), and the Relative Strength Index (RSI)—to identify and manage trades.
Core Components:
1. Exponential Moving Averages (EMAs):
Two EMAs, one with a shorter period (fast) and one with a longer period (slow), are calculated. The idea is to spot when the faster EMA crosses above or below the slower EMA. A fast EMA crossing above the slow EMA often suggests upward momentum, while crossing below suggests downward momentum.
2. Supertrend Indicator:
The Supertrend uses Average True Range (ATR) to establish dynamic support and resistance lines. These lines shift above or below price depending on the prevailing trend. When price is above the Supertrend line, the trend is considered bullish; when below, it’s considered bearish. This helps ensure that the strategy trades only in the direction of the overall trend rather than against it.
3. RSI Filter:
The RSI measures momentum. It helps avoid buying into markets that are already overbought or selling into markets that are oversold. For example, when going long (buying), the strategy only proceeds if the RSI is not too high, and when going short (selling), it only proceeds if the RSI is not too low. This filter is meant to improve the quality of the trades by reducing the chance of entering right before a reversal.
4. Time Filters:
The strategy only triggers entries during user-specified date and time ranges. This is useful if one wants to limit trading activity to certain trading sessions or periods with higher market liquidity.
5. Risk Management via ATR-based Stops and Targets:
Both stop loss and take profit levels are set as multiples of the ATR. ATR measures volatility, so when volatility is higher, both stops and profit targets adjust to give the trade more breathing room. Conversely, when volatility is low, stops and targets tighten. This dynamic approach helps maintain consistent risk management regardless of market conditions.
Overall Logic Flow:
- First, the market conditions are analyzed through EMAs, Supertrend, and RSI.
- When a buy (long) condition is met—meaning the fast EMA crosses above the slow EMA, the trend is bullish according to Supertrend, and RSI is below the specified “overbought” threshold—the strategy initiates or adds to a long position.
- Similarly, when a sell (short) condition is met—meaning the fast EMA crosses below the slow EMA, the trend is bearish, and RSI is above the specified “oversold” threshold—it initiates or adds to a short position.
- Each position is protected by an automatically calculated stop loss and a take profit level based on ATR multiples.
Intended Result:
By blending trend detection, momentum filtering, and volatility-adjusted risk management, the strategy aims to capture moves in the primary trend direction while avoiding entries at excessively stretched prices. Allowing multiple entries can potentially amplify gains in strong trends but also increases exposure, which traders should consider in their risk management approach.
In essence, this strategy tries to ride established trends as indicated by the Supertrend and EMAs, filter out poor-quality entries using RSI, and dynamically manage trade risk through ATR-based stops and targets.