-
PHP Code:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//
//@version=6
indicator('Trend System', shorttitle = '.', overlay = true)
///////
// Input
fastlen1 = input(2, title = 'Fast Moving Average')
slowlen1 = input(3, title = 'Slow Moving Average')
signallen1 = input(3, title = 'Signal Line')
switch21 = input(true, title = 'Enable Moving Averages?')
// Calculation
fast1 = ta.ema(close, fastlen1)
slow1 = ta.ema(close, slowlen1)
MACD1= fast1 - slow1
signal1 = ta.ema(MACD1, signallen1)
histogr1 = MACD1 - signal1
// MACD, MA colors
MACDcolor1 = fast1 > slow1 ? color.lime : color.red
fastcolor1 = ta.change(fast1) > 0 ? color.lime : color.red
slowcolor1 = ta.change(slow1) > 0 ? color.lime: color.red
MACDupdowncolor1 = ta.change(MACD1) > 0 ? color.lime : color.red
// MACD histogram colors
histogrMACDcolor1 = MACD1 > histogr1 ? color.lime : color.red
histogrzerocolor1 = histogr1 > 0 ? color.lime : color.red
histogrupdowncolor1 = ta.change(histogr1) > 0 ? color.lime : color.red
// MACD signal line colors
signalMACDcolor1 = MACD1 > signal1 ? color.lime : color.red
signalzerocolor1 = signal1 > 0 ? color.lime : color.red
signalupdowncolor1 = ta.change(signal1) > 0 ? color.lime : color.red
S1 = plot(switch21 ? slow1 : na, color = MACDcolor1, linewidth = 1,title="MACD-Trend")
///////////////////////
///////////////////
// @variable Length for LOWESS calculation
int length = input.int(1, minval = 1, title = 'Length', group = 'LOWESS (Locally Weighted Scatterplot Smoothing)')
// @variable Number of bars to the left for pivot calculation
int leftBars = input.int(5, 'Length', group = 'Pivots')
// @variable Number of bars to the right for pivot calculation
int rightBars = leftBars - 4
// @variable Line object for high pivot
var line line_h = na
// @variable Line object for low pivot
var line line_l = na
// @variable Color for upward movements
color col_up = color.yellow
// @variable Color for downward movements
color col_dn = color.red
// Calculate pivot high and low
ph = ta.pivothigh(leftBars, rightBars)
pl = ta.pivotlow(leftBars, rightBars)
//@function Calculates LOWESS (Locally Weighted Scatterplot Smoothing)
//@param src (float) Source series
//@param length (int) Lookback period
//@returns (float) LOWESS value
lowess(src, length) =>
sum_w = 0.0
sum_wx = 0.0
sum_wy = 0.0
for i = 0 to length - 1 by 1
w = math.pow(1 - math.pow(i / length, 3), 3)
sum_w := sum_w + w
sum_wx := sum_wx + w * i
sum_wy := sum_wy + w * src[i]
sum_wy
a = sum_wy / sum_w
b = sum_wx / sum_w
a + b / (length - 1) / 2000
//@function Calculates Modified Adaptive Gaussian Moving Average
//@param src (float) Source series
//@param length (int) Lookback period
//@returns [float, float] Gaussian MA and smoothed Gaussian MA
GaussianMA(src, length) =>
h_l = array.new<float>(length)
float gma = 0.0
float sumOfWeights = 0.0
float sigma = (ta.atr(length) + ta.stdev(close, length)) / 2 // Volatility adaption
float highest = 0.0
float lowest = 0.0
float smoothed = 0.0
for i = 0 to length - 1 by 1
h_l.push(close[i])
highest := h_l.max()
lowest := h_l.min()
weight = math.exp(-math.pow((i - (length - 1)) / (2 * sigma), 2) / 2)
value = math.max(highest[i], highest) + math.min(lowest[i], lowest)
gma := gma + value * weight
sumOfWeights := sumOfWeights + weight
sumOfWeights
gma := gma / sumOfWeights / 2
smoothed := lowess(gma, 10)
[gma, smoothed]
[gma, smoothed] = GaussianMA(close, length)
smoothedColor = smoothed > smoothed[2] ? col_up : smoothed <= smoothed[2] ? col_dn : na
plot(smoothed, 'Pivot trend', smoothedColor)
/////////////////////////////
-
PHP Code:
//@version=6
indicator('LOWESS (Locally Weighted Scatterplot Smoothing) [ChartPrime]', '.', overlay = true, max_lines_count = 500, max_labels_count = 500)
//@version=6
////
/////
///////////////
//@version=6
// Inputs
a = input.int(1, title='Key Value. \"This changes the sensitivity\"')
c = input.int(1, title='ATR Period')
h = input.bool(true, title='Signals from Heikin Ashi Candles')
xATR = ta.atr(c)
nLoss = a * xATR
src = h ? request.security(syminfo.tickerid, timeframe.period, close, lookahead=barmerge.lookahead_off, gaps=barmerge.gaps_off) : close
xATRTrailingStop = 0.0
iff_1 = src > nz(xATRTrailingStop[1], 0) ? src - nLoss : src + nLoss
iff_2 = src < nz(xATRTrailingStop[1], 0) and src[1] < nz(xATRTrailingStop[1], 0) ? math.min(nz(xATRTrailingStop[1]), src + nLoss) : iff_1
xATRTrailingStop := src > nz(xATRTrailingStop[1], 0) and src[1] > nz(xATRTrailingStop[1], 0) ? math.max(nz(xATRTrailingStop[1]), src - nLoss) : iff_2
pos = 0
iff_3 = src[1] > nz(xATRTrailingStop[1], 0) and src < nz(xATRTrailingStop[1], 0) ? -1 : nz(pos[1], 0)
pos := src[1] < nz(xATRTrailingStop[1], 0) and src > nz(xATRTrailingStop[1], 0) ? 1 : iff_3
xcolor = pos == -1 ? color.red : pos == 1 ? color.green : color.blue
ema = ta.ema(src, 5)
above = ta.crossover(ema, xATRTrailingStop)
below = ta.crossover(xATRTrailingStop, ema)
barbuy = src > xATRTrailingStop
barsell = src < xATRTrailingStop
barcolor(barbuy ? color.green : na)
barcolor(barsell ? color.red : na)
//////////////
//////////////////
///////////////////
/////////////////////
//@version=6
start1 = input(0.1)
increment1 = input(0.1)
maximum1 = input(0.1)
xo = input(0.01)
xpr = input(0.01)
psar = 0.0 // PSAR
af = 0.0 // Acceleration Factor
trend_dir = 0 // Current direction of PSAR
ep = 0.0 // Extreme point
sar_long_to_short = trend_dir[1] == 1 and close <= psar[1] * (1 - xo) // PSAR switches from long to short and exceeds xo filter
sar_short_to_long = trend_dir[1] == -1 and close >= psar[1] * (1 + xo) // PSAR switches from short to long and exceeds xo filter
trend_change = barstate.isfirst[1] or sar_long_to_short or sar_short_to_long
// Calculate trend direction
trend_dir := 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_dir[1])
// Calculate Acceleration Factor
af := trend_change ? start1 : trend_dir == 1 and high > ep[1] or trend_dir == -1 and low < ep[1] ? math.min(maximum1, af[1] + increment1) : af[1]
// Calculate extreme point
ep := trend_change and trend_dir == 1 ? high : trend_change and trend_dir == -1 ? low : trend_dir == 1 ? math.max(ep[1], high * (1 + xpr)) : math.min(ep[1], low * (1 - xpr))
// Calculate PSAR
psar := barstate.isfirst[1] and close[1] > open[1] ? low[1] : barstate.isfirst[1] and close[1] <= open[1] ? high[1] : trend_change ? ep[1] : trend_dir == 1 ? psar[1] + af * (ep - psar[1]) : psar[1] - af * (psar[1] - ep)
plot(psar, style = plot.style_stepline, color = trend_dir == 1 ? color.yellow : color.blue,title = "Range",linewidth = 1)
////////////////////
start12 = input(0.2)
increment12 = input(0.2)
maximum12 = input(0.2)
xo12 = input(0.01)
xpr12 = input(0.01)
psar12 = 0.0 // PSAR
af12 = 0.0 // Acceleration Factor
trend_dir12 = 0 // Current direction of PSAR
ep12 = 0.0 // Extreme point
sar_long_to_short12 = trend_dir12[1] == 1 and close <= psar12[1] * (1 - xo12) // PSAR switches from long to short and exceeds xo filter
sar_short_to_long12 = trend_dir12[1] == -1 and close >= psar12[1] * (1 + xo12) // PSAR switches from short to long and exceeds xo filter
trend_change12 = barstate.isfirst[1] or sar_long_to_short12 or sar_short_to_long12
// Calculate trend direction
trend_dir12 := barstate.isfirst[1] and close[1] > open[1] ? 1 : barstate.isfirst[1] and close[1] <= open[1] ? -1 : sar_long_to_short12 ? -1 : sar_short_to_long12 ? 1 : nz(trend_dir12[1])
// Calculate Acceleration Factor
af12 := trend_change12 ? start12 : trend_dir12 == 1 and high > ep12[1] or trend_dir12 == -1 and low < ep12[1] ? math.min(maximum12, af12[1] + increment12) : af12[1]
// Calculate extreme point
ep12 := trend_change12 and trend_dir12 == 1 ? high : trend_change12 and trend_dir12 == -1 ? low : trend_dir12 == 1 ? math.max(ep12[1], high * (1 + xpr12)) : math.min(ep12[1], low * (1 - xpr12))
// Calculate PSAR
psar12 := barstate.isfirst[1] and close[1] > open[1] ? low[1] : barstate.isfirst[1] and close[1] <= open[1] ? high[1] : trend_change12 ? ep12[1] : trend_dir12 == 1 ? psar12[1] + af12 * (ep12 - psar12[1]) : psar12[1] - af12 * (psar12[1] - ep12)
plot(psar12, style = plot.style_stepline, color = trend_dir12 == 1 ? color.yellow : color.blue,title = "Range",linewidth = 1)
al=ta.crossover(psar, psar12)
plotshape(al)
al1=ta.crossover(close, psar)
plotshape(al1)
///////////////////////
//////
-
PHP Code:
//@version=6
indicator(title = '....', shorttitle = '.', overlay = true)
start1 = input(0.1)
increment1 = input(0.1)
maximum1 = input(0.1)
xo = input(0.01)
xpr = input(0.01)
psar = 0.0 // PSAR
af = 0.0 // Acceleration Factor
trend_dir = 0 // Current direction of PSAR
ep = 0.0 // Extreme point
sar_long_to_short = trend_dir[1] == 1 and close <= psar[1] * (1 - xo) // PSAR switches from long to short and exceeds xo filter
sar_short_to_long = trend_dir[1] == -1 and close >= psar[1] * (1 + xo) // PSAR switches from short to long and exceeds xo filter
trend_change = barstate.isfirst[1] or sar_long_to_short or sar_short_to_long
// Calculate trend direction
trend_dir := 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_dir[1])
// Calculate Acceleration Factor
af := trend_change ? start1 : trend_dir == 1 and high > ep[1] or trend_dir == -1 and low < ep[1] ? math.min(maximum1, af[1] + increment1) : af[1]
// Calculate extreme point
ep := trend_change and trend_dir == 1 ? high : trend_change and trend_dir == -1 ? low : trend_dir == 1 ? math.max(ep[1], high * (1 + xpr)) : math.min(ep[1], low * (1 - xpr))
// Calculate PSAR
psar := barstate.isfirst[1] and close[1] > open[1] ? low[1] : barstate.isfirst[1] and close[1] <= open[1] ? high[1] : trend_change ? ep[1] : trend_dir == 1 ? psar[1] + af * (ep - psar[1]) : psar[1] - af * (psar[1] - ep)
plot(psar, style = plot.style_stepline, color = trend_dir == 1 ? color.yellow : color.blue,title = "Range",linewidth = 1)
////////////////////
start12 = input(0.2)
increment12 = input(0.2)
maximum12 = input(0.2)
xo12 = input(0.01)
xpr12 = input(0.01)
psar12 = 0.0 // PSAR
af12 = 0.0 // Acceleration Factor
trend_dir12 = 0 // Current direction of PSAR
ep12 = 0.0 // Extreme point
sar_long_to_short12 = trend_dir12[1] == 1 and close <= psar12[1] * (1 - xo12) // PSAR switches from long to short and exceeds xo filter
sar_short_to_long12 = trend_dir12[1] == -1 and close >= psar12[1] * (1 + xo12) // PSAR switches from short to long and exceeds xo filter
trend_change12 = barstate.isfirst[1] or sar_long_to_short12 or sar_short_to_long12
// Calculate trend direction
trend_dir12 := barstate.isfirst[1] and close[1] > open[1] ? 1 : barstate.isfirst[1] and close[1] <= open[1] ? -1 : sar_long_to_short12 ? -1 : sar_short_to_long12 ? 1 : nz(trend_dir12[1])
// Calculate Acceleration Factor
af12 := trend_change12 ? start12 : trend_dir12 == 1 and high > ep12[1] or trend_dir12 == -1 and low < ep12[1] ? math.min(maximum12, af12[1] + increment12) : af12[1]
// Calculate extreme point
ep12 := trend_change12 and trend_dir12 == 1 ? high : trend_change12 and trend_dir12 == -1 ? low : trend_dir12 == 1 ? math.max(ep12[1], high * (1 + xpr12)) : math.min(ep12[1], low * (1 - xpr12))
// Calculate PSAR
psar12 := barstate.isfirst[1] and close[1] > open[1] ? low[1] : barstate.isfirst[1] and close[1] <= open[1] ? high[1] : trend_change12 ? ep12[1] : trend_dir12 == 1 ? psar12[1] + af12 * (ep12 - psar12[1]) : psar12[1] - af12 * (psar12[1] - ep12)
plot(psar12, style = plot.style_stepline, color = trend_dir12 == 1 ? color.yellow : color.blue,title = "Range",linewidth = 1)
-
PHP Code:
//@version=6
indicator(title = '.', shorttitle = '.')
ao = ta.sma(hl2, 5) - ta.sma(hl2, 45)
plot(ao, color = ta.change(ao) <= 0 ? color.red : color.green, style = plot.style_cross, linewidth = 2)
çok...sade....
-
Alıntı:
Originally Posted by
@yörük@
PHP Code:
//@version=6
indicator(title = '.', shorttitle = '.')
ao = ta.sma(hl2, 5) - ta.sma(hl2, 45)
plot(ao, color = ta.change(ao) <= 0 ? color.red : color.green, style = plot.style_cross, linewidth = 2)
çok...sade....
neden....çünkü... barın yüksek düşük/2 sini veri olarak alıp,
5barlık sma dan, 45 barlık sma....çıkarıp...
sıfırdan küçük veya büyük olmasına göre...hesaplanıp....çiziliyor....
buna strateji yazılsa....ve grafiğin üzerine atılsa ne güzel olurdu....
ama referans aralıkları farklı....
aynı grafiğe atabilmek için....
ya bar renklendirme....
ya da
zemin renklendirme yapmak gerekir...
böylece...yazılan strateji...çok rahat görülür...
örnek....
https://www.tradingview.com/x/kcpV2WUj/
https://www.tradingview.com/x/2yNlpXXL/
https://www.tradingview.com/x/CAP0Y87Q/
https://www.tradingview.com/x/ge5heEHW/
-
PHP Code:
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=6
indicator(".", overlay = true, max_lines_count = 500, max_labels_count=500)
//////////////// MAS TREND VE BAR RENKLENDİRMESİDİR /////////////////////////
type_ma = input.string("SMA", "Type", options = ["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group = "MA")
length = input.int(10, "Length", inline = "ma", group = "MA")
source = input.source(hl2, "", inline = "ma", group = "MA")
grp = "MA Shift Oscillator"
osc_len = input.int(15, "Length", group = grp, inline = "osc")
osc_threshold = input.float(0.5, "", step = 0.1, group = grp, inline = "osc")
// Colors
osc_col_up1 = input.color(#1dd1c2, "", inline = "c", group = "color")
osc_col_up2 = input.color(#17a297, "", inline = "c", group = "color")
osc_col_dn1 = input.color(color.yellow, "", inline = "c", group = "color")
osc_col_dn2 = input.color(color.orange, "", inline = "c", group = "color")
// Smoothing MA Calculation
ma(source, length, MAtype) =>
switch MAtype
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
// MA
MA = ma(source, length, type_ma)
color = source >= MA ? osc_col_up2 : osc_col_dn2
// Osc
diff = source - MA
perc_r = ta.percentile_linear_interpolation(diff, 1000, 99)
osc = ta.hma(ta.change(diff / perc_r, osc_len), 10)
osc_col = osc > 0 ? (osc > osc[1] ? osc_col_up1 : osc_col_up2) : (osc < osc[1] ? osc_col_dn1 : osc_col_dn2)
// MAs Plot
plot(MA, "MAS TREND", color=color, force_overlay = true, linewidth = 2)
barcolor(color)
/////////////////// 40 SMA İLE TREND TAKİP HESAPLAMASIDIR ///////////////////////
smaHigh = ta.sma(high, 40)
smaLow = ta.sma(low, 40)
mf=(smaHigh+smaLow)/2
plot(mf, title = 'SMA TREND ', color = #fd07f5, linewidth = 2)
///////////////// YÜZDEYLE TREND VE KANAL HESAPLAMASIDIR //////////////////
//@version=6
// Input for the filter smoothness parameter
lambda = input.int(100, 'Smoothness Parameter (λ)', minval = 1)
// Input to switch between percentage and price difference views
displayMode = input.string('Percentage', 'Display Mode', options = ['Percentage', 'Price Difference'])
// Function to calculate the approximate HP trend component
hpFilter(src, lambda) =>
var float trend = na
trend := na(trend[1]) ? src : (src + (lambda - 1) * nz(trend[1])) / lambda
trend
// Calculate the HP Filter (trend component)
hp_trend = hpFilter(close, lambda)
// Calculate the cycle component as both percentage and price difference
cycle_pct = (close - hp_trend) / hp_trend * 100
cycle_price = close - hp_trend
// Arrays to store positive and negative cycle percentage values
var pos_values = array.new_float()
var neg_values = array.new_float()
// Collect positive and negative cycle percentage values
if displayMode == 'Percentage'
if cycle_pct > 0
array.push(pos_values, cycle_pct)
else if cycle_pct < 0
array.push(neg_values, cycle_pct)
// Calculate medians for values above and below zero
pos_median = array.size(pos_values) > 0 ? array.avg(pos_values) : na
neg_median = array.size(neg_values) > 0 ? array.avg(neg_values) : na
// Target circles
longtarget = pos_median / 100 * hp_trend + hp_trend
shorttaget = neg_median / 100 * hp_trend + hp_trend
// Conditional plotting based on the selected display mode
//plot(displayMode == 'Percentage' ? cycle_pct : na, title = 'HP Filter Divergence (%)', color = color.blue, linewidth = 1)
//plot(displayMode == 'Price Difference' ? cycle_price : na, title = 'HP Filter Divergence (Price)', color = color.blue, linewidth = 1)
//hline(0, 'Zero Line', linestyle = hline.style_dashed)
// Plot the cycle component in the new pane
plot(hp_trend, title = 'YÖRÜK TREND', color = color.gray, linewidth = 2, force_overlay = true)
plot(longtarget, title = 'YÖRÜK ÜST KANAL', color = color.gray, force_overlay = true, style = plot.style_line)
plot(shorttaget, title = 'YÖRÜK ALT KANAL', color = color.gray, force_overlay = true, style = plot.style_line)
// Plot horizontal lines for the median values above and below zero
//plot(pos_median, 'Positive Median Line', color = color.green)
//plot(neg_median, 'Negative Median Line', color = color.purple)
////////////////////// ATR TREND HESAPLAMASIDIR /////////////////////
//@version=6
var params = "Parameters"
src55 = nz(input.source(close, title = "Source", group = params))
len55 = input.int(10, title = "ATR Len", group = params)
multi55 = input.float(1.5, title = "Multi", step = 0.25, minval = 0, group = params)
var disp = "Display"
rng_tog = input.bool(true, title = "Consolidation Ranges", group = disp)
atr_tog = input.bool(false, title = "ATR Channel", group = disp)
var cols = "Colors"
up_col = input.color(#3daa45, title = "Up Color", group = cols)
down_col = input.color(#ff033e, title = "Down Color", group = cols)
flat_col = input.color(color.rgb(235, 243, 6), title = "Flat Color", inline = "3", group = cols)
rng_col = input.color(#004d9233, title = "", inline = "3", group = cols)
//Smooths a Source similar to Rope Stabilization in a Drawing Application. OR a "Range Filter" as some might say ;)
rope_smoother(float _src55, float _threshold) =>
var float _rope = _src55
_move = _src55 - _rope //Movement from Rope
_rope += math.max(math.abs(_move) - nz(_threshold), 0) * math.sign(_move) //Directional Movement beyond the Threshold
[_rope,_rope+_threshold,_rope-_threshold] //[Rope, Upper, Lower]
///_____________________________________________________________________________________________________________________
///Rope Calcs
///‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
//Calculating Rope
atr = ta.atr(len55)*multi55
[rope,upper,lower] = rope_smoother(src55,atr)
//Directional Detection
var dir = 0
dir := rope > rope[1] ? 1 : rope < rope[1] ? -1 : dir
if ta.cross(src55,rope)
dir := 0
//Directional Color Assignment
col = dir > 0 ? up_col : dir < 0 ? down_col : flat_col
///_____________________________________________________________________________________________________________________
///Consolidation Ranges
///‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
//High and Low Output Lines
var float c_hi = na
var float c_lo = na
//Counters for Accumulating Averages
var float h_sum = 0
var float l_sum = 0
var int c_count = 0
//Flip-Flop
var ff = 1
//Flip Flop, Pip Slip Top,
//Bear Drop, Bull Pop, Lunch Time Chop,
//Tight Stop, Desktop Prop.
if dir == 0
if dir[1] != 0
h_sum := 0
l_sum := 0
c_count := 0
ff := ff * -1
h_sum += upper
l_sum += lower
c_count += 1
c_hi := h_sum/c_count
c_lo := l_sum/c_count
///_____________________________________________________________________________________________________________________
///Display
///‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
//Rope
plot(rope, linewidth = 3, color = col, title = "ATR TREND", force_overlay = true)
/////////////////////////// ZEMİNİ RSİ TRENDE GÖRE RENKLENDİRME HESAPLAMASIDIR ///////////////////
src88 = input.source(close,"RSI Source",group = "Connors RSI")
lenrsi = input(24, "RSI Length",group = "Connors RSI")
lenupdown = input(20, "UpDown Length",group = "Connors RSI")
lenroc = input(75, "ROC Length",group = "Connors RSI")
z_score_length = input(14, "Z-Score Lookback",group = "Filtering")
threshold = input.float(1.5, "Z-Score Threshold", step=0.025,group = "Filtering")
trendingLongThreshold = input.float(65, "Trending Long Threshold" ,group = "Filtering")
trendingShortThreshold = input.float(35, "Trending Short Threshold",group = "Filtering")
revertingLongThreshold = input.float(70, title="Reverting Long Threshold",group = "Filtering")
revertingShortThreshold = input.float(30, title="Reverting Short Threshold",group = "Filtering")
// ─── CONNORS RSI ──────────────────────────────────────────────────────────
updown(s) =>
isEqual = s == s[1]
isGrowing = s > s[1]
ud = 0.0
ud := isEqual ? 0 : isGrowing ? (nz(ud[1]) <= 0 ? 1 : nz(ud[1])+1) : (nz(ud[1]) >= 0 ? -1 : nz(ud[1])-1)
ud
rsi88 = ta.rsi(src88, lenrsi)
updownrsi = ta.rsi(updown(src88), lenupdown)
percentrank = ta.percentrank(ta.roc(src88, 1), lenroc)
crsi = math.avg(rsi88, updownrsi, percentrank)
// ─── Z-SCORING ──────────────────────────────────────────────────────────
mean = ta.sma(crsi, z_score_length)
stdDev = ta.stdev(crsi, z_score_length)
zScore88 = (crsi - mean) / stdDev
isTrending = math.abs(zScore88) > threshold
// ─── Signal Generation ────────────────────────────────────────────────
var int signal = 0
if barstate.isconfirmed
if isTrending
signal := crsi > trendingLongThreshold ? 1 : crsi < trendingShortThreshold ? -1 : signal[1]
else
signal := crsi > revertingLongThreshold ? 1 : crsi < revertingShortThreshold ? -1 : signal[1]
trendColor = signal == 1 ? #17dfad : signal == -1 ? #dd326b : color.gray
//decor = plot(crsi,"Decor",style = plot.style_columns,histbase = 50,color=trendColor,linewidth = 2)
bgcolor(color.new(trendColor,75))
//plotcandle(open,high,low,close,"Candles",color=trendColor,wickcolor = trendColor,bordercolor = trendColor,force_overlay = true)
/////////////
//@version=6
// Color variables
upTrendColor = color.green
neutralColor = #0e0e0e
downTrendColor = color.red
fillColor = color.rgb(12, 12, 12, 70) // Color between lines
yellowColor = color.rgb(230, 214, 2)
blackTextColor = color.rgb(0, 0, 0)
blueColor = color.rgb(233, 217, 0)
whiteTextColor = color.rgb(7, 7, 7)
greenColor = color.green
redColor = color.red
// Source
source99 = input(defval = close, title = 'Source')
// Sampling Period
period = input.int(defval = 50, minval = 1, title = 'Sampling Period')
// Range Multiplier
multiplier = input.float(defval = 3.0, minval = 0.1, title = 'Range Multiplier')
// Take Profit Settings
takeProfitPips = input.float(defval = 600.0, title = 'Take Profit (in pips)')
// Smooth Average Range
smoothRange(x, t, m) =>
adjustedPeriod = t * 2 - 1
avgRange = ta.ema(math.abs(x - x[1]), t)
smoothRange = ta.ema(avgRange, adjustedPeriod) * m
smoothRange
smoothedRange = smoothRange(source99, period, multiplier)
// Trend Filter
trendFilter(x, r) =>
filtered = x
filtered := x > nz(filtered[1]) ? x - r < nz(filtered[1]) ? nz(filtered[1]) : x - r : x + r > nz(filtered[1]) ? nz(filtered[1]) : x + r
filtered
filter = trendFilter(source, smoothedRange)
// Filter Direction
upCount = 0.0
upCount := filter > filter[1] ? nz(upCount[1]) + 1 : filter < filter[1] ? 0 : nz(upCount[1])
downCount = 0.0
downCount := filter < filter[1] ? nz(downCount[1]) + 1 : filter > filter[1] ? 0 : nz(downCount[1])
// Colors
filterColor = upCount > 0 ? upTrendColor : downCount > 0 ? downTrendColor : neutralColor
// Double Line Design
//lineOffset = smoothedRange * 0.1
//upperLinePlot = plot(filter + lineOffset, color = filterColor, linewidth = 1, title = 'EMA TREND')
//lowerLinePlot = plot(filter - lineOffset, color = filterColor, linewidth = 1, title = 'Düşüş Trend Çizgisi')
//fill(upperLinePlot, lowerLinePlot, color = fillColor, title = 'Trend Fill')
// Break Outs
longCondition = bool(na)
shortCondition = bool(na)
longCondition := source99 > filter and source99 > source99[1] and upCount > 0 or source99 > filter and source99 < source99[1] and upCount > 0
shortCondition := source99 < filter and source99 < source99[1] and downCount > 0 or source99 < filter and source99 > source99[1] and downCount > 0
initialCondition = 0
initialCondition := longCondition ? 1 : shortCondition ? -1 : initialCondition[1]
longSignal = longCondition and initialCondition[1] == -1
shortSignal = shortCondition and initialCondition[1] == 1
// Take Profit Logic
var float entryPriceBuy = na
var float entryPriceSell = na
takeProfitSignalBuy = false
takeProfitSignalSell = false
if longSignal
entryPriceBuy := source99
entryPriceBuy
if not na(entryPriceBuy) and source99 >= entryPriceBuy + takeProfitPips * syminfo.mintick
takeProfitSignalBuy := true
entryPriceBuy := na
entryPriceBuy
if shortSignal
entryPriceSell := source99
entryPriceSell
if not na(entryPriceSell) and source99 <= entryPriceSell - takeProfitPips * syminfo.mintick
takeProfitSignalSell := true
entryPriceSell := na
entryPriceSell
// Alerts and Signals
plotshape(longSignal, title = 'Smart Buy Signal', text = 'Al', textcolor = color.white, style = shape.labelup, size = size.small, location = location.belowbar, color = greenColor)
plotshape(shortSignal, title = 'Smart Sell Signal', text = 'Sat', textcolor = color.white, style = shape.labeldown, size = size.small, location = location.abovebar, color = redColor)
//plotshape(takeProfitSignalBuy, title = 'Book Profit Buy', text = 'Book Profit', textcolor = blackTextColor, style = shape.labeldown, size = size.small, location = location.abovebar, color = yellowColor)
//plotshape(takeProfitSignalSell, title = 'Book Profit Sell', text = 'Book Profit', textcolor = whiteTextColor, style = shape.labelup, size = size.small, location = location.belowbar, color = blueColor)
///////////////////// FİBO TREND HESAPLAMASIDIR ///////////////////
//@version=6
grp1 = "Indicator Settings"
tpAggressiveness = input.string("low", "TP Aggressiveness", options=["low", "medium", "high"], group=grp1, tooltip="Controls how aggressive the Take Profit (TP) trigger is. Low = slower exits, High = faster exits.", display = display.data_window)
src44 = input.source(hlc3, "Source", group=grp1, tooltip="Price source used for band calculations", display = display.data_window)
len44 = input.int(10, "Length", group=grp1, tooltip="Length for the basis calculation", display = display.data_window)
atrLen44 = input.int(10, "ATR Length", group=grp1, tooltip="Length for ATR or Stdev volatility basis", display = display.data_window)
useATR = input.bool(true, "Use ATR", group=grp1, tooltip="Toggle between ATR or standard deviation for band width", display = display.data_window)
grp2 = "Visual Options"
showRej = input.bool(true, "Show Take Profit Crosses", group=grp2, display = display.data_window)
showBounce = input.bool(true, "Show Basis Bounce Arrows", group=grp2, display = display.data_window)
//colorbar = input.bool(true, "Custom Bar Color", group=grp2, display = display.data_window)
//green = input.color(#00ffbb, "Bullish Color", group=grp2, display = display.data_window)
//red = input.color(#ff1100, "Bearish Color", group=grp2, display = display.data_window)
gray = input.color(color.fuchsia, "Basis Color", group=grp2, display = display.data_window)
basis = ta.ema(ta.ema(src44, len44), len44)
vol = useATR ? ta.atr(atrLen44) : ta.stdev(src44, len44)
mult1 = 0.618
mult2 = 1.0
mult3 = 1.618
mult4 = 2.618
var int trend = 0
trend := basis > basis[1] ? 1 : basis < basis[1] ? -1 : nz(trend[1])
upper1 = basis + vol * mult1
upper2 = basis + vol * mult2
upper3 = basis + vol * mult3
upper4 = basis + vol * mult4
lower1 = basis - vol * mult1
lower2 = basis - vol * mult2
lower3 = basis - vol * mult3
lower4 = basis - vol * mult4
plot(basis, title="Fibo-Trend", color=gray, linewidth=1)
///////////////////////MACD TREND HESAPLAMASIDIR/////////////////
//@version=6
// Input
fastlen1 = input(2, title = 'Fast Moving Average')
slowlen1 = input(3, title = 'Slow Moving Average')
signallen1 = input(3, title = 'Signal Line')
switch21 = input(true, title = 'Enable Moving Averages?')
// Calculation
fast1 = ta.ema(close, fastlen1)
slow1 = ta.ema(close, slowlen1)
MACD1= fast1 - slow1
signal1 = ta.ema(MACD1, signallen1)
histogr1 = MACD1 - signal1
// MACD, MA colors
MACDcolor1 = fast1 > slow1 ? color.lime : color.red
fastcolor1 = ta.change(fast1) > 0 ? color.lime : color.red
slowcolor1 = ta.change(slow1) > 0 ? color.lime: color.red
MACDupdowncolor1 = ta.change(MACD1) > 0 ? color.lime : color.red
// MACD histogram colors
histogrMACDcolor1 = MACD1 > histogr1 ? color.lime : color.red
histogrzerocolor1 = histogr1 > 0 ? color.lime : color.red
histogrupdowncolor1 = ta.change(histogr1) > 0 ? color.lime : color.red
// MACD signal line colors
signalMACDcolor1 = MACD1 > signal1 ? color.lime : color.red
signalzerocolor1 = signal1 > 0 ? color.lime : color.red
signalupdowncolor1 = ta.change(signal1) > 0 ? color.lime : color.red
S1 = plot(switch21 ? slow1 : na, color = MACDcolor1, linewidth = 1,title="MACD-Trend")
///////////////////////
///////////////////
// @variable Length for LOWESS calculation
int length77 = input.int(1, minval = 1, title = 'Length', group = 'LOWESS (Locally Weighted Scatterplot Smoothing)')
// @variable Number of bars to the left for pivot calculation
int leftBars = input.int(5, 'Length', group = 'Pivots')
// @variable Number of bars to the right for pivot calculation
int rightBars = leftBars - 4
// @variable Line object for high pivot
var line line_h = na
// @variable Line object for low pivot
var line line_l = na
// @variable Color for upward movements
color col_up = color.yellow
// @variable Color for downward movements
color col_dn = color.red
// Calculate pivot high and low
ph = ta.pivothigh(leftBars, rightBars)
pl = ta.pivotlow(leftBars, rightBars)
//@function Calculates LOWESS (Locally Weighted Scatterplot Smoothing)
//@param src (float) Source series
//@param length (int) Lookback period
//@returns (float) LOWESS value
lowess(src79, length77) =>
sum_w = 0.0
sum_wx = 0.0
sum_wy = 0.0
for i = 0 to length77 - 1 by 1
w = math.pow(1 - math.pow(i / length77, 3), 3)
sum_w := sum_w + w
sum_wx := sum_wx + w * i
sum_wy := sum_wy + w * src79[i]
sum_wy
a = sum_wy / sum_w
b = sum_wx / sum_w
a + b / (length77 - 1) / 2000
//@function Calculates Modified Adaptive Gaussian Moving Average
//@param src (float) Source series
//@param length (int) Lookback period
//@returns [float, float] Gaussian MA and smoothed Gaussian MA
GaussianMA(src79, length77) =>
h_l = array.new<float>(length77)
float gma = 0.0
float sumOfWeights = 0.0
float sigma = (ta.atr(length77) + ta.stdev(close, length77)) / 2 // Volatility adaption
float highest = 0.0
float lowest = 0.0
float smoothed = 0.0
for i = 0 to length77 - 1 by 1
h_l.push(close[i])
highest := h_l.max()
lowest := h_l.min()
weight = math.exp(-math.pow((i - (length77 - 1)) / (2 * sigma), 2) / 2)
value = math.max(highest[i], highest) + math.min(lowest[i], lowest)
gma := gma + value * weight
sumOfWeights := sumOfWeights + weight
sumOfWeights
gma := gma / sumOfWeights / 2
smoothed := lowess(gma, 10)
[gma, smoothed]
[gma, smoothed] = GaussianMA(close, length)
smoothedColor = smoothed > smoothed[2] ? col_up : smoothed <= smoothed[2] ? col_dn : na
plot(smoothed, 'Pivot trend', smoothedColor)
/////////////////////////////STOP HESAPLAMADIR////////////////////////////////////
//@version=6
length66 = input(title = 'ATR Period', defval = 10)
mult66 = input.float(title = 'ATR Multiplier', step = 0.1, defval = 2)
srca = input(title = 'Source', defval = ohlc4)
wicks = input(title = 'Take Wicks into Account ?', defval = true)
atr66 = mult66 * ta.atr(length66)
highPrice = wicks ? high : close
lowPrice = wicks ? low : close
doji4price = open == close and open == low and open == high
longStop = srca - atr66
longStopPrev = nz(longStop[1], longStop)
if longStop > 0
if doji4price
longStop := longStopPrev
longStop
else
longStop := lowPrice[1] > longStopPrev ? math.max(longStop, longStopPrev) : longStop
longStop
else
longStop := longStopPrev
longStop
shortStop = srca + atr66
shortStopPrev = nz(shortStop[1], shortStop)
if shortStop > 0
if doji4price
shortStop := shortStopPrev
shortStop
else
shortStop := highPrice[1] < shortStopPrev ? math.min(shortStop, shortStopPrev) : shortStop
shortStop
else
shortStop := shortStopPrev
shortStop
var int dir66 = 1
dir66 := dir66 == -1 and highPrice > shortStopPrev ? 1 : dir66 == 1 and lowPrice < longStopPrev ? -1 : dir66
var color longColor = color.green
var color shortColor = color.red
buySignal = dir66 == 1 and dir66[1] == -1
plotshape(buySignal ? longStop : na, title = 'Long Stop Start', location = location.absolute, style = shape.circle, size = size.normal, color = color.new(longColor, 0))
sellSignal = dir66 == -1 and dir66[1] == 1
plotshape(sellSignal ? shortStop : na, title = 'Short Stop Start', location = location.absolute, style = shape.circle, size = size.normal, color = color.new(shortColor, 0))
/////////////////////////SAR İLE KANAL ARALIK HESAPLAMASIDIR////////////////////
//@version=6
start1 = input(0.)
increment1 = input(0.1)
maximum1 = input(0.9)
xo = input(0.01)
xpr = input(0.01)
psar = 0.0 // PSAR
af = 0.0 // Acceleration Factor
trend_dir = 0 // Current direction of PSAR
ep = 0.0 // Extreme point
sar_long_to_short = trend_dir[1] == 1 and close <= psar[1] * (1 - xo) // PSAR switches from long to short and exceeds xo filter
sar_short_to_long = trend_dir[1] == -1 and close >= psar[1] * (1 + xo) // PSAR switches from short to long and exceeds xo filter
trend_change = barstate.isfirst[1] or sar_long_to_short or sar_short_to_long
// Calculate trend direction
trend_dir := 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_dir[1])
// Calculate Acceleration Factor
af := trend_change ? start1 : trend_dir == 1 and high > ep[1] or trend_dir == -1 and low < ep[1] ? math.min(maximum1, af[1] + increment1) : af[1]
// Calculate extreme point
ep := trend_change and trend_dir == 1 ? high : trend_change and trend_dir == -1 ? low : trend_dir == 1 ? math.max(ep[1], high * (1 + xpr)) : math.min(ep[1], low * (1 - xpr))
// Calculate PSAR
psar := barstate.isfirst[1] and close[1] > open[1] ? low[1] : barstate.isfirst[1] and close[1] <= open[1] ? high[1] : trend_change ? ep[1] : trend_dir == 1 ? psar[1] + af * (ep - psar[1]) : psar[1] - af * (psar[1] - ep)
plot(psar, style = plot.style_stepline, color = trend_dir == 1 ? color.yellow : color.blue,title = "KANAL",linewidth = 1)
////////////////////
start12 = input(0.)
increment12 = input(0.01)
maximum12 = input(0.9)
xo12 = input(0.01)
xpr12 = input(0.01)
psar12 = 0.0 // PSAR
af12 = 0.0 // Acceleration Factor
trend_dir12 = 0 // Current direction of PSAR
ep12 = 0.0 // Extreme point
sar_long_to_short12 = trend_dir12[1] == 1 and close <= psar12[1] * (1 - xo12) // PSAR switches from long to short and exceeds xo filter
sar_short_to_long12 = trend_dir12[1] == -1 and close >= psar12[1] * (1 + xo12) // PSAR switches from short to long and exceeds xo filter
trend_change12 = barstate.isfirst[1] or sar_long_to_short12 or sar_short_to_long12
// Calculate trend direction
trend_dir12 := barstate.isfirst[1] and close[1] > open[1] ? 1 : barstate.isfirst[1] and close[1] <= open[1] ? -1 : sar_long_to_short12 ? -1 : sar_short_to_long12 ? 1 : nz(trend_dir12[1])
// Calculate Acceleration Factor
af12 := trend_change12 ? start12 : trend_dir12 == 1 and high > ep12[1] or trend_dir12 == -1 and low < ep12[1] ? math.min(maximum12, af12[1] + increment12) : af12[1]
// Calculate extreme point
ep12 := trend_change12 and trend_dir12 == 1 ? high : trend_change12 and trend_dir12 == -1 ? low : trend_dir12 == 1 ? math.max(ep12[1], high * (1 + xpr12)) : math.min(ep12[1], low * (1 - xpr12))
// Calculate PSAR
psar12 := barstate.isfirst[1] and close[1] > open[1] ? low[1] : barstate.isfirst[1] and close[1] <= open[1] ? high[1] : trend_change12 ? ep12[1] : trend_dir12 == 1 ? psar12[1] + af12 * (ep12 - psar12[1]) : psar12[1] - af12 * (psar12[1] - ep12)
plot(psar12, style = plot.style_stepline, color = trend_dir12 == 1 ? color.yellow : color.blue,title = "KANAL",linewidth = 1)
//////////////////////
-
PHP Code:
//@version=6
indicator(title="Parabolic SAR Deviation [BigBeluga]", shorttitle="...", overlay=true, max_lines_count = 500, max_labels_count = 500)
//@version=6
init = input.float(0.009, title = 'Initial Start', step = 0.001)
fi = input.float(3, title = 'Increment/Start Ratio', step = 0.1)
fm = input.float(9, title = 'Max/Start Ratio', step = 0.1)
sar01 = ta.sar(init * 01, init * fi * 01, init * fm * 01)
sar10 = ta.sar(init * 10, init * fi * 10, init * fm * 10)
//plot(sar01, title = '01 SAR', style = plot.style_circles, color = renk ? sar01 > high ? color.red : color.green : color.silver, linewidth = 1)
//plot(sar10, title = '10 SAR', style = plot.style_circles, color = renk ? sar10 > high ? color.red : color.green : color.silver, linewidth = 1)
fd=(sar01+sar10)/2
plot(fd, title = 'SAR TREND', style = plot.style_stepline, color = renk ? fd > high ? color.red : color.green : color.silver, linewidth = 2)
////////////////////////////////
//@version=6
start = input(0.)
increment = input(0.1)
maximum = input(0.9, "Max Value")
out55 = ta.sar(start, increment, maximum)
plot_color = close > out55 ? color.rgb(5, 182, 64) : close < out55 ? color.rgb(169, 7, 7) : na
show_header = input(false, title="Show header?", group='Table Settings')
dashboard_position = input.string("Top center", title="Position", options=["Top right", "Top center", "Middle right"], group='Table Settings')
text_size = input.string('Normal', title="Size", options=["Tiny", "Small", "Normal", "Large"], group='Table Settings')
text_color = input.color(color.rgb(11, 68, 224), title="Text color", group='Table Settings')
table_color = input.color(color.purple, title="Border color", group='Table Settings')
uptrend_indicator = "🔵"
downtrend_indicator = "🟠"
tf1 = input.timeframe("1", title="Timeframe 1")
tf2 = input.timeframe("3", title="Timeframe 2")
tf3 = input.timeframe("5", title="Timeframe 3")
tf4 = input.timeframe("10", title="Timeframe 4")
tf5 = input.timeframe("15", title="Timeframe 5")
tf6 = input.timeframe("30", title="Timeframe 6")
tf7 = input.timeframe("60", title="Timeframe 7")
tf8 = input.timeframe("120", title="Timeframe 8")
tf9 = input.timeframe("240", title="Timeframe 9")
tf10 = input.timeframe("D", title="Timeframe 10")
var table_position = dashboard_position == 'Top center' ? position.top_center :
dashboard_position == 'Top center' ? position.top_center :
dashboard_position == 'Middle right' ? position.middle_right : position.middle_right
var table_text_size = text_size == 'Normal' ? size.normal :
text_size == 'Small' ? size.small : size.normal
var t = table.new(position=table_position, columns=3, rows=20, frame_color=#cdcbcb, frame_width=5, border_color=table_color, border_width=1,bgcolor =color.rgb(21, 21, 21) )
get_trend_status(trend_value) =>
is_uptrend = close > trend_value
candle_now = is_uptrend ? uptrend_indicator : downtrend_indicator
candle_now
//--------------------------------------------------------------------------------------
sar_1 = request.security(syminfo.tickerid, tf1, ta.sar(start, increment, maximum))
sar_2 = request.security(syminfo.tickerid, tf2, ta.sar(start, increment, maximum))
sar_3 = request.security(syminfo.tickerid, tf3, ta.sar(start, increment, maximum))
sar_4 = request.security(syminfo.tickerid, tf4, ta.sar(start, increment, maximum))
sar_5 = request.security(syminfo.tickerid, tf5, ta.sar(start, increment, maximum))
sar_6 = request.security(syminfo.tickerid, tf6, ta.sar(start, increment, maximum))
sar_7 = request.security(syminfo.tickerid, tf7, ta.sar(start, increment, maximum))
sar_8 = request.security(syminfo.tickerid, tf8, ta.sar(start, increment, maximum))
sar_9 = request.security(syminfo.tickerid, tf9, ta.sar(start, increment, maximum))
sar_10 = request.security(syminfo.tickerid, tf10, ta.sar(start, increment, maximum))
trend_indicator_1 = get_trend_status(sar_1)
trend_indicator_2 = get_trend_status(sar_2)
trend_indicator_3 = get_trend_status(sar_3)
trend_indicator_4 = get_trend_status(sar_4)
trend_indicator_5 = get_trend_status(sar_5)
trend_indicator_6 = get_trend_status(sar_6)
trend_indicator_7 = get_trend_status(sar_7)
trend_indicator_8 = get_trend_status(sar_8)
trend_indicator_9 = get_trend_status(sar_9)
trend_indicator_10 = get_trend_status(sar_10)
if tf1 == "60"
tf1 := "1H"
if tf1 == "120"
tf1 := "2H"
if tf1 == "180"
tf1 := "3H"
if tf1 == "240"
tf1 := "4H"
if tf2 == "60"
tf2 := "1H"
if tf2 == "120"
tf2 := "2H"
if tf2 == "180"
tf2 := "3H"
if tf2 == "240"
tf2 := "4H"
if tf3 == "60"
tf3 := "1H"
if tf3 == "120"
tf3 := "2H"
if tf3 == "180"
tf3 := "3H"
if tf3 == "240"
tf3 := "4H"
if tf4 == "60"
tf4 := "1H"
if tf4 == "120"
tf4 := "2H"
if tf4 == "180"
tf4 := "3H"
if tf4 == "240"
tf4 := "4H"
if tf5 == "60"
tf5 := "1H"
if tf5 == "120"
tf5 := "2H"
if tf5 == "180"
tf5 := "3H"
if tf5 == "240"
tf5 := "4H"
if tf6 == "60"
tf6 := "1H"
if tf6 == "120"
tf6 := "2H"
if tf6 == "180"
tf6 := "3H"
if tf6 == "240"
tf6 := "4H"
if tf7 == "60"
tf7 := "1H"
if tf7 == "120"
tf7 := "2H"
if tf7 == "180"
tf7 := "3H"
if tf7 == "240"
tf7 := "4H"
if tf8 == "60"
tf8 := "1H"
if tf8 == "120"
tf8 := "2H"
if tf8 == "180"
tf8 := "3H"
if tf8 == "240"
tf8 := "4H"
if tf9 == "60"
tf9 := "1H"
if tf9 == "120"
tf9 := "2H"
if tf9 == "180"
tf9 := "3H"
if tf9 == "240"
tf9 := "4H"
if tf10 == "60"
tf10 := "1H"
if tf10 == "120"
tf10 := "2H"
if tf10 == "180"
tf10 := "3H"
if tf10 == "240"
tf10 := "4H"
//---------------------------------------------------------------------------------------------
// Update table with trend data
//---------------------------------------------------------------------------------------------
if (barstate.islast)
table.cell(t, 0, 1, tf1, text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 1, text="●", text_color=trend_indicator_1==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 1, str.tostring(sar_1, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 2, tf2, text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 2, text="●", text_color=trend_indicator_2==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 2, str.tostring(sar_2, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 3, tf3, text_color=color.white, text_size=table_text_size,bgcolor= color.rgb(21, 21, 21))
table.cell(t, 1, 3, text="●", text_color=trend_indicator_3==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 3, str.tostring(sar_3, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 4, tf4, text_color=color.white, text_size=table_text_size, bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 4, text="●", text_color=trend_indicator_4==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 4, str.tostring(sar_4, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 5, tf5, text_color=color.white, text_size=table_text_size, bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 5, text="●", text_color=trend_indicator_5==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 5, str.tostring(sar_5, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 6, tf6, text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 6, text="●", text_color=trend_indicator_6==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 6, str.tostring(sar_6, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 7, tf7, text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 7, text="●", text_color=trend_indicator_7==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 7, str.tostring(sar_7, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 8, tf8, text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 8, text="●", text_color=trend_indicator_8==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 8, str.tostring(sar_8, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 9, tf9, text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 9, text="●", text_color=trend_indicator_9==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 9, str.tostring(sar_9, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 0, 10, tf10, text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t, 1, 10, text="●", text_color=trend_indicator_10==uptrend_indicator?color.lime:color.red,text_size = size.large)
table.cell(t, 2, 10, str.tostring(sar_10, "#.##"), text_color=color.white, text_size=table_text_size,bgcolor = color.rgb(21, 21, 21))
table.cell(t,0,0,"Periyot",text_color = color.white,bgcolor = color.rgb(21, 21, 21))
table.cell(t,1,0,"Trend",text_color = color.white,bgcolor = color.rgb(21, 21, 21))
table.cell(t,2,0,"Fiyat",text_color = color.white,bgcolor = color.rgb(21, 21, 21))
lookback = input.int(5, "Line Lookback Period", minval=1)
//////////////////////////DEVİNASYON İLE SMA HESAPLAMASIDIR///////////////////////
//@version=6
bool prices = input.bool(true, "Signals", group = "SAR")
color col_up = input.color(#40c3fb, "", inline = "col", group = "SAR")
color col_dn = input.color(#e040fb, "", inline = "col", group = "SAR")
float deviation_size = input.float(3.5, "Deviation", step = 0.1, group = "Deviation Levels")
color color_na = color.new(color.black, 100)
color standart_col = chart.fg_color
out88 = ta.sma(close,40)
deviation_levels(trend)=>
float dist = ta.sma(high-low, 100)*deviation_size
var lines = array.new<line>(1, line(na))
var labels = array.new<label>(1, label(na))
if trend != trend[1]
for i = 1 to 4
y = trend ? close+dist*i : close-dist*i
bool trend = close > out88
bool trend_up = ta.crossover(close, out88) and barstate.isconfirmed
bool trend_dn = ta.crossunder(close, out88) and barstate.isconfirmed
color trend_col = trend ? col_up : col_dn
if prices
if trend_up
label.new(bar_index, out88, "▲\n" + str.tostring(close, "#,###.####"), style=label.style_label_up, textcolor = trend_col, color = color_na)
if trend_dn
label.new(bar_index, out88, str.tostring(close, "#,###.####") + "\n▼", style=label.style_label_down, textcolor = trend_col, color = color_na)
//deviation_levels(trend)
///////////////DEVİNASYON VE 40 EMA İLE SAR TREND HESAAPLAMASIDIR//////////////////////
s13 = ta.sar(0, 0.1, 0.9)
lookBack13 = input(40)
multi13 = input.float(1, title = 'Multiplier', minval = 0.001, maxval = 2)
mean13 = ta.ema(s13, lookBack13)
stddev = multi13 * ta.stdev(s13, lookBack13)
b123 = mean13 + stddev
s232 = mean13 - stddev
meanp = plot(mean13, title = 'Sar Trend', color = color.new(color.yellow, 0))
//////////////////SAR İLE KANAL ARASI HESAPLAMASIDIR///////////////////////////
//@version=6
start1 = input(0.)
increment1 = input(0.1)
maximum1 = input(0.9)
xo = input(0.01)
xpr = input(0.01)
psar = 0.0 // PSAR
af = 0.0 // Acceleration Factor
trend_dir = 0 // Current direction of PSAR
ep = 0.0 // Extreme point
sar_long_to_short = trend_dir[1] == 1 and close <= psar[1] * (1 - xo) // PSAR switches from long to short and exceeds xo filter
sar_short_to_long = trend_dir[1] == -1 and close >= psar[1] * (1 + xo) // PSAR switches from short to long and exceeds xo filter
trend_change = barstate.isfirst[1] or sar_long_to_short or sar_short_to_long
// Calculate trend direction
trend_dir := 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_dir[1])
// Calculate Acceleration Factor
af := trend_change ? start1 : trend_dir == 1 and high > ep[1] or trend_dir == -1 and low < ep[1] ? math.min(maximum1, af[1] + increment1) : af[1]
// Calculate extreme point
ep := trend_change and trend_dir == 1 ? high : trend_change and trend_dir == -1 ? low : trend_dir == 1 ? math.max(ep[1], high * (1 + xpr)) : math.min(ep[1], low * (1 - xpr))
// Calculate PSAR
psar := barstate.isfirst[1] and close[1] > open[1] ? low[1] : barstate.isfirst[1] and close[1] <= open[1] ? high[1] : trend_change ? ep[1] : trend_dir == 1 ? psar[1] + af * (ep - psar[1]) : psar[1] - af * (psar[1] - ep)
plot(psar, style = plot.style_stepline, color = trend_dir == 1 ? color.yellow : color.blue,title = "KANAL",linewidth = 1)
////////////////////
start12 = input(0.)
increment12 = input(0.01)
maximum12 = input(0.9)
xo12 = input(0.01)
xpr12 = input(0.01)
psar12 = 0.0 // PSAR
af12 = 0.0 // Acceleration Factor
trend_dir12 = 0 // Current direction of PSAR
ep12 = 0.0 // Extreme point
sar_long_to_short12 = trend_dir12[1] == 1 and close <= psar12[1] * (1 - xo12) // PSAR switches from long to short and exceeds xo filter
sar_short_to_long12 = trend_dir12[1] == -1 and close >= psar12[1] * (1 + xo12) // PSAR switches from short to long and exceeds xo filter
trend_change12 = barstate.isfirst[1] or sar_long_to_short12 or sar_short_to_long12
// Calculate trend direction
trend_dir12 := barstate.isfirst[1] and close[1] > open[1] ? 1 : barstate.isfirst[1] and close[1] <= open[1] ? -1 : sar_long_to_short12 ? -1 : sar_short_to_long12 ? 1 : nz(trend_dir12[1])
// Calculate Acceleration Factor
af12 := trend_change12 ? start12 : trend_dir12 == 1 and high > ep12[1] or trend_dir12 == -1 and low < ep12[1] ? math.min(maximum12, af12[1] + increment12) : af12[1]
// Calculate extreme point
ep12 := trend_change12 and trend_dir12 == 1 ? high : trend_change12 and trend_dir12 == -1 ? low : trend_dir12 == 1 ? math.max(ep12[1], high * (1 + xpr12)) : math.min(ep12[1], low * (1 - xpr12))
// Calculate PSAR
psar12 := barstate.isfirst[1] and close[1] > open[1] ? low[1] : barstate.isfirst[1] and close[1] <= open[1] ? high[1] : trend_change12 ? ep12[1] : trend_dir12 == 1 ? psar12[1] + af12 * (ep12 - psar12[1]) : psar12[1] - af12 * (psar12[1] - ep12)
plot(psar12, style = plot.style_stepline, color = trend_dir12 == 1 ? color.yellow : color.blue,title = "KANAL",linewidth = 1)
///////////////////
-
PHP Code:
//@version=6
indicator('...', overlay = true, max_bars_back = 100)
renk = input(true)
//////başlangıç ve imza kısmıdır.////////////////
a1 = ta.sar(0., 0.043, 0.34)
a2 = ta.sar(0.1, 0., 0.34)
a3 = ta.sar(0.1, 0.01, 0.5)
a5 = ta.sar(0., 0.04, 0.4)
a6 = ta.sar(0., 0.03, 0.3)
a7 = ta.sar(0., 0.02, 0.2)
a8 = ta.sar(0., 0.01, 0.1)
plot(a1, title='6', style=plot.style_stepline, color=renk ? a1 > close ? color.rgb(247, 3, 3, 00) : color.rgb(24, 250, 4, 00) : color.silver, linewidth=1)
plot(a2, title='4', style=plot.style_stepline, color=renk ? a2 > close ? color.rgb(247, 3, 3, 00) : color.rgb(24, 250, 4, 00) : color.silver, linewidth=1)
plot(a3, title = '1', style = plot.style_stepline, color = renk ? a3 > close ? color.rgb(247, 3, 3, 00) : color.rgb(24, 250, 4, 00) : color.silver, linewidth = 1)
plot(a5, title = '2', style = plot.style_stepline, color = renk ? a5 > close ? color.rgb(247, 3, 3, 00) : color.rgb(24, 250, 4, 00) : color.silver, linewidth = 1)
plot(a6, title='5', style=plot.style_stepline, color=renk ? a6 > close ? color.rgb(247, 3, 3, 00) : color.rgb(24, 250, 4, 00) : color.silver, linewidth=1)
plot(a7, title = '3', style = plot.style_stepline, color = renk ? a7 > close ? color.rgb(247, 3, 3, 00) : color.rgb(24, 250, 4, 00) : color.silver, linewidth = 1)
plot(a8, title='0', style=plot.style_stepline, color=renk ? a8 > close ? color.rgb(247, 3, 3, 00) : color.rgb(24, 250, 4, 00) : color.silver, linewidth=1)
////////////////////
//@version=6
UV = ta.sar(0., 0.1, 0.9)
OV = ta.sar(0., 0.1, 0.1)
OV1 = ta.sar(0, 0.01, 0.9)
plot(UV, title = '1,Döngü', style = plot.style_circles, color = renk ? UV > close ? color.red : color.lime : color.silver, linewidth = 2)
plot(OV, title = '2.Döngü', style = plot.style_circles, color = renk ? OV > close ? color.red : color.lime : color.silver, linewidth = 2)
plot(OV1, title = '3.Döngü', style = plot.style_circles, color = renk ? OV1 > close ? color.red : color.lime : color.silver, linewidth = 2)