PHP Code:
//@version=5
indicator(title="Range Filter x Hull Suite", shorttitle="RF x Hull", overlay=true)
//selectedSession = input.string("No filter", options=["No filter", "New York", "London", "Tokyo", "Sydney"], title="Filter entry signals & alerts by session")
grp_CS = "Candlesticks"
//colorEntrybar = input(true, title="Show entry candles", group=grp_CS, inline="el")
//markEntrybar = input(true, title="Arrow", group=grp_CS, inline="el")
//entryLabels = input(false, title="Label", group=grp_CS, inline="el")
showRanging = input(true, title="Color consolidation candles", group=grp_CS, tooltip="Determined by the Range Filter settings as ranging/consolidating mid-range")
allCandleColor = input(true, title="Color trending candles", group=grp_CS, tooltip="Determined by the Range Filter settings as not ranging/consolidating")
grp_MAIN = "General"
//showWatermark = input(true, title="Show watermark", group=grp_MAIN)
//enableSessions = input(false, title="Show sessions", group=grp_MAIN)
//showHullRibbon = input(true, title="Show Hull ribbon", group=grp_MAIN)
showRF = input(false, title="Show Range Filter", group=grp_MAIN)
showRFBands = input(false, title="Show Range Filter bands", group=grp_MAIN)
//grp_MAVE = "Moving averages"
//enableMA = input(false, title="Show moving averages", group=grp_MAVE)
//enableMTFMA = input(false, title="Show MTF moving average levels", group=grp_MAVE, tooltip="This will show up to three moving average for different timeframes, defaults are set to the 144 ema, and the 3m, 5m and 15m timeframes.")
//tripleMAFilter = input(false, title="Triple moving average trend filter", group=grp_MAVE, tooltip="This will use 3 moving averages, short, mid and long, to detect trend when they are lined up one above the other in order for buys, and in reverse order for sells.\n\nIt is for the purpose of avoiding trades when price may likely be consolidating.")
//showMATrendRibbon=input(false, title="Triple moving average trend ribbon", group=grp_MAVE, tooltip="This will show a ribbon at the bottom of the chart when the 3 moving averages are trending one above the other in order.")
// Color variables
grp_THEME = "Theme"
upColor = input.color(color.rgb(0, 225, 255), title="Bullish*", group=grp_THEME, tooltip="This will be applied to entry candles, the Range Filter, and the Hull ribbon. These are not always technically bullish candles, but rather derive their logic from the Range Filter bar coloring instead of OHLC values.")
downColor = input.color(color.rgb(226, 2, 107), title="Bearish*", group=grp_THEME, tooltip="This will be applied to entry candles, the Range Filter, and the Hull ribbon. These are not always technically bearish candles, but rather derive their logic from the Range Filter bar coloring instead of OHLC values.")
midColor = input.color(color.orange, title="Consolidation candle", group=grp_THEME, tooltip="Determined by the Range Filter settings as ranging")
//=Range Filter
//==================================================================================================================================
grp_RF = "Range Filter"
src = input(defval=hl2, title="Source", group=grp_RF)
per = input.int(defval=27, minval=1, title="Sampling Period", group=grp_RF)
mult = input.float(defval=2.7, minval=0.1, title="Range Multiplier", group=grp_RF)
// Smooth Average Range
smoothrng(x, t, m) =>
wper = t * 2 - 1
avrng = ta.ema(math.abs(x - x[1]), t)
smoothrng = ta.ema(avrng, wper) * m
smoothrng
smrng = smoothrng(src, per, mult)
// Range Filter
rngfilt(x, r) =>
rngfilt = x
rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r :
x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r
rngfilt
filt = rngfilt(src, smrng)
// Filter Direction
upward = 0.0
upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1])
downward = 0.0
downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 : nz(downward[1])
// Target Bands
//hband = filt + smrng
//lband = filt - smrng
// Colors
filtcolor = upward > 0 ? upColor : downward > 0 ? downColor : midColor
barcolor = src > filt and src > src[1] and upward > 0 ? (allCandleColor ? upColor : na) :
src > filt and src < src[1] and upward > 0 ? (allCandleColor ? upColor : na) :
src < filt and src < src[1] and downward > 0 ? (allCandleColor ? downColor : na) :
src < filt and src > src[1] and downward > 0 ? (allCandleColor ? downColor : na) : (showRanging ? midColor : na)
isUpColor = src > filt and src > src[1] and upward > 0 ? true :
src > filt and src < src[1] and upward > 0 ? true : false
isDownColor = src < filt and src < src[1] and downward > 0 ? true :
src < filt and src > src[1] and downward > 0 ? true : false
isOrange = src > filt and src > src[1] and upward > 0 ? na :
src > filt and src < src[1] and upward > 0 ? na :
src < filt and src < src[1] and downward > 0 ? na :
src < filt and src > src[1] and downward > 0 ? na : true
filtplot = plot(filt, color=filtcolor, linewidth=2, title="Range Filter", display=(showRF ? display.all : display.none))
barcolor(barcolor)
burası iş görüyor....
PHP Code:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © HoanGhetti
//@version=5
indicator("Dynamic Fibonacci Retracement [HG]", overlay = true,max_lines_count = 100)
input_lookback = input.int(defval = 5, title = 'Lookback Range', minval = 5)
input_extend1 = input.string(defval = 'None', title = 'Extend', options = ['None', 'Right', 'Left', 'Both'])
input_width = input.int(defval = 1, title = 'Width', minval = 0)
input_labels = input.bool(defval = true, title = 'Labels', inline = 'Labels')
input_offset = input.int(defval = 5, title = '| Offset Right', inline = 'Labels')
input_prices = input.bool(defval = true, title = 'Prices', tooltip = 'Prints the price of the level next to the retracement level.')
input_bullColor = input.color(defval = color.green, title = 'Bull', inline = 'color')
input_bearColor = input.color(defval = color.red, title = 'Bear', inline = 'color')
input_trendline = input.bool(defval = true, title = 'Use Trendline', group = 'Levels')
input_use236 = input.bool(defval = false, title = '', inline = '0', group = 'Levels')
input_236 = input.float(defval = 0.236, title = '', inline = '0', group = 'Levels', step = 0.01)
input_use382 = input.bool(defval = false, title = '', inline = '382', group = 'Levels')
input_382 = input.float(defval = 0.382, title = '', inline = '382', group = 'Levels', step = 0.01)
input_use5 = input.bool(defval = true, title = '', inline = '382', group = 'Levels')
input_5 = input.float(defval = 0.5, title = '', inline = '382', group = 'Levels', step = 0.01)
input_use618 = input.bool(defval = false, title = '', inline = '618', group = 'Levels')
input_618 = input.float(defval = 0.618, title = '', inline = '618', group = 'Levels', step = 0.01)
input_use786 = input.bool(defval = false, title = '', inline = '618', group = 'Levels')
input_786 = input.float(defval = 0.786, title = '', inline = '618', group = 'Levels', step = 0.01)
exType = switch input_extend1
'None' => extend.none
'Right' => extend.right
'Left' => extend.left
'Both' => extend.both
pl1 = fixnan(ta.pivotlow(input_lookback, input_lookback))
ph1 = fixnan(ta.pivothigh(input_lookback, input_lookback))
plC = ta.barssince(ta.change(pl1))
phC = ta.barssince(ta.change(ph1))
var string dir = na
since = phC < plC ? plC + input_lookback : phC + input_lookback
if ta.change(ph1) or ta.crossunder(low, pl1)
dir := 'bear'
if ta.change(pl1) or ta.crossover(high, ph1)
dir := 'bull'
col = dir == 'bull' ? input_bullColor : input_bearColor
getOuter(pivot, src) =>
var srcValue = src
if ta.change(pivot)
srcValue := pivot
if pivot == ph1 ? src > srcValue : src < srcValue
srcValue := src
[srcValue]
[h] = getOuter(ph1, high)
[l] = getOuter(pl1, low)
calcFib(float lo, float hi, float perc) => dir == 'bull' ? lo - (lo - hi) * perc : hi - (hi - lo) * perc
levelsArr = array.from(0, input_use236 ? input_236 : na, input_use382 ? input_382 : na, input_use5 ? input_5 : na, input_use618 ? input_618 : na, input_use786 ? input_786 : na, 1)
var trendline = line.new(na, na, na, na, style = line.style_dotted, width = input_width)
var innerLines = array.new<line>()
for i = 0 to 6
if innerLines.size() < 7
innerLines.push(line.new(na, na, na, na, width = input_width))
innerLines.get(i).set_xy1(bar_index - since, calcFib(l, h, levelsArr.get(i)))
innerLines.get(i).set_xy2(bar_index, calcFib(l, h, levelsArr.get(i)))
innerLines.get(i).set_color(col)
innerLines.get(i).set_extend(exType)
if input_labels
var labelArray = array.new<label>()
if labelArray.size() < 7
labelArray.push(label.new(na, na, na, style = label.style_none))
labelArray.get(i).set_xy(bar_index + input_offset, calcFib(l, h, levelsArr.get(i)))
labelArray.get(i).set_text(str.tostring(levelsArr.get(i)) + (input_prices ? ' (' + str.tostring(calcFib(l, h, levelsArr.get(i)), format.mintick) + ')' : na))
labelArray.get(i).set_textcolor(col)
if input_trendline
if dir == 'bull'
trendline.set_xy1(bar_index - since, l)
trendline.set_xy2(bar_index, h)
else
trendline.set_xy1(bar_index - since, h)
trendline.set_xy2(bar_index, l)
trendline.set_color(col)
///////////////////////////
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © HoanGhetti
//@version=5
import HoanGhetti/SimpleTrendlines/4 as tl
input_len = input.int(defval = 5, title = 'Pivot Length', minval = 1)
input_pivotType = input.string(defval = 'Fast', title = 'Pivot Type', options = ['Normal', 'Fast'], tooltip = 'Normal: Uses Pine\'s built-in pivot system.\n\nFast: Uses a custom pivot system that tracks every reversal.')
input_repaint = input.bool(defval = true, title = 'Repainting', tooltip = 'If disabled, it will wait for bar confirmation to avoid printing false alerts.')
input_targets = input.bool(defval = true, title = 'Target Levels')
input_bearC = input.color(defval = color.red, title = 'Bear Breakout', group = 'Styling')
input_bullC = input.color(defval = color.green, title = 'Bull Breakout', group = 'Styling')
input_extend = input.string(defval = extend.none, title = 'Extend', options = [extend.none, extend.right, extend.left, extend.both], group = 'Styling')
input_style = input.string(defval = line.style_dotted, title = 'Trendline Style', options = [line.style_dotted, line.style_dashed, line.style_solid], group = 'Styling')
input_tstyle = input.string(defval = line.style_dashed, title = 'Target Style', options = [line.style_dotted, line.style_dashed, line.style_solid], group = 'Styling')
input_override = input.bool(defval = true, title = 'Override Source', group = 'Override', tooltip = 'Overriding the source will allow the script to create trendlines on any specified source.')
input_useSrc = input.bool(defval = true, title = 'Use Source for Cross Detection', group = 'Override', tooltip = 'Instead of checking if the close value crossed trendline, check for the specified source.')
input_source = input.source(defval = low, title = 'Source', group = 'Override')
pl = fixnan(ta.pivotlow(input_override ? input_source : low, input_pivotType == 'Normal' ? input_len : 1, input_len))
ph = fixnan(ta.pivothigh(input_override ? input_source : high, input_pivotType == 'Normal' ? input_len : 1, input_len))
pivot(float pType) =>
pivot = pType == pl ? pl : ph
xAxis = ta.valuewhen(ta.change(pivot), bar_index, 0) - ta.valuewhen(ta.change(pivot), bar_index, 1)
prevPivot = ta.valuewhen(ta.change(pivot), pivot, 1)
pivotCond = ta.change(pivot) and (pType == pl ? pivot > prevPivot : pivot < prevPivot)
pData = tl.new(x_axis = xAxis, offset = input_len, strictMode = true, strictType = pType == pl ? 0 : 1)
pData.drawLine(pivotCond, prevPivot, pivot, input_override ? input_source : na)
pData
breakout(tl.Trendline this, float pType) =>
var bool hasCrossed = false
if ta.change(this.lines.startline.get_y1())
hasCrossed := false
this.drawTrendline(not hasCrossed)
confirmation = not hasCrossed and (input_repaint ? not hasCrossed : barstate.isconfirmed)
if (pType == pl ? (input_override and input_useSrc ? input_source : close) < this.lines.trendline.get_y2() : (input_override and input_useSrc ? input_source : close) > this.lines.trendline.get_y2()) and confirmation
hasCrossed := true
this.lines.startline.set_xy2(this.lines.trendline.get_x2(), this.lines.trendline.get_y2())
this.lines.trendline.set_xy2(na, na)
this.lines.startline.copy()
hasCrossed
plData = pivot(pl)
phData = pivot(ph)
style(tl.Trendline this, color col) =>
this.lines.startline.set_color(col), this.lines.trendline.set_color(col)
this.lines.startline.set_width(2), this.lines.trendline.set_width(2)
this.lines.trendline.set_style(input_style), this.lines.trendline.set_extend(input_extend)
style(plData, input_bearC), style(phData, input_bullC)
cu = breakout(plData, pl)
co = breakout(phData, ph)
plotshape(ta.change(cu) and cu ? plData.lines.startline.get_y2() : na, title = 'Bearish Breakout', style = shape.labeldown, color = input_bearC, textcolor = color.white, location = location.abovebar, text = 'PS')
plotshape(ta.change(co) and co ? phData.lines.startline.get_y2() : na, title = 'Bullish Breakout', style = shape.labelup, color = input_bullC, textcolor = color.white, location = location.belowbar, text = 'PA')
alertcondition(ta.change(cu) and cu, 'Bearish Breakout')
alertcondition(ta.change(co) and co, 'Bullish Breakout')
// Target Levels [v4 Update]
phData_target = tl.new(phData.values.changeInX)
plData_target = tl.new(plData.values.changeInX)
phData_target.drawLine(ta.change(phData.values.y1) and input_targets, phData.values.y2, phData.values.y2)
plData_target.drawLine(ta.change(plData.values.y1) and input_targets, plData.values.y2, plData.values.y2)
target_style(tl.Trendline this, color col) =>
this.lines.startline.set_style(input_tstyle)
this.lines.trendline.set_style(input_tstyle)
this.lines.startline.set_color(col)
this.lines.trendline.set_color(col)
target_style(plData_target, input_bearC)
target_style(phData_target, input_bullC)
breakout(phData_target, ph)
breakout(plData_target, pl)
///////////////////////
//@version=5
grp_CS = "Candlesticks"
showRanging = input(true, title="Color consolidation candles", group=grp_CS, tooltip="Determined by the Range Filter settings as ranging/consolidating mid-range")
allCandleColor = input(true, title="Color trending candles", group=grp_CS, tooltip="Determined by the Range Filter settings as not ranging/consolidating")
grp_MAIN = "General"
showRF = input(false, title="Show Range Filter", group=grp_MAIN)
showRFBands = input(false, title="Show Range Filter bands", group=grp_MAIN)
// Color variables
grp_THEME = "Theme"
upColor = input.color(color.rgb(0, 225, 255), title="Bullish*", group=grp_THEME, tooltip="This will be applied to entry candles, the Range Filter, and the Hull ribbon. These are not always technically bullish candles, but rather derive their logic from the Range Filter bar coloring instead of OHLC values.")
downColor = input.color(color.rgb(226, 2, 107), title="Bearish*", group=grp_THEME, tooltip="This will be applied to entry candles, the Range Filter, and the Hull ribbon. These are not always technically bearish candles, but rather derive their logic from the Range Filter bar coloring instead of OHLC values.")
midColor = input.color(color.orange, title="Consolidation candle", group=grp_THEME, tooltip="Determined by the Range Filter settings as ranging")
//=Range Filter
//==================================================================================================================================
grp_RF = "Range Filter"
src = input(defval=hl2, title="Source", group=grp_RF)
per = input.int(defval=27, minval=1, title="Sampling Period", group=grp_RF)
mult = input.float(defval=2.7, minval=0.1, title="Range Multiplier", group=grp_RF)
// Smooth Average Range
smoothrng(x, t, m) =>
wper = t * 2 - 1
avrng = ta.ema(math.abs(x - x[1]), t)
smoothrng = ta.ema(avrng, wper) * m
smoothrng
smrng = smoothrng(src, per, mult)
// Range Filter
rngfilt(x, r) =>
rngfilt = x
rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r :
x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r
rngfilt
filt = rngfilt(src, smrng)
// Filter Direction
upward = 0.0
upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1])
downward = 0.0
downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 : nz(downward[1])
// Colors
filtcolor = upward > 0 ? upColor : downward > 0 ? downColor : midColor
barcolor = src > filt and src > src[1] and upward > 0 ? (allCandleColor ? upColor : na) :
src > filt and src < src[1] and upward > 0 ? (allCandleColor ? upColor : na) :
src < filt and src < src[1] and downward > 0 ? (allCandleColor ? downColor : na) :
src < filt and src > src[1] and downward > 0 ? (allCandleColor ? downColor : na) : (showRanging ? midColor : na)
isUpColor = src > filt and src > src[1] and upward > 0 ? true :
src > filt and src < src[1] and upward > 0 ? true : false
isDownColor = src < filt and src < src[1] and downward > 0 ? true :
src < filt and src > src[1] and downward > 0 ? true : false
isOrange = src > filt and src > src[1] and upward > 0 ? na :
src > filt and src < src[1] and upward > 0 ? na :
src < filt and src < src[1] and downward > 0 ? na :
src < filt and src > src[1] and downward > 0 ? na : true
filtplot = plot(filt, color=filtcolor, linewidth=1, title="Range Filter", display=(showRF ? display.all : display.none))
barcolor(barcolor)
Yer İmleri