RozaniGhani-RG

Price Cross Time Custom Range Interactive

█  OVERVIEW
This indicator was a time-based indicator and intended as educational purpose only based on pine script v5 functions for ta.cross(), ta.crossover() and ta.crossunder().
I realised that there is some overlap price with the cross functions, hence I integrate them into Custom Range Interactive with value variance and overlap displayed into table.
This was my submission for Pinefest #1, I decided to share this as public, I may accidentally delete this as long as i keep as private.

█ INSPIRATION
Inspired by design, code and usage of CAGR. Basic usage of custom range / interactive, pretty much explained here. Credits to TradingView.

█ FEATURES
1. Custom Range Interactive
2. Label can be resize and change color.
3. Label show tooltip for price and time.
4. Label can be offset to improve readability.
5. Table can show price variance when any cross is true.
6. Table can show overlap if found crosss is overlap either with crossover and crossunder.
7. Table text color automatically change based on chart background (light / dark mode).
8. Source 2 is drawn as straight line, while Source 1 will draw as label either above line for crossover, below line for crossunder and marked 'X' if crossing with Source 2's line.
9. Cross 'X' label can be offset to improve readability.
10. Both Source 1 and Source 2 can select Open, Close, High and Low, which can be displayed into table.

█ LIMITATIONS
1. Table is limited to intraday timeframe only as time format is not accurate for daily timeframe and above. Example daily timeframe will give result less 1 day from actual date.
2. I did not include other sources such external source or any built in sources such as hl2, hlc3, ohlc4 and hlcc4.

█ CODE EXPLAINATION
I pretty much create custom function with method which returns tuple value.
method crossVariant(float price = na, chart.point ref = na) =>
    cross = ta.cross(     price, ref.price)
    over  = ta.crossover( price, ref.price)
    under = ta.crossunder(price, ref.price)
    [cross, over , under]

Unfortunately, I unable make the labels into array which i plan to return string value by getting the text value from array label, hence i use label.all and add incremental int value as reference.
series label labelCross = na, labelCross.delete()
var int num = 0
if over
	num += 1
    labelCross := label.new()
if under
	num += 1
    labelCross := label.new()
if cross 
    num += 1
    labelCross := label.new()

I realised cross value can be overlap with crossover and crossunder, hence I add bool to enable force overlap and add additional bools.
series label labelCross = na, labelCross.delete()
var int num = 0
if forceOverlap
    if over
        num += 1
        labelCross := label.new()
    if under
        num += 1
        labelCross := label.new()
    if cross 
        num += 1
        labelCross := label.new()
else
    if cross and over
        num += 1
        labelCross := label.new()
    if cross and under
        num += 1
        labelCross := label.new()
    if cross and not over and not under
        num += 1
        labelCross := label.new()

█ USAGE / EXAMPLES

오픈 소스 스크립트

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

면책사항

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

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