eyvallah...inş....işine yarar bir şeyler çıkar....
eski çalışmalarım ve yenileri....
buraya yedekleyerek paylaşacağım.....
Printable View
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))
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)
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)
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
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)
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
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)
saatlik pivota...seanslık kanallama.....ve sağ 5...sol 3...işaretleme....
PHP Code:
//@version=5
indicator(title='Pivot Points High Low Extension', shorttitle='.', overlay=true)
pvtLenL = input.int(5, minval=1, title='Pivot Length Left Hand Side')
pvtLenR = input.int(3, minval=1, title='Pivot Length Right Hand Side')
maxLvlLen = input.int(0, minval=0, title='Maximum Extension Length')
ShowHHLL = input(false, title='Show HH,LL,LH,HL Markers On Pivots Points')
WaitForClose = input(false, title='Wait For Candle Close Before Printing Pivot')
// Get High and Low Pivot Points
pvthi_ = ta.pivothigh(high, pvtLenL, pvtLenR)
pvtlo_ = ta.pivotlow(low, pvtLenL, pvtLenR)
// Force Pivot completion before plotting.
Shunt = WaitForClose ? 1 : 0
pvthi = pvthi_[Shunt]
pvtlo = pvtlo_[Shunt]
// ||-----------------------------------------------------------------------------------------------------||
// ||--- Higher Highs, Lower Highs, Higher Lows, Lower Lows -------------------------------------------||
valuewhen_1 = ta.valuewhen(pvthi, high[pvtLenR + Shunt], 1)
valuewhen_2 = ta.valuewhen(pvthi, high[pvtLenR + Shunt], 0)
higherhigh = na(pvthi) ? na : valuewhen_1 < valuewhen_2 ? pvthi : na
valuewhen_3 = ta.valuewhen(pvthi, high[pvtLenR + Shunt], 1)
valuewhen_4 = ta.valuewhen(pvthi, high[pvtLenR + Shunt], 0)
lowerhigh = na(pvthi) ? na : valuewhen_3 > valuewhen_4 ? pvthi : na
valuewhen_5 = ta.valuewhen(pvtlo, low[pvtLenR + Shunt], 1)
valuewhen_6 = ta.valuewhen(pvtlo, low[pvtLenR + Shunt], 0)
higherlow = na(pvtlo) ? na : valuewhen_5 < valuewhen_6 ? pvtlo : na
valuewhen_7 = ta.valuewhen(pvtlo, low[pvtLenR + Shunt], 1)
valuewhen_8 = ta.valuewhen(pvtlo, low[pvtLenR + Shunt], 0)
lowerlow = na(pvtlo) ? na : valuewhen_7 > valuewhen_8 ? pvtlo : na
plot(not ShowHHLL ? pvthi : na, title='PH *', style=plot.style_cross, ****=false, color=color.new(color.red, 0), offset=-pvtLenR - Shunt, linewidth=4)
plot(not ShowHHLL ? pvtlo : na, title='PL *', style=plot.style_cross, ****=false, color=color.new(color.lime, 0), offset=-pvtLenR - Shunt, linewidth=4)
width = input.int(1, minval=1)
xHigh = request.security(syminfo.tickerid, '60', high[1])
xLow = request.security(syminfo.tickerid, '60', 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, 100), title='S1', style=plot.style_steplinebr, linewidth=width)
plot(vS2, color=color.new(#ff002a, 100), title='S2', style=plot.style_steplinebr, linewidth=width)
plot(vS3, color=color.new(#ff014a, 100), title='S3', style=plot.style_steplinebr, linewidth=width)
plot(vR1, color=color.new(#009600, 100), title='R1', style=plot.style_steplinebr, linewidth=width)
plot(vR2, color=color.new(#006F00, 100), title='R2', style=plot.style_steplinebr, linewidth=width)
plot(vR3, color=color.new(#004900, 100), title='R3', style=plot.style_steplinebr, linewidth=width)
//@version=5
Base = input.timeframe(title='Larger Res than Chart', defval='240')
breakline = input(title='Breaks in lines', defval=true)
so = request.security(syminfo.tickerid, Base, open)
sh = request.security(syminfo.tickerid, Base, high)
sl = request.security(syminfo.tickerid, Base, low)
sc = request.security(syminfo.tickerid, Base, close)
br = so != so[1] and sc != sc[1] and sh != sh[1] and sl != sl[1] and breakline == true ? 1 : na
col = so > sc ? color.red : color.green
a1 = na(br) ? so : na
a2 = na(br) ? sh : na
a3 = na(br) ? sl : na
a4 = na(br) ? sc : na
p1 = plot(a1, 'Open', color.new(color.white, 0), style=plot.style_linebr)
p2 = plot(a2, 'High', color.new(color.black, 75), style=plot.style_linebr)
p3 = plot(a3, 'Low', color.new(color.black, 75), style=plot.style_linebr)
p4 = plot(a4, 'Close', col, style=plot.style_linebr)
fill(p1, p4, col, transp=25)
fill(p2, p3, color.new(color.silver, 65))
pivotla trend hesaplama...ama mtf olarak....
ve altta periyotların durumunu göreme...al-sat-nötr şeklinde.....
bu arada barları renklendşirir.....
PHP Code:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © theGary
//@version=5
indicator("Price-Action Candles", overlay = true, max_bars_back = 100)
// inputs
sdLength = input.int(3, title = 'Price-Action Length', minval = 2, maxval = 100)
labelType = input.string('Repaint', title = 'Label Type', options = ['Repaint', 'No-Repaint'])
candleType = input.string('Fill Only', title = 'Candle Color Type', options = ['Entire Candle', 'Fill Only'])
bullCSS = input.color(color.lime, title = 'Bull')
bearCSS = input.color(color.rgb(255, 0, 0), title = 'Bear')
neutCSS = input.color(color.yellow, title = 'Neutral')
useTrendTable = input.bool(true, title = 'Enabled', group = 'MTF Trend')
use_mtf1 = input.bool(true, title = 'MTF 1', group = 'MTF Trend', inline = '1')
mtf_1 = input.timeframe("1", title = '', group = 'MTF Trend', inline = '1')
use_mtf2 = input.bool(true, title = 'MTF 2', group = 'MTF Trend', inline = '2')
mtf_2 = input.timeframe("3", title = '', group = 'MTF Trend', inline = '2')
use_mtf3 = input.bool(true, title = 'MTF 3', group = 'MTF Trend', inline = '3')
mtf_3 = input.timeframe("5", title = '', group = 'MTF Trend', inline = '3')
use_mtf4 = input.bool(true, title = 'MTF 4', group = 'MTF Trend', inline = '4')
mtf_4 = input.timeframe("15", title = '', group = 'MTF Trend', inline = '4')
use_mtf5 = input.bool(true, title = 'MTF 5', group = 'MTF Trend', inline = '5')
mtf_5 = input.timeframe("60", title = '', group = 'MTF Trend', inline = '5')
// functions
f_getSwingValues(sdLength, offset) =>
sh = ta.pivothigh(high, sdLength, sdLength)
sl = ta.pivotlow(low, sdLength, sdLength)
csh = ta.valuewhen(not na(sh), high[sdLength], 0)
csl = ta.valuewhen(not na(sl), low[sdLength], 0)
psh = ta.valuewhen(not na(sh), high[sdLength], 1)
psl = ta.valuewhen(not na(sl), low[sdLength], 1)
hh = sh >= psh
lh = sh < psh
ll = sl <= psl
hl = sl > psl
var int trend = na
trend := ((hh and high >= psh) or close > csh) ? 1 : ((ll and low <= psl) or close < csl) ? -1 : lh or hl ? 0 : trend[1]
var int last_signal = na
last_signal := hh ? 2 : lh ? -1 : ll ? -2 : hl ? 1 : last_signal[1]
[sh[offset], sl[offset], psh[offset], psl[offset], csh[offset], csl[offset], hh[offset], lh[offset], ll[offset], hl[offset], trend[offset], last_signal[offset]]
// calculate chart tf
[sh, sl, psh, psl, csh, csl, hh, lh, ll, hl, trend, last_signal] =
request.security(syminfo.tickerid, "", f_getSwingValues(sdLength, 0))
plotshape(ll and not na(sl), text="LL", title="Lower Low", style=shape.labelup, display = display.none,
color=bearCSS, textcolor=color.black, location=location.belowbar, offset = labelType == 'Repaint' ? -sdLength : 0)
plotshape(hl and not na(sl), text="HL", title="Higher Low", style=shape.labelup, display = display.none,
color=neutCSS, textcolor=color.black, location=location.belowbar, offset = labelType == 'Repaint' ? -sdLength : 0)
plotshape(hh and not na(sh), text="HH", title="Higher High", style=shape.labeldown, display = display.none,
color=bullCSS, textcolor=color.black, location=location.abovebar, offset = labelType == 'Repaint' ? -sdLength : 0)
plotshape(lh and not na(sh), text="LH", title="Lower High", style=shape.labeldown, display = display.none,
color=neutCSS, textcolor=color.black, location=location.abovebar, offset = labelType == 'Repaint' ? -sdLength : 0)
barCSS = trend == 1 ? bullCSS
: trend == -1 ? bearCSS
: neutCSS
barcolor(candleType != 'Fill Only' ? na
: barCSS, editable = false)
plotcandle(open, high, low, close, title = 'Price Action Candles',
color = barCSS, wickcolor = barCSS, bordercolor = barCSS,
display = candleType == 'Entire Candle' ? display.all : display.none, editable = false)
// calculate mtf
f_ltf_values(tf) =>
var int returnTrend = na
adjusted_timeframe = timeframe.in_seconds(tf) >= timeframe.in_seconds() ? '' : tf
[ltf_sh, ltf_sl, ltf_psh, ltf_psl, ltf_csh, ltf_csl, ltf_hh, ltf_lh, ltf_ll, ltf_hl, ltf_trend, ltf_last_signal] =
request.security_lower_tf(syminfo.tickerid, adjusted_timeframe, f_getSwingValues(sdLength, 0))
if array.size(ltf_trend) > 0
returnTrend := array.last(ltf_trend)
else
returnTrend := 0
returnTrend
f_htf_values(tf) =>
[htf_sh, htf_sl, htf_psh, htf_psl, htf_csh, htf_csl, htf_hh, htf_lh, htf_ll, htf_hl, htf_trend, htf_last_signal] =
request.security(syminfo.tickerid, tf, f_getSwingValues(sdLength, 1), lookahead = barmerge.lookahead_on)
htf_trend
f_sametf_values() =>
[sametf_sh, sametf_sl, sametf_psh, sametf_psl, sametf_csh, sametf_csl, sametf_hh, sametf_lh, sametf_ll, sametf_hl, sametf_trend, sametf_last_signal] =
f_getSwingValues(sdLength, 0)
sametf_trend
var int mtf1_trend = na
var int mtf2_trend = na
var int mtf3_trend = na
var int mtf4_trend = na
var int mtf5_trend = na
if barstate.islast
if use_mtf1
if timeframe.in_seconds() == timeframe.in_seconds(mtf_1)
mtf1_trend := f_sametf_values()
else if timeframe.in_seconds() > timeframe.in_seconds(mtf_1)
mtf1_trend := f_ltf_values(mtf_1)
else
mtf1_trend := f_htf_values(mtf_1)
if use_mtf2
if timeframe.in_seconds() == timeframe.in_seconds(mtf_2)
mtf2_trend := f_sametf_values()
else if timeframe.in_seconds() > timeframe.in_seconds(mtf_2)
mtf2_trend := f_ltf_values(mtf_2)
else
mtf2_trend := f_htf_values(mtf_2)
if use_mtf3
if timeframe.in_seconds() == timeframe.in_seconds(mtf_3)
mtf3_trend := f_sametf_values()
else if timeframe.in_seconds() > timeframe.in_seconds(mtf_3)
mtf3_trend := f_ltf_values(mtf_3)
else
mtf3_trend := f_htf_values(mtf_3)
if use_mtf4
if timeframe.in_seconds() == timeframe.in_seconds(mtf_4)
mtf4_trend := f_sametf_values()
else if timeframe.in_seconds() > timeframe.in_seconds(mtf_4)
mtf4_trend := f_ltf_values(mtf_4)
else
mtf4_trend := f_htf_values(mtf_4)
if use_mtf5
if timeframe.in_seconds() == timeframe.in_seconds(mtf_5)
mtf5_trend := f_sametf_values()
else if timeframe.in_seconds() > timeframe.in_seconds(mtf_5)
mtf5_trend := f_ltf_values(mtf_5)
else
mtf5_trend := f_htf_values(mtf_5)
// table
if barstate.islast and useTrendTable
var trendTable = table.new(position = position.bottom_right, columns = 5, rows = 1, border_width = 1, border_color = color.black, frame_width = 2, frame_color = color.black)
if use_mtf1
table.cell(trendTable, 0, 0, text = str.tostring(mtf_1), text_color = color.black,
bgcolor = color.new(mtf1_trend == 1 ? bullCSS : mtf1_trend == -1 ? bearCSS : neutCSS, 0))
if use_mtf2
table.cell(trendTable, 1, 0, text = str.tostring(mtf_2), text_color = color.black,
bgcolor = color.new(mtf2_trend == 1 ? bullCSS : mtf2_trend == -1 ? bearCSS : neutCSS, 0))
if use_mtf3
table.cell(trendTable, 2, 0, text = str.tostring(mtf_3), text_color = color.black,
bgcolor = color.new(mtf3_trend == 1 ? bullCSS : mtf3_trend == -1 ? bearCSS : neutCSS, 0))
if use_mtf4
table.cell(trendTable, 3, 0, text = str.tostring(mtf_4), text_color = color.black,
bgcolor = color.new(mtf4_trend == 1 ? bullCSS : mtf4_trend == -1 ? bearCSS : neutCSS, 0))
if use_mtf5
table.cell(trendTable, 4, 0, text = str.tostring(mtf_5), text_color = color.black,
bgcolor = color.new(mtf5_trend == 1 ? bullCSS : mtf5_trend == -1 ? bearCSS : neutCSS, 0))
bu kurcalanmalı....bence...
PHP Code:
// 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
indicator("Protected Highs & Lows [TFO]", "Protected Highs & Lows [TFO]", true, max_lines_count = 500, max_labels_count = 500, max_boxes_count = 500)
var g_STR = "Structure"
ps = input.int(0, "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("MSS", "", 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(true, "Show Protected Trail", inline = "TRAIL", group = g_PHL)
trail_width = input.int(1, "", inline = "TRAIL", group = g_PHL)
var g_PB = "Pullbacks"
use_valid_pbs = input.bool(true, "Use Valid Pullback Criteria", tooltip = "When looking at the swing high that price must close above for a BOS/MSS, in order to form a valid protected low, price must first close below the low of the candle that made the swing high (and vice versa for protected highs)", group = g_PB)
extra_valid_pbs = input.bool(false, "Specific Pullback Candle Criteria", tooltip = "When 'Use Valid Pullback Criteria' is enabled, if a given swing high is formed with a down close candle, the script will look backward to find the most recent up-close candle. Using this candle, price must close below its low to validate a pullback from a swing high (and vice versa)", group = g_PB)
ph_color = input.color(#f23645, "", inline = "PHL", group = g_PHL)
pl_color = input.color(color.blue, "", inline = "PHL", group = g_PHL)
bull_color = input.color(color.teal, "", inline = "TREND", group = g_STR)
bear_color = input.color(#f23645, "", inline = "TREND", group = g_STR)
var g_RET = "Retracements"
show_rets = input.bool (true, "Show Retracements", tooltip = "Show retracements of the previous zone with 30, 50, and 70% retracement levels", group = g_RET)
box_transp = input.int(100, "Box Transparency", 0, 100, tooltip = "Larger values will make the retracement box more transparent", group = g_RET)
line_w = input.int(1, "Line Width", 0, 10, group = g_RET)
line_s = input.string('Dotted', "Line Style", options = ['Solid', 'Dashed', 'Dotted'], group = g_RET)
var style = switch line_s
'Solid' => line.style_solid
'Dashed' => line.style_dashed
'Dotted' => line.style_dotted
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 pb
float price
int idx
bool valid = false
bool bull
type snd
box _box
line _30
line _50
line _70
type dwg
label[] _label
label[] _phl
line[] _line
bool[] _bull
method snd_add(snd s, float _high, float _low, bool bull) =>
_30 = (_high - _low) * 0.1 + _low
_50 = (_high - _low) * 0.3 + _low
_70 = (_high - _low) * 0.5 + _low
s._box := box.new(time, _high, time, _low, xloc = xloc.bar_time, border_color = na, bgcolor = na)
s._30 := line.new(time, _30, time, _30, xloc = xloc.bar_time, color = na, style = style, width = line_w)
s._50 := line.new(time, _50, time, _50, xloc = xloc.bar_time, color = na, style = style, width = line_w)
s._70 := line.new(time, _70, time, _70, xloc = xloc.bar_time, color = na, style = style, width = line_w)
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)
method pb_set(pb p, float P, int I) =>
p.price := P
p.idx := I
p.valid := false
clear_all() =>
pl.clear()
plt.clear()
ph.clear()
pht.clear()
var pb_from_high = pb.new(bull = true)
var pb_from_low = pb.new(bull = false)
if ta.pivotlow(low, ps, ps) and pl.size() == 0
pl.unshift(low[ps])
plt.unshift(time[ps])
if extra_valid_pbs
for i = 0 to 3
if close[ps + i] < open[ps + i]
pb_set(pb_from_low, high[ps + i], bar_index)
break
else
pb_set(pb_from_low, high[ps], bar_index)
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 extra_valid_pbs
for i = 0 to 3
if close[ps + i] > open[ps + i]
pb_set(pb_from_high, low[ps + i], bar_index)
break
else
pb_set(pb_from_high, low[ps], bar_index)
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
check_pb(pb p) =>
if p.bull
if close < p.price and p.valid == false
p.valid := true
else
if close > p.price and p.valid == false
p.valid := true
check_pb(pb_from_high)
check_pb(pb_from_low)
if (high[ps] > track_high or na(track_high) or last_low_idx >= track_high_idx) and not na(ta.pivothigh(high, ps, ps)) and (use_valid_pbs ? pb_from_low.valid == true : true)
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)) and (use_valid_pbs ? pb_from_high.valid == true : true)
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())
var snd = snd.new()
maintain(snd s) =>
if not na(s._box)
s._box.set_right(time)
s._30.set_x2(time)
s._50.set_x2(time)
s._70.set_x2(time)
maintain(snd)
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 ? "BOS" : "MSS", xloc = xloc.bar_time, style = label.style_label_down, color = #ffffff00, textcolor = na)
if bull
bos_bull := true
else
mss_bull := true
if show_rets and (use_valid_pbs ? pb_from_high.valid == true : true)
snd.snd_add(ph.get(0), track_low, 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, "▲", xloc = xloc.bar_time, style = label.style_label_up, textcolor = na, 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 ? "BOS" : "MSS", xloc = xloc.bar_time, style = label.style_label_up, color = #ffffff00, textcolor = na)
if not bull
bos_bear := true
else
mss_bear := true
if show_rets and (use_valid_pbs ? pb_from_low.valid == true : true)
snd.snd_add(pl.get(0), track_high, false)
_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, "▼", xloc = xloc.bar_time, style = label.style_label_down, textcolor = na, 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)
snd._box.set_bgcolor(color.new(bull ? bull_color : bear_color, box_transp))
snd._30.set_color(_bull ? bull_color : bear_color)
snd._50.set_color(_bull ? bull_color : bear_color)
snd._70.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)
20-50 ema....ama sentinelli...
PHP Code:
fi(ki)=>'ra'
// © fikira This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// @version=5
indicator ( "Sentinels"
, overlay=true
)
_ = '
Settings
------------- '
typeMA1 = input.string( "EMA" , 'Type' , options=["SMA", "EMA", "SMMA (RMA)", "HullMA", "WMA", "VWMA", "DEMA", "TEMA", "NONE"], group= 'MA 1' )
len1 = input.int ( 20 , 'Length' , group= 'MA 1' )
typeMA2 = input.string( "EMA" , 'Type' , options=["SMA", "EMA", "SMMA (RMA)", "HullMA", "WMA", "VWMA", "DEMA", "TEMA", "NONE"], group= 'MA 2' )
len2 = input.int ( 50 , 'Length' , group= 'MA 2' )
tentacles = input.bool ( true , '' , inline= '1', group='tentacles')
typeMA3 = input.string( "EMA" ,'******' , inline= '1'
, options=["SMA", "EMA", "SMMA (RMA)", "HullMA", "WMA", "VWMA", "DEMA", "TEMA", "NONE"], group='tentacles')
UpCol1 = input.color (color.rgb( 5, 250, 131 ), "" , inline= '1', group = '***********Head************-**Tentacles')
UpCol2 = input.color (color.rgb(255, 176, 6, 80), "" , inline= '1', group = '***********Head************-**Tentacles')
UpCol3 = input.color (color.rgb( 14, 236, 243, 37),"*-**", inline= '1', group = '***********Head************-**Tentacles')
DnCol1 = input.color (color.rgb(255, 0, 0 ), "" , inline= '2', group = '***********Head************-**Tentacles')
DnCol2 = input.color (color.rgb(255, 176, 6, 80), "" , inline= '2', group = '***********Head************-**Tentacles')
DnCol3 = input.color (color.rgb(243, 25, 255, 37),"*-**", inline= '2', group = '***********Head************-**Tentacles')
_ = '
Methods
----------- '
method ma(string type, int length) =>
//
ema1 = ta.ema(close, length)
ema2 = ta.ema(ema1 , length)
ema3 = ta.ema(ema2 , length)
//
switch type
"SMA" => ta.sma (close, length)
"EMA" => ema1
"SMMA (RMA)" => ta.rma (close, length)
"HullMA" => ta.hma (close, length)
"WMA" => ta.wma (close, length)
"sar" => ta.ema(close, length)
"DEMA" => 2 * ema1 - ema2
"TEMA" => (3 * ema1) - (3 * ema2) + ema3
=> na
method cond(int count, int n1, int n2) => count >= n1 and count <= n2
_ = '
Calculations
-------------- '
ma1 = typeMA1.ma(len1)
ma2 = typeMA2.ma(len2)
trigUp = ta.crossover (ma1, ma2), bsUp = ta.barssince(trigUp)
trigDn = ta.crossunder(ma1, ma2), bsDn = ta.barssince(trigDn)
UpR1 = color.r(UpCol1), UpG1 = color.g(UpCol1), UpB1 = color.b(UpCol1), UpT1 = color.t(UpCol1)
UpR2 = color.r(UpCol2), UpG2 = color.g(UpCol2), UpB2 = color.b(UpCol2), UpT2 = color.t(UpCol2)
DnR1 = color.r(DnCol1), DnG1 = color.g(DnCol1), DnB1 = color.b(DnCol1), DnT1 = color.t(DnCol1)
DnR2 = color.r(DnCol2), DnG2 = color.g(DnCol2), DnB2 = color.b(DnCol2), DnT2 = color.t(DnCol2)
TupMn = math.min(UpT1, UpT2), TupMx = math.max(UpT1, UpT2)
TdnMn = math.min(DnT1, DnT2), TdnMx = math.max(DnT1, DnT2)
Rdn = (DnR1 - DnR2) / 12, Rup = (UpR1 - UpR2) / 12
Gdn = (DnG1 - DnG2) / 12, Gup = (UpG1 - UpG2) / 12
Bdn = (DnB1 - DnB2) / 12, Bup = (UpB1 - UpB2) / 12
Tup = (TupMx - TupMn) / 12, Tdn = (TdnMx - TdnMn) / 12
_ = '
Sentinels
-------------- '
plot(bsUp.cond( 0, 1) ? ma1 : na, '', color= color.rgb(UpR1 - (Rup * 0), UpG1 - (Gup * 0), UpB1 - (Bup * 0), TupMn + (Tup * 0)), style=plot.style_linebr, linewidth=7)
plot(bsUp.cond( 1, 2) ? ma1 : na, '', color= color.rgb(UpR1 - (Rup * 1), UpG1 - (Gup * 1), UpB1 - (Bup * 1), TupMn + (Tup * 1)), style=plot.style_linebr, linewidth=6)
plot(bsUp.cond( 2, 5) ? ma1 : na, '', color=bsUp < 3 ? color.rgb(UpR1 - (Rup * 2), UpG1 - (Gup * 2), UpB1 - (Bup * 2), TupMn + (Tup * 2))
: color.rgb(UpR1 - (Rup * 3), UpG1 - (Gup * 3), UpB1 - (Bup * 3), TupMn + (Tup * 3)), style=plot.style_linebr, linewidth=5)
plot(bsUp.cond( 5, 11) ? ma1 : na, '', color=bsUp < 7 ? color.rgb(UpR1 - (Rup * 4), UpG1 - (Gup * 4), UpB1 - (Bup * 4), TupMn + (Tup * 4))
: color.rgb(UpR1 - (Rup * 5), UpG1 - (Gup * 5), UpB1 - (Bup * 5), TupMn + (Tup * 5)), style=plot.style_linebr, linewidth=4)
plot(bsUp.cond(11, 27) ? ma1 : na, '', color=bsUp < 18 ? color.rgb(UpR1 - (Rup * 6), UpG1 - (Gup * 6), UpB1 - (Bup * 6), TupMn + (Tup * 6))
: color.rgb(UpR1 - (Rup * 7), UpG1 - (Gup * 7), UpB1 - (Bup * 7), TupMn + (Tup * 7)), style=plot.style_linebr, linewidth=3)
plot(bsUp.cond(27, 40) ? ma1 : na, '', color=bsUp < 30 ? color.rgb(UpR1 - (Rup * 8), UpG1 - (Gup * 8), UpB1 - (Bup * 8), TupMn + (Tup * 8))
: color.rgb(UpR1 - (Rup * 9), UpG1 - (Gup * 9), UpB1 - (Bup * 9), TupMn + (Tup * 9)), style=plot.style_linebr, linewidth=2)
plot(bsUp.cond(40, 60) ? ma1 : na, '', color=bsUp < 50 ? color.rgb(UpR1 - (Rup * 10), UpG1 - (Gup * 10), UpB1 - (Bup * 10), TupMn + (Tup * 10))
: color.rgb(UpR1 - (Rup * 11), UpG1 - (Gup * 11), UpB1 - (Bup * 11), TupMn + (Tup * 11)), style=plot.style_linebr, linewidth=1)
plot(bsDn.cond( 0, 1) ? ma2 : na, '', color= color.rgb(DnR1 - (Rdn * 0), DnG1 - (Gdn * 0), DnB1 - (Bdn * 0), TdnMn + (Tdn * 0)), style=plot.style_linebr, linewidth=7)
plot(bsDn.cond( 1, 2) ? ma2 : na, '', color= color.rgb(DnR1 - (Rdn * 1), DnG1 - (Gdn * 1), DnB1 - (Bdn * 1), TdnMn + (Tdn * 1)), style=plot.style_linebr, linewidth=6)
plot(bsDn.cond( 2, 5) ? ma2 : na, '', color=bsDn < 3 ? color.rgb(DnR1 - (Rdn * 2), DnG1 - (Gdn * 2), DnB1 - (Bdn * 2), TdnMn + (Tdn * 2))
: color.rgb(DnR1 - (Rdn * 3), DnG1 - (Gdn * 3), DnB1 - (Bdn * 3), TdnMn + (Tdn * 3)), style=plot.style_linebr, linewidth=5)
plot(bsDn.cond( 5, 11) ? ma2 : na, '', color=bsDn < 7 ? color.rgb(DnR1 - (Rdn * 4), DnG1 - (Gdn * 4), DnB1 - (Bdn * 4), TdnMn + (Tdn * 4))
: color.rgb(DnR1 - (Rdn * 5), DnG1 - (Gdn * 5), DnB1 - (Bdn * 5), TdnMn + (Tdn * 5)), style=plot.style_linebr, linewidth=4)
plot(bsDn.cond(11, 27) ? ma2 : na, '', color=bsDn < 18 ? color.rgb(DnR1 - (Rdn * 6), DnG1 - (Gdn * 6), DnB1 - (Bdn * 6), TdnMn + (Tdn * 6))
: color.rgb(DnR1 - (Rdn * 7), DnG1 - (Gdn * 7), DnB1 - (Bdn * 7), TdnMn + (Tdn * 7)), style=plot.style_linebr, linewidth=3)
plot(bsDn.cond(27, 40) ? ma2 : na, '', color=bsDn < 30 ? color.rgb(DnR1 - (Rdn * 8), DnG1 - (Gdn * 8), DnB1 - (Bdn * 8), TdnMn + (Tdn * 8))
: color.rgb(DnR1 - (Rdn * 9), DnG1 - (Gdn * 9), DnB1 - (Bdn * 9), TdnMn + (Tdn * 9)), style=plot.style_linebr, linewidth=2)
plot(bsDn.cond(40, 60) ? ma2 : na, '', color=bsDn < 50 ? color.rgb(DnR1 - (Rdn * 10), DnG1 - (Gdn * 10), DnB1 - (Bdn * 10), TdnMn + (Tdn * 10))
: color.rgb(DnR1 - (Rdn * 11), DnG1 - (Gdn * 11), DnB1 - (Bdn * 11), TdnMn + (Tdn * 11)), style=plot.style_linebr, linewidth=1)
plotshape(bsUp == 0 ? ma1 : na, '', color= chart.fg_color , location=location.absolute, style=shape.circle, size=size.tiny )
plotshape(bsUp == 0 ? ma1 : na, '', color=color.new(chart.fg_color, 75), location=location.absolute, style=shape.circle, size=size.small )
plotshape(bsUp == 0 ? ma1 : na, '', color=color.new(chart.fg_color, 85), location=location.absolute, style=shape.circle, size=size.normal)
plotshape(bsDn == 0 ? ma2 : na, '', color= chart.fg_color , location=location.absolute, style=shape.circle, size=size.tiny )
plotshape(bsDn == 0 ? ma2 : na, '', color=color.new(chart.fg_color, 75), location=location.absolute, style=shape.circle, size=size.small )
plotshape(bsDn == 0 ? ma2 : na, '', color=color.new(chart.fg_color, 85), location=location.absolute, style=shape.circle, size=size.normal)
diff = math.round((len2 - len1) / 6)
vwma1 = typeMA3.ma(len1 + diff * 1)
vwma2 = typeMA3.ma(len1 + diff * 2)
vwma3 = typeMA3.ma(len1 + diff * 3)
vwma4 = typeMA3.ma(len1 + diff * 4)
vwma5 = typeMA3.ma(len1 + diff * 5)
vwma6 = typeMA3.ma(len1 + diff * 6)
plot(tentacles ? bsDn > 0 and bsDn <= 15 ? bsDn < 3 ? ma2 : vwma1 : na : na, '', color=DnCol3, style=plot.style_linebr)
plot(tentacles ? bsDn > 0 and bsDn <= 20 ? bsDn < 3 ? ma2 : vwma2 : na : na, '', color=DnCol3, style=plot.style_linebr)
plot(tentacles ? bsDn > 0 and bsDn <= 25 ? bsDn < 3 ? ma2 : vwma3 : na : na, '', color=DnCol3, style=plot.style_linebr)
plot(tentacles ? bsDn > 0 and bsDn <= 30 ? bsDn < 3 ? ma2 : vwma4 : na : na, '', color=DnCol3, style=plot.style_linebr)
plot(tentacles ? bsDn > 0 and bsDn <= 35 ? bsDn < 3 ? ma2 : vwma5 : na : na, '', color=DnCol3, style=plot.style_linebr)
plot(tentacles ? bsDn > 0 and bsDn <= 40 ? bsDn < 3 ? ma2 : vwma6 : na : na, '', color=DnCol3, style=plot.style_linebr)
plot(tentacles ? bsUp > 0 and bsUp <= 15 ? bsUp < 3 ? ma1 : vwma1 : na : na, '', color=UpCol3, style=plot.style_linebr)
plot(tentacles ? bsUp > 0 and bsUp <= 20 ? bsUp < 3 ? ma1 : vwma2 : na : na, '', color=UpCol3, style=plot.style_linebr)
plot(tentacles ? bsUp > 0 and bsUp <= 25 ? bsUp < 3 ? ma1 : vwma3 : na : na, '', color=UpCol3, style=plot.style_linebr)
plot(tentacles ? bsUp > 0 and bsUp <= 30 ? bsUp < 3 ? ma1 : vwma4 : na : na, '', color=UpCol3, style=plot.style_linebr)
plot(tentacles ? bsUp > 0 and bsUp <= 35 ? bsUp < 3 ? ma1 : vwma5 : na : na, '', color=UpCol3, style=plot.style_linebr)
plot(tentacles ? bsUp > 0 and bsUp <= 40 ? bsUp < 3 ? ma1 : vwma6 : na : na, '', color=UpCol3, style=plot.style_linebr)
_ = '
-------------- '
son 16 barı...ikili gruplar....ve açılış ile kapanışı hesaplar...
kapanışa göre renklendirir....
pozitif momentumu bulut şeklinde gösterir....
PHP Code:
//@version=5
indicator('Squeeze TD', shorttitle='.', overlay=true, precision=2)
length = input.int(20, "TTM Squeeze Length")
//BOLLINGER BANDS
BB_mult = input.float(2.0, "Bollinger Band STD Multiplier")
BB_basis = ta.sma(close, length)
dev = BB_mult * ta.stdev(close, length)
BB_upper = BB_basis + dev
BB_lower = BB_basis - dev
atr = ta.atr(14)
//KELTNER CHANNELS
KC_mult_high = input.float(1.0, "Keltner Channel #1")
KC_mult_mid = input.float(1.5, "Keltner Channel #2")
KC_mult_low = input.float(2.0, "Keltner Channel #3")
KC_basis = ta.sma(close, length)
devKC = ta.sma(ta.tr, length)
KC_upper_high = KC_basis + devKC * KC_mult_high
KC_lower_high = KC_basis - devKC * KC_mult_high
KC_upper_mid = KC_basis + devKC * KC_mult_mid
KC_lower_mid = KC_basis - devKC * KC_mult_mid
KC_upper_low = KC_basis + devKC * KC_mult_low
KC_lower_low = KC_basis - devKC * KC_mult_low
//SQUEEZE CONDITIONS
NoSqz = BB_lower < KC_lower_low or BB_upper > KC_upper_low //NO SQUEEZE: GREEN
LowSqz = BB_lower >= KC_lower_low or BB_upper <= KC_upper_low //LOW COMPRESSION: BLACK
MidSqz = BB_lower >= KC_lower_mid or BB_upper <= KC_upper_mid //MID COMPRESSION: RED
HighSqz = BB_lower >= KC_lower_high or BB_upper <= KC_upper_high //HIGH COMPRESSION: ORANGE
//MOMENTUM OSCILLATOR
mom = ta.linreg(close - math.avg(math.avg(ta.highest(high, length), ta.lowest(low, length)), ta.sma(close, length)), length, 0)
//MOMENTUM HISTOGRAM COLOR
iff_1 = mom > nz(mom[1]) ? color.new(color.aqua, 0) : color.new(#2962ff, 0)
iff_2 = mom < nz(mom[1]) ? color.new(color.red, 0) : color.new(color.yellow, 0)
mom_color = mom > 0 ? iff_1 : iff_2
// Bullsqueeze and Bearsqueeze Conditions
bullsqueeze = ((NoSqz and mom_color == color.new(color.aqua, 0)) or (mom_color == color.new(color.aqua, 0) and mom_color[1] == color.new(color.red, 0)))
bearsqueeze = ((NoSqz and mom_color == color.new(color.red, 0)) or (mom_color == color.new(color.red, 0) and mom_color[1] == color.new(color.aqua, 0)))
// BULL AND BEAR WATCH OUT Conditions
buyConf = (mom_color == color.new(color.aqua, 0) and mom_color[1] == color.new(color.yellow, 0)) and not bullsqueeze
sellConf = (mom_color == color.new(color.red, 0) and mom_color[1] == color.new(#2962ff, 0)) and not bearsqueeze
// User inputs for colors and widths related to the BAND
userColorBullish = input.color(color.silver, "Bullish Band Color", group= "Customize BAND")
userColorBearish = input.color(color.black, "Bearish Band Color",group= "Customize BAND")
bandWidthMultiplier = input.float(2.0, "Band Width Multiplier", minval=1.0,group= "Customize BAND")
userWidth = input.int(1, "Band Width", minval=1,group= "Customize BAND")
// Adjusted band calculations
upperBand = high + (atr * bandWidthMultiplier)
lowerBand = low - (atr * bandWidthMultiplier)
// Initialize a color variable for the band
var color bandColor = na
// Initialize a variable to store the previous band color
var color prevBandColor = na
// Update the previous band color for the next bar
prevBandColor := bandColor[1]
// Create variables to store the previous squeeze state
var bool prevBullSqueeze = false
var bool prevBearSqueeze = false
// Update the previous squeeze state at the beginning of each new bar
if (barstate.isnew)
prevBullSqueeze := bandColor == color.new(userColorBullish, 75)
prevBearSqueeze := bandColor == color.new(userColorBearish, 75)
// Determine the band color based on custom conditions
if (bullsqueeze)
bandColor := color.new(userColorBullish, 50)
else if (bearsqueeze)
bandColor := color.new(userColorBearish, 100)
else if (sellConf and prevBullSqueeze)
bandColor := color.new(userColorBullish, 70)
else if (sellConf)
bandColor := color.new(userColorBearish, 100)
else if (buyConf and prevBearSqueeze)
bandColor := color.new(userColorBearish, 100)
else if (buyConf)
bandColor := color.new(userColorBullish, 70)
// Plot the bands and store the plot references
upperBandPlot = plot(upperBand, "H", color=bandColor, linewidth=userWidth)
lowerBandPlot = plot(lowerBand, "L", color=bandColor, linewidth=userWidth)
// Fill between the bands using the plot references
fill(upperBandPlot, lowerBandPlot, color=bandColor)
///////////////////////////////
//@version=5
dual_color=false
var bar_value= 1 //(1-16)
currentHigh = high
previousHigh = high[1]
currentClose = close
previousClose = close[1]
currentLow = low
previousLow = low[1]
//
condition1 = currentHigh > previousHigh and currentClose > previousClose and currentLow > previousLow
condition2 = currentHigh < previousHigh and currentClose > previousClose and currentLow > previousLow
condition3 = currentHigh > previousHigh and currentClose > previousClose and currentLow < previousLow
condition4 = currentHigh < previousHigh and currentClose > previousClose and currentLow < previousLow
//--------------------------------------------------------
condition5 = currentHigh > previousHigh and currentClose < previousClose and currentLow > previousLow
condition6 = currentHigh < previousHigh and currentClose < previousClose and currentLow > previousLow
condition7 = currentHigh > previousHigh and currentClose < previousClose and currentLow < previousLow
condition8 = currentHigh < previousHigh and currentClose < previousClose and currentLow < previousLow
open_up = close > open[1]
open_down = close < open[1]
switch
condition1 and open_up => bar_value:=16
condition1 and open_down => bar_value:=15
condition2 and open_up => bar_value:=14
condition2 and open_down => bar_value:=13
condition3 and open_up => bar_value:=12
condition3 and open_down => bar_value:=11
condition4 and open_up => bar_value:=10
condition4 and open_down => bar_value:=9
condition5 and open_up => bar_value:=8
condition5 and open_down => bar_value:=7
condition6 and open_up => bar_value:=6
condition6 and open_down => bar_value:=5
condition7 and open_up => bar_value:=4
condition7 and open_down => bar_value:=3
condition8 and open_up => bar_value:=2
condition8 and open_down => bar_value:=1
//plot(bar_value,display = display.none,title="Bar Value")
plotchar(open_up , char="+", color=color.white)
plotchar(open_down, char="-", color=color.white)
barcolor(condition1 and not dual_color ? color.lime : na, title="C+L+H+")
barcolor(condition2 and not dual_color ? color.lime : na, title="C+L+H-")
barcolor(condition3 and not dual_color ? color.lime : na, title="C+L-H+")
barcolor(condition4 and not dual_color ? color.yellow : na, title="C+L-H-")
//--------------------------------------------------------------------------
barcolor(condition5 and not dual_color ? color.yellow : na, title="C-L+H+")
barcolor(condition6 and not dual_color ? color.red : na, title="C-L+H-")
barcolor(condition7 and not dual_color ? color.red : na, title="C-L-H+")
barcolor(condition8 and not dual_color ? color.red : na, title="C-L-H-")
///////////////////////
sadece günlükte çalışan...
yüzdeleme mantığı....
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/
// © faiyaz7283
//@version=5
indicator(title="Hi-Lo-Gauges", overlay=true)
// ::Imports:: {
import faiyaz7283/tools/12 as tools
import faiyaz7283/printer/6 as prnt
import faiyaz7283/multidata/7 as mltd
import faiyaz7283/Gauge/3 as gge
// }
// ::Inputs:: {
var section01 = 'POSITION, SIZE & COLORS'
//---------------------:
var displayLoc = input.string(defval = position.middle_center, title = 'Display Location', options = [position.top_left,
position.top_center, position.top_right, position.middle_left, position.middle_center, position.middle_right,
position.bottom_left, position.bottom_center, position.bottom_right], group = section01)
var cellPad = input.int(defval = 1, title = 'Cell Spacing', minval = 0, maxval = 5, group = section01)
var orientation = input.string(defval = 'vertical', title = 'Orientation', options = ['horizontal', 'vertical'],
group = section01) == 'vertical' ? false : true
var grdUp = input.color(defval = #00ff007a, title = '⬆ Max', inline = 'grdnt', group = section01)
var grdNeutral = input.color(defval = #fff9c47e, title = '⮕ Neutral', inline = 'grdnt', group = section01)
var grdDown = input.color(defval = #ff00006b, title = '⬇ Min', inline = 'grdnt', group = section01)
var titleColor = input.color(defval = #ffe0b2, title = 'Title:\tText', inline = 'ttlCl', group = section01)
var titleBgColor = input.color(defval = #1E283273, title = 'Bg', inline = 'ttlCl', group = section01)
var titleSize = input.string(defval=size.auto, title = 'Size', options = ['hide', size.auto, size.tiny, size.small,
size.normal, size.large, size.huge], inline = 'ttlCl', group = section01)
var titleAlign = input.string(defval=text.align_center, title = 'Align',
options = [text.align_left, text.align_center, text.align_right], inline = 'ttlCl', group = section01)
var labelColor = input.color(defval = #00e3ff, title = 'Label:\tColor', inline = 'lblCl', group = section01)
var labelSize = input.string(defval=size.auto, title = 'Size', options = ['hide', size.auto, size.tiny, size.small,
size.normal, size.large, size.huge], inline = 'lblCl', group = section01)
var keySize = input.string(defval=size.auto, title = 'Percentage Size', options = ['hide', size.auto, size.tiny, size.small,
size.normal, size.large, size.huge], inline = 'prcCl', group = section01)
var offColor = input.color(defval = #0098E736, title = 'Inactive Color', inline = 'inctCl', group = section01)
var size = input.int(defval = 5, title = 'Gauge Size', minval = 5, maxval = 20, group = section01)
var section02 = 'DATA DISPLAY'
//----------------------------:
var closeTip = 'Check this box to measure price based on a candle\'s closing price. Uncheck the box to use a candle\'s high/low prices.'
useClose = input.bool(defval=false, title='Use Close', tooltip=closeTip, group=section02)
highSource = useClose ? close : high
hs = bool(useClose) ? 'close' : 'high'
lowSource = useClose ? close : low
ls = bool(useClose) ? 'close' : 'low'
var showAT = input.bool(defval=true, title='Show All Time High and Low', group=section02)
var show52W = input.bool(defval=true, title='Show 52 Weeks High and Low', group=section02)
var show1Y = input.bool(defval=true, title='Show Current Annual High and Low', group=section02)
var show6M = input.bool(defval=true, title='Show Current Semi-Annual High and Low', group=section02)
var show3M = input.bool(defval=true, title='Show Current Quarterly High and Low', group=section02)
var show1M = input.bool(defval=true, title='Show Current Monthly High and Low', group=section02)
var show1W = input.bool(defval=true, title='Show Current Weekly High and Low', group=section02)
var show1D = input.bool(defval=true, title='Show Current Daily High and Low', group=section02)
// }
// :Functions: {
weeklyMs() =>
dayOfWeek = dayofweek(timenow)
ms = switch
dayOfWeek == 1 => timenow - (6 * 86400000)
dayOfWeek > 1 => timenow - ((dayOfWeek - 1) * 86400000)
timenow - timestamp(year(timenow), month(timenow), dayofmonth(ms))
monthlyMs() =>
timenow - timestamp(year(timenow), month(timenow), 01)
quaterlyMs() =>
cm = month(timenow)
m = switch
cm <= 3 => 01
cm <= 6 and cm > 3 => 04
cm <= 9 and cm > 6 => 07
cm <= 12 and cm > 9 => 10
timenow - timestamp(year(timenow), m, 01)
semiAnnuallyMs() =>
m = month(timenow) <= 6 ? 01 : 07
timenow - timestamp(year(timenow), m, 01)
annuallyMs() =>
timenow - timestamp(year(timenow), 01, 01)
// }
if timeframe.isdaily
// ::Data:: {
var fiftyTwoWeekMS = timeframe.in_seconds('52W') * 1000
atL = lowSource.allTimeLowest().get(ls)
atH = highSource.allTimeHighest().get(hs)
_52wL = fiftyTwoWeekMS.timeRangeLowest(lowSource).get(ls)
_52wH = fiftyTwoWeekMS.timeRangeHighest(highSource).get(hs)
_1yL = annuallyMs().timeRangeLowest(lowSource).get(ls)
_1yH = annuallyMs().timeRangeHighest(highSource).get(hs)
_6mL = semiAnnuallyMs().timeRangeLowest(lowSource).get(ls)
_6mH = semiAnnuallyMs().timeRangeHighest(highSource).get(hs)
_3mL = quaterlyMs().timeRangeLowest(lowSource).get(ls)
_3mH = quaterlyMs().timeRangeHighest(highSource).get(hs)
_1mL = monthlyMs().timeRangeLowest(lowSource).get(ls)
_1mH = monthlyMs().timeRangeHighest(highSource).get(hs)
_1wL = weeklyMs().timeRangeLowest(lowSource).get(ls)
_1wH = weeklyMs().timeRangeHighest(highSource).get(hs)
// }
if barstate.islast
tbs = prnt.tableStyle.new(bgColor=na, frameColor=na, borderColor=na, borderWidth=cellPad)
printer = prnt.printer(stack=orientation, loc=displayLoc, tableStyle=tbs, gutterStyle=prnt.gutterStyle.new(true, 1, 1))
prms = gge.gaugeParams.new(num=close, min=0, max=0, size=size, offColor=offColor, upColor=grdUp,
downColor=grdDown, neutralColor=grdNeutral, titleColor=titleColor, titleBgColor=titleBgColor,
labelColor=labelColor, titleAlign=titleAlign, titleSize=titleSize, keySize=keySize, labelSize=labelSize,
horizontal=orientation)
if showAT
paramsAT = gge.gaugeParams.copy(prms)
paramsAT.min := atL
paramsAT.max := atH
paramsAT.title := 'TÜM ZAMANLAR'
paramsAT.minLabel := str.format("{0,number,currency}", atL)
paramsAT.maxLabel := str.format("{0,number,currency}", atH)
printer.gauge(paramsAT)
if show52W
params52W = gge.gaugeParams.copy(prms)
params52W.min := _52wL
params52W.max := _52wH
params52W.title := '52 HAFTA'
params52W.minLabel := str.format("{0,number,currency}", _52wL)
params52W.maxLabel := str.format("{0,number,currency}", _52wH)
printer.gauge(params52W)
if show1Y
params1Y = gge.gaugeParams.copy(prms)
params1Y.min := _1yL
params1Y.max := _1yH
params1Y.title := 'YILLIK'
params1Y.minLabel := str.format("{0,number,currency}", _1yL)
params1Y.maxLabel := str.format("{0,number,currency}", _1yH)
printer.gauge(params1Y)
if show6M
params6M = gge.gaugeParams.copy(prms)
params6M.min := _6mL
params6M.max := _6mH
params6M.title := '6 AYLIK'
params6M.minLabel := str.format("{0,number,currency}", _6mL)
params6M.maxLabel := str.format("{0,number,currency}", _6mH)
printer.gauge(params6M)
if show3M
params3M = gge.gaugeParams.copy(prms)
params3M.min := _3mL
params3M.max := _3mH
params3M.title := '3 AYLIK'
params3M.minLabel := str.format("{0,number,currency}", _3mL)
params3M.maxLabel := str.format("{0,number,currency}", _3mH)
printer.gauge(params3M)
if show1M
params1M = gge.gaugeParams.copy(prms)
params1M.min := _1mL
params1M.max := _1mH
params1M.title := 'AYLIK'
params1M.minLabel := str.format("{0,number,currency}", _1mL)
params1M.maxLabel := str.format("{0,number,currency}", _1mH)
printer.gauge(params1M)
if show1W
params1W = gge.gaugeParams.copy(prms)
params1W.min := _1wL
params1W.max := _1wH
params1W.title := 'HAFTALIK'
params1W.minLabel := str.format("{0,number,currency}", _1wL)
params1W.maxLabel := str.format("{0,number,currency}", _1wH)
printer.gauge(params1W)
if show1D
params1D = gge.gaugeParams.copy(prms)
params1D.min := low
params1D.max := high
params1D.title := 'GÜNLÜK'
params1D.minLabel := str.format("{0,number,currency}", low)
params1D.maxLabel := str.format("{0,number,currency}", high)
printer.gauge(params1D)
else
prnt._printer.new().print("SADECE GÜNLÜK GRAFİKTE ÇALIŞIR.")
korku-çoşku kodu....
PHP Code:
//@version=5
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //
//# * ══════════════════════════════════════════════════════════════════════════════════════════════
//# *
//# * Study : Trading Psychology - Fear & Greed Index by DGT
//# * Author : © dgtrd
//# *
//# * Revision History
//# * Release : Jul 21, 2020
//# * Update : Apr 09, 2021 : Added ability to display Current Time Frame's Fear and Greed Index
//# * Update : Apr 09, 2022 : Added Price Candle display option with Fear & Greed weighted risk levels
//# *
//# * ══════════════════════════════════════════════════════════════════════════════════════════════
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //
indicator('Trading Psychology - Fear & Greed Index by DGT', '.', true, max_bars_back=252)
// -Inputs ====================================================================================== //
display = input.string('Price Candles', 'Display as', options=['Price Candles', 'Fear & Greed Index'])
smoothLength = input.int(5, 'RMA Smoothing Length', minval=1, maxval=13)
faster = input(false, 'Fear & Greed Index : Calculation with Faster Legths')
daily = input(true, 'Display Daily Time Frame Calculated Value')
lagendDesc = input(true, 'Show Color Legend')
hLabel = input(false, 'Hide Statistical Label')
fastLength = faster ? 13 : 21
slowLength = faster ? 89 : 144
// -Calculations ================================================================================ //
pmacd = (close / ta.ema(close, slowLength) - 1) * 100
pmacd_d = request.security(syminfo.tickerid, 'D', pmacd, barmerge.gaps_off, barmerge.lookahead_on)
ror = (close - close[slowLength]) / close[slowLength] * 100
ror_d = request.security(syminfo.tickerid, 'D', ror, barmerge.gaps_off, barmerge.lookahead_on)
accDist = close == high and close == low or high == low ? 0 : (2 * close - low - high) / (high - low)
nzVolume = nz(volume)
moneyFlow = math.sum(accDist * nzVolume, fastLength) / math.sum(nzVolume, fastLength) * 100
accDist_d = request.security(syminfo.tickerid, 'D', accDist, barmerge.gaps_off, barmerge.lookahead_on)
nzVolume_d = request.security(syminfo.tickerid, 'D', nzVolume)
moneyFlow_d = math.sum(accDist_d * nzVolume_d, fastLength) / math.sum(nzVolume_d, fastLength) * 100
vix = request.security('VIX', timeframe.period, -(close / ta.ema(close, slowLength) - 1) * 100, barmerge.gaps_off, barmerge.lookahead_on)
vix_d = request.security('VIX', 'D', -(close / ta.ema(close, slowLength) - 1) * 100, barmerge.gaps_off, barmerge.lookahead_on)
gold = request.security('BIST:XU100', timeframe.period, -(1 - close[fastLength] / close) * 100, barmerge.gaps_off, barmerge.lookahead_on)
gold_d = request.security('BIST:XU100', 'D', -(1 - close[fastLength] / close) * 100, barmerge.gaps_off, barmerge.lookahead_on)
cycle_raw = nzVolume ? math.avg(pmacd, ror, moneyFlow, vix, gold) : math.avg(pmacd, ror, vix, gold)
cycle_raw_d = nzVolume_d ? math.avg(pmacd_d, ror_d, moneyFlow_d, vix_d, gold_d) : math.avg(pmacd_d, ror_d, vix_d, gold_d)
cycle = ta.rma(cycle_raw, smoothLength)
cycle_d = ta.rma(cycle_raw_d, smoothLength)
f_getText(_cycle) =>
if _cycle > 73
'AŞIRI ÇOSKULU'
else if _cycle > 33
'ÇOSKULU'
else if _cycle < -25
'KORKU'
else if _cycle < -41
'AŞIRI KORKU'
else
'NÖTR'
f_getColor(_cycle) =>
if _cycle >= 73
#006400
else if _cycle >= 63 and _cycle < 73
#007439
else if _cycle >= 52 and _cycle < 63
#008368
else if _cycle >= 41 and _cycle < 52
#009096
else if _cycle >= 30 and _cycle < 41
#009bbf
else if _cycle >= 20 and _cycle < 30
#00a4df
else if _cycle >= 10 and _cycle < 20
#00a4df
else if _cycle >= 5 and _cycle < 10
#65a095
else if _cycle < -5 and _cycle >= -10
#b7b763
else if _cycle < -10 and _cycle >= -15
#fafa6e
else if _cycle < -15 and _cycle >= -20
#fecb35
else if _cycle < -20 and _cycle >= -25
#ff9800
else if _cycle < -25 and _cycle >= -31
#ff7434
else if _cycle < -31 and _cycle >= -37
#ff5252
else if _cycle < -37 and _cycle >= -41
#c72e29
else if _cycle < -41
#910000
else
#92928f
f_getColor1(_cycle) =>
if _cycle >= 73
#910000
else if _cycle >= 63 and _cycle < 73
#c72e29
else if _cycle >= 52 and _cycle < 63
#ff5252
else if _cycle >= 41 and _cycle < 52
#ff7434
else if _cycle >= 30 and _cycle < 41
#ff9800
else if _cycle >= 20 and _cycle < 30
#fecb35
else if _cycle >= 10 and _cycle < 20
#fafa6e
else if _cycle >= 5 and _cycle < 10
#b7b763
else if _cycle < -5 and _cycle >= -10
#65a095
else if _cycle < -10 and _cycle >= -15
#00a4df
else if _cycle < -15 and _cycle >= -20
#00a4df
else if _cycle < -20 and _cycle >= -25
#009bbf
else if _cycle < -25 and _cycle >= -31
#009096
else if _cycle < -31 and _cycle >= -37
#008368
else if _cycle < -37 and _cycle >= -41
#007439
else if _cycle < -41
#006400
else
#92928f
// -Plotting ==================================================================================== //
fgColor = daily ? f_getColor(cycle_d) : f_getColor(cycle)
//plot(display == 'Fear & Greed Index' ? daily ? cycle_d : cycle : na, 'Psychology of The Market Cycle - Index Display', fgColor, 2)
var label fgiLabel = na
if not hLabel
fgiLabel := label.new(time + math.round(ta.change(time) * 7), display == 'Price Candles' ? close : daily ? cycle_d : cycle, (daily ? '*Daily' : 'Daily') + ' Time Frame : ' + f_getText(cycle_d) + ' : ' +
str.tostring(math.round(cycle_d, 2)) + '%\n' + (daily ? 'Current' : '*Current') + ' Time Frame (' + timeframe.period + ') : ' + f_getText(cycle) + ' : ' +
str.tostring(math.round(cycle, 2)) + '%', xloc.bar_time, tooltip='Psychology of The Market Cycle by DGT\n\n' + 'Fear & Greed Index :\nDaily Time Frame : ' + f_getText(cycle_d) + ' : ' +
str.tostring(math.round(cycle_d, 2)) + '%\nCurrent Time Frame (' + timeframe.period + ') : ' + f_getText(cycle) + ' : ' +
str.tostring(math.round(cycle, 2)) + '%' + '%\n\nReference Sources : ' + '\n-------------------------------------------------------------------' +
'\n 1 - Price Convergence/Divergence to/from its Moving Average (' + str.tostring(slowLength) + ') :\n Daily TF ' + str.tostring(math.round(pmacd_d, 2)) + '% / Current TF ' + str.tostring(math.round(pmacd, 2)) + '%' +
'\n 2 - Rate of Return (Momentum/RoC), Length (' + str.tostring(slowLength) + ') :\n Daily TF ' + str.tostring(math.round(ror_d, 2)) + '% / Current TF ' + str.tostring(math.round(ror, 2)) + '%' +
'\n 3 - Chaikin Money Flow, Length (' + str.tostring(fastLength) + ') :\n Daily TF ' + str.tostring(math.round(moneyFlow_d, 2)) + '% / Current TF ' + str.tostring(math.round(moneyFlow, 2)) + '% \n ps: cmf calculated only if volume data is provided' +
'\n 4 - VIX - Volatility (Fear) Index, Length (' + str.tostring(slowLength) + ') :\n Daily TF ' + str.tostring(math.round(vix_d, 2)) + '% / Current TF ' + str.tostring(math.round(vix, 2)) + '%' +
'\n 5 - Safe Haven Demand - Gold Demand, Length (' + str.tostring(fastLength) + ') :\n Daily TF ' + str.tostring(math.round(gold_d, 2)) + '% / Current TF ' + str.tostring(math.round(gold, 2)) + '%' +
'\n\nWarren Buffett’s quote, buy when others are fearful, and sell when others are greedy', color=color.new(color.gray, 85), style=label.style_label_left, textcolor=color.gray, textalign=text.align_left)
label.delete(fgiLabel[1])
var o = 0., var h = 0., var l = 0., var c = 0.
if display == 'Price Candles'
o := open, h := high, l := low, c := close
fgColor := daily ? f_getColor1(cycle_d) : f_getColor1(cycle)
if display == 'Fear & Greed Index'
fgColor := na
//plotcandle(o, h, l, c, 'Psychology of The Market Cycle - Price Display', fgColor, fgColor, bordercolor = fgColor)
//var table logo = table.new(position.bottom_right, 1, 1)
//table.cell(logo, 0, 0, "☼☾ ", text_size = size.normal, text_color = color.teal)
var table legend = table.new(position.middle_center , 1, 5)
if lagendDesc
if display == 'Price Candles'
table.cell(legend, 0, 0, "Max FIRSAT █", text_size = size.small, text_color = #006400, text_halign = text.align_right)
table.cell(legend, 0, 1, "FIRSAT █", text_size = size.small, text_color = #008368, text_halign = text.align_right)
table.cell(legend, 0, 2, "NÖTR █", text_size = size.small, text_color = #92928f, text_halign = text.align_right)
table.cell(legend, 0, 3, "RİSK █", text_size = size.small, text_color = #ff7434, text_halign = text.align_right)
table.cell(legend, 0, 4, "Max RİSK █", text_size = size.small, text_color = #910000, text_halign = text.align_right)
else
table.cell(legend, 0, 0, "AŞIRI ÇOŞKU █", text_size = size.small, text_color = #006400, text_halign = text.align_right)
table.cell(legend, 0, 1, "ÇOŞKU █", text_size = size.small, text_color = #008368, text_halign = text.align_right)
table.cell(legend, 0, 2, "NÖTR █", text_size = size.small, text_color = #92928f, text_halign = text.align_right)
table.cell(legend, 0, 3, "KORKU █", text_size = size.small, text_color = #ff7434, text_halign = text.align_right)
table.cell(legend, 0, 4, "AŞIRI KORKU █", text_size = size.small, text_color = #910000, text_halign = text.align_right)
mia ve reder arasında iyi arbitraj yapıyorlar....
:):):)
58 Teknik bir hedefti.. Teknikten kopmamak adına takipliyorum ve göreceğine inanıyorum bu seviyeyi..
Ama görüyorsunuz gün gün düşüyor fiyat aşağıya.. Şakkadanak olmaz ki bu işler:)
2 geri 1 ileri şeklinde..
İşte o 1 ilerilerde ben pozisyona giriyorum:yes:
Sevgiler:kalp:
Sn Yörük hacim bilgisi kodlanabiliyor mu ?
Ve mantıksal komutlar verilebiliyor mu hacim ile ilgili?
Şu kademedeki lotları şu kademelerdeki lotlar ile topla çıkar.. Günü artı kapatmışsa şöyle çıkar, eksi kapatmışsa böyle çıkar gibi?
:)
yapılıyor...
https://tr.tradingview.com/scripts/rvol/
çoğunluk rvol tarzı kodları kullanıyor.....
ben...TW yi...free kullandığım için....yani canlı api tarzında....
derinlik ve hacim paketini almadığım için.....
hacim kodlarını kullan(a)mıyorum....
bu yüzden tasarımlarımı sadece bar...fiyat üzerinden yapıyorum..
forumda....
https://www.hisse.net/topluluk/showt...25#post6727625
yazan TA hocanın.....bu konuda kendine has çok güzel bir çalışması var....
aracı kurumları takip edip....grafiğe döküyor.....
size.....yardımcı olabilir belki......
selamlar.....
Olası bar hareketi hesaplamayı şu an ben bakkal hesabı ile yapıyorum..
Mesela dedim ya Garanti Mart vade 68.50 bekliyorum.. Bu olasılığı yüksek bar hareketi:yes:
Ya aslında iki ayrı hesaplama yapıyorum.. Biri excel de ortalama long ve short maliyet hesabı.. ( Bu bana düşerse nereye kadar düşer çıkarsa nereye kadar çıkarın cevabını veriyor orta vade)
Diğeri bir sıfır noktası oluşturarak barlardaki hacimden olası bar hareketi:):):) (Bu da günlük)
canlı veri alamayınca.... ne yazık ki, kodları kullanamıyorum....
veri....olduğu an....
ilk olarak....veri yığını parçalanıp....güvenliği artırılıyor.....
sonra...o veri için....mtf dediğimiz bölümlemeler yapılıyor....
böylece kullanılacak veriye....tam bakılmış oluyor....
garan da ise...vadeli ve spot olunca....ayrı ilişkilendirme gerekiyor.....
hacimde ise....veriyi doğrulamak zor oluyor....
çünkü virman olayı....
ve aynı malı döndürme söz konusu olunca.....
çok değişiyor.....
örneğin....topik olan bir metada alıcılar...aldığını satmadığında.....
robotlar.....işlem hacmi kırıyor....
gün sonu bakıyoruz.....finnetten....para girişi yok ama tavan.....
ben de sayım işini denedim...
ama yapamadım.... vazgeçtim...
Teşekkür ederim.. Bence de olmalı.. Zihindeki herşey kodlanabilmeli.. Kod çalışmasına ilk başladığımda okuduğum bir yazıda hacim kademe analizine girdiği için kodlanmıyor yazıyordu.. Bende peşini bıraktım..
Şimdi yine umutlandım:kalp:
Yapıcam inşallah... İyice bir oturtayim kafamdakini..
ileri dönük bar hesaplamaları ise.....
ichimoku bulutu gibi.....
ya precessin ile ileriye atılıyor.....
genellikle....fiyattan hesaplanıyor.....
hesaplamalarda da
ya pattern
ya pivot
ya da kanallar kullanılıyor....
ama işin için de zig zag olunca...repaint olabiliyor....
ilk başlarda....
sonraki barları hesaplatmak için çok değişik kodları denedim....
ancak jeton düşünce....
olacaktan değil.....
olandan sorumlu olduğumu anlayınca.....
tasarımları dinamikleştirdim.....
oluşan fiyat hareketine göre....hareket edince...
kendim sürekli al sat yaparken buldum....
daldan dala atlayıp durmaya başladım....
sonuç...
panda misali....
dala çıkıyorum....ama inemiyorum....
bol bol düşüyorum...:drunk:
Bakın 67.40 iken vadelisi Garanti spot 64.50 idi..
68.50 hedefi için spot 64.50 den aldım..
Şu an 65.35 fiyatı.. Vadelisi ise 68 oldu..
68.50 olduğunda muhtemelen spotta 65.70 lerde olur.. Ve kapatırım..
Senkronize gidiyor..
Pandalar en sevdiğim canlılar:kalp:
https://www.instagram.com/reel/C3E96...doeGs5eHNsZDky
Basit mantık şu değil mi?
Pala aldığı malı satmak zorunda.. Sattığını da aşağıdan yerine koymak zorunda.. Geleceği öngörmek diye buna denir:):):)
eğer yanlış anlamadıysam....
yapacağı sayımlar için....
https://tr.tradingview.com/script/ZM...StratifyTrade/ bu kod gibi izleri analiz edeceksin...
https://tr.tradingview.com/script/U8...StratifyTrade/ bu kodla...fiyatı ilişkilendireceksin....
https://tr.tradingview.com/script/LG...es-ChartPrime/ bununla da olasılıkları hesaplayacaksın....
bunları birleştirip...tek koda indirip....
ilave kendi indikatörlerini ekleyebilirsin...
ama....veri paketini alman gerekir....
Garanti 65.50 oldu.. :one: Vadeli 68.13.. :one: Birazdan kapatıcam inşallah..
Sevgiler ve bol kazançlar hepinize:kalp:
https://www.youtube.com/watch?v=j5-yKhDd64s
Ama hacim bilgisine bakıyorum sadece..
Gerekirse vadeli de açarım spotu bırakır.. Pala çok üstüme gelmesin:):):)
İyice bir profesyonelleşeyim sayımda..
Garanti için kendime 1 yıl verdim.. Huyunu suyunu iyice öğrenmek için..
Ben bu kod yazmayı şunun için istedim.. Tüm hisseleri taratıp short maliyetlerinin altına geleni bulayım.. Yorulmadan.. Ve pozisyona gireyim.. U30 daki tüm hisseleri sayacaktım ama çok zaman alıyor..
Öğrenicem inşallah.. Garantide iyice bir ustalaşayim:kalp:
heikin yıldız... destek-direnç ve trend gösterir...heikin barla ilişkilidir.....
yüksek periyottan düşüğe göre kullanımı olabilir....
PHP Code:
//@version=5
//
indicator(title='.', overlay=true, format=format.inherit, max_bars_back=100, max_lines_count=100)
//Swing High/Low Settings
length = input.int(1, minval=1, maxval=499, group='Swing')
ref = input.int(10, 'Occurence', minval=0, group='Swing')
anchor_mode = input.string('Swing High', 'Anchor Point', options=['Swing High', 'Swing Low'], group='Swing')
//Spiral Settings
turns = input.int(12, 'Spiral Turns', minval=1, group='Spiral')
fliph = input.bool(false, 'Flip Horizontally', group='Spiral')
flipv = input.bool(true, 'Flip Vertically', group='Spiral')
//Style Settings
solid = input.bool(false, 'Use Solid Color', inline='inlinesolid', group='Style')
solid_col = input.color(#FFFFFF, '100', inline='inlinesolid', group='Style')
gradient_min = input.color(#fd0202, 'Gradient Colors', inline='inlinegradient', group='Style')
gradient_max = input.color(#51fa02, '', inline='inlinegradient', group='Style')
//------------------------------------------------------------------------------
n = bar_index
var pi = math.pi
var anchor = 0
var color col = na
var lines = array.new_line(0)
yval = array.new_float(0)
xval = array.new_int(0)
prices = array.new_float(0)
//Flipping Constants
flip_h = fliph ? -1 : 1
flip_v = flipv ? -1 : 1
//Get Swing High/Low
ph = close
pl = close
ph_val = ta.valuewhen(ph, high[length], ref)
pl_val = ta.valuewhen(pl, low[length], ref)
//Get anchor corrdinate
if anchor_mode == 'Swing High'
anchor := ta.valuewhen(ph, n - length, ref)
anchor
else
anchor := ta.valuewhen(pl, n - length, ref)
anchor
len = n - anchor
//Append lines
if barstate.isfirst
for i = 0 to 99 by 1
array.push(lines, line.new(na, na, na, na))
//------------------------------------------------------------------------------
y1 = 0.
y2 = 0.
max = 0.
min = 0.
if barstate.islast
//Append spiral coordinates to arays
for i = 0 to len - 1 by 1
t = i / (len - 1) * turns * pi
x = t * math.cos(t) * flip_h / pi / turns * len + anchor
y = t * math.sin(t) * flip_v / pi
array.push(yval, y)
array.push(xval, int(x))
for i = 0 to array.max(xval) - array.min(xval) - 1 by 1
array.push(prices, close[i])
//Rescale coordinates and set line corrdinates
for i = 1 to len - 1 by 1
yval_max = array.max(yval)
yval_min = array.min(yval)
yval_range = yval_max - yval_min
range_1 = array.max(prices) - array.min(prices)
x1 = array.get(xval, i - 1)
x2 = array.get(xval, i)
if anchor_mode == 'Swing High'
y1 := ph_val + array.get(yval, i - 1) / yval_range * range_1
y2 := ph_val + array.get(yval, i) / yval_range * range_1
min := ph_val + yval_min / yval_range * range_1
max := ph_val + yval_max / yval_range * range_1
max
else
y1 := pl_val + array.get(yval, i - 1) / yval_range * range_1
y2 := pl_val + array.get(yval, i) / yval_range * range_1
min := pl_val + yval_min / yval_range * range_1
max := pl_val + yval_max / yval_range * range_1
max
//Line coloring
if solid
col := solid_col
col
else
col := color.from_gradient(y2, min, max, gradient_min, gradient_max)
col
l = array.get(lines, i - 1)
line.set_xy1(l, x1, y1)
line.set_xy2(l, x2, y2)
line.set_color(l, col)
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © erdas0
//@version=5
users = input(true, title='Use Current Chart Resolution?')
tf = input.timeframe(title='Use Different Timeframe?', defval='')
res = users ? timeframe.period : tf
sym = input.symbol(defval = '',title = "Symbol")
md = input.string(title = "Mode", defval = "Normal", options=["Heikin-Ashi", "Linear", "Normal"],group="Mode", inline="md")
hulllen= input.int(200, "Hull Length",minval=1, group="Mode", inline="md")
usem = input(true, title='Use Cande Callculate Method?',group="Method")
symo1 = request.security(sym, res, open)
symh1 = request.security(sym, res, high)
syml1 = request.security(sym, res, low)
symc1 = request.security(sym, res, close)
//Method
ema(source, length, type) =>
switch type
"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)
typeMA = input.string(title = "Method", defval = "EMA", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"],group="Method",inline="mt")
len32 = input.int(5, minval=1,group="Method",inline="mt")
symo = usem ? ema(symo1,len32,typeMA) : symo1
symh = usem ? ema(symh1,len32,typeMA) : symh1
syml = usem ?ema(syml1,len32,typeMA) : syml1
symc = usem ? ema(symc1,len32,typeMA) : symc1
o = md=="Heikin-Ashi" ? (symo[1]+symc[1])/2 : md=="Linear" ? ta.linreg(symo,len32+1, 0) : symo
h = md=="Heikin-Ashi" ? math.max(symh,symo,symc) : md=="Linear" ? ta.linreg(symh,len32+1, 0) : symh
l = md=="Heikin-Ashi" ? math.min(syml,symo,symc) : md=="Linear" ? ta.linreg(syml,len32+1, 0) : syml
c = md=="Heikin-Ashi" ? (symo+symc+symh+syml)/4 : md=="Linear" ? ta.linreg(symc,len32+1, 0) : symc
op = request.security(sym, res, o)
hp = request.security(sym, res, h)
lp = request.security(sym, res, l)
cp = request.security(sym, res, c)
col32 = 0.0
col32 := cp > op and cp > cp[1] ? 1 : cp < op and cp < cp[1] ? -1 : col32[1]
clr = col32 == 1 ? color.rgb(60, 253, 2) : col32 == -1 ? color.rgb(250, 3, 3) : color.rgb(252, 227, 4)
//Hull
hullma = ta.wma(2*ta.wma(c, hulllen/2)-ta.wma(c, hulllen), math.floor(math.sqrt(hulllen)))
cl=hullma>c? color.red : color.lime
prch= (c-hullma)*100/c
plotcandle(op, hp, lp, cp, color=clr, wickcolor=clr, bordercolor=clr, title='heikinn')