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))
16.07.2024 - 10.12.2024
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))
16.07.2024 - 10.12.2024
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)
16.07.2024 - 10.12.2024
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)
_ = '
-------------- '
16.07.2024 - 10.12.2024
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-")
///////////////////////
16.07.2024 - 10.12.2024
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.")
16.07.2024 - 10.12.2024
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)
16.07.2024 - 10.12.2024
Yer İmleri