p2pasta

CCI/MFI/VZO/RSI - HEATMAP

p2pasta 업데이트됨   
Heatmap I made/reverse engineered.

Currently tracks the 4 following oscillators:
- CCI (Channel Commodity Index)
- MFI (Money Flow Index)
- VZO (Volume Zone Oscillator)
- RSI (Relative Strength Index)

Any feedback or suggestions highly appreciated.

/* Inspiration taken from @UnknownUnicorn2188849 (TradingView profile: /u/ByzantineGeneral, indicator: /script/keAGdnWO-Byzantium-Oscillator-Heatmap) */
릴리즈 노트:
Clarified user input.

- Changed levels (editable = false) -> These where transparent 100% anyways so made the input screen unorganized.
- Changed plot (editable = false) -> These where transparent 100% anyways so made the input screen unorganized.

Only the inputs that have visual difference are now being shown i.e the fill colors
릴리즈 노트:
New version because the screenshot of showing the indicator was not sized properly.
릴리즈 노트:
VERSION 1.4

On request, I added buy/long and sell/short signals dependig on certain conditions. The indicator will display those above or below the heatmap. Unfortunately, I had to add some 'whitespace' above and below the heatmap for the signals to become visible, otherwise the signals would blend in with the heatmap.

I want to keep this as a standalone indicator. If you want me to turn this into a strategy, let me know and i'll make a new script for this.
릴리즈 노트:
VERSION 1.5 (because why not)

CORE CHANGES:
Added color gradients instead of using if/else stacks for choosing color. Thankfully, a gradient framework was already in circulation by @PineCoders
You can find the framework here:
- Removed the two 'whitespace' horizontal lines again so it looks more clean in my opinion.
- Changed the plotchart symbols to the color white so it is visible even if the oscillator has the maximum color gradient assigned.
- Added more comments to the code for better reusability
릴리즈 노트:
VERSION 1.6

