This code represents a TradingView strategy that uses Fibonacci levels in conjunction with high/low price criteria over specified lookback periods to determine buy (long) and sell (short) conditions. Below is an explanation of each main part of the code:
Explanation of Key Sections User Inputs for Higher Time Frame and Candle Settings
Users can select a higher time frame (timeframe) for analysis and specify whether to use the "Current" or "Last" higher time frame (HTF) candle for calculating Fibonacci levels. The currentlast setting allows flexibility between using real-time or the most recent closed higher time frame candle. Lookback Periods for High/Low Criteria
Two lookback periods, lowestLookback and highestLookback, allow users to set the number of bars to consider when finding the lowest and highest prices, respectively. This determines the criteria for entering trades based on how recent highs or lows compare to current prices. Fibonacci Levels Configuration
Fibonacci levels (0%, 23.6%, 38.2%, 50%, 61.8%, 78.6%, and 100%) are configurable. These are used to calculate price levels between the high and low of the higher time frame candle. Each level represents a retracement or extension relative to the high/low range of the HTF candle, providing important price levels for decision-making. HTF Candle Calculation
HTF candle data is calculated based on the higher time frame selected by the user, using the newbar check to reset htfhigh, htflow, and htfopen values. The values are updated with each new HTF bar or as prices move within the same HTF bar to track the highest high and lowest low accurately. Set Fibonacci Levels Array
Using the calculated HTF candle's high, low, and open, the Fibonacci levels are computed by interpolating these values according to the user-defined Fibonacci levels. A fibLevels array stores these computed values. Plotting Fibonacci Levels
Each Fibonacci level is plotted on the chart with a different color, providing visual indicators for potential support/resistance levels. High/Low Price Criteria Calculation
The lowest and highest prices over the specified lookback periods (lowestLookback and highestLookback) are calculated and plotted on the chart. These serve as dynamic levels to trigger long or short entries. Trade Signal Conditions
longCondition: A long (buy) signal is generated when the price crosses above both the lowest price criteria and the 50% Fibonacci level. shortCondition: A short (sell) signal is generated when the price crosses below both the highest price criteria and the 50% Fibonacci level. Executing Trades
Based on the longCondition and shortCondition, trades are entered with the strategy.entry() function, using the labels "Long" and "Short" for tracking on the chart. Strategy Use This strategy allows traders to utilize Fibonacci retracement levels and recent highs/lows to identify trend continuation or reversal points, potentially providing entry points aligned with larger market structure. Adjusting the lowestLookback and highestLookback along with Fibonacci levels enables a customizable approach to suit different trading styles and market conditions.
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun das Script auch andere Trader verstehen und prüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden. Die Nutzung dieses Codes in einer Veröffentlichung wird in unseren Hausregeln reguliert. Sie können es als Favoriten auswählen, um es in einem Chart zu verwenden.
Möchten Sie dieses Skript auf einem Chart verwenden?
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.