OPEN-SOURCE SCRIPT
MTF strategy with (CE, TT, Bernoulli,DMF,RSI filters)

Strategy Overview
The strategy designed to be highly customizable, allowing users to select and configure different components.
Key Components:
1. Entry Signal Source
You can choose between two primary signal generators:
Chandelier Exit: A volatility-based indicator that provides buy/sell signals when the price moves a certain multiple of the Average True Range (ATR) away from a high or low.
Configurable parameters: ATR Period, ATR Multiplier, and whether to use the Close price for extremums.
Trend Trader: This appears to be a custom combination of MACD and ADX. It generates buy/sell signals based on MACD crossovers when the ADX is above a certain threshold (25, indicating a trending market).
Configurable parameters: Fast Length, Slow Length, Signal Smoothing (for MACD), ADX Length, and DI Length.
2. Take Profit (TP) Settings
The strategy offers flexible Take Profit options:
Enable/Disable: You can choose whether to use Take Profit at all.
Method:
Percentage: Closes the trade when a specified percentage profit is reached.
Risk/Reward Ratio: Calculates the Take Profit level based on a multiple of the initial Stop Loss distance.
Hold Until Stop: An option to override Take Profit and reverse signals, keeping the trade open until the Stop Loss is hit.
3. Stop Loss (SL) Settings (by chadmex)
This section defines how Stop Loss is calculated and managed:
Type:
Trailing: The Stop Loss dynamically adjusts as the trade moves in profit, locking in gains.
Fixed: The Stop Loss remains at its initial calculated level.
ATR Length: Period for ATR calculation, used in determining the Stop Loss distance.
Use Structure (High/Low): If enabled, the Stop Loss is calculated relative to recent Highs/Lows; otherwise, it's based on the Close price.
Lookback: The period for finding recent Highs/Lows for structure-based Stop Loss.
ATR Multiplier: A multiplier applied to the ATR value to set the Stop Loss distance.
4. Alert Settings
Customizable messages for various trade events:
Long Entry
Short Entry
Take Profit Hit
Stop Loss Hit
5. Filtering Mechanisms
The strategy includes a wide array of filters that can be independently enabled and configured to refine trade entries:
EMA Crossover Filter: Allows trades only when a fast EMA is above a slow EMA (for long) or vice versa (for short).
Configurable parameters: Timeframe, Fast EMA Length, Slow EMA Length.
RSI + Bollinger Bands + EMA Filter: Filters trades based on the relationship between an RSI-based Moving Average (Fast or Slow EMA of RSI) and the Bollinger Band Basis of RSI.
Configurable parameters: Timeframe, RSI Length, BB Length, BB Multiplier, Fast EMA Length, Slow EMA Length.
RSI EMA Level Filter: Prevents trades when RSI EMA is in overbought (for long) or oversold (for short) regions.
Configurable parameters: Upper Level (forbid longs), Lower Level (forbid shorts).
MFI (Custom) Filter: Filters trades based on a custom Money Flow Index (MFI) indicator. Default is long for MFI > 0, short for MFI < 0, with an option to reverse the logic.
Configurable parameters: Timeframe, MFI Period.
RSI+MFI (by VuManChu) Filter: Filters trades based on a combined RSI and MFI indicator. Default is long for indicator > 0, short for < 0, with an option to reverse the logic.
Configurable parameters: Timeframe, RSI+MFI Period, Multiplier, Y Position Offset.
OBV (On-Balance Volume) Filter: Two options for filtering based on OBV and its EMAs/SMAs.
Option 1: Fast EMA of OBV vs. OBV SMA.
Option 2: Fast EMA of OBV vs. OBV SMA and Slow EMA.
Configurable parameters: Timeframe, OBV BB Length, OBV Fast EMA Length, OBV Slow EMA Length, and an option to invert the logic.
Bernoulli (by kocurekc) Filter: Filters trades using a Bernoulli entropy indicator. Default is long for value > 0, short for < 0, with options to reverse the logic and block trades in a "gray zone" (close to zero).
Configurable parameters: Timeframe, Entropy Length, Averaging Length, Trade Band (gray zone), Measurement Type, Bernoulli Purest, Probability Smoother, Include Source (price), Include Volume.
EMA Deviation (v2) Filter: Prevents trades after significant price deviations from EMAs, indicating potential overextension.
Configurable parameters: Timeframe, Fast EMA Length, Slow EMA Length, Average Lookback, Signal Multiplier.
Advanced RSI Conditions Filter (Forbidding): Allows defining multiple conditions based on RSI, its EMAs, and Bollinger Bands that, if any are met, forbid a trade. Includes "Death Cross" and "Golden Cross" variations.
Configurable parameters: Timeframe, RSI Length, BB Length, BB Multiplier, Fast EMA Length, Slow EMA Length, and numerous toggleable rules with customizable operators (Above/Below) and values for BB, RSI, and EMA relationships.
Advanced RSI Conditions Filter - 2 (Allowing): Similar to the forbidding filter, but trades are only allowed if all enabled conditions are met.
Configurable parameters: Same as the forbidding filter, but for allowing rules.
DMF (Dynamic Money Flow) Filter: Filters trades based on a custom Dynamic Money Flow indicator and its moving averages.
Configurable parameters: Timeframe, Period, Moving Average Type (EMA, WMA, T3, FRAMA), Fast Length, Slow Length.
Detailed Long/Short Conditions: Allows precise control over the DMF value, fast MA, and slow MA ranges, and cloud conditions for both long and short entries.
Trade Execution Logic:
Signal Generation: Either Chandelier Exit or Trend Trader generates a raw buy or sell signal.
Filter Application: The raw signal is then passed through all enabled filters.
For forbidding filters, if any of their active rules are met, the trade is blocked.
For allowing filters, all of their active rules must be met for the trade to proceed.
Combined Filters: All active filters must allow a trade for it to be considered valid.
Entry: If a valid buySignal and allowLong conditions are met (and not holding until stop, or if holding until stop, there's no open position), a "Long" entry is executed. The same applies for "Short" entries.
Stop Loss Calculation: Upon entry, an initial Stop Loss price is calculated based on the chosen type (Fixed/Trailing) and parameters.
For trailing SL, the active_long_stop or active_short_stop is updated to trail the price.
Take Profit Calculation: If useTakeProfit is true and holdUntilStop is false, a Take Profit target is calculated based on the chosen method (Percentage or Risk/Reward).
Exit:
If the price hits the Stop Loss, the position is closed.
If the price hits the Take Profit target, the position is closed (unless holdUntilStop is active).
Plotting:
The script plots:
Calculated Stop Loss and Take Profit levels (as white lines, typically for visual debugging).
The active Trailing Stop Loss lines (green for long, red for short).
The strategy designed to be highly customizable, allowing users to select and configure different components.
Key Components:
1. Entry Signal Source
You can choose between two primary signal generators:
Chandelier Exit: A volatility-based indicator that provides buy/sell signals when the price moves a certain multiple of the Average True Range (ATR) away from a high or low.
Configurable parameters: ATR Period, ATR Multiplier, and whether to use the Close price for extremums.
Trend Trader: This appears to be a custom combination of MACD and ADX. It generates buy/sell signals based on MACD crossovers when the ADX is above a certain threshold (25, indicating a trending market).
Configurable parameters: Fast Length, Slow Length, Signal Smoothing (for MACD), ADX Length, and DI Length.
2. Take Profit (TP) Settings
The strategy offers flexible Take Profit options:
Enable/Disable: You can choose whether to use Take Profit at all.
Method:
Percentage: Closes the trade when a specified percentage profit is reached.
Risk/Reward Ratio: Calculates the Take Profit level based on a multiple of the initial Stop Loss distance.
Hold Until Stop: An option to override Take Profit and reverse signals, keeping the trade open until the Stop Loss is hit.
3. Stop Loss (SL) Settings (by chadmex)
This section defines how Stop Loss is calculated and managed:
Type:
Trailing: The Stop Loss dynamically adjusts as the trade moves in profit, locking in gains.
Fixed: The Stop Loss remains at its initial calculated level.
ATR Length: Period for ATR calculation, used in determining the Stop Loss distance.
Use Structure (High/Low): If enabled, the Stop Loss is calculated relative to recent Highs/Lows; otherwise, it's based on the Close price.
Lookback: The period for finding recent Highs/Lows for structure-based Stop Loss.
ATR Multiplier: A multiplier applied to the ATR value to set the Stop Loss distance.
4. Alert Settings
Customizable messages for various trade events:
Long Entry
Short Entry
Take Profit Hit
Stop Loss Hit
5. Filtering Mechanisms
The strategy includes a wide array of filters that can be independently enabled and configured to refine trade entries:
EMA Crossover Filter: Allows trades only when a fast EMA is above a slow EMA (for long) or vice versa (for short).
Configurable parameters: Timeframe, Fast EMA Length, Slow EMA Length.
RSI + Bollinger Bands + EMA Filter: Filters trades based on the relationship between an RSI-based Moving Average (Fast or Slow EMA of RSI) and the Bollinger Band Basis of RSI.
Configurable parameters: Timeframe, RSI Length, BB Length, BB Multiplier, Fast EMA Length, Slow EMA Length.
RSI EMA Level Filter: Prevents trades when RSI EMA is in overbought (for long) or oversold (for short) regions.
Configurable parameters: Upper Level (forbid longs), Lower Level (forbid shorts).
MFI (Custom) Filter: Filters trades based on a custom Money Flow Index (MFI) indicator. Default is long for MFI > 0, short for MFI < 0, with an option to reverse the logic.
Configurable parameters: Timeframe, MFI Period.
RSI+MFI (by VuManChu) Filter: Filters trades based on a combined RSI and MFI indicator. Default is long for indicator > 0, short for < 0, with an option to reverse the logic.
Configurable parameters: Timeframe, RSI+MFI Period, Multiplier, Y Position Offset.
OBV (On-Balance Volume) Filter: Two options for filtering based on OBV and its EMAs/SMAs.
Option 1: Fast EMA of OBV vs. OBV SMA.
Option 2: Fast EMA of OBV vs. OBV SMA and Slow EMA.
Configurable parameters: Timeframe, OBV BB Length, OBV Fast EMA Length, OBV Slow EMA Length, and an option to invert the logic.
Bernoulli (by kocurekc) Filter: Filters trades using a Bernoulli entropy indicator. Default is long for value > 0, short for < 0, with options to reverse the logic and block trades in a "gray zone" (close to zero).
Configurable parameters: Timeframe, Entropy Length, Averaging Length, Trade Band (gray zone), Measurement Type, Bernoulli Purest, Probability Smoother, Include Source (price), Include Volume.
EMA Deviation (v2) Filter: Prevents trades after significant price deviations from EMAs, indicating potential overextension.
Configurable parameters: Timeframe, Fast EMA Length, Slow EMA Length, Average Lookback, Signal Multiplier.
Advanced RSI Conditions Filter (Forbidding): Allows defining multiple conditions based on RSI, its EMAs, and Bollinger Bands that, if any are met, forbid a trade. Includes "Death Cross" and "Golden Cross" variations.
Configurable parameters: Timeframe, RSI Length, BB Length, BB Multiplier, Fast EMA Length, Slow EMA Length, and numerous toggleable rules with customizable operators (Above/Below) and values for BB, RSI, and EMA relationships.
Advanced RSI Conditions Filter - 2 (Allowing): Similar to the forbidding filter, but trades are only allowed if all enabled conditions are met.
Configurable parameters: Same as the forbidding filter, but for allowing rules.
DMF (Dynamic Money Flow) Filter: Filters trades based on a custom Dynamic Money Flow indicator and its moving averages.
Configurable parameters: Timeframe, Period, Moving Average Type (EMA, WMA, T3, FRAMA), Fast Length, Slow Length.
Detailed Long/Short Conditions: Allows precise control over the DMF value, fast MA, and slow MA ranges, and cloud conditions for both long and short entries.
Trade Execution Logic:
Signal Generation: Either Chandelier Exit or Trend Trader generates a raw buy or sell signal.
Filter Application: The raw signal is then passed through all enabled filters.
For forbidding filters, if any of their active rules are met, the trade is blocked.
For allowing filters, all of their active rules must be met for the trade to proceed.
Combined Filters: All active filters must allow a trade for it to be considered valid.
Entry: If a valid buySignal and allowLong conditions are met (and not holding until stop, or if holding until stop, there's no open position), a "Long" entry is executed. The same applies for "Short" entries.
Stop Loss Calculation: Upon entry, an initial Stop Loss price is calculated based on the chosen type (Fixed/Trailing) and parameters.
For trailing SL, the active_long_stop or active_short_stop is updated to trail the price.
Take Profit Calculation: If useTakeProfit is true and holdUntilStop is false, a Take Profit target is calculated based on the chosen method (Percentage or Risk/Reward).
Exit:
If the price hits the Stop Loss, the position is closed.
If the price hits the Take Profit target, the position is closed (unless holdUntilStop is active).
Plotting:
The script plots:
Calculated Stop Loss and Take Profit levels (as white lines, typically for visual debugging).
The active Trailing Stop Loss lines (green for long, red for short).
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。