- Added input for customizing the colors that are used for the gradient (Default values: #0097A7, #9C27B0 - Bullish, Bearish)
- Removed the Oscillator inputs and turned them into constants (Default values: 14, 28, 14, 28 - RSI, VZO, MFI, CCI )
- Removed some unnecessary code: unused color constants and colors needed for previous versions
- Reformatted the code for easier source reading and reusability
릴리즈 노트:
  • Version Information: The version number and author information have been removed from the code.
  • Simplified Input Colors: The user input colors are now set using the simple #RRGGBB format instead of input.color function. Additionally, the input names have been adjusted for clarity.
  • Renamed Gradient Function: The function f_c_gradientRelativePro has been removed, and the existing f_c_gradientRelative function now handles both cases of gradient color calculation.
  • Removed Redundant Constants: The color constants (C_AQUA, C_BLACK, etc.) have been removed as they were not used in the updated code.
  • Updated Horizontal Lines: The horizontal lines (h0, h1, h2, h3, h4) are now created using hline with the input values (oversoldThreshold, overboughtThreshold, etc.) directly, avoiding any redundant intermediate variables.
  • Updated Signal Conditions: The conditions for generating Long and Short signals have been modified for better performance and accuracy.
  • Signal Marker Colors: The color for the Long and Short signal markers (▲ and ▼) is now set to alertColor to be consistent with the color used in other parts of the indicator.
  • Removed Unused Commented Code: Some commented-out plotting statements have been removed from the code for better clarity and to reduce unnecessary lines.
  • Removed Gradient "center" variable: The _center variable used in the gradient function has been removed, and the calculation is directly applied within the color.from_gradient function.
  • Updated Gradient Colors: The input color names used in the gradient function are updated to match the new input names, and the gradient calculation is simplified using ternary operators.
릴리즈 노트:
  • Changed the default values for the oversoldThreshold and overboughtThreshold inputs from 25 and 75 to 26 and 74, respectively.
  • Updated the horizontal lines for h1 and h2 to be at levels 25 and 50, respectively.
  • Renamed the variable test to combined to reflect its actual purpose.
  • Changed the title of the plot from "Combined" to "Combined Heatmap" to provide a more descriptive name.
  • Removed the editable=false property from the horizontal lines h1, h2, h3, and h4 since editable properties are not applicable for script plots.
  • Adjusted the conditions for the enterLong and enterShort signals based on the new threshold values (26 and 74).
릴리즈 노트:
I have rolled out an updated version of the CCI/MFI/VZO/RSI Heatmap indicator. Here's what's new and what you can expect:

Pine Script Version
The indicator is now using Pine Script version 5, which allows us to make use of newer features and functionalities. This makes the indicator more robust and compatible with future updates.

User Inputs
The color input fields have been simplified. You no longer have to specify the type of input; the script automatically detects it based on the default value. This makes the setup process a tad quicker.

Technical Indicators
The calculation logic for RSI, VZO, MFI, and CCI remains the same. So, you can expect the same level of accuracy and performance as the previous version.

Visual Enhancements
We've added transparent horizontal lines for better visual cues. These lines will help you quickly identify the different regions of the plot, enhancing readability.

Code Efficiency
The code has been optimized for better performance, although the core functionalities remain the same.

Signals
The buy and sell signals are generated in the same manner as the previous version, keeping the strategy consistent.

New Color Scheme
The color scheme remains the same; however, the script is now more efficient in generating the gradient colors, which should result in smoother transitions.

Please note that these updates are aimed at improving the efficiency and readability of the indicator. Feel free to reach out if you have any questions or encounter any issues.
릴리즈 노트:
  1. Input Modification:
    In the old version, the lengths of the indicators were hardcoded. In the new version, these have been changed to user inputs, allowing for more flexibility and customization.
    Grouped related inputs together under labels like "Length", "Alert Thresholds", "Colors", and "Multi-Timeframe" for better organization and user experience.

    // Old Version:
    rsi_y = 14
    vzo_y = 28
    mfi_y = 14
    cci_y = 28
    
    // New Version:
    rsi_y = input.int(14, "RSI", group="Length")
    vzo_y = input.int(28, "VZO", group="Length")
    mfi_y = input.int(14, "MFI", group="Length")
    cci_y = input.int(28, "CCI", group="Length")

  2. Multi-Timeframe Analysis:
    Added the ability to analyze a secondary timeframe alongside the current timeframe. This feature helps in providing a more robust analysis by considering higher timeframe data.

    higherTf = input.timeframe("D", "Higher Timeframe", group="Multi-Timeframe")

  3. Indicator Calculation Enhancement:
    Extended the script to include a secondary combined oscillator calculation (tf2Combined) based on the higher timeframe. This allows for dual timeframe analysis within the same script, providing a more comprehensive view.

    tf2(x) => request.security(syminfo.tickerid, higherTf, ta.rsi(close, x))
    tf2_rsi = tf2(rsi_y)
    tf2_mfi = tf2(mfi_y)
    tf2_vzo = request.security(syminfo.tickerid, higherTf, vzo(vzo_y))
    tf2_cci = tf2(cci_y)
    tf2Combined = (tf2_rsi * 9 + tf2_mfi * 9 + (tf2_vzo + 100) * 4.5 + tf2_cci + 450) / 3600 * 100

  4. Plotting Enhancement:
    Added a new plot for the secondary combined oscillator (tf2Combined) with a distinct title and color to differentiate it from the primary combined oscillator plot.

    plot(tf2Combined, 'Timeframe 2', higherTfColor, linewidth = 2)

  5. Color Input Modification:
    Introduced a new color input for the higher timeframe plot for better differentiation and user customization.

    higherTfColor = input(#D1D4DC, 'Color', group = "Multi-Timeframe")

  6. Alert Color Modification:
    Changed the alert color input default value for better visibility.

    // Old Version:
    alertColor = input(#ffffff, 'Alert color')
    
    // New Version:
    alertColor = input(#D1D4DC, 'Alert color', group = "Colors")


  7. Explanation:

    - The shift from hardcoded values to user inputs enhances the flexibility and usability of the script.
    - The multi-timeframe analysis is a significant upgrade that allows users to analyze higher timeframe data alongside the current timeframe, which can be crucial for identifying broader market trends and making more informed trading decisions.
    - The new plot for the secondary timeframe provides a visual representation of the higher timeframe data, which, when compared to the current timeframe data, can provide a more nuanced understanding of market conditions.
    - The color modifications improve the visual aesthetics of the script, making it easier to differentiate between different plots and understand the alert signals.
릴리즈 노트:
  1. Multi-Timeframe Enablement:
    A significant addition is the option to enable or disable multi-timeframe analysis. This is controlled by a new input toggle named higherTfEnabled.

    higherTfEnabled = input.bool(true, "Enabled", group="Multi-Timeframe")

  2. Multi-Timeframe Color Modification:
    The color input for the higher timeframe plot has been updated to a new default color. This change makes the secondary timeframe plot more distinguishable from other plots.

    // Old Version:
    higherTfColor = input(#D1D4DC, 'Color', group = "Multi-Timeframe")
    
    // New Version:
    higherTfColor = input(#F57C00, 'Color', group = "Multi-Timeframe")

  3. Multi-Timeframe Plotting:
    The secondary timeframe plot is now conditional based on the higherTfEnabled input. This allows users to toggle the secondary timeframe plot on and off, providing better control over what is displayed.

    plot(higherTfEnabled ? tf2Combined : na, 'Timeframe 2', higherTfColor, linewidth = 2)

  4. Indicator Calculations:
    The calculation methodology for higher timeframe data has been streamlined by consolidating the request.security function calls within the main indicator calculations section. This change improves code readability and maintenance.

    tf2_rsi = request.security(syminfo.tickerid, higherTf, ta.rsi(close, rsi_y))
    tf2_mfi = request.security(syminfo.tickerid, higherTf, ta.mfi(close, mfi_y))
    tf2_vzo = request.security(syminfo.tickerid, higherTf, vzo(vzo_y))
    tf2_cci = request.security(syminfo.tickerid, higherTf, ta.cci(close, cci_y))

  5. Explanation:

    - The new higherTfEnabled toggle is a valuable addition for users who may not always require a multi-timeframe analysis. This feature provides a way to declutter the indicator window when needed.
    - The color modification for the higher timeframe plot ensures that users can easily differentiate between the current and higher timeframe data, improving the overall user experience.
    - Streamlining the higher timeframe data calculations by consolidating the request.security function calls makes the code more readable and easier to maintain. This is a crucial change for anyone who might want to further customize or extend the script.
릴리즈 노트:
Version Update Summary


This update focuses on improving the efficiency and readability of the code, without changing the core functionality of the indicator. Various parts of the code have been refactored, and common calculations are now reused.


Detailed Changes


Input Groups
  • Old: Variable-length input groups were not efficiently named.
  • New: Shortened and clarified input group names for better readability.
Utility Functions
  • Old: Repeated calculations for combined indicators.
  • New: Introduced calcCombined() function to handle the combined indicator calculation, making the code DRY (Don't Repeat Yourself).
Indicator Calculations
  • Old: Separate calls to request.security() for each higher timeframe indicator.
  • New: Batched the higher timeframe indicator calculations into a single request.security() call, improving efficiency.
Signal Definitions
  • Old: Signal conditions were verbose.
  • New: Shortened variables used in signal definitions for better readability.

What Remains Unchanged?
The core functionality and calculations remain the same.
The color schemes and alert conditions are consistent with the old version.

What Does This Mean for You?
As a user, you'll find the updated version to be functionally identical to the old one. The changes are mainly under the hood, aimed at making the code more efficient and maintainable. No action is required on your part unless you're interested in customizing the indicator further.

Feel free to dive into the new code if you're curious!

오픈 소스 스크립트

이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?