OPEN-SOURCE SCRIPT

Easy Profit JHIDALGO

Von Jchidalgo92
//version=5
indicator("Easy Profit JHIDALGO", overlay = true)

//------------------------------------------------------------------------------
// Settings
//------------------------------------------------------------------------------{
length = input.int(14, 'Swing Detection Lookback')
mult = input.float(1., 'Slope', minval = 0, step = .1)
calcMethod = input.string('Atr', 'Slope Calculation Method', options = ['Atr','Stdev','Linreg', 'RsiSlope'])
backpaint = input(true, tooltip = 'Backpainting offset displayed elements in the past. Disable backpainting to see real time information returned by the indicator.')
minBreakVolume = input.float(1.5, 'Min Break Volume Multiplier', tooltip = 'Minimum volume multiplier for breakout confirmation.')
useSupportResistanceFilter = input(true, 'Use Support/Resistance Filter')

//Style
upCss = input.color(color.teal, 'Up Trendline Color', group = 'Style')
dnCss = input.color(color.red, 'Down Trendline Color', group = 'Style')
showExt = input(true, 'Show Extended Lines')

//------------------------------------------------------------------------------
// Calculations
//------------------------------------------------------------------------------{
var upper = 0.
var lower = 0.
var slope_ph = 0.
var slope_pl = 0.
var offset = backpaint ? length : 0

n = bar_index
src = close

ph = ta.pivothigh(length, length)
pl = ta.pivotlow(length, length)

// Slope Calculation Method
slope = switch calcMethod
'Atr' => ta.atr(length) / length * mult
'Stdev' => ta.stdev(src,length) / length * mult
'Linreg' => math.abs(ta.sma(src * n, length) - ta.sma(src, length) * ta.sma(n, length)) / ta.variance(n, length) / 2 * mult
'RsiSlope' => ta.rsi(src, length) / 100 * mult

// Get slopes and calculate trendlines
slope_ph := ph ? slope : slope_ph
slope_pl := pl ? slope : slope_pl

upper := ph ? ph : upper - slope_ph
lower := pl ? pl : lower + slope_pl

var upos = 0
var dnos = 0
upos := ph ? 0 : close > upper - slope_ph * length ? 1 : upos
dnos := pl ? 0 : close < lower + slope_pl * length ? 1 : dnos

//------------------------------------------------------------------------------
// Support/Resistance Filter
//------------------------------------------------------------------------------{
var resistanceLevel = ta.highest(close, length)
var supportLevel = ta.lowest(close, length)
useSRFilter = useSupportResistanceFilter and ((close > resistanceLevel) or (close < supportLevel))

// Breakout Confirmation
breakoutVolume = volume > ta.sma(volume, length) * minBreakVolume

//------------------------------------------------------------------------------
// Extended Lines
//------------------------------------------------------------------------------{
var uptl = line.new(na,na,na,na, color = upCss, style = line.style_dashed, extend = extend.right)
var dntl = line.new(na,na,na,na, color = dnCss, style = line.style_dashed, extend = extend.right)

if ph and showExt
uptl.set_xy1(n-offset, backpaint ? ph : upper - slope_ph * length)
uptl.set_xy2(n-offset+1, backpaint ? ph - slope : upper - slope_ph * (length+1))

if pl and showExt
dntl.set_xy1(n-offset, backpaint ? pl : lower + slope_pl * length)
dntl.set_xy2(n-offset+1, backpaint ? pl + slope : lower + slope_pl * (length+1))

//------------------------------------------------------------------------------
// Plots
//------------------------------------------------------------------------------{
plot(backpaint ? upper : upper - slope_ph * length, 'Upper', color = ph ? na : upCss, offset = -offset)
plot(backpaint ? lower : lower + slope_pl * length, 'Lower', color = pl ? na : dnCss, offset = -offset)

// Breakouts with confirmation
plotshape(upos > upos[1] and useSRFilter and breakoutVolume, "Upper Break"
, shape.labelup
, location.absolute
, upCss
, text = "B"
, textcolor = color.white
, size = size.tiny)

plotshape(dnos > dnos[1] and useSRFilter and breakoutVolume, "Lower Break"
, shape.labeldown
, location.absolute
, dnCss
, text = "B"
, textcolor = color.white
, size = size.tiny)

//------------------------------------------------------------------------------
// Alerts
//------------------------------------------------------------------------------{
alertcondition(upos > upos[1] and useSRFilter and breakoutVolume, 'Upward Breakout', 'Price broke the down-trendline upward with confirmation')
alertcondition(dnos > dnos[1] and useSRFilter and breakoutVolume, 'Downward Breakout', 'Price broke the up-trendline downward with confirmation')

//------------------------------------------------------------------------------
Trend AnalysisVolatilityVolume

Open-source Skript

Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun das Script auch andere Trader verstehen und prüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden. Die Nutzung dieses Codes in einer Veröffentlichung wird in unseren Hausregeln reguliert. Sie können es als Favoriten auswählen, um es in einem Chart zu verwenden.

Möchten Sie dieses Skript auf einem Chart verwenden?

Haftungsausschluss