-
ortaya karışık kombine...
PHP Code:
//@version=5
strategy('**', overlay=true)
start = input(0.01)
increment = input(0.01)
maximum = input(0.2)
psar = ta.sar(start, increment, maximum)
if psar > high
strategy.entry('ParLE', strategy.long, stop=psar, comment='Long')
else
strategy.cancel('ParLE')
if psar < low
strategy.entry('ParSE', strategy.short, stop=psar, comment='Short')
else
strategy.cancel('ParSE')
//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)
///// yörük sar stratejisi////////////
y1 = ta.sar(0.01, 0.01, 0.2)
y2 = ta.sar(0.01, 0.02, 0.2)
y3 = ta.sar(0.01, 0.03, 0.2)
plot(y1,"Sar-Slow", style=plot.style_cross, color=color.new(color.fuchsia, 0), linewidth=1)
plot(y2,"Sar-Median", style=plot.style_cross, color=color.new(color.orange, 0), linewidth=1)
plot(y3, "Sar-Fast",style=plot.style_cross, color=color.new(color.white, 0), linewidth=1)
//////////////////////////////yörük trend//////////////
len44 = input.int(3, 'Length', step=1, minval=1)
displace = input.int(1, 'Displace', step=1, minval=0)
ma_type = input.string('SMA', 'MA Type', options=['SMA', 'HMA'])
//Hilo Activator
float hilo = na
hi = ta.sma(high, len44)
lo = ta.sma(low, len44)
// Hull Moving Average (HMA)
if ma_type == 'HMA'
hi := ta.wma(2 * ta.wma(high, len44 / 2) - ta.wma(high, len44), math.round(math.sqrt(len44)))
lo := ta.wma(2 * ta.wma(low, len44 / 2) - ta.wma(low, len44), math.round(math.sqrt(len44)))
hilo := close > hi[displace] ? 1 : close < lo[displace] ? -1 : hilo[1]
ghla = hilo == -1 ? hi[displace] : lo[displace]
color44 = hilo == -1 ? color.red : color.lime
//Alerts
buyCondition = hilo == 1 and hilo[1] == -1
sellCondition = hilo == -1 and hilo[1] == 1
if buyCondition
alert('Long', alert.freq_once_per_bar)
if sellCondition
alert('Short', alert.freq_once_per_bar)
//Plots
plot(ghla, "TRend", color=color44, style=plot.style_line, linewidth = 2)
/////////////////////yörük..herkesin kullandığı sar ile strateji...///////////////
start41 = input(0.02)
increment41 = input(0.02)
maximum41 = input(0.2)
psar41 = 0.0 // PSAR
af41 = 0.0 // Acceleration Factor
trend_dir41 = 0 // Current direction of PSAR
ep41 = 0.0 // Extreme point
sar_long_to_short = trend_dir41[1] == 1 and close <= psar41[1] // PSAR switches from long to short
sar_short_to_long = trend_dir41[1] == -1 and close >= psar41[1] // PSAR switches from short to long
trend_change = barstate.isfirst[1] or sar_long_to_short or sar_short_to_long
// Calculate trend direction
trend_dir41 := barstate.isfirst[1] and close[1] > open[1] ? 1 : barstate.isfirst[1] and close[1] <= open[1] ? -1 : sar_long_to_short ? -1 : sar_short_to_long ? 1 : nz(trend_dir41[1])
// Calculate Acceleration Factor
af41 := trend_change ? start41 : trend_dir41 == 1 and high > ep41[1] or trend_dir41 == -1 and low < ep41[1] ? math.min(maximum41, af41[1] + increment41) : af41[1]
// Calculate extreme point
ep41 := trend_change and trend_dir41 == 1 ? high : trend_change and trend_dir41 == -1 ? low : trend_dir41 == 1 ? math.max(ep41[1], high) : math.min(ep41[1], low)
// Calculate PSAR
psar41 := barstate.isfirst[1] and close[1] > open[1] ? low[1] : barstate.isfirst[1] and close[1] <= open[1] ? high[1] : trend_change ? ep41[1] : trend_dir41 == 1 ? psar41[1] + af41 * (ep41 - psar41[1]) : psar41[1] - af41 * (psar41[1] - ep41)
plot(psar41,"Alarm", style=plot.style_cross, color=trend_dir41 == 1 ? color.green : color.red, linewidth=1)
plotshape(sar_short_to_long, style=shape.arrowup, color=color.new(color.green, 0), location=location.abovebar, text='Long',textcolor = color.lime)
plotshape(sar_long_to_short, style=shape.arrowdown, color=color.new(color.red, 0), location=location.belowbar, text='Short',textcolor = color.red)
// Alerts
alertcondition(sar_short_to_long, 'PSAR Long', 'PSAR Long')
alertcondition(sar_long_to_short, 'PSAR Short', 'PSAR Short')
//////////////////////////////////////yörük Ana trend sar...////////////
AF_initial55 = input(0.01)
AF_increment55 = input(0.01)
AF_maximum55 = input(0.2)
LUCID_SAR(initial55, increment55, maximum55) =>
// start with uptrend
//1->true, 0-> false
uptrend = 1
newtrend = 0
EP55 = high
SAR55 = low
AF55 = AF_initial55
EP55 := nz(uptrend[1]) == 1 ? math.max(high, nz(EP55[1])) : math.min(low, nz(EP55[1]))
AF55 := nz(newtrend[1]) == 1 ? AF_initial55 : AF55
iff_1 = EP55 != nz(EP55[1]) ? math.min(AF_maximum55, nz(AF55[1]) + AF_increment55) : nz(AF55[1])
AF55 := nz(newtrend[1]) == 0 ? iff_1 : AF55
SAR55 := nz(SAR55[1]) + AF55 * (EP55 - nz(SAR55[1]))
iff_2 = nz(newtrend) == 1 ? math.max(high, nz(EP55[1])) : math.min(SAR55, nz(low[1]))
iff_3 = nz(newtrend) == 1 ? math.min(low, nz(EP55[1])) : math.max(SAR55, nz(high[1]))
SAR55 := nz(uptrend[1]) == 1 ? iff_2 : iff_3
iff_4 = nz(newtrend) == 1 ? math.min(low, nz(low[1])) : EP55
iff_5 = nz(newtrend) == 1 ? math.max(high, nz(high[1])) : EP55
EP55 := nz(uptrend[1]) == 1 ? iff_4 : iff_5
SAR55 := nz(uptrend[1]) == 1 and nz(newtrend) == 0 and nz(low[2]) != 0 ? math.min(SAR55, nz(low[2])) : SAR55
SAR55 := nz(uptrend[1]) == 0 and nz(newtrend) == 0 and nz(high[2]) != 0 ? math.max(SAR55, nz(high[2])) : SAR55
SAR55 := nz(uptrend[1]) == 1 and nz(newtrend) == 0 and SAR55 > low ? math.max(high, nz(EP55[1])) : SAR55
EP55 := nz(uptrend[1]) == 1 and nz(newtrend) == 0 and SAR55 > low ? math.min(low, nz(low[1])) : EP55
uptrend := nz(uptrend[1]) == 1 and nz(newtrend) == 0 and SAR55 > low ? 0 : uptrend
newtrend := nz(uptrend[1]) == 1 and nz(newtrend) == 0 and SAR55 > low ? 1 : newtrend
uptrend := nz(uptrend[1]) == 1 and nz(newtrend) == 0 and not(SAR55 < low) ? 1 : uptrend
newtrend := nz(uptrend[1]) == 1 and nz(newtrend) == 0 and not(SAR55 < low) ? 0 : newtrend
SAR55 := nz(uptrend[1]) == 0 and nz(newtrend) == 0 and SAR55 < high ? math.min(low, nz(EP55[1])) : SAR55
EP55 := nz(uptrend[1]) == 0 and nz(newtrend) == 0 and SAR55 < high ? math.max(high, nz(high[1])) : EP55
uptrend := nz(uptrend[1]) == 0 and nz(newtrend) == 0 and SAR55 < high ? 1 : uptrend
newtrend := nz(uptrend[1]) == 0 and nz(newtrend) == 0 and SAR55 < high ? 1 : newtrend
uptrend := nz(uptrend[1]) == 0 and nz(newtrend) == 0 and not(SAR55 < high) ? 0 : uptrend
newtrend := nz(uptrend[1]) == 0 and nz(newtrend) == 0 and not(SAR55 < high) ? 0 : newtrend
[SAR55, uptrend]
[L_SAR, up] = LUCID_SAR(AF_initial55, AF_increment55, AF_maximum55)
plot(L_SAR, 'AnaTREND', color=up ? color.new(color.green, 0) : color.new(color.red, 0), style=plot.style_stepline, linewidth=2)
///////////////////yörük....en hassas sar ile iz stop niyetine....////////////
start61 = input.int(5, minval=0, maxval=10, title='Start - Default = 2 - Multiplied by .01')
increment61 = input.int(5, minval=0, maxval=10, title='Step Setting (Sensitivity) - Default = 2 - Multiplied by .01')
maximum61 = input.int(5, minval=1, maxval=10, title='Maximum Step (Sensitivity) - Default = 2 - Multiplied by .10')
sus61 = input(true, 'Show Up Trending Parabolic Sar')
sds61 = input(true, 'Show Down Trending Parabolic Sar')
disc61 = input(true, title='Start and Step settings are *.01 so 2 = .02 etc, Maximum Step is *.10 so 2 = .2')
startCalc61 = start61 * .01
incrementCalc61 = increment61 * .01
maximumCalc61 = maximum61 * .10
sarUp61 = ta.sar(startCalc61, incrementCalc61, maximumCalc61)
sarDown61 = ta.sar(startCalc61, incrementCalc61, maximumCalc61)
colUp61 = close >= sarDown61 ? color.rgb(0, 230, 119, 100) : na
colDown61 = close <= sarUp61 ? color.rgb(255, 82, 82, 100) : na
plot(sus61 and sarUp61 ? sarUp61 : na, title='SAR-İz', style=plot.style_steplinebr, linewidth=2, color=colUp61)
plot(sds61 and sarDown61 ? sarDown61 : na, title='SAR-İz', style=plot.style_steplinebr, linewidth=2, color=colDown61)
//@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)
///////////////////////////
//@version=5
len445 = input.int(10, 'Length', step=1, minval=1)
displace63 = input.int(1, 'Displace', step=1, minval=0)
ma_type63 = input.string('HMA', 'MA Type', options=['SMA', 'HMA'])
//Hilo Activator
float hilo63 = na
hi63 = ta.sma(high, len445)
lo63 = ta.sma(low, len445)
// Hull Moving Average (HMA)
if ma_type63 == 'HMA'
hi63 := ta.wma(2 * ta.wma(high, len445 / 2) - ta.wma(high, len445), math.round(math.sqrt(len445)))
lo63 := ta.wma(2 * ta.wma(low, len445 / 2) - ta.wma(low, len445), math.round(math.sqrt(len445)))
hilo63 := close > hi63[displace63] ? 1 : close < lo63[displace63] ? -1 : hilo63[1]
ghla63 = hilo63 == -1 ? hi63[displace63] : lo63[displace63]
color4463 = hilo63 == -1 ? color.fuchsia : color.yellow
//Alerts
buyCondition63 = hilo63 == 1 and hilo63[1] == -1
sellCondition63 = hilo63 == -1 and hilo63[1] == 1
if buyCondition63
alert('Long', alert.freq_once_per_bar)
if sellCondition63
alert('Short', alert.freq_once_per_bar)
//Plots
plot(ghla63, "TR", color=color4463, style=plot.style_stepline, linewidth = 3)
//plotshape(buyCondition, title = "Long", color = color.lime, textcolor = color.lime, text = "Long", style = shape.triangleup, location = location.belowbar, size = size.small)
//plotshape(sellCondition, title = "Short", color = color.red, textcolor = color.red, text = "Short", style = shape.triangledown, location = location.abovebar, size = size.small)
-
-
-
-
-
-
-