zig zag temelli....
pivot mantığıyla...olası destek ve dirençleri çizen kod.....
PHP Code:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © HeWhoMustNotBeNamed
// ░▒
// ▒▒▒ ▒▒
// ▒▒▒▒▒ ▒▒
// ▒▒▒▒▒▒▒░ ▒ ▒▒
// ▒▒▒▒▒▒ ▒ ▒▒
// ▓▒▒▒ ▒ ▒▒▒▒▒▒▒▒▒▒▒
// ▒▒▒▒▒▒▒▒▒▒▒ ▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ▒ ▒ ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░▒▒▒▒▒▒▒▒
// ▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒
// ▒▒▒▒▒ ▒▒▒▒▒▒▒
// ▒▒▒▒▒▒▒▒▒
// ▒▒▒▒▒ ▒▒▒▒▒
// ░▒▒▒▒ ▒▒▒▒▓ ████████╗██████╗ ███████╗███╗ ██╗██████╗ ██████╗ ███████╗ ██████╗ ██████╗ ██████╗ ███████╗
// ▓▒▒▒▒ ▒▒▒▒ ╚══██╔══╝██╔══██╗██╔════╝████╗ ██║██╔══██╗██╔═══██╗██╔════╝██╔════╝██╔═══██╗██╔══██╗██╔════╝
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ██║ ██████╔╝█████╗ ██╔██╗ ██║██║ ██║██║ ██║███████╗██║ ██║ ██║██████╔╝█████╗
// ▒▒▒▒▒ ▒▒▒▒▒ ██║ ██╔══██╗██╔══╝ ██║╚██╗██║██║ ██║██║ ██║╚════██║██║ ██║ ██║██╔═══╝ ██╔══╝
// ▒▒▒▒▒ ▒▒▒▒▒ ██║ ██║ ██║███████╗██║ ╚████║██████╔╝╚██████╔╝███████║╚██████╗╚██████╔╝██║ ███████╗
// ▒▒ ▒
//@version=5
indicator("Next Pivot Projection [Trendoscope]", "NPP[Trendoscope]", overlay=true, max_lines_count = 500, max_labels_count = 500)
import HeWhoMustNotBeNamed/mZigzag/12 as zg
import HeWhoMustNotBeNamed/enhanced_ta/14 as eta
import HeWhoMustNotBeNamed/arrays/1 as pa
length = input.int(8, 'Length', group='Zigzag', display = display.none)
oscillatorType = input.string("rsi", title="Oscillator", inline="osc", options=["cci", "cmo", "cog", "mfi", "roc", "rsi"],
group='Oscillator', display = display.none)
oscLength = input.int(14, title="", inline="osc", group='Oscillator', display = display.none)
supertrendLength = input.int(5, 'History', inline='st', group='Supertrend', display = display.none)
drawSupertrend = input.bool(false, "Draw Zigzag Supertrend", inline='st2', group='Supertrend', display = display.none)
showTable = input.bool(false, 'Detailed Stats', inline='txt', group = 'Stats and Display', display = display.none)
txtSize = input.string(size.tiny, '', [size.tiny, size.small, size.normal, size.large, size.huge],
inline='txt', group = 'Stats and Display', display = display.none)
txtColor = input.color(color.white, '', inline='txt', group = 'Stats and Display', display = display.none)
showPivotLines = input.bool(true, 'Pivot Lines', inline='pli', group = 'Stats and Display', display = display.none)
showPivotLabel = input.bool(false, 'Pivot Label', inline='pla', group = 'Stats and Display', display = display.none)
fillAreas = input.bool(true, 'Fill Bullish/Bearish Sentiments', inline='fil', group = 'Stats and Display', display = display.none)
increment(mtx, row, col, val=1)=>matrix.set(mtx, row, col, matrix.get(mtx, row, col)+val)
gettrendindex(int price, int osc, int trend)=>
trendFactor = trend > 0 ? 0 : 1
priceFactor = math.abs(price) > 1? 1 : 0
oscFactor = math.abs(osc) > 1? 1 : 0
trendFactor*4 + priceFactor*2 + oscFactor
getSentimentDetails(pDir, oDir, sDir) =>
sentiment = pDir == oDir ? sDir == pDir or sDir * 2 == -pDir ? -sDir : sDir * 4 : sDir == pDir or sDir == -oDir ? 0 : (math.abs(oDir) > math.abs(pDir) ? sDir : -sDir) * (sDir == oDir ? 2 : 3)
sentimentSymbol = sentiment == 4 ? '⬆' : sentiment == -4 ? '⬇' : sentiment == 3 ? '↗' : sentiment == -3 ? '↘' : sentiment == 2 ? '⤴' : sentiment == -2 ? '⤵' : sentiment == 1 ? '⤒' : sentiment == -1 ? '⤓' : '▣'
sentimentColor = sentiment == 4 ? color.green : sentiment == -4 ? color.red : sentiment == 3 ? color.lime : sentiment == -3 ? color.orange : sentiment == 2 ? color.rgb(202, 224, 13, 0) : sentiment == -2 ? color.rgb(250, 128, 114, 0) : color.silver
sentimentLabel = math.abs(sentiment) == 4 ? 'C' : math.abs(sentiment) == 3 ? 'H' : math.abs(sentiment) == 2 ? 'D' : 'I'
[sentimentSymbol, sentimentLabel, sentimentColor]
getStatus(int trendIndex, int pivotDir)=>
trendFactor = int(trendIndex/4)
remainder = trendIndex % 4
priceFactor = int(remainder/2)+1
oscFactor = (remainder % 2)+1
trendChar = (trendFactor == 0)? 'U' : 'D'
priceChar = pivotDir > 0? (priceFactor == 2? 'HH' : 'LH') : (priceFactor == 2? 'LL' : 'HL')
oscChar = pivotDir > 0? (oscFactor == 2? 'HH' : 'LH') : (oscFactor == 2? 'LL' : 'HL')
trendChar + ' - ' + priceChar + '/'+oscChar
draw_zg_line(idx1, idx2, zigzaglines, zigzaglabels, valueMatrix, directionMatrix, ratioMatrix, divergenceMatrix, doubleDivergenceMatrix,
barArray, trendArray, lineColor, lineWidth, lineStyle) =>
if matrix.rows(valueMatrix) > 2
idxLen1 = matrix.rows(valueMatrix)-idx1
idxLen2 = matrix.rows(valueMatrix)-idx2
lastValues = matrix.row(valueMatrix, idxLen1)
llastValues = matrix.row(valueMatrix, idxLen2)
lastDirections = matrix.row(directionMatrix, idxLen1)
lastRatios = matrix.row(ratioMatrix, idxLen1)
lastDivergence = matrix.row(divergenceMatrix, idxLen1)
lastDoubleDivergence = matrix.row(doubleDivergenceMatrix, idxLen1)
y1 = array.get(lastValues, 0)
y2 = array.get(llastValues, 0)
x1 = array.get(barArray, idxLen1)
x2 = array.get(barArray, idxLen2)
zline = line.new(x1=x1, y1=y1, x2=x2, y2=y2, color=lineColor, width=lineWidth, style=lineStyle)
currentDir = y1 > y2? 1 : -1
priceDir = array.get(lastDirections, 0)
oscDir = array.get(lastDirections, 1)
trendDir = array.get(trendArray, idxLen1)
trendIndex = gettrendindex(priceDir, oscDir, trendDir)
trendLabel = getStatus(trendIndex, currentDir)
[sentimentSymbol, sentimentLabel, sentimentColor] = getSentimentDetails(priceDir, oscDir, trendDir)
labelStyle = currentDir > 0? label.style_label_down : label.style_label_up
zlabel = showPivotLabel ? label.new(x=x1, y=y1, yloc=yloc.price, color=sentimentColor, style=labelStyle, text=sentimentSymbol + ' ' + trendLabel,
textcolor=color.black, size = size.small, tooltip=sentimentLabel) : na
if array.size(zigzaglines) > 0
lastLine = array.get(zigzaglines, array.size(zigzaglines)-1)
if line.get_x2(lastLine) == x2 and line.get_x1(lastLine) <= x1
pa.pop(zigzaglines)
pa.pop(zigzaglabels)
pa.push(zigzaglines, zline, 500)
pa.push(zigzaglabels, zlabel, 500)
draw(matrix<float> valueMatrix, matrix<int> directionMatrix, matrix<float> ratioMatrix, matrix<int> divergenceMatrix, matrix<int> doubleDivergenceMatrix, array<int> barArray, array<int> trendArray,
bool newZG, bool doubleZG, color lineColor = color.blue, int lineWidth = 1, string lineStyle = line.style_solid)=>
var zigzaglines = array.new_line(0)
var zigzaglabels = array.new_label(0)
if(newZG)
if doubleZG
draw_zg_line(2, 3, zigzaglines, zigzaglabels, valueMatrix, directionMatrix, ratioMatrix, divergenceMatrix, doubleDivergenceMatrix, barArray, trendArray,
lineColor, lineWidth, lineStyle)
if matrix.rows(valueMatrix) >= 2
draw_zg_line(1, 2, zigzaglines, zigzaglabels, valueMatrix, directionMatrix, ratioMatrix, divergenceMatrix, doubleDivergenceMatrix, barArray, trendArray,
lineColor, lineWidth, lineStyle)
[valueMatrix, directionMatrix, ratioMatrix, divergenceMatrix, doubleDivergenceMatrix, barArray, zigzaglines, zigzaglabels]
indicatorHigh = array.new_float()
indicatorLow = array.new_float()
indicatorLabels = array.new_string()
[oscHigh, _, _] = eta.oscillator(oscillatorType, oscLength, oscLength, oscLength, high)
[oscLow, _, _] = eta.oscillator(oscillatorType, oscLength, oscLength, oscLength, low)
array.push(indicatorHigh, math.round(oscHigh,2))
array.push(indicatorLow, math.round(oscLow,2))
array.push(indicatorLabels, oscillatorType+str.tostring(oscLength))
[valueMatrix, directionMatrix, ratioMatrix, divergenceMatrix, doubleDivergenceMatrix, barArray, trendArray, supertrendDir, supertrend, newZG, doubleZG] =
zg.calculate(length, array.from(high, low), indicatorHigh, indicatorLow, supertrendLength = supertrendLength)
nextDirection = matrix.rows(directionMatrix) > 0? matrix.row(directionMatrix, matrix.rows(directionMatrix)-1) : array.new_int()
lastDirection = matrix.rows(directionMatrix) > 1? matrix.row(directionMatrix, matrix.rows(directionMatrix)-2) : array.new_int()
llastDirection = matrix.rows(directionMatrix) > 2? matrix.row(directionMatrix, matrix.rows(directionMatrix)-3) : array.new_int()
lllastDirection = matrix.rows(directionMatrix) > 3? matrix.row(directionMatrix, matrix.rows(directionMatrix)-4) : array.new_int()
var pivotHighStats = matrix.new<int>(64, 3, 0)
var pivotLowStats = matrix.new<int>(64, 3, 0)
var pivotHighRatios = matrix.new<float>(64, 3, 0)
var pivotLowRatios = matrix.new<float>(64, 3, 0)
var pivotHighBars = matrix.new<float>(64, 3, 0)
var pivotLowBars = matrix.new<float>(64, 3, 0)
currentTotalTrendIndex = 0
nextTotalTrendIndex = 0
currentDir = matrix.rows(directionMatrix) > 0? matrix.get(directionMatrix, matrix.rows(directionMatrix)-1, 0) : 0
currentPDir = lastDirection.size() > 0 ? lastDirection.first() : na
changePriceDirection = ta.change(math.sign(currentPDir))
if(array.size(lllastDirection) > 0)
priceDirection = array.get(lastDirection, 0)
priceRatio = matrix.get(ratioMatrix, matrix.rows(ratioMatrix)-2, 0)
numberOfBars = array.get(barArray, array.size(barArray)-2) - array.get(barArray, array.size(barArray)-3)
currentPriceDirection = array.get(lastDirection, 0)
currentOscDirection = array.get(lastDirection, 1)
currentTrend = array.get(trendArray, array.size(trendArray)-2)
nextPriceDirection = array.get(nextDirection, 0)
nextOscDirection = array.get(nextDirection, 1)
nextTrend = array.get(trendArray, array.size(trendArray)-1)
lastPriceDirection = array.get(llastDirection, 0)
lastOscDirection = array.get(llastDirection, 1)
lastTrend = array.get(trendArray, array.size(trendArray)-3)
llastPriceDirection = array.get(lllastDirection, 0)
llastOscDirection = array.get(lllastDirection, 1)
llastTrend = array.get(trendArray, array.size(trendArray)-4)
colLast = math.abs(priceDirection) %2
nextTrendIndex = gettrendindex(nextPriceDirection, nextOscDirection, nextTrend)
currentTrendIndex = gettrendindex(currentPriceDirection, currentOscDirection, currentTrend)
lastTrendIndex = gettrendindex(lastPriceDirection, lastOscDirection, lastTrend)
llastTrendIndex = gettrendindex(llastPriceDirection, llastOscDirection, llastTrend)
totalIndex = lastTrendIndex*8 + llastTrendIndex
currentTotalTrendIndex := currentTrendIndex*8 + lastTrendIndex
nextTotalTrendIndex := nextTrendIndex*8 + currentTrendIndex
matrixToSet = math.sign(priceDirection) > 0? pivotHighStats : pivotLowStats
ratioMatrixToSet = math.sign(priceDirection) > 0? pivotHighRatios : pivotLowRatios
barMatrixToSet = math.sign(priceDirection) > 0? pivotHighBars : pivotLowBars
if(not na(currentPDir) and changePriceDirection != 0)
increment(matrixToSet, totalIndex, colLast)
increment(ratioMatrixToSet, totalIndex, colLast, priceRatio)
increment(barMatrixToSet, totalIndex, colLast, numberOfBars)
increment(matrixToSet, totalIndex, 2)
increment(ratioMatrixToSet, totalIndex, 2, priceRatio)
increment(barMatrixToSet, totalIndex, 2, numberOfBars)
var float hhValue = na
var float lhValue = na
var float llValue = na
var float hlValue = na
var float hhProbability = na
var float llProbability = na
var float htRatio = na
var float ltRatio = na
if(array.size(barArray) > 10)
currentBar = array.get(barArray, array.size(barArray)-1)
lastBar = array.get(barArray, array.size(barArray)-2)
currentPrice = matrix.get(valueMatrix, matrix.rows(valueMatrix)-1, 0)
lastPrice = matrix.get(valueMatrix, matrix.rows(valueMatrix)-2, 0)
llastPrice = matrix.get(valueMatrix, matrix.rows(valueMatrix)-3, 0)
startRow = 2
var statsTable = showTable ? table.new(position=position.top_right, columns=10, rows=64+startRow, border_color = color.black, border_width = 2) : na
phSortIndices = array.sort_indices(matrix.col(pivotHighStats, 2), order.descending)
phColStart = currentDir > 0 ? 0 : 5
if(showTable)
table.clear(statsTable, 0, 0, 9, 64+startRow-1)
table.cell(statsTable, phColStart, 0, 'Pivot High Projection', text_color = txtColor, text_size = txtSize, bgcolor = color.maroon)
table.cell(statsTable, phColStart, 1, 'Last Two Pivots', text_color = txtColor, text_size = txtSize, bgcolor = color.maroon)
table.cell(statsTable, phColStart+2, 1, 'HH', text_color = txtColor, text_size = txtSize, bgcolor = color.maroon)
table.cell(statsTable, phColStart+3, 1, 'LH', text_color = txtColor, text_size = txtSize, bgcolor = color.maroon)
table.cell(statsTable, phColStart+4, 1, 'T', text_color = txtColor, text_size = txtSize, bgcolor = color.maroon)
table.merge_cells(statsTable, phColStart, 0, phColStart+4, 0)
table.merge_cells(statsTable, phColStart, 1, phColStart+1, 1)
hlr = startRow
for i=0 to 63
si = array.get(phSortIndices, i)
lastTrendIndex = int(si/8)
llastTrendIndex = si%8
lastPivotStatus = getStatus(lastTrendIndex, -1)
llastPivotStatus = getStatus(llastTrendIndex, 1)
hhStats = matrix.get(pivotHighStats, si, 0)
lhStats = matrix.get(pivotHighStats, si, 1)
tStats = matrix.get(pivotHighStats, si, 2)
hhRatio = math.round(matrix.get(pivotHighRatios, si, 0)/hhStats, 3)
lhRatio = math.round(matrix.get(pivotHighRatios, si, 1)/lhStats, 3)
tRatio = math.round(matrix.get(pivotHighRatios, si, 2)/tStats, 3)
hhBars = math.round(matrix.get(pivotHighBars, si, 0)/hhStats)
lhBars = math.round(matrix.get(pivotHighBars, si, 1)/lhStats)
tBars = math.round(matrix.get(pivotHighBars, si, 2)/tStats)
highlight = math.sign(currentDir) < 0 ? nextTotalTrendIndex == si : currentTotalTrendIndex == si
hhTooltip = 'Average Ratio - '+str.tostring(hhRatio)+'\n'+'Average Bars - '+str.tostring(hhBars)
lhTooltip = 'Average Ratio - '+str.tostring(lhRatio)+'\n'+'Average Bars - '+str.tostring(lhBars)
tTooltip = 'Average Ratio - '+str.tostring(tRatio)+'\n'+'Average Bars - '+str.tostring(tBars)
if(highlight)
var line hhLine = na
var line lhLine = na
var line tLine = na
var label hhLabel = na
var label lhLabel = na
var label tLabel = na
line.delete(hhLine)
line.delete(lhLine)
line.delete(tLine)
label.delete(hhLabel)
label.delete(lhLabel)
label.delete(tLabel)
x1 = math.sign(currentDir) < 0 ? currentBar : lastBar
hhX2 = x1 + hhBars
lhX2 = x1 + lhBars
tX2 = x1 + tBars
y1 = math.sign(currentDir) < 0 ? currentPrice : lastPrice
prev = math.sign(currentDir) < 0 ? lastPrice : llastPrice
hhY2 = math.round_to_mintick(y1 + math.abs(y1-prev)*hhRatio)
lhY2 = math.round_to_mintick(y1 + math.abs(y1-prev)*lhRatio)
tY2 = math.round_to_mintick(y1 + math.abs(y1-prev)*tRatio)
hhLine := line.new(x1, y1, hhX2, hhY2, xloc=xloc.bar_index, color=color.green, style=line.style_arrow_right)
lhLine := line.new(x1, y1, lhX2, lhY2, xloc=xloc.bar_index, color=color.lime, style=line.style_arrow_right)
tLine := line.new(x1, y1, tX2, tY2, xloc=xloc.bar_index, color=color.yellow, style=line.style_arrow_right)
hhPercent = str.tostring(hhStats*100/tStats, format.percent)
lhPercent = str.tostring(lhStats*100/tStats, format.percent)
hhText = 'Number of Historical References :'+str.tostring(hhStats)+'/'+str.tostring(tStats)+
'\nProbability of Higher High :'+hhPercent+
'\nAverage Higher High Ratio :'+str.tostring(hhRatio) +
'\nAverage Higher High Bars :'+str.tostring(hhBars)
lhText = 'Number of Historical References :'+str.tostring(lhStats)+'/'+str.tostring(tStats)+
'\nProbability of Lower High :'+lhPercent+
'\nAverage Lower High Ratio :'+str.tostring(lhRatio) +
'\nAverage Lower High Bars :'+str.tostring(lhBars)
tText = 'Number of Historical References :'+str.tostring(tStats)+
'\nAverage Fib Ratio :'+str.tostring(tRatio)+
'\nAverage Bars :'+str.tostring(tBars)
hhLabel := label.new(hhX2, hhY2, str.tostring(hhY2)+ ' - ' +hhPercent, style=label.style_label_lower_left, color=color.new(color.green, 70), textcolor = color.white, size=size.small, tooltip=hhText)
lhLabel := label.new(lhX2, lhY2, str.tostring(lhY2)+ ' - ' +lhPercent, style=label.style_label_upper_left, color=color.new(color.lime, 70), textcolor = color.white, size=size.small, tooltip=lhText)
tLabel := label.new(tX2, tY2, str.tostring(tY2)+ '@'+str.tostring(tRatio), style=label.style_label_left, color=color.new(color.yellow, 70), textcolor = color.white, size=size.small, tooltip=tText)
hhValue := hhY2
lhValue := lhY2
hhProbability := hhStats*100/tStats
htRatio := tRatio
if(hhStats != 0 and lhStats != 0) and showTable
table.cell(statsTable, phColStart, hlr, llastPivotStatus, text_color = txtColor, text_size = txtSize, bgcolor = color.new(color.lime, 60))
table.cell(statsTable, phColStart+1, hlr, lastPivotStatus, text_color = txtColor, text_size = txtSize, bgcolor = color.new(color.orange, 60))
table.cell(statsTable, phColStart+2, hlr, str.tostring(hhStats)+' - '+str.tostring(hhRatio), text_color = txtColor, text_size = txtSize, bgcolor = color.new(color.green, highlight ? 50 : 90), tooltip = hhTooltip)
table.cell(statsTable, phColStart+3, hlr, str.tostring(lhStats)+' - '+str.tostring(lhRatio), text_color = txtColor, text_size = txtSize, bgcolor = color.new(color.red, highlight? 50 : 90), tooltip = lhTooltip)
table.cell(statsTable, phColStart+4, hlr, str.tostring(tStats)+' - '+str.tostring(tRatio), text_color = txtColor, text_size = txtSize, bgcolor = color.from_gradient(hhStats/tStats, 0, 1, color.red, color.green), tooltip = tTooltip)
hlr+=1
plColStart = currentDir < 0 ? 0 : 5
if(showTable)
table.cell(statsTable, plColStart, 0, 'Pivot Low Projection', text_color = txtColor, text_size = txtSize, bgcolor = color.maroon)
table.cell(statsTable, plColStart, 1, 'Last Two Pivots', text_color = txtColor, text_size = txtSize, bgcolor = color.maroon)
table.cell(statsTable, plColStart+2, 1, 'LL', text_color = txtColor, text_size = txtSize, bgcolor = color.maroon)
table.cell(statsTable, plColStart+3, 1, 'HL', text_color = txtColor, text_size = txtSize, bgcolor = color.maroon)
table.cell(statsTable, plColStart+4, 1, 'T', text_color = txtColor, text_size = txtSize, bgcolor = color.maroon)
table.merge_cells(statsTable, plColStart, 0, plColStart+4, 0)
table.merge_cells(statsTable, plColStart, 1, plColStart+1, 1)
plSortIndices = array.sort_indices(matrix.col(pivotLowStats, 2), order.descending)
llr = startRow
for i=0 to 63
si = array.get(plSortIndices, i)
lastTrendIndex = int(si/8)
llastTrendIndex = si%8
lastPivotStatus = getStatus(lastTrendIndex, 1)
llastPivotStatus = getStatus(llastTrendIndex, -1)
llStats = matrix.get(pivotLowStats, si, 0)
hlStats = matrix.get(pivotLowStats, si, 1)
tStats = matrix.get(pivotLowStats, si, 2)
llRatio = math.round(matrix.get(pivotLowRatios, si, 0)/llStats, 3)
hlRatio = math.round(matrix.get(pivotLowRatios, si, 1)/hlStats, 3)
tRatio = math.round(matrix.get(pivotLowRatios, si, 2)/tStats, 3)
llBars = math.round(matrix.get(pivotLowBars, si, 0)/llStats)
hlBars = math.round(matrix.get(pivotLowBars, si, 1)/hlStats)
tBars = math.round(matrix.get(pivotLowBars, si, 2)/tStats)
highlight = math.sign(currentDir) > 0 ? nextTotalTrendIndex== si : currentTotalTrendIndex == si
llTooltip = 'Average Ratio - '+str.tostring(llRatio)+'\n'+'Average Bars - '+str.tostring(llBars)
hlTooltip = 'Average Ratio - '+str.tostring(hlRatio)+'\n'+'Average Bars - '+str.tostring(hlBars)
tTooltip = 'Average Ratio - '+str.tostring(tRatio)+'\n'+'Average Bars - '+str.tostring(tBars)
if(highlight)
var line llLine = na
var line hlLine = na
var line tLine = na
var label llLabel = na
var label hlLabel = na
var label tLabel = na
line.delete(llLine)
line.delete(hlLine)
line.delete(tLine)
label.delete(llLabel)
label.delete(hlLabel)
label.delete(tLabel)
x1 = math.sign(currentDir) > 0 ? currentBar : lastBar
llX2 = x1 + llBars
hlX2 = x1 + hlBars
tX2 = x1 + tBars
y1 = math.sign(currentDir) > 0 ? currentPrice : lastPrice
prev = math.sign(currentDir) > 0 ? lastPrice : llastPrice
llY2 = math.round_to_mintick(y1 - math.abs(y1-prev)*llRatio)
hlY2 = math.round_to_mintick(y1 - math.abs(y1-prev)*hlRatio)
tY2 = math.round_to_mintick(y1 - math.abs(y1-prev)*tRatio)
llLine := line.new(x1, y1, llX2, llY2, xloc=xloc.bar_index, color=color.red, style=line.style_arrow_right)
hlLine := line.new(x1, y1, hlX2, hlY2, xloc=xloc.bar_index, color=color.orange, style=line.style_arrow_right)
tLine := line.new(x1, y1, tX2, tY2, xloc=xloc.bar_index, color=color.yellow, style=line.style_arrow_right)
llPercent = str.tostring(llStats*100/tStats, format.percent)
hlPercent = str.tostring(hlStats*100/tStats, format.percent)
llText = 'Number of Historical References :'+str.tostring(llStats)+'/'+str.tostring(tStats)+
'\nProbability of Lower Low :'+llPercent+
'\nAverage Lower Low Ratio :'+str.tostring(llRatio) +
'\nAverage Lower Low Bars :'+str.tostring(llBars)
hlText = 'Number of Historical References :'+str.tostring(hlStats)+'/'+str.tostring(tStats)+
'\nProbability of Higher Low :'+hlPercent+
'\nAverage Higher Low Ratio :'+str.tostring(hlRatio) +
'\nAverage Higher Low Bars :'+str.tostring(hlBars)
tText = 'Number of Historical References :'+str.tostring(tStats)+
'\nAverage Fib Ratio :'+str.tostring(tRatio)+
'\nAverage Bars :'+str.tostring(tBars)
llLabel := label.new(llX2, llY2, str.tostring(llY2)+ ' - ' +llPercent, style=label.style_label_upper_left, color=color.new(color.red, 70), textcolor = color.white, size=size.small, tooltip=llText)
hlLabel := label.new(hlX2, hlY2, str.tostring(hlY2)+ ' - ' +hlPercent, style=label.style_label_lower_left, color=color.new(color.orange, 70), textcolor = color.white, size=size.small, tooltip=hlText)
tLabel := label.new(tX2, tY2, str.tostring(tY2)+ '@'+str.tostring(tRatio), style=label.style_label_left, color=color.new(color.yellow, 70), textcolor = color.white, size=size.small, tooltip=tText)
llValue := llY2
hlValue := hlY2
llProbability := llStats*100/tStats
ltRatio := tRatio
if(llStats != 0 and hlStats != 0) and showTable
table.cell(statsTable, plColStart, llr, llastPivotStatus, text_color = txtColor, text_size = txtSize, bgcolor = color.new(color.orange, 60))
table.cell(statsTable, plColStart+1, llr, lastPivotStatus, text_color = txtColor, text_size = txtSize, bgcolor = color.new(color.lime, 60))
table.cell(statsTable, plColStart+2, llr, str.tostring(llStats)+' - '+str.tostring(llRatio), text_color = txtColor, text_size = txtSize, bgcolor = color.new(color.red, highlight? 50 : 90), tooltip=llTooltip)
table.cell(statsTable, plColStart+3, llr, str.tostring(hlStats)+' - '+str.tostring(hlRatio), text_color = txtColor, text_size = txtSize, bgcolor = color.new(color.green, highlight? 50 : 90), tooltip = hlTooltip)
table.cell(statsTable, plColStart+4, llr, str.tostring(tStats)+' - '+str.tostring(tRatio), text_color = txtColor, text_size = txtSize, bgcolor = color.from_gradient(llStats/tStats, 0, 1, color.green, color.red), tooltip = tTooltip)
llr+=1
if showPivotLines
draw(valueMatrix, directionMatrix, ratioMatrix, divergenceMatrix, doubleDivergenceMatrix, barArray, trendArray, newZG, doubleZG)
plot(drawSupertrend? supertrend:na, color=supertrendDir>0? color.green:color.red, style=plot.style_linebr)
hhp = plot(fillAreas?hhValue:na, 'Higher High Range', color.new(color.green, 100), 1)
lhp = plot(fillAreas?lhValue:na, 'Lower High Range', color.new(color.lime, 100), 1)
llp = plot(fillAreas?llValue:na, 'Lower Low Range', color.new(color.red, 100), 1)
hlp = plot(fillAreas?hlValue:na, 'Higher Low Range', color.new(color.orange, 100), 1)
fill(hhp, lhp, color=color.new(hhProbability > 50 ? color.green : hhProbability < 50? color.red : color.silver, 90))
fill(llp, hlp, color=color.new(llProbability > 50 ? color.red : llProbability < 50? color.green : color.silver, 90))
16.07.2024 - 10.12.2024
bu kod çok hoşuma gidiyor....
bir çok tasarımda kullanırım.....
çünkü dinamiktir.....
uzunluğa değil....
barlara göre....fibo hesaplar.....
trade edenler için sistemlerde olması gerekir bence.....
PHP Code:
//Fib box for OTE on visible chart only (61.8% - 78.6%)
//Thanks to Pinecoder's VisibleChart library (PineCoders/VisibleChart/4) from which i borrowed code to write the library used here
//Fib extensions added: user input; choose if above or below the range
//User input toggle to choose to anchor the range from wick high/low or candle body high/low
//23rd Jan'23
//@twingall
//@version=5
import twingall/BasicVisibleChart/1
indicator("OTE visible chart", overlay = true)
useBodies =input.bool(false, "use Candle Bodies to anchor range")
showFibBox = input.bool(true, "show Fib Box", group = "OTE box", inline = "2")
boxColor = input.color(color.new(color.yellow, 82), "", group = "OTE box", inline = "2")
showText = input.bool(false, "show Text",group = "OTE box", inline = "2")
showHighLowLines=input.bool(true, "high/low lines", group = "fib retracements",inline = "3")
lineColor = input.color(color.rgb(217, 76, 217), "", group = "fib retracements",inline = "3")
showMidline =input.bool(true, "Midline", group = "fib retracements",inline = "3")
midlineColor = input.color(color.gray,"", group = "fib retracements",inline = "3")
show61eight=input.bool(false, "show 61.8 line", group = "fib retracements",inline = "5")
show78six=input.bool(false, "show 78.6 line", group = "fib retracements",inline = "6")
show88six=input.bool(false, "show 88.6 line", group = "fib retracements",inline = "7")
showfibExt1=input.bool(true,"Ext#1", group ="fib extensions",inline="9")
fibExt1Color=input.color(color.red,"", group ="fib extensions",inline="9")
fibExt1=input.float(1.618, "", group ="fib extensions",inline="9")
showfibExt2=input.bool(true,"Ext#2", group ="fib extensions",inline="9")
fibExt2Color=input.color(color.red,"", group ="fib extensions",inline="9")
fibExt2=input.float(2.0, "", group ="fib extensions",inline="9")
showfibExt3=input.bool(false,"Ext#3", group ="fib extensions",inline="10")
fibExt3Color=input.color(color.red,"", group ="fib extensions",inline="10")
fibExt3=input.float(1.5, "", group ="fib extensions",inline="10")
showfibExt4=input.bool(false,"Ext#4", group ="fib extensions",inline="10")
fibExt4Color=input.color(color.red,"", group ="fib extensions",inline="10")
fibExt4=input.float(2.5, "", group ="fib extensions",inline="10")
showfibExt5=input.bool(false,"Ext#5", group ="fib extensions",inline="11")
fibExt5Color=input.color(color.red,"", group ="fib extensions",inline="11")
fibExt5=input.float(3.0, "", group ="fib extensions",inline="11")
showfibExt6=input.bool(false,"Ext#6", group ="fib extensions",inline="11")
fibExt6Color=input.color(color.red,"", group ="fib extensions",inline="11")
fibExt6=input.float(3.5, "", group ="fib extensions",inline="11")
_88sixColor = input.color(color.green, "", group = "fib retracements",inline = "7")
_61eightColor = input.color(color.green, "", group = "fib retracements",inline = "5")
_78sixColor = input.color(color.green, "", group = "fib retracements",inline = "6")
colorNone = color.new(color.white,100)
showExtLabels=input.bool(false,"Show Labels (Fib extensions)", group ="fib extensions",inline="11")
flipInvertExts=input.bool(false,"flip/invert extensions", group ="fib extensions",inline="12")
showFibLabels = input.bool(false, "Show Labels (Fib retracements)", group="fib retracements", inline="8")
// Calling Library functions to get: high/low, body high / body low, timings, bull/bear
float chartHigh = useBodies? BasicVisibleChart.highestBody():BasicVisibleChart.high()
float chartLow =useBodies?BasicVisibleChart.lowestBody():BasicVisibleChart.low()
int highTime = BasicVisibleChart.highBarTime()
int lowTime = BasicVisibleChart.lowBarTime()
int leftTime = math.min(highTime, lowTime)
int rightTime = math.max(highTime, lowTime)
bool isBull = lowTime < highTime
// Function to manage fib lines. It declares fib lines and label the first time it is called, then sets their properties on subsequent calls.
fibLine(series color fibColor, series float fibLevel, bool _showPriceLabels) =>
float fibRatio = 1-(fibLevel / 100)
float fibPrice = isBull ? chartLow + ((chartHigh - chartLow) * fibRatio) :
chartHigh - ((chartHigh - chartLow) * fibRatio)
float _fibLabel = fibLevel /100
var line fibLine = line.new(na, na, na, na, xloc.bar_time, extend.right, fibColor, line.style_dotted, 2)
line.set_xy1(fibLine, leftTime, fibPrice)
line.set_xy2(fibLine, rightTime, fibPrice)
var label fibLabel = label.new(na, na, "", xloc.bar_time, yloc.price, color(na), label.style_label_up, _showPriceLabels? fibColor:colorNone)
label.set_xy(fibLabel, int(math.avg(leftTime, rightTime)), fibPrice)
label.set_text(fibLabel, str.tostring(fibPrice, format.mintick))
//label.set_text(fibLabel, str.format("{0, number, #.###} ({1})", _fibLabel , str.tostring(fibPrice, format.mintick)))
//Function for Fib Extension lines..
fibExt(series color fibColor, series float fibLevel, bool _showExt) =>
float fibRatio = fibLevel / 100
float fibPrice = isBull ? chartLow - ((chartHigh - chartLow) * fibRatio) :
chartHigh + ((chartHigh - chartLow) * fibRatio)
float fibLabel = not flipInvertExts? -(fibLevel /100) :(fibLevel /100)+1 //getting both normal and inverted ext labels to display as positive numbers
var line fibLine = line.new(na, na, na, na, xloc.bar_time, extend.right, fibColor, line.style_dotted, 2)
line.set_xy1(fibLine, leftTime, fibPrice)
line.set_xy2(fibLine, rightTime, fibPrice)
var label fibExtLabel = label.new(na, na, "", xloc.bar_time, yloc.price, color(na), label.style_label_up, _showExt? fibColor:colorNone)
label.set_xy(fibExtLabel, int(math.avg(leftTime, rightTime)), fibPrice)
label.set_text(fibExtLabel, str.format("{0, number, #.###} ({1})", fibLabel , str.tostring(fibPrice, format.mintick)))
//Fib Box function; similar to the above but highlighting the area between 2 fib levels
fibBox(series color fibColor, series float fibLevel_1, series float fibLevel_2) =>
float fibRatio_1 = 1-(fibLevel_1 / 100)
float fibPrice_1 = isBull ? chartLow + ((chartHigh - chartLow) * fibRatio_1) : chartHigh - ((chartHigh - chartLow) * fibRatio_1)
float fibRatio_2 = 1-(fibLevel_2 / 100)
float fibPrice_2 = isBull ? chartLow + ((chartHigh - chartLow) * fibRatio_2) : chartHigh - ((chartHigh - chartLow) * fibRatio_2)
var b = box.new(na, na, na, na, xloc=xloc.bar_time, border_style=line.style_dashed, extend = extend.right, border_color=colorNone, text_color=color.new(color.gray,70), text_halign=text.align_right)
box.set_lefttop(b, leftTime, fibPrice_1)
box.set_rightbottom(b, rightTime,fibPrice_2)
box.set_bgcolor(b, fibColor)
box.set_text(b, text = showText? "OTE":"")
// Display code that only runs on the last bar but displays visuals on visible bars, wherever they might be in the dataset.
if barstate.islast
//Declare fib lines and fib box
fibLine(lineColor, 100,showFibLabels )
fibLine(showMidline?midlineColor :colorNone, 50,showFibLabels )
fibLine(lineColor, 0,showFibLabels )
fibBox(showFibBox?boxColor:colorNone, 78.6, 61.8)
fibLine(show88six?_88sixColor:colorNone, 88.6,showFibLabels )
fibLine(show61eight?_61eightColor:colorNone, 61.8,showFibLabels )
fibLine(show78six?_78sixColor:colorNone, 78.6,showFibLabels )
//more fib lines
//fibLine(_88sixColor, 11.4)
//fibLine(_61eightColor, 38.2)
//fibLine(_78sixColor, 21.4)
//Declare Fib extensions
if barstate.islast and showfibExt1 and flipInvertExts
fibExt(fibExt1Color, (fibExt1*100)-100, showExtLabels)
if barstate.islast and showfibExt2 and flipInvertExts
fibExt(fibExt2Color, (fibExt2*100)-100, showExtLabels)
if barstate.islast and showfibExt3 and flipInvertExts
fibExt(fibExt3Color, (fibExt3*100)-100, showExtLabels)
if barstate.islast and showfibExt4 and flipInvertExts
fibExt(fibExt4Color, (fibExt4*100)-100, showExtLabels)
if barstate.islast and showfibExt5 and flipInvertExts
fibExt(fibExt5Color, (fibExt5*100)-100, showExtLabels)
if barstate.islast and showfibExt6 and flipInvertExts
fibExt(fibExt6Color, (fibExt6*100)-100, showExtLabels)
if barstate.islast and showfibExt1 and not flipInvertExts
fibExt(fibExt1Color, -(fibExt1*100), showExtLabels)
if barstate.islast and showfibExt2 and not flipInvertExts
fibExt(fibExt2Color, -(fibExt2*100), showExtLabels)
if barstate.islast and showfibExt3 and not flipInvertExts
fibExt(fibExt3Color, -(fibExt3*100), showExtLabels)
if barstate.islast and showfibExt4 and not flipInvertExts
fibExt(fibExt4Color, -(fibExt4*100), showExtLabels)
if barstate.islast and showfibExt5 and not flipInvertExts
fibExt(fibExt5Color, -(fibExt5*100), showExtLabels)
if barstate.islast and showfibExt6 and not flipInvertExts
fibExt(fibExt6Color, -(fibExt6*100), showExtLabels)
16.07.2024 - 10.12.2024
bu kod ise....
kombinedir.....
barların sinyalleri olduğu gibi.....
ayı-boğa ilişkisini gösterir.....
ayrıca.... olası bar hareketlerini hesaplar gösterir.....
içinde yok yok...PHP Code:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © dg_factor [21.06.2023]
// ╠═══════════════════════════ Anıl Özekşi Library ═══════════════════════════╣
// 1) OTT [31.05.2019] Optimized Trend Tracker
// 2) TOTT [01.05.2020] Twin Ott (Ott Bands)
// 3) OTT CHANNEL [19.03.2021] Ott Channel (Half Channel & Fibonacci Channel)
// 4) RISOTTO [16.04.2021] Rsi-Ott
// 5) SOTT [18.04.2021] Stochastic Ott
// 6) HOTT-LOTT [06.03.2022] Highest-Lowest Ott & Sum Version [07.04.2022]
// 7) ROTT [19.05.2022] Relative Ott
// 8) FT [24.06.2022] "Fırsatçı Trend"
// 9) RTR [26.09.2022] Relative True Range
// "TOTTO" and "OTTO" are not included in the script.
// TOTTO and TOTT have the same calculations, the only difference is the length parameter.
// OTTO has been created by another (K. H. Alpay).
// Special thanks to Kıvanç Özbilgiç for Pine Script design and calculation examples of OTT.
//@version=5
indicator("!", precision=2, max_lines_count = 100, max_labels_count = 100, overlay=true)
// ╠═════════════════════════════════ Inputs ══════════════════════════════════╣
gr_sys = "╠═══════════════ SYSTEM ══════════════╣"
system = input.string(title="System ", defval="OTT", group=gr_sys, options=
["OTT", "TOTT", "OTT CHANNEL", "RISOTTO", "SOTT", "HOTT-LOTT", "ROTT", "FT", "RTR"])
tt_p = "Enable repating signals.\n" +
"(This option allows you to display consecutive signals in the same direction for TOTT & HOTT-LOTT. " +
"It also effects the colour of bars.)"
tt_bars = "Bars option is available for :\nOTT, TOTT, OTT CHANNEL, HOTT-LOTT, FT."
pyr = input.bool(title="Pyramiding", defval=false, group=gr_sys, tooltip=tt_p)
gr_dis = "╠═══════════════ DISPLAY ══════════════╣"
sh_signal = input.bool(title="Signals****", defval=true, group=gr_dis, inline="1")
sh_bar_color = input.bool(title="Barcolor****", defval=true, group=gr_dis, inline="1")
sh_bar = input.bool(title="Bars", defval=true, group=gr_dis, inline="1", tooltip=tt_bars)
col_sup = #00bcd4
col_tar = #ff9800
col_l = #00ff00
col_s = #ff0000
col_n = #333333
// ╔═══════════════════════════════════════════════════════════════════════════╗
// ║ FUNCTIONS ║
// ╚═══════════════════════════════════════════════════════════════════════════╝
// ╠═══════════════════════════════════ VAR ═══════════════════════════════════╣
// Variable Index Dynamic Adaptive Moving Average - Tushar Chande
f_var(series float data, series int length) =>
a = ta.sma(data, length)
b = math.abs(ta.change(data, 9)) // Momentum
c = math.sum(math.abs(ta.change(data)), 9) // Volatility
d = c != 0 ? b / c : 0 // Efficiency Ratio
e = 2 / (length + 1)
r = 0.0, r := length == 1 ? data : na(r[1]) ? a : d * e * (data - nz(r[1])) + nz(r[1]) // Matriks design
// r = 0.0, r := d * e * (data - nz(r[1])) + nz(r[1]) // Output used in previously published versions on Tradingview
//
// ╠═══════════════════════════════════ OTT ═══════════════════════════════════╣
// Optimized Trend Tracker - Anıl Özekşi
f_ott(series float data, series float multiplier) =>
a = multiplier / 100
b = data * a, c = data - b, d = data + b
c := c > nz(c[1]) or data < nz(c[1]) ? c : nz(c[1])
d := d < nz(d[1]) or data > nz(d[1]) ? d : nz(d[1])
e = 0.0, e := data > nz(e[1]) ? c : data < nz(e[1]) ? d : nz(e[1]) // MOST - by Anıl Özekşi :)
f = 1 + a / 2
g = 1 - a / 2
h = data > e ? e * f : e * g
r = nz(h[2])
//
// ╔═══════════════════════════════════════════════════════════════════════════╗
// ║ CALCULATIONS ║
// ╚═══════════════════════════════════════════════════════════════════════════╝
// ╠═══════════════════════════════════ OTT ═══════════════════════════════════╣
// Inputs
string gr_ott = "╠═══════════════ OTT ════════════════╣"
ott_u = input.int(title="Length ", defval=20, step=5, group=gr_ott, tooltip="MA Length [20, 60]")
ott_k = input.float(title="Multiplier ", defval=1.5, step=0.1, group=gr_ott, tooltip="OTT Multiplier")
// Calcs
ott_support = f_var(close, ott_u)
ott_line = f_ott(ott_support, ott_k)
// Signals
ott_long = ott_support > ott_line // ta.crossover(ott_support, ott_line)
ott_short = ott_support < ott_line // ta.crossunder(ott_support, ott_line)
// ╠══════════════════════════════════ TOTT ═══════════════════════════════════╣
// Inputs
string gr_tott = "╠═══════════════ TOTT ═══════════════╣"
tott_u = input.int(title="Length ", defval=35, step=5, group=gr_tott, tooltip="MA Length [15, 45]")
tott_k1 = input.float(title="Multiplier ", defval=0.5, step=0.1, group=gr_tott, tooltip="OTT Multiplier [0.3, 0.6]")
tott_k2 = input.float(title="Band Multiplier ", defval=0.0006, step=0.0001, group=gr_tott, tooltip="[0.0004, 0.0006]")
// Calcs
tott_support = f_var(close, int(tott_u / 2))
tott_up = f_ott(f_var(tott_support, 2), tott_k1) * (1 + tott_k2)
tott_dn = f_ott(f_var(tott_support, 2), tott_k1) * (1 - tott_k2)
// Signals
tott_long = tott_support > tott_up // ta.crossover(tott_support, tott_up)
tott_short = tott_support < tott_dn // ta.crossunder(tott_support, tott_dn)
// ╠═══════════════════════════════ OTT CHANNEL ═══════════════════════════════╣
// Inputs
string gr_ottc = "╠════════════ OTT CHANNEL ════════════╣"
string ottc_t1 = "You can use this parameter to optimize '[Channel] Upper Line' manually."
string ottc_t2 = "You can use this parameter to optimize '[Channel] Lower Line' manually."
string ottc_t3 = "It is recommended to hide the channel levels to see the trends correctly while you're setting the manuel parameter optimization."
ottc_t = input.string(title="Channel Type", defval="Half Channel", options=["Half Channel", "Fibonacci Channel", "Both"], group=gr_ottc)
ottc_u = input.int(title="Length ", defval=2, group=gr_ottc, tooltip="MA Length")
ottc_k1 = input.float(title="Multiplier ", defval=1.4, group=gr_ottc, tooltip="OTT Multiplier")
ottc_k2 = input.float(title="Upper Line Multiplier", defval=0.01, step=0.01, group=gr_ottc, tooltip=ottc_t1)
ottc_k3 = input.float(title="Lower Line Multiplier", defval=0.01, step=0.01, group=gr_ottc, tooltip=ottc_t2)
ottc_h1 = input.bool(title="Hide Upper & Lower Lines", defval=false, group=gr_ottc)
ottc_h2 = input.bool(title="Hide Channel Lines", defval=false, group=gr_ottc, tooltip=ottc_t3)
// Ottc Mid Line
ottc_m = f_ott(f_var(close, ottc_u), ottc_k1)
// Channel Calcs
ottc_1 = ottc_m * (1 + ottc_k2)
ottc_2 = ottc_m * (1 + ottc_k2 * 0.618)
ottc_3 = ottc_m * (1 + ottc_k2 * 0.500)
ottc_4 = ottc_m * (1 + ottc_k2 * 0.382)
ottc_5 = ottc_m * (1 - ottc_k3 * 0.382)
ottc_6 = ottc_m * (1 - ottc_k3 * 0.500)
ottc_7 = ottc_m * (1 - ottc_k3 * 0.618)
ottc_8 = ottc_m * (1 - ottc_k3)
// Signals
// There're no any referenced conditions to generate signals for Ott Channel.
// It is recommended to use Channels as support and resistance levels.
// ╠═════════════════════════════════ RISOTTO ═════════════════════════════════╣
// Inputs
string gr_risotto = "╠═════════════ RISOTTO ═══════════════╣"
risotto_u1 = input.int(title="Length 1", defval=100, group=gr_risotto, tooltip="RSI Length")
risotto_u2 = input.int(title="Length 2", defval=50, group=gr_risotto, tooltip="MA Length")
risotto_k = input.float(title="Multiplier ", defval=0.2, group=gr_risotto, tooltip="OTT Multiplier")
// Calcs
risotto_support = f_var(ta.rsi(close, risotto_u1), risotto_u2) + 1000
risotto_line = f_ott(f_var(risotto_support, 2), risotto_k)
// Signals
risotto_long = risotto_support > risotto_line // ta.crossover(risotto_support, risotto_line)
risotto_short = risotto_support < risotto_line // ta.crossunder(risotto_support, risotto_line)
// ╠══════════════════════════════════ SOTT ═══════════════════════════════════╣
// Inputs
string gr_sott = "╠═══════════════ SOTT ═══════════════╣"
sott_u1 = input.int(title="Length 1", defval=500, group=gr_sott, tooltip="Stochastic %k Length")
sott_u2 = input.int(title="Length 2", defval=200, group=gr_sott, tooltip="Stochastic %d Length")
sott_k = input.float(title="Multiplier ", defval=0.5, group=gr_sott, tooltip="OTT Multiplier")
// Calcs
sott_support = f_var(ta.stoch(close, high, low, sott_u1), sott_u2) + 1000
sott_line = f_ott(f_var(sott_support, 2), sott_k)
// Signals
sott_long = sott_support > sott_line // ta.crossover(sott_support, sott_line)
sott_short = sott_support < sott_line // ta.crossunder(sott_support, sott_line)
// ╠═══════════════════════════════ HOTT & LOTT ═══════════════════════════════╣
// Inputs
string gr_hl = "╠════════════ HOTT & LOTT ═════════════╣"
string hl_t1 = "If you activate this option, signals will be generated according to the confirmation concept for N bars. \n\n" +
"Long : If the 'High' price is higher than Hott for N bars.\n\n" +
"Short : If the 'Low' price is lower than Lott for N bars."
hl_u = input.int(title="Length ", defval=10, step=5, group=gr_hl, tooltip="ta.highest() & ta.lowest() Length\n[10, 30]")
hl_k = input.float(title="Multiplier ", defval=0.6, step=0.1, group=gr_hl, tooltip="OTT Multiplier [0.3, 0.6]")
hl_sum = input.bool(title="Sum N bars", defval=false, group=gr_hl, inline="1")
hl_sum_n = input.int(title="**********", defval=3, group=gr_hl, inline="1", tooltip=hl_t1)
// Calcs
hott = f_ott(f_var(ta.highest(hl_u), 2), hl_k)
lott = f_ott(f_var(ta.lowest(hl_u), 2), hl_k)
// Signals
hl_long = not hl_sum ? high > hott : math.sum(high > hott ? 1 : 0, hl_sum_n) == hl_sum_n // ta.crossover(high, hott)
hl_short = not hl_sum ? low < lott : math.sum(low < lott ? 1 : 0, hl_sum_n) == hl_sum_n // ta.crossunder(low, lott)
// ╠══════════════════════════════════ ROTT ═══════════════════════════════════╣
// Inputs
string gr_rott = "╠═══════════════ ROTT ═══════════════╣"
rott_u = input.int(title="Length ", defval=200, group=gr_rott, tooltip="MA Length [100, 300]")
rott_k = input.float(title="Multiplier ", defval=1.0, group=gr_rott, tooltip="OTT Multiplier")
// Calcs
rott_support = f_var(close, rott_u) * 2
rott_line = f_ott(f_var(rott_support, 2), rott_k)
// Signals
rott_long = rott_support > rott_line // ta.crossover(rott_support, rott_line)
rott_short = rott_support < rott_line // ta.crossunder(rott_support, rott_line)
// ╠═══════════════════════════════════ FT ════════════════════════════════════╣
// Inputs
string gr_ft = "╠════════════════ FT ════════════════╣"
ft_u = input.int(title="Length ", defval=30, step=10, group=gr_ft, tooltip="MA Length [20, 40]")
ft_k1 = input.float(title="Major Multiplier", defval=3.6, group=gr_ft, tooltip="Major OTT Multiplier")
ft_k2 = input.float(title="Minor Multiplier", defval=1.8, group=gr_ft, tooltip="Minor OTT Multiplier")
// Calcs
ft_support = f_var(close, ft_u)
major_trend = f_ott(ft_support, ft_k1)
minor_trend = f_ott(ft_support, ft_k2)
ft_line = (minor_trend + (2 * minor_trend - major_trend)[100]) / 2
// Signals
ft_long = ft_support > ft_line // ta.crossover(ft_support, ft_line)
ft_short = ft_support < ft_line // ta.crossunder(ft_support, ft_line)
// ╠═══════════════════════════════════ RTR ═══════════════════════════════════╣
// Inputs
string gr_rtr = "╠═══════════════ RTR ════════════════╣"
rtr_u1 = input.int(title="Length 1", defval=10, group=gr_rtr, tooltip="ATR Length [10, 20]")
rtr_u2 = input.int(title="Length 2", defval=200, group=gr_rtr, tooltip="MA Length [200, 500]")
// Calcs
rtr_line = close / f_var(close / ta.atr(rtr_u1), rtr_u2)
// Signals
// There're no any referenced conditions to generate signals for Relative True Range.
// It is recommended to use RTR as a volatility indicator.
// ╔═══════════════════════════════════════════════════════════════════════════╗
// ║ RETURN ║
// ╚═══════════════════════════════════════════════════════════════════════════╝
// ╠═════════════════════════════ Support & Lines ═════════════════════════════╣
_support =
system == "OTT" ? ott_support :
system == "TOTT" ? tott_support :
system == "RISOTTO" ? risotto_support :
system == "SOTT" ? sott_support :
system == "ROTT" ? rott_support :
system == "FT" ? ft_support :
na
//
_target =
system == "OTT" ? ott_line :
system == "RISOTTO" ? risotto_line :
system == "SOTT" ? sott_line :
system == "ROTT" ? rott_line :
system == "FT" ? ft_line :
system == "RTR" ? rtr_line :
na
//
_line_up =
system == "TOTT" ? tott_up :
system == "HOTT-LOTT" ? hott :
na
//
_line_dn =
system == "TOTT" ? tott_dn :
system == "HOTT-LOTT" ? lott :
na
//
// ╠═════════════════════════════════ Signals ═════════════════════════════════╣
long =
system == "OTT" ? ott_long :
system == "TOTT" ? tott_long :
system == "RISOTTO" ? risotto_long :
system == "SOTT" ? sott_long :
system == "HOTT-LOTT" ? hl_long :
system == "ROTT" ? rott_long :
system == "FT" ? ft_long :
na
//
short =
system == "OTT" ? ott_short :
system == "TOTT" ? tott_short :
system == "RISOTTO" ? risotto_short :
system == "SOTT" ? sott_short :
system == "HOTT-LOTT" ? hl_short :
system == "ROTT" ? rott_short :
system == "FT" ? ft_short :
na
//
// Fix Signal
var bool l = na
var bool s = na
ls = not s and long
ss = not l and short
if ls
l := false
s := true
if ss
l := true
s := false
int dir = 0
dir := pyr ? long ? 1 : short ? -1 : 0 : ls ? 1 : ss ? -1 : nz(dir[1])
long_signal = pyr ? not long[1] and long : ls
short_signal = pyr ? not short[1] and short : ss
total_signals = ta.cum(long_signal or short_signal ? 1 : 0)
// ╠═══════════════════════════════ Plotshapes ════════════════════════════════╣
plotshape(sh_signal ? long_signal : na, "Long Signal", shape.triangleup, location.bottom, col_l, size=size.normal)
plotshape(sh_signal ? short_signal : na, "Short Signal", shape.triangledown, location.top, col_s, size=size.normal)
// ╠══════════════════════════ Plot Support & Lines ═══════════════════════════╣
plot(_support, color=col_sup, title=". ")
plot(_target, color=col_tar, title="..")
//plot(_line_up, color=#00bb00, title="Upper Line")
//plot(_line_dn, color=#fb0000, title="Lower Line")
// ╠══════════════════════════════ Plot Channels ══════════════════════════════╣
bool ottc_none = system != "OTT CHANNEL"
bool ottc_half = ottc_t == "Both" or ottc_t == "Half Channel"
bool ottc_fibo = ottc_t == "Both" or ottc_t == "Fibonacci Channel"
//plot(ottc_none or ottc_h1 ? na : ottc_1, color=#00bb00, title="[Channel] Upper Line")
//plot(ottc_none or ottc_h2 ? na : ottc_fibo ? ottc_2 : na, color=#8c00ff, title="[Channel] ⮝ 0.618")
//plot(ottc_none or ottc_h2 ? na : ottc_half ? ottc_3 : na, color=#00bcd4, title="[Channel] ⮝ Half Line")
//plot(ottc_none or ottc_h2 ? na : ottc_fibo ? ottc_4 : na, color=#1848cc, title="[Channel] ⮝ 0.382")
//plot(ottc_none or ottc_h2 ? na : ottc_m, color=#787B86, title="[Channel] Mid Line")
//plot(ottc_none or ottc_h2 ? na : ottc_fibo ? ottc_5 : na, color=#945100, title="[Channel] ⮟ 0.382")
//plot(ottc_none or ottc_h2 ? na : ottc_half ? ottc_6 : na, color=#ff9800, title="[Channel] ⮟ Half Line")
//plot(ottc_none or ottc_h2 ? na : ottc_fibo ? ottc_7 : na, color=#a4a600, title="[Channel] ⮟ 0.618")
//plot(ottc_none or ottc_h1 ? na : ottc_8, color=#fb0000, title="[Channel] Lower Line")
// ╠════════════════════════════════ Barcolor ═════════════════════════════════╣
no_color = system == "OTT CHANNEL" or system == "RTR"
bar_color =
no_color ? na :
dir == 1 ? col_l : dir == -1 ? col_s : col_n
barcolor(sh_bar_color ? bar_color : na, title="Barcolor")
// ╠═══════════════════════════════ Plotcandle ════════════════════════════════╣
no_bars = system == "RISOTTO" or system == "SOTT" or system == "ROTT" or system == "RTR"
candle_color = close>open ? #08998175 : close<open ? #f2364575 : #33333375
plotshape(barstate.isfirst, title="╠═════ OHLC ═════╣", location=location.bottom, color=#00000000, editable=false)
plotcandle(
no_bars ? na : sh_bar ? open : na,
no_bars ? na : sh_bar ? high : na,
no_bars ? na : sh_bar ? low : na,
no_bars ? na : sh_bar ? close : na,
title="Bars", color=candle_color, bordercolor=candle_color, wickcolor=candle_color)
//
// ╠═══════════════════════════════ Parameters ════════════════════════════════╣
p_ott =
"Length : " + str.tostring(ott_u) + "\n\n" +
"Multiplier : " + str.tostring(ott_k)
p_tott =
"Length : " + str.tostring(tott_u) + "\n\n" +
"Multiplier : " + str.tostring(tott_k1) + "\n\n" +
"Band Multiplier : " + str.tostring(tott_k2)
p_ottc =
"Length : " + str.tostring(ottc_u) + "\n\n" +
"Multiplier : " + str.tostring(ottc_k1) + "\n\n" +
"Upper Line Multiplier : " + str.tostring(ottc_k2) + "\n\n" +
"Lower Line Multiplier : " + str.tostring(ottc_k3)
p_risotto =
"Rsi Length : " + str.tostring(risotto_u1) + "\n\n" +
"Ott Length : " + str.tostring(risotto_u2) + "\n\n" +
"Multplier : " + str.tostring(risotto_k)
p_sott =
"Stochastic %k Length : " + str.tostring(sott_u1) + "\n\n" +
"Stochastic %d Length : " + str.tostring(sott_u2) + "\n\n" +
"Multplier : " + str.tostring(sott_k)
pp_sum =
hl_sum ? "Sum Option : On" + "\n\n" + "Sum N Bars : " + str.tostring(hl_sum_n) : ""
p_hl =
"Length : " + str.tostring(hl_u) + "\n\n" +
"Multiplier : " + str.tostring(hl_k) + "\n\n" +
pp_sum
p_rott =
"Length : " + str.tostring(rott_u)+ "\n\n" +
"Multiplier : " + str.tostring(rott_k)
p_ft =
"Length : " + str.tostring(ft_u) + "\n\n" +
"Major Multiplier : " + str.tostring(ft_k1) + "\n\n" +
"Minor Multiplier : " + str.tostring(ft_k2)
p_rtr =
"Atr Length : " + str.tostring(rtr_u1) + "\n\n" +
"Var Length : " + str.tostring(rtr_u2)
//
parameter =
system == "OTT" ? p_ott :
system == "TOTT" ? p_tott :
system == "OTT CHANNEL" ? p_ottc :
system == "RISOTTO" ? p_risotto :
system == "SOTT" ? p_sott :
system == "HOTT-LOTT" ? p_hl :
system == "ROTT" ? p_rott :
system == "FT" ? p_ft :
system == "RTR" ? p_rtr :
na
//
// ╠══════════════════════════════════ Table ══════════════════════════════════╣
var tb = table.new(position.top_right, 1, 10)
if barstate.islast
table.cell(tb, 0, 0, ottc_none ? "\n\n" + system : "\n\n" + system + "\n\n[" + ottc_t + "]", text_color=color.blue, text_halign=text.align_left)
table.cell(tb, 0, 1, parameter, text_color=#686868, text_halign=text.align_left)
table.cell(tb, 0, 2, "\n\nChart Info", text_color=color.blue, text_halign=text.align_left)
table.cell(tb, 0, 3, "Bars : " + str.tostring(bar_index + 1), text_color=#686868, text_halign=text.align_left)
table.cell(tb, 0, 4, "Signals : " + str.tostring(total_signals), text_color=#686868, text_halign=text.align_left)
//
// ╠═══════════════════════════════════ Out ═══════════════════════════════════╣
// Direction
plot(dir, title="Direction", display=display.data_window, editable=false)
// Entry & Exit
long_entry = dir == 1 and dir[1] != 1
long_exit = dir != 1 and dir[1] == 1
short_entry = dir == -1 and dir[1] != -1
short_exit = dir !=-1 and dir[1] == -1
// Out
plot(long_entry ? 1 : 0, "Long Entry", display=display.data_window, editable=false)
plot(long_exit ? 1 : 0, "Long Exit", display=display.data_window, editable=false)
plot(short_entry ? 1 : 0, "Short Entry", display=display.data_window, editable=false)
plot(short_exit ? 1 : 0, "Short Exit", display=display.data_window, editable=false)
// Alert
freq = alert.freq_once_per_bar_close
if long_entry
alert(system + "\nLong Entry !", freq)
if long_exit
alert(system + "\nLong Exit !", freq)
if short_entry
alert(system + "\nShort Entry !", freq)
if short_exit
alert(system + "\nShort Exit !", freq)
//
// Bitti :)
plotshape(barstate.isfirst, title="@ dg_factor", location=location.bottom, color=#00000000, editable=false)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tradeforopp
//@version=5
var g_STR = "Structure"
ps = input.int(1, "Pivot Strength", group = g_STR)
color_trend = input.bool(true, "Trend Candles", inline = "TREND", group = g_STR)
show_labels = input.bool(true, "Show Structure Labels", inline = "MSS", group = g_STR)
label_type = input.string("All", "", options = ['MSS', 'BOS', 'All'], inline = "MSS", group = g_STR)
var g_PHL = "Protected Highs & Lows"
show_phl = input.bool(true, "Show Protected Highs & Lows", inline = "PHL", group = g_PHL)
trail_phl = input.bool(false, "Show Protected Trail", inline = "TRAIL", group = g_PHL)
trail_width = input.int(1, "", inline = "TRAIL", group = g_PHL)
ph_color = input.color(color.rgb(253, 237, 4), "", inline = "PHL", group = g_PHL)
pl_color = input.color(color.rgb(253, 237, 4), "", inline = "PHL", group = g_PHL)
bull_color = input.color(color.rgb(61, 248, 4), "", inline = "TREND", group = g_STR)
bear_color = input.color(color.rgb(250, 3, 3), "", inline = "TREND", group = g_STR)
var bool bull = na
var float trail_price = na
var color trail_color = na
var ph = array.new_float()
var pl = array.new_float()
var pht = array.new_int()
var plt = array.new_int()
var float last_high = na
var float last_low = na
var int last_high_idx = na
var int last_low_idx = na
var float track_high = na
var float track_low = na
var int track_high_idx = na
var int track_low_idx = na
type dwg
label[] _label
label[] _phl
line[] _line
bool[] _bull
method dwg_add(dwg d, label LB, label PHL, line LN, bool BL) =>
d._label.unshift(LB)
d._phl.unshift(PHL)
d._line.unshift(LN)
d._bull.unshift(BL)
clear_all() =>
pl.clear()
plt.clear()
ph.clear()
pht.clear()
if ta.pivotlow(low, ps, ps) and pl.size() == 0
pl.unshift(low[ps])
plt.unshift(time[ps])
if na(last_low)
last_low := low[ps]
last_low_idx := bar_index - ps
else
if low[ps] < last_low
last_low := low[ps]
last_low_idx := bar_index - ps
if ta.pivothigh(high, ps, ps) and ph.size() == 0
ph.unshift(high[ps])
pht.unshift(time[ps])
if na(last_high)
last_high := high[ps]
last_high_idx := bar_index - ps
else
if high[ps] > last_high
last_high := high[ps]
last_high_idx := bar_index - ps
if (high[ps] > track_high or na(track_high) or last_low_idx >= track_high_idx) and not na(ta.pivothigh(high, ps, ps))
track_high := high[ps]
track_high_idx := bar_index - ps
if (low[ps] < track_low or na(track_low) or last_high_idx >= track_low_idx) and not na(ta.pivotlow(low, ps, ps))
track_low := low[ps]
track_low_idx := bar_index - ps
bos_bear = false
bos_bull = false
mss_bear = false
mss_bull = false
change = false
var dwgs = dwg.new(array.new_label(), array.new_label(), array.new_line(), array.new_bool())
if ph.size() > 0
if close > ph.get(0)
label _label = na
label _phl = na
if show_labels
save = false
if label_type == 'MSS' and not bull
save := true
else if label_type == 'BOS' and bull
save := true
else if label_type == 'All'
save := true
if save
_label := label.new(math.floor(math.avg(time, pht.get(0))), ph.get(0), bull ? "AYILAR" : "BOĞALAR", xloc = xloc.bar_time, style = label.style_label_down, color = #ffffff00, textcolor = na)
if bull
bos_bull := true
else
mss_bull := true
_line = line.new(pht.get(0), ph.get(0), time, ph.get(0), color = na, xloc = xloc.bar_time, style = line.style_dashed)
bull := true
change := true
clear_all()
if not na(track_low)
if show_phl
_phl := label.new(time[bar_index - track_low_idx], track_low, "AL", xloc = xloc.bar_time, style = label.style_label_up, textcolor = color.yellow, color = #ffffff00)
pl.unshift(track_low)
plt.unshift(time[bar_index - track_low_idx])
last_high := na
dwgs.dwg_add(_label, _phl, _line, bull)
if pl.size() > 0
if close < pl.get(0)
label _label = na
label _phl = na
if show_labels
save = false
if label_type == 'MSS' and bull
save := true
else if label_type == 'BOS' and not bull
save := true
else if label_type == 'All'
save := true
if save
_label := label.new(math.floor(math.avg(time, plt.get(0))), pl.get(0), not bull ? "AYILAR" : "BOĞALAR", xloc = xloc.bar_time, style = label.style_label_up, color = #ffffff00, textcolor = na)
if not bull
bos_bear := true
else
mss_bear := true
_line = line.new(plt.get(0), pl.get(0), time, pl.get(0), color = na, xloc = xloc.bar_time, style = line.style_dashed)
bull := false
change := true
clear_all()
if not na(track_high)
if show_phl
_phl := label.new(time[bar_index - track_high_idx], track_high, "SAT", xloc = xloc.bar_time, style = label.style_label_down, textcolor = color.yellow, color = #ffffff00)
ph.unshift(track_high)
pht.unshift(time[bar_index - track_high_idx])
last_low := na
dwgs.dwg_add(_label, _phl, _line, bull)
if change[1]
if bos_bear[1] or mss_bear[1]
trail_price := track_high
trail_color := ph_color
else if bos_bull[1] or mss_bull[1]
trail_price := track_low
trail_color := pl_color
_bull = dwgs._bull.get(0)
dwgs._label.get(0).set_textcolor(_bull ? bull_color : bear_color)
dwgs._phl.get(0).set_textcolor(_bull ? pl_color : ph_color)
dwgs._line.get(0).set_color(_bull ? bull_color : bear_color)
//barcolor(color_trend ? (bull ? bull_color : bear_color) : na)
plot(trail_phl ? trail_price : na, color = trail_color, linewidth = trail_width)
alertcondition(bos_bear[1] or bos_bull[1], "BOS Any")
alertcondition(mss_bear[1] or mss_bull[1], "MSS Any")
alertcondition(bos_bear[1], "BOS Bear")
alertcondition(bos_bull[1], "BOS Bull")
alertcondition(mss_bear[1], "MSS Bear")
alertcondition(mss_bull[1], "MSS Bull")
//@version=5
import Steversteves/SPTS_StatsPakLib/1 as spts
t1 = "This will plot a line from the first Result to the last Result for the forecast length"
t2 = "Showing results and variances will plot both the results (blue) and the standard errors based on the variance in the dataset. Only plotting reuslts will only plot the most likely outcome without the variance."
// Inputs
src = input.source(close, "Forecast Source"), train = input.int(150, "Train Time"), len = input.int(14, "Forecast Length"),
typ = input.string("Line Plot", "Scatter Plot Type", ["Line Plot", "Scatter Plot"]), show_stats = input.bool(false, "Show Model Statistics")
line_bf = input.bool(true, "Show Trendline", tooltip = t1), show_others = input.string("Show Results Only","Show Results/Variance", ["Show Results and Variances", "Show Results Only"], tooltip = t2)
// Arrays
results = array.new_float()
ucl = array.new_float()
lcl = array.new_float()
// Forecast
[a, b, c] = spts.f_forecast(src, src[1], train, len, results, ucl, lcl)
// Model Statistics
cor = ta.correlation(src, src[len], train)
r2 = math.pow(cor,2)
max_val = array.max(ucl)
min_val = array.min(lcl)
// Plots
var table data = table.new(position.middle_right, 2, 6, bgcolor = color.blue, frame_color = color.rgb(0, 0, 0), frame_width = 4)
if show_stats
table.cell(data, 1, 1, text = "Model Data", bgcolor = color.blue, text_color = color.white)
table.cell(data, 1, 2, text = "Correlation: " + str.tostring(math.round(cor,2)), bgcolor = color.blue, text_color = color.white)
table.cell(data, 1, 3, text = "R2: " + str.tostring(math.round(r2, 3)), bgcolor = color.blue, text_color = color.white)
table.cell(data, 1, 4, text = "Max Forecasted Value: " + str.tostring(math.round(max_val, 2)), bgcolor = color.blue, text_color = color.white)
table.cell(data, 1, 5, text = "Min Forecasted Value: " + str.tostring(math.round(min_val, 2)), bgcolor = color.blue, text_color = color.white)
if barstate.islast and typ == "Line Plot"
for i = 0 to len
line.new(bar_index + i, y1 = array.get(results, i), x2 = bar_index + 1 + i, y2 = array.get(results, i), color = color.blue, width = 3)
if show_others == "Show Results and Variances"
line.new(bar_index + i, y1 = array.get(ucl, i), x2 = bar_index + 1 + i, y2 = array.get(ucl, i), color = color.lime, width = 3)
line.new(bar_index + i, y1 = array.get(lcl, i), x2 = bar_index + 1 + i, y2 = array.get(lcl, i), color = color.red, width = 3)
if barstate.islast and typ == "Scatter Plot"
for i = 0 to len
label.new(bar_index + i, array.get(results, i), text = "", color = color.blue, style = label.style_circle, size = size.tiny)
if show_others == "Show Results and Variances"
label.new(bar_index + i, array.get(ucl, i), text = "", color = color.lime, style = label.style_circle, size = size.tiny)
label.new(bar_index + i, array.get(lcl, i), text = "", color = color.red, style = label.style_circle, size = size.tiny)
var line trendline = na
if barstate.islast and line_bf
line.delete(trendline)
trendline := line.new(bar_index[1], y1 = array.get(results, 0), x2 = bar_index + array.size(results) - 1, y2 = array.get(results, array.size(results) - 1), color = color.purple, width = 3)
16.07.2024 - 10.12.2024
bu kod...
sar kullanarak....
barları renklendirir...
beyaz renk...konsilide...diğerleri belli.....
PHP Code:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © joelly3d
//All my scripts are part of a suite called Papercuts.
//Dual PSAR is a trend following script that uses auto-higher timeframe calculation of the current timeframe to create a dual Parabolic Stop And Release.
//This is useful because it can determine periods of transition or indecision and can flag those periods with which way it is learning even though it is undecided, what i call "Wait Zones".
//When both PSARS are not in alignment, it uses the lower timeframe one to determine which way the wait zone is learning.
//You can see below in the chart shows some good trends and some wait zones.
//A wait zone can have bullish indication, but then still have a bearish continuation.
//A wait zone can have bullish indication, and then enter a bull trend.
//Typically I won't make trades in wait zones, and I will exit trades when entering one.
//Just wanted to try this out and see how it did. Figured I'd share.
//@version=5
indicator('v01', overlay=true, max_bars_back=500)
//-----------------------------------------------------------------Shared Functions
//-----------------------------------------------------------------Shared Functions
//-----------------------------------------------------------------Shared Functions
// —————————————————————————————————————————
// ————— Function returning `_color` with `_transp` transparency.
// —————————————————————————————————————————
f_colorNew(_color, _transp) =>
var _r = color.r(_color)
var _g = color.g(_color)
var _b = color.b(_color)
color _return = color.rgb(_r, _g, _b, _transp)
_return
//automatic higher timeframe chooser
f_autoHTF(str) =>
str == '1S' or str == '5S' or str == '10S' or str == '15S' or str == '20S' or str == '30S' or str == '40S' or str == '45S' or str == '50S' ? '1' : str == '1' or str == '2' or str == '3' or str == '4' ? '5' : str == '5' or str == '10' ? '15' : str == '15' or str == '20' ? '30' : str == '30' or str == '45' or str == '50' ? '60' : str == '60' or str == '90' or str == '100' ? '120' : str == '120' or str == '180' ? '240' : str == '240' ? 'D' : str == 'D' ? 'W' : str == 'W' ? '2W' : 'M'
var string ticker = syminfo.tickerid
var string tfp = timeframe.period
htf1 = f_autoHTF(tfp)
htf2 = f_autoHTF(htf1)
htf3 = f_autoHTF(htf2)
htf4 = f_autoHTF(htf3)
f_security(_sym, _res, _src, _rep) =>
request.security(_sym, _res, _src[not _rep and barstate.isrealtime ? 1 : 0])[_rep or barstate.isrealtime ? 0 : 1]
//-----------------------------------------------------------------Shared Functions
//-----------------------------------------------------------------Shared Functions
//-----------------------------------------------------------------Shared Functions
/// --------------------------------------------- Dual Parabolic Stop and Reverse Options
//PSAR inputs
grpin = '⚙=====-----'
grpout = '-----=====⚙'
grpPSAR = grpin + 'Dual PSAR Options:' + grpout
colorBull = input.color(defval=#8afc07, group=grpPSAR, title='Bullish Color') //Light Blue
colorBear = input.color(defval=#fc0505, group=grpPSAR, title='Bearish Color') //yellow
colorWait = input.color(defval=#dbdbdb, group=grpPSAR, title='Wait Color') //grey
showRecolorCandles = input.bool(true, 'Show Trend Full-Candle Recoloring?', group=grpPSAR, tooltip='Recolor the full candle including wick and border with trend color.')
psar_start = input.float(defval=0, group=grpPSAR, title='PSAR: Start', minval=0, maxval=2, step=0.01)
psar_accel = input.float(defval=0.1, group=grpPSAR, title='PSAR: Acceleration Factor', minval=0.01, maxval=2, step=0.01)
psar_maximum = input.float(defval=0.1, group=grpPSAR, title='PSAR: Extreme Point', minval=0.01, maxval=2)
f_psar() =>
ta.sar(psar_start, psar_accel, psar_maximum)
psar_ctf = f_psar()
psar_htf = f_security(ticker, htf1, f_psar(), false)
longZone = psar_ctf < low and psar_htf < low
shortZone = psar_ctf > high and psar_htf > high
waitZone = not longZone and not shortZone
trendSupportColor = longZone ? colorBull : shortZone ? colorBear : colorWait
plotcandle(showRecolorCandles ? open : na, high, low, close, color=trendSupportColor, wickcolor=trendSupportColor, bordercolor=trendSupportColor, title='Plot Candles Trend-Recolor')
barcolor(trendSupportColor)
//plot when dual supported otherwise hide it
//plot(longZone ? low : shortZone ? high : na, color=color.new(longZone ? colorBull : shortZone ? colorBear : na, 50), style=plot.style_stepline, linewidth=3, title='Dual PSAR Support Line')
//plot(waitZone ? psar_ctf : na, color=color.new(psar_ctf < low ? colorBull : colorBear, 0), style=plot.style_circles, linewidth=7, title='Single PSAR Support Dots')
/// --------------------------------------------- Dual Parabolic Stop and Reverse Options
16.07.2024 - 10.12.2024
parabol sarı...
aynı anda onlu hesaplayan kod.....
PHP Code:
//@version=5
indicator('Parabolic Glitter', '.', overlay=true)
init = input.float(0.1, title='Initial Start', step=0.1)
fi = input.float(0.1, title='Increment/Start Ratio', step=0.1)
fm = input.float(0.2, title='Max/Start Ratio', step=0.1)
ac = input(false, title='Adaptive Coloring')
sar01 = ta.sar(init * 01, init * fi * 01, init * fm * 01)
sar02 = ta.sar(init * 02, init * fi * 02, init * fm * 02)
sar03 = ta.sar(init * 03, init * fi * 03, init * fm * 03)
sar04 = ta.sar(init * 04, init * fi * 04, init * fm * 04)
sar05 = ta.sar(init * 05, init * fi * 05, init * fm * 05)
sar06 = ta.sar(init * 06, init * fi * 06, init * fm * 06)
sar07 = ta.sar(init * 07, init * fi * 07, init * fm * 07)
sar08 = ta.sar(init * 08, init * fi * 08, init * fm * 08)
sar09 = ta.sar(init * 09, init * fi * 09, init * fm * 09)
sar10 = ta.sar(init * 10, init * fi * 10, init * fm * 10)
plot(sar01, title=' 01', style=plot.style_circles, color=ac ? sar01 > close ? color.rgb(255, 82, 82, 100) : color.rgb(76, 175, 79, 100) : color.silver, linewidth=1)
plot(sar02, title=' 02', style=plot.style_circles, color=ac ? sar02 > close ? color.rgb(255, 82, 82, 100) : color.rgb(76, 175, 79, 100) : color.silver, linewidth=1)
plot(sar03, title=' 03', style=plot.style_circles, color=ac ? sar03 > close ? color.rgb(255, 82, 82, 100) : color.rgb(76, 175, 79, 100) : color.silver, linewidth=1)
plot(sar04, title=' 04', style=plot.style_circles, color=ac ? sar04 > close ? color.rgb(255, 82, 82, 100) : color.rgb(76, 175, 79, 100) : color.silver, linewidth=1)
plot(sar05, title=' 05', style=plot.style_circles, color=ac ? sar05 > close ? color.fuchsia : color.white : color.silver, linewidth=3)
plot(sar06, title=' 06', style=plot.style_circles, color=ac ? sar06 > close ? color.rgb(255, 82, 82, 100) : color.rgb(76, 175, 79, 100) : color.silver, linewidth=1)
plot(sar07, title=' 07', style=plot.style_circles, color=ac ? sar07 > close ? color.rgb(255, 82, 82, 100) : color.rgb(76, 175, 79, 100) : color.silver, linewidth=1)
plot(sar08, title=' 08', style=plot.style_circles, color=ac ? sar08 > close ? color.rgb(255, 82, 82, 100) : color.rgb(76, 175, 79, 100) : color.silver, linewidth=1)
plot(sar09, title=' 09', style=plot.style_circles, color=ac ? sar09 > close ? color.rgb(255, 82, 82, 100) : color.rgb(76, 175, 79, 100) : color.silver, linewidth=1)
plot(sar10, title=' 10', style=plot.style_circles, color=ac ? sar10 > close ? color.rgb(255, 82, 82, 100) : color.rgb(76, 175, 79, 100) : color.silver, linewidth=1)
16.07.2024 - 10.12.2024
belirttiğiniz uzunluğa otomatik paralel çizdirir.....
trend kanalları gibi düşünün....PHP Code:
//@version=5
indicator('Parallel Pivot Lines [Firegenie]', overlay=true, max_bars_back=500)
// User Settings
length = input.int(50, group='Indicator Settings', tooltip='Pivot length. Higher values will connect to more significant pivots')
lookback = input.int(1, minval=1, group='Indicator Settings', tooltip='Number of lines connecting a pivot high/low')
Slope = input.float(1., minval=-1, maxval=1, step=0.01, group='Indicator Settings', tooltip='Multiplies the linear regression with a number between -1 and 1')
// Style Settings
ph_col = input.color(#2157f3, 'Pivot High Lines Colour', group='Style Settings')
pl_col = input.color(#ff1100, 'Pivot Low Lines Colour', group='Style Settings')
pm_col = input.color(#f6e017, 'Pivot Low Lines Colour', group='Style Settings')
// Functions
Sma(src, p) =>
a = ta.cum(src)
(a - a[math.max(p, 0)]) / math.max(p, 0)
Variance(src, p) =>
_sma = Sma(src * src, p)
p == 1 ? 0 : _sma - math.pow(Sma(src, p), 2)
Covariance(x, y, p) =>
Sma(x * y, p) - Sma(x, p) * Sma(y, p)
n = bar_index
ph = ta.pivothigh(length, length)
pl = ta.pivotlow(length, length)
varip ph_array = array.new_float(0)
varip pl_array = array.new_float(0)
varip ph_n_array = array.new_int(0)
varip pl_n_array = array.new_int(0)
if not na(ph)
array.insert(ph_array, 0, ph)
array.insert(ph_n_array, 0, n)
if not na(pl)
array.insert(pl_array, 0, pl)
array.insert(pl_n_array, 0, n)
val_ph = ta.valuewhen(not na(ph) , n - length, lookback - 1)
val_pl = ta.valuewhen(not na(pl) , n - length, lookback - 1)
val = math.min(val_ph, val_pl)
k = n - val > 0 ? n - val : 2
slope = Covariance(close, n, k) / Variance(n, k) * Slope
var line ph_l = na
var line pl_l = na
var line pm_l = na
if barstate.islast
for i = 0 to lookback - 1 by 1
ph_y2 = array.get(ph_array, i)
ph_x1 = array.get(ph_n_array, i) - length
pl_y2 = array.get(pl_array, i)
pl_x1 = array.get(pl_n_array, i) - length
ph_l := line.new(ph_x1, ph_y2, ph_x1 + 1, ph_y2 + slope, extend=extend.both, color=ph_col)
pl_l := line.new(pl_x1, pl_y2, pl_x1 + 1, pl_y2 + slope, extend=extend.both, color=pl_col)
pm_l := line.new((pl_x1 + ph_x1) / 2, (pl_y2 + ph_y2) / 2, (pl_x1 + 1 + ph_x1 + 1) / 2, (pl_y2 + slope + ph_y2 + slope) / 2, extend=extend.both, color=pm_col)
pm_l
16.07.2024 - 10.12.2024
pivot çizdirmece....
ama...
saatlik en yükseği.....seanslık en düşüğü.... ve 15 dakkalık kapanış kullanarak.....
destek ve dirençler için....
PHP Code:
//@version=5
////////////////////////////////////////////////////////////
// Copyright by HPotter v1.0 10/07/2014
// Pivot points simply took the high, low, and closing price from the previous period and
// divided by 3 to find the pivot. From this pivot, traders would then base their
// calculations for three support, and three resistance levels. The calculation for the most
// basic flavor of pivot points, known as ‘floor-trader pivots’, along with their support and
// resistance levels.
////////////////////////////////////////////////////////////
indicator(title='Pivot Point', shorttitle='Pivot Point', overlay=true)
width = input.int(1, minval=1)
xHigh = request.security(syminfo.tickerid, '60', high[1])
xLow = request.security(syminfo.tickerid, '240', low[1])
xClose = request.security(syminfo.tickerid, '15', close[1])
vPP = (xHigh + xLow + xClose) / 3
vR1 = vPP + vPP - xLow
vS1 = vPP - (xHigh - vPP)
vR2 = vPP + xHigh - xLow
vS2 = vPP - (xHigh - xLow)
vR3 = xHigh + 2 * (vPP - xLow)
vS3 = xLow - 2 * (xHigh - vPP)
plot(vS1, color=color.new(#ff0000, 0), title='S1', style=plot.style_steplinebr, linewidth=width)
plot(vS2, color=color.new(#ff002a, 0), title='S2', style=plot.style_steplinebr, linewidth=width)
plot(vS3, color=color.new(#ff014a, 0), title='S3', style=plot.style_steplinebr, linewidth=width)
plot(vR1, color=color.new(#009600, 0), title='R1', style=plot.style_steplinebr, linewidth=width)
plot(vR2, color=color.new(#006F00, 0), title='R2', style=plot.style_steplinebr, linewidth=width)
plot(vR3, color=color.new(#004900, 0), title='R3', style=plot.style_steplinebr, linewidth=width)
16.07.2024 - 10.12.2024
Yer İmleri