Smart Trend, Crypto - WORK IN PROGRESSDescription of the Script
This Pine Script is a trend-following trading indicator designed to help traders identify buy and sell opportunities while managing risk through take-profit (TP) and stop-loss (SL) levels. Here’s what the script does in detail:
Core Features:
1. Trend Detection Using EMA Crossover:
• Fast EMA and Slow EMA are calculated using adjustable lengths.
• A Buy Signal is triggered when the Fast EMA crosses above the Slow EMA (bullish trend).
• A Sell Signal is triggered when the Fast EMA crosses below the Slow EMA (bearish trend).
2. Support for Multi-Condition Signals:
• The script combines EMA crossovers, RSI levels, and ADX strength to determine signals:
• Relative Strength Index (RSI): Detects overbought or oversold conditions.
• Average Directional Index (ADX): Ensures trends have sufficient strength.
• Signals only trigger if all selected conditions are met.
Risk Management Features:
3. Stop-Loss Levels:
• Stop-loss levels are calculated based on a percentage distance from the last Buy or Sell Signal.
• For a Buy Signal, the stop-loss is set below the buy price.
• For a Sell Signal, the stop-loss is set above the sell price.
• These levels are plotted as horizontal lines on the chart.
4. Take-Profit Levels:
• Take-profit levels are calculated as a percentage distance from the last Buy or Sell Signal:
• For a Buy Signal, the TP level is above the buy price.
• For a Sell Signal, the TP level is below the sell price.
• Take-Profit Bubbles:
• Small bubbles appear on the chart at TP levels only for the current Buy or Sell Signal.
• This helps focus on the latest trade without cluttering the chart.
Visual Aids:
5. Background Highlighting for Trend Identification:
• The chart background changes color to reflect the detected trend:
• Green for a bullish trend (Buy Signal).
• Red for a bearish trend (Sell Signal).
6. Clear Signal Markers:
• Buy Signal: A green triangle below the price bar.
• Sell Signal: A red triangle above the price bar.
• These markers help visually identify signal points on the chart.
Customizability:
• Adjustable Parameters: The script allows the user to customize:
• EMA lengths, ADX threshold, RSI levels, TP percentage, and SL percentage.
• Preset Configurations: Quick settings for popular assets like BTC, ETH, and others.
Usage:
1. Buy and Sell Signals:
• Use the signals to enter long (Buy) or short (Sell) trades.
2. Risk Management:
• Follow the Stop Loss and Take Profit levels to manage risk and lock in profits.
3. Trend Confirmation:
• Observe background colors and EMA lines to confirm trend direction.
This script provides a comprehensive tool for identifying trades, managing risk, and visually simplifying trend-following strategies. Let me know if you need further clarifications!
WORK
Efficient Work [LucF]█ OVERVIEW
Efficient Work measures the ratio of price movement from close to close ( resulting work ) over the distance traveled to the high and low before settling down at the close ( total work ). The closer the two values are, the more Efficient Work approaches its maximum value of +1 for an up move or -1 for a down move. When price does not change, Efficient Work is zero.
Higher values of Efficient Work indicate more efficient price travel between the close of two successive bars, which I interpret to be more significant, regardless of the move's amplitude. Because it measures the direction and strength of price changes rather than their amplitude, Efficient Work may be thought of as a sentiment indicator.
█ CONCEPTS
This oscillator's design stems from a few key concepts.
Relative Levels
Other than the centerline, relative rather than absolute levels are used to identify levels of interest. Accordingly, no fixed levels correspond to overbought/oversold conditions. Relative levels of interest are identified using:
• A Donchian channel (historical highs/lows).
• The oscillator's position relative to higher timeframe values.
• Oscillator levels following points in time where a divergence is identified.
Higher timeframes
Two progressively higher timeframes are used to calculate larger-context values for the oscillator. The rationale underlying the use of timeframes higher than the chart's is that, while they change less frequently than the values calculated at the chart's resolution, they are more meaningful because more work (trader activity) is required to calculate them. Combining the immediacy of values calculated at the chart's resolution to higher timeframe values achieves a compromise between responsiveness and reliability.
Divergences as points of interest rather than directional clues
A very simple interpretation of what constitutes a divergence is used. A divergence is defined as a discrepancy between any bar's direction and the direction of the signal line on that same bar. No attempt is made to attribute a directional bias to divergences when they occur. Instead, the oscillator's level is saved and subsequent movement of the oscillator relative to the saved level is what determines the bullish/bearish state of the oscillator.
Conservative coloring scheme
Several additive coloring conditions allow the bull/bear coloring of the oscillator's main line to be restricted to specific areas meeting all the selected conditions. The concept is built on the premise that most of the time, an oscillator's value should be viewed as mere noise, and that somewhat like price, it only occasionally conveys actionable information.
█ FEATURES
Plots
• Three lines can be plotted. They are named Main line , Line 2 and Line 3 . You decide which calculation to use for each line:
• The oscillator's value at the chart's resolution.
• The oscillator's value at a medium timeframe higher than the chart's resolution.
• The oscillator's value at the highest timeframe.
• An aggregate line calculated using a weighed average of the three previous lines (see the Aggregate Weights section of Inputs to configure the weights).
• The coloring conditions, divergence levels and the Hi/Lo channel always apply to the Main line, whichever calculation you decide to use for it.
• The color of lines 2 and 3 are fixed but can be set in the "Colors" section of Inputs.
• You can change the thickness of each line.
• When the aggregate line is displayed, higher timeframe values are only used in its calculation when they become available in the chart's history,
otherwise the aggregate line would appear much later on the chart. To indicate when each higher timeframe value becomes available,
a small label appears near the centerline.
• Divergences can be shown as small dots on the centerline.
• Divergence levels can be shown. The level and fill are determined by the oscillator's position relative to the last saved divergence level.
• Bull/bear markers can be displayed. They occur whenever a new bull/bear state is determined by the "Main Line Coloring Conditions".
• The Hi/Lo (Donchian) channel can be displayed, and its period defined.
• The background can display the state of any one of 11 different conditions.
• The resolutions used for the higher timeframes can be displayed to the right of the last bar's value.
• Four key values are always displayed in the Data Window (fourth icon down to the right of your chart):
oscillator values for the chart, medium and highest timeframes, and the oscillator's instant value before it is averaged.
Main Line Coloring Conditions
• Nine different conditions can be selected to determine the bull/bear coloring of the main line. All conditions set to "ON" must be met to determine the bull/bear state.
• A volatility state can also be used to filter the conditions.
• When the coloring conditions and the filter do not allow for a bull/bear state to be determined, the neutral color is used.
Signal
• Seven different averages can be used to calculate the average of the oscillator's value.
• The average's period can be set. A period of one will show the instant value of the oscillator,
provided you don't use linear regression or the Hull MA as they do not work with a period of one.
• An external signal can be used as the oscillator's instant value. If an already averaged external value is used, set the period to one in this indicator.
• For the cases where an external signal is used, a centerline value can be set.
Higher Timeframes
• The two higher timeframes are named Medium timeframe and Highest timeframe . They can be determined using one of three methods:
• Auto-steps: the higher timeframes are determined using the chart's resolution. If the chart uses a seconds resolution, for example,
the medium and highest resolutions will be 15 and 60 minutes.
• Multiples: the timeframes are calculated using a multiple of the chart's resolution, which you can set.
• Fixed: the set timeframes do not change with the chart's resolution.
Repainting
• Repainting can be controlled separately for the chart's value and the higher timeframe values.
• The default is a repainting chart value and non-repainting higher timeframe values. The Aggregate line will thus repaint by default,
as it uses the chart's value along with the higher timeframes values.
Aggregate Weights
• The weight of each component of the Aggregate line can be set.
• The default is equal weights for the three components, meaning that the chart's value accounts for one third of the weight in the Aggregate.
High Volatility
• This provides control over the volatility filter used in the Main line's coloring conditions and the background display.
• Volatility is determined to be high when the short-term ATR is greater than the long-term ATR.
Colors
• You can define your own colors for all of the oscillator's plots.
• The default colors will perform well on both white and black chart backgrounds.
Alerts
• An alert can be defined for the script. The alert will trigger whenever a bull/bear marker appears in the indicator's display.
The particular combination of coloring conditions and the display of bull/bear markers when you create the alert will thus determine when the alert triggers.
Once the alerts are created, subsequent changes to the conditions controlling the display of markers will not affect the existing alert(s).
• You can create multiple alerts from this script, each triggering on different conditions.
Backtesting & Trading Engine Signal Line
• An invisible plot named "BTE Signal" is provided. It can be used as an entry signal when connected to the PineCoders Backtesting & Trading Engine as an external input.
It will generate an entry whenever a marker is displayed.
█ NOTES
• I do not know for sure if the calculations in Efficient Work are original. I apologize if they are not.
• Because this version of Efficient Work only has access to OHLC information, it cannot measure the total distance traveled through all of a bar's ticks, but the indicator nonetheless behaves in a manner consistent with the intentions underlying its design.
For Pine coders
This code was written using the following standards:
• The PineCoders Coding Conventions for Pine .
• A modified version of the PineCoders MTF Oscillator Framework and MTF Selection Framework .