-
önceki tasarımla....beraber görüntü...
https://www.tradingview.com/x/IhnXkJfX/
https://www.tradingview.com/x/bBmfMqgS/
https://www.tradingview.com/x/QCTFnIQ5/
gap koduyla beraber bakılınca....
genellikle...bıraktığı gapları doldurma eğilimi yüksek....
-
az işlem açan....
strateji ile birleşmiş görüntü...
https://www.tradingview.com/x/8an6uh54/
PHP Code:
//@version=5
strategy(title='Moonhub Cycle Index', shorttitle='*', overlay=true,max_lines_count = 100)
// Input parameters
len_DIema = input.int(5, minval=1, title='COEMA Length')
len_DIsma = input.int(20, minval=1, title='COSMA Length')
start1 = input(0)
increment1 = input(0.1)
maximum1 = input(1, "Max Value")
out1 = ta.sar(start1, increment1, maximum1)
start2 = input(0)
increment2 = input(0.01)
maximum2 = input(0.1, "Max Value")
out2 = ta.sar(start2, increment2, maximum2)
start3 = input(0.1)
increment3 = input(0.1)
maximum3 = input(0.1, "Max Value")
out3 = ta.sar(start3, increment3, maximum3)
// Create a custom index
index = (out1 + out2 + out3) / 3
// Calculate COEMA and COSMA for the Custom Index
DI_index_Co_E = ta.ema(index, len_DIema)
DI_Co_indexS = ta.sma(index, len_DIsma)
// Plot the index
plot(index, title='Index', color=color.new(#ff5252, 100), linewidth=2)
plot(DI_index_Co_E, title='5EMA', color=color.new(#2195f3, 100), linewidth=2)
plot(DI_Co_indexS, title='20SMA', color=color.new(#4caf4f, 100), linewidth=2)
changebarcol = input.bool(true, title='Change Bar Color', inline='bcol')
bcolup = input.color(color.rgb(103, 243, 76), title='', inline='bcol')
bcoldn = input.color(color.rgb(248, 78, 78), title='', inline='bcol')
var color lastBarColor = na
BullishColor = input.color(color.rgb(125, 247, 77))
BearishColor = input.color(color.rgb(245, 76, 76))
barColorBasedOnDEMATrend = close > out1 and close > out2 and close > out3 ? BullishColor : close < out1 and close < out2 and close < out3 ? BearishColor : nz(lastBarColor[1])
lastBarColor := barColorBasedOnDEMATrend
//barcolor(color=changebarcol ? barColorBasedOnDEMATrend : na)
xa = ta.crossover(close,out1) and ta.crossover(close,out2) and ta.crossover(close,out3)
ys = ta.crossunder(close,out1) and ta.crossunder(close,out2) and ta.crossunder(close,out3)
in_b = ta.barssince(xa)[1] < ta.barssince(ys)[1]
in_s = ta.barssince(ys)[1] < ta.barssince(xa)[1]
if xa
strategy.entry("Long",strategy.long)
if ys
strategy.close("Long")
///////////////////////////////////////////////////
// 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
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)
//////////////////////////
denemek isteyenler için kod....
-
-
https://tr.tradingview.com/v/Q95qqFgC/ kod.... görüntü... https://www.tradingview.com/x/kotnb7al/
https://tr.tradingview.com/v/BgC5o5F9/ görüntü...https://www.tradingview.com/x/7lPfoRSw/
https://tr.tradingview.com/v/GtWKHvJB/ görüntü... https://www.tradingview.com/x/QlqnvQ9s/
https://tr.tradingview.com/v/YBPV8OiX/ görüntü... https://www.tradingview.com/x/dI3BSep0/
hepsini 12-25 uzunluk ile kombine edersek.....
PHP Code:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © btc_charlie / @TheParagonGrp
//@version=5
strategy('*', overlay=true,explicit_plot_zorder=true)
// Variables
var ok = 0
var countBuy = 0
var countSell = 0
src = input(close, title='OHLC Type')
i_fastEMA = input(12, title='Fast EMA')
i_slowEMA = input(25, title='Slow EMA')
i_defEMA = input(25, title='Consolidated EMA')
// Allow the option to show single or double EMA
i_bothEMAs = input(title='Show Both EMAs', defval=true)
// Define EMAs
v_fastEMA = ta.ema(src, i_fastEMA)
v_slowEMA = ta.ema(src, i_slowEMA)
v_biasEMA = ta.ema(src, i_defEMA)
// Color the EMAs
emaColor = v_fastEMA > v_slowEMA ? color.rgb(76, 175, 79, 100) : v_fastEMA < v_slowEMA ? color.rgb(255, 82, 82, 100) : #FF530D
// Plot EMAs
plot(i_bothEMAs ? na : v_biasEMA, color=emaColor, linewidth=3, title='Consolidated EMA')
plot(i_bothEMAs ? v_fastEMA : na, title='12EMA', color=emaColor)
plot(i_bothEMAs ? v_slowEMA : na, title='25EMA', color=emaColor)
// Colour the bars
buy = v_fastEMA > v_slowEMA
sell = v_fastEMA < v_slowEMA
if buy
countBuy += 1
countBuy
if buy
countSell := 0
countSell
if sell
countSell += 1
countSell
if sell
countBuy := 0
countBuy
buysignal = countBuy < 2 and countBuy > 0 and countSell < 1 and buy and not buy[1]
sellsignal = countSell > 0 and countSell < 2 and countBuy < 1 and sell and not sell[1]
barcolor(buysignal ? color.green : na)
barcolor(sellsignal ? color.red : na)
// Plot Bull/Bear
//plotshape(buysignal, title='Bull', text='Bull', style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), textcolor=color.new(color.black, 0), size=size.tiny)
//plotshape(sellsignal, title='Bear', text='Bear', style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), textcolor=color.new(color.black, 0), size=size.tiny)
bull = countBuy > 1
bear = countSell > 1
barcolor(bull ? color.yellow : na)
barcolor(bear ? color.blue : na)
/////////////////
start = input(0)
increment = input(0.01)
maximum = input(1, "Max Value")
out = ta.sar(start, increment, maximum)
plot(out, "ParabolicSAR", style=plot.style_cross, color=#f809ec)
//Inputs
lengthMA = input(25, 'Length DR', inline='Inp', group='Input')
color green = input(#00e677f6, inline='Col', group='Color')
color red = input(#ff5252, inline='Col', group='Color')
color gray =input(#787b86, inline='Col', group='Color')
// Function
dyn_rea(out, len) =>
var smma = 0.0
h = ta.ema(out, len)
smma := na(smma[1]) ? h : (smma[1] * (len - 1) + out) / len
smma
// Calculation
hi=dyn_rea(high, lengthMA)
lo=dyn_rea(low, lengthMA)
mi=(hi-lo)/2+lo
// Plots
//a=plot(hi,"", hlc3>hi?green:hlc3<lo?red:gray)
//b=plot(lo,"", hlc3>hi?green:hlc3<lo?red:gray)
c=plot(mi,"", hlc3>hi?green:hlc3<lo?red:gray)
//fill(a,b,hlc3>hi?color.new(green,60):hlc3<lo?color.new(red,60):color.gray)
////////////////
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MirNader_
//@version=5
//Input & Swing Detection
// Define the input "swingLength" for the number of candles to look back for Swing detection
int swingLength = input.int(20, 'Lookback Period' , minval = 5 , tooltip = "Determines the length of bullish and bearish swings in the market")
// Set the line color for bullish trend
color swingcolorBullish = input.color(color.green, 'Bullish Line' , inline = '01' , tooltip = "This line represents the trend direction. Green color indicates a bullish trend and red color indicates a bearish trend")
// Set the line color for bearish trend
color swingcolorBearish = input.color(color.red , 'Bearish Line' , inline = '01' , tooltip = "This line represents the trend direction. Green color indicates a bullish trend and red color indicates a bearish trend")
//End of Input & Swing Detection
//------------------------------\\
//Swing Detection Function
// The "detectSwing" function will calculate the swing highs and lows for the given number of candles
detectSwing(swingPeriod) =>
// Initialize the "currentSwingState" variable, which will be used to determine the swing state (0 for swing high, 1 for swing low)
var currentSwingState = 0
// Calculate the highest high and lowest low for the given number of candles
highestSwing = ta.highest(swingPeriod)
lowestSwing = ta.lowest(swingPeriod)
// Determine the swing state based on the current candle high and low compared to the highest high and lowest low
currentSwingState := high[swingPeriod] > highestSwing ? 0 : low[swingPeriod] < lowestSwing ? 1 : currentSwingState[1]
// If the current candle is a swing high and the previous candle was not a swing high, set "currentSwingTop" to the current candle high
currentSwingTop = currentSwingState == 0 and currentSwingState[1] != 0 ? high[swingPeriod] : 0
// If the current candle is a swing low and the previous candle was not a swing low, set "currentSwingBottom" to the current candle low
currentSwingBottom = currentSwingState == 1 and currentSwingState[1] != 1 ? low[swingPeriod] : 0
// Return the calculated swing high and swing low values
[currentSwingTop, currentSwingBottom]
//End of Swing Detection
//------------------------------\\
//Parameters
// Initialize the "trendDirection" variable, which will keep track of the trend state (0 for downtrend, 1 for uptrend)
var trendDirection = 0
// Initialize variables for storing pivot high values
var swingTopValue = 0., var swingTopTimestamp = 0
// Initialize variables for storing pivot low values
var swingBottomValue = 0., var swingBottomTimestamp = 0
// Initialize variables for keeping track of the trailing maximum
var trailingSwingHigh = high, var trailingSwingLow = low
var trailingSwingHighTimestamp = 0, var trailingSwingLowTimestamp = 0
// Initialize variables for keeping track of pivot crosses
var topCrossCheck = true, var bottomCrossCheck = true
// Call the "detectSwing" function to calculate the swing highs and lows
[currentSwingTop, currentSwingBottom] = detectSwing(swingLength)
//Line Extend
var line extendingTopLine = na // Initialize a line object for extending the recent top
var line extendingBottomLine = na // Initialize a line object for extending the recent bottom
//End of Parameters
//------------------------------\\
//Pivot High Function
//The calculation of pivot high is an important step in detecting bullish structures in the market
if currentSwingTop
// If a new top is found, set "topCrossCheck" to true
topCrossCheck := true
// Delete the previous extendingTopLine line
line.delete(extendingTopLine[1])
// Create a new extendingTopLine line from the recent top to the last bar
extendingTopLine := line.new(bar_index-swingLength, currentSwingTop, bar_index, currentSwingTop, color = swingcolorBullish)
// Store the pivot high values
swingTopValue := currentSwingTop
swingTopTimestamp := bar_index - swingLength
// Update the trailing maximum values
trailingSwingHigh := currentSwingTop
trailingSwingHighTimestamp := bar_index - swingLength
//Update the trailing maximum values
trailingSwingHigh := math.max(high, trailingSwingHigh)
trailingSwingHighTimestamp := trailingSwingHigh == high ? bar_index : trailingSwingHighTimestamp
//Set the top extension line properties
if barstate.islast
line.set_xy1(extendingTopLine, trailingSwingHighTimestamp, trailingSwingHigh)
line.set_xy2(extendingTopLine, bar_index + 20, trailingSwingHigh)
//End of Pivot High Function
//------------------------------\\
//Pivot Low Function
//the Pivot low is used to detect the presence of a bearish structure in the price movement and update the trend accordingly.
if currentSwingBottom
// If a new low is found, set "bottomCrossCheck" to true
bottomCrossCheck := true
//Extend recent bottom to last bar
line.delete(extendingBottomLine[1])
extendingBottomLine := line.new(bar_index - swingLength, currentSwingBottom, bar_index, currentSwingBottom, color = swingcolorBearish)
//Store the pivot low values
swingBottomValue := currentSwingBottom
swingBottomTimestamp := bar_index - swingLength
//Update the trailing minimum values
trailingSwingLow := currentSwingBottom
trailingSwingLowTimestamp := bar_index - swingLength
//Update the trailing minimum values
trailingSwingLow := math.min(low, trailingSwingLow)
trailingSwingLowTimestamp := trailingSwingLow == low ? bar_index : trailingSwingLowTimestamp
//Set the bottom extension line properties
if barstate.islast
line.set_xy1(extendingBottomLine, trailingSwingLowTimestamp, trailingSwingLow)
line.set_xy2(extendingBottomLine, bar_index + 20, trailingSwingLow)
// End of Pivot Low Function
//------------------------------\\
// You can use 'trendDirection' for your strategy to identify the uptrend or downtrend
// This section of code checks if the close price crosses over the trailing maximum value (top_y).
// If it does, the top_cross boolean is set to false and the trend is set to 1, indicating a bullish trend.
//Detect bullish Structure
if ta.crossover(close, swingTopValue) and topCrossCheck
topCrossCheck := false
trendDirection := 1
// This section of code checks if the close price crosses under the trailing minimum value (btm_y).
// If it does, the btm_cross boolean is set to false and the trend is set to -1, indicating a bearish trend.
// Detect bearish Structure
if ta.crossunder(close, swingBottomValue) and bottomCrossCheck
bottomCrossCheck := false
trendDirection := -1
// End
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mutantdog
//@version=5
// v1.1
//
string S01 = 'open'
string S02 = 'high'
string S03 = 'low'
string S04 = 'close'
string S11 = 'hl2'
string S12 = 'hlc3'
string S13 = 'ohlc4'
string S14 = 'hlcc4'
string S51 = 'oc2'
string S52 = 'hlc2-o2'
string S53 = 'hl-oc2'
string S54 = 'cc-ohlc4'
string S91 = '*AUX 1'
string S92 = '*AUX 2'
string S93 = '*TRIGGER'
string M00 = 'none'
string M01 = 'SMA'
string M02 = 'EMA'
string M03 = 'WMA'
string M04 = 'RMA'
string M11 = 'VWMA'
string M12 = 'VWEMA'
string M13 = 'HMA'
string M41 = 'Median'
string M42 = 'Mid Range'
// INPUTS
auxSource_1 = input.source (close, 'Aux 1 ', inline='01')
auxSource_2 = input.source (close, 'Aux 2 ', inline='01')
triggerSource = input.string ('close', 'Source', [S01, S02, S03, S04, S11, S12, S13, S14, S51, S52, S53, S54, S91, S92], inline='11', group='Trigger')
triggerFilter = input.string ('EMA', 'Filter ', [M00, M01, M02, M03, M04, M11, M12, M13, M41, M42], inline='12', group='Trigger')
triggerLength = input.int (12, 'Length', minval=1, inline='12', group='Trigger')
centreSource = input.string ('hl2', 'Source', [S01, S02, S03, S04, S11, S12, S13, S14, S51, S52, S53, S54, S91, S92, S93], inline='21', group='Centre')
centreFilter = input.string ('EMA', 'Filter ', [M00, M01, M02, M03, M04, M11, M12, M13, M41, M42], inline='22', group='Centre')
centreLength = input.int (25, 'Length', minval=1, inline='22', group='Centre')
tslActive = input.bool (true, 'Trailing ', inline='41', group='Dynamics')
tslPercent = input.float (0, '%', step=0.1, inline='41', group='Dynamics')
atrActive = input.bool (true, 'ATR', inline='42', group='Dynamics')
atrLength = input.int (8, 'Length', minval=1, inline='42', group='Dynamics')
atrMult = input.float (1, 'Mult', step=0.1, inline='42', group='Dynamics')
iqrActive = input.bool (true, 'IQR', inline='43', group='Dynamics')
iqrLength = input.int (12, 'Length', minval=1, inline='43', group='Dynamics')
iqrMult = input.float (0, 'Mult', step=0.1, inline='43', group='Dynamics')
filterSum = input.bool (false, 'Filter Sum', inline='47', group='Dynamics')
loMult = input.float (1, 'Side Mult: Lo', minval=0, step=0.05, inline='49', group='Dynamics')
hiMult = input.float (1, 'Hi ', minval=0, step=0.05, inline='49', group='Dynamics')
showLostop = input.bool (true, 'LoStop', inline='71', group='Visual')
showHistop = input.bool (true, 'HiStop', inline='71', group='Visual')
showCentre = input.bool (false, 'Centre', inline='71', group='Visual')
showTrigger = input.bool (false, 'Trigger', inline='71', group='Visual')
showBands = input.bool (false, 'Bands', inline='71', group='Visual')
bullCol = input.color (#5a6e30, '', inline='88', group='Visual')
bearCol = input.color (#a11030, '', inline='88', group='Visual')
centreCol = input.color (#58aeb1, '', inline='88', group='Visual')
triggerCol = input.color (#ccc26d, '', inline='88', group='Visual')
bandCol = input.color (#6d6969, '', inline='88', group='Visual')
stopsOpac = input.int (100, 'Opacity: Stops', minval=0, maxval=100, step=5, inline='89', group='Visual')
otherOpac = input.int (40, 'Other', minval=0, maxval=100, step=5, inline='89', group='Visual')
// FUNCTIONS
source_switch (src, aux1, aux2) =>
source = switch src
'open' => open
'high' => high
'low' => low
'close' => close
'hl2' => hl2
'hlc3' => hlc3
'ohlc4' => ohlc4
'hlcc4' => hlcc4
'oc2' => (open + close) / 2
'hlc2-o2' => (high + low + close - open) / 2
'hl-oc2' => high + low - (open + close) / 2
'cc-ohlc4' => 2 * close - ohlc4
'*AUX 1' => aux1
'*AUX 2' => aux2
//
filter_switch (src, len, mode) =>
filter = switch mode
'none' => src
'SMA' => ta.sma (src, len)
'EMA' => ta.ema (src, len)
'WMA' => ta.wma (src, len)
'RMA' => ta.rma (src, len)
'VWMA' => ta.vwma (src, len)
'Median' => ta.median (src, len)
'Mid Range' => ta.lowest (src, len) + ta.range (src, len) / 2
'VWEMA' => ta.ema (src * volume, len) / ta.ema (volume, len)
'HMA' => len >= 2 ? ta.hma (src, len) : src
//
iqr_array (len) =>
float[] hiArray = array.new_float (0)
float[] loArray = array.new_float (0)
float[] cmArray = array.new_float (0)
for i = 0 to len - 1
array.push (hiArray, high[i])
array.push (loArray, low[i])
array.push (cmArray, hlcc4[i])
hlArray = array.concat (hiArray, loArray)
hlcmArray = array.concat (hlArray, cmArray)
q1 = array.percentile_linear_interpolation (hlcmArray, 25)
q3 = array.percentile_linear_interpolation (hlcmArray, 75)
iqr = (q3 - q1) / 2
//
trail_blaze (srct, srcc, lofac, hifac) =>
lostop = 0.0
histop = 0.0
trend = 0
trend := srct > histop[1] ? 1 : srct < lostop[1] ? -1 : nz (trend[1], 1)
lostop00 = trend == 1 and trend[1] == -1
histop00 = trend == -1 and trend[1] == 1
lostop := lostop00 ? srcc - lofac : srct[1] > lostop[1] ? math.max (srcc - lofac, lostop[1]) : srcc - lofac
histop := histop00 ? srcc + hifac : srct[1] < histop[1] ? math.min (srcc + hifac, histop[1]) : srcc + hifac
[lostop, histop, trend]
//
// PROCESS
triggerSwitch = source_switch (triggerSource, auxSource_1, auxSource_2)
trigger = filter_switch (triggerSwitch, triggerLength, triggerFilter)
centreSwitch = centreSource == '*TRIGGER' ? trigger : source_switch (centreSource, auxSource_1, auxSource_2)
centre = filter_switch (centreSwitch, centreLength, centreFilter)
tslFactor = tslActive ? centre * tslPercent / 100 : 0
atrFactor = atrActive ? atrMult * ta.atr (atrLength) : 0
iqrFactor = iqrActive ? iqrMult * iqr_array (iqrLength) : 0
sumFactor = filterSum ? ta.swma (nz (tslFactor) + nz (atrFactor) + nz (iqrFactor)) : nz (atrFactor) + nz (iqrFactor) + nz (tslFactor)
loFactor = math.max (sumFactor, 0) * loMult
hiFactor = math.max (sumFactor, 0) * hiMult
[lostop, histop, trend] = trail_blaze (trigger, centre, loFactor, hiFactor)
// VISUALS AND ALERTS
lostopColour = color.new (bullCol, 100 - stopsOpac)
histopColour = color.new (bearCol, 100 - stopsOpac)
centreColour = color.new (centreCol, 100 - otherOpac)
triggerColour = color.new (triggerCol, 100 - otherOpac)
bandColour = color.new (bandCol, 100 - otherOpac)
plotCentre = plot (showCentre ? centre : na, 'Centre', centreColour, 2)
plotTrigger = plot (showTrigger ? trigger : na, 'Trigger', triggerColour, 2)
plotLoband = plot (showBands ? centre - loFactor : na, 'Lo Band', bandColour, 2)
plotHiband = plot (showBands ? centre + hiFactor : na, 'Hi Band', bandColour, 2)
plotLostop = plot (showLostop ? trend == 1 ? lostop : na : na, 'Lo Stop', lostopColour, 2, plot.style_linebr)
plotHistop = plot (showHistop ? trend == 1 ? na : histop : na, 'Hi Stop', histopColour, 2, plot.style_linebr)
isNewTrend = trend != trend[1]
isNewUp = trend == 1 and trend[1] == -1
isNewDown = trend == -1 and trend[1] == 1
plotshape (isNewUp ? lostop : na, 'Long Start', shape.circle, location.absolute, lostopColour, size=size.tiny)
plotshape (isNewDown ? histop : na, 'Short Start', shape.circle, location.absolute, histopColour, size=size.tiny)
alertcondition (isNewTrend, '00: Trail Blaze - Direction Change', 'Trail Blaze has changed direction!')
alertcondition (isNewDown, '01: Trail Blaze - Sell', 'SELL SIGNAL: Trail Blaze Down!')
alertcondition (isNewUp, '02: Trail Blaze - Buy', 'BUY SIGNAL: Trail Blaze Up!')
görüntüler....
https://www.tradingview.com/x/enQ4pcSW/
https://www.tradingview.com/x/jXep6ehs/
-
strateji denemesi....
PHP Code:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © chervolino
// Dynamic Reactor [CHE] indicator displays dynamic support and resistance levels.
// Green lines represent resistance, red lines represent support, and gray lines represent areas of consolidation.
// The length of the indicator can be adjusted with the lengthMA input.
//@version=5
strategy("Dynamic Reactor [CHE]", shorttitle="*", overlay=true)
start = input(0.1)
increment = input(0.1)
maximum = input(1, "Max Value")
out = ta.sar(start, increment, maximum)
//plot(out, "SAR", style=plot.style_cross, color=#f809ec)
//Inputs
lengthMA = input(9, 'Length DR', inline='Inp', group='Input')
color green = input(#00e677f6, inline='Col', group='Color')
color red = input(#ff5252, inline='Col', group='Color')
color gray =input(#787b86, inline='Col', group='Color')
// Function
dyn_rea(out, len) =>
var smma = 0.0
h = ta.sma(out, len)
smma := na(smma[1]) ? h : (smma[1] * (len - 1) + out) / len
smma
// Calculation
hi=dyn_rea(out, lengthMA)
lo=dyn_rea(out, lengthMA)
mi=(hi-lo)/2+lo
// Plots
c=plot(mi,"", hlc3>hi?green:hlc3<lo?red:gray)
start1 = input(0.1)
increment1 = input(0.1)
maximum1 = input(1, "Max Value")
out1 = ta.sar(start1, increment1, maximum1)
//Inputs
lengthMA1 = input(27, 'Length DR', inline='Inp', group='Input')
// Function
dyn_rea1(out1, len1) =>
var smma1 = 0.0
h1 = ta.sma(out1, len1)
smma1 := na(smma1[1]) ? h1 : (smma1[1] * (len1 - 1) + out1) / len1
smma1
// Calculation
hi1=dyn_rea1(out1, lengthMA1)
lo1=dyn_rea1(out1, lengthMA1)
mi1=(hi1-lo1)/2+lo1
c1=plot(mi1,"", hlc3>hi?green:hlc3<lo?red:gray)
xa = (close >mi) and (close >mi1)
ys = (close <mi) and (close <mi1)
in_b = ta.barssince(xa)[1] < ta.barssince(ys)[1]
in_s = ta.barssince(ys)[1] < ta.barssince(xa)[1]
if xa
strategy.entry("Long",strategy.long)
if ys
strategy.close("Long")
-
https://tr.tradingview.com/v/j5xkAKCL/
belirleyeceğiniz 10 şeyi...ema kesişimleri ile
bulunduğunuz periyotlarda tarama yapar....
https://www.tradingview.com/x/agwTZNYn/
-
https://tr.tradingview.com/v/DU228Vjm/
otomatik bayrak bulucu kod....kendi değerlerinizle....
bayrağı ve direk uzunluğunu...
belirleyeceğiniz periyot ve uzunlukta bulmanıza yardımcı olur...
-