Distance Between Price and EMA with SD BandsMade with chatgpt.
The indicator measures the distance between price and an EMA of choice, with SD1 and SD2.
Disable plot and ema to see the actual indicator.
Exponential Moving Average (EMA)
8 EMA and 20 EMA with CrossoversThis Pine Script is designed to plot two Exponential Moving Averages (EMAs) on the chart:
8-period EMA (Blue Line):
This is a faster-moving average that reacts more quickly to recent price changes. It uses the last 8 periods (bars) of the price data to calculate the average.
It is plotted in blue to distinguish it from the other EMA.
20-period EMA (Red Line):
This is a slower-moving average that smooths out the price data over a longer period of time, providing a better indication of the overall trend.
It is plotted in red to visually differentiate it from the 8-period EMA.
Key Features:
Version: This script is written in Pine Script version 6.
Overlay: The EMAs are plotted directly on the price chart, allowing for easy visualization of the moving averages relative to the price action.
Visual Appearance:
The 8-period EMA is displayed with a blue line.
The 20-period EMA is displayed with a red line.
Both lines have a thickness of 2 to make them more prominent.
Purpose:
The combination of these two EMAs can be used for trend analysis and trading strategies:
A bullish signal is often seen when the faster (8-period) EMA crosses above the slower (20-period) EMA.
A bearish signal is typically generated when the faster (8-period) EMA crosses below the slower (20-period) EMA.
Traders use these EMAs to help determine market trends, potential entry points, and exit points based on crossovers and price interactions with these moving averages.
MA & EMA Crossover//@version=5
indicator("MA & EMA Crossover", overlay=true)
// Input Parameters
ma_length = input.int(20, title="MA Length", minval=1)
ema_length = input.int(10, title="EMA Length", minval=1)
// Calculations
ma = ta.sma(close, ma_length)
ema = ta.ema(close, ema_length)
// Signal Conditions
buy_signal = ta.crossover(ema, ma) // EMA crosses above MA
sell_signal = ta.crossunder(ema, ma) // EMA crosses below MA
// Plot MA and EMA
plot(ma, color=color.blue, title="MA (20)", linewidth=2)
plot(ema, color=color.red, title="EMA (10)", linewidth=2)
// Buy and Sell Signals
plotshape(series=buy_signal, location=location.belowbar, color=color.green, style=shape.labelup, title="Buy Signal", text="BUY")
plotshape(series=sell_signal, location=location.abovebar, color=color.red, style=shape.labeldown, title="Sell Signal", text="SELL")
// Alerts
alertcondition(buy_signal, title="Buy Alert", message="EMA crossed above MA - Buy Signal")
alertcondition(sell_signal, title="Sell Alert", message="EMA crossed below MA - Sell Signal")
Multiframe - EMAs + RSI LevelsThis indicator was created to make life easier for all traders, including the main market indicators, such as EMAs 12, 26 and 200 + respective EMAs in higher time frames, and complemented with RSI Levels that vary from overbought 70 - 90 and oversold 30 - 10.
The Indicator can be configured to make the chart cleaner according to your wishes.
SPXL strategy based on HighYield Spread (TearRepresentative56)This strategy is focused on leveraged funds (SPXL as basis that stands for 3x S&P500) and aims at maximising profit while keeping potential drawdowns at measurable level
Originally created by TearRepresentative56, I`m not the author of the concept, just backtesting it and sharing with the community
Key idea : Buy or Sell AMEX:SPXL SPXL if triggered
Trigger: HighYield Spread Change ( FRED:BAMLH0A0HYM2 BAMLH0A0HYM2). BAMLH0A0HYM2 can be used as indicator of chop/decline market (if spread rises significantly)
How it works :
1. Track BAMLH0A0HYM2 for 30% decline from local high marks the 'buy' trigger for SPXL (with all available funds)
2. When BAMLH0A0HYM2 increases 30% from local low (AND is higher then 330d EMA) strategy will signal with 'sell' trigger (sell all available contracts)
3. When in position strategy shows signal to DCA each month (adding contracts to position)
Current version update :
Added DCA function
User can provide desired amount of funds added into SPXL each month.
Funds will be added ONLY when user holds position already and avoids DCAing while out of the market (while BAML is still high)
Backtesting results :
11295% for SPXL (since inception in 2009) with DCAing of 500USD monthly
4547% for SPXL (since inception in 2009) without DCA (only 10 000USD invested initially)
For longer period: even with SP500 (no leverage) the strategy provides better results than Buy&Hold (420% vs 337% respectively since 1999)
Default values (can be changed by user):
Start investing amount = 10 000 USD
Decline % (Entry trigger) = 30%
Rise % (Exit trigger) = 30%
Timeframe to look for local high/low = 180 days
DCA amount = 500 USD
Inflation yearly rate for DCA amount = 2%
EMA to track = 330d
Important notes :
1. BAMLH0A0HYM2 is 1 day delayed (that provides certain lag)
2. Highly recommended to select 'on bar close' option in properties of the strategy
3. Please use DAILY SPXL chart.
4. Strategy can be used with any other ticker - SPX, QQQ or leveraged analogues (while basic scenario is still in SPXL)
Distance Between EMA and SMA with 1 SD BandScript made by chatgpt
Measures the distance between an EMA and an SMA.
Daily Strategy with Triple EMA, DMI, DPO, RSI, and ATRThe strategy combines trend identification (via EMAs), momentum confirmation (via RSI and ADX), and directional strength (via DMI) to enter trades only during well-defined, strong trends.
Components:
Triple EMA System:
Fast EMA (10): Captures short-term price momentum.
Medium EMA (25): Serves as a medium-term trend filter.
Slow EMA (50): Defines the overall trend direction.
Condition: Trades are triggered when the fast EMA crosses the medium EMA, but only in the direction of the slow EMA (e.g., above for long, below for short).
RSI (14):
Measures momentum and overbought/oversold conditions.
Ensures trades are only taken when the market's momentum aligns with the trend (e.g., RSI > 50 for long trades).
ADX (14):
Confirms the presence of a strong trend. Trades are only allowed when the ADX value is above 25, signaling a trending market.
DMI (Directional Movement Index):
+DI and -DI measure directional strength.
Long trades are taken when +DI > -DI, confirming bullish strength.
Short trades are taken when -DI > +DI, confirming bearish strength.
Entry Rules:
Fast EMA crosses above the medium EMA, and both are above the slow EMA (for longs).
Fast EMA crosses below the medium EMA, and both are below the slow EMA (for shorts).
RSI must indicate momentum aligned with the trade direction (>50 for longs, <50 for shorts).
ADX must be above 25, ensuring the market is trending.
DMI must confirm directional strength (+DI > -DI for longs, -DI > +DI for shorts).
Exit Rules:
Exits are determined by external criteria (e.g., stop loss, trailing stop, or manual intervention). The base version does not include automated exits but can be extended with trailing stops, fixed targets, or dynamic ATR-based stops.
Strengths:
High Probability Trades: Multiple layers of confirmation reduce false signals.
Works in Trending Markets: The combination of ADX and EMAs ensures the strategy capitalizes on strong trends.
Momentum Alignment: RSI and DMI add confidence by confirming that momentum supports the trade direction.
Weaknesses:
Limited in Range-Bound Markets: The strategy may underperform during sideways or low-volatility periods.
Delayed Entries: Using multiple EMAs can result in slightly lagged signals.
Complexity: The combination of indicators may be overkill for traders who prefer simplicity.
Best Used For:
Daily Timeframe: Designed for higher timeframes to filter noise and capture significant trends.
Trend-Following Markets: Ideal for assets with clear directional movement, such as forex pairs, commodities, or major indices.
EMA Cross BandEMA Cross Band – Visualize Market Trends with Moving Averages
The "EMA Cross Band" script provides a clear visualization of market trends using two exponential moving averages (EMAs). This tool helps traders intuitively identify market movements and supports potential trading decisions.
Features:
Customizable EMAs: Adjust the lengths of EMA 1 and EMA 2 (default: 50 and 200) to suit your trading strategy.
Clear Trend Identification: The area between the two EMAs is color-coded – green for a bullish trend (EMA 1 above EMA 2) and red for a bearish trend (EMA 1 below EMA 2).
Overlay on the Chart: The script is displayed directly on the price chart and dynamically adapts to market movements.
Use Cases:
Identify short-term and long-term trends based on EMA crossovers.
Utilize the visualized area between the EMAs to assess the strength of the current trend.
Enhance your trading setup by combining this script with other indicators.
This script is suitable for traders of all experience levels who want to optimize their chart analysis and recognize trends more effectively. Try it now and integrate it into your strategy!
Gray bars below 200SMA/EMA and PWLBars are colored gray if they close below the 200SMA, 200EMA and Previous weeks low.
Simple filter to help avoid taking longs into unfavorable conditions
4EMAs + Opening HrsThis indicator shows 4 different EMAs of your chosen length and color together with opening hours for NYC and London Stock exchanges.
Opening hours are in the respective local time zones. Opening phases are split into two sections for pre-opening and actual opening.
In order to make the script simpler and to use less ressources the opening hours are also shown on weekends and holidays.
London:
7:30-8:00 - pre-opening phase
8:00-9:00 - opening phase
NYC:
8:30-9:30 - pre-opening phase
9:30-10:30 - opening phase
8 EMA and 20 EMAThis Pine Script is designed to plot two Exponential Moving Averages (EMAs) on the chart:
8-period EMA (Blue Line):
This is a faster-moving average that reacts more quickly to recent price changes. It uses the last 8 periods (bars) of the price data to calculate the average.
It is plotted in blue to distinguish it from the other EMA.
20-period EMA (Red Line):
This is a slower-moving average that smooths out the price data over a longer period of time, providing a better indication of the overall trend.
It is plotted in red to visually differentiate it from the 8-period EMA.
Key Features:
Version: This script is written in Pine Script version 6.
Overlay: The EMAs are plotted directly on the price chart, allowing for easy visualization of the moving averages relative to the price action.
Visual Appearance:
The 8-period EMA is displayed with a blue line.
The 20-period EMA is displayed with a red line.
Both lines have a thickness of 2 to make them more prominent.
Purpose:
The combination of these two EMAs can be used for trend analysis and trading strategies:
A bullish signal is often seen when the faster (8-period) EMA crosses above the slower (20-period) EMA.
A bearish signal is typically generated when the faster (8-period) EMA crosses below the slower (20-period) EMA.
Traders use these EMAs to help determine market trends, potential entry points, and exit points based on crossovers and price interactions with these moving averages.
Multiple EMAs with CrossunderPlots 9, 21, 50, 100, 200 EMAs.
The 21, 50, 100, & 200 turn red when the 9 crosses below it.
Coded by ChatGPT.
EMA 9 & EMA 15This TradingView script plots two Exponential Moving Averages (EMAs) on your chart to help you identify trends and potential trade setups. Here's a detailed explanation of its components:
ema,atr and with Bollinger Bands (Indicator)1. Indicator Overview
The indicator:
Displays EMA and Bollinger Bands on the chart.
Tracks price behavior during a user-defined trading session.
Generates long/short signals based on crossover conditions of EMA or Bollinger Bands.
Provides alerts for potential entries and exits.
Visualizes tracked open and close prices to help traders interpret market conditions.
2. Key Features
Inputs
session_start and session_end: Define the active trading session using timestamps.
E.g., 17:00:00 (5:00 PM) for session start and 15:40:00 (3:40 PM) for session end.
atr_length: The lookback period for the Average True Range (ATR), used for price movement scaling.
bb_length and bb_mult: Control the Bollinger Bands' calculation, allowing customization of sensitivity.
EMA Calculation
A 21-period EMA is calculated using:
pinescript
Copy code
ema21 = ta.ema(close, 21)
Purpose: Acts as a dynamic support/resistance level. Price crossing above or below the EMA indicates potential trend changes.
Bollinger Bands
Purpose: Measure volatility and identify overbought/oversold conditions.
Formula:
Basis: Simple Moving Average (SMA) of closing prices.
Upper Band: Basis + (Standard Deviation × Multiplier).
Lower Band: Basis - (Standard Deviation × Multiplier).
Code snippet:
pinescript
Copy code
bb_basis = ta.sma(close, bb_length)
bb_dev = bb_mult * ta.stdev(close, bb_length)
bb_upper = bb_basis + bb_dev
bb_lower = bb_basis - bb_dev
Session Tracking
The in_session variable ensures trading signals are only generated within the defined session:
pinescript
Copy code
in_session = time >= session_start and time <= session_end
3. Entry Conditions
EMA Crossover
Long Signal: When the price crosses above the EMA during the session:
pinescript
Copy code
ema_long_entry_condition = ta.crossover(close, ema21) and in_session and barstate.isconfirmed
Short Signal: When the price crosses below the EMA during the session:
pinescript
Copy code
ema_short_entry_condition = ta.crossunder(close, ema21) and in_session and barstate.isconfirmed
Bollinger Bands Crossover
Long Signal: When the price crosses above the upper Bollinger Band:
pinescript
Copy code
bb_long_entry_condition = ta.crossover(close, bb_upper) and in_session and barstate.isconfirmed
Short Signal: When the price crosses below the lower Bollinger Band:
pinescript
Copy code
bb_short_entry_condition = ta.crossunder(close, bb_lower) and in_session and barstate.isconfirmed
4. Tracked Prices
The script keeps track of key open/close prices using the following logic:
If a long signal is detected and the close is above the open, it tracks the open price.
If the close is below the open, it tracks the close price.
Tracked values are scaled using *4 (custom scaling logic).
These tracked prices are plotted for visual feedback:
pinescript
Copy code
plot(tracked_open, color=color.red, title="Tracked Open Price", linewidth=2)
plot(tracked_close, color=color.green, title="Tracked Close Price", linewidth=2)
5. Exit Conditions
Long Exit: When the price drops below the tracked open and close price:
pinescript
Copy code
exit_long_condition = (close < open) and (tracked_close < tracked_open) and barstate.isconfirmed
Short Exit: When the price rises above the tracked open and close price:
pinescript
Copy code
exit_short_condition = (close > open) and (tracked_close > tracked_open) and barstate.isconfirmed
6. Visualization
Plots:
21 EMA, Bollinger Bands (Basis, Upper, Lower).
Tracked open/close prices for additional context.
Background Colors:
Green for long signals, red for short signals (e.g., ema_long_entry_condition triggers a green background).
7. Alerts
The script defines alerts to notify the user about key events:
Entry Alerts:
pinescript
Copy code
alertcondition(ema_long_entry_condition, title="EMA Long Entry", message="EMA Long Entry")
alertcondition(bb_long_entry_condition, title="BB Long Entry", message="BB Long Entry")
Exit Alerts:
pinescript
Copy code
alertcondition(exit_long_condition, title="Exit Long", message="Exit Long")
8. Purpose
Trend Following: EMA crossovers help identify trend changes.
Volatility Breakouts: Bollinger Band crossovers highlight overbought/oversold regions.
Custom Sessions: Trading activity is restricted to specific time periods for precision.
EMA: f(x) - f'(x) - f''(x)Computes EMA for the given input period.
Also computes, the first and the second order derivative of that EMA.
EMA: f(x) - f'(x) - f''(x)Computes EMA for the given input period.
Also computes, the first and the second order derivative of that EMA.
Adaptive MFI Divergence IndicatorKey Features:
Pivot-Based Divergence Detection:
The script identifies bullish and bearish divergences using MFI EMA and price pivots:
Bullish Divergence: Price forms a lower low, while the MFI EMA forms a higher low.
Bearish Divergence: Price forms a higher high, while the MFI EMA forms a lower high.
Pivots are determined using configurable left and right bars for fine-tuned divergence detection.
Dynamic Entry Conditions:
For bullish divergences, the script:
Records the pivot high formed between the two pivot lows.
Triggers a buy signal only when the price closes above the recorded pivot high.
Ensures that the divergence aligns with a positive trend and occurs under favorable volatility conditions.
For bearish divergences, the script:
Records the pivot low formed between the two pivot highs.
Triggers a sell signal only when the price closes below the recorded pivot low.
Confirms the divergence aligns with a negative trend and sufficient volatility.
Trend and Volatility Filtering:
Confirms trend alignment using EMA crossovers:
Bullish Trend: EMA (25) > EMA (50).
Bearish Trend: EMA (25) < EMA (50).
Filters signals using Historical Volatility (HV):
Signals are valid only if HV exceeds its 50-period SMA benchmark, ensuring active market conditions.
Enhanced Money Flow Index (MFI):
The MFI calculation is enhanced by:
Adjusting for volume weight using a logarithmic scale based on the ratio of current to average volume.
Normalizing weights to stay within a stable range (0.5–1.5).
Offers the option to toggle between standard and adjusted MFI using the “Use adjusted MFI” input.
Clear Visual and Alert System:
Signals are marked directly on the chart:
Green "BUY" labels appear below the bars for bullish signals.
Red "SELL" labels appear above the bars for bearish signals.
Alerts for both bullish and bearish divergences enable real-time notifications.
Entry Conditions:
Bullish Entry:
Divergence Confirmation:
Price forms a lower low.
MFI EMA forms a higher low.
Pivot low is confirmed.
Pivot High Recording:
The script records the pivot high formed between the two pivot lows.
Entry Trigger:
A buy alert is triggered only when the price closes above the recorded pivot high.
Additional checks:
Trend Confirmation: EMA (25) > EMA (50).
Volatility Validation: HV exceeds its benchmark (50-period SMA).
MFI EMA Threshold: MFI EMA > 61.8.
Bearish Entry:
Divergence Confirmation:
Price forms a higher high.
MFI EMA forms a lower high.
Pivot high is confirmed.
Pivot Low Recording:
The script records the pivot low formed between the two pivot highs.
Entry Trigger:
A sell alert is triggered only when the price closes below the recorded pivot low.
Additional checks:
Trend Confirmation: EMA (25) < EMA (50).
Volatility Validation: HV exceeds its benchmark (50-period SMA).
MFI EMA Threshold: MFI EMA < 38.2.
Practical Applications:
Divergence-Based Reversals:
Ideal for detecting potential trend reversals using divergence signals confirmed by pivot breakouts.
Trend-Filtered Signals:
Eliminates false signals by requiring trend alignment via EMA crossovers.
Volatility-Aware Trading:
Ensures signals occur during active market conditions, reducing noise and enhancing signal reliability.
Why Choose This Indicator?
The Custom MFI Divergence Alerts script combines:
Accurate divergence detection using pivots on price and MFI EMA.
Dynamic entry conditions that align with trend and market volatility.
Volume-weighted MFI adjustments for more reliable oscillator signals
Estrategia Intradía - Cruce EMA + RSI - OptimizadoEstrategia simple, basado en cruces de emas y rsi. Estrategia que se puede aplicar a multiples time-frames y optimizada. Se puede apliar a mercado tradicional y criptomonedas.
Multi 7EMA With MJDescription: The Multi EMA Intraday Setup is a comprehensive indicator designed for intraday trading, combining multiple Exponential Moving Averages (EMAs) to identify market trends and support swift decision-making. By plotting EMAs of varying periods (5, 13, 21, 34, 50, 100, and 200), this setup gives traders a clear view of market momentum and potential entry or exit points. The indicator automatically adjusts to intraday price movements, providing valuable insights into trend strength and direction.
Features:
Multiple EMAs: The setup includes EMAs of various lengths (5, 13, 21, 34, 50, 100, and 200) for a broad analysis of short to long-term trends.
Trend Confirmation: The background color dynamically shifts to green (bullish) or red (bearish) based on the relative positioning of the EMAs.
Customizable Settings: Adjust the lengths of each EMA to tailor the indicator to your specific trading needs.
Intraday Focus: Optimized for intraday trading, the EMAs respond quickly to price changes and market shifts.
Visual Clarity: EMAs are displayed in distinct colors, making it easy to differentiate them on the chart.
How to Use:
Trend Identification: When the EMAs are aligned in a bullish order (shorter EMAs above longer EMAs), the background turns green, indicating a potential uptrend. A bearish alignment (shorter EMAs below longer EMAs) results in a red background, indicating a downtrend.
Bullish Confirmation: Look for the EMA5 to be above EMA13, EMA13 above EMA21, and so on. The stronger the alignment, the stronger the bullish signal.
Bearish Confirmation: Conversely, when all EMAs are aligned downward (EMA5 below EMA13, EMA13 below EMA21, etc.), it suggests a bearish trend.
Entry/Exit Signals: Use the alignment and crossovers of the EMAs to identify potential entry or exit points. The EMAs can help you decide when to enter or exit based on the market's trend direction.
EMA 50 200 BandThis indicator displays the Exponential Moving Averages (EMA) with periods of 50 and 200 and visually highlights the areas between the two lines. The color coding helps to quickly identify trends:
Green: EMA 50 is above EMA 200 (bullish signal).
Red: EMA 50 is below EMA 200 (bearish signal).
This tool is especially useful for trend analysis and can act as a filter for buy and sell signals. It is suitable for day trading or swing trading across various timeframes.
EMA Zones With Buy/Sell SignalsThis EMA Zones With Buy/Sell Signals indicator provides a way to visualize and trade based on exponential moving averages (EMAs) with buy and sell signals. Here's what it does:
Conditions to Trade:
Not all Buy/Sell signals are valid and can be traded.
Here are the conditions to take the Buy or Sell trade.
For Sell trade :
* The filled zone should be in red color.
* The filled zone is declining.
* The filled zone should not be too broad.
* The Sell signal is shown.
* The next candle has taken off the low of the Sell signal candle.
For Buy trade :
* The filled zone should be in green color.
* The filled zone is moving to up side.
* The filled zone should not be too broad.
* The Buy signal is shown.
* The next candle has taken off the high of the Buy signal candle.
Pro Tip:
Avoid trade if the zone is changing color very frequently. like 1-2 candles green, then 1-2 candles white (neutral), then 1-2 candles green. That means, there is the lack in momentum.
Core Concept:
The indicator uses multiple EMAs to define different "zones" on the price chart and provides buy and sell signals based on the relationship between the price and these EMAs. It includes:
Fast and Slow EMAs to determine trend direction.
Color Zones to represent the market's condition (bullish or bearish).
Buy and Sell Signals based on specific candle patterns and the relative positions of the price
and EMAs.
Key Features:
Multiple EMAs:
Main EMAs: A fast and slow EMA are plotted by default, representing the primary trend indicators.
Other EMAs: The script includes additional EMAs (e.g., 10, 20, 50, 100, etc.) to provide further trend information, helping users make more informed decisions.
These EMAs are plotted with different colors and line styles.
Zone Coloring:
Green Zone: When the price is above both EMAs (and the fast EMA is above the slow EMA), the zone is highlighted in green. This indicates a bullish market condition.
Red Zone: When the price is below both EMAs (and the fast EMA is below the slow EMA), the zone is highlighted in red. This indicates a bearish market condition.
Neutral Zone: A neutral zone is shown when there is no clear bullish or bearish condition, with a semi-transparent color fill between the EMAs.
Buy and Sell Conditions:
Sell Condition: A sell signal is generated when:
The price is in the red zone (below both EMAs).
The candle's high is within or above the red zone and closes below the fast EMA.
The candle is bearish (closing lower than the open), or it has a long wick above.
Buy Condition: A buy signal is generated when:
The price is in the green zone (above both EMAs).
The candle's low is within or below the green zone and closes above the fast EMA.
The candle is bullish (closing higher than the open), or it has a long wick below.
These conditions are combined to create the final buy and sell signals, with specific patterns of candle behavior used to confirm trends and reversals.
Plotting Buy/Sell Signals:
Sell Signal: A "SELL" label is plotted above the bar when a sell condition is met.
Buy Signal: A "BUY" label is plotted below the bar when a buy condition is met.
Alerts are also set up to notify the trader when buy or sell conditions occur.
How It Helps Traders:
Trend Identification: The EMA zone coloring helps traders quickly identify whether the market is in a bullish (green zone) or bearish (red zone) state.
Signal Confirmation: The buy and sell signals give traders entry and exit points based on price action and EMA crossovers, which can be used in conjunction with other strategies.
Multiple Timeframes: By using different EMAs (e.g., short-term and long-term), the indicator provides insight into the market from both a short-term and long-term perspective.
Conclusion:
This indicator is designed to assist traders in making decisions based on EMAs, price action, and zone conditions. It highlights areas of potential interest (green/red zones) and provides actionable buy and sell signals when certain price patterns occur within those zones. It can be particularly useful for trend-following strategies or traders looking for potential reversals or breakouts.