KUCOIN:KSMUSDT   Kusama / Tether
//@version=4
study(title="OBV Divergence Indicator")

pivot_right = 5
pivot_left = 5
max_range=50
min_range=5

obv_value=obv
plot(obv_value, title="OBV", linewidth=2, color=color.black)


//check if we have pivot low in obv
pivot_low_true = na(pivotlow(obv_value, pivot_left, pivot_right)) ? false : true //returns price of the pivot low point. It returns 'NaN', if there was no pivot low point.

//Create a function that returns true/false
confirm_range(x) =>
bars = barssince(x == true) //Counts the number of bars since the last time the condition was true
min_range <= bars and bars <= max_range // makes ure bars is less than 60 and less than 5 and returns true

//------------------------------------------------------------------------------
// obv higher low check

OBV_HL_check = obv_value > valuewhen(pivot_low_true, obv_value, 1) and confirm_range(pivot_low_true)

// Price Lower Low check

price_ll_check = low < valuewhen(pivot_low_true, low, 1)

bullCond = price_ll_check and OBV_HL_check and pivot_low_true

//Plot the areas, terneary conditional operator
plot(
pivot_low_true ? obv_value : na,
offset=-pivot_right,
linewidth=3,
color=(bullCond ? color.green : color.new(color.white, 100)))//colornew applies the specified transparency to the given color

)

plotshape(
bullCond ? obv_value : na,
offset=-pivot_right,
text=" BUY ",
style=shape.labelup,
location=location.absolute,
color=color.green,
textcolor=color.white

)

Idées en relation

Clause de non-responsabilité

Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.