PHP Code:
//@version=5
indicator("*", overlay = true, max_boxes_count=100,max_lines_count = 100, max_labels_count = 100, format=format.price)
//////////////////////Parabolic Sar ile Trend Takip Sistemidir.//////////////////////////////////////////////////////////////////////////////////////////////////////////////
psar(start1, inc1, maximum1) =>
out1 = float(na)
isUpTrend1 = bool(na)
maxMin1 = float(na)
acc1 = float(na)
prev1 = float(na)
if bar_index >= 1
prev1 := out1[1]
if bar_index == 1
if close > close[1]
isUpTrend1 := true
maxMin1 := math.max(high, high[1])
prev1 := math.min(low, low[1])
prev1
else
isUpTrend1 := false
maxMin1 := math.min(low, low[1])
prev1 := math.max(high, high[1])
prev1
acc1 := start1
acc1
else
isUpTrend1 := isUpTrend1[1]
acc1 := acc1[1]
maxMin1 := maxMin1[1]
maxMin1
if isUpTrend1
if high > maxMin1
maxMin1 := high
acc1 := math.min(acc1 + inc1, maximum1)
acc1
else
if low < maxMin1
maxMin1 := low
acc1 := math.min(acc1 + inc1, maximum1)
acc1
if na(out1)
out1 := prev1 + acc1 * (maxMin1 - prev1)
out1
if isUpTrend1
if low <= out1
isUpTrend1 := false
out1 := maxMin1
maxMin1 := low
acc1 := start1
acc1
else
if high >= out1
isUpTrend1 := true
out1 := maxMin1
maxMin1 := high
acc1 := start1
acc1
if na(out1)
if isUpTrend1
out1 := math.min(out1, bar_index == 1 ? low[1] : math.min(low[1], low[2]))
out1
else
out1 := math.max(out1, bar_index == 1 ? high[1] : math.max(high[1], high[2]))
out1
[out1, acc1, maxMin1, isUpTrend1]
start1 = input(0)
increment1 = input(0.01)
maximum1 = input(0.1)
[p1, AF1, EP1, isUpTrend1] = psar(start1, increment1, maximum1)
newEP1 = EP1 != EP1[1]
epNew1 = newEP1 ? EP1 : na
plot(p1, 'Trend-1', style=plot.style_cross, color=isUpTrend1 ? color.rgb(76, 175, 79, 100) : color.rgb(255, 82, 82, 100), linewidth=2)
//plot(EP1, 'ONAY', style=plot.style_circles, color=isUpTrend1 ? color.green : color.red, linewidth=2)
plot(epNew1, 'Trend-2', style=plot.style_linebr, color=isUpTrend1 ? color.rgb(76, 175, 79, 100) : color.rgb(255, 82, 82, 100), linewidth=2)
///////////////Parabolic Sar ortalamaları ile onaylama sistemidir...///////////////////////////////////////////
//////////////////////////////////////////////Alarmlı Kısa-orta ve uzun reverse sistemidir............///////////////
requestSecurity(string _symbol, string _res, bool _repaints) =>
repIndex = _repaints ? 0 : barstate.isrealtime ? 1 : 0
resIndex = _repaints ? 0 : barstate.isrealtime ? 0 : 1
[h, l, t] = request.security(_symbol, _res, [high[repIndex], low[repIndex], time[repIndex]])
[h[resIndex], l[resIndex], t[resIndex]]
var GRP1 = "General Settings"
string res = input.timeframe(title = "Resolution", defval = "", group = GRP1)
bool ignoreInsideBars = input.bool(title = "Ignore Inside Bars?", defval = true, group = GRP1)
bool rep = input.bool(title = "Allow Repainting?", defval = false, group = GRP1)
var string GRP2 = "Short Term Settings"
bool showSTHighs = input.bool(title = "Show Short Term Highs?", defval = true, group = GRP2)
color stHighsColor = input.color(color.yellow, "Short Term Highs Color", group = GRP2)
bool showSTLows = input.bool(title = "Show Short Term Lows?", defval = true, group = GRP2)
color stLowsColor = input.color(color.yellow, "Short Term Lows Color", group = GRP2)
var string GRP3 = "Mid Term Settings"
bool showMTHighs = input.bool(title = "Show Mid Term Highs?", defval = true, group = GRP3)
color mtHighsColor = input.color(color.aqua, "Mid Term Highs Color", group = GRP3)
bool showMTLows = input.bool(title = "Show Mid Term Lows?", defval = true, group = GRP3)
color mtLowsColor = input.color(color.aqua, "Mid Term Lows Color", group = GRP3)
var string GRP4 = "Long Term Settings"
bool showLTHighs = input.bool(title = "Show Long Term Highs?", defval = true, group = GRP4)
color ltHighsColor = input.color(color.white, "Long Term Highs Color", group = GRP4)
bool showLTLows = input.bool(title = "Show Long Term Lows?", defval = true, group = GRP4)
color ltLowsColor = input.color(color.white, "Long Term Lows Color", group = GRP4)
[h, l, t] = requestSecurity(syminfo.ticker, res, rep)
type ReversalPoint
int bar_time
float price
var lowShortRevPoints = array.new<ReversalPoint>()
var highShortRevPoints = array.new<ReversalPoint>()
var lowMediumRevPoints = array.new<ReversalPoint>()
var highMediumRevPoints = array.new<ReversalPoint>()
isReversalPoint(bool isLow, float firstSrc, float midSrc, float lastSrc, bool isInsideBar) =>
bool isReversalPoint = false
if not (isInsideBar and ignoreInsideBars)
if isLow
isReversalPoint := lastSrc > midSrc and midSrc < firstSrc
else
isReversalPoint := lastSrc < midSrc and midSrc > firstSrc
isReversalPoint
plotReversalPoint(bool isLow, ReversalPoint revPoint, color revPointColor, string labelSize, bool createLabel) =>
if createLabel
label.new(revPoint.bar_time, revPoint.price, isLow ? '▲' : '▼',
xloc = xloc.bar_time, yloc = isLow ? yloc.belowbar : yloc.abovebar, size = labelSize, color = color(na),
textcolor = revPointColor, style = label.style_text_outline)
getReversalPoints(bool isLow, ReversalPoint[] sourceArray, color plotColor, ReversalPoint newRp, string labelSize,
bool createLabel, bool isInsideBar) =>
ReversalPoint result = na
sourceArray.push(newRp)
plotReversalPoint(isLow, newRp, plotColor, labelSize, createLabel)
int arraySize = sourceArray.size()
float midArrayValue = arraySize >= 2 ? sourceArray.get(arraySize - 2).price : na
float firstArrayValue = arraySize >= 3 ? sourceArray.get(arraySize - 3).price : na
if not na(firstArrayValue) and not na(midArrayValue) and isReversalPoint(isLow, firstArrayValue, midArrayValue, newRp.price, isInsideBar)
result := sourceArray.get(arraySize - 2)
result
bool isInsideBar = h < nz(h[1]) and l > nz(l[1])
ReversalPoint shortTermLow = isReversalPoint(true, nz(l[2]), nz(l[1]), l, isInsideBar) ? ReversalPoint.new(nz(t[1]), nz(l[1])) : na
ReversalPoint midTermLow = na
ReversalPoint longTermLow = na
if not na(shortTermLow)
midTermLow := getReversalPoints(true, lowShortRevPoints, stLowsColor, shortTermLow, size.tiny, showSTLows, isInsideBar)
if not na(midTermLow)
longTermLow := getReversalPoints(true, lowMediumRevPoints, mtLowsColor, midTermLow, size.small, showMTLows, isInsideBar)
if not na(longTermLow)
plotReversalPoint(true, longTermLow, ltLowsColor, size.normal, showLTLows)
ReversalPoint shortTermHigh = isReversalPoint(false, nz(h[2]), nz(h[1]), h, isInsideBar) ? ReversalPoint.new(nz(t[1]), nz(h[1])) : na
ReversalPoint midTermHigh = na
ReversalPoint longTermHigh = na
if not na(shortTermHigh)
midTermHigh := getReversalPoints(false, highShortRevPoints, stHighsColor, shortTermHigh, size.tiny, showSTHighs, isInsideBar)
if not na(midTermHigh)
longTermHigh := getReversalPoints(false, highMediumRevPoints, mtHighsColor, midTermHigh, size.small, showMTHighs, isInsideBar)
if not na(longTermHigh)
plotReversalPoint(false, longTermHigh, ltHighsColor, size.normal, showLTHighs)
alertcondition(not na(midTermLow) or not na(longTermLow), "Strong Buy Signal", "Strong Bullish Change Detected")
alertcondition(not na(midTermHigh) or not na(longTermHigh), "Strong Sell Signal", "Strong Bearish Change Detected")
alertcondition(not na(shortTermLow), "Buy Signal", "Bullish Change Detected")
alertcondition(not na(shortTermHigh), "Sell Signal", "Bearish Change Detected")
alertcondition(not na(shortTermLow) or not na(midTermLow) or not na(longTermLow), "All Buy Signals", "Any Bullish Change Detected")
alertcondition(not na(shortTermHigh) or not na(midTermHigh) or not na(longTermHigh), "All Sell Signals", "Any Bearish Change Detected")
///////////////////////////////////Kırılım çizgileri.....////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
ma(sourcexz, lengthxz, type) =>
switch type
"SMA" => ta.sma(sourcexz, lengthxz)
"EMA" => ta.ema(sourcexz, lengthxz)
"SMMA (RMA)" => ta.rma(sourcexz, lengthxz)
"WMA" => ta.wma(sourcexz, lengthxz)
"VWMA" => ta.vwma(sourcexz, lengthxz)
factorxz= input(0.004)
lengthxz = input(20)
maTypeInput = input.string("EMA", title="MA Type", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="MA Settings")
logHigh = math.log10(high)
logLow = math.log10(low)
logAvg = math.log10((high + low) / 2)
logUpperband = ma(logHigh * (1 + 2 * (((logHigh - logLow) / (logAvg)) * 1000) * factorxz), lengthxz, maTypeInput)
logLowerband = ma(logLow * (1 - 2 * (((logHigh - logLow) / (logAvg)) * 1000) * factorxz), lengthxz, maTypeInput)
logCentral = (logUpperband + logLowerband) / 2
Upperbandxz = math.pow(10, logUpperband)
Centralxz = math.pow(10, logCentral)
Lowerbandxz = math.pow(10, logLowerband)
//plot(Upperbandxz, title="Olası-Tepe", color=color.rgb(255, 82, 82, 100))
//plot(Centralxz,title="Olası-Ort", color=color.rgb(255, 153, 0, 100))
//plot(Lowerbandxz,title="Olası-Dip", color=color.rgb(76, 175, 79, 100))
draw_prediction = input.bool(true, title="Draw Prediction Lines")
slope_length = input(20, title = "Slope Length")
customLogarithmicRegression(_data, _color) =>
logData = math.log10(_data)
linreg = ta.linreg(logData, slope_length, 0)
linreg_p = ta.linreg(logData, slope_length, 0 + 1)
xxz = bar_index
slope = linreg - linreg_p
intercept = linreg - xxz * slope
deviationSum = 0.0
for i = 0 to slope_length - 1 by 1
deviationSum += math.pow(logData[i] - (slope * (xxz - i) + intercept), 2)
deviation = math.sqrt(deviationSum / slope_length)
x1 = xxz - slope_length
x2 = xxz
y1 = slope * (xxz - slope_length) + intercept
y2 = linreg
var line b = na
updating = timestamp("20 Jul 2050 00:00 +0300") >= time
displacement = false
if draw_prediction
if updating
b := line.new(x1, math.pow(10, y1), x2, math.pow(10, y2), xloc.bar_index, extend.right, _color, style=line.style_dotted, width=2)
if not displacement
line.delete(b[1])
customLogarithmicRegression(Upperbandxz, color.red)
customLogarithmicRegression(Centralxz, color.orange)
customLogarithmicRegression(Lowerbandxz, color.green)
/////////////////////////////////////////////////////////////
// INPUTS //
//
startq = input(0)
incrementq = input(0.01)
maximumq = input(0.1)
s1q = ta.sar(startq, incrementq, maximumq)
pcq = close < s1q ? color.red : color.green
//plot(s1q, style=plot.style_line, color=pcq)
//
lookBackq = input(20)
//
multiq = input.float(2, title='Multiplier', minval=0.001, maxval=2)
meanq = ta.ema(s1q, lookBackq)
stddevq = multiq * ta.stdev(s1q, lookBackq)
bq = meanq + stddevq
s2q = meanq - stddevq
low1q = ta.crossover(s1q, s2q)
high1q = ta.crossunder(s1q, bq)
plotshape(low1q, title='low', text='DİP', color=color.new(color.green, 0), style=shape.labelup, location=location.belowbar, size=size.tiny, textcolor=color.new(color.white, 0)) //plot for buy icon
plotshape(high1q, title='high', text='TEPE', color=color.new(color.red, 0), style=shape.labeldown, location=location.abovebar, size=size.tiny, textcolor=color.new(color.white, 0)) //plot for sell icon
//////////////////
lenxc = input(5)
lenxc20 = input(20)
lenxc50 = input(50)
z(close, lenxc) =>
hxc = 0.0
dxc = 0.0
for i = 0 to lenxc - 1 by 1
kxc = (lenxc - i) * lenxc
hxc += kxc
dxc += close[i] * kxc
dxc
dxc / hxc
cxc = z(close, math.floor(math.sqrt(lenxc)))
//
z20(close, lenxc20) =>
hcx20 = 0.0
dxc20 = 0.0
for i = 0 to lenxc20 - 1 by 1
kxc20 = (lenxc20 - i) * lenxc20
hcx20 += kxc20
dxc20 += close[i] * kxc20
dxc20
dxc20 / hcx20
cxc20 = z20(close, math.floor(math.sqrt(lenxc20)))
//
z50(close, lenxc50) =>
hxc50 = 0.0
dxc50 = 0.0
for i = 0 to lenxc50 - 1 by 1
kxc50 = (lenxc50 - i) * lenxc50
hxc50 += kxc50
dxc50 += close[i] * kxc50
dxc50
dxc50 / hxc50
cxc50 = z50(close, math.floor(math.sqrt(lenxc50)))
//
//
startsx = 0
incrementsx = 0.01
maximumsx = 0.1
ssx = ta.sar(startsx, incrementsx, maximumsx)
s1sx = z(ssx, lenxc)
pcsx = close < s1sx ? color.red : color.green
plot(s1sx, title="5",style=plot.style_cross, color=pcsx, linewidth=1)
startsx20 = 0
incrementsx20 = 0.01
maximumsx20 = 0.1
ssx20 = ta.sar(startsx20, incrementsx20, maximumsx20)
s1sx20 = z20(ssx20, lenxc20)
pcsx20 = close < s1sx20 ? color.red : color.green
plot(s1sx20, title="20",style=plot.style_cross, color=pcsx20, linewidth=1)
startsx50 = 0
incrementsx50 = 0.01
maximumsx50 = 0.1
ssx50 = ta.sar(startsx50, incrementsx50, maximumsx50)
s1sx50 = z50(ssx50, lenxc50)
pcsx50 = close < s1sx50 ? color.red : color.green
plot(s1sx50, title="50",style=plot.style_cross, color=pcsx50, linewidth=1)
//////////////////////////
Yer İmleri