NariCapitalTrading

Futures Auto Levels [NariCapitalTrading]

NariCapitalTrading Zaktualizowano   
Futures Auto Levels Indicator

Introduction

The "Futures Auto Levels" (FAL) indicator shows the previous day's levels, weekly open, high, low, and the Initial Balance Range (IBR).

Indicator Components

The FAL indicator comprises the following components:

Previous Day's Levels: These include the open, high, low, and close of the previous trading day. They are represented on the chart by lines and labels, helping to identify significant price levels from the prior session.
Weekly Open, High, Low: These levels represent the open, high, and low prices of the current trading week.
Initial Balance Range (IBR): The IBR is calculated based on the price range during the first 60 minutes of the trading day. It helps identify initial trading range and potential breakout levels.

How to Use the Indicator

1. Previous Day's Levels:

Monitor the previous day's open, high, low, and close to identify key support and resistance levels.
Use these levels to gauge market sentiment and potential price reversals.
2. Weekly Open, High, Low:

Pay attention to the weekly open, high, and low to understand the market's behavior within the weekly timeframe.
These levels can act as reference points for setting profit targets and stop-loss orders.
3. Initial Balance Range (IBR):

Watch for price movements within the IBR to identify potential trading opportunities.
Breakouts above or below the IBR may signal the beginning of a new trend or continuation of the current trend.

Suggested/Potential Strategies

Reversal Trading: Look for price reversals around previous day's levels, especially when they coincide with other technical indicators or significant support/resistance zones.
Trend Following: Follow the trend by trading breakouts above/below the IBR or weekly high/low levels. Use trailing stops to capture profits while the trend remains intact.
Range Trading: Trade within the IBR when the market is consolidating. Buy near the IBR low and sell near the IBR high, with tight stop-loss orders to manage risk.

Conclusion

The Futures Auto Levels indicator is designed to help incorporate levels into trading analysis and trading strategies to improve profitability and consistency.
Informacje o Wersji:
Changes in the New Code:
1. Input Controls:
- In the new code, the display of different time frame levels (Daily, Weekly, Monthly, Quarterly) can be toggled using boolean inputs (showDaily, showWeekly, showMonthly, showQuarterly). This allows for greater customization and flexibility in displaying levels based on user preferences.

2. Data Fetching:
- Previously, weekly open, high, and low were fetched using array destructuring. In the new code, individual variables are assigned for weekly open, high, and low, enhancing code readability and maintainability.

3. Initialization and Reset:
- In the new code, variables for daily, weekly, monthly, and quarterly levels are initialized using a function (resetLevels()). This ensures a consistent approach to initializing variables and reduces redundancy.

4. Level Update Handling:
- The new code implements functions (updateLevels() and handleLevel()) to handle the updating and drawing of levels, enhancing modularity and code organization.
- Additionally, alerts for each level type are added in the new code, providing timely notifications when price reaches significant levels.

5. Code Organization and Readability:
- The new code is organized into distinct sections, making it easier to understand and maintain.
- Variable declarations, level updates, level drawing functions, and alert conditions are clearly separated, improving code readability and organization.

Conclusion:
The new code for the "Futures Auto Levels" indicator introduces several improvements over the old code, including enhanced input controls, modular level handling, and improved code organization. These changes aim to provide a more flexible and user-friendly indicator for identifying significant price levels in futures trading.
Informacje o Wersji:
Introduction
This script is designed to plot key levels (daily, weekly, monthly, quarterly, and initial balance) on trading charts. These levels provide traders with significant reference points from previous periods.

Original Code Functionality
The original script accomplished the following:

Input Handling: Allowed users to toggle the visibility of daily, weekly, monthly, quarterly, and initial balance levels.
Data Fetching: Retrieved open, high, low, and close prices from previous periods using the request.security function.
Level Drawing: Used the drawLevel function to plot levels and create/update labels for each level.
Alerts: Set up alerts to notify users when the price reached key levels.
However, the original script faced issues with label creation and updating due to the use of mutable arguments in functions, leading to repeated plotting of labels.

Updated Code Enhancements
The updated script addresses the issues in the original by restructuring the label handling and ensuring that labels are created and updated correctly without repetition.

Changes and Enhancements
The key changes and enhancements made in the updated script are as follows:

Label Management:

Original Approach: Used a single function (drawLevel) to draw lines and manage labels. This function accepted mutable arguments, causing errors and label duplication.

Updated Approach: Separated line drawing and label updating into distinct functions. Managed label creation and updating using global variables and conditional logic outside the function to avoid mutable arguments.

Function Separation:

Line Drawing: The drawLine function is responsible for drawing lines without managing labels.

Label Updating/Creation: Labels are created or updated using straightforward if-else conditions, ensuring they are managed correctly without duplication.

Error Handling and Code Simplification:

Removed the use of ternary operators for label updates, replacing them with if-else blocks to handle label creation and updating more robustly.
Simplified the code structure to enhance readability and maintainability.
Detailed Code Comparison

Original Code Excerpt:

drawLevel(price, color, labelRef, labelText) =>
if not na(price)
line.new(bar_index, price, bar_index + 500, price, color=color, width=2, extend=extend.right)
if na(labelRef)
labelRef := label.new(bar_index, price, text=labelText, color=color, textcolor=color.white, style=label.style_label_right, size=size.tiny, yloc=yloc.price, xloc=xloc.bar_index)
else
label.set_xy(labelRef, bar_index, price)
labelRef


Updated Code Excerpt:

drawLine(price, color) =>
if not na(price)
line.new(bar_index, price, bar_index + 500, price, color=color, width=2, extend=extend.right)

// Update or create labels
if na(dailyOpenLabel)
dailyOpenLabel := label.new(bar_index, previousDayOpen, text="Prev Open", color=color.orange, textcolor=color.white, style=label.style_label_right, size=size.tiny, yloc=yloc.price)
else
label.set_xy(dailyOpenLabel, bar_index, previousDayOpen)


Comparison and Conclusion
Benefits of the Updated Approach:

Correct Label Handling: The updated script ensures that labels are created and updated correctly without duplication, solving the primary issue in the original code.
Improved Readability: By separating concerns (line drawing and label management), the code is more readable and easier to maintain.

Robustness: The use of if-else blocks for label management avoids issues with mutable arguments and ternary operators, making the script more robust.

Conclusion:
The updated script provides a more reliable and maintainable solution for automatically plotting key levels

Skrypt open-source

Zgodnie z prawdziwym duchem TradingView, autor tego skryptu opublikował go jako open-source, aby traderzy mogli go zrozumieć i zweryfikować. Brawo dla autora! Możesz używać go za darmo, ale ponowne wykorzystanie tego kodu w publikacji jest regulowane przez Dobre Praktyki. Możesz go oznaczyć jako ulubione, aby użyć go na wykresie.

Wyłączenie odpowiedzialności

Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.

Chcesz użyć tego skryptu na wykresie?