OPEN-SOURCE SCRIPT

Futures Auto Levels [NariCapitalTrading]

Zaktualizowano
[center][size=5]Futures Auto Levels Indicator[/size][/center]

[size=4]Introduction[/size]

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

[size=4]Indicator Components[/size]

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.

[size=4]How to Use the Indicator[/size]

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.

[size=4]Suggested/Potential Strategies[/size]

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.

[size=4]Conclusion[/size]

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
[size=3]Introduction[/size]
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.

[size=3]Original Code Functionality[/size]
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.

[size=3]Updated Code Enhancements[/size]
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.

[size=3]Changes and Enhancements[/size]
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.
[size=3]Detailed Code Comparison[/size]

Original Code Excerpt:
[code]
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
[/code]

Updated Code Excerpt:
[code]
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)
[/code]

[size=3]Comparison and Conclusion[/size]
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
Informacje o Wersji
Made changes to the code to more accurately identify initial balance (here is set to NY time zone, users may need to adjust code or chart settings for their preferred time zone)

Users now have the option to choose the color and transparency of the lines for each level, and the option to toggle levels on/off in the settings.

Changes to the code also include optimized calculations
forecastingmultitimeframePivot points and levels

Skrypt open-source

W prawdziwym duchu TradingView autor tego skryptu opublikował go jako open source, aby inwestorzy mogli go zrozumieć i zweryfikować. Pozdrowienia dla autora! Możesz go używać bezpłatnie, ale ponowne użycie tego kodu w publikacji podlega Zasadom Regulaminu. Możesz go oznaczyć jako ulubione, aby użyć go na wykresie.

Chcesz użyć tego skryptu na wykresie?


Również na:

Wyłączenie odpowiedzialności