AugustoErni

Uptrend Downtrend Loopback Candle Identification Lib

AugustoErni Cập nhật   
This library is for identifying uptrends and downtrends using a loopback candle analysis method. Which contains two functions:
uptrendLoopbackCandleIdentification() and downtrendLoopbackCandleIdentification(). These functions check if the current candle is part of an uptrend or downtrend, respectively, based on the specified lookback period.

The uptrendLoopbackCandleIdentification() takes two arguments: index, which is the index of the current bar, and lookbackPeriod, which is the number of previous candles to check for an uptrend. The function returns false if the index is less than the lookback period. Otherwise, it initializes a boolean variable isHigherHigh as true and loops through the previous candles. If any of the previous candles have a higher high than the current candle, isHigherHigh is set to false, and the loop breaks. Finally, the function returns the value of isHigherHigh.

The downtrendLoopbackCandleIdentification() takes the same arguments and returns false if the index is less than the lookback period. The function initializes a boolean variable isHigherLow as true and loops through the previous candles. If any of the previous candles have a higher low than the current candle, isHigherLow is set to false, and the loop breaks. The function returns the value of isHigherLow.
Phát hành các Ghi chú:
v2

Updated:
uptrendLoopbackCandleIdentification(lookbackPeriod)
  Parameters:
    lookbackPeriod (int)

downtrendLoopbackCandleIdentification(lookbackPeriod)
  Parameters:
    lookbackPeriod (int)

uptrendLoopbackCandleIdentification:
The function starts by declaring a variable isUptrend and initializes it as false. This variable will be used to store the result of the loop analysis.
A for loop is used to iterate through the specified lookbackPeriod with the loop index variable i.
Inside the loop, the code checks if the low of the current bar (low) is greater than or equal to the low of the bar i bars ago (low).
If the condition in step 3 is met, the variable isUptrend is set to true.
After the loop has finished, the function returns the final value of isUptrend.

downtrendLoopbackCandleIdentification:
The function starts by declaring a variable isDowntrend and initializes it as false. This variable will be used to store the result of the loop analysis.
A for loop is used to iterate through the specified lookbackPeriod with the loop index variable i.
Inside the loop, the code checks if the low of the current bar (low) is less than or equal to the low of the bar i bars ago (low).
If the condition in step 3 is met, the variable isDowntrend is set to true.
After the loop has finished, the function returns the final value of isDowntrend.

Each function will return true if the respective condition is met for any bar within the lookback period. The loops will not terminate early if the conditions are met.
Phát hành các Ghi chú:
v3

add else to change variable value and break the loop to return the expected result.

Thư viện Pine

Với tinh thần TradingView thực sự, tác giả đã xuất bản mã Pine này như một thư viện mã nguồn mở để các lập trình viên Pine khác từ cộng đồng của chúng tôi có thể sử dụng lại nó. Chúc mừng tác giả! Bạn có thể sử dụng thư viện này một cách riêng tư hoặc trong các ấn phẩm mã nguồn mở khác, nhưng việc sử dụng lại mã này trong một ấn phẩm chịu sự điều chỉnh của Nội quy chung.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.

Bạn muốn sử dụng thư viện này?

Sao chép văn bản vào khay nhớ tạm và dán nó vào tập lệnh của bạn.