name
stringlengths 1
64
| url
stringlengths 44
135
| author
stringlengths 3
30
| author_url
stringlengths 34
61
| likes_count
int64 0
33.2k
| kind
stringclasses 3
values | pine_version
int64 1
5
| license
stringclasses 3
values | source
stringlengths 177
279k
|
---|---|---|---|---|---|---|---|---|
VIX Contango 1 | https://www.tradingview.com/script/3H25nHda-VIX-Contango-1/ | ales1585 | https://www.tradingview.com/u/ales1585/ | 43 | study | 1 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ales1585
// Contango - VIX CBOE-VX1!
study("VIX Contango 1", overlay=false)
VIX1 = security("VX1!", "D", close)
VIX2 = security("VX2!", "D", close)
oscillator = 100*(VIX2-VIX1)/VIX1
plot(oscillator, color=blue)
hline(0,linestyle=dotted,title = "Center")
hline(20,linestyle=dashed,color = green)
hline(-20,linestyle=dashed,color = purple)
|
Momentum-based ZigZag (incl. QQE) NON-REPAINTING | https://www.tradingview.com/script/gY4ilk5N-Momentum-based-ZigZag-incl-QQE-NON-REPAINTING/ | Peter_O | https://www.tradingview.com/u/Peter_O/ | 7,296 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Peter_O
//@version=5
indicator('Momentum-based ZigZag', overlay=true)
var int momentum_direction = 0
color_zigzag_lines = input(true, title='Color ZigZag lines to show force direction')
momentum_select = input.string(title='Select Momentum Indicator:', defval='QQE', options=['MACD', 'MovingAverage', 'QQE'])
// ZigZag function {
zigzag(_momentum_direction) =>
zz_goingup = _momentum_direction == 1
zz_goingdown = _momentum_direction == -1
var float zz_peak = na
var float zz_bottom = na
zz_peak := high > zz_peak[1] and zz_goingup or zz_goingdown[1] and zz_goingup ? high : nz(zz_peak[1])
zz_bottom := low < zz_bottom[1] and zz_goingdown or zz_goingup[1] and zz_goingdown ? low : nz(zz_bottom[1])
zigzag = zz_goingup and zz_goingdown[1] ? zz_bottom[1] : zz_goingup[1] and zz_goingdown ? zz_peak[1] : na
zigzag
// } End of ZigZag function
// MACD {
fast_length = input.int(title='Fast Length', defval=12, group='if MACD Selected', inline='macd')
slow_length = input.int(title='Slow Length', defval=26, group='if MACD Selected', inline='macd')
src = input.source(title='Source', defval=close, group='if MACD Selected', inline='macd')
signal_length = input.int(title='Signal Smoothing', minval=1, maxval=50, defval=9, group='if MACD Selected', inline='macd')
sma_source = input.string(title='Oscillator MA Type', defval='EMA', options=['SMA', 'EMA'], group='if MACD Selected', inline='macd')
sma_signal = input.string(title='Signal Line MA Type', defval='EMA', options=['SMA', 'EMA'], group='if MACD Selected', inline='macd')
fast_ma = sma_source == 'SMA' ? ta.sma(src, fast_length) : ta.ema(src, fast_length)
slow_ma = sma_source == 'SMA' ? ta.sma(src, slow_length) : ta.ema(src, slow_length)
macd = fast_ma - slow_ma
signal = sma_signal == 'SMA' ? ta.sma(macd, signal_length) : ta.ema(macd, signal_length)
macdUP = ta.crossover(macd, signal)
macdDOWN = ta.crossunder(macd, signal)
// } End of MACD
// Moving Averages {
smoothing_type = input.string(title='Average type', defval='SMA', options=['EMA', 'SMA', 'WMA', 'VWMA', 'HMA', 'RMA', 'DEMA'], inline='movingaverage', group='if Moving Average selected')
ma_length = input.int(20, title='Length', inline='movingaverage', group='if Moving Average selected')
moving_average(_series, _length, _smoothing) =>
_smoothing == 'EMA' ? ta.ema(_series, _length) : _smoothing == 'SMA' ? ta.sma(_series, _length) : _smoothing == 'WMA' ? ta.wma(_series, _length) : _smoothing == 'VWMA' ? ta.vwma(_series, _length) : _smoothing == 'HMA' ? ta.hma(_series, _length) : _smoothing == 'RMA' ? ta.rma(_series, _length) : _smoothing == 'DEMA' ? 2 * ta.ema(_series, _length) - ta.ema(ta.ema(_series, _length), _length) : ta.ema(_series, _length)
movingaverage = moving_average(close, ma_length, smoothing_type)
maUP = movingaverage > movingaverage[1] and movingaverage[2] > movingaverage[1]
maDOWN = movingaverage < movingaverage[1] and movingaverage[2] < movingaverage[1]
// } End of Moving Averages
// QQE {
RSI_Period = input.int(14, title='RSI Length', inline='qqe', group='if QQE selected')
qqeslow = input.float(4.238, title='QQE Factor', inline='qqe', group='if QQE selected')
SFslow = input.int(5, title='RSI Smoothing', inline='qqe', group='if QQE selected')
ThreshHold = input.int(10, title='Thresh-hold', inline='qqe', group='if QQE selected')
rsi_currenttf = ta.rsi(close, RSI_Period)
qqenew(_qqefactor, _smoothingfactor, _rsi, _threshold, _RSI_Period) =>
RSI_Period = _RSI_Period
SF = _smoothingfactor
QQE = _qqefactor
ThreshHold = _threshold
Wilders_Period = RSI_Period * 2 - 1
Rsi = _rsi
RsiMa = ta.ema(Rsi, SF)
AtrRsi = math.abs(RsiMa[1] - RsiMa)
MaAtrRsi = ta.ema(AtrRsi, Wilders_Period)
dar = ta.ema(MaAtrRsi, Wilders_Period) * QQE
longband = 0.0
shortband = 0.0
trend = 0
DeltaFastAtrRsi = dar
RSIndex = RsiMa
newshortband = RSIndex + DeltaFastAtrRsi
newlongband = RSIndex - DeltaFastAtrRsi
longband := RSIndex[1] > longband[1] and RSIndex > longband[1] ? math.max(longband[1], newlongband) : newlongband
shortband := RSIndex[1] < shortband[1] and RSIndex < shortband[1] ? math.min(shortband[1], newshortband) : newshortband
QQExlong = 0
QQExlong := nz(QQExlong[1])
QQExshort = 0
QQExshort := nz(QQExshort[1])
qqe_goingup = ta.barssince(QQExlong == 1) < ta.barssince(QQExshort == 1)
qqe_goingdown = ta.barssince(QQExlong == 1) > ta.barssince(QQExshort == 1)
var float last_qqe_high = high
var float last_qqe_low = low
last_qqe_high := high > last_qqe_high[1] and qqe_goingup or qqe_goingdown[1] and qqe_goingup ? high : nz(last_qqe_high[1])
last_qqe_low := low < last_qqe_low[1] and qqe_goingdown or qqe_goingup[1] and qqe_goingdown ? low : nz(last_qqe_low[1])
trend := ta.crossover(RSIndex, shortband[1]) or ta.crossover(high, last_qqe_high) ? 1 : ta.crossunder(RSIndex, longband[1]) or ta.crossunder(low, last_qqe_low) ? -1 : nz(trend[1], 1)
FastAtrRsiTL = trend == 1 ? longband : shortband
// Find all the QQE Crosses
QQExlong := trend == 1 and trend[1] == -1 ? QQExlong + 1 : 0
QQExshort := trend == -1 and trend[1] == 1 ? QQExshort + 1 : 0
qqeLong = QQExlong == 1 ? FastAtrRsiTL[1] - 50 : na
qqeShort = QQExshort == 1 ? FastAtrRsiTL[1] - 50 : na
qqenew = qqeLong ? 1 : qqeShort ? -1 : na
qqenew
qqeUP = qqenew(qqeslow, SFslow, rsi_currenttf, ThreshHold, RSI_Period) == 1
qqeDOWN = qqenew(qqeslow, SFslow, rsi_currenttf, ThreshHold, RSI_Period) == -1
// } End of QQE
momentumUP = momentum_select == 'MACD' ? macdUP : momentum_select == 'MovingAverage' ? maUP : momentum_select == 'QQE' ? qqeUP : qqeUP
momentumDOWN = momentum_select == 'MACD' ? macdDOWN : momentum_select == 'MovingAverage' ? maDOWN : momentum_select == 'QQE' ? qqeDOWN : qqeDOWN
momentum_direction := momentumUP ? 1 : momentumDOWN ? -1 : nz(momentum_direction[1])
// { Force detection
rsi5 = ta.rsi(close, 5)
ob = 80
os = 20
barssince_momentumUP = ta.barssince(momentumUP)
barssince_momentumDOWN = ta.barssince(momentumDOWN)
momentum_DOWN_was_force_up = momentumDOWN and (barssince_momentumUP >= ta.barssince(rsi5 > ob))[1]
momentum_UP_was_force_down = momentumUP and (barssince_momentumDOWN >= ta.barssince(rsi5 < os))[1]
zzcolor_rsi5 = momentum_DOWN_was_force_up ? color.lime : momentum_UP_was_force_down ? color.red : color.black
// } End of Force detection
ZigZag = zigzag(momentum_direction)
plot(ZigZag, linewidth=5, color=color_zigzag_lines ? zzcolor_rsi5 : color.black, title='ZIGZAG', style=plot.style_line, transp=0)
GoShort = momentumDOWN and not momentum_DOWN_was_force_up
GoLong = momentumUP and not momentum_UP_was_force_down
if GoShort
label.new(bar_index, ZigZag, style=label.style_label_down, color=color.red, text=str.tostring('SHORT\n\npivot high: \n' + str.tostring(ZigZag)))
if GoLong
label.new(bar_index, ZigZag, style=label.style_label_up, color=color.lime, text=str.tostring('LONG\n\npivot low: \n' + str.tostring(ZigZag)))
var float stoploss_long = low
var float stoploss_short = high
pl = ta.valuewhen(momentumUP, ZigZag, 0)
ph = ta.valuewhen(momentumDOWN, ZigZag, 0)
if GoLong
stoploss_long := low < pl ? low : pl
stoploss_long
if GoShort
stoploss_short := high > ph ? high : ph
stoploss_short
TakeProfitLevel=input(200)
if GoLong
alertsyntax_golong = 'long slprice=' + str.tostring(stoploss_long) + ' tp=' + str.tostring(TakeProfitLevel)
alert(message=alertsyntax_golong, freq=alert.freq_once_per_bar_close)
if GoShort
alertsyntax_goshort = 'short slprice=' + str.tostring(stoploss_short) + ' tp=' + str.tostring(TakeProfitLevel)
alert(message=alertsyntax_goshort, freq=alert.freq_once_per_bar_close)
|
[FN] Strategy - Store Level on Condition | https://www.tradingview.com/script/WrjN4xGt-FN-Strategy-Store-Level-on-Condition/ | kurtsmock | https://www.tradingview.com/u/kurtsmock/ | 53 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © kurtsmock
//@version=4
study("Store Level on Condition")
//////////////////////////
// Example Parameters ////
//////////////////////////{
c_entry = input("Market", "Entry Type", input.string, options = ["Market", "Limit"])
//-- This script is a study so strategy function isn't actually being used so it will compile without an error.
strategy_position_size = 1
//-- A new long trade has been initiated when the position size on the prior bar was <= 0 and is now > 0
newTrade_L = strategy_position_size[1] <= 0 and strategy_position_size > 0
//-- This is a convoluted but valid way to initialize a variable that will update on execution
inTrade_long = false, inTrade_long := nz(inTrade_long[1]), inTrade_long := strategy_position_size > 0
//-- Determines what type of order should be executed. But, this will only serve to inform strategy.entry() and strategy.order()
//-- which is a separate matter. For our purposes, we're choosing which level to store based on the order type we would deploy.
limit_entry = c_entry == "Limit" ? true : false // true = Entry Limit Order, False = Entry Market Order on candle close
//-- Condition Building
startCondition = newTrade_L and not inTrade_long[1]
holdCondition = inTrade_long and inTrade_long[1]
whichLvlCondition = limit_entry
lvl = open
altLvl = hlc3
// Example 1 //
// Holding a static level from starting point - Test for Hold Condition first so a new start condition won't update the level.
// 1. If your Hold Condition is not true, then you're waiting for a start condition.
// 2. On the bar your start condition is true, the initialization variable is updated with the level defined ( _lvl )
// 3. Your hold condition should then become true on the next bar.
// On each subsequent bar the hold condition should be true as long as the logic that holds it as true is valid.
// (e.g. strategy.position_size > 0 This will remain true as long as you have a long trade open, which makes it a good hold condition for a
// price level in a strategy.)
// Because the hold condition is true and the function tests for that first, new instances of the start condition will not update the
// value of the variable.
// 4. When the hold condition is no longer true (e.g. position is closed and the position size is <= 0) AND there is no start condition present
// the level is set back to na and is waiting for a new start condition to re-initialize the level to be stored.
// 5. When the hold condition is no longer true AND the start condition is present, the level will update
_rememberLvl1(_startCondition, _holdCondition, _lvl) =>
initialization = float(na)
if _holdCondition
initialization := initialization[1]
else if _startCondition
initialization := _lvl // Level to store
else
initialization := float(na)
[initialization]
//-- You can build the conditions as we did on lines 26-30 or you can just insert the conditions
levelExample1_a = _rememberLvl1(startCondition, holdCondition, lvl)
levelExample1_b = _rememberLvl1((newTrade_L and not inTrade_long[1]), inTrade_long, open)
// Example 1 Variation //
// Multiple possible levels. Making the decision on which level to store at the time at which _startCondition = true
// 1. All the above is the same except for how the script determines the level that is stored
// 2. When start condition is true, the script asks a nested if question.
// if _whichLvlCondition is true, then choose _lvl, but if not, then choose the _altLvl
// This can be useful in situations where your standard stop level on a long trade is above the entry price for example
// or when the long entry price is above the current price.
// 3. This feature can be expanded to a logic tree that fits the strategy. When start condition fires as true, you may want to
// make certain determiniations to decide what level you want stored.
// 4. More _whichLvlCondtion(s) can be added to the function by expanding the nested if function starting on line 82.
// 5. To do this, change 'else' on line 84 to 'else if _whichLvlCondtion2'. Then add _whichLvlCondition2 to line 77.
// also add _altLvl2 to line 77. If all _whichLvlCondition(s) are false, then you will set level to na.
// You can add as many potential levels as you like by expanding that logic by as many 'else if' statements as required.
// I know that's not super clear, but hopefully it conveys the idea.
_rememberLvl1Alt(_startCondition, _holdCondition, _whichLvlCondition, _lvl, _altLvl) =>
initialization = float(na)
if _holdCondition
initialization := initialization[1]
else if _startCondition
if _whichLvlCondition // e.g. close > open
initialization := _lvl // Level to remember
else
initialization := _altLvl // alternative level
else
initialization := float(na)
[initialization]
//-- You can build the conditions as we did on lines 26-30 or you can just insert the conditions
levelsExample1alt_a = _rememberLvl1Alt(startCondition, holdCondition, whichLvlCondition, lvl, altLvl)
levelsExample1alt_b = _rememberLvl1Alt((newTrade_L and not inTrade_long[1]), inTrade_long, limit_entry, hlc3, open)
// Example 2 //
// Recalculating the stored level on each occurrence of _startCondition or _holdCondition
// 1. In some cases you may want to track a certain value like ATR(20) calculating it only while the condition is running.
// 2. When _startCondition triggers or the _holdCondition keeps it valid, it recalculates the level on each bar.
// 3. However when both of these conditions are false (i.e. when you are flat), it will return na.
_rememberLvl2(_startCondition, _holdCondition, _lvl) =>
initialization = float(na)
if _startCondition or _holdCondition
initialization := _lvl
else
initialization := float(na)
[initialization]
//-- You can build the conditions as we did on lines 26-30 or you can just insert the conditions
levelExample2_a = _rememberLvl2(startCondition, holdCondition, lvl)
levelExample2_b = _rememberLvl2((newTrade_L and not inTrade_long[1]), inTrade_long, open)
// Example 3 //
// Update level on each occurence of _startCondition only
// 1. Here the function tests for the presence of the start condition first.
// 2. When _startCondition = true, then the level is updated. This is true even when the _holdCondition is true.
// 3. When _startCondition = false and the _holdCondition = true, then it will simply carry the last value forward, keeping
// the same level as defined by the prior bar.
_rememberLvl3(_startCondition, _holdCondition, _lvl) =>
initialization = float(na)
if _startCondition
initialization := _lvl // Level to store
else if _holdCondition
initialization := initialization[1]
else
initialization := float(na)
[initialization]
//-- You can build the conditions as we did on lines 26-30 or you can just insert the conditions
levelExample3_a = _rememberLvl3(startCondition, holdCondition, lvl)
levelExample3_b = _rememberLvl3((newTrade_L and not inTrade_long[1]), inTrade_long, open)
plot(close)
|
Moving Average % channel (Vlad965) | https://www.tradingview.com/script/duK0gkmu-Moving-Average-channel-Vlad965/ | Vlad965 | https://www.tradingview.com/u/Vlad965/ | 43 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//SMA indicator. Creates two additional SMA around the normal SMA , offset by the specified percentage. This creates the look of a channel.
// © Vlad965
//@version=4
study(title="Moving Average % channel (Vlad965)", shorttitle="MA % channel (Vlad965)", overlay=true, resolution="")
//Settings
per = input(600, minval = 1, maxval = 1000, title = "Length")
src = input(close, title = "Source")
buylevel = input(-26.0, minval = -1000, maxval = 1000, title = "Buy line (lime)")
selllevel = input(431.0, minval = -1000, maxval = 1000, title = "Sell line (red)")
//SMAs
sma = sma(src, per)
buy = sma * ((100 + buylevel) / 100)
sell = sma * ((100 + selllevel) / 100)
plot(buy, linewidth = 2, color=color.lime, title = "Buy line")
plot(sell, linewidth = 2, color=color.red, title = "Sell line")
plot(sma, linewidth = 2, color=color.black, title = "MA line") |
Price density [Measuring Market Noise:Take advantage] | https://www.tradingview.com/script/XBnX88JR-Price-density-Measuring-Market-Noise-Take-advantage/ | Unknown_TracerBUNNY | https://www.tradingview.com/u/Unknown_TracerBUNNY/ | 73 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Unknown_TracerBUNNY
//This indicator allows you to measure market noise which is very use full as a market regime filter
//@version=4
study("UNK_Tracer|Bunny's Price density")
length = input(20, "period")
numerator = 0.0
for i = 0 to length-1
numerator := numerator + (high[i]-low[i])
deno = highest(high, length) - lowest(low, length)
as = numerator / deno
plot(as) |
Intraday Hourly Volume | https://www.tradingview.com/script/cEoXp9cK-Intraday-Hourly-Volume/ | RicardoSantos | https://www.tradingview.com/u/RicardoSantos/ | 314 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RicardoSantos
//@version=4
study(title='Intraday Hourly Volume')
var float[] volumes = array.new_float(24, 0.0)
var int[] counters = array.new_int(24, 0)
var line[] lines = array.new_line(24)
var label[] labels = array.new_label(24)
if barstate.isfirst
for _i = 0 to 23
array.set(lines, _i, line.new(bar_index, 0.0, bar_index, 0.1, style=line.style_arrow_right, width=2))
array.set(labels, _i, label.new(bar_index, 0.0, str.format('{0}', _i), style=label.style_label_up))
int h = hour(time)
// label.set_tooltip(array.get(labels, 0), str.tostring(h))
if change(h) != 0
_volume = array.get(volumes, h) + volume
_count = array.get(counters, h) + 1
array.set(volumes, h, _volume)
array.set(counters, h, _count)
line _line = array.get(lines, h)
line.set_y1(_line, _volume / _count)
line.set_y2(_line, volume)
label.set_color(array.get(labels, h), color=color.red)
label.set_color(array.get(labels, (24 + h - 1) % 24), color=color.blue)
if barstate.islastconfirmedhistory
for _i = 0 to 23
line _line = array.get(lines, _i)
label _label = array.get(labels, _i)
int _idx = bar_index + 10 * _i
line.set_x1(_line, _idx)
line.set_x2(_line, _idx)
label.set_x(_label, _idx)
|
Drift Study (Inspired by Monte Carlo Simulations with BM) [KL] | https://www.tradingview.com/script/aDymGrFx-Drift-Study-Inspired-by-Monte-Carlo-Simulations-with-BM-KL/ | DojiEmoji | https://www.tradingview.com/u/DojiEmoji/ | 150 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © DojiEmoji
//@version=5
indicator("Drift [DojiEmoji]", overlay=false)
var int len_drift = input(14, title="Lookback")
var string _repaint_mode = input.string("Off", title="Repaint mode on/off", options=["On", "Off"])
var bool repaint_mode = _repaint_mode == "On"
// @function get_drift()
// @param int n : lookback period
// @returns float drift, a value that depicts trend with +/- signs signifying up/down (respectively)
get_drift(int n) =>
_pc = math.log(close / close[1])
return_drift = ta.sma(_pc, len_drift) - math.pow(ta.stdev(_pc, len_drift), 2) * 0.5
return_drift
float drift = get_drift(len_drift)
color _col = drift > 0 ? color.blue : color.red
plot(drift[repaint_mode?0:1], color=_col[repaint_mode?0:1], linewidth=2, offset=repaint_mode?0:-1)
plot(0, color=color.new(color.gray, 0)) // zeroline
|
RedK Magic Ribbon | https://www.tradingview.com/script/wWEVE3pq-RedK-Magic-Ribbon/ | RedKTrader | https://www.tradingview.com/u/RedKTrader/ | 1,343 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RedKTrader
//@version=5
indicator('RedK Magic Ribbon', shorttitle='MagicRibbon v5.0', overlay=true, timeframe='', timeframe_gaps=false)
// Jan31, 2023: Release Notes for version 5.0
// ------------------------------
// Add more optional MA's and standardizing their colors for consistency with other MA's & charts
// updated LazyLine() with latest version
// display for MA values are only in the data window to reduce clutter
//====================================================================
f_LazyLine(_data, _length) =>
w1 = 0, w2 = 0, w3 = 0
L1 = 0.0, L2 = 0.0, L3 = 0.0
w = _length / 3
if _length > 4
w2 := math.round(w)
w1 := math.round((_length - w2) / 2)
w3 := int((_length - w2) / 2)
L1 := ta.wma(_data, w1)
L2 := ta.wma(L1, w2)
L3 := ta.wma(L2, w3)
L3
else
L3 := ta.wma(_data, _length)
L3
//=====================================================================
f_CoraWave(source, length, s) =>
numerator = 0.0, denom = 0.0
c_weight = 0.0, r_multi = 2.0
Start_Wt = 0.01 // Start Weight & r_multi are set to basic values here.
End_Wt = length // use length as initial End Weight to calculate base "r"
r = math.pow(End_Wt / Start_Wt, 1 / (length - 1)) - 1
base = 1 + r * r_multi
for i = 0 to length - 1 by 1
c_weight := Start_Wt * math.pow(base, length - i)
numerator += source[i] * c_weight
denom += c_weight
denom
cora_raw = numerator / denom
cora_wave = ta.wma(cora_raw, s)
cora_wave
// ======================================================================
Source_1 = input.source(close, 'Source', inline='CRMA1', group='CoRa Wave (Fast MA)')
Length_1 = input.int(10, 'Length', minval=1, inline='CRMA1', group='CoRa Wave (Fast MA)')
smooth = input.int(3, 'Smooth', minval=1, inline='CRMA2', group='CoRa Wave (Fast MA)')
Source_2 = input.source(close, 'Source', inline='RSSMA', group='RSS_WMA (Slow MA)')
Length_2 = input.int(15, 'Smoothness', minval=1, inline='RSSMA', group='RSS_WMA (Slow MA)')
ShowFill = input.bool(true, 'Ribbon Fill?', group='RSS_WMA (Slow MA)')
FastLine = f_CoraWave(Source_1, Length_1, smooth)
SlowLine = f_LazyLine(Source_2, Length_2)
c_fup = color.new(color.aqua, 30)
c_fdn = color.new(color.orange, 30)
Fast_up = FastLine > FastLine[1]
Fast_dn = FastLine < FastLine[1]
c_sup = color.new(#33ff00, 0)
c_sdn = color.new(#ff1111, 0)
Slow_up = SlowLine > SlowLine[1]
Slow_dn = SlowLine < SlowLine[1]
FastPlot = plot(FastLine, title='Fast Line', color=Fast_up ? c_fup : c_fdn, linewidth=2)
SlowPlot = plot(SlowLine, title='Slow Line', color=Slow_up ? c_sup : c_sdn, linewidth=2)
c_rup = color.new(#33ff00, 70)
c_rdn = color.new(#ff1111, 70)
c_rsw = color.new(color.gray, 70)
Ribbon_up = Fast_up and Slow_up
Ribbon_dn = not Fast_up and not Slow_up
fill(FastPlot, SlowPlot, title='Ribbon Fill', color=ShowFill ? Ribbon_up ? c_rup : Ribbon_dn ? c_rdn : c_rsw : na)
// ======================================================================================================
// v3.0 adds 2 optional MA's - to enable us to track what many other traders are working with
// the below code is based on the built-in MA Ribbon in the TV library - with some modifications
// ======================================================================
f_ma(source, length, type) =>
type == 'SMA' ? ta.sma(source, length) :
type == 'EMA' ? ta.ema(source, length) :
ta.wma(source, length)
// ======================================================================
gr_ma = 'Optional Moving Averages'
t_ma1 = 'MA #1'
t_ma2 = 'MA #2'
t_ma3 = 'MA #3'
t_ma4 = 'MA #4'
show_ma1 = input.bool(false, t_ma1, inline=t_ma1, group=gr_ma)
ma1_type = input.string('SMA', '', options=['SMA', 'EMA', 'WMA'], inline=t_ma1, group=gr_ma)
ma1_source = input.source(close, '', inline=t_ma1, group=gr_ma)
ma1_length = input.int(10, '', minval=1, inline=t_ma1, group=gr_ma)
ma1_color = color.new(#ffeb3b,0)
ma1 = f_ma(ma1_source, ma1_length, ma1_type)
plot(show_ma1 ? ma1 : na, color=ma1_color, title=t_ma1, linewidth=1, display = display.pane + display.data_window)
show_ma2 = input.bool(false, t_ma2, inline=t_ma2, group=gr_ma)
ma2_type = input.string('SMA', '', options=['SMA', 'EMA', 'WMA'], inline=t_ma2, group=gr_ma)
ma2_source = input.source(close, '', inline=t_ma2, group=gr_ma)
ma2_length = input.int(20, '', minval=1, inline=t_ma2, group=gr_ma)
ma2_color = color.new(#f57c00,0)
ma2 = f_ma(ma2_source, ma2_length, ma2_type)
plot(show_ma2 ? ma2 : na, color=ma2_color, title=t_ma2, linewidth=1, display = display.pane + display.data_window)
show_ma3 = input.bool(false, t_ma3, inline=t_ma3, group=gr_ma)
ma3_type = input.string('SMA', '', options=['SMA', 'EMA', 'WMA'], inline=t_ma3, group=gr_ma)
ma3_source = input.source(close, '', inline=t_ma3, group=gr_ma)
ma3_length = input.int(50, '', minval=1, inline=t_ma3, group=gr_ma)
ma3_color = color.new(#ab47bc,0)
ma3 = f_ma(ma3_source, ma3_length, ma3_type)
plot(show_ma3 ? ma3 : na, color=ma3_color, title=t_ma3, linewidth=1, display = display.pane + display.data_window)
show_ma4 = input.bool(false, t_ma4, inline=t_ma4, group=gr_ma)
ma4_type = input.string('SMA', '', options=['SMA', 'EMA', 'WMA'], inline=t_ma4, group=gr_ma)
ma4_source = input.source(close, '', inline=t_ma4, group=gr_ma)
ma4_length = input.int(100, '', minval=1, inline=t_ma4, group=gr_ma)
ma4_color = color.new(#2424f0,0)
ma4 = f_ma(ma4_source, ma4_length, ma4_type)
plot(show_ma4 ? ma4 : na, color=ma4_color, title=t_ma4, linewidth=1, display = display.pane + display.data_window)
// ======================================================================================================
// v4.0 adds alerts for Fast and Slow swinging to a new move up or new move down
// This is easier than looking for the visual signal / color change .. as requested
// The main signal is really when the ribbon "agrees" on a spcific color
// ======================================================================================================
Alert_Fastup = Fast_up and not Fast_up[1]
Alert_Fastdn = Fast_dn and not Fast_dn[1]
Alert_Slowup = Slow_up and not Slow_up[1]
Alert_Slowdn = Slow_dn and not Slow_dn[1]
alertcondition(Alert_Fastup, 'Fast Line Swings Up', 'MagicRibbon - Fast Line Swing Up Detected!')
alertcondition(Alert_Fastdn, 'Fast Line Swings Down', 'MagicRibbon - Fast Line Swing Down Detected!')
alertcondition(Alert_Slowup, 'Slow Line Swings Up', 'MagicRibbon - Slow Line Swing Up Detected!')
alertcondition(Alert_Slowdn, 'Slow Line Swings Down', 'MagicRibbon - Slow Line Swing Down Detected!')
|
iBagging Multi-Indicator | https://www.tradingview.com/script/ira03RGz-iBagging-Multi-Indicator/ | Skyrex | https://www.tradingview.com/u/Skyrex/ | 188 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SkyRockSignals
//@version=4
study(title="iBagging", shorttitle="iB", overlay=true, resolution="")
var int sum_bull=0
var int sum_bear=0
sum_bear:=0
sum_bull:=0
//EMAx2++ params
len_fast = input(9, minval=1, title="Length of fast EMA")
src_fast = input(close, title="Source of fast EMA")
offset_fast = input(title="Offset of fast EMA", type=input.integer, defval=0, minval=-500, maxval=500)
len_slow = input(30, minval=1, title="Length of slow EMA")
src_slow = input(close, title="Source of slow EMA")
offset_slow = input(title="Offset of slow EMA", type=input.integer, defval=0, minval=-500, maxval=500)
len_filter=input(title="Length of Filter", type=input.integer,defval=10)
filter = input(true,title='Filter', type=input.bool)
//divergency params
len = input(title="RSI Period", minval=1, defval=14)
src = input(title="RSI Source", defval=close)
lbR = input(title="Pivot Lookback Right", defval=5)
lbL = input(title="Pivot Lookback Left", defval=5)
rangeUpper = input(title="Max of Lookback Range", defval=60)
rangeLower = input(title="Min of Lookback Range", defval=5)
osc = rsi(src, len)
//BB Power Params
len_bb = input(title="EMA Period of BB Power", minval=1, defval=13)
//NATR PARAMS
natr_len=input(title='Normalized ATR Length',minval=1,defval=13)
natr_trashold=input(title="NATR Trashold",minval=0,defval=1)
//EMAx2++
basis = sma(close, 20)
dev = 2.0 * stdev(close, 20)
upper = basis + dev
lower = basis - dev
width = abs(upper-lower)
var float[] width_arr=array.new_float(len_filter)
for i=0 to array.size(width_arr)-1
array.push(width_arr,width[i])
array.shift(width_arr)
//supp/resis indicator params
n = input(title="Periods of pivot", defval=20, minval=2, type=input.integer)
inacc = input(title = "Inaccuracy", defval = 0.05, type = input.float, step = 0.005)
int i_history = input(200, "Number of fractals")
width_aver = array.avg(width_arr)
out_fast = ema(src_fast, len_fast)
out_slow = ema(src_slow, len_slow)
var bool bullish=false
var bool strong_bullish=false
var bool bearish=false
var bool strong_bearish=false
if (filter==true)
bullish:= crossover(out_fast,out_slow) //and width>width_aver
strong_bullish:=out_slow<min(close,open) and crossover(out_fast,out_slow) and width>width_aver
eq=bullish==strong_bullish
bullish:= not eq
bearish:= crossunder(out_fast,out_slow) //and width>width_aver
strong_bearish:=out_slow>min(open,close) and crossunder(out_fast,out_slow) and width>width_aver
eq:= bearish==strong_bearish
bearish:= not eq
else
bullish:= crossover(out_fast,out_slow)// and width>width_aver
strong_bullish:=out_slow<min(close,open) and crossover(out_fast,out_slow)
eq=bullish==strong_bullish
bullish:= not eq
bearish:= crossunder(out_fast,out_slow)
strong_bearish:=out_slow>min(open,close) and crossunder(out_fast,out_slow)
eq:= bearish==strong_bearish
bearish:= not eq
if (bearish or strong_bearish)
sum_bear:=sum_bear+1
if (bullish or strong_bullish)
sum_bull:=sum_bull+1
//divergency--------------------------------------------------------------------
var bool[] bull_div_array=array.new_bool(5000)
var bool[] bear_div_array=array.new_bool(5000)
plFound = na(pivotlow(osc, lbL, lbR)) ? false : true
phFound = na(pivothigh(osc, lbL, lbR)) ? false : true
_inRange(cond) =>
bars = barssince(cond == true)
rangeLower <= bars and bars <= rangeUpper
// Regular Bullish
// Osc: Higher Low
oscHL = osc[lbR] > valuewhen(plFound, osc[lbR], 1) and _inRange(plFound[1])
// Price: Lower Low
priceLL = low[lbR] < valuewhen(plFound, low[lbR], 1)
bullCond = priceLL and oscHL and plFound
// Regular Bearish
// Osc: Lower High
oscLH = osc[lbR] < valuewhen(phFound, osc[lbR], 1) and _inRange(phFound[1])
// Price: Higher High
priceHH = high[lbR] > valuewhen(phFound, high[lbR], 1)
bearCond = priceHH and oscLH and phFound
for i=0 to 3
if (bearCond[4999-i]==true)
sum_bear:=sum_bear+1
break
for i=0 to 3
if (bullCond[4999-i]==true)
sum_bull:=sum_bull+1
break
//bull_bear power
bull_power=high-ema(close,len_bb)
bear_power=low-ema(close,len_bb)
if (bull_power>0 and bear_power>0)
sum_bull:=sum_bull+1
if (bull_power<0 and bear_power<0)
sum_bear:=sum_bear+1
//Norm ATR
natr = 100 * atr(natr_len) / close
if (natr>natr_trashold)
sum_bull:=sum_bull+1
sum_bear:=sum_bear+1
//enter
var float pivot_less=100000000000000000
var float pivot_more=-1
longCondition = sum_bull>=3
plotshape(longCondition,text="Bullish Signal",style=shape.flag,size=size.small,offset=2,color=color.green,textcolor=color.green,location=location.abovebar)
shortCondition = sum_bear>=3
plotshape(shortCondition,text="Bearish Signal",style=shape.flag,size=size.small,offset=2,color=color.red,textcolor=color.red,location=location.belowbar)
|
Pivot Crossover | https://www.tradingview.com/script/Wp2Qekxz-Pivot-Crossover/ | aksharmty | https://www.tradingview.com/u/aksharmty/ | 31 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © aksharmty
//@version=4
study("Pivot Crossover",shorttitle="Pivot Crossover" ,overlay=true)
pivet2 = (close[2]+low[2]+high[2])/3
plot(pivet2, color=color.yellow, title="2nd last bar pivet", linewidth=4)
pivet1 = (close[1]+low[1]+high[1])/3
orc = pivet2 < pivet1 ? color.green : color.red
plot(pivet1, color=orc, title="last bar pivet", linewidth=4)
pivet = (close[0]+low[0]+high[0])/3
plot(pivet, color=color.white, title="current bar pivet", linewidth=4)
|
Volume Pressure Analysis - Overlay | https://www.tradingview.com/script/8zPb15WG-Volume-Pressure-Analysis-Overlay/ | veryfid | https://www.tradingview.com/u/veryfid/ | 1,303 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © veryfid
//@version=4
study("Volume Pressure Analysis", overlay = true)
spike = close - open <= 0 ? open - close : close - open
avglength = input(30,"Lookback bars for Average",group = "General Settings")
avg = array.new_float(0)
for i = 1 to avglength
array.push(avg, spike[i])
rvol = spike / array.avg(avg)
//plot(rvol)
avg2 = array.new_float(0)
for i = 1 to avglength
array.push(avg2, volume[i])
rvol2 = volume / array.avg(avg2)
rvol3 = rvol - rvol2 > 0 ? rvol - rvol2 : na
rvol4 = rvol - rvol2 < 0 ? rvol - rvol2 : na
rvolsma = sma(volume,20)
float(rvol3)
float(rvol4)
//plot(rvol - rvol2, style = plot.style_columns, color = rvol - rvol2 > 0 ? color.teal : color.red)
sma1 = sma(rvol3, 20)
sma2 = sma(rvol4, 20)
//plot(sma(rvol - rvol2 < 0, 20))
plotshape(rvol4 < sma2 and open < close , color = color.yellow, style = shape.triangledown, location = location.abovebar)
plotshape(rvol4 < sma2 and open > close , color = color.yellow, style = shape.triangleup, location = location.belowbar)
plotshape(rvol3 > sma1 and open < close , color = #80deea, style = shape.triangleup, location = location.belowbar)
plotshape(rvol3 > sma1 and open > close , color = color.red, style = shape.triangledown, location = location.abovebar)
barcolor(rvol - rvol2 > sma1 and close > open ? #80deea : rvol - rvol2 > sma1 and open > close ? #ffcdd2 : na) |
Trading ABC | https://www.tradingview.com/script/0SBnTaqJ-Trading-ABC/ | LonesomeTheBlue | https://www.tradingview.com/u/LonesomeTheBlue/ | 8,538 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © LonesomeTheBlue
//@version=4
study("Trading ABC", overlay = true, max_bars_back = 500, max_lines_count = 500, max_labels_count = 500)
prd = input(defval = 8, title="ZigZag Period", minval = 2, maxval = 50, group = "Setup")
fiboup = input(defval = 0.618, title = "Fibonacci Max", group = "Setup")
fibodn = input(defval = 0.382, title = "Fibonacci Min", group = "Setup")
errorrate = input(defval = 5.0, title = "Error Rate", minval = 0, maxval = 30, group = "Setup") / 100
showabc = input(defval = true, title = "Show ABC", group = "Extras")
keepabc = input(defval = true, title = "Keep Old ABCs", group = "Extras")
showcloud = input(defval = true, title = "Show Cloud", group = "Extras", inline = "cloud")
c_upcol = input(defval = color.new(color.lime, 75), title = "", group = "Extras", inline = "cloud")
c_dncol = input(defval = color.new(color.red, 75), title = "", group = "Extras", inline = "cloud")
showzigzag = input(defval = true, title = "Show Zig Zag & Fibo", group = "Extras", inline = "zigzag")
upcol = input(defval = color.lime, title = "", group = "Extras", inline = "zigzag")
dncol = input(defval = color.red, title = "", group = "Extras", inline = "zigzag")
srcma = input(defval = close, title = "Source for Moving Averages", group = "Trend Cloud")
malen1 = input(defval = 50, title = "SMA 1 Length", minval = 1, group = "Trend Cloud")
malen2 = input(defval = 100, title = "SMA 2 Length", minval = 1, group = "Trend Cloud")
malen3 = input(defval = 150, title = "SMA 3 Length", minval = 1, group = "Trend Cloud")
malen4 = input(defval = 200, title = "SMA 4 Length", minval = 1, group = "Trend Cloud")
malen5 = input(defval = 20, title = "EMA 1 Length", minval = 1, group = "Trend Cloud")
malen6 = input(defval = 40, title = "EMA 2 Length", minval = 1, group = "Trend Cloud")
ma_array = array.new_float(6)
array.set(ma_array, 0, sma(srcma, malen1))
array.set(ma_array, 1, sma(srcma, malen2))
array.set(ma_array, 2, sma(srcma, malen3))
array.set(ma_array, 3, sma(srcma, malen4))
array.set(ma_array, 4, ema(srcma, malen5))
array.set(ma_array, 5, ema(srcma, malen6))
float umax = na
float umin = na
float lmax = na
float lmin = na
int upper = 0
int lower = 0
for x = 1 to 6
ma = array.get(ma_array, x -1)
if ma >= max(open, close)
upper := upper + 1
if na(umax)
umax := ma
umin := ma
else
umax := max(umax, ma)
umin := min(umin, ma)
else if ma <= min(open, close)
lower := lower + 1
if na(lmax)
lmax := ma
lmin := ma
else
lmax := max(lmax, ma)
lmin := min(lmin, ma)
var int trend = 0
trend := lower > 0 and upper == 0 and lower[1] > 0 and upper[1] == 0 ? 1 :
lower == 0 and upper > 0 and lower[1] == 0 and upper[1] > 0 ? -1 :
trend
tucolor = trend == 1 ? c_upcol: na
tdcolor = trend == -1 ? c_dncol : na
fill(plot(umax, color = na), plot(umin, color = na), color = showcloud ? tdcolor : na)
fill(plot(lmax, color = na), plot(lmin, color = na), color = showcloud ? tucolor : na)
//===================================================================
// zigzag part
get_ph_pl_dir(len)=>
float ph = highestbars(high, len) == 0 ? high : na
float pl = lowestbars(low, len) == 0 ? low : na
var dir = 0
dir := iff(ph and na(pl), 1, iff(pl and na(ph), -1, dir))
[ph, pl, dir]
[ph, pl, dir] = get_ph_pl_dir(prd)
var max_array_size = 10
var zigzag = array.new_float(0)
add_to_zigzag(value, bindex)=>
array.unshift(zigzag, bindex)
array.unshift(zigzag, value)
if array.size(zigzag) > max_array_size
array.pop(zigzag)
array.pop(zigzag)
update_zigzag(value, bindex)=>
if array.size(zigzag) == 0
add_to_zigzag(value, bindex)
else
if (dir == 1 and value > array.get(zigzag, 0)) or (dir == -1 and value < array.get(zigzag, 0))
array.set(zigzag, 0, value)
array.set(zigzag, 1, bindex)
0.
dir_changed = change(dir)
if ph or pl
if dir_changed
add_to_zigzag(dir == 1 ? ph : pl, bar_index)
else
update_zigzag(dir == 1 ? ph : pl, bar_index)
if showzigzag and array.size(zigzag) > 5
var line zzline1 = na
var line zzline2 = na
line.delete(zzline1)
line.delete(zzline2)
zzline1 := line.new(x1 = round(array.get(zigzag, 1)) , y1 = array.get(zigzag, 0), x2 = round(array.get(zigzag, 3)), y2 = array.get(zigzag, 2), color = dir == 1 ? upcol : dncol, width = 2, style = line.style_dashed)
zzline2 := line.new(x1 = round(array.get(zigzag, 3)) , y1 = array.get(zigzag, 2), x2 = round(array.get(zigzag, 5)), y2 = array.get(zigzag, 4), color = dir == -1 ? upcol : dncol, width = 2, style = line.style_dashed)
// min/max fibo levels
zzlen = abs(array.get(zigzag, 2) - array.get(zigzag, 4))
fmin = dir == 1 ? array.get(zigzag, 2) + zzlen * (fibodn - errorrate) : array.get(zigzag, 4) + zzlen * ((1 - fibodn) + errorrate)
fmax = dir == 1 ? array.get(zigzag, 2) + zzlen * (fiboup + errorrate) : array.get(zigzag, 4) + zzlen * ((1 - fiboup) - errorrate)
var line fibo1 = na
var line fibo2 = na
line.delete(fibo1)
line.delete(fibo2)
fibo1 := line.new(x1 = round(array.get(zigzag, 3)), y1 = fmin, x2 = round(array.get(zigzag, 3)) + 1, y2 = fmin, color = color.blue, style = line.style_dashed, extend = extend.right)
fibo2 := line.new(x1 = round(array.get(zigzag, 3)), y1 = fmax, x2 = round(array.get(zigzag, 3)) + 1, y2 = fmax, color = color.blue, style = line.style_dashed, extend = extend.right)
zchange = array.size(zigzag) > 0 ? array.get(zigzag, 0) : 0.0
abc = array.new_float(0)
if change(zchange) and array.size(zigzag) > 5 and ((pl and trend == 1 and dir == -1 and low < array.max(ma_array)) or (ph and trend == -1 and dir == 1 and high > array.min(ma_array)))
a = array.get(zigzag, 0)
b = array.get(zigzag, 2)
b_loc = array.get(zigzag, 3)
c = array.get(zigzag, 4)
c_loc = array.get(zigzag, 5)
rate = (a - b) / (c - b)
if rate >= (fibodn - fibodn * errorrate) and rate <= (fiboup + fiboup * errorrate)
array.push(abc, b)
array.push(abc, b_loc)
array.push(abc, c)
array.push(abc, c_loc)
draw_line(dir, x1_,y1_, x2_, y2_, x3_, y3_)=>
l1 = line.new(x1 = x1_, y1 = y1_, x2 = x2_, y2 = y2_, color = dir == 1 ? upcol : dncol, width = 2)
l2 = line.new(x1 = x2_, y1 = y2_, x2 = x3_, y2 = y3_, color = dir == 1 ? dncol : upcol, width = 2)
[l1, l2]
draw_label(dir, x1_,y1_, x2_, y2_, x3_, y3_)=>
alabel = label.new( x = x1_,
y = y1_,
text = "C",
style = dir == 1 ? label.style_label_down : label.style_label_up,
color = color.new(color.white, 100),
textcolor = color.blue)
blabel = label.new( x = x2_,
y = y2_,
text = "B",
style = dir == -1 ? label.style_label_down : label.style_label_up,
color = color.new(color.white, 100),
textcolor = color.blue)
clabel = label.new( x = x3_,
y = y3_,
text = "A",
style = dir == 1 ? label.style_label_down : label.style_label_up,
color = color.new(color.white, 100),
textcolor = color.blue)
[alabel, blabel, clabel]
var abclines = array.new_line(2)
var abclabels = array.new_label(3)
if showabc and array.size(abc) >= 4
if not keepabc
line.delete(array.pop(abclines))
line.delete(array.pop(abclines))
label.delete(array.pop(abclabels))
label.delete(array.pop(abclabels))
label.delete(array.pop(abclabels))
[l1_, l2_] = draw_line(dir, bar_index, array.get(zigzag, 0), round(array.get(abc, 1)), array.get(abc, 0), round(array.get(abc, 3)), array.get(abc, 2))
array.unshift(abclines, l1_)
array.unshift(abclines, l2_)
[la1_, la2_, la3_] = draw_label(dir, bar_index, array.get(zigzag, 0), round(array.get(abc, 1)), array.get(abc, 0), round(array.get(abc, 3)), array.get(abc, 2))
array.unshift(abclabels, la1_)
array.unshift(abclabels, la2_)
array.unshift(abclabels, la3_)
// bounce?
lbounced = false
sbounced = false
for i = 0 to 5
if min(low, low[1]) <= array.get(ma_array, i) and close > array.get(ma_array, i) and close > open
lbounced := true
if max(high, high[1]) >= array.get(ma_array, i) and close < array.get(ma_array, i) and close < open
sbounced := true
// stoch give signal?
sto = sma(stoch(close, high, low, 5), 3)
sto_sig = sma(sto, 3)
lstoch = sto[1] <= sto_sig[1] and sto > sto_sig and sto[1] < 50 //and sto_sig > 20
sstoch = sto[1] >= sto_sig[1] and sto < sto_sig and sto[1] > 50 //and sto_sig < 80
/// check if conditions met
there_is_abc = array.size(abc) != 0
var float last_zz_point = 0.
last_zz_point := array.size(zigzag) > 2 and there_is_abc ? array.get(zigzag, 0) : last_zz_point
var abc_bar_count = 0
abc_bar_count := there_is_abc ? 0 : abc_bar_count + 1
hhh_ = highest(abc_bar_count + 1)
lll_ = lowest(abc_bar_count + 1)
// long condition
long = trend == 1 and abc_bar_count <= 6 and lbounced and lll_ >= last_zz_point
short = trend == -1 and abc_bar_count <= 6 and sbounced and hhh_ <= last_zz_point
plotshape(long, style = shape.triangleup, color = upcol, location = location.belowbar, size = size.small)
plotshape(short, style = shape.triangledown, color = dncol, location = location.abovebar, size = size.small)
alertcondition(long, title = "ABC Long", message = "ABC Long")
alertcondition(short, title = "ABC Short", message = "ABC Short")
|
Volume Pressure Analysis | https://www.tradingview.com/script/K4zDWmnT-Volume-Pressure-Analysis/ | veryfid | https://www.tradingview.com/u/veryfid/ | 2,328 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © veryfid
//@version=4
study("Volume Pressure Analysis", shorttitle = "VPA")
theme = input("RVOL Analysis", "Theme:", options=["Pressure Analysis","Support vs Resistance", "Directional Pressure", "RVOL Analysis", "RVOL"], group = "Main Settings", inline = "main")
widget = input("None", "Widget:", options=["None","Support vs Resistance", "Directional Pressure", "Support vs Resistance + Directional Pressure"], group = "Main Settings", inline = "main")
show = input(true, "Show Pressure Signals")
showentry = input(true, "Show Entry Signals?",group = "Entry Signals")
showvol = input(true, "Show Current Volume?",group = "General Settings")
showavg = input(true, title = "Show Average",group = "General Settings")
showrvol = input(true, "Show RVOL Calculation?",group = "General Settings")
showpercent = input(true, "Show Pressure Direction Percentage?", group = "General Settings")
showlsma21 = input(true,"Show LSMA 21 Entry Points", group = "Entry Signals")
showlsma6 = input(true,"Show LSMA 6 Entry Points",group = "Entry Signals")
showticker = input(false, "Show Ticker ID?",group = "General Settings")
showvola = input(false, "Show Relative Volatility? (RVOL Analysis theme only")
showlastvola = input(false, "Show Relative Volatility? (Widget only")
showlastsma = input(true, "Show SMA Line? (Widget only")
offset1 = 11
if theme == "Directional Pressure"
show := false
if theme == "Pressure Analysis"
show := false
if widget == "Support vs Resistance + Directional Pressure"
offset1 := 22
x = "k"
vol = volume
if volume < 1000
x := ""
if volume >= 1000
vol := volume / 1000
if volume >= 1000000
x := "M"
vol := volume / 1000000
if volume >= 1000000000
x := "B"
vol := volume / 1000000000
spike = close - open <= 0 ? open - close : close - open
avglength = input(30,"Lookback bars for Average",group = "General Settings")
avg = array.new_float(0)
for i = 1 to avglength
array.push(avg, spike[i])
rvol = spike / array.avg(avg)
avg2 = array.new_float(0)
for i = 1 to avglength
array.push(avg2, volume[i])
rvol2 = volume / array.avg(avg2)
y = "k"
avg1 = array.avg(avg2)
avg3 = avg1
if avg1 < 1000
y := ""
if avg1 >= 1000
avg3 := avg1 / 1000
if avg1 >= 1000000
y := "M"
avg3 := avg1 / 1000000
if avg1 >= 1000000000
y := "B"
avg3 := avg1 / 1000000000
rvol3 = rvol - rvol2 > 0 ? rvol - rvol2 : na
rvol4 = rvol - rvol2 < 0 ? rvol - rvol2 : na
rvoltot = rvol - rvol2 > 0 ? rvol - rvol2 : rvol - rvol2 < 0 ? (rvol - rvol2) * -1 : na
sma = sma(rvol2,20)
sma1 = sma(rvol3, 20)
sma2 = sma(rvol4, 20)
sma3 = sma(rvoltot,20)
lsma1 = linreg(rvol2, 50,0)
ma2 = linreg(rvol2,50,0)
ma3 = linreg(rvol2,21,0)
ma4 = linreg(rvol2,6,0)
cond1 = crossover(ma2,0)
clean = rvol2 - lsma1
float(rvol3)
float(rvol4)
transp1 = 0
highest = highest(rvol2,30) / 2
plot(showvola ? rvol : na, style = plot.style_columns, color = color.yellow,title = "Volatility")
plot(showlastvola ? rvol : na, style = plot.style_columns, color = color.yellow,title = "Volatility", show_last = 10, offset = 11)
plot(theme == "RVOL" and rvol - rvol2 > rvol2 ? (rvol - rvol2) : na, style = plot.style_columns, color = close > open ? #80deea : #ffcdd2, transp = 0)
plot(theme == "RVOL" ? rvol2 : na, style = plot.style_columns, color = close > open ? #26a69a : color.red, transp = 60)
plot(theme == "RVOL" and rvol - rvol2 < 0 ? (rvol - rvol2) * -1 : na, style = plot.style_columns, color = close > open ? #FF5252 : #26a69a, transp = 60)
plot(theme == "RVOL" and clean > stdev(rvol2,21) or theme == "RVOL" and rvol - rvol2 > rvol2 ? rvol2 : na, style = plot.style_columns , color = close > open ? #26a69a : color.red, title = "Anomalies")
plot(theme == "RVOL" and clean > stdev(rvol2,21) and rvol - rvol2 < 0 ? (rvol - rvol2) * -1 : na, style = plot.style_columns, color = close > open ? #FF5252 : #26a69a, title = "Anomalies")
plot(theme == "RVOL" ? rvol2 : na, style = plot.style_columns, color = close > open ? #26a69a : color.red, show_last = 1)
plot(theme == "RVOL" and rvol - rvol2 < 0 ? (rvol - rvol2) * -1 : na, style = plot.style_columns, color = close > open ? #FF5252 : #26a69a, show_last = 1)
plot(theme == "RVOL" and rvol - rvol2 < rvol2 and rvol - rvol2 > 0 ? (rvol - rvol2): na, style = plot.style_columns, color = close > open ? #80deea : #ffcdd2, transp = 0, show_last = 1)
plot(theme == "RVOL" and clean > stdev(rvol2,21) and rvol - rvol2 < rvol2 and rvol - rvol2 > 0 ? (rvol - rvol2): na, style = plot.style_columns, color = close > open ? #80deea : #ffcdd2, transp = 0)
plot(theme == "RVOL Analysis" and rvol - rvol2 > rvol2 ? (rvol - rvol2) : na, style = plot.style_columns, color = close > open ? #80deea : #ffcdd2, transp = 0)
plot(theme == "RVOL Analysis" ? rvol2 : na, style = plot.style_columns, color = close > open ? #26a69a : color.red)
plot(theme == "RVOL Analysis" and rvol - rvol2 < 0 ? (rvol - rvol2) * -1 : na, style = plot.style_columns, color = close > open ? #FF5252 : #26a69a)
plot(theme == "RVOL Analysis" and rvol - rvol2 < rvol2 and rvol - rvol2 > 0 ? (rvol - rvol2): na, style = plot.style_columns, color = close > open ? #80deea : #ffcdd2, transp = 0)
plot(widget == "Support vs Resistance" and (rvol - rvol2) > 0 or widget == "Support vs Resistance + Directional Pressure" and (rvol - rvol2) > 0 ? (rvol - rvol2) : na, style = plot.style_columns, color = #26a69a, show_last = 10, offset = 11,title = "pressure")
plot(widget == "Support vs Resistance" and (rvol - rvol2) < 0 or widget == "Support vs Resistance + Directional Pressure" and (rvol - rvol2) < 0 ? (rvol - rvol2) * -1 : na, style = plot.style_columns, color = color.red, show_last = 10, offset = 11,title = "pressure")
plot(theme == "Support vs Resistance" and (rvol - rvol2) > 0 ? (rvol - rvol2) : na, style = plot.style_columns, color = rvol - rvol2 > 0 and rvol - rvol2 > sma1 ? #4db6ac : rvol - rvol2 > 0 ? #00796b : rvol - rvol2 < 0 and rvol - rvol2 < sma2 ? #ef5350 : #9a2b2b,title = "SR")
plot(theme == "Support vs Resistance" and (rvol - rvol2) < 0 ? (rvol - rvol2) * -1 : na, style = plot.style_columns, color = rvol - rvol2 > 0 and rvol - rvol2 > sma1 ? #4db6ac : rvol - rvol2 > 0 ? #00796b : rvol - rvol2 < 0 and rvol - rvol2 < sma2 ? #ef5350 : #9a2b2b,title = "SR")
plot(theme == "Directional Pressure" and close < open and (rvol - rvol2) < 0 ? (rvol - rvol2) * -1 : na, style = plot.style_columns, color = rvol - rvol2 > 0 and rvol - rvol2 > sma1 ? #4db6ac : rvol - rvol2 > 0 ? #00796b : rvol - rvol2 < 0 and rvol - rvol2 < sma2 ? #4db6ac : #00796b)
plot(theme == "Directional Pressure" and close > open and (rvol - rvol2) < 0 ? rvol - rvol2 : na, style = plot.style_columns, color = rvol - rvol2 > 0 and rvol - rvol2 > sma1 ? #ef5350 : rvol - rvol2 > 0 ? #9a2b2b : rvol - rvol2 < 0 and rvol - rvol2 < sma2 ? #ef5350 : #9a2b2b)
plot(theme == "Directional Pressure" and close > open and (rvol - rvol2) > 0 ? (rvol - rvol2) : na, style = plot.style_columns, color = rvol - rvol2 > 0 and rvol - rvol2 > sma1 ? #4db6ac : rvol - rvol2 > 0 ? #00796b : rvol - rvol2 < 0 and rvol - rvol2 < sma2 ? #4db6ac : #00796b)
plot(theme == "Directional Pressure" and close < open and (rvol - rvol2) > 0 ? (rvol - rvol2) * -1 : na, style = plot.style_columns, color = rvol - rvol2 > 0 and rvol - rvol2 > sma1 ? #ef5350 : rvol - rvol2 > 0 ? #9a2b2b : rvol - rvol2 < 0 and rvol - rvol2 < sma2 ? #ef5350 : #9a2b2b)
//plot(theme == "Directional Pressure 2" and close < open and (rvol - rvol2) < 0 ? (rvol - rvol2) * -1 : na, style = plot.style_columns, color = rvol - rvol2 > 0 and rvol - rvol2 > sma1 ? #4db6ac : rvol - rvol2 > 0 ? #00796b : rvol - rvol2 < 0 and rvol - rvol2 < sma2 ? #4db6ac : #00796b)
//plot(theme == "Directional Pressure 2" and close > open and (rvol - rvol2) < 0 ? rvol - rvol2 * -1 : na, style = plot.style_columns, color = rvol - rvol2 > 0 and rvol - rvol2 > sma1 ? #ef5350 : rvol - rvol2 > 0 ? #9a2b2b : rvol - rvol2 < 0 and rvol - rvol2 < sma2 ? #ef5350 : #9a2b2b)
//plot(theme == "Directional Pressure 2" and close > open and (rvol - rvol2) > 0 ? (rvol - rvol2) : na, style = plot.style_columns, color = rvol - rvol2 > 0 and rvol - rvol2 > sma1 ? #4db6ac : rvol - rvol2 > 0 ? #00796b : rvol - rvol2 < 0 and rvol - rvol2 < sma2 ? #4db6ac : #00796b)
//plot(theme == "Directional Pressure 2" and close < open and (rvol - rvol2) > 0 ? (rvol - rvol2) : na, style = plot.style_columns, color = rvol - rvol2 > 0 and rvol - rvol2 > sma1 ? #ef5350 : rvol - rvol2 > 0 ? #9a2b2b : rvol - rvol2 < 0 and rvol - rvol2 < sma2 ? #ef5350 : #9a2b2b)
plot(widget == "Directional Pressure" and close < open and (rvol - rvol2) < 0 or widget == "Support vs Resistance + Directional Pressure" and close < open and (rvol - rvol2) < 0 ? (rvol - rvol2) * -1 : na, style = plot.style_columns, color = rvol - rvol2 > 0 and rvol - rvol2 > sma1 ? #4db6ac : rvol - rvol2 > 0 ? #00796b : rvol - rvol2 < 0 and rvol - rvol2 < sma2 ? #4db6ac : #00796b, show_last = 10, offset = offset1)
plot(widget == "Directional Pressure" and close > open and (rvol - rvol2) < 0 or widget == "Support vs Resistance + Directional Pressure" and close > open and (rvol - rvol2) < 0 ? rvol - rvol2 * -1 : na, style = plot.style_columns, color = rvol - rvol2 > 0 and rvol - rvol2 > sma1 ? #ef5350 : rvol - rvol2 > 0 ? #9a2b2b : rvol - rvol2 < 0 and rvol - rvol2 < sma2 ? #ef5350 : #9a2b2b, show_last = 10, offset = offset1)
plot(widget == "Directional Pressure" and close > open and (rvol - rvol2) > 0 or widget == "Support vs Resistance + Directional Pressure" and close > open and (rvol - rvol2) > 0 ? (rvol - rvol2) : na, style = plot.style_columns, color = rvol - rvol2 > 0 and rvol - rvol2 > sma1 ? #4db6ac : rvol - rvol2 > 0 ? #00796b : rvol - rvol2 < 0 and rvol - rvol2 < sma2 ? #4db6ac : #00796b, show_last = 10, offset = offset1)
plot(widget == "Directional Pressure" and close < open and (rvol - rvol2) > 0 or widget == "Support vs Resistance + Directional Pressure" and close < open and (rvol - rvol2) > 0 ? (rvol - rvol2) : na, style = plot.style_columns, color = rvol - rvol2 > 0 and rvol - rvol2 > sma1 ? #ef5350 : rvol - rvol2 > 0 ? #9a2b2b : rvol - rvol2 < 0 and rvol - rvol2 < sma2 ? #ef5350 : #9a2b2b, show_last = 10, offset = offset1)
tot1 = close < open and (rvol - rvol2) < 0 ? (rvol - rvol2) * -1 : close > open and (rvol - rvol2) < 0 ? rvol - rvol2 * -1 : close > open and (rvol - rvol2) > 0 ? (rvol - rvol2) : close < open and (rvol - rvol2) > 0 ? (rvol - rvol2) : na
totup = close < open and (rvol - rvol2) < 0 ? (rvol - rvol2) * -1 : close > open and (rvol - rvol2) > 0 ? (rvol - rvol2) : na
totdown = close > open and (rvol - rvol2) < 0 ? rvol - rvol2 * -1 : close < open and (rvol - rvol2) > 0 ? (rvol - rvol2) : na
totlength = input(10,"Lookback bars for Directional Pressure Percentage",group = "General Settings")
sumu = array.new_float(0)
for i = 0 to totlength
array.push(sumu, totup[i])
sumd = array.new_float(0)
for i = 0 to totlength
array.push(sumd, totdown[i])
tot = array.new_float(0)
for i = 0 to totlength
array.push(tot, tot1[i])
sumup = array.sum(sumu)
sumdown = array.sum(sumd)
sum = array.sum(tot)
percentup = (sumup / sum) * 100
percentdown = (sumdown / sum) * 100
percent = percentup > percentdown ? percentup : percentdown > percentup ? percentdown : na
plotshape(show and rvol4 < sma2 and open < close , color = color.yellow, style = shape.triangledown, location = location.bottom)
plotshape(show and rvol4 < sma2 and open > close , color = color.yellow, style = shape.triangleup, location = location.bottom)
plotshape(show and rvol3 > sma1 and open < close , color = #00796b , style = shape.triangleup, location = location.bottom)
plotshape(show and rvol3 > sma1 and open > close , color = #b71c1c , style = shape.triangledown, location = location.bottom)
plot(theme == "RVOL Analysis" or theme == "RVOL" ? sma : na,color = color.white)
plot(widget == "Support vs Resistance + Directional Pressure" and showlastsma ? sma3 : na,color = color.white, show_last = 10, offset = 11)
plot(theme == "Pressure Analysis" ? rvol - rvol2 : na, style = plot.style_columns, color = rvol - rvol2 > 0 and rvol - rvol2 > sma1 ? #4db6ac : rvol - rvol2 > 0 ? #00796b : rvol - rvol2 < 0 and rvol - rvol2 < sma2 ? #ef5350 : #9a2b2b)
if showlsma21 and not showlsma6
cond1 := crossover(ma2,0) or crossover(ma3,0)
if showlsma6 and not showlsma21
cond1 := crossover(ma2,0) or crossover(ma4,0)
if showlsma6 and showlsma21
cond1 := crossover(ma2,0) or crossover(ma3,0) or crossover(ma4,0)
plotshape(showentry? cond1 : na, title="Entry Signal", location=location.top, style=shape.circle, size=size.tiny, color=color.yellow, transp=0)
var table perfTable = table.new(position.top_right, 3, 2, border_width = 0)
f_fillCell(_table, _column, _row, _value) =>
_cellText = tostring(_value, "#.##") + x
table.cell(_table, _column, _row, _cellText, text_color = close > open ? color.teal : color.red)
f_fillCell4(_table, _column, _row, _value) =>
_cellText = tostring(_value, "#.##") + y
table.cell(_table, _column, _row, _cellText, text_color = color.blue)
f_fillCell3(_table, _column, _row, _value) =>
_cellText = tostring(_value, "#.##")
table.cell(_table, _column, _row, _cellText, text_color = color.yellow)
f_fillCell5(_table, _column, _row, _value) =>
_cellText = tostring(_value, "#.##") + "%"
table.cell(_table, _column, _row, _cellText, text_color = percentup > percentdown ? color.teal : percentdown > percentup ? color.red : na)
table.cell_set_text_halign(perfTable, 2, 1, text.align_right)
if barstate.islast and showvol
f_fillCell(perfTable, 2, 0, vol)
if barstate.islast and showpercent
f_fillCell5(perfTable, 2, 1, percent)
if barstate.islast and showavg
f_fillCell4(perfTable, 1, 0, avg3)
if barstate.islast and showrvol
f_fillCell3(perfTable, 0, 0, rvol2)
var table perfTable2 = table.new(position.top_center, 1, 2, border_width = 0)
f_fillCell2(_table, _column, _row, _value) =>
table.cell(_table, _column, _row, text_color = color.blue, text= syminfo.tickerid + " " + timeframe.period)
if barstate.islast and showticker
f_fillCell2(perfTable2, 0, 0, syminfo.description)
|
Relative Performance | https://www.tradingview.com/script/jE9szaxP-Relative-Performance/ | millerrh | https://www.tradingview.com/u/millerrh/ | 222 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © millerrh
// This script takes the Performance Indicator that was first published when tables were introduced (from @BeeHolder) and compares the performance of the chart
// ticker to the performance of a selected index/ticker. It also shows the monthly volatility (per stock screener) which is similar to ADR.
//@version=5
indicator('Relative Performance', overlay=false)
var table perfTable = table.new(position.middle_left, 9, 2, border_width=3)
lightTransp = 90
avgTransp = 80
heavyTransp = 70
// === USER INPUTS ===
i_posColor = input(color.rgb(38, 166, 154), title='Positive Color')
i_negColor = input(color.rgb(240, 83, 80), title='Negative Color')
i_volColor = input(color.new(#999999, 0), title='Volatility Color')
sym = input.symbol(title='Index/Ticker Compare', defval='SPY')
f_rateOfreturn(_v1, _v2) =>
(_v1 - _v2) * 100 / math.abs(_v2)
f_performance(sec, _barsBack) =>
request.security(sec, '1D', f_rateOfreturn(close, close[_barsBack]))
recentClose(sec) =>
request.security(sec, '1D', close)
lastYearClose(sec) =>
request.security(sec, '12M', close[1], lookahead=barmerge.lookahead_on)
f_fillCell(_table, _column, _row, _value, _timeframe) =>
_c_color = _value >= 0 ? i_posColor : i_negColor
_transp = math.abs(_value) > 10 ? heavyTransp : math.abs(_value) > 5 ? avgTransp : lightTransp
_cellText = str.tostring(_value, '0.00') + '%\n' + _timeframe
table.cell(_table, _column, _row, _cellText, bgcolor=color.new(_c_color, _transp), text_color=_c_color, width=6)
volatility(sec) => // Monthly Volatility in Stock Screener (also ADR)
request.security(sec, 'D', ta.sma((high - low) / math.abs(low) * 100, 21))
fiftyTwoHighDiff(sec) =>
fiftyTwoHigh = request.security(sec, 'W', ta.highest(high, 52))
request.security(sec, '1D', ((fiftyTwoHigh - close)/fiftyTwoHigh)*100)
f_fillCellVol(_table, _column, _row, _value) =>
_transp = math.abs(_value) > 7 ? heavyTransp : math.abs(_value) > 4 ? avgTransp : lightTransp
_cellText = str.tostring(_value, '0.00') + '%\n' + 'ADR'
table.cell(_table, _column, _row, _cellText, bgcolor=color.new(i_volColor, _transp), text_color=i_volColor, width=6)
f_fillCellFiftyTwo(_table, _column, _row, _value) =>
_c_color = _value <= 25 ? i_posColor : i_negColor
_transp = math.abs(_value) <= 10 ? heavyTransp : math.abs(_value) <= 15 ? avgTransp : lightTransp
_cellText = str.tostring(_value, '0.0') + '%\n' + 'OFF 52WK HIGH'
table.cell(_table, _column, _row, _cellText, bgcolor=color.new(_c_color, _transp), text_color=_c_color, width=10)
f_fillCellSec(_table, _column, _row, _value) =>
table.cell(_table, _column, _row, _value, bgcolor=color.new(i_volColor, avgTransp), text_color=i_volColor, width=12)
if barstate.islast
f_fillCellSec(perfTable, 0, 0, syminfo.ticker)
f_fillCell(perfTable, 1, 0, f_performance(syminfo.tickerid, 5), '1W')
f_fillCell(perfTable, 2, 0, f_performance(syminfo.tickerid, 21), '1M')
f_fillCell(perfTable, 3, 0, f_performance(syminfo.tickerid, 63), '3M')
f_fillCell(perfTable, 4, 0, f_performance(syminfo.tickerid, 126), '6M')
f_fillCell(perfTable, 5, 0, f_rateOfreturn(recentClose(syminfo.tickerid), lastYearClose(syminfo.tickerid)), 'YTD')
f_fillCell(perfTable, 6, 0, f_performance(syminfo.tickerid, 251), '1Y')
f_fillCellVol(perfTable, 7, 0, volatility(syminfo.tickerid))
f_fillCellFiftyTwo(perfTable, 8, 0, fiftyTwoHighDiff(syminfo.tickerid))
f_fillCellSec(perfTable, 0, 1, sym)
f_fillCell(perfTable, 1, 1, f_performance(sym, 5), '1W')
f_fillCell(perfTable, 2, 1, f_performance(sym, 21), '1M')
f_fillCell(perfTable, 3, 1, f_performance(sym, 63), '3M')
f_fillCell(perfTable, 4, 1, f_performance(sym, 126), '6M')
f_fillCell(perfTable, 5, 1, f_rateOfreturn(recentClose(sym), lastYearClose(sym)), 'YTD')
f_fillCell(perfTable, 6, 1, f_performance(sym, 251), '1Y')
f_fillCellVol(perfTable, 7, 1, volatility(sym))
f_fillCellFiftyTwo(perfTable, 8, 1, fiftyTwoHighDiff(sym))
|
VPA - 5.0 | https://www.tradingview.com/script/3lD9J22Q-VPA-5-0/ | karthikmarar | https://www.tradingview.com/u/karthikmarar/ | 1,622 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © karthikmarar
//Version 5 - dated 15 Aug 2023 - Revision Notes
//Now the user has an option to display SOS and SOW symbols instead of text labels. The description of the SOS/SOW can be made available with the help of Tooltips displayed when the cursor is placed on the symbols
//Bugs in the trend band for the Minor Trend has been corrected
//Status of the "Relative Strength" (In comparision to NSE 500) , The Absolute Strength of the stock trend and the Moneyflow in to the stock are displayed in the STatus Table on the right Hand side top.
//New signal added - High Volume unable to move price. Demand / Supply Area - Bullish or Bearish Depending on the Location of the Bar
//@version=4
// This is a updated version of the VPA Analysis, Rechristened as VPA 5.0 to be inline with the Amibroker Version.
// Thanks to Marge Pande for Coding assistance - Resistance and Volume Lines and some updates
// Credits to Quantnomad for the new Alert log (Public Script).
// Revision Notes
// Added the Bar Status and Trend Indication Table
// Aded the Alert Indicatio and LOg
// New signals like two bar reversal and Ease of movement added
// Option to switch off various VSA indication added
//Added option to plot Ressitance and Volume LInes
//-------------------------Revision 1 ------------------------------------------
//--------------------------Revision Notes-------------------------------------------
//Version 5 - Revision Notes
//Now the user has an option to display SOS and SOW symbols instead of text labels. The description of the SOS/SOW can be made available with the help of Tooltips displayed when the cursor is placed on the symbols
//Bugs in the trend band for the Minor Trend has been corrected
//Status of the "Relative Strength" (In comparison to NSE 500) , The Absolute Strength of the stock trend and the Money flow in to the stock are displayed in the Status Table on the right Hand side top.
//New signal added - High Volume unable to move price. Demand / Supply Area - Bullish or Bearish Depending on the Location of the Bar
// The Bar colouring based on strength (3 Colours) is confusing to many users and will be removed.
//New bar colouring has been introduced. If the close is higher than yesterday’s close then it will be coloured in green shade. If the volume is below average then the colour will be in lighter green and if the volume is higher than average colour will be darker shade of green.in the similar manner if the close is lower than yesterdays’ close then the bar will be coloured in shades of Red depending on Volume. The average volume will be 60 days volume.
//------------------------------------------------------------------------------------------------------------------------
study("VPA - 5.0 ", overlay=true, max_labels_count=500)
crt = input(true, "New Chart format with symbols and POP up descriptions")
bkbg = input(title="Black Background", type=input.bool, defval=false)
showtrend = input(false, title="Show Trend Bands", type=input.bool, group="Bands")
strband = input(false, title="Show Strength Bands", type=input.bool, group="Bands")
plot50 = input(title="Plot 50 EMA", type=input.bool, defval=false, group="Mov.Avg")
plot200 = input(title="Plot 200 EMA", type=input.bool, defval=false, group="Mov.Avg")
plot(plot50? ema(close,50): na, "EMA50", color= color.blue, style = plot.style_line )
plot(plot200? ema(close,200): na,"EMA200", color=color.fuchsia, style = plot.style_line )
//---------------------Plot EMA's and VWAP------------------------------------
showvwap = input(false, "Show VWAP", group="VWAP & EMA")
plot(showvwap ? vwap : na, "VWAP", color=color.new(color.yellow,10), style=plot.style_stepline, linewidth=2)
showpma = input(false, "Show EMA", group="VWAP & EMA")
emasrc = input("CLOSE", "EMA Source", options=["CLOSE","PIVOT"], group="VWAP & EMA")
shp = input(13,"Short EMA period", group="VWAP & EMA")
mip = input(34, "Mid EMA period", group="VWAP & EMA")
lop = input(55, "Long EMA period", group="VWAP & EMA")
pe = emasrc == "CLOSE" ? close : hlc3
ped = ema(pe,shp)
pew = ema(pe,mip)
pem = ema(pe,lop)
plot1 = plot(showpma ? ped : na, "PEMA-Short", color=color.lime)
plot2 = plot(showpma ? pew : na, "PEMA-Medium", color=color.yellow)
plot3 = plot(showpma ? pem : na, "PEMA-Long", color=color.red)
fill(plot1, plot2, color.new(color.green, transp =90) )
fill(plot2, plot3, color.new(color.yellow, transp =90) )
//-------------------End of EMA and VWAP section --------------
//===================== Basic VSA Definitions =======================================
volAvg = sma(volume,60)
volMean = stdev(volAvg,30)
volUpBand3 = volAvg + (3*volMean)
volUpBand2 = volAvg + (2*volMean)
volUpBand1 = volAvg + (1*volMean)
volDnBand1 = volAvg -(1*volMean)
volDnBand2 = volAvg - (2*volMean)
H = high
L = low
V = volume
C = close
O = open
midprice = (H+L)/2
spread = (H-L)
avgSpread = sma(spread,40)
AvgSpreadBar = spread > avgSpread// to be checked
wideRangeBar = spread>(1.5*avgSpread)
narrowRangeBar = spread<(0.7*avgSpread)
lowVolume = V<volume[1] and V<volume[2] and V <volAvg // mods
upBar = C>close[1]//C>Ref(C,-1)
downBar = C<close[1]//C<Ref(C,-1)
highVolume = V>volume[1] and volume[1]>volume[2]// Review
closeFactor = C-L
clsPosition = spread/closeFactor
closePosition = ((closeFactor == 0) ? (avgSpread) : (clsPosition))
vb = V > volAvg or V> volume[1]
upClose = C>=((spread*0.7)+L)// close is above 70% of the Bar
downClose = C<=((spread*0.3)+L)// close is below the 30% of the bar
aboveClose = C>((spread*0.5)+L)// close is between 50% and 70% of the bar
belowClose = C<((spread*0.5)+L)// close is between 50% and 30% of the bar
midClose = C>((spread*0.3)+L) and C<((spread*0.7)+L)// close is between 30% and 70% of the bar
veryLowClose = closePosition>4//close is below 25% of the bar
veryHighClose = closePosition<1.35// Close is above 80% of the bar
ClosePos = iff(C<=((spread*0.2)+L),1,iff(C<=((spread*0.4)+L),2,iff(C<=((spread*0.6)+L),3,iff(C<=((spread*0.8)+L),4,5))))
//1 = downClose, 2 = belowClose, 3 = midClose, 4 = aboveClose, 6 = upClose
volpos = iff(V>(volAvg*2),1,iff(V>(volAvg*1.3),2,iff(V>volAvg,3,iff(V<volAvg and (V<volAvg*0.7) ,4,5))))
//1 = veryhigh, 2 = High , 3 = AboveAverage, 4 = volAvg //LessthanAverage, 5 = lowVolume
freshGndHi = high == highest(high,5)?1:0
freshGndLo = low == lowest(low,5)?1:0
//---------------No Movement Bar--------------------
pm = abs(C - O) // price move
pma = ema(pm, 40) // avg price move
Lpm = pm < (0.5 * pma) // small price move
bw = C > O ? H-C : H-O // wick
bwh = bw >= 2 * pm // big wick
fom1 = V > 1.5 * volAvg and Lpm // high volume not able to move the price
//---------------Two Bar Revrsal Dowm side--------------------
tbcd = C[1] < C[5] and C[1] < C[4] and C[1] < C[3] and C[1] < C[2] //yesterday bar lower than last 4 bars
tbc1 = L < L[1] and H > H[1] // today bar shadoes yesterday bar
tbc1a = L < L[1] and C > C[1]
tbc2 = tbcd == 1 and tbc1 == 1 and V > 1.2 * volAvg and upClose
tbc2a = tbcd == 1 and tbc1a == 1 and V > 1.2 * volAvg and upClose and not tbc1
tbc3 = tbcd == 1 and tbc1 == 1 and upClose and V <= 1.2 * volAvg
//---------------- Two bar reversal Up sie --------------------
tbcu = C[1] > C[5] and C[1] > C[4] and C[1] > C[3] and C[1] > C[2]
tbc4 = tbcu == 1 and tbc1 == 1 and V > 1.2 * volAvg and downClose
tbc5 = tbcu == 1 and tbc1 == 1 and downClose and V <= 1.2 * volAvg
//=========================================================================|
// Trend Analysis Module |
//=========================================================================|
rwhmins = (high - nz(low[2])) / (atr(2) * sqrt(2))
rwhmaxs = (high - nz(low[10])) / (atr(10) * sqrt(10))
rwhs = max( rwhmins, rwhmaxs )
rwlmins = (nz(high[2]) - low) / (atr(2) * sqrt(2))
rwlmaxs = (nz(high[10]) - low) / (atr(10) * sqrt(10))
rwls = max( rwlmins, rwlmaxs )
rwhminl = (high - nz(low[8])) / (atr(8) * sqrt(8))
rwhmaxl = (high - nz(low[40])) / (atr(40) * sqrt(40))
rwhl = max( rwhminl, rwhmaxl )
rwlminl = (nz(high[8]) - low) / (atr(8) * sqrt(8))
rwlmaxl = (nz(high[40]) - low) / (atr(40) * sqrt(40))
rwll = max( rwlminl, rwlmaxl )
//RWILLo = max(rllmin,rllmax)
ground = rwhs
sky = rwls
j = rwhl-rwll
k = rwhs-rwls
j2 = rwhl
k2 = rwll
ja = crossover(j,1) // The following section check the diffeent condition of the RWi above and below zero
jb = crossunder(j,1) // In oder to check which trend is doing what
jc = crossover(-1,j)
jd = crossover(j,-1)
j2a = crossover(j2,1)
j2b = crossunder(j2,1)
k2a = crossover(k2,1)
k2b = crossunder(k2,1)
//Define the Major, Minor and Immediate trend Status
upmajoron = j > 1 and ja[1]
upmajoroff = j < 1 and jb[1]
upminoron = j2 > 1 and j2a[1]
upminoroff = j2 < 1 and j2b[1]
dnmajoron = j < -1 and jc[1]
dnmajoroff = j > -1 and jd[1]
dnminoron = k2 > 1 and k2a[1]
dnminoroff = k2 < 1 and k2b[1]
upmid = iff(ground > 1, 1,0)
dnimd = iff(sky > 1, 1, 0)
upmajor = iff(j>1,1,iff(j<(-1),-1,0))
upminor = iff(j2>1,1,-1)
dnminor = iff(k2>1,1,-1)
upmajclr = upmajor ==1 ? color.rgb(3, 252, 36) : upmajor == -1 ? #fa5050 : #f4fc79
//upmajclr = upmajor == 1 ? color.lime : upmajor == -1? color.red : color.yellow
upmidclr = upmid == 1 ? color.lime : upmid == 0 and dnimd == 1? color.red : color.yellow
upminclr = upminor == 1 ? color.lime : upminor == -1 ? color.red : color.yellow
plotshape(showtrend, title="Major Trend", style=shape.square, color=upmajclr, location=location.top, size= size.normal, text="")
plotshape(showtrend, title="Mid Trend", style=shape.square, color=upmidclr, location=location.top, size = size.small, text="")
plotshape(showtrend, title="Minor Trend", style=shape.square, color=upminclr, location=location.top, size = size.tiny, text="")
//=========================================================================|
// Slope Calculation |
//=========================================================================|
src = sma(close,5)
//--------------longterm trend---------------
lts = linreg(src, 40, 0)
ltsprev = linreg(close[3], 40, 0)
ltsslope = ((lts - ltsprev) / 3 )
//-------------Medium Term Trend-------------
mts = linreg(src, 20, 0)
mtsprev = linreg(close[3], 20, 0)
mtsslope = ((mts - mtsprev) / 3 )
//-------------short Term Trend-------------
sts = linreg(src, 3, 0)
stsprev = linreg(close[1], 3, 0)
stsslope = ((sts - stsprev) / 2 )
tls = stsslope
//=========================================================================|
// VSA SIGNAL GENERATION |
//=========================================================================|
upThrustBar = wideRangeBar and downClose and high > high[1] and upmid==1 //WRB and UHS in midterm trend
nut = wideRangeBar and downClose and freshGndHi and highVolume // NEW SIGNAL - Upthrust after new short up move. Review and delete
bc = wideRangeBar and aboveClose and volume == highest(volume,60) and upmajor==1 // Buying Climax
upThrustBar1 = wideRangeBar and (ClosePos==1 or ClosePos==2) and upminor>0 and H>H[1]and (upmid>0 or upmajor>0) and volpos < 4 // after minor up trend
upThrustBartrue = wideRangeBar and ClosePos==1 and upmajor>0 and H>H[1] and volpos < 4//occurs after a major uptrend
upThrustCond1 = upThrustBar[1] and downBar and not narrowRangeBar // The Bar after Upthrust Bar- Confirms weakness
upThrustCond2 = upThrustBar[1] and downBar and V>(volAvg*1.3) // The Bar after Upthrust Bar- Confirms weakness
upThrustCond3 = upThrustBar and V>(volAvg*2) // Review
topRevBar = V[1]>volAvg and upBar[1] and wideRangeBar[1] and downBar and downClose and wideRangeBar and upmajor>0 and H==highest(H,10)// Top Reversal bar
PseudoUpThrust = (upBar[1])and H>H[1] and V[1]>1.5*volAvg and downBar and downClose and not upThrustBar
pseudoUtCond = PseudoUpThrust[1] and downBar and downClose and not upThrustBar
trendChange = upBar[1] and H==highest(H,5) and downBar and (downClose or midClose) and V>volAvg and upmajor>0 and upmid>0 and not wideRangeBar and not PseudoUpThrust
noDemandBarUt = upBar and narrowRangeBar and lowVolume and (aboveClose or upClose) and ((upminor>=0 and upmid>=0) or (upminor<=0 and upminor>=0))//in a up market
noDemandBarDt = upBar and narrowRangeBar and lowVolume and (aboveClose or upClose) and (upminor<=0 or upmid<=0)// in a down or sidewayss market
noSupplyBar = downBar and narrowRangeBar and lowVolume and midClose
lowVolTest = low == lowest(low,5) and upClose and lowVolume
lowVolTest1 = low == lowest(low,5) and V<volAvg and L<L[1] and upClose and upminor>0 and upmajor>0
lowVolTest2 = lowVolTest[1] and upBar and upClose
sellCond1 = (upThrustCond1 or upThrustCond2 or upThrustCond3)
sellCond2 = sellCond1[1]==0
sellCond = sellCond1 and sellCond2
strengthDown0 = upmajor < 0 and volpos < 4 and downBar[1] and upBar and ClosePos>3 and dnminor ==1 and dnimd == 1
strengthDown = volpos<4 and downBar[1] and upBar and ClosePos>3 and dnimd == 1 and dnminor ==1 //upmid < 0 and upminor<0 // Strength after a down trend
strengthDown1 = upmajor== -1 and V>(volAvg*1.5) and downBar[1] and upBar and ClosePos>3 and upmid<=00 and upminor<0
strengthDown2 = upmid<=0 and V[1]<volAvg and upBar and veryHighClose and volpos<4
buyCond1 = strengthDown or strengthDown1
buyCond = upBar and buyCond1[1]
stopVolume = L==lowest(L,5) and (upClose or midClose) and V>1.5*volAvg and upmajor<0
revUpThrust = upBar and upClose and V>V[1] and V>volAvg and wideRangeBar and downBar[1] and downClose[1] and upminor<0 and close<close[1]
effortUp = H>H[1] and L>L[1] and C>C[1] and C>=((H-L)*0.7+L) and spread>avgSpread and volpos < 4
effortUpfail = effortUp[1] and (upThrustBar or upThrustCond1 or upThrustCond2 or upThrustCond3 or (downBar and AvgSpreadBar))
effortDown = H<H[1] and L<L[1] and C<C[1] and C<=((H-L)*0.25+L) and wideRangeBar and V>V[1]
effortDownFail = effortDown[1] and ((upBar and AvgSpreadBar) or revUpThrust or buyCond1)
upflag = (sellCond or buyCond or effortUp or effortUpfail or stopVolume or effortDown or effortDownFail or revUpThrust or noDemandBarDt or noDemandBarUt or noSupplyBar or lowVolTest or lowVolTest1 or lowVolTest2 or bc)
bullBar = (V>volAvg or V>V[1]) and C<=((spread*0.2)+L) and upBar and not upflag
bearBar = vb and downClose and downBar and spread>avgSpread and not upflag
sc = wideRangeBar and belowClose and V == highest(V,60) and upmajor== -1 // NEW SIGNAL Selling Climax
//=============================== PLOT SHAPES SECTION===================
ofs = close * 0.02
showut = input(true, "Show Up Thrusts (UT)", tooltip="An Upthrust Bar. A sign of weakness. High Volume adds weakness. A down bar after Upthrust adds weakness", group="VSA Signals")
plotshape(showut and not crt? (upThrustBar or upThrustBartrue) and not effortUpfail and not sellCond and not bc : na, "", style=shape.triangledown, location=location.abovebar, color=color.new(#990000,0), text="UT1", textcolor=#990000, editable=false, size=size.tiny)
UT1 = upThrustBar or upThrustBartrue
plotshape(showut and not crt ? (upThrustCond1 or upThrustCond2 ) and not effortUpfail and not sellCond and not bc : na, "UT2", style=shape.triangledown, location=location.abovebar, color=color.new(#ff0000, 0), text="UT2", textcolor=#ff0000, editable=false, size=size.tiny)
UT2 = upThrustCond1 or upThrustCond2
UT = UT1 or UT2
//----------------------
// Draw a new label above the current bar's high
if UT and crt
UTLabel = label.new(x=bar_index, y=high+ofs, color=color.new(color.red,0),style=label.style_triangledown, size=size.tiny)
label.set_tooltip(UTLabel, "--------------- \n SOW \n--------------\n UPTHRUST BAR \n----------------\n A Sign of Weakness. The prices were marked up first, attracting the retail buyer. Then prices are rapidly marked down trapping the weak hands ")
//-------------------------------
//alertcondition(upThrustBar, title='Alert on UT1 an UT2 and UT', message='An Upthrust Bar. A sign of weakness. High Volume adds weakness. A down bar after Upthrust adds weakness')
showtrb = input(true, "Show Top Reversal Bar (TRB)", tooltip="Top Reversal. Sign of Weakness. ", group="VSA Signals")
plotshape(showtrb and not crt ? topRevBar and not sellCond and not UT and not effortUpfail : na, "TRB", style=shape.triangledown, location=location.abovebar, color=color.new(#ff9900, 0), text="TRB", textcolor=#ff9900, editable=false, size=size.tiny)
//alertcondition(topRevBar , title='Alert on TRB', message='Top Reversal. Sign of Weakness. ')
if (topRevBar and not sellCond and not UT and not effortUpfail) and crt
TRBLabel = label.new(x=bar_index, y=high+ofs, color=color.new(color.red,0),style=label.style_triangledown, size=size.tiny)
label.set_tooltip(TRBLabel, "--------------- \n SOW \n--------------\n TOP REVERSAL BAR \n----------------\n A Sign of Weakness. Probable top is being formed and probability of reversal looks eminent ")
//--------------------------------------------------------------------
showtch = input(true, "Show Trend Change (TC)", tooltip="High volume Downbar after an upmove on high volume indicates weakness.", group="VSA Signal")
plotshape(showtch and not crt? trendChange and not effortUpfail : na, "TC", style=shape.triangledown, location=location.abovebar, color=color.new(#ff471a, 0), text="TC", textcolor=#ff471a, editable=false, size=size.tiny)
//alertcondition(trendChange , title='Alert on TCH', message='High volume Downbar after an upmove on high volume indicates weakness. ')
if (trendChange and not effortUpfail) and crt
TCLabel = label.new(x=bar_index, y=high+ofs, color=color.new(color.red,0),style=label.style_triangledown, size=size.tiny)
label.set_tooltip(TCLabel, "--------------- \n SOW \n--------------\n TREND CHANGE BAR \n----------------\n A Sign of Weakness. Indicates high probability of a Trend Change from Up Trend ")
//---------------------------------------------------------------------
showput = input(true, "Show Pseudo Up Thrust (PST/PUC)", tooltip="Psuedo UpThrust. A Sign of Weakness.A Down Bar closing down after a Pseudo Upthrust confirms weakness. ", group="VSA Signals")
plotshape(showput and not crt ? PseudoUpThrust and not effortUpfail : na , "PUT", style=shape.triangledown, location=location.abovebar, color=color.new(#ff471a, 0), text="PUT", textcolor=#ff471a, editable=false, size=size.tiny)
plotshape(showput and not crt? pseudoUtCond and not effortUpfail : na, "PUC", style=shape.triangledown, location=location.abovebar, color=color.new(#ff471a, 0), text="PUC", textcolor=#ff471a, editable=false, size=size.tiny)
if (PseudoUpThrust and not effortUpfail) and crt
PTLabel = label.new(x=bar_index, y=high+ofs, color=color.new(color.orange,0),style=label.style_triangledown, size=size.tiny)
label.set_tooltip(PTLabel, "--------------- \n SOW \n--------------\n PSEUDO UPTHRUST BAR \n----------------\n A Sign of Weakness. Psuedo UpThrust Bar. An UpThrust Bar on lower volume. Indicates weakness, though reduced. ")
//-----------------------------
shownd = input(true, "Show No Demand (ND)", tooltip="No Demand in a Uptrend. A sign of Weakness. Otherwise upside unlikely soon ", group="VSA Signals")
plotshape(shownd and not crt? noDemandBarUt : na, "ND", style=shape.circle, location=location.abovebar, color=#f7e30c, text="ND", textcolor=#ff471a, editable=false, size=size.tiny)
plotshape(shownd and not crt? noDemandBarDt : na, "ND", style=shape.circle, location=location.abovebar, color=#f7e30c, text="ND", textcolor=#ff471a, editable=false, size=size.tiny)
//alertcondition(noDemandBarUt or noDemandBarDt , title='Alert on ND', message='No Demand in a Uptrend. A sign of Weakness. Otherwise upside unlikely soon ')
if noDemandBarUt and crt
NDLabel1 = label.new(x=bar_index, y=high+ofs, color=color.new (color.yellow,0),style=label.style_triangledown, size=size.tiny)
label.set_tooltip(NDLabel1, "--------------- \n SOW \n--------------\n NO DEMAND BAR \n----------------\n A Sign of Weakness. Indicates lack of Demand. Without Demand price cannot move up. No Demand in a Up trend indicates more weakness ")
if noDemandBarDt and crt
NDLabel2 = label.new(x=bar_index, y=high+ofs, color=color.new(color.yellow,0),style=label.style_triangledown, size=size.tiny)
label.set_tooltip(NDLabel2, "--------------- \n SOW \n--------------\n NO DEMAND BAR \n----------------\n A Sign of Weakness. Indicates lack of Demand in a down Trend.Does not have much impact ")
//------------------------------------------------------
showns = input(true, "Show No Supply (NS)", tooltip="No Supply. A sign of Strength.", group="VSA Signals")
plotshape(showns and not crt? noSupplyBar : na, "NS", style=shape.circle, location=location.belowbar, color=color.new(color.lime, 0), text="NS", textcolor=color.green, editable=false)
// alertcondition(noSupplyBar , title='Alert on NS', message='No Supply. A sign of Strength. ')
if noSupplyBar and crt
NSLabel = label.new(x=bar_index, y=low-ofs, color=color.new(color.yellow,0),style=label.style_triangleup, size=size.tiny)
label.set_tooltip(NSLabel, "--------------- \n SOS \n--------------\n NO SUPPLY BAR \n----------------\n A Sign of Strength. Indicates lack of Supply. Without Supply price cannot move down ")
//---------------------------------------------------------------------------------------------
showlvtst = input(true, "Show Low Volume Supply Test (LVT/ST)", tooltip="Test of Supply. A high volume Bar closing on High after the Test will confirm the Strength", group="VSA Signals")
plotshape(showlvtst and not crt ? lowVolTest and not effortDownFail : na, "LVT", style=shape.circle, location=location.belowbar, color=color.new(color.lime, 0), text="LVT", textcolor=color.green, editable=false, size=size.tiny)
plotshape(showlvtst and not crt? lowVolTest2 and not effortUp : na, "ST", style=shape.triangleup, location=location.belowbar, color=color.new(color.lime, 0), text="ST", textcolor=color.green, editable=false, size=size.tiny)
lvt = lowVolTest or lowVolTest2
//alertcondition(lvt , title='Alert on LVT', message='Test for supply. An upBar closing near High after a Test confirms strength. ')
if (lowVolTest and not effortDownFail) and crt
LV1Label = label.new(x=bar_index, y=low-ofs, color=color.new(color.lime,0) ,style=label.style_triangleup, size=size.tiny)
label.set_tooltip(LV1Label, "--------------- \n SOS \n--------------\n LOW VOLUME TEST \n----------------\n Sign of Strength. \n Test of Supply. A high volume Bar closing on High after the Test will confirm the Strength")
if (lowVolTest2 and not effortUp ) and crt
LV2Label = label.new(x=bar_index, y=low-ofs, color=color.new(color.lime,0),style=label.style_triangleup, size=size.tiny)
label.set_tooltip(LV2Label, "--------------- \n SOS \n--------------\n LOW VOLUME TEST \n----------------\n Sign of Strength. \n Test of Supply. A high volume Bar closing on High after the Test will confirm the Strength")
//----------------------------------------------------------------------------------------
EFD = effortDownFail
ST1 = strengthDown0
ST2 = strengthDown and not strengthDown2
strcond = (strengthDown2 and not strengthDown0 and not strengthDown and not strengthDown1)? 1:0
ST3 = strengthDown1
ST4 = strengthDown2 and strcond
ST5 = strengthDown2 and not strcond
ST = ST1 or ST2 or ST3 or ST4 or ST5
showstsig = input(true, "Show Strength Signals (ST)", tooltip="Strength seen returning after a down trend.", group="VSA Signals")
plotshape(showstsig and not crt? strengthDown0 : na, "ST1", style=shape.triangleup, location=location.belowbar, color=color.new(color.lime, 0), text="ST1", textcolor=color.green, editable=false, size=size.tiny)
//plotshape(showstsig ? strengthDown0 and not EFD and not effortUp and not stopVolume and not revUpThrust : na, "ST1", style=shape.triangleup, location=location.belowbar, color=color.new(color.lime, 0), text="ST1", textcolor=color.green, editable=false, size=size.tiny)
plotshape(showstsig and not crt ? strengthDown and not strengthDown2 and not EFD and not effortUp and not stopVolume and not revUpThrust: na, "ST2", style=shape.triangleup, location=location.belowbar, color=color.new(color.lime, 0), text="ST1", textcolor=color.green, editable=false, size=size.tiny)
plotshape(showstsig and not crt ? strengthDown1 and not EFD and not effortUp and not stopVolume and not revUpThrust : na, "ST3", style=shape.triangleup, location=location.belowbar, color=color.new(color.lime, 0), text="ST1", textcolor=color.green, editable=false, size=size.auto)
plotshape(showstsig and not crt ? strengthDown2 and strcond and not EFD and not effortUp and not stopVolume and not revUpThrust: na, "ST4", style=shape.triangleup, location=location.belowbar, color=color.new(color.lime, 0), text="ST2", textcolor=color.green, editable=false, size=size.tiny)
//alertcondition(ST , title='Alert on ST1, ST2, ST3, ST4 and ST', message='Strength seen returning after a down trend. ')
if strengthDown0 and crt
ST1Label = label.new(x=bar_index, y=low-ofs, color=color.new(color.lime,0),style=label.style_triangleup, size=size.tiny)
label.set_tooltip(ST1Label, "--------------- \n SOS \n--------------\n STRENGTH COMING IN \n----------------\n sign of Strength. \n Strength coming in after a Down Trend")
if strengthDown and crt
ST2Label = label.new(x=bar_index, y=low-ofs, color=color.new(color.lime,0),style=label.style_triangleup, size=size.tiny)
label.set_tooltip(ST2Label, "--------------- \n SOS \n--------------\n STRENGTH COMING IN \n----------------\n sign of Strength. \n Strength coming in after a Down Trend")
if strengthDown1 and crt
ST3Label = label.new(x=bar_index, y=low-ofs, color=color.new(color.lime,0),style=label.style_triangleup, size=size.tiny)
label.set_tooltip(ST3Label, "--------------- \n SOS \n--------------\n STRENGTH COMING IN \n----------------\n sign of Strength. \n Strength coming in after a Down Trend. High VOlume adds to the strength")
if strengthDown2 and crt
ST4Label = label.new(x=bar_index, y=low-ofs, color=color.new(color.lime,0),style=label.style_triangleup, size=size.tiny)
label.set_tooltip(ST4Label, "--------------- \n SOS \n--------------\n STRENGTH COMING IN \n----------------\n sign of Strength. \n High volume upBar closing on the high indicates strength.")
//--------------------------------------------------------------------------------------------------------------------------------------
showsv = input(true, "Show Stop Volume (SV)", tooltip="Stopping volume. Normally indicates end of bearishness is nearing.", group="VSA Signals")
plotshape(showsv and not crt ? stopVolume and not ST : na, "SV", style=shape.circle, location=location.belowbar, color=color.new(color.lime, 0), text="SV", textcolor=color.green, editable=false, size=size.auto)
//plotshape(showsv ? stopVolume and ST : na, "SV" , style=shape.circle, location=location.belowbar, color=color.new(color.lime, 0), text="ST\nSV", textcolor=color.green, editable=false, size=size.auto)
//alertcondition(stopVolume , title='Alert on SV', message='Stopping volume. Normally indicates end of bearishness is nearing. ')
if stopVolume and not ST and crt
SVLabel = label.new(x=bar_index, y=low-ofs, color=color.new(color.lime,0),style=label.style_triangleup, size=size.tiny)
label.set_tooltip(SVLabel, "--------------- \n SOS \n--------------\n STOPPING VOLUME \n----------------\n 1. Stopping volume is also called as absorption volume. \n 2. This indicates that the weak hands are panic selling and the strong hands are stepping in to absorb the selling. As a result the stock will soon see side ways movement or go into a long accumulation phase." +
" \n 3. In effect the stopping volume or absorption volume indicates that the long bearish move is likely to end soon. \n 4. Stopping volumes are basically alert to the impending reversal. ")
//---------------------------------------------------------------------------
showeu = input(true, "Show Effort Up (EU)", tooltip="Effort to Move up. Bullish Sign.", group="VSA Signals")
plotshape(showeu and not crt? effortUp and not ST and not buyCond and not effortDownFail and not bc: na, "EU", style=shape.triangleup, location=location.belowbar, color=color.new(color.lime, 0), text="EU", textcolor=color.green, editable=false, size=size.tiny)
//REV 1 /plotshape(showeu ? effortUp and ST and not buyCond : na, "EU", style=shape.triangleup, location=location.belowbar, color=color.new(color.lime, 0), text="ST\nEU", textcolor=color.green, editable=false, size=size.tiny)
//alertcondition(effortUp , title='Alert on EU', message='Effort to Move up. Bullish Sign. ')
if (effortUp and not ST and not buyCond and not effortDownFail and not bc ) and crt
EULabel = label.new(x=bar_index, y=low-ofs, color=color.new(color.lime,0),style=label.style_triangleup, size=size.tiny)
label.set_tooltip(EULabel, "--------------- \n SOS \n--------------\n EFFORT MOVE UP BAR \n----------------\n 1. Also called “Effort to Rise” Bar \n 2. Indicates that Smart money is pushing up the Price \n 3. Indicates that interest is coming in the stock \n 4. Most common signal seen")
//-------------------------------------------------------------------------------------------
showeuf = input(true, "Show Effort Up Fail (EUF)", tooltip="Effort to Move up Failed. Bearish sign.", group="VSA Signals")
plotshape(showeuf and not crt ? effortUpfail and not UT : na, "EUF", style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), text="EUF", textcolor=color.red, editable=false, size=size.tiny)
//alertcondition(effortUpfail , title='Alert on EUF', message='Effort to Move up Failed. Bearish sign ')
if (effortUpfail and not UT) and crt
EUFLabel = label.new(x=bar_index, y=high+ofs, color=color.new(color.orange,0),style=label.style_triangledown, size=size.tiny)
label.set_tooltip(EUFLabel, "--------------- \n SOW \n--------------\n EFFORT TO MOVE UP FAILED \n----------------\n sign of Weakness. \n Effort to Move Up Failed. Supply is still present and overcame effort to move up stock")
//------------------------------------------------------------------------------------------------------------------------------------
showed = input(true, "Show Effort Down (ED)", tooltip="Effort to Move Down. Bearish Sign.", group="VSA Signals")
plotshape(showed and not crt? effortDown and not effortUpfail and not sc : na, "ED", style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), text="ED", textcolor=color.green, editable=false, size=size.tiny)
//alertcondition(effortDown , title='Alert on ED', message='Effort to Move Down. Bearish Sign ')
if (effortDown and not effortUpfail and not sc) and crt
EUFLabel = label.new(x=bar_index, y=high+ofs, color=color.new(color.orange,0),style=label.style_triangledown, size=size.tiny)
label.set_tooltip(EUFLabel, "--------------- \n SOW \n--------------\n EFFORT TO MOVE DOWN \n----------------\n sign of Weakness. \n Overwhelming supply psuhing down the Price")
//------------------------------------------------------------------------------------------------------------------------------
showedf = input(true, "Show Effort Down Fail (EDF)", tooltip="Effort to Move Down Failed. Bullish sign.", group="VSA Signals")
plotshape(showedf and not crt? effortDownFail and not ST : na, "EDF", style=shape.triangleup, location=location.belowbar, color=color.new(color.lime, 0), text="EDF", textcolor=color.green, editable=false, size=size.tiny)
//plotshape(showedf and not crt? effortDownFail and ST : na, "EDF", style=shape.triangleup, location=location.belowbar, color=color.new(color.lime, 0), text="ST\nEDF", textcolor=color.green, editable=false, size=size.tiny)
//alertcondition(effortDownFail , title='Alert on EDF', message='Effort to Down Failed. Bullish sign ')
if (effortDownFail and not ST) and crt
EDFLabel = label.new(x=bar_index, y=low-ofs, color=color.rgb(81, 238, 152, 13),style=label.style_triangleup, size=size.tiny)
label.set_tooltip(EDFLabel, "--------------- \n SOS \n--------------\n EFFORT TO MOVE DOWN FAIL\n----------------\n sign of Strength. \n Effort to push the prices down has been overcome by demand. Shows Demand has the upper hand.")
//-----------------------------------------------------------------------------------------------------
showrut = input(true, "Show Reverse Up Thrust (RUT)", tooltip="Reverse Up Thrust - Bullish sign.", group="VSA Signals")
plotshape(showrut and not crt ? revUpThrust and not ST : na, "RUT", style=shape.triangleup, location=location.belowbar, color=color.new(color.lime, 0), text="RUT", textcolor=color.green, editable=false, size=size.auto)
//alertcondition(revUpThrust , title='Alert on RUT', message='Reverse Up Thrust - Bullish.')
if (revUpThrust and not ST) and crt
RUTLabel = label.new(x=bar_index, y=low-ofs, color=color.rgb(57, 193, 91, 13),style=label.style_triangleup, size=size.tiny)
label.set_tooltip(RUTLabel, "--------------- \n SOS \n--------------\n REVERSE UPTHRUST\n----------------\n sign of WeaknessStrength. \n First the Prices are drivedriven down attracting short. Then the prices are quickly marked up Trapping the shorts. Normally happens at reversla points")
//------------------------------------------------------------------------
showbyc = input(true, "Show Buy Condition Exist (BCE)", tooltip="Strength Returns - Buy Condition exist.", group="VSA Signals")
plotshape(showbyc and not crt ? buyCond and not ST and not effortUp and not lvt : na, "BCE1", style=shape.triangleup, location=location.belowbar, color=color.new(color.lime, 0), text="BCE", textcolor=color.green, editable=false, size=size.tiny)
//plotshape(showbyc ? buyCond and not ST and effortUp : na, "BCE2", style=shape.triangleup, location=location.belowbar, color=color.new(color.lime, 0), text="EU\nBCE", textcolor=color.green, editable=false, size=size.tiny, display = display.all - display.status_line)
//alertcondition(buyCond , title='Alert on BYC', message='Strength Returns - Buy Condition exist.')
if (buyCond and not ST and not effortUp and not lvt ) and crt
BYLabel = label.new(x=bar_index, y=low-ofs, color=color.rgb(57, 193, 91, 13),style=label.style_triangleup, size=size.tiny)
label.set_tooltip(BYLabel, "--------------- \n SOS \n--------------\n BUY CONDITION EXISTS\n----------------\n sign of Strength. \n Strength has returned. Buy Conditions exits. Probability of bullish moves is high")
//----------------------------------------------------------------------
showsce = input(true, "Show Sell Condition Exist (SCE)", tooltip="Weakness Returns - Sell Condition exist.", group="VSA Signals")
plotshape(showsce and not crt? sellCond and not UT : na, "SCE", style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), text="SCE", textcolor=color.red, editable=false, size=size.tiny)
plotshape(showsce and not crt ? sellCond and UT1 : na, "SCE", style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), text="UT\nSCE", textcolor=color.red, editable=false, size=size.tiny)
//alertcondition(sellCond , title='Alert on SEC', message='Weakness Returns - Sell Condition exist.')
if ( sellCond and not UT ) and crt
SYLabel = label.new(x=bar_index, y=high+ofs, color=color.new(color.orange,0),style=label.style_triangledown, size=size.tiny)
label.set_tooltip(SYLabel, "--------------- \n SOW \n--------------\n SELL CONDITION EXISTS\n----------------\n sign of Weakness. \n Weakness has returned. Sell Conditions exits. Probability of Bearish moves is high")
//--------------------------------------------------------------------------------------------
showbc = input(true, "Show Buying Climax (BC)", tooltip="Buying Climax - End of Current Up Trend.", group="VSA Signals")
plotshape(showbc and not crt? bc and not UT : na, "BC", style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), text="BC", textcolor=color.red, editable=false, size=size.tiny)
plotshape(showbc and not crt? bc and UT1 : na, "BC", style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), text="UT\nBC", textcolor=color.red, editable=false, size=size.tiny)
//alertcondition(bc , title='Alert on BC', message='Buying Climax - End of Current Up Trend.')
if ((bc and not UT) and crt ) or ((bc and UT1) and crt )
BCLabel = label.new(x=bar_index, y=high+ofs, color=color.new(color.orange,0),style=label.style_triangledown, size=size.tiny)
label.set_tooltip(BCLabel, "--------------- \n SOW \n--------------\n BUYING CLIMAX\n----------------\n sign of Weakness. \n Buying Climax. \n 1. Strong Hand passing of huge quantity of their stock to weak Hands. \n 2. Generally Indicates end of an up move \n 3. The move up need not necessarily reverse immediately ")
//--------------------------------------------------------------------------------
showsc = input(true, "Show Selling Climax (SC)", tooltip="Selling Climax - End of Current Down Trend.", group="VSA Signals")
plotshape(showsc and not crt? sc and not ST : na, "SC", style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), text="SC", textcolor=color.green, editable=false, size=size.tiny)
plotshape(showsc and not crt? sc and ST : na, "SC", style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), text="ST\nSC", textcolor=color.green, editable=false, size=size.tiny)
//alertcondition(sc , title='Alert on SC', message='Selling Climax - End of Current Down Trend.')
if ((sc and not ST) and crt ) or ((sc and ST) and crt )
SCLabel = label.new(x=bar_index, y=low-ofs, color=color.new(color.lime,0),style=label.style_triangleup, size=size.tiny)
label.set_tooltip(SCLabel, "--------------- \n SOS \n--------------\n SELLING CLIMAX\n----------------\n Sign of Strength. \n Selling Climax. Smart money accumulating the stock in huge quantity. Possible end of the current Down move")
//--------------------------------------------------------------------------------
showtb = input(true, "Show Two bar Reversal (TB)", tooltip="Two bar revesal - Indicated possibility of reversal of current move. High volume adds strength", group="VSA Signals")
plotshape(showtb and not crt? tbc2 : na, "TB", style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 0), text="TB", textcolor=color.red, editable=false, size=size.tiny)
plotshape(showtb and not crt ? tbc3 : na, "TB", style=shape.triangleup, location=location.belowbar, color=#f7e30c, text="TB", textcolor=color.red, editable=false, size=size.tiny)
plotshape(showtb and not crt? tbc4 and not UT: na, "TB", style=shape.triangledown, location=location.abovebar, color=color.new(color.red, 0), text="TB", textcolor=color.green, editable=false, size=size.tiny)
plotshape(showtb and not crt ? tbc5 and not UT : na, "TB", style=shape.triangledown, location=location.abovebar, color=#f7e30c, text="TB", textcolor=color.green, editable=false, size=size.tiny)
//alertcondition(tbc2 or tbc3 , title='Alert on TBR', message='Two Bar Reversal to the Upside')
//alertcondition(tbc4 or tbc5 , title='Alert on TBR', message='Two Bar Reversal to the Downside')
if tbc2 and crt
TBLabel1 = label.new(x=bar_index, y=high+ofs, color=color.new(color.lime,0),style=label.style_triangledown, size=size.tiny)
label.set_tooltip(TBLabel1, "--------------- \n SOS \n--------------\n TWO BAR REVERSAL\n----------------\n Sign of Strength. \n Two Bar Reversal on High Volume during a up move. \n Temporary Reversal in the current move. \n High Prabability signal")
if tbc3 and crt
TBLabel2 = label.new(x=bar_index, y=high+ofs, color=color.new(color.yellow,0),style=label.style_triangledown, size=size.tiny)
label.set_tooltip(TBLabel2, "--------------- \n SOS \n--------------\n TWO BAR REVERSAL\n----------------\n Sign of Strength. \n Two Bar Reversal on Low Volume during a up move.\n Temporary Reversal in the current move. \n Low Prabability signal")
if tbc4 and not UT and crt
TBLabel3 = label.new(x=bar_index, y=low-ofs, color=color.new(color.orange,0),style=label.style_triangleup, size=size.tiny)
label.set_tooltip(TBLabel3, "--------------- \n SOW \n--------------\n TWO BAR REVERSAL\n----------------\n Sign of Weakness. \n Two Bar Reversal on High Volume during a down move.\n Temporary Reversal in the current move. \n High Prabability signal")
if tbc5 and not UT and crt
TBLabel4 = label.new(x=bar_index, y=low-ofs, color=color.new(color.yellow,0),style=label.style_triangleup, size=size.tiny)
label.set_tooltip(TBLabel4, "--------------- \n SOW \n--------------\n TWO BAR REVERSAL\n----------------\n Sign of Weakness. \n Two Bar Reversal on Low Volume during a down move. \n Temporary Reversal in the current move. \n Low Prabability signal")
//-------------------------------------------------------------------
showfom = input(true, "Show Ease of Movement (FOM)", tooltip="High Supply Volume unable to Move the Price. Could be Demand/Supply area ", group="VSA Signals")
plotshape(showtb and not UT and not crt? fom1 : na, "", style=shape.square, location=location.belowbar, color=color.new(color.yellow,0), text="DS", textcolor=color.new(color.red,0), editable=false, size=size.tiny)
if fom1 and crt
FOLabel = label.new(x=bar_index, y=low-ofs, color=color.new(color.yellow,0),style=label.style_triangleup, size=size.tiny)
label.set_tooltip(FOLabel, "--------------- \n ALERT \n--------------\n DEMAND?SUPPLY AREA \n----------------\n Alert \n High Volume unable to move the price. Hence it could be a Supply or Demand Area. Evalaute based on the price struture and Price Action")
//-----------------------------Bar coloring Code-------------------------------------------------
//Vlp=Param("Volume lookback period",150,20,300,10);
Vrg=sma(volume,30)// average volume
rg=(high-close)
arg=wma(rg,30)
Vh=volume>volume[1] and volume[1]>volume[2]
Cloc=close-low
x=(high-low)/Cloc
x1=Cloc==0?arg:x
Vb1 = volume >Vrg or volume > volume[1]
ucls=x1<2
dcls=x1>2
mcls=x1<2.2 and x1>1.8
Vlcls=x1>4
Vhcls=x1<1.35
upbar = close > close[1]
dnbar = close < close[1]
CloseUp = close > close[1]
CloseDn = close < close[1]
VolUp = volume > volume[1]
VolDn = volume < volume[1]
bb1 = upbar and CloseUp and ucls and low > low[1]
bb2 = upbar and VolUp
bb3 = dnbar and CloseDn and VolDn
bb4 = dnbar and CloseDn and close > close[1]
db1 = dnbar and CloseDn and dcls
db2 = dnbar and VolUp
db3 = upbar and CloseDn and VolUp
db4 = upbar and CloseDn and close<low[1] and dcls
db5 = upbar and CloseUp and ucls and low<low[1]
db6 = upbar and CloseUp and dcls
bb=(bb1 or bb2 or bb3 or bb4)
db=(db1 or db2 or db3 or db4 or db5 or db6)
//mycolor = bb and tls>0? color.green : (db and tls<0? color.red: (bkbg == true ? color.white : color.blue))
mcolor = close > close[1] ? ( volume < sma(volume,60) ? color.rgb(122, 236, 125) : color.rgb(73, 177, 52)) :( volume < sma(volume,60) ? color.rgb(243, 155, 155): color.rgb(207, 58, 58))
bgcolor( bkbg == true? color.black : color.white, editable = false)
barcolor(color=mcolor)
//---------------------
log_show = input(true, title = "Show Alert window?", group = "Alert")
log_show_msg = input(2, title = "# of message to show", group = "Alert")
log_offset = input(0, title = "# of messages to offset", group = "Alert", step = 1)
// LOGGING FUNCTION ///
var bar_arr = array.new_int(0)
var time_arr = array.new_string(0)
var msg_arr = array.new_string(0)
var type_arr = array.new_string(0)
log_msg(message, type) =>
//array.push(bar_arr, bar_index)
array.push(time_arr, tostring(month) + "-" + tostring(dayofmonth) + " , " + tostring(hour) + ":" + tostring(minute) )
array.push(msg_arr, message)
array.push(type_arr, type)
// Messages //
if (upThrustBar)
log_msg("UpThrust Bar - A Sure sign of weakness", 'weakness')
if (upThrustBar and not upThrustBartrue)
log_msg("UpThrust Bar - A sign of weakness " , 'weakness')
if (upThrustCond1)
log_msg("A downbar after an Upthrust. Confirm weakness." , 'weakness')
if (upThrustCond2 and not upThrustCond1)
log_msg("A High Volume downbar after an Upthrust. Confirm weakness." , 'weakness')
if (upThrustCond3)
log_msg("This upthrust at very High Voume, Confirms weakness" , 'weakness')
if (PseudoUpThrust)
log_msg("Psuedo UpThrust. A Sign of Weakness." , 'weakness')
if (pseudoUtCond)
log_msg("A Down Bar closing down after a Pseudo Upthrust confirms weakness." , 'weakness')
if (trendChange)
log_msg("High volume Downbar after an upmove on high volume indicates weakness." , 'weakness')
if (sellCond)
log_msg("Possible end of Uptrend and start of Downtrend soon." , 'weakness')
if (effortUpfail)
log_msg("Effort to Move up has failed. Bearish sign." , 'weakness')
if (bearBar)
log_msg("Day's Move Indicates weakness." , 'weakness')
if (bc)
log_msg("Potential Buying climax." , 'weakness')
if (effortDown)
log_msg("Effort to Fall. Bearish sign. " , 'weakness')
if (tbc4)
log_msg("Two Bar Reversal on Higher volume " , 'weakness')
if (noSupplyBar)
log_msg("No Supply. A sign of Strength. " , 'weakness')
if (lowVolTest)
log_msg("Test for supply. " , 'strength')
if (lowVolTest2)
log_msg("An upBar closing near High after a Test confirms strength." , 'strength')
if (lowVolTest1)
log_msg("Test for supply in a uptrend. Sign of Strength." , 'strength')
if (strengthDown1)
log_msg("Strength seen returning after a down trend. High volume adds to strength.." , 'strength')
if (strengthDown0 and not strengthDown)
log_msg("Strength seen returning after a down trend." , 'strength')
if (strengthDown and not strengthDown1)
log_msg("Strength seen returning after a down trend." , 'strength')
if (buyCond)
log_msg("Possible end of downtrend and start of uptrend soon.." , 'strength')
if (effortDownFail)
log_msg("Effort to Move Down has failed. Bulish sign. " , 'strength')
if (strengthDown2)
log_msg("High volume upBar closing on the high indicates strength. " , 'strength')
if (stopVolume)
log_msg("Stopping volume. Normally indicates end of bearishness is nearing." , 'strength')
if (revUpThrust)
log_msg("Reverse upthrust. Indicates strength" , 'strength')
if (bullBar )
log_msg("Day's Move Indicates strength. " , 'strength')
if (tbc2 )
log_msg("Two Bar Reversal on Higher volume. " , 'strength')
if (tbc2a )
log_msg("Two Bar like Reversal to upside on high volume. " , 'strength')
if (sc )
log_msg(" Possible Selling Climax " , 'strength')
if (topRevBar )
log_msg("Top Reversal. Sign of Weakness. " , 'warning')
if (noDemandBarDt )
log_msg("No Demand. upside unlikely soon. " , 'warning')
if (noDemandBarUt )
log_msg("No Demand in a Uptrend. A sign of Weakness. " , 'warning')
if (fom1 )
log_msg("High Volume unable to move the price. Could be a Supply / Demand Area " , 'warning')
if (tbc2 )
log_msg("Two Bar Reversal to upside on High volume. " , 'warning')
if (tbc3 )
log_msg("Two Bar Reversal to upside on Low volume. " , 'warning')
if (tbc4 )
log_msg("Two Bar Reversal to upside on High volume. " , 'warning')
if (tbc5 )
log_msg("Two Bar Reversal to upside on Low volume. " , 'warning')
///////////////////////////////
// Create and fill log table //
var log_tbl = table.new(position.bottom_left, 3, log_show_msg + 1, frame_color = color.black, frame_width = 1,border_color=color.black,border_width = 1)
if (barstate.islast and log_show)
//table.cell(log_tbl, 0, 0, "Bar #", bgcolor = color.gray, text_size = size.small)
table.cell(log_tbl, 1, 0, "TIME", bgcolor = #9894f7, text_size = size.small)
table.cell(log_tbl, 2, 0, "ALERT", bgcolor = #9894f7, text_size = size.small)
for i = 1 to log_show_msg
arr_i = array.size(msg_arr) - log_show_msg + i - 1 - log_offset
if (arr_i < 0)
break
type = array.get(type_arr, arr_i)
msg_color = type == 'strength' ? #c2fc03 :
type == 'weakness' ? #fa5050 :
type == 'warning' ? #f4fc79 : na
//table.cell(log_tbl, 0, i, tostring(array.get(bar_arr, arr_i)), bgcolor = msg_color, text_size = size.small)
table.cell(log_tbl, 1, i, array.get(time_arr, arr_i), bgcolor = msg_color, text_size = size.small)
table.cell(log_tbl, 2, i, array.get(msg_arr, arr_i), bgcolor = msg_color, text_size = size.small)
//======================================================================================
//--------------------------------- Relative Strength ------------------------------------------------------
a = close
len = 22
bs = security("cnx500", 'D', close)
zeroline = 0
crs = ((a/a[len])/(bs/bs[len]) - 1)
//zero_color = (crs >= 0) ? color.green : color.orange
//plot_color = (crs >= 0) ? color.green : color.red
fill_color1 = (crs >= 0) ? color.new(color.green, 80) : color.new(color.red, 80)
//--------------------------------- Moneyflow----------------------------------------------------------------
TYP = hlc3
RMF = TYP*volume
PMF = TYP > TYP[1] ? RMF : 0 //PMF:Positive Money Flow///
NMF = TYP < TYP[1] ? RMF : 0 ///nmf: Negative Money Flow///
periods = input(22, "period", minval=5, maxval=66, step=1)
MFR = sum(PMF, periods) / sum(NMF, periods) ///MFR: Money Flow Ratio///
RMFI = 100 - (100 / ( 1 + MFR))
JM = wma(RMFI,22)
RF = (RMFI > JM) ? 1 : 0
fill_color2 = (RMFI > JM) ? color.new(color.green, 80) : color.new(color.red, 80)
//=========================================Strength Band===================================================================
RPeriod = 14
Lb = 30
mySig = rsi(close,14)
Adev = stdev(mySig, 3*RPeriod)
jh = highest(mySig,Lb)
jl = lowest(mySig,Lb)
jx = jh-jl
jy = (wma(jx,RPeriod)*0.60)+wma(jl,RPeriod)
Hiline = jh-jy*0.2
Loline = jl+jy*0.2
midline = (jh-jl)/2
R = ( 4 * mySig + 3 * mySig[1] + 2 * mySig[2] + mySig[3] ) / 10
stcolour = R>Hiline ? color.lime : R<Loline ? color.orange : color.blue
plotshape(strband, "Strength band", color=stcolour, style=shape.square, location=location.bottom, size = size.small, text="")
//=============================== Bar and Satus Indication ==================================================
spr = (H-L)
avspr = sma(spread,40)
sprst = spr < (avspr*0.6) ? 1 : spr < (avspr*0.9) and spr >(avspr*0.6) ? 2 : spr > (avspr*0.9) and spr < (avspr*1.1) ? 3 : spr > (avspr*1.1) and spr < (avspr*1.5) ?
4 : spr > (avspr*1.5) and spr < (avspr*2) ? 5 : 6
var testTable = table.new(position = position.top_right, columns = 3, rows = 3,frame_color = color.black, frame_width = 1, bgcolor = color.white, border_color=color.black,border_width = 1)
if barstate.islast
table.cell(table_id = testTable, column = 0, row = 0, text = ClosePos ==1 ? "Close : Down Close ": ClosePos == 2 ? "Close : Below Close " : ClosePos == 3 ? "Close : Mid Close " :
ClosePos == 4 ? "Close : Above Close ": "Close : UP Close ", text_size = size.small, bgcolor = #f4fc79 )
table.cell(table_id = testTable, column = 1, row = 0, text = volpos ==1 ? "Volume : Very High ": volpos == 2 ? "Volume : High " : volpos == 3 ? "Volume : Above Average " :
volpos == 4 ? "Volume : Less Than Avg ": "Volume : Low Volume ", text_size = size.small, bgcolor = #f4fc79 )
table.cell(table_id = testTable, column = 2, row = 0, text = sprst == 1 ? "Spread : Narrow ": sprst == 2 ? "Spread : Below Average" : sprst == 3 ? "Spread : Average " :
sprst == 4 ? "Spread : Above Average ": sprst ==5 ? "Spread = Wide" : "SPread : Very Wide", text_size = size.small, bgcolor = #f4fc79 )
table.cell(table_id = testTable, column = 0, row = 1, text = upmajor ==1 ? "Major Trend - UP ": upmajor == -1 ? "Major Trend - DOWN " : "Major Trend - No Trend" ,
text_size = size.small , bgcolor = upmajor ==1 ? #c2fc03 : upmajor == -1 ? #fa5050 : #f4fc79 )
table.cell(table_id = testTable, column = 1, row = 1, text = upmid ==1 ? "Minor Trend - UP ": dnimd == 1 ? "Minor Trend - DOWN " : "Minor Tend - No Trend" ,
text_size = size.small , bgcolor = upmid ==1 ? #c2fc03 : dnimd == 1 ? #fa5050 : #f4fc79 )
table.cell(table_id = testTable, column = 2, row = 1, text = upminor ==1 ? "Immed. Trend - UP ": dnminor == 1 ? "Immed. Trend - DOWN " : "Immed. Tend - No Trend" ,
text_size = size.small , bgcolor = upminor ==1 ? #c2fc03 : dnminor == 1 ? #fa5050 : #f4fc79 )
table.cell(table_id = testTable, column = 0, row = 2, text = crs > 0 ? "Rel. Strength Positive ": "Rel. Strength Negative" ,
text_size = size.small , bgcolor = crs > 0 ? #c2fc03 : #fa5050 )
table.cell(table_id = testTable, column = 1, row = 2, text = R>Hiline ? "Abs. Strength Positive ": R<Loline ? "Abs. Strength Negative " : "Abs. Strength Neutral" ,
text_size = size.small , bgcolor = R>Hiline ? #c2fc03 : R<Loline ? #fa5050 :#f4fc79 )
table.cell(table_id = testTable, column = 2, row = 2, text = RMFI>JM ? " Money Flow Positive ": " Money Flow Negative" ,
text_size = size.small , bgcolor = RMFI>JM ? #c2fc03 : #fa5050 )
//---------------------------------------------End of Table --------------------------------------
//============================================================
//====================================================================================|
// Support & Resistance volume Lines |
//====================================================================================|
showrs = input(false, "Show support and resistance lines", group="Support & Resistance lines")
sens = input(10, "Sensitivity", minval=2, maxval=15, group="Support & Resistance lines")
ph = pivothigh(high, sens, 0)
pl = pivotlow(low, sens, 0)
var float phl = na
var float pll = na
phl := nz(ph) != 0 ? ph : phl[1]
pll := nz(pl) != 0 ? pl : pll[1]
plot(showrs ? phl : na, "Period High", color=color.blue, style=plot.style_cross)
plot(showrs ? pll : na, "Period Low", color=color.red, style=plot.style_cross)
showhighvol = input(false, "Show high volume lines", group="Support & Resistance lines")
volpd = input(14, "Vol Length", group="Support & Resistance lines")
volm = input(1.618,"Vol Factor",type=input.float,step=0.1, group="Support & Resistance lines")
minvol = input(1,"Minimum volume", group="Support & Resistance lines")
avol = sma(volume, volpd)
hvol = volume > minvol and volume > volm * avol
var float hp = na
var float lp = na
var float mp = na
hhv = highest(high,2)
llv = lowest(low,2)
hp := hvol ? hhv : hp[1]
lp := hvol ? llv : lp[1]
plot(not showhighvol ? na : hp, "HV - High", color=color.olive, style=plot.style_circles, linewidth=2)
plot(not showhighvol ? na : lp, "HV - Low", color=color.maroon, style=plot.style_circles, linewidth=2)
//====================================================================================|
// End of Support & Resistance volume Lines |
//====================================================================================| |
Moving Average Support and Resistance Channel | https://www.tradingview.com/script/N0B81Y6n-moving-average-support-and-resistance-channel/ | Best_Solve | https://www.tradingview.com/u/Best_Solve/ | 159 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Best_Solve
//@version=4
study(title="Moving Average Support and Resistance Channel", shorttitle="MA Channel", format=format.price, precision=8, overlay=true, resolution="")
mode = input (defval='Auto', title="Mode", options=["Auto", "User Defined"])
smoothing = input(defval="RMA", title="Smoothing", options=["SMA", "EMA", "RMA", "WMA", "VWMA", "HMA"])
length = input(30, minval=1, title="Length")
x = input(1.618, "Factor", minval=0.001, maxval=5)
HTFp = timeframe.period == '1'? 60:
timeframe.period == '3'? 20:
timeframe.period == '5'? 48:
timeframe.period == '15'? 96:
timeframe.period == '30'? 48:
timeframe.period == '45'? 32:
timeframe.period == '60'? 24:
timeframe.period == '120'? 84:
timeframe.period == '180'? 56:
timeframe.period == '240'? 42:
timeframe.period == 'D'? 30:
timeframe.period == 'W'? 52: 12
len = mode=='Auto'? HTFp : length
ma_function(source, length)=>
if smoothing == "SMA"
sma(source, len)
else
if smoothing == "EMA"
ema(source, len)
else
if smoothing == "RMA"
rma(source, len)
else
if smoothing == "WMA"
wma(source, len)
else
if smoothing == "VWMA"
vwma(source, len)
else
hma(source, len)
serie1 = close>open? close: close<open? open: high
serie2 = close<open? close: close>open? open: low
bottom = ma_function (serie1, len)-x*ma_function (tr(true), len)
top = ma_function (serie2, len)+x*ma_function (tr(true), len)
bottom1 = bottom-x*ma_function (tr(true), len)
top1 = top+x*ma_function (tr(true), len)
basis = ma_function (hlc3, len)
plot(top, "R1", color=color.red)
plot(bottom, "S1", color=color.green)
plot(top1, "R2")
plot(bottom1, "S2")
plot(basis, "Middle Line", color=color.yellow)
|
CPR by Wsr | https://www.tradingview.com/script/1VwOnxwf-CPR-by-Wsr/ | wisestockresearch | https://www.tradingview.com/u/wisestockresearch/ | 168 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © wisestockresearch
//@version=4
study(title="CPR by WSR ", shorttitle="CPR by WSR:", overlay=true)
pivottimeframe = input(title="Pivot Resolution", defval="D", options=["D", "W", "M"])
dp = input(true, title="Display Floor Pivots")
cp = input(true, title="Display Camarilla Pivots")
hl = input(true, title="Display M, W, D Highs/Lows")
tp = input(false, title="Display Tomorrow Pivots")
//dp in the prefix implies daily pivot calculation
dpopen = security(syminfo.tickerid, pivottimeframe, open[1], barmerge.gaps_off, barmerge.lookahead_on)
dphigh = security(syminfo.tickerid, pivottimeframe, high[1], barmerge.gaps_off, barmerge.lookahead_on)
dplow = security(syminfo.tickerid, pivottimeframe, low[1], barmerge.gaps_off, barmerge.lookahead_on)
dpclose = security(syminfo.tickerid, pivottimeframe, close[1], barmerge.gaps_off, barmerge.lookahead_on)
dprange = dphigh - dplow
//Expanded Floor Pivots Formula
pivot = (dphigh + dplow + dpclose) / 3.0
bc = (dphigh + dplow) / 2.0
tc = pivot - bc + pivot
r1 = pivot * 2 - dplow
r2 = pivot + dphigh - dplow
r3 = r1 + dphigh - dplow
r4 = r3 + r2 - r1
s1 = pivot * 2 - dphigh
s2 = pivot - (dphigh - dplow)
s3 = s1 - (dphigh - dplow)
s4 = s3 - (s1 - s2)
//Expanded Camarilla Pivots Formula
h1 = dpclose + dprange * (1.1 / 12)
h2 = dpclose + dprange * (1.1 / 6)
h3 = dpclose + dprange * (1.1 / 4)
h4 = dpclose + dprange * (1.1 / 2)
h5 = dphigh / dplow * dpclose
l1 = dpclose - dprange * (1.1 / 12)
l2 = dpclose - dprange * (1.1 / 6)
l3 = dpclose - dprange * (1.1 / 4)
l4 = dpclose - dprange * (1.1 / 2)
l5 = dpclose - (h5 - dpclose)
//Tomorrow's Pivot Calculation
tpopen = security(syminfo.tickerid, pivottimeframe, open, barmerge.gaps_off, barmerge.lookahead_on)
tphigh = security(syminfo.tickerid, pivottimeframe, high, barmerge.gaps_off, barmerge.lookahead_on)
tplow = security(syminfo.tickerid, pivottimeframe, low, barmerge.gaps_off, barmerge.lookahead_on)
tpclose = security(syminfo.tickerid, pivottimeframe, close, barmerge.gaps_off, barmerge.lookahead_on)
tprange = tphigh - tplow
tppivot = (tphigh + tplow + tpclose) / 3.0
tpbc = (tphigh + tplow) / 2.0
tptc = tppivot - tpbc + tppivot
tpr1 = tppivot * 2 - tplow
tps1 = tppivot * 2 - tphigh
tph3 = tpclose + tprange * (1.1 / 4)
tpl3 = tpclose - tprange * (1.1 / 4)
//m,w,d in the prefix implies monthly, weekly and daily
mhigh = security(syminfo.tickerid, "M", high[1], lookahead=barmerge.lookahead_on)
mlow = security(syminfo.tickerid, "M", low[1], lookahead=barmerge.lookahead_on)
whigh = security(syminfo.tickerid, "W", high[1], lookahead=barmerge.lookahead_on)
wlow = security(syminfo.tickerid, "W", low[1], lookahead=barmerge.lookahead_on)
dhigh = security(syminfo.tickerid, "D", high[1], lookahead=barmerge.lookahead_on)
dlow = security(syminfo.tickerid, "D", low[1], lookahead=barmerge.lookahead_on)
dclose = security(syminfo.tickerid, "D", close[1], lookahead=barmerge.lookahead_on)
//Plotting
plot(dp and pivot ? pivot : na, title="Pivot", color=#FF007F, style=plot.style_cross, transp=0)
plot(dp and bc ? bc : na, title="BC", color=color.blue, style=plot.style_cross, transp=0)
plot(dp and tc ? tc : na, title="TC", color=color.blue, style=plot.style_cross, transp=0)
plot(dp and r1 ? r1 : na, title="R1", color=color.green, style=plot.style_cross, transp=0)
plot(dp and r2 ? r2 : na, title="R2", color=color.green, style=plot.style_cross, transp=0)
plot(dp and r3 ? r3 : na, title="R3", color=color.green, style=plot.style_cross, transp=0)
plot(dp and r4 ? r4 : na, title="R4", color=color.green, style=plot.style_cross, transp=0)
plot(dp and s1 ? s1 : na, title="S1", color=color.red, style=plot.style_cross, transp=0)
plot(dp and s2 ? s2 : na, title="S2", color=color.red, style=plot.style_cross, transp=0)
plot(dp and s3 ? s3 : na, title="S3", color=color.red, style=plot.style_cross, transp=0)
plot(dp and s4 ? s4 : na, title="S4", color=color.red, style=plot.style_cross, transp=0)
plot((timeframe.isintraday or timeframe.isdaily or timeframe.isweekly) and hl ? mhigh : na, title="Monthly High", style=plot.style_circles, color=#FF7F00, transp=0)
plot((timeframe.isintraday or timeframe.isdaily or timeframe.isweekly) and hl ? mlow : na, title="Monthly Low", style=plot.style_circles, color=#FF7F00, transp=0)
plot((timeframe.isintraday or timeframe.isdaily) and hl ? whigh : na, title="Weekly High", style=plot.style_circles, color=#FF7F00, transp=0)
plot((timeframe.isintraday or timeframe.isdaily) and hl ? wlow : na, title="Weekly Low", style=plot.style_circles, color=#FF7F00, transp=0)
plot(timeframe.isintraday and hl ? dhigh : na, title="Daily High", style=plot.style_circles, color=#FF7F00, transp=0)
plot(timeframe.isintraday and hl ? dlow : na, title="Daily Low", style=plot.style_circles, color=#FF7F00, transp=0)
plot(timeframe.isintraday and hl ? dclose : na, title="Daily Close",style=plot.style_circles, color=#000000, transp=0)
plot(tp and tppivot ? tppivot : na, title="Pivot", color=color.blue, style=plot.style_cross, transp=0)
plot(tp and tpbc ? tpbc : na, title="BC", color=color.blue, style=plot.style_cross, transp=0)
plot(tp and tptc ? tptc : na, title="TC", color=color.blue, style=plot.style_cross, transp=0)
plot(tp and tpr1 ? tpr1 : na, title="R1", color=color.green, style=plot.style_cross, transp=0)
plot(tp and tps1 ? tps1 : na, title="S1", color=color.red, style=plot.style_cross, transp=0)
plot(tp and tph3 ? tph3 : na, title="H3", color=tph3 != tph3[1] ? na : color.black, transp=0)
plot(tp and tpl3 ? tpl3 : na, title="L3", color=tpl3 != tpl3[1] ? na : color.black, transp=0)
plot(timeframe.isintraday and tp ? tphigh : na, title="High", style=plot.style_circles, color=#FF7F00, transp=0)
plot(timeframe.isintraday and tp ? tplow : na, title="Low", style=plot.style_circles, color=#FF7F00, transp=0)
//Candle Stick Patterns
DJ1 = abs(open - close) < (high - low) * 0.1 and high - low > atr(14)
plotshape(DJ1, title="Doji", location=location.abovebar, color=color.blue, style=shape.xcross)
OR1 = open[1] > close[1] and open < close and low[1] > low and close > high[1] and
high - low > atr(14) * 1.25 // or close[1] > open
plotshape(OR1, title="Bullish Engulfing", style=shape.arrowup, color=color.green, location=location.belowbar)
OR2 = open[1] < close[1] and open > close and high[1] < high and close < low[1] and
high - low > atr(14) * 1.25 // or close[1] < open
plotshape(OR2, title="Bearish Engulfing", style=shape.arrowdown, color=color.red)
WR1 = low < low[1] and abs(low - min(open, close)) > abs(open - close) * 2 and
abs(high - close) < (high - low) * 0.35 and high - low > atr(14)
plotshape(WR1, title="Hammer", location=location.belowbar, color=color.green, style=shape.arrowup)
WR2 = high > high[1] and high - max(open, close) > abs(open - close) * 2 and
abs(close - low) < (high - low) * 0.35 and high - low > atr(14)
plotshape(WR2, title="Shooting Star", color=color.red, style=shape.arrowdown)
ER1 = high[1] - low[1] > atr(14) * 2 and
abs(open[1] - close[1]) > (high[1] - low[1]) * 0.5 and open[1] > close[1] and
open < close //and abs(open[1] - close[1]) < (high[1]-low[1]) * 0.85
plotshape(ER1, title="Bullish E.Reversal", location=location.belowbar, color=color.green, style=shape.arrowup) // E denotes Extreme
ER2 = high[1] - low[1] > atr(14) * 2 and
abs(open[1] - close[1]) > (high[1] - low[1]) * 0.5 and open[1] < close[1] and
open > close //and abs(open[1] - close[1]) < (high[1]-low[1]) * 0.85
plotshape(ER2, title="Bearish E.Reversal", location=location.abovebar, color=color.red, style=shape.arrowdown)
|
Gann Square of 9 | https://www.tradingview.com/script/kBhTugZn-Gann-Square-of-9/ | OztheWoz | https://www.tradingview.com/u/OztheWoz/ | 228 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © OztheWoz
//@version=4
study("Gann Squares", overlay=true)
// ---Inputs---
keyprice = input(1.0, "Starting Price")
intlen = input(1.0, "Interval Length")
// ---Calculations---
val1 = keyprice
val2 = keyprice + (1 * intlen)
val3 = keyprice + (2 * intlen)
val4 = keyprice + (3 * intlen)
val5 = keyprice + (4 * intlen)
val6 = keyprice + (5 * intlen)
val7 = keyprice + (6 * intlen)
val8 = keyprice + (7 * intlen)
val9 = keyprice + (8 * intlen)
val10 = keyprice + (9 * intlen)
val11 = keyprice + (10 * intlen)
val12 = keyprice + (11 * intlen)
val13 = keyprice + (12 * intlen)
val14 = keyprice + (13 * intlen)
val15 = keyprice + (14 * intlen)
val16 = keyprice + (15 * intlen)
val17 = keyprice + (16 * intlen)
val18 = keyprice + (17 * intlen)
val19 = keyprice + (18 * intlen)
val20 = keyprice + (19 * intlen)
val21 = keyprice + (20 * intlen)
val22 = keyprice + (21 * intlen)
val23 = keyprice + (22 * intlen)
val24 = keyprice + (23 * intlen)
val25 = keyprice + (24 * intlen)
val26 = keyprice + (25 * intlen)
val27 = keyprice + (26 * intlen)
val28 = keyprice + (27 * intlen)
val29 = keyprice + (28 * intlen)
val30 = keyprice + (29 * intlen)
val31 = keyprice + (30 * intlen)
val32 = keyprice + (31 * intlen)
val33 = keyprice + (32 * intlen)
val34 = keyprice + (33 * intlen)
val35 = keyprice + (34 * intlen)
val36 = keyprice + (35 * intlen)
val37 = keyprice + (36 * intlen)
val38 = keyprice + (37 * intlen)
val39 = keyprice + (38 * intlen)
val40 = keyprice + (39 * intlen)
val41 = keyprice + (40 * intlen)
val42 = keyprice + (41 * intlen)
val43 = keyprice + (42 * intlen)
val44 = keyprice + (43 * intlen)
val45 = keyprice + (44 * intlen)
val46 = keyprice + (45 * intlen)
val47 = keyprice + (46 * intlen)
val48 = keyprice + (47 * intlen)
val49 = keyprice + (48 * intlen)
val50 = keyprice + (49 * intlen)
val51 = keyprice + (50 * intlen)
val52 = keyprice + (51 * intlen)
val53 = keyprice + (52 * intlen)
val54 = keyprice + (53 * intlen)
val55 = keyprice + (54 * intlen)
val56 = keyprice + (55 * intlen)
val57 = keyprice + (56 * intlen)
val58 = keyprice + (57 * intlen)
val59 = keyprice + (58 * intlen)
val60 = keyprice + (59 * intlen)
val61 = keyprice + (60 * intlen)
val62 = keyprice + (61 * intlen)
val63 = keyprice + (62 * intlen)
val64 = keyprice + (63 * intlen)
val65 = keyprice + (64 * intlen)
val66 = keyprice + (65 * intlen)
val67 = keyprice + (66 * intlen)
val68 = keyprice + (67 * intlen)
val69 = keyprice + (68 * intlen)
val70 = keyprice + (69 * intlen)
val71 = keyprice + (70 * intlen)
val72 = keyprice + (71 * intlen)
val73 = keyprice + (72 * intlen)
val74 = keyprice + (73 * intlen)
val75 = keyprice + (74 * intlen)
val76 = keyprice + (75 * intlen)
val77 = keyprice + (76 * intlen)
val78 = keyprice + (77 * intlen)
val79 = keyprice + (78 * intlen)
val80 = keyprice + (79 * intlen)
val81 = keyprice + (80 * intlen)
gann9clr = color.new(#CFCFCF, 80)
cardcrossclr = color.new(color.yellow, 60)
ordcrossclr = color.new(color.aqua, 60)
gann9 = table.new(position=position.middle_right, columns=10, rows= 10, bgcolor=gann9clr)
table.cell(gann9, 5, 5, tostring(val1), text_color=color.white, bgcolor=cardcrossclr)
table.cell(gann9, 4, 5, tostring(val2), text_color=color.white, bgcolor=ordcrossclr)
table.cell(gann9, 4, 4, tostring(val3), text_color=color.white, bgcolor=cardcrossclr)
table.cell(gann9, 5, 4, tostring(val4), text_color=color.white, bgcolor=ordcrossclr)
table.cell(gann9, 6, 4, tostring(val5), text_color=color.white, bgcolor=cardcrossclr)
table.cell(gann9, 6, 5, tostring(val6), text_color=color.white, bgcolor=ordcrossclr)
table.cell(gann9, 6, 6, tostring(val7), text_color=color.white, bgcolor=cardcrossclr)
table.cell(gann9, 5, 6, tostring(val8), text_color=color.white, bgcolor=ordcrossclr)
table.cell(gann9, 4, 6, tostring(val9), text_color=color.white, bgcolor=cardcrossclr)
table.cell(gann9, 3, 6, tostring(val10), text_color=color.white)
table.cell(gann9, 3, 5, tostring(val11), text_color=color.white, bgcolor=ordcrossclr)
table.cell(gann9, 3, 4, tostring(val12), text_color=color.white)
table.cell(gann9, 3, 3, tostring(val13), text_color=color.white, bgcolor=cardcrossclr)
table.cell(gann9, 4, 3, tostring(val14), text_color=color.white)
table.cell(gann9, 5, 3, tostring(val15), text_color=color.white, bgcolor=ordcrossclr)
table.cell(gann9, 6, 3, tostring(val16), text_color=color.white)
table.cell(gann9, 7, 3, tostring(val17), text_color=color.white, bgcolor=cardcrossclr)
table.cell(gann9, 7, 4, tostring(val18), text_color=color.white)
table.cell(gann9, 7, 5, tostring(val19), text_color=color.white, bgcolor=ordcrossclr)
table.cell(gann9, 7, 6, tostring(val20), text_color=color.white)
table.cell(gann9, 7, 7, tostring(val21), text_color=color.white, bgcolor=cardcrossclr)
table.cell(gann9, 6, 7, tostring(val22), text_color=color.white)
table.cell(gann9, 5, 7, tostring(val23), text_color=color.white, bgcolor=ordcrossclr)
table.cell(gann9, 4, 7, tostring(val24), text_color=color.white)
table.cell(gann9, 3, 7, tostring(val25), text_color=color.white, bgcolor=cardcrossclr)
table.cell(gann9, 2, 7, tostring(val26), text_color=color.white)
table.cell(gann9, 2, 6, tostring(val27), text_color=color.white)
table.cell(gann9, 2, 5, tostring(val28), text_color=color.white, bgcolor=ordcrossclr)
table.cell(gann9, 2, 4, tostring(val29), text_color=color.white)
table.cell(gann9, 2, 3, tostring(val30), text_color=color.white)
table.cell(gann9, 2, 2, tostring(val31), text_color=color.white, bgcolor=cardcrossclr)
table.cell(gann9, 3, 2, tostring(val32), text_color=color.white)
table.cell(gann9, 4, 2, tostring(val33), text_color=color.white)
table.cell(gann9, 5, 2, tostring(val34), text_color=color.white, bgcolor=ordcrossclr)
table.cell(gann9, 6, 2, tostring(val35), text_color=color.white)
table.cell(gann9, 7, 2, tostring(val36), text_color=color.white)
table.cell(gann9, 8, 2, tostring(val37), text_color=color.white, bgcolor=cardcrossclr)
table.cell(gann9, 8, 3, tostring(val38), text_color=color.white)
table.cell(gann9, 8, 4, tostring(val39), text_color=color.white)
table.cell(gann9, 8, 5, tostring(val40), text_color=color.white, bgcolor=ordcrossclr)
table.cell(gann9, 8, 6, tostring(val51), text_color=color.white)
table.cell(gann9, 8, 7, tostring(val52), text_color=color.white)
table.cell(gann9, 8, 8, tostring(val53), text_color=color.white, bgcolor=cardcrossclr)
table.cell(gann9, 7, 8, tostring(val54), text_color=color.white)
table.cell(gann9, 6, 8, tostring(val55), text_color=color.white)
table.cell(gann9, 5, 8, tostring(val56), text_color=color.white, bgcolor=ordcrossclr)
table.cell(gann9, 4, 8, tostring(val57), text_color=color.white)
table.cell(gann9, 3, 8, tostring(val58), text_color=color.white)
table.cell(gann9, 2, 8, tostring(val59), text_color=color.white, bgcolor=cardcrossclr)
table.cell(gann9, 1, 8, tostring(val50), text_color=color.white)
table.cell(gann9, 1, 7, tostring(val51), text_color=color.white)
table.cell(gann9, 1, 6, tostring(val52), text_color=color.white)
table.cell(gann9, 1, 5, tostring(val53), text_color=color.white, bgcolor=ordcrossclr)
table.cell(gann9, 1, 4, tostring(val54), text_color=color.white)
table.cell(gann9, 1, 3, tostring(val55), text_color=color.white)
table.cell(gann9, 1, 2, tostring(val56), text_color=color.white)
table.cell(gann9, 1, 1, tostring(val57), text_color=color.white, bgcolor=cardcrossclr)
table.cell(gann9, 2, 1, tostring(val58), text_color=color.white)
table.cell(gann9, 3, 1, tostring(val59), text_color=color.white)
table.cell(gann9, 4, 1, tostring(val60), text_color=color.white)
table.cell(gann9, 5, 1, tostring(val61), text_color=color.white, bgcolor=ordcrossclr)
table.cell(gann9, 6, 1, tostring(val62), text_color=color.white)
table.cell(gann9, 7, 1, tostring(val63), text_color=color.white)
table.cell(gann9, 8, 1, tostring(val64), text_color=color.white)
table.cell(gann9, 9, 1, tostring(val65), text_color=color.white, bgcolor=cardcrossclr)
table.cell(gann9, 9, 2, tostring(val66), text_color=color.white)
table.cell(gann9, 9, 3, tostring(val67), text_color=color.white)
table.cell(gann9, 9, 4, tostring(val68), text_color=color.white)
table.cell(gann9, 9, 5, tostring(val69), text_color=color.white, bgcolor=ordcrossclr)
table.cell(gann9, 9, 6, tostring(val70), text_color=color.white)
table.cell(gann9, 9, 7, tostring(val71), text_color=color.white)
table.cell(gann9, 9, 8, tostring(val72), text_color=color.white)
table.cell(gann9, 9, 9, tostring(val73), text_color=color.white, bgcolor=cardcrossclr)
table.cell(gann9, 8, 9, tostring(val74), text_color=color.white)
table.cell(gann9, 7, 9, tostring(val75), text_color=color.white)
table.cell(gann9, 6, 9, tostring(val76), text_color=color.white)
table.cell(gann9, 5, 9, tostring(val77), text_color=color.white, bgcolor=ordcrossclr)
table.cell(gann9, 4, 9, tostring(val78), text_color=color.white)
table.cell(gann9, 3, 9, tostring(val79), text_color=color.white)
table.cell(gann9, 2, 9, tostring(val80), text_color=color.white)
table.cell(gann9, 1, 9, tostring(val81), text_color=color.white, bgcolor=cardcrossclr)
|
PrivacySmurf's RSIs | https://www.tradingview.com/script/nmcguzFT-PrivacySmurf-s-RSIs/ | PrivacySmurf | https://www.tradingview.com/u/PrivacySmurf/ | 258 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © PrivacySmurf
//@version=5
indicator(title='PrivacySmurfs RSIs', overlay=false, shorttitle='PS RSIs v2.2')
tradrsi = input(false, title='Use Traditional RSI')
stockbands = input(false, title='Plot Traditional 70/30 bands?')
plotmidline = input(true, title='Plot Midline?')
//Stock RSI
stocklen = 14
src = close
up = ta.rma(math.max(ta.change(src), 0), stocklen)
down = ta.rma(-math.min(ta.change(src), 0), stocklen)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)
stockbandtop = 70.0
stockbandbottom = 30.0
midline = 50.0
//Cyclic Smoothed RSI by Lars Von Thienen (whentotrade)
domcycle = input.int(20, minval=10, title='Dominant Cycle Length')
crsi = 0.0
cyclelen = domcycle / 2
vibration = 10
leveling = 10.0
cyclicmemory = domcycle * 2
//set min/max ranges?
torque = 2.0 / (vibration + 1)
phasingLag = (vibration - 1) / 2.0
cUp = ta.rma(math.max(ta.change(src), 0), cyclelen)
cDown = ta.rma(-math.min(ta.change(src), 0), cyclelen)
rsi2 = cDown == 0 ? 100 : cUp == 0 ? 0 : 100 - 100 / (1 + cUp / cDown)
crsi := torque * (2 * rsi2 - rsi2[phasingLag]) + (1 - torque) * nz(crsi[1])
lmax = -999999.0
lmin = 999999.0
for i = 0 to cyclicmemory - 1 by 1
if nz(crsi[i], -999999.0) > lmax
lmax := nz(crsi[i])
lmax
else
if nz(crsi[i], 999999.0) < lmin
lmin := nz(crsi[i])
lmin
mstep = (lmax - lmin) / 100
aperc = leveling / 100
db = 0.0
for steps = 0 to 100 by 1
testvalue = lmin + mstep * steps
above = 0
below = 0
for m = 0 to cyclicmemory - 1 by 1
below += (crsi[m] < testvalue ? 1 : 0)
below
ratio = below / cyclicmemory
if ratio >= aperc
db := testvalue
break
else
continue
ub = 0.0
for steps = 0 to 100 by 1
testvalue = lmax - mstep * steps
above = 0
for m = 0 to cyclicmemory - 1 by 1
above += (crsi[m] >= testvalue ? 1 : 0)
above
ratio = above / cyclicmemory
if ratio >= aperc
ub := testvalue
break
else
continue
//Plots
mid = plot(plotmidline ? midline : na, 'Midline', color=color.new(color.white, 0))
lowband = plot(not stockbands ? db : na, 'Adaptive Lower Band', color.new(#FF5252, 0), linewidth=2)
highband = plot(not stockbands ? ub : na, 'Adaptive Higher Band', color.new(#4CAF50, 0), linewidth=2)
signal = plot(not tradrsi ? crsi : na, 'CRSI', color.new(color.fuchsia, 0), linewidth=4)
fill(lowband, highband, color=color.new(color.gray, 90), title="Backgound fill color")
fill(signal, highband, crsi > ub ? color.new(#4CAF50,55) : na, 'PS RSI Overbought fill color')
fill(signal, lowband, crsi < db ? color.new(#FF5252,55) : na, 'PS RSI Oversold fill color')
linetop = plot(stockbands ? stockbandtop : na,'70 line', color=color.new(#4CAF50, 2), linewidth=2)
linebottom = plot(stockbands ? stockbandbottom : na, '30 line', color=color.new(#FF5252, 2), linewidth=2)
fill(signal, linetop, crsi > 70 and stockbands ? color.new(#4CAF50,55) : na, 'PS RSI w/ 70/30 Overbought fill color')
fill(signal, linebottom, crsi < 30 and stockbands ? color.new(#FF5252,55) : na, 'PS RSI w/ 70/30 Oversold fill color')
signal2 = plot(tradrsi ? rsi : na, 'Traditional RSI', color=color.new(color.blue, 0), linewidth=4)
fill(signal2, highband, rsi > ub ? color.new(#4CAF50,55) : na, 'Trad RSI w/ ABs Overbought fill color')
fill(signal2, lowband, rsi < db ? color.new(#FF5252,55) : na, 'Trad RSI w/ ABs Oversold fill color')
fill(signal2, linetop, rsi > 70 and stockbands ? color.new(#4CAF50,55) : na, 'Traditional RSI Overbought fill color')
fill(signal2, linebottom, rsi < 30 and stockbands ? color.new(#FF5252,55) : na, 'Traditional RSI Oversold fill color')
//alerts
alertcondition(ta.crossunder(crsi, db) or ta.crossunder(crsi, stockbandbottom) or ta.crossunder(rsi, db) or ta.crossunder(rsi, stockbandbottom), title='Oversold', message='Entering Oversold Territory')
alertcondition(ta.crossover(crsi, ub) or ta.crossover(crsi, stockbandtop) or ta.crossover(rsi, ub) or ta.crossover(rsi, stockbandtop), title='Overbought', message='Entering Overbought Territory')
|
EWave -target | https://www.tradingview.com/script/9Ti2YNfZ-EWave-target/ | cmdqwe1 | https://www.tradingview.com/u/cmdqwe1/ | 235 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © HeWhoMustNotBeNamed
//@version=4
study("Elliot Wave - Impulse", shorttitle="MA50-200+EW TARGET", overlay=true, max_lines_count=500, max_labels_count=500)
source=input(close)
len2 = input(50, minval=1, title="Length")
src2 = input(close, title="Source")
out2 = sma(src2, len2)
len = input(200, minval=1, title="Length")
src = input(close, title="Source")
out = sma(src, len)
plot(out, color=#0b6ce5, title="MA200")
plot(out2, color=#ff4500, title="MA50")
zigzagLength = input(10, minval=0, step=5)
errorPercent = input(5, minval=2, step=5, maxval=20)
entryPercent = input(30, minval=10, step=10, maxval=100)
zigzagWidth = input(2, step=1, minval=1)
zigzagStyle = input(defval=line.style_dotted, options=[line.style_dashed, line.style_dotted, line.style_solid])
waitForConfirmation = true
max_pivot_size = 10
zigzagColor = color.black
showZigZag = true
var zigzagpivots = array.new_float(0)
var zigzagpivotbars = array.new_int(0)
var zigzagpivotdirs = array.new_int(0)
var waveLinesArray = array.new_line(2)
var targetLabels = array.new_label(0)
var targetLines = array.new_line(0)
var wavelines = array.new_line(0)
transparent = color.new(#FFFFFF, 100)
int max_array_size = 100
err_min = (100-errorPercent)/100
err_max = (100+errorPercent)/100
entry_range = (entryPercent)/100
var patterncount = array.new_int(2,0)
pivots(length)=>
float phigh = highestbars(high, length) == 0 ? high : na
float plow = lowestbars(low, length) == 0 ? low : na
dir = 0
dir := iff(phigh and na(plow), 1, iff(plow and na(phigh), -1, dir[1]))
[dir, phigh, plow]
zigzag(length, zigzagpivots, zigzagpivotbars, zigzagpivotdirs)=>
[dir, phigh, plow] = pivots(length)
dirchanged = change(dir)
if(phigh or plow)
value = (dir == 1? phigh : plow)
bar = bar_index
if(not dirchanged and array.size(zigzagpivots) >=1)
pivot = array.shift(zigzagpivots)
pivotbar = array.shift(zigzagpivotbars)
pivotdir = array.shift(zigzagpivotdirs)
value:= value*pivotdir < pivot*pivotdir? pivot : value
bar:= value*pivotdir < pivot*pivotdir? pivotbar : bar
if(array.size(zigzagpivots) >=2)
LastPoint = array.get(zigzagpivots,1)
dir := dir*value > dir*LastPoint? dir*2 : dir
array.unshift(zigzagpivots, value = value)
array.unshift(zigzagpivotbars, bar)
array.unshift(zigzagpivotdirs, dir)
if(array.size(zigzagpivots) > max_pivot_size)
array.pop(zigzagpivots)
array.pop(zigzagpivotbars)
array.pop(zigzagpivotdirs)
draw_zigzag(zigzagpivots, zigzagpivotbars, zigzagcolor, zigzagwidth, zigzagstyle, showZigZag)=>
if(array.size(zigzagpivots) > 2 and showZigZag)
for i=0 to array.size(zigzagpivots)-2
y1 = array.get(zigzagpivots, i)
y2 = array.get(zigzagpivots, i+1)
x1 = array.get(zigzagpivotbars, i)
x2 = array.get(zigzagpivotbars, i+1)
zline = line.new(x1=x1, y1=y1,
x2 = x2, y2=y2,
color=zigzagcolor, width=zigzagwidth, style=zigzagstyle)
//////////////////////////////////// Draw Lines with labels //////////////////////////////////////////////////
f_drawLinesWithLabels(target, lbl, linecolor)=>
timeDiffEnd = time - time[10]
timeDiffLabel = time - time[5]
line_x1 = time
line_x2 = time+timeDiffEnd
label_x = time+timeDiffLabel
targetLine = line.new(x1=line_x1, y1=target, x2=line_x2, y2=target, color=linecolor, xloc=xloc.bar_time)
targetLabel = label.new(x=label_x, y=target, text=lbl + " : "+tostring(target), xloc=xloc.bar_time, style=label.style_none, textcolor=color.black, size=size.normal)
[targetLine,targetLabel]
//////////////////////////////////// Delete Lines with labels //////////////////////////////////////////////////
f_deleteLinesWithLabels(targetLine, targetLabel)=>
line.delete(targetLine)
label.delete(targetLabel)
ew_impulse(zigzagpivots, zigzagpivotbars, zigzagpivotdirs, zigzagWidth, zigzagStyle, showZigZag, waveLinesArray, targetLines, targetLabels)=>
start = waitForConfirmation? 1: 0
waveFound = false
if(array.size(zigzagpivots) >= 3+start and showZigZag)
Point2 = array.get(zigzagpivots, start)
Point2Bar = array.get(zigzagpivotbars, start)
Point2Dir = array.get(zigzagpivotdirs, start)
Point1 = array.get(zigzagpivots, start+1)
Point1Bar = array.get(zigzagpivotbars, start+1)
Point1Dir = array.get(zigzagpivotdirs, start+1)
Point0 = array.get(zigzagpivots, start+2)
Point0Bar = array.get(zigzagpivotbars, start+2)
Point0Dir = array.get(zigzagpivotdirs, start+2)
W1Length = abs(Point1-Point0)
W2Length = abs(Point2-Point1)
r2 = W2Length/W1Length
existingW1 = array.get(waveLinesArray, 0)
existingW2 = array.get(waveLinesArray, 1)
existing0 = line.get_y1(existingW1)
existing1 = line.get_y1(existingW2)
existing2 = line.get_y2(existingW2)
dir = Point0 > Point1? -1 : 1
entry = Point2 + dir*entry_range*W2Length
stop = Point0
tstop = Point2 - dir*entry_range*W2Length
target1 = Point2 + dir*1.618*W2Length
target2 = Point2 + dir*2.0*W2Length
target3 = Point2 + dir*2.618*W2Length
target4 = Point2 + dir*3.236*W2Length
stopColor = dir == 1? color.red : color.red
targetColor = dir == 1? color.green : color.green
ignore = false
patternMatched = false
dirMatched = false
if(existing0 == Point0 or existing1 == Point1 or existing2 == Point2)
ignore := true
if(r2 > 0.50*err_min and r2 < 0.50*err_max) or (r2 > 0.618*err_min and r2 < 0.618*err_max) or
(r2 > 0.764*err_min and r2 < 0.764*err_max) or (r2 > 0.854*err_min and r2 < 0.854*err_max)
patternMatched := true
if(Point1Dir == 2 and Point2Dir == -1) or (Point1Dir == -2 and Point2Dir == 1)
dirMatched := true
directionColor = Point1 > Point2 ? color.green : color.red
if(not ignore and patternMatched and dirMatched)
w1 = line.new(y1=Point0, y2=Point1, x1=Point0Bar, x2=Point1Bar, color=directionColor, width=zigzagWidth, style=zigzagStyle)
w2 = line.new(y1=Point1, y2=Point2, x1=Point1Bar, x2=Point2Bar, color=directionColor, width=zigzagWidth, style=zigzagStyle)
array.set(waveLinesArray,0,w1)
array.set(waveLinesArray,1,w2)
if(array.size(targetLines) > 0)
for i=0 to array.size(targetLines)-1
line.delete(array.shift(targetLines))
for i=0 to array.size(targetLabels)-1
label.delete(array.shift(targetLabels))
[entryLine,entryLabel] = f_drawLinesWithLabels(entry, "Entry", color.blue)
[stopLine,stopLabel] = f_drawLinesWithLabels(stop, "Stop", stopColor)
[tstopLine,tstopLabel] = f_drawLinesWithLabels(tstop, "T.Stop", stopColor)
[t1Line,t1Label] = f_drawLinesWithLabels(target1, "Target - 1", targetColor)
[t2Line,t2Label] = f_drawLinesWithLabels(target2, "Target - 2", targetColor)
[t3Line,t3Label] = f_drawLinesWithLabels(target3, "Target - 3", targetColor)
[t4Line,t4Label] = f_drawLinesWithLabels(target4, "Target - 4", targetColor)
array.unshift(targetLines, entryLine)
array.unshift(targetLines, stopLine)
array.unshift(targetLines, tstopLine)
array.unshift(targetLines, t1Line)
array.unshift(targetLines, t2Line)
array.unshift(targetLines, t3Line)
array.unshift(targetLines, t4Line)
array.unshift(targetLabels, entryLabel)
array.unshift(targetLabels, stopLabel)
array.unshift(targetLabels, tstopLabel)
array.unshift(targetLabels, t1Label)
array.unshift(targetLabels, t2Label)
array.unshift(targetLabels, t3Label)
array.unshift(targetLabels, t4Label)
count_index = dir==1?0:1
array.set(patterncount, count_index, array.get(patterncount, count_index)+1)
waveFound := true
if(existing0 == Point0 and existing1 == Point1 and existing2 == Point2) and waveFound[1]
line.delete(existingW1)
line.delete(existingW2)
array.set(patterncount, count_index, array.get(patterncount, count_index)-1)
waveFound
zigzag(zigzagLength, zigzagpivots, zigzagpivotbars, zigzagpivotdirs)
waveFormed = ew_impulse(zigzagpivots, zigzagpivotbars, zigzagpivotdirs, zigzagWidth, zigzagStyle, showZigZag, waveLinesArray, targetLines, targetLabels)
alertcondition(waveFormed, title='New impulse wave alert', message='New impulse wave detected on {{ticker}}')
var stats = table.new(position = position.top_right, columns = 3, rows = max_pivot_size+2, border_width = 1)
if(barstate.islast)
table.cell(table_id = stats, column = 1, row = 0 , text = "Bullish", bgcolor=color.black, text_color=color.white)
table.cell(table_id = stats, column = 2, row = 0 , text = "Bearish", bgcolor=color.black, text_color=color.white)
dtColor = color.white
for type = 1 to (array.size(patterncount)/2)
for direction = 0 to 1
count_index = (type*2 - 2) + direction
row = type
column = direction+1
text = tostring(array.get(patterncount, count_index))
table.cell(table_id = stats, column = column, row = row, text = text, bgcolor=dtColor)
|
EPS and PER indicator | https://www.tradingview.com/script/jzH00umi/ | kei525dow | https://www.tradingview.com/u/kei525dow/ | 72 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © kei525dow
//@version=4
// Quarterly EPS, PER, total revenue(FQ) (in million unit), PSR can be shown as an indicator.
// Check only one indicator for the chart visibility.
study(title = "EPS REVENUE PSR indicator", shorttitle = "EPS REVENUE PSR")
// basic EPS
BEPS = financial(syminfo.tickerid, "EARNINGS_PER_SHARE_BASIC", "FQ")
DEPS = financial(syminfo.tickerid, "EARNINGS_PER_SHARE_DILUTED", "FQ")
BPER = close / BEPS
DPER = close / DEPS
// PSR
TSO = financial(syminfo.tickerid, "TOTAL_SHARES_OUTSTANDING", "FQ")
MarketCap = TSO * close
REV_Q = financial(syminfo.tickerid, "TOTAL_REVENUE", "FQ")
PSR = MarketCap / REV_Q / 4
RPS = REV_Q / TSO
// PLOT
plot(BEPS, title="Basic EPS", color=color.red, linewidth=2)
plot(BPER, title="Basic PER", color=color.lime, linewidth=2)
plot(PSR, title="PSR", color=color.blue, linewidth=2)
plot(REV_Q/1e6, title="total revenue(FQ, million unit)", color=color.aqua, linewidth=2)
plot(RPS, title="total revenue(FQ) per share", color=color.green, linewidth=2)
|
DMI - Visual | https://www.tradingview.com/script/8HjVuCes/ | RB_TRADER | https://www.tradingview.com/u/RB_TRADER/ | 103 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RB_TRADER
//@version=4
study(title="Directional Movement Index", shorttitle="DMI", format=format.price, precision=4, resolution="")
lensig = input(14, title="ADX Smoothing", minval=1, maxval=50)
len = input(14, minval=1, title="DI Length")
up = change(high)
down = -change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
trur = rma(tr, len)
plus = fixnan(100 * rma(plusDM, len) / trur)
minus = fixnan(100 * rma(minusDM, len) / trur)
sum = plus + minus
adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), lensig)
plot(adx, color=#FF006E, title="ADX")
plot(plus, color=#0094FF, title="+DI")
plot(minus, color=#FF6A00, title="-DI")
bgcolor(adx<plus and adx<minus ? color.white : plus>=minus ? color.blue : color.red)
bgcolor(adx<plus and adx<minus ? color.white : plus>=minus and adx>=minus and adx>=adx[1] ? color.blue : na)
bgcolor(adx<plus and adx<minus ? color.white : plus<minus and adx>=plus and adx>=adx[1] ? color.red : na)
level = input(20)
hline(level)
plotshape(plus, style=shape.circle, color=crossover(plus, level) ? color.blue:na, location=location.bottom)
plotshape(minus, style=shape.circle, color=crossover(minus, level) ? color.red:na, location=location.top)
plot(plus, style=plot.style_circles, linewidth=3, color=crossover(plus, minus) ? color.blue:na)
plot(minus, style=plot.style_circles, linewidth=3, color=crossover(minus, plus) ? color.red:na)
|
RSI in Bollinger bands | https://www.tradingview.com/script/asdvdojA-RSI-in-Bollinger-bands/ | Phantom_007 | https://www.tradingview.com/u/Phantom_007/ | 90 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Phantom_007
//@version=4
study(title="Relative Strength Index", shorttitle="RSI", format=format.price, precision=2, resolution="")
len = input(14, minval=1, title="Length")
ob = input(70, minval=50, maxval = 100, title="Overbought Level")
os = input(30, minval=0, maxval = 50, title="Oversold Level")
bl = input(60, minval=50, maxval = 100, title="Buyers Level")
sl = input(40, minval=0, maxval = 50, title="Sellers Level")
src = input(close, "Source", type = input.source)
up = rma(max(change(src), 0), len)
down = rma(-min(change(src), 0), len)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
plot(rsi, "RSI", color=color.yellow, linewidth = 2)
hline(50, "Mid Band", color=color.gray)
band6=hline(bl, "Buyers Band", color=color.green)
band4=hline(sl, "Sellers Band", color=color.red)
band1 = hline(ob, "Upper Band", color=color.red, linewidth =2, linestyle= hline.style_solid)
band0 = hline(os, "Lower Band", color=color.green, linewidth =2, linestyle= hline.style_solid)
fill(band4, band6, color=#9915FF, transp=90, title="Background")
fill(band6, band1, color=color.green, transp=90, title="60-70")
fill(band4, band0, color=color.red, transp=90, title="60-70")
// bb
length = input(20, minval=1)
mult = input(2.0, minval=0.001, maxval=50, title="StdDev")
basis = sma(rsi, length)
dev = mult * stdev(rsi, length)
upper = basis + dev
lower = basis - dev
offset = input(0, "Offset", type = input.integer, minval = -500, maxval = 500)
plot(basis, "Basis", color=#FF6D00, offset = offset)
p1 = plot(upper, "Upper", color=#2962FF, offset = offset)
p2 = plot(lower, "Lower", color=#2962FF, offset = offset)
fill(p1, p2, title = "Background", color=color.rgb(33, 150, 243, 95)) |
SSL of MAs | https://www.tradingview.com/script/isdJAKL8-SSL-of-MAs/ | cmartin81 | https://www.tradingview.com/u/cmartin81/ | 85 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © eylwithsteph
//This script will allow you to take the SSL OF the selected MA and includes a signal line that can be modified
//Multiple MA is taken from @StephXAGs (SSL of RSI)
//Multiple MA Options Credits to @Fractured
//@version=4
study(title="SSL of MAs", shorttitle="SSL of MAs", overlay=true)
maperiod = input(9, title="MA Period")
rsiperiod = input(14, title="RSI Period")
Mode = input(title = "RSI MA Mode", defval="SMMA", options=["TMA","ALMA", "EMA", "DEMA", "TEMA", "WMA", "VWMA", "SMA", "SMMA", "HMA", "LSMA", "JMA", "VAMA", "FRAMA", "ZLEMA", "KAMA", "Kijun", "Kijun v2", "McGinley", "IDWMA", "FLMSA", "PEMA", "HCF", "TIF", "MF", "ARMA", "DAF","WRMA", "RMA", "RAF", "GF", "A2RMA", "EDSMA"])
lsma_offset = input(defval=0, title="* Least Squares (LSMA) Only - Offset Value", minval=0)
alma_offset = input(defval=0.85, title="* Arnaud Legoux (ALMA) Only - Offset Value", minval=0, step=0.01) //0.85
alma_sigma = input(defval=6, title="* Arnaud Legoux (ALMA) Only - Sigma Value", minval=0) //6
jurik_phase = input(title="* Jurik (JMA) Only - Phase", type=input.integer, defval=50)
jurik_power = input(title="* Jurik (JMA) Only - Power", type=input.integer, defval=2)
volatility_lookback = input(51, title="* Volatility Adjusted (VAMA) Only - Volatility lookback length")
frama_FC = input(defval=1,minval=1, title="* Fractal Adjusted (FRAMA) Only - FC")
frama_SC = input(defval=200,minval=1, title="* Fractal Adjusted (FRAMA) Only - SC")
kama_fast_len = input(title="* Kaufman (KAMA) Only - Fast EMA Length", type=input.integer, defval=2)
kama_slow_len = input(title="* Kaufman (KAMA) Only - Slow EMA Length", type=input.integer, defval=30)
center = input(defval=10, title="* Trend Impulse Filter Only - Center")
//MF
beta = input(0.8,minval=0,maxval=1, title="Modular Filter, General Filter Only - Beta")
feedback = input(false, title="Modular Filter Only - Feedback")
z = input(0.5,title="Modular Filter Only - Feedback Weighting",minval=0,maxval=1)
//ARMA
gamma = input(3.,type=input.float, title="ARMA, A2RMA, General Filter Gamma")
zl = input(false,title="ARMA, DAF, WRMA, Zero-Lag")
//GF
zeta = input(1,maxval=1,type=input.float,title="General Filter Zeta")
//EDSMA
ssfLength = input(title="EDSMA - Super Smoother Filter Length", type=input.integer, minval=1, defval=20)
ssfPoles = input(title="EDSMA - Super Smoother Filter Poles", type=input.integer, defval=2, options=[2, 3])
//IDWMA
calcWeight(src, length, i) =>
distanceSum = 0.0
for j = 0 to length - 1
distanceSum := distanceSum + abs(nz(src[i]) - nz(src[j]))
distanceSum
//HCF
//study("Hybrid Convolution Filter",overlay=true)
//length = input(14)
//----
f(x) =>
.5*(1 - cos(x*3.14159))
d(x,length) =>
f(x/length) - f((x-1)/length)
//----
filter(a,b,length) =>
sum = 0.
for i = 1 to length
sgn = f(i/length)
sum := sum + (sgn*b + (1 - sgn)*a[i-1]) * d(i,length)
sum
//----
//A2RMA
ama(er,x)=>
a = 0.
a := er*x+(1-er)*nz(a[1],x)
//EDSMA
get2PoleSSF(src, length) =>
PI = 2 * asin(1)
arg = sqrt(2) * PI / length
a1 = exp(-arg)
b1 = 2 * a1 * cos(arg)
c2 = b1
c3 = -pow(a1, 2)
c1 = 1 - c2 - c3
ssf = 0.0
ssf := c1 * src + c2 * nz(ssf[1]) + c3 * nz(ssf[2])
get3PoleSSF(src, length) =>
PI = 2 * asin(1)
arg = PI / length
a1 = exp(-arg)
b1 = 2 * a1 * cos(1.738 * arg)
c1 = pow(a1, 2)
coef2 = b1 + c1
coef3 = -(c1 + b1 * c1)
coef4 = pow(c1, 2)
coef1 = 1 - coef2 - coef3 - coef4
ssf = 0.0
ssf := coef1 * src + coef2 * nz(ssf[1]) + coef3 * nz(ssf[2]) + coef4 * nz(ssf[3])
ma(type, src, len) =>
float result = 0
if type=="TMA"
result := sma(sma(src, ceil(len / 2)), floor(len / 2) + 1)
if type=="SMA" // Simple
result := sma(src, len)
if type=="EMA" // Exponential
result := ema(src, len)
if type=="DEMA" // Double Exponential
e = ema(src, len)
result := 2 * e - ema(e, len)
if type=="TEMA" // Triple Exponential
e = ema(src, len)
result := 3 * (e - ema(e, len)) + ema(ema(e, len), len)
if type=="WMA" // Weighted
result := wma(src, len)
if type=="VWMA" // Volume Weighted
result := vwma(src, len)
if type=="SMMA" // Smoothed
w = wma(src, len)
result := na(w[1]) ? sma(src, len) : (w[1] * (len - 1) + src) / len
if type=="HMA" // Hull
result := wma(2 * wma(src, len / 2) - wma(src, len), round(sqrt(len)))
if type=="LSMA" // Least Squares
result := linreg(src, len, lsma_offset)
if type=="ALMA" // Arnaud Legoux
result := alma(src, len, alma_offset, alma_sigma)
if type=="JMA" // Jurik
/// Copyright © 2018 Alex Orekhov (everget)
/// Copyright © 2017 Jurik Research and Consulting.
phaseRatio = jurik_phase < -100 ? 0.5 : jurik_phase > 100 ? 2.5 : jurik_phase / 100 + 1.5
beta = 0.45 * (len - 1) / (0.45 * (len - 1) + 2)
alpha = pow(beta, jurik_power)
jma = 0.0
e0 = 0.0
e0 := (1 - alpha) * src + alpha * nz(e0[1])
e1 = 0.0
e1 := (src - e0) * (1 - beta) + beta * nz(e1[1])
e2 = 0.0
e2 := (e0 + phaseRatio * e1 - nz(jma[1])) * pow(1 - alpha, 2) + pow(alpha, 2) * nz(e2[1])
jma := e2 + nz(jma[1])
result := jma
if type=="VAMA" // Volatility Adjusted
/// Copyright © 2019 to present, Joris Duyck (JD)
mid=ema(src,len)
dev=src-mid
vol_up=highest(dev,volatility_lookback)
vol_down=lowest(dev,volatility_lookback)
result := mid+avg(vol_up,vol_down)
if type=="FRAMA" // Fractal Adaptive
int len1 = len/2
e = 2.7182818284590452353602874713527
w = log(2/(frama_SC+1)) / log(e) // Natural logarithm (ln(2/(SC+1))) workaround
H1 = highest(high,len1)
L1 = lowest(low,len1)
N1 = (H1-L1)/len1
H2_ = highest(high,len1)
H2 = H2_[len1]
L2_ = lowest(low,len1)
L2 = L2_[len1]
N2 = (H2-L2)/len1
H3 = highest(high,len)
L3 = lowest(low,len)
N3 = (H3-L3)/len
dimen1 = (log(N1+N2)-log(N3))/log(2)
dimen = iff(N1>0 and N2>0 and N3>0,dimen1,nz(dimen1[1]))
alpha1 = exp(w*(dimen-1))
oldalpha = alpha1>1?1:(alpha1<0.01?0.01:alpha1)
oldN = (2-oldalpha)/oldalpha
N = (((frama_SC-frama_FC)*(oldN-1))/(frama_SC-1))+frama_FC
alpha_ = 2/(N+1)
alpha = alpha_<2/(frama_SC+1)?2/(frama_SC+1):(alpha_>1?1:alpha_)
frama = 0.0
frama :=(1-alpha)*nz(frama[1]) + alpha*src
result := frama
if type=="ZLEMA" // Zero-Lag EMA
f_lag = (len - 1) / 2
f_data = src + (src - src[f_lag])
result := ema(f_data, len)
if type=="KAMA" // Kaufman Adaptive
mom = abs(change(src, len))
volatility = sum(abs(change(src)), len)
er = volatility != 0 ? mom / volatility : 0
fastAlpha = 2 / (kama_fast_len + 1)
slowAlpha = 2 / (kama_slow_len + 1)
sc = pow((er * (fastAlpha - slowAlpha)) + slowAlpha, 2)
kama = 0.0
kama := sc * src + (1 - sc) * nz(kama[1])
result := kama
if type=="Kijun" //Kijun-sen
kijun = avg(lowest(len), highest(len))
result :=kijun
if type=="Kijun v2"
kijun = avg(lowest(len), highest(len))
conversionLine = avg(lowest(len/2), highest(len/2))
delta = (kijun + conversionLine)/2
result :=delta
if type=="McGinley"
mg = 0.0
mg := na(mg[1]) ? ema(src, len) : mg[1] + (src - mg[1]) / (len * pow(src/mg[1], 4))
result :=mg
if type=="IDWMA"
sum = 0.0
weightSum = 0.0
for i = 0 to len - 1
weight = calcWeight(src, len, i)
sum := sum + nz(src[i]) * weight
weightSum := weightSum + weight
idwma = sum / weightSum
result := idwma
if type=="FLMSA"
n = bar_index
b = 0.
e = sma(abs(src - nz(b[1])),len)
z = sma(src - nz(b[1],src),len)/e
r = (exp(2*z) - 1)/(exp(2*z) + 1)
a = (n - sma(n,len))/stdev(n,len) * r
b := sma(src,len) + a*stdev(src,len)
result := b
if type=="PEMA"
// Copyright (c) 2010-present, Bruno Pio
// Copyright (c) 2019-present, Alex Orekhov (everget)
// Pentuple Exponential Moving Average script may be freely distributed under the MIT license.
ema1 = ema(src, len)
ema2 = ema(ema1, len)
ema3 = ema(ema2, len)
ema4 = ema(ema3, len)
ema5 = ema(ema4, len)
ema6 = ema(ema5, len)
ema7 = ema(ema6, len)
ema8 = ema(ema7, len)
pema = 8 * ema1 - 28 * ema2 + 56 * ema3 - 70 * ema4 + 56 * ema5 - 28 * ema6 + 8 * ema7 - ema8
result := pema
if type=="HCF"
output = 0.
output := filter(src, nz(output[1],src), len)
result := output
if type=="TIF"
b = 0.0
a = rising(src,len) or falling(src,len) ? 1 : 0
b := ema(a*src+(1-a)*nz(b[1],src),center)
result := b
if type=="MF"
ts=0.,b=0.,c=0.,os=0.
//----
alpha = 2/(len+1)
a = feedback ? z*src + (1-z)*nz(ts[1],src) : src
//----
b := a > alpha*a+(1-alpha)*nz(b[1],a) ? a : alpha*a+(1-alpha)*nz(b[1],a)
c := a < alpha*a+(1-alpha)*nz(c[1],a) ? a : alpha*a+(1-alpha)*nz(c[1],a)
os := a == b ? 1 : a == c ? 0 : os[1]
//----
upper = beta*b+(1-beta)*c
lower = beta*c+(1-beta)*b
ts := os*upper+(1-os)*lower
result := ts
if type=="ARMA"
//----
ma = 0.
mad = 0.
//----
src2 = zl ? src + change(src,len/2) : src
ma := nz(mad[1],src2)
d = cum(abs(src2[len] - ma))/bar_index * gamma
mad := sma(sma(src2 > nz(mad[1],src2) + d ? src2 + d : src2 < nz(mad[1],src) - d ? src2 - d : nz(mad[1],src2),len),len)
result := mad
if type=="DAF"
AC = zl ? 1 : 0
out = 0.
K = 0.
//----
src2 = src + (src - nz(out[1],src))
out := nz(out[1],src2) + nz(K[1])*(src2 - nz(out[1],src2)) + AC*(nz(K[1])*(src2 - sma(src2,len)))
K := abs(src2 - out)/(abs(src2 - out) + stdev(src2,len)*len)
result := out
if type=="WRMA"
//----
alpha = 2/(len+1)
p1 = zl ? len/4 : 1
p2 = zl ? len/4 : len/2
//----
a = 0.0
b = 0.0
A = 0.0
B = 0.0
a := nz(a[1]) + alpha*nz(A[1])
b := nz(b[1]) + alpha*nz(B[1])
y = ema(a + b,p1)
A := src - y
B := src - ema(y,p2)
result := y
//----
if type=="RMA"
ma = sma(src,len*3) + sma(src,len*2) - sma(src,len)
result := ma
if type=="RAF"
altma = 0.0
AR = 2*(highest(len) - lowest(len))
BR = 2*(highest(len*2) - lowest(len*2))
k1 = (1 - AR)/AR
k2 = (1 - BR)/BR
//
alpha = k2/k1
R1 = sqrt(highest(len))/4 * ((alpha - 1)/alpha) * (k2/(k2 + 1))
R2 = sqrt(highest(len*2))/4 * (alpha - 1) * (k1/(k1 + 1))
Factor = R2/R1
//
AltK = fixnan(pow(Factor >= 1 ? 1 : Factor,sqrt(len)))*(1/len)
altma := AltK*src+(1-AltK)*nz(altma[1],src)
result := altma
if type=="GF"
////////////////////////////////////////////////////////////////
//Coefficients Table :
//
//MA : beta = 2/gamma = 0.5
//EMA : beta = 3/gamma = 0.4
//HMA = beta = 4/gamma = 0.85
//LSMA : beta = 3.5/gamma = 0.9
//QLSMA : beta = 5.25/gamma = 1
//JMA : beta = pow*2/gamma = 0.5
//3 Poles Butterworth Filter : beta = 5.5/gamma = 0.5/zeta = 0
//
////////////////////////////////////////////////////////////////
b = 0.0
d = 0.0
p = len/beta
a = src - nz(b[p],src)
b := nz(b[1],src) + a/p*gamma
c = b - nz(d[p],b)
d := nz(d[1],src) + (zeta*a+(1-zeta)*c)/p*gamma
result := d
if type=="A2RMA"
er = abs(change(src,len))/sum(abs(change(src)),len)
//----
ma = 0.
d = cum(abs(src - nz(ma[1],src)))/bar_index * gamma
ma := ama(er,ama(er,src > nz(ma[1],src) + d ? src + d : src < nz(ma[1],src) - d ? src - d : nz(ma[1],src)))
//----
result := ma
if type=="EDSMA"
zeros = src - nz(src[2])
avgZeros = (zeros + zeros[1]) / 2
// Ehlers Super Smoother Filter
ssf = ssfPoles == 2
? get2PoleSSF(avgZeros, ssfLength)
: get3PoleSSF(avgZeros, ssfLength)
// Rescale filter in terms of Standard Deviations
stdev = stdev(ssf, len)
scaledFilter = stdev != 0
? ssf / stdev
: 0
alpha = 5 * abs(scaledFilter) / len
edsma = 0.0
edsma := alpha * src + (1 - alpha) * nz(edsma[1])
result := edsma
result
ma_value = ma(Mode,close, maperiod)
rsi_value = rsi(ma_value, rsiperiod)
smaHigh=ma(Mode,high, maperiod)
smaLow=ma(Mode,low, maperiod)
float Hlv = na
Hlv := close > smaHigh ? 1 : close < smaLow ? -1 : Hlv[1]
sslDown = Hlv < 0 ? smaHigh: smaLow
sslUp = Hlv < 0 ? smaLow : smaHigh
plot(sslDown, linewidth=2, color=color.red)
plot(sslUp, linewidth=2, color=color.lime)
buy = sslUp > sslDown and sslUp[1] < sslDown[1]
sell = sslUp < sslDown and sslUp[1] > sslDown[1]
//bgcolor(cross(sslUp, sslDown) and sslUp > sslDown? color.green: cross(sslUp, sslDown) and sslUp < sslDown ? color.red: na, transp=50)
bgcolor(buy? color.green: sell ? color.red: na, transp=50)
|
Levels Off Previous Day Close | https://www.tradingview.com/script/kZlqOSaE-Levels-Off-Previous-Day-Close/ | DominatorTrades | https://www.tradingview.com/u/DominatorTrades/ | 57 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © DominatorTrades
//@version=4
study("Levels Off Previous Day Close", overlay=true)
// Define Inputs
// What to calc inputs
var showInput90 = input(title="Show 90% Line", type=input.bool, defval=true, confirm=false)
var showInput120 = input(title="Show 120% Line ", type=input.bool, defval=true, confirm=false)
var showInput180 = input(title="Show 180% Line", type=input.bool, defval=true, confirm=false)
var showInput240 = input(title="Show 240% Line", type=input.bool, defval=false, confirm=false)
var showInput360 = input(title="Show 120% Line", type=input.bool, defval=false, confirm=false)
var Input90Text = input(title="90% Label Text", type=input.string, defval="90 ", confirm=false)
var Input120Text = input(title="120% Label Text", type=input.string, defval="120 ", confirm=false)
var Input180Text = input(title="180% Label Text", type=input.string, defval="180 ", confirm=false)
var Input240Text = input(title="240% Label Text", type=input.string, defval="240 ", confirm=false)
var Input360Text = input(title="360% Label Text", type=input.string, defval="360 ", confirm=false)
//Line Style Input
var styleOption = input(title="Line Style", type=input.string,
options=["solid (─)", "dotted (┈)", "dashed (╌)",
"arrow left (←)", "arrow right (→)", "arrows both (↔)"],
defval="solid (─)")
var lineStyle = styleOption == "dotted (┈)" ? line.style_dotted :
styleOption == "dashed (╌)" ? line.style_dashed :
styleOption == "arrow left (←)" ? line.style_arrow_left :
styleOption == "arrow right (→)" ? line.style_arrow_right :
styleOption == "arrows both (↔)" ? line.style_arrow_both :
line.style_solid
var lineThickness = input(title="Line Thickness", type=input.integer,
options=[1,2,3,4],
defval=1)
var lineColor = input(title="Line Color", type=input.color,defval=color.gray)
var textColor = input(title="Text Color", type=input.color,defval=color.black)
// Define the prices
prev_daily_close = security(syminfo.tickerid, "D", close[0])
ninety = (prev_daily_close[1] * 1.90 )
oneTwenty = (prev_daily_close[1] * 2.20 )
oneEighty = (prev_daily_close[1] * 2.80 )
twoForty = (prev_daily_close[1] * 3.40 )
threeSixty = (prev_daily_close[1] * 3.60 )
// Set the Price Labels
var ninetyLabel = label.new(x=bar_index, y=ninety, color=color.orange,textcolor=textColor, style=label.style_none)
label.set_text(id=ninetyLabel, text=Input90Text + tostring(ninety))
if(showInput90 )
label.set_xy(ninetyLabel,bar_index,ninety), label.set_xy(ninetyLabel,bar_index,ninety)
var oneTwentyLabel = label.new(x=bar_index, y=oneTwenty, color=color.orange,textcolor=textColor, style=label.style_none)
label.set_text(id=oneTwentyLabel, text=Input120Text + tostring(oneTwenty))
if(showInput120 )
label.set_xy(oneTwentyLabel,bar_index,oneTwenty)
var oneEightyLabel = label.new(x=bar_index, y=oneEighty, color=color.orange,textcolor=textColor, style=label.style_none)
label.set_text(id=oneEightyLabel, text=Input180Text + tostring(oneEighty))
if(showInput180 )
label.set_xy(oneEightyLabel,bar_index,oneEighty)
var twoFortyLabel = label.new(x=bar_index, y=twoForty, color=color.orange,textcolor=textColor, style=label.style_none)
label.set_text(id=twoFortyLabel, text=Input240Text + tostring(twoForty))
if(showInput240 )
label.set_xy(twoFortyLabel,bar_index,twoForty)
var threeSixtyLabel = label.new(x=bar_index, y=threeSixty, color=color.orange,textcolor=textColor,style=label.style_none)
label.set_text(id=threeSixtyLabel, text=Input360Text + tostring(threeSixty))
if(showInput360 )
label.set_xy(threeSixtyLabel,bar_index,threeSixty)
line lnNinety = na
line lineOneTwenty = na
line lineOneEighty = na
line lineTwoForty = na
line lineThreeSixty = na
line.delete(lnNinety[1])
line.delete(lineOneTwenty[1])
line.delete(lineOneEighty[1])
line.delete(lineTwoForty[1])
line.delete(lineThreeSixty[1])
if(showInput90 )
lnNinety := line.new( bar_index - 1, ninety, bar_index, ninety, width=lineThickness, color=lineColor, extend=extend.both, style=lineStyle)
if(showInput120 )
lineOneTwenty := line.new(bar_index - 1, oneTwenty, bar_index, oneTwenty, width=lineThickness, color=lineColor, extend=extend.both, style=lineStyle)
if(showInput180 )
lineOneEighty := line.new(bar_index - 1, oneEighty, bar_index, oneEighty, width=lineThickness, color=lineColor, extend=extend.both, style=lineStyle)
if(showInput240 )
lineTwoForty := line.new(bar_index - 1, twoForty, bar_index, twoForty, width=lineThickness, color=lineColor, extend=extend.both, style=lineStyle)
if(showInput360 )
lineThreeSixty := line.new(bar_index - 1, threeSixty, bar_index, threeSixty, width=lineThickness, color=lineColor, extend=extend.both, style=lineStyle)
|
Klinger Volume Divergence Indicator | https://www.tradingview.com/script/U3iUmTUB-Klinger-Volume-Divergence-Indicator/ | seslly | https://www.tradingview.com/u/seslly/ | 240 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © seslly
//@version=4
// Modified version of the divergence indicator by seslly
study(title="Klinger Volume Divergence Indicator", shorttitle="Divergence Indicator", format=format.volume, resolution="")
lbR = input(title="Pivot Lookback Right", defval=5)
lbL = input(title="Pivot Lookback Left", defval=5)
rangeUpper = input(title="Max of Lookback Range", defval=60)
rangeLower = input(title="Min of Lookback Range", defval=5)
plotBull = input(title="Plot Bullish", defval=true)
plotHiddenBull = input(title="Plot Hidden Bullish", defval=false)
plotBear = input(title="Plot Bearish", defval=true)
plotHiddenBear = input(title="Plot Hidden Bearish", defval=false)
bearColor = color.red
bullColor = color.green
hiddenBullColor = color.new(color.green, 80)
hiddenBearColor = color.new(color.red, 80)
textColor = color.white
noneColor = color.new(color.white, 100)
sv = change(hlc3) >= 0 ? volume : -volume
kvo = ema(sv, 34) - ema(sv, 55)
sig = ema(kvo, 13)
pressure = kvo < 0 ? color.red : color.green
plot(kvo, title="KVO", linewidth=2, color=pressure)
plot(sig, title="Signal", linewidth=1, color = #8D1699)
hline(0, title="Middle Line", linestyle=hline.style_dotted)
plFound = na(pivotlow(kvo, lbL, lbR)) ? false : true
// TODO add separate price and vol pivots and lh/ll
// volplFound = na(pivotlow(kvo, lbL, lbR)) ? false : true
phFound = na(pivothigh(kvo, lbL, lbR)) ? false : true
// volphFound = na(pivothigh(kvo, lbL, lbR)) ? false : true
_inRange(cond) =>
bars = barssince(cond == true)
rangeLower <= bars and bars <= rangeUpper
//------------------------------------------------------------------------------
// Regular Bullish
// kvo: Higher Low
kvoHL = kvo[lbR] > valuewhen(plFound, kvo[lbR], 1) and _inRange(plFound[1])
// Price: Lower Low
priceLL = low[lbR] < valuewhen(plFound, low[lbR], 1)
bullCond = plotBull and priceLL and kvoHL and plFound
plot(
plFound ? kvo[lbR] : na,
offset=-lbR,
title="Regular Bullish",
linewidth=2,
color=(bullCond ? bullColor : noneColor)
)
plotshape(
bullCond ? kvo[lbR] : na,
offset=-lbR,
title="Regular Bullish Label",
text=" Bull ",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=textColor
)
alertcondition(bullCond, "Bullish Signal Alert", "{{exchange}}:{{ticker}}, price = {{close}}")
//------------------------------------------------------------------------------
// Hidden Bullish
// kvo: Lower Low
kvoLL = kvo[lbR] < valuewhen(plFound, kvo[lbR], 1) and _inRange(plFound[1])
// Price: Higher Low
priceHL = low[lbR] > valuewhen(plFound, low[lbR], 1)
hiddenBullCond = plotHiddenBull and priceHL and kvoLL and plFound
plot(
plFound ? kvo[lbR] : na,
offset=-lbR,
title="Hidden Bullish",
linewidth=2,
color=(hiddenBullCond ? hiddenBullColor : noneColor)
)
plotshape(
hiddenBullCond ? kvo[lbR] : na,
offset=-lbR,
title="Hidden Bullish Label",
text=" H Bull ",
style=shape.labelup,
location=location.absolute,
color=bullColor,
textcolor=textColor
)
alertcondition(hiddenBullCond, "Hidden Bullish Signal Alert", "{{exchange}}:{{ticker}}, price = {{close}}")
//------------------------------------------------------------------------------
// Regular Bearish
// kvo: Lower High
kvoLH = kvo[lbR] < valuewhen(phFound, kvo[lbR], 1) and _inRange(phFound[1])
// Price: Higher High
priceHH = high[lbR] > valuewhen(phFound, high[lbR], 1)
bearCond = plotBear and priceHH and kvoLH and phFound
plot(
phFound ? kvo[lbR] : na,
offset=-lbR,
title="Regular Bearish",
linewidth=2,
color=(bearCond ? bearColor : noneColor)
)
plotshape(
bearCond ? kvo[lbR] : na,
offset=-lbR,
title="Regular Bearish Label",
text=" Bear ",
style=shape.labeldown,
location=location.absolute,
color=bearColor,
textcolor=textColor
)
alertcondition(bearCond, "Bearish Signal Alert", "{{exchange}}:{{ticker}}, price = {{close}}")
//------------------------------------------------------------------------------
// Hidden Bearish
// kvo: Higher High
kvoHH = kvo[lbR] > valuewhen(phFound, kvo[lbR], 1) and _inRange(phFound[1])
// Price: Lower High
priceLH = high[lbR] < valuewhen(phFound, high[lbR], 1)
hiddenBearCond = plotHiddenBear and priceLH and kvoHH and phFound
plot(
phFound ? kvo[lbR] : na,
offset=-lbR,
title="Hidden Bearish",
linewidth=2,
color=(hiddenBearCond ? hiddenBearColor : noneColor)
)
plotshape(
hiddenBearCond ? kvo[lbR] : na,
offset=-lbR,
title="Hidden Bearish Label",
text=" H Bear ",
style=shape.labeldown,
location=location.absolute,
color=bearColor,
textcolor=textColor
)
alertcondition(hiddenBearCond, "Hidden Bearish Signal Alert", "{{exchange}}:{{ticker}}, price = {{close}}") |
Volume Profile Auto [line] | https://www.tradingview.com/script/pTCl4kV6-Volume-Profile-Auto-line/ | fikira | https://www.tradingview.com/u/fikira/ | 3,618 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © fikira
//@version=4
study("Volume Profile Auto [line] v2", shorttitle="VPa [line] v2", overlay=true, max_lines_count=500, max_boxes_count=500)
i_size = input(25 , "parts" , minval = 5, maxval = 50)
i_width = input(15 , "max width")
aMax = input(500 , "max lines", maxval = 500)
c_volH = input(color.new(color.orange, 40), type = input.color, title="color vol max")
c_vol = input(color.new(color.blue , 65), type = input.color, title="color vol" )
c_POC = input(color.new(#ff0000 , 40), type = input.color, title="color POC" )
maxVol = highest(volume, aMax)
i_auto = input(true , title="Automatic Settings", tooltip=
"Lower Timeframe = Monthly -> Higher Timeframe = 1 Year \nLower Timeframe = Weekly -> Higher Timeframe = 1 Month \nLower Timeframe = Daily -> Higher Timeframe = 1 Week \nLower Timeframe = Hourly -> Higher Timeframe = 1 Day \nLower Timeframe = Minutes -> Higher Timeframe = 1 Hour \nLower Timeframe = Seconds -> Higher Timeframe = 1 Minute")
periodL1 = input("60", title="Lower Timeframe", type=input.resolution)
periodH1 = input("D" , title="Higher Timeframe", type=input.resolution)
periodH2 = "1"
if timeframe.ismonthly
periodH2 := "12M"
else
if timeframe.isweekly
periodH2 := "1M"
else
if timeframe.isdaily
periodH2 := "1W"
else
if timeframe.period == "60" or
timeframe.period == "120" or
timeframe.period == "180" or
timeframe.period == "240" or
timeframe.period == "360" or
timeframe.period == "480" or
timeframe.period == "720"
periodH2 := "1D"
else
if timeframe.isminutes
periodH2 := "60"
else
if timeframe.isseconds
periodH2 := "1"
periodL = i_auto ? timeframe.period : periodL1
periodH = i_auto ? periodH2 : periodH1
chT_H = change(time(periodH))
chT_Lo = change(time(periodL))
var t_H = 0
var t_L = 0
t_H :=
periodH == "1" ? 1000 * 60 :
periodH == "3" ? 1000 * 60 * 3 :
periodH == "5" ? 1000 * 60 * 5 :
periodH == "10" ? 1000 * 60 * 10 :
periodH == "15" ? 1000 * 60 * 15 :
periodH == "30" ? 1000 * 60 * 30 :
periodH == "60" ? 1000 * 60 * 60 :
periodH == "120" ? 1000 * 60 * 60 * 2 :
periodH == "180" ? 1000 * 60 * 60 * 3 :
periodH == "240" ? 1000 * 60 * 60 * 4 :
periodH == "360" ? 1000 * 60 * 60 * 6 :
periodH == "720" ? 1000 * 60 * 60 * 12 :
periodH == "1D" ? 1000 * 60 * 60 * 24 :
periodH == "3D" ? 1000 * 60 * 60 * 24 * 3 :
periodH == "1W" ? 1000 * 60 * 60 * 24 * 7 :
periodH == "1M" ? 1000 * 60 * 60 * 24 * 30 :
1000 * 60 * 60 * 24 * 365
t_L :=
not i_auto ?
periodL == "1" ? 1000 * 60 :
periodL == "3" ? 1000 * 60 * 3 :
periodL == "5" ? 1000 * 60 * 5 :
periodL == "10" ? 1000 * 60 * 10 :
periodL == "15" ? 1000 * 60 * 15 :
periodL == "30" ? 1000 * 60 * 30 :
periodL == "60" ? 1000 * 60 * 60 :
periodL == "120" ? 1000 * 60 * 60 * 2 :
periodL == "180" ? 1000 * 60 * 60 * 3 :
periodL == "240" ? 1000 * 60 * 60 * 4 :
periodL == "360" ? 1000 * 60 * 60 * 6 :
periodL == "720" ? 1000 * 60 * 60 * 12 :
periodL == "1D" ? 1000 * 60 * 60 * 24 :
periodL == "3D" ? 1000 * 60 * 60 * 24 * 3 :
periodL == "1W" ? 1000 * 60 * 60 * 24 * 7 :
1000 * 60 * 60 * 24 * 30 :
timeframe.isseconds ? 1000 * timeframe.multiplier :
timeframe.isminutes ? 1000 * 60 * timeframe.multiplier :
periodL == "60" ? 1000 * 60 * 60 :
periodL == "120" ? 1000 * 60 * 60 * 2 :
periodL == "180" ? 1000 * 60 * 60 * 3 :
periodL == "240" ? 1000 * 60 * 60 * 4 :
periodL == "360" ? 1000 * 60 * 60 * 6 :
periodL == "720" ? 1000 * 60 * 60 * 12 :
timeframe.isdaily ? 1000 * 60 * 60 * 24 * timeframe.multiplier :
timeframe.isweekly ? 1000 * 60 * 60 * 24 * 7 * timeframe.multiplier :
1000 * 60 * 60 * 24 * 30 * timeframe.multiplier
mult = t_H / t_L
var a_lines = array.new_line (i_size, na)
var a_vol = array.new_float(i_size, 0)
var a_box = array.new_box (i_size, na)
var tempArray = array.new_float(i_size, 0)
var tmpAmax = 0.
var index = 0
var line l_POC = na, line.delete(l_POC)
// if change new period
if chT_H
// before adding a new series of lines -> wrap up
// Draw POC
l_POC := line.new(
line.get_x1(array.get(a_lines, index)) , avg(line.get_y1(array.get(a_lines, index)), line.get_y1(array.get(a_lines, index + 1))),
line.get_x2(array.get(a_lines, index)) + 100, avg(line.get_y1(array.get(a_lines, index)), line.get_y1(array.get(a_lines, index + 1))),
color = c_POC)
// place box just 1 bar further
if array.size (a_box) > 0
box.set_right(array.get(a_box, 0), bar_index) // move latest box (right size) 1 bar_index further when new period
// create new box
array.unshift(a_box, box.new(bar_index, high, bar_index, low, border_color=na, bgcolor=color.new(c_vol, 95)))
// clean-up if max is reached
if array.size (a_box) > ceil(aMax / i_size)
box.delete (array.get(a_box , array.size(a_box ) - 1))
array.pop (a_box)
// adding a new series of lines
for i = 0 to i_size - 1
// create x amount of memory space for volume (lines)
array.unshift(a_lines, line.new(bar_index, high - ((high - low) / i_size * i), bar_index, high - ((high - low) / i_size * (i + 1)), width=1, color=c_vol)) // create new x amount of lines (parts)
array.unshift(a_vol , 0)
// clean-up if max is reached
if array.size (a_lines) > (aMax)
line.delete(array.get(a_lines, array.size(a_lines) - 1))
array.pop (a_lines )
array.pop (a_vol )
if array.size(a_lines) > 0
//if not chT_H
box.set_right(array.get(a_box, 0), bar_index ) // make existing box 1 bar larger to the right
line.set_x2 (l_POC , bar_index ) // make existing POC 1 bar larger to the right
hi = line.get_y1(array.get(a_lines, 0 )) // highest high of HTF
lo = line.get_y2(array.get(a_lines, i_size - 1)) // lowest low of HTF
if high > hi
for i = 0 to i_size - 1
line.set_y1(array.get(a_lines, 0), high)
hi := line.get_y1(array.get(a_lines, 0))
line.set_y1(array.get(a_lines, i), hi - ((hi - lo ) / i_size * i ))
line.set_y2(array.get(a_lines, i), hi - ((hi - lo ) / i_size * (i + 1 )))
box.set_top(array.get(a_box , 0), hi)
if low < lo
for i = 0 to i_size - 1
line.set_y2(array.get(a_lines, i_size - 1), low)
lo := line.get_y2(array.get(a_lines, i_size - 1))
line.set_y1 (array.get(a_lines, i), hi - ((hi - lo) / i_size * i ))
line.set_y2 (array.get(a_lines, i), hi - ((hi - lo) / i_size * (i + 1)))
box.set_bottom (array.get(a_box , 0), lo)
for i = 0 to i_size - 1
if high >= line.get_y1 (array.get(a_lines, i)) and low <= line.get_y2(array.get(a_lines, i))
array.set(a_vol, i, array.get(a_vol , i) + volume)
line.set_width (array.get(a_lines, i), round(array.get(a_vol, i)))
if array.size(a_vol) > 0
for i = 0 to array.size(tempArray) - 1
line.set_color(array.get(a_lines, i), c_vol)
array.set(tempArray, i, array.get(a_vol, i))
tmpAmax := array.max(tempArray)
index := array.indexof(tempArray, tmpAmax)
line.set_color(array.get(a_lines, index), c_volH)
l_POC := line.new(
line.get_x1(array.get(a_lines, index)) , avg(line.get_y1(array.get(a_lines, index)), line.get_y1(array.get(a_lines, index + 1))),
line.get_x2(array.get(a_lines, index)) + 100, avg(line.get_y1(array.get(a_lines, index)), line.get_y1(array.get(a_lines, index + 1))),
color = c_POC)
if barstate.islast
for i = 0 to array.size(a_lines) - 1
boxL = box.get_left (array.get(a_box, 0))
boxR = box.get_right(array.get(a_box, 0))
width = boxR - boxL
line.set_width(array.get(a_lines, i), round((i_width / maxVol) * array.get(a_vol, i))) // at the last bar, adjust all line width's (to get a uniform comparison between lines)
line.set_x2(l_POC, bar_index + 200)
barcolor(color.new(color.black, 100)) // make candles transparent
//plot(array.size(a_box ) > 0 ? array.size(a_box ) : na)
//plot(array.size(a_lines) > 0 ? array.size(a_lines) : na)
|
Gann Square 4 Table Concept Alternate UI | https://www.tradingview.com/script/yH604xPv-Gann-Square-4-Table-Concept-Alternate-UI/ | RozaniGhani-RG | https://www.tradingview.com/u/RozaniGhani-RG/ | 23 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RozaniGhani-RG
// Inspired by The Tunnel Thru The Air Or Looking Back From 1940, written by WD Gann
// Page 195 - 198
//
// Related build
// https://www.tradingview.com/script/WMeyD4Sy-Gann-Square-4-Cross-Cardinal-Table-Concept/
// https://www.tradingview.com/script/mEzLbIKm-Gann-Square-9-Cross-Cardinal-Table-Concept/
//@version=5
indicator('Gann Square 4 Table Concept Alternate UI', shorttitle = 'GS4TCAU_SC')
// 0. Arrays
// 1. Variables
// 2. Custom functions
// 3. if statament
// 4. Inputs
// ————————————————————————————————————————————————————————————————————————————— 0. Arrays {
// 0 1 2 3 4 5 6 7 8 9
arr_cardinal_45 = array.from(1, 6, 19, 40, 69, 106, 151, 204, 265, 334)
arr_cardinal_135 = array.from(2, 9, 24, 47, 78, 117, 164, 219, 282, 353)
arr_cardinal_225 = array.from(3, 12, 29, 54, 87, 128, 177, 234, 299, 372)
arr_cardinal_315 = array.from(4, 15, 34, 61, 96, 139, 190, 249, 316, 391)
// sort array
array.sort(arr_cardinal_45, order.descending)
// }
// ————————————————————————————————————————————————————————————————————————————— 1. Variables {
G1 = 'Cross Cardinal'
var testTable = table.new(position = position.middle_center, columns = 21, rows = 21, bgcolor = color.black, border_width = 1)
input_font = input.string('Small', 'Font Size',options = ['Tiny', 'Small', 'Normal', 'Large', 'Huge'])
font = switch input_font
'Tiny' => size.tiny
'Small' => size.small
'Large' => size.large
'Huge' => size.huge
=> size.normal
// }
// ————————————————————————————————————————————————————————————————————————————— 2. Custom functions {
cell_default(int _column, int _row, _id, int _index)=>
table.cell(testTable, _column, _row, str.tostring(array.get(_id, _index)), bgcolor = color.gray, text_color = color.black, text_size = font)
fun_set(_input, _column0, _row0, _column1, _row1, _column2, _row2, _column3, _row3, _color) =>
if _input
table.cell_set_bgcolor(testTable, _column0, _row0, _color)
table.cell_set_bgcolor(testTable, _column1, _row1, _color)
table.cell_set_bgcolor(testTable, _column2, _row2, _color)
table.cell_set_bgcolor(testTable, _column3, _row3, _color)
// }
// ————————————————————————————————————————————————————————————————————————————— 3. if statament {
if barstate.islast
for _id = 0 to 9
cell_default( _id, _id, arr_cardinal_45, _id)
cell_default(11 + _id, 9 - _id, arr_cardinal_135, _id)
cell_default(11 + _id, 11 + _id, arr_cardinal_225, _id)
cell_default(9 - _id, 11 + _id, arr_cardinal_315, _id)
// }
// ————————————————————————————————————————————————————————————————————————————— 4. Inputs {
cardinal_0 = input(false, ' 1, 2, 3, 4', group = G1, inline = '0'), c0 = input.color(color.red, '', group = G1, inline = '0')
cardinal_1 = input(false, ' 6, 9, 12, 15', group = G1, inline = '1'), c1 = input.color(color.orange, '', group = G1, inline = '1')
cardinal_2 = input(false, ' 19, 24, 29, 34', group = G1, inline = '2'), c2 = input.color(color.yellow, '', group = G1, inline = '2')
cardinal_3 = input(false, ' 40, 47, 54, 61', group = G1, inline = '3'), c3 = input.color(color.green, '', group = G1, inline = '3')
cardinal_4 = input(false, ' 69, 78, 87, 96', group = G1, inline = '4'), c4 = input.color(color.teal, '', group = G1, inline = '4')
cardinal_5 = input(false, '106, 117, 128, 139', group = G1, inline = '5'), c5 = input.color(color.aqua, '', group = G1, inline = '5')
cardinal_6 = input(false, '151, 164, 177, 190', group = G1, inline = '6'), c6 = input.color(color.blue, '', group = G1, inline = '6')
cardinal_7 = input(false, '204, 219, 234, 249', group = G1, inline = '7'), c7 = input.color(color.purple, '', group = G1, inline = '7')
cardinal_8 = input(false, '265, 282, 299, 316', group = G1, inline = '8'), c8 = input.color(color.fuchsia, '', group = G1, inline = '8')
cardinal_9 = input(false, '334, 353, 372, 391', group = G1, inline = '9'), c9 = input.color(#FFC0CB, '', group = G1, inline = '9')
arr_bool_cardinal = array.new_bool(10)
array.set(arr_bool_cardinal, 0, cardinal_0)
array.set(arr_bool_cardinal, 1, cardinal_1)
array.set(arr_bool_cardinal, 2, cardinal_2)
array.set(arr_bool_cardinal, 3, cardinal_3)
array.set(arr_bool_cardinal, 4, cardinal_4)
array.set(arr_bool_cardinal, 5, cardinal_5)
array.set(arr_bool_cardinal, 6, cardinal_6)
array.set(arr_bool_cardinal, 7, cardinal_7)
array.set(arr_bool_cardinal, 8, cardinal_8)
array.set(arr_bool_cardinal, 9, cardinal_9)
// input cardinal 45 135 125 135 color
// c r c r c r c r
fun_set(cardinal_0, 9, 9, 11, 9, 11, 11, 9, 11, c0)
fun_set(cardinal_1, 8, 8, 12, 8, 12, 12, 8, 12, c1)
fun_set(cardinal_2, 7, 7, 13, 7, 13, 13, 7, 13, c2)
fun_set(cardinal_3, 6, 6, 14, 6, 14, 14, 6, 14, c3)
fun_set(cardinal_4, 5, 5, 15, 5, 15, 15, 5, 15, c4)
fun_set(cardinal_5, 4, 4, 16, 4, 16, 16, 4, 16, c5)
fun_set(cardinal_6, 3, 3, 17, 3, 17, 17, 3, 17, c6)
fun_set(cardinal_7, 2, 2, 18, 2, 18, 18, 2, 18, c7)
fun_set(cardinal_8, 1, 1, 19, 1, 19, 19, 1, 19, c8)
fun_set(cardinal_9, 0, 0, 20, 0, 20, 20, 0, 20, c9)
// } |
Gann Square 4 Cross Cardinal Table Concept | https://www.tradingview.com/script/WMeyD4Sy-Gann-Square-4-Cross-Cardinal-Table-Concept/ | RozaniGhani-RG | https://www.tradingview.com/u/RozaniGhani-RG/ | 25 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RozaniGhani-RG
// Inspired by The Tunnel Thru The Air Or Looking Back From 1940, written by WD Gann
// Page 195 - 198
//@version=4
study("Gann Square 4 Cross Cardinal Table Concept", shorttitle = "GS4CCTC_SC")
// 0. Arrays
// 1. Variables
// 2. Custom functions
// 3. if statament
// 4. Inputs
// 0. Arrays
// 0 1 2 3 4 5 6 7 8 9
arr_cardinal_45 = array.from(1, 6, 19, 40, 69, 106, 151, 204, 265, 334)
arr_cardinal_135 = array.from(2, 9, 24, 47, 78, 117, 164, 219, 282, 353)
arr_cardinal_225 = array.from(3, 12, 29, 54, 87, 128, 177, 234, 299, 372)
arr_cardinal_315 = array.from(4, 15, 34, 61, 96, 139, 190, 249, 316, 391)
// sort array
array.sort(arr_cardinal_45, order.descending)
// 1. Variables
G1 = "Cross Cardinal"
var testTable = table.new(position = position.middle_center, columns = 21, rows = 21, bgcolor = color.black, border_width = 1)
input_font = input("Small", "Font Size",options = ["Tiny", "Small", "Normal", "Large", "Huge"])
font = input_font == "Tiny" ? size.tiny :
input_font == "Small" ? size.small :
input_font == "Large" ? size.large :
input_font == "Huge" ? size.huge :
size.normal
// 2. Custom functions
cell_default(_column, _row, _id, _index)=>
table.cell(testTable, _column, _row, tostring(array.get(_id, _index)), bgcolor = color.gray, text_color = color.black, text_size = font)
fun_set(_input, _column, _row, _color) =>
if _input
table.cell_set_bgcolor(testTable, _column, _row, _color)
// 3. if statament
if barstate.islast
for _id = 0 to 9
cell_default( _id, _id, arr_cardinal_45, _id)
cell_default(11 + _id, 9 - _id, arr_cardinal_135, _id)
cell_default(11 + _id, 11 + _id, arr_cardinal_225, _id)
cell_default(9 - _id, 11 + _id, arr_cardinal_315, _id)
// 4. Inputs
c0 = input(color.red, "", group = G1, inline = "0")
c1 = input(color.orange, "", group = G1, inline = "1")
c2 = input(color.yellow, "", group = G1, inline = "2")
c3 = input(color.green, "", group = G1, inline = "3")
c4 = input(color.teal, "", group = G1, inline = "4")
c5 = input(color.aqua, "", group = G1, inline = "5")
c6 = input(color.blue, "", group = G1, inline = "6")
c7 = input(color.purple, "", group = G1, inline = "7")
c8 = input(color.fuchsia, "", group = G1, inline = "8")
c9 = input(#FFC0CB, "", group = G1, inline = "9")
// arr_cardinal_45
cardinal_45_0 = input(false, "1 ", group = G1, inline = "0"), fun_set(cardinal_45_0, 9, 9, c0)
cardinal_45_1 = input(false, "6 ", group = G1, inline = "1"), fun_set(cardinal_45_1, 8, 8, c1)
cardinal_45_2 = input(false, "19 ", group = G1, inline = "2"), fun_set(cardinal_45_2, 7, 7, c2)
cardinal_45_3 = input(false, "40 ", group = G1, inline = "3"), fun_set(cardinal_45_3, 6, 6, c3)
cardinal_45_4 = input(false, "69 ", group = G1, inline = "4"), fun_set(cardinal_45_4, 5, 5, c4)
cardinal_45_5 = input(false, "106", group = G1, inline = "5"), fun_set(cardinal_45_5, 4, 4, c5)
cardinal_45_6 = input(false, "151", group = G1, inline = "6"), fun_set(cardinal_45_6, 3, 3, c6)
cardinal_45_7 = input(false, "204", group = G1, inline = "7"), fun_set(cardinal_45_7, 2, 2, c7)
cardinal_45_8 = input(false, "265", group = G1, inline = "8"), fun_set(cardinal_45_8, 1, 1, c8)
cardinal_45_9 = input(false, "334", group = G1, inline = "9"), fun_set(cardinal_45_9, 0, 0, c9)
// arr_cardinal_135
cardinal_135_0 = input(false, "2 ", group = G1, inline = "0"), fun_set(cardinal_135_0, 11, 9, c0)
cardinal_135_1 = input(false, "9 ", group = G1, inline = "1"), fun_set(cardinal_135_1, 12, 8, c1)
cardinal_135_2 = input(false, "24 ", group = G1, inline = "2"), fun_set(cardinal_135_2, 13, 7, c2)
cardinal_135_3 = input(false, "47 ", group = G1, inline = "3"), fun_set(cardinal_135_3, 14, 6, c3)
cardinal_135_4 = input(false, "78 ", group = G1, inline = "4"), fun_set(cardinal_135_4, 15, 5, c4)
cardinal_135_5 = input(false, "117", group = G1, inline = "5"), fun_set(cardinal_135_5, 16, 4, c5)
cardinal_135_6 = input(false, "164", group = G1, inline = "6"), fun_set(cardinal_135_6, 17, 3, c6)
cardinal_135_7 = input(false, "219", group = G1, inline = "7"), fun_set(cardinal_135_7, 18, 2, c7)
cardinal_135_8 = input(false, "282", group = G1, inline = "8"), fun_set(cardinal_135_8, 19, 1, c8)
cardinal_135_9 = input(false, "353", group = G1, inline = "9"), fun_set(cardinal_135_9, 20, 0, c9)
// arr_cardinal_225
cardinal_225_0 = input(false, "3 ", group = G1, inline = "0"), fun_set(cardinal_225_0, 11, 11, c0)
cardinal_225_1 = input(false, "12 ", group = G1, inline = "1"), fun_set(cardinal_225_1, 12, 12, c1)
cardinal_225_2 = input(false, "29 ", group = G1, inline = "2"), fun_set(cardinal_225_2, 13, 13, c2)
cardinal_225_3 = input(false, "54 ", group = G1, inline = "3"), fun_set(cardinal_225_3, 14, 14, c3)
cardinal_225_4 = input(false, "87 ", group = G1, inline = "4"), fun_set(cardinal_225_4, 15, 15, c4)
cardinal_225_5 = input(false, "128", group = G1, inline = "5"), fun_set(cardinal_225_5, 16, 16, c5)
cardinal_225_6 = input(false, "177", group = G1, inline = "6"), fun_set(cardinal_225_6, 17, 17, c6)
cardinal_225_7 = input(false, "234", group = G1, inline = "7"), fun_set(cardinal_225_7, 18, 18, c7)
cardinal_225_8 = input(false, "299", group = G1, inline = "8"), fun_set(cardinal_225_8, 19, 19, c8)
cardinal_225_9 = input(false, "372", group = G1, inline = "9"), fun_set(cardinal_225_9, 20, 20, c9)
// arr_cardinal_315
cardinal_315_0 = input(false, "4 ", group = G1, inline = "0"), fun_set(cardinal_315_0, 9, 11, c0)
cardinal_315_1 = input(false, "15 ", group = G1, inline = "1"), fun_set(cardinal_315_1, 8, 12, c1)
cardinal_315_2 = input(false, "34 ", group = G1, inline = "2"), fun_set(cardinal_315_2, 7, 13, c2)
cardinal_315_3 = input(false, "61 ", group = G1, inline = "3"), fun_set(cardinal_315_3, 6, 14, c3)
cardinal_315_4 = input(false, "96 ", group = G1, inline = "4"), fun_set(cardinal_315_4, 5, 15, c4)
cardinal_315_5 = input(false, "139", group = G1, inline = "5"), fun_set(cardinal_315_5, 4, 16, c5)
cardinal_315_6 = input(false, "190", group = G1, inline = "6"), fun_set(cardinal_315_6, 3, 17, c6)
cardinal_315_7 = input(false, "249", group = G1, inline = "7"), fun_set(cardinal_315_7, 2, 18, c7)
cardinal_315_8 = input(false, "316", group = G1, inline = "8"), fun_set(cardinal_315_8, 1, 19, c8)
cardinal_315_9 = input(false, "391", group = G1, inline = "9"), fun_set(cardinal_315_9, 0, 20, c9) |
Gann Square 9 Cross Cardinal Table Concept | https://www.tradingview.com/script/mEzLbIKm-Gann-Square-9-Cross-Cardinal-Table-Concept/ | RozaniGhani-RG | https://www.tradingview.com/u/RozaniGhani-RG/ | 62 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RozaniGhani-RG
// Inspired by The Tunnel Thru The Air Or Looking Back From 1940, written by WD Gann
//@version=4
study("Gann Square 9 Cross Cardinal Table Concept", shorttitle = "GS9CCTC_SC")
// 0. Arrays
// 1. Variables
// 2. Custom functions
// 3. if statament
// 4. Inputs
// 0. Arrays
// 0 1 2 3 4 5 6 7 8
arr_cross_0 = array.from(2, 11, 28, 53, 86, 127, 176, 233, 298)
arr_cross_90 = array.from(4, 15, 34, 61, 96, 139, 190, 249, 316)
arr_cross_180 = array.from(6, 19, 40, 69, 106, 151, 204, 265, 334)
arr_cross_270 = array.from(8, 23, 46, 77, 116, 163, 218, 281, 352)
arr_cardinal_45 = array.from(3, 13, 31, 57, 91, 133, 183, 241, 307)
arr_cardinal_135 = array.from(5, 17, 37, 65, 101, 145, 197, 257, 325)
arr_cardinal_225 = array.from(7, 21, 43, 73, 111, 157, 211, 273, 343)
arr_cardinal_315 = array.from(9, 25, 49, 81, 121, 169, 225, 289, 361)
// sort array
array.sort(arr_cross_0, order.descending)
array.sort(arr_cardinal_45, order.descending)
array.sort(arr_cross_90, order.descending)
// 1. Variables
G0 = "Cross", G1 = "Cross Cardinal"
var testTable = table.new(position = position.middle_center, columns = 21, rows = 21, bgcolor = color.black, border_width = 1)
input_font = input("Normal", "Font Size", options = ["Tiny", "Small", "Normal", "Large", "Huge"])
font = input_font == "Tiny" ? size.tiny :
input_font == "Small" ? size.small :
input_font == "Large" ? size.large :
input_font == "Huge" ? size.huge :
size.normal
// 2. Custom functions
cell_default(_column, _row, _id, _index)=>
table.cell(testTable, _column, _row, tostring(array.get(_id, _index)), bgcolor = color.gray, text_color = color.black, text_size = font)
fun_set(_input, _column, _row, _color) =>
if _input
table.cell_set_bgcolor(testTable, _column, _row, _color)
// 3. if statament
if barstate.islast
for _id = 0 to 8
cell_default( _id, 9, arr_cross_0, _id)
cell_default( _id, _id, arr_cardinal_45, _id)
cell_default( 10, _id, arr_cross_90, _id)
cell_default(11 + _id, 8 - _id, arr_cardinal_135, _id)
cell_default(11 + _id, 9, arr_cross_180, _id)
cell_default(11 + _id, 11 + _id, arr_cardinal_225, _id)
cell_default( 10, 11 + _id, arr_cross_270, _id)
cell_default(8 - _id, 11 + _id, arr_cardinal_315, _id)
// 4. Inputs
c0 = input(color.red, "", group = G0, inline = "0")
c1 = input(color.orange, "", group = G0, inline = "1")
c2 = input(color.yellow, "", group = G0, inline = "2")
c3 = input(color.green, "", group = G0, inline = "3")
c4 = input(color.teal, "", group = G0, inline = "4")
c5 = input(color.aqua, "", group = G0, inline = "5")
c6 = input(color.blue, "", group = G0, inline = "6")
c7 = input(color.purple, "", group = G0, inline = "7")
c8 = input(color.fuchsia, "", group = G0, inline = "8")
c9 = input(color.red, "", group = G1, inline = "9")
c10 = input(color.orange, "", group = G1, inline = "10")
c11 = input(color.yellow, "", group = G1, inline = "11")
c12 = input(color.green, "", group = G1, inline = "12")
c13 = input(color.teal, "", group = G1, inline = "13")
c14 = input(color.aqua, "", group = G1, inline = "14")
c15 = input(color.blue, "", group = G1, inline = "15")
c16 = input(color.purple, "", group = G1, inline = "16")
c17 = input(color.fuchsia, "", group = G1, inline = "17")
// arr_cross_0
cross_0_0 = input(false, "2 ", group = G0, inline = "0"), fun_set(cross_0_0, 8, 9, c0)
cross_0_1 = input(false, "11 ", group = G0, inline = "1"), fun_set(cross_0_1, 7, 9, c1)
cross_0_2 = input(false, "28 ", group = G0, inline = "2"), fun_set(cross_0_2, 6, 9, c2)
cross_0_3 = input(false, "53 ", group = G0, inline = "3"), fun_set(cross_0_3, 5, 9, c3)
cross_0_4 = input(false, "86 ", group = G0, inline = "4"), fun_set(cross_0_4, 4, 9, c4)
cross_0_5 = input(false, "127", group = G0, inline = "5"), fun_set(cross_0_5, 3, 9, c5)
cross_0_6 = input(false, "176", group = G0, inline = "6"), fun_set(cross_0_6, 2, 9, c6)
cross_0_7 = input(false, "233", group = G0, inline = "7"), fun_set(cross_0_7, 1, 9, c7)
cross_0_8 = input(false, "298", group = G0, inline = "8"), fun_set(cross_0_8, 0, 9, c8)
// arr_cross_90
cross_90_0 = input(false, "4 ", group = G0, inline = "0"), fun_set(cross_90_0, 10, 8, c0)
cross_90_1 = input(false, "15 ", group = G0, inline = "1"), fun_set(cross_90_1, 10, 7, c1)
cross_90_2 = input(false, "34 ", group = G0, inline = "2"), fun_set(cross_90_2, 10, 6, c2)
cross_90_3 = input(false, "61 ", group = G0, inline = "3"), fun_set(cross_90_3, 10, 5, c3)
cross_90_4 = input(false, "96 ", group = G0, inline = "4"), fun_set(cross_90_4, 10, 4, c4)
cross_90_5 = input(false, "139", group = G0, inline = "5"), fun_set(cross_90_5, 10, 3, c5)
cross_90_6 = input(false, "190", group = G0, inline = "6"), fun_set(cross_90_6, 10, 2, c6)
cross_90_7 = input(false, "249", group = G0, inline = "7"), fun_set(cross_90_7, 10, 1, c7)
cross_90_8 = input(false, "316", group = G0, inline = "8"), fun_set(cross_90_8, 10, 0, c8)
// arr_cross_180
cross_180_0 = input(false, "6 ", group = G0, inline = "0"), fun_set(cross_180_0, 11, 9, c0)
cross_180_1 = input(false, "19 ", group = G0, inline = "1"), fun_set(cross_180_1, 12, 9, c1)
cross_180_2 = input(false, "40 ", group = G0, inline = "2"), fun_set(cross_180_2, 13, 9, c2)
cross_180_3 = input(false, "69 ", group = G0, inline = "3"), fun_set(cross_180_3, 14, 9, c3)
cross_180_4 = input(false, "106", group = G0, inline = "4"), fun_set(cross_180_4, 15, 9, c4)
cross_180_5 = input(false, "151", group = G0, inline = "5"), fun_set(cross_180_5, 16, 9, c5)
cross_180_6 = input(false, "204", group = G0, inline = "6"), fun_set(cross_180_6, 17, 9, c6)
cross_180_7 = input(false, "265", group = G0, inline = "7"), fun_set(cross_180_7, 18, 9, c7)
cross_180_8 = input(false, "334", group = G0, inline = "8"), fun_set(cross_180_8, 19, 9, c8)
// arr_cross_270
cross_270_0 = input(false, "8 ", group = G0, inline = "0"), fun_set(cross_270_0, 10, 11, c0)
cross_270_1 = input(false, "23 ", group = G0, inline = "1"), fun_set(cross_270_1, 10, 12, c1)
cross_270_2 = input(false, "46 ", group = G0, inline = "2"), fun_set(cross_270_2, 10, 13, c2)
cross_270_3 = input(false, "77 ", group = G0, inline = "3"), fun_set(cross_270_3, 10, 14, c3)
cross_270_4 = input(false, "116", group = G0, inline = "4"), fun_set(cross_270_4, 10, 15, c4)
cross_270_5 = input(false, "163", group = G0, inline = "5"), fun_set(cross_270_5, 10, 16, c5)
cross_270_6 = input(false, "218", group = G0, inline = "6"), fun_set(cross_270_6, 10, 17, c6)
cross_270_7 = input(false, "281", group = G0, inline = "7"), fun_set(cross_270_7, 10, 18, c7)
cross_270_8 = input(false, "352", group = G0, inline = "8"), fun_set(cross_270_8, 10, 19, c8)
// arr_cardinal_45
cardinal_45_0 = input(false, "3 ", group = G1, inline = "9"), fun_set(cardinal_45_0, 8, 8, c9)
cardinal_45_1 = input(false, "13 ", group = G1, inline = "10"), fun_set(cardinal_45_1, 7, 7, c10)
cardinal_45_2 = input(false, "31 ", group = G1, inline = "11"), fun_set(cardinal_45_2, 6, 6, c11)
cardinal_45_3 = input(false, "57 ", group = G1, inline = "12"), fun_set(cardinal_45_3, 5, 5, c12)
cardinal_45_4 = input(false, "91 ", group = G1, inline = "13"), fun_set(cardinal_45_4, 4, 4, c13)
cardinal_45_5 = input(false, "133", group = G1, inline = "14"), fun_set(cardinal_45_5, 3, 3, c14)
cardinal_45_6 = input(false, "183", group = G1, inline = "15"), fun_set(cardinal_45_6, 2, 2, c15)
cardinal_45_7 = input(false, "241", group = G1, inline = "16"), fun_set(cardinal_45_7, 1, 1, c16)
cardinal_45_8 = input(false, "307", group = G1, inline = "17"), fun_set(cardinal_45_8, 0, 0, c17)
// arr_cardinal_135
cardinal_135_0 = input(false, "5 ", group = G1, inline = "9"), fun_set(cardinal_135_0, 11, 8, c9)
cardinal_135_1 = input(false, "17 ", group = G1, inline = "10"), fun_set(cardinal_135_1, 12, 7, c10)
cardinal_135_2 = input(false, "37 ", group = G1, inline = "11"), fun_set(cardinal_135_2, 13, 6, c11)
cardinal_135_3 = input(false, "65 ", group = G1, inline = "12"), fun_set(cardinal_135_3, 14, 5, c12)
cardinal_135_4 = input(false, "101", group = G1, inline = "13"), fun_set(cardinal_135_4, 15, 4, c13)
cardinal_135_5 = input(false, "145", group = G1, inline = "14"), fun_set(cardinal_135_5, 16, 3, c14)
cardinal_135_6 = input(false, "197", group = G1, inline = "15"), fun_set(cardinal_135_6, 17, 2, c15)
cardinal_135_7 = input(false, "257", group = G1, inline = "16"), fun_set(cardinal_135_7, 18, 1, c16)
cardinal_135_8 = input(false, "325", group = G1, inline = "17"), fun_set(cardinal_135_8, 19, 0, c17)
// arr_cardinal_225
cardinal_225_0 = input(false, "7 ", group = G1, inline = "9"), fun_set(cardinal_225_0, 11, 11, c9)
cardinal_225_1 = input(false, "21 ", group = G1, inline = "10"), fun_set(cardinal_225_1, 12, 12, c10)
cardinal_225_2 = input(false, "43 ", group = G1, inline = "11"), fun_set(cardinal_225_2, 13, 13, c11)
cardinal_225_3 = input(false, "73 ", group = G1, inline = "12"), fun_set(cardinal_225_3, 14, 14, c12)
cardinal_225_4 = input(false, "111", group = G1, inline = "13"), fun_set(cardinal_225_4, 15, 15, c13)
cardinal_225_5 = input(false, "157", group = G1, inline = "14"), fun_set(cardinal_225_5, 16, 16, c14)
cardinal_225_6 = input(false, "211", group = G1, inline = "15"), fun_set(cardinal_225_6, 17, 17, c15)
cardinal_225_7 = input(false, "273", group = G1, inline = "16"), fun_set(cardinal_225_7, 18, 18, c16)
cardinal_225_8 = input(false, "343", group = G1, inline = "17"), fun_set(cardinal_225_8, 19, 19, c17)
// arr_cardinal_315
cardinal_315_0 = input(false, "9 ", group = G1, inline = "9"), fun_set(cardinal_315_0, 8, 11, c9)
cardinal_315_1 = input(false, "25 ", group = G1, inline = "10"), fun_set(cardinal_315_1, 7, 12, c10)
cardinal_315_2 = input(false, "49 ", group = G1, inline = "11"), fun_set(cardinal_315_2, 6, 13, c11)
cardinal_315_3 = input(false, "81 ", group = G1, inline = "12"), fun_set(cardinal_315_3, 5, 14, c12)
cardinal_315_4 = input(false, "121", group = G1, inline = "13"), fun_set(cardinal_315_4, 4, 15, c13)
cardinal_315_5 = input(false, "169", group = G1, inline = "14"), fun_set(cardinal_315_5, 3, 16, c14)
cardinal_315_6 = input(false, "225", group = G1, inline = "15"), fun_set(cardinal_315_6, 2, 17, c15)
cardinal_315_7 = input(false, "289", group = G1, inline = "16"), fun_set(cardinal_315_7, 1, 18, c16)
cardinal_315_8 = input(false, "361", group = G1, inline = "17"), fun_set(cardinal_315_8, 0, 19, c17) |
Gann Square 9 Table Concept Alternate UI | https://www.tradingview.com/script/n0CPKM4g-Gann-Square-9-Table-Concept-Alternate-UI/ | RozaniGhani-RG | https://www.tradingview.com/u/RozaniGhani-RG/ | 141 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RozaniGhani-RG
// Inspired by The Tunnel Thru The Air Or Looking Back From 1940, written by WD Gann
//
// Related build
// https://www.tradingview.com/script/WMeyD4Sy-Gann-Square-4-Cross-Cardinal-Table-Concept/
// https://www.tradingview.com/script/mEzLbIKm-Gann-Square-9-Cross-Cardinal-Table-Concept/
// https://www.tradingview.com/script/yH604xPv-Gann-Square-4-Table-Concept-Alternate-UI/
//@version=4
study("Gann Square 9 Table Concept Alternate UI", shorttitle = "GS9TCAU_SC")
// 0. Arrays
// 1. Variables
// 2. Custom functions
// 3. if statament
// 4. Inputs
// 0. Arrays
// 0 1 2 3 4 5 6 7 8
arr_cross_0 = array.from(2, 11, 28, 53, 86, 127, 176, 233, 298)
arr_cross_90 = array.from(4, 15, 34, 61, 96, 139, 190, 249, 316)
arr_cross_180 = array.from(6, 19, 40, 69, 106, 151, 204, 265, 334)
arr_cross_270 = array.from(8, 23, 46, 77, 116, 163, 218, 281, 352)
arr_cardinal_45 = array.from(3, 13, 31, 57, 91, 133, 183, 241, 307)
arr_cardinal_135 = array.from(5, 17, 37, 65, 101, 145, 197, 257, 325)
arr_cardinal_225 = array.from(7, 21, 43, 73, 111, 157, 211, 273, 343)
arr_cardinal_315 = array.from(9, 25, 49, 81, 121, 169, 225, 289, 361)
// sort array
array.sort(arr_cross_0, order.descending)
array.sort(arr_cardinal_45, order.descending)
array.sort(arr_cross_90, order.descending)
// 1. Variables
G0 = "Cross", G1 = "Cross Cardinal"
var testTable = table.new(position = position.middle_center, columns = 21, rows = 21, bgcolor = color.black, border_width = 1)
input_font = input("Small", "Font Size", options = ["Tiny", "Small", "Normal", "Large", "Huge"])
font = input_font == "Tiny" ? size.tiny :
input_font == "Small" ? size.small :
input_font == "Large" ? size.large :
input_font == "Huge" ? size.huge :
size.normal
// 2. Custom functions
cell_default(_column, _row, _id, _index)=>
table.cell(testTable, _column, _row, tostring(array.get(_id, _index)), bgcolor = color.gray, text_color = color.black, text_size = font)
fun_set(_input, _column0, _row0, _column1, _row1, _column2, _row2, _column3, _row3, _color) =>
if _input
table.cell_set_bgcolor(testTable, _column0, _row0, _color)
table.cell_set_bgcolor(testTable, _column1, _row1, _color)
table.cell_set_bgcolor(testTable, _column2, _row2, _color)
table.cell_set_bgcolor(testTable, _column3, _row3, _color)
// 3. if statament
if barstate.islast
for _id = 0 to 8
cell_default( _id, 9, arr_cross_0, _id)
cell_default( _id, _id, arr_cardinal_45, _id)
cell_default( 10, _id, arr_cross_90, _id)
cell_default(11 + _id, 8 - _id, arr_cardinal_135, _id)
cell_default(11 + _id, 9, arr_cross_180, _id)
cell_default(11 + _id, 11 + _id, arr_cardinal_225, _id)
cell_default( 10, 11 + _id, arr_cross_270, _id)
cell_default(8 - _id, 11 + _id, arr_cardinal_315, _id)
// 4. Inputs
c0 = input(color.red, "", group = G0, inline = "0")
c1 = input(color.orange, "", group = G0, inline = "1")
c2 = input(color.yellow, "", group = G0, inline = "2")
c3 = input(color.green, "", group = G0, inline = "3")
c4 = input(color.teal, "", group = G0, inline = "4")
c5 = input(color.aqua, "", group = G0, inline = "5")
c6 = input(color.blue, "", group = G0, inline = "6")
c7 = input(color.purple, "", group = G0, inline = "7")
c8 = input(color.fuchsia, "", group = G0, inline = "8")
c9 = input(color.red, "", group = G1, inline = "9")
c10 = input(color.orange, "", group = G1, inline = "10")
c11 = input(color.yellow, "", group = G1, inline = "11")
c12 = input(color.green, "", group = G1, inline = "12")
c13 = input(color.teal, "", group = G1, inline = "13")
c14 = input(color.aqua, "", group = G1, inline = "14")
c15 = input(color.blue, "", group = G1, inline = "15")
c16 = input(color.purple, "", group = G1, inline = "16")
c17 = input(color.fuchsia, "", group = G1, inline = "17")
// input cross 0 90 180 270 color
// c r c r c r c r
cross_0 = input(false, " 2, 4, 6, 8", group = G0, inline = "0"), fun_set(cross_0, 8, 9, 10, 8, 11, 9, 10, 11, c0)
cross_1 = input(false, " 11, 15, 19, 23", group = G0, inline = "1"), fun_set(cross_1, 7, 9, 10, 7, 12, 9, 10, 12, c1)
cross_2 = input(false, " 28, 34, 40, 46", group = G0, inline = "2"), fun_set(cross_2, 6, 9, 10, 6, 13, 9, 10, 13, c2)
cross_3 = input(false, " 53, 61, 69, 77", group = G0, inline = "3"), fun_set(cross_3, 5, 9, 10, 5, 14, 9, 10, 14, c3)
cross_4 = input(false, " 86, 96, 106, 116", group = G0, inline = "4"), fun_set(cross_4, 4, 9, 10, 4, 15, 9, 10, 15, c4)
cross_5 = input(false, "127, 139, 151, 163", group = G0, inline = "5"), fun_set(cross_5, 3, 9, 10, 3, 16, 9, 10, 16, c5)
cross_6 = input(false, "176, 190, 204, 218", group = G0, inline = "6"), fun_set(cross_6, 2, 9, 10, 2, 17, 9, 10, 17, c6)
cross_7 = input(false, "233, 249, 265, 281", group = G0, inline = "7"), fun_set(cross_7, 1, 9, 10, 1, 18, 9, 10, 18, c7)
cross_8 = input(false, "298, 316, 334, 352", group = G0, inline = "8"), fun_set(cross_8, 0, 9, 10, 0, 19, 9, 10, 19, c8)
// input cardinal 45 135 225 315 color
// c r c r c r c r
cardinal_0 = input(false, "3 , 5 , 7 , 9 ", group = G1, inline = "9"), fun_set(cardinal_0, 8, 8, 11, 8, 11, 11, 8, 11, c9)
cardinal_1 = input(false, "13 , 17 , 21 , 25 ", group = G1, inline = "10"), fun_set(cardinal_1, 7, 7, 12, 7, 12, 12, 7, 12, c10)
cardinal_2 = input(false, "31 , 37 , 43 , 49 ", group = G1, inline = "11"), fun_set(cardinal_2, 6, 6, 13, 6, 13, 13, 6, 13, c11)
cardinal_3 = input(false, "57 , 65 , 73 , 81 ", group = G1, inline = "12"), fun_set(cardinal_3, 5, 5, 14, 5, 14, 14, 5, 14, c12)
cardinal_4 = input(false, "91 , 101, 111, 121", group = G1, inline = "13"), fun_set(cardinal_4, 4, 4, 15, 4, 15, 15, 4, 15, c13)
cardinal_5 = input(false, "133, 145, 157, 169", group = G1, inline = "14"), fun_set(cardinal_5, 3, 3, 16, 3, 16, 16, 3, 16, c14)
cardinal_6 = input(false, "183, 197, 211, 225", group = G1, inline = "15"), fun_set(cardinal_6, 2, 2, 17, 2, 17, 17, 2, 17, c15)
cardinal_7 = input(false, "241, 257, 273, 289", group = G1, inline = "16"), fun_set(cardinal_7, 1, 1, 18, 1, 18, 18, 1, 18, c16)
cardinal_8 = input(false, "307, 325, 343, 361", group = G1, inline = "17"), fun_set(cardinal_8, 0, 0, 19, 0, 19, 19, 0, 19, c17)
|
Range Breakout | https://www.tradingview.com/script/rtoqSbG7-Range-Breakout/ | arunbabumvk_23 | https://www.tradingview.com/u/arunbabumvk_23/ | 287 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © arunbabumvk_23
//@version=4
study(title="Range Breakout", overlay = true)
range_length = input(5, minval=3, title="Range Length")
rangeHighest = highest(high, range_length)
rangeBreakout = iff(close > rangeHighest[1], 1, 0)
rangeSmallest = lowest(low, range_length)
rangeBreakdown = iff(close < rangeSmallest[1], 1, 0)
plotshape(rangeBreakout, style=shape.labelup, location = location.belowbar, color=color.rgb(87,146,100))
plotshape(rangeBreakdown, style=shape.labeldown, location = location.abovebar, color=color.rgb(193,74,80)) |
Customizable Gap Finder | https://www.tradingview.com/script/MsW7e2Sw-Customizable-Gap-Finder/ | ProfessorZoom | https://www.tradingview.com/u/ProfessorZoom/ | 487 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ProfessorZoom
//@version=4
study("Customizable Gap Finder", overlay=true, max_bars_back=4000)
// Inputs
var barsBack = input(title="Bars to Check For", type=input.integer, defval=4000, group="Main Settings", minval=50, maxval=4000, step=1)
var extendUnFilled = input(title="Extend Unfilled Gap Boxes", type=input.bool, defval=true, group="Main Settings")
var showFilledBoxes = input(title="Show Filled Gap Boxes", type=input.bool, defval=true, group="Main Settings")
var gapFilledLabelColor = input(title="Gap Filled Label Color", type=input.color, defval=color.white, group="Main Settings")
var hideAllFilledStuff = input(title="Hide All Filled Gap Stuff", type=input.bool, defval=true, group="Main Settings")
var showLabels = input(title="Show Gap Notification Labels", type=input.bool, defval=false, group="Main Settings")
var gapUpLabelColor = input(title="Gap Up Label Color", type=input.color, defval=color.white, group="Gap Up")
var gapUpBackgroundColor = input(title="Gap Up Border Color", type=input.color, defval=color.rgb(255,255,255,75), group="Gap Up")
var gapUpBorderColor = input(title="Gap Up Background Color", type=input.color, defval=color.white, group="Gap Up")
var gapDownLabelColor = input(title="Gap Down Label Color", type=input.color, defval=color.white, group="Gap Down")
var gapDownBackgroundColor = input(title="Gap Down Border Color", type=input.color, defval=color.rgb(255,255,255,75), group="Gap Down")
var gapDownBorderColor = input(title="Gap Down Background Color", type=input.color, defval=color.white, group="Gap Down")
// Really wish we could write classes
// Gap Ups
var gapUpBarsAgo = array.new_int()
var gapUpRight = array.new_int()
var gapUpLeft = array.new_int()
var gapUpHighs = array.new_float()
var gapUpLows = array.new_float()
var gapUpClosed = array.new_int()
// Gap Downs
var gapDownBarsAgo = array.new_int()
var gapDownRight = array.new_int()
var gapDownLeft = array.new_int()
var gapDownHighs = array.new_float()
var gapDownLows = array.new_float()
var gapDownClosed = array.new_int()
// We take the current bar and look back
// what we do here is to go back back back back
if barstate.islast
// Check for gaps
for i = 0 to barsBack
// Gap Ups
if low[i] > high[i+1]
if showLabels
label.new(bar_index[i], high[i], "Gap Up", color=gapUpLabelColor)
array.push(gapUpBarsAgo, i)
array.push(gapUpRight, bar_index[i])
array.push(gapUpLeft, bar_index[i+1])
array.push(gapUpHighs, low[i])
array.push(gapUpLows, high[i+1])
// Gap Downs
if high[i] < low[i+1]
if showLabels
label.new(bar_index[i], high[i], "Gap Down", color=gapUpLabelColor)
array.push(gapDownBarsAgo, i)
array.push(gapDownRight, bar_index[i])
array.push(gapDownLeft, bar_index[i+1])
array.push(gapDownHighs, low[i+1])
array.push(gapDownLows, high[i])
// [GAP UP] Check if any gaps are filled
if (array.size(gapUpBarsAgo) > 0)
for i = 0 to array.size(gapUpRight) - 1
for j = array.get(gapUpBarsAgo, i) to 0
if low[j] <= array.get(gapUpLows, i)
if showFilledBoxes and hideAllFilledStuff == false
box.new(left=array.get(gapUpLeft, i), top=array.get(gapUpHighs, i), right=bar_index[j], bottom=array.get(gapUpLows, i), border_width=1, border_style=line.style_solid, bgcolor=gapUpBackgroundColor, border_color=gapUpBorderColor)
if hideAllFilledStuff == false and showLabels
label.new(bar_index[j], low[j], "Gap Filled", color=gapFilledLabelColor, style=label.style_label_up)
array.push(gapUpClosed, array.get(gapUpRight, i))
break
// [GAP UP] Draw unfilled gap boxes
for i = 0 to array.size(gapUpRight) - 1
if array.includes(gapUpClosed, array.get(gapUpRight, i)) == false
box.new(left=array.get(gapUpLeft, i), top=array.get(gapUpHighs, i), right=bar_index, bottom=array.get(gapUpLows, i), border_width=1, border_style=line.style_solid, bgcolor=gapUpBackgroundColor, border_color=gapUpBorderColor, extend=extendUnFilled ? extend.right : extend.none)
// [GAP DOWN] Check if any gaps are filled
if (array.size(gapDownBarsAgo) > 0)
for i = 0 to array.size(gapDownRight) - 1
for j = array.get(gapDownBarsAgo, i) to 0
if high[j] >= array.get(gapDownHighs, i)
if showFilledBoxes and hideAllFilledStuff == false
box.new(left=array.get(gapDownLeft, i), top=array.get(gapDownHighs, i), right=bar_index[j], bottom=array.get(gapDownLows, i), border_width=1, border_style=line.style_solid, bgcolor=gapDownBackgroundColor, border_color=gapDownBorderColor)
if hideAllFilledStuff == false and showLabels
label.new(bar_index[j], high[j], "Gap Filled", color=gapFilledLabelColor, style=label.style_label_down)
array.push(gapDownClosed, array.get(gapDownRight, i))
break
// [GAP DOWN] Draw unfilled gap boxes
for i = 0 to array.size(gapDownRight) - 1
if array.includes(gapDownClosed, array.get(gapDownRight, i)) == false
box.new(left=array.get(gapDownLeft, i), top=array.get(gapDownHighs, i), right=bar_index, bottom=array.get(gapDownLows, i), border_width=1, border_style=line.style_solid, bgcolor=gapDownBackgroundColor, border_color=gapDownBorderColor, extend=extendUnFilled ? extend.right : extend.none) |
indreajit mukherjee strategy | https://www.tradingview.com/script/KIhsE4eO-indreajit-mukherjee-strategy/ | Shauryam_or | https://www.tradingview.com/u/Shauryam_or/ | 316 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// coder of cm_ultimate_mtf @ChirshMoody
// coder of macd4c is @vkno422
// © Shauryam_or
//@version=4
study(title="indreajit mukherjee strategy", shorttitle="IM strategy", overlay=true)
//inputs
src = close
useCurrentRes = input(true, title="Use Current Chart Resolution?")
resCustom = input(title="Use Different Timeframe? Uncheck Box Above", type=input.resolution, defval="D")
len = input(20, title="Moving Average Length - LookBack Period")
//periodT3 = input(defval=7, title="Tilson T3 Period", minval=1)
factorT3 = input(defval=7, title="Tilson T3 Factor - *.10 - so 7 = .7 etc.", minval=0)
atype = input(1,minval=1,maxval=8,title="1=SMA, 2=EMA, 3=WMA, 4=HullMA, 5=VWMA, 6=RMA, 7=TEMA, 8=Tilson T3")
spc=input(false, title="Show Price Crossing 1st Mov Avg - Highlight Bar?")
cc = input(true,title="Change Color Based On Direction?")
smoothe = input(2, minval=1, maxval=10, title="Color Smoothing - Setting 1 = No Smoothing")
doma2 = input(false, title="Optional 2nd Moving Average")
spc2=input(false, title="Show Price Crossing 2nd Mov Avg?")
len2 = input(50, title="Moving Average Length - Optional 2nd MA")
sfactorT3 = input(defval=7, title="Tilson T3 Factor - *.10 - so 7 = .7 etc.", minval=0)
atype2 = input(1,minval=1,maxval=8,title="1=SMA, 2=EMA, 3=WMA, 4=HullMA, 5=VWMA, 6=RMA, 7=TEMA, 8=Tilson T3")
cc2 = input(true,title="Change Color Based On Direction 2nd MA?")
warn = input(false, title="***You Can Turn On The Show Dots Parameter Below Without Plotting 2nd MA to See Crosses***")
warn2 = input(false, title="***If Using Cross Feature W/O Plotting 2ndMA - Make Sure 2ndMA Parameters are Set Correctly***")
sd = input(false, title="Show Dots on Cross of Both MA's")
basis = sma(src, len)
res = useCurrentRes ? timeframe.period : resCustom
//hull ma definition
hullma = wma(2*wma(src, len/2)-wma(src, len), round(sqrt(len)))
//TEMA definition
ema1 = ema(src, len)
ema2 = ema(ema1, len)
ema3 = ema(ema2, len)
tema = 3 * (ema1 - ema2) + ema3
//Tilson T3
factor = factorT3 *.10
gd(src, len, factor) => ema(src, len) * (1 + factor) - ema(ema(src, len), len) * factor
t3(src, len, factor) => gd(gd(gd(src, len, factor), len, factor), len, factor)
tilT3 = t3(src, len, factor)
avg = atype == 1 ? sma(src,len) : atype == 2 ? ema(src,len) : atype == 3 ? wma(src,len) : atype == 4 ? hullma : atype == 5 ? vwma(src, len) : atype == 6 ? rma(src,len) : atype == 7 ? 3 * (ema1 - ema2) + ema3 : tilT3
//2nd Ma - hull ma definition
hullma2 = wma(2*wma(src, len2/2)-wma(src, len2), round(sqrt(len2)))
//2nd MA TEMA definition
sema1 = ema(src, len2)
sema2 = ema(sema1, len2)
sema3 = ema(sema2, len2)
stema = 3 * (sema1 - sema2) + sema3
//2nd MA Tilson T3
sfactor = sfactorT3 *.10
sgd(src, len2, sfactor) => ema(src, len2) * (1 + sfactor) - ema(ema(src, len2), len2) * sfactor
st3(src, len2, sfactor) => sgd(sgd(gd(src, len2, sfactor), len2, sfactor), len2, sfactor)
stilT3 = st3(src, len2, sfactor)
avg2 = atype2 == 1 ? sma(src,len2) : atype2 == 2 ? ema(src,len2) : atype2 == 3 ? wma(src,len2) : atype2 == 4 ? hullma2 : atype2 == 5 ? vwma(src, len2) : atype2 == 6 ? rma(src,len2) : atype2 == 7 ? 3 * (ema1 - ema2) + ema3 : stilT3
out = avg
out_two = avg2
out1 = security(syminfo.tickerid, res, out)
out2 = security(syminfo.tickerid, res, out_two)
//Formula for Price Crossing Moving Average #1
cr_up = open < out1 and close > out1
cr_Down = open > out1 and close < out1
//Formula for Price Crossing Moving Average #2
cr_up2 = open < out2 and close > out2
cr_Down2 = open > out2 and close < out2
//barcolor Criteria for Price Crossing Moving Average #1
iscrossUp() => cr_up
iscrossDown() => cr_Down
//barcolor Criteria for Price Crossing Moving Average #2
iscrossUp2() => cr_up2
iscrossDown2() => cr_Down2
ma_up = out1 >= out1[smoothe]
ma_down = out1 < out1[smoothe]
col = cc ? ma_up ? #22E132 : ma_down ? #E11300 : #7EDAE1 : #7EDAE1
col2 = cc2 ? ma_up ? #22E132 : ma_down ? #E11300 : #7EDAE1 :#FFFFFF
circleYPosition = out2
plot(out1, title="Multi-Timeframe Moving Avg", style=plot.style_line, linewidth=4, color = col)
plot(doma2 and out2 ? out2 : na, title="2nd Multi-TimeFrame Moving Average", style=plot.style_circles, linewidth=4, color=col2)
plot(sd and cross(out1, out2) ? circleYPosition : na,style=plot.style_cross, linewidth=15, color=color.aqua)
//barcolor Plot for Price Crossing Moving Average #1
barcolor(spc and iscrossUp() ? (iscrossUp() ? color.yellow : na) : na)
barcolor(spc and iscrossDown() ? (iscrossDown() ? color.yellow : na) : na)
//barcolor Plot for Price Crossing Moving Average #2
barcolor(spc2 and iscrossUp2() ? (iscrossUp2() ? color.yellow : na) : na)
barcolor(spc2 and iscrossDown2() ? (iscrossDown2() ? color.yellow : na) : na)
//STRATEGY
buy1 = ma_up and close > basis
sell1 = ma_down and close < basis
buy2 = iscrossUp()
sell2 =iscrossDown()
buy = ma_up ? 1 : 0
sell = ma_down ? 1 : 0
fastMA = input(title="Fast moving average", type=input.integer, defval=12, minval=7)
slowMA = input(title="Slow moving average", type=input.integer, defval=26, minval=7)
lastColor = color.yellow
[currMacd, signal, _] = macd(close[0], fastMA, slowMA, 9)
[prevMacd, _, _] = macd(close[1], fastMA, slowMA, 9)
plotColor = currMacd > 0 ? currMacd > prevMacd ? color.lime : color.green :
currMacd < prevMacd ? color.maroon : color.red
plot(currMacd, style=plot.style_histogram, color=plotColor, linewidth=3)
plot(0, title="Zero line", linewidth=1, color=color.gray)
plot(signal, title="signal", linewidth=1, color=color.blue)
signalColor1 =currMacd >0 and ma_up and ma_up != ma_up[1] ? 1 : 0
signalColor2 =currMacd<0 and ma_down and ma_down != ma_down[1] ? 1 : 0
plotshape(series=signalColor1, title="cmLong", style=shape.arrowup, location=location.belowbar, color=color.green, text="cmbuy", size=size.normal)
plotshape(series=signalColor2, title="cmShort", style=shape.arrowdown, location=location.abovebar, color=color.red, text="cmsell", size=size.normal)
//ALERT FOR AUTOVIEW TRADE
alertcondition(signalColor1, title='BUY', message='buy')
alertcondition(signalColor2, title='SELL', message='sell')
|
Intraday FOREX london scalper | https://www.tradingview.com/script/mmzEtg5Y-Intraday-FOREX-london-scalper/ | exlux99 | https://www.tradingview.com/u/exlux99/ | 124 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © exlux99
//@version=4
study("Intraday london scalper", overlay=true)
timeinrange(res, sess) => time(res, sess) != 0
doEurOpen = true
europeSession = color.blue
bgcolor(doEurOpen and timeinrange(timeframe.period, "0200-0300") ? europeSession : na, transp=70)
isess = session.regular
t = tickerid(syminfo.prefix, syminfo.ticker, session=isess)
yesterdayHigh = security(t,"D",high)
yesterdayLow = security(t,"D",low)
// Plot the other time frame's data
a=plot(timeframe.isintraday ? yesterdayHigh : na, color=color.red, linewidth=1, style=plot.style_linebr)
b=plot(timeframe.isintraday ? yesterdayLow : na, color=color.lime, linewidth=1, style=plot.style_linebr)
|
Angels Calls 2.0- By Cloves | https://www.tradingview.com/script/3UOnXQvQ/ | ClovesRodrigues | https://www.tradingview.com/u/ClovesRodrigues/ | 298 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ClovesRodrigues
//@version=4
study("Angels Calls 3.0- By Cloves", shorttitle="Angels Calls 3.0 - By Cloves", scale=scale.right, overlay=true)
//precision=0
data = close < open
[middle, upper, lower] = bb(close, 21, 2)
plot(middle, color=#1d79f2)
plot(upper, color=color.red, linewidth=2)
plot(lower, color=color.green, linewidth=2)
r = rsi(close, 21)
c = cci(close, 20)
e5 = ema(close, 5)
e10 = ema(low,10)
e20 = ema(close, 20)
e50 = ema(close, 40)
e200 = ema(close, 200)
eUp = crossover(e5, e10)
eLONG = crossover(e5, e50)
eGOOD = crossover(e20, e50)
eTOP = crossover(e50, e200)
eSell = crossunder(e5, e50)
eSHORTLow = crossunder(e5, e20)
eSHORT = crossunder(e20, e50)
eSellStrong = crossunder(e20, e200)
barcolor((ema(close, 2)) > (ema(close, 4)) ? color.green : color.red)
// Detect crosses.
xUp = crossunder( r, 65)
xUltra = crossunder( r, 75)
xDn = crossover(r, 35)
cUp = crossunder(c, 120)
c200 = crossunder(c, 200)
cUltra = crossunder(c, 300)
cDn = crossover(c, -100)
cBUY = crossover(c, -200)
color1 = color.from_gradient(close, e50, e5, color.new(color.red, 15), color.new(color.green, 15))
color2 = color.from_gradient(close, e200, e5, color.new(color.red, 15), color.new(color.blue, 15))
plot(ema(close, 20), color=color1, linewidth=4, style=plot.style_line)
plot(ema(close, 200), color=color2, linewidth=4, style=plot.style_line)
var Table = table.new(position = position.top_right, columns = 5, rows = 5, bgcolor = color.new(color.green, 50), border_width = 2)
table.cell(table_id = Table, column = 0, row = 2, text = "PRICE : ", bgcolor = color.green)
table.cell(table_id = Table, column = 1, row = 2, text = tostring(close), bgcolor = color.yellow)
if r>60
table.cell(table_id = Table, column = 0, row = 2, text = " PRICE : ", bgcolor = color.green)
table.cell(table_id = Table, column = 1, row = 2, text = tostring(close), bgcolor = color.yellow)
else if r>70
table.cell(table_id = Table, column = 0, row = 2, text = "Suport : ", bgcolor = color.green)
table.cell(table_id = Table, column = 1, row = 2, text = tostring(close*0.9215), bgcolor = color.yellow)
else if r<40
table.cell(table_id = Table, column = 0, row = 2, text = "PRICE : ", bgcolor = color.green)
table.cell(table_id = Table, column = 1, row = 2, text = tostring(close), bgcolor = color.yellow)
else
table.cell(table_id = Table, column = 0, row = 2, text = " PRICE : ", bgcolor = color.green)
table.cell(table_id = Table, column = 1, row = 2, text = tostring(close), bgcolor = color.yellow)
if xDn
table.cell(table_id = Table, column = 0, row = 2, text = "RESISTENCE : ", bgcolor = color.green)
table.cell(table_id = Table, column = 1, row = 2, text = tostring(close/0.9618), bgcolor = color.yellow)
if xDn and close>open
x = label.new(bar_index, na)
label.set_text(x, "RSI / Buy Alert")
label.set_color(x, color.green)
label.set_yloc(x, yloc.belowbar)
label.set_style(x, label.style_label_up)
//label.set_size(x, size.large )
else if cBUY and low<=lower and close>low
t = label.new(bar_index, na)
//label.set_text(t, "CCI -200")
label.set_color(t, color.green)
label.set_yloc(t, yloc.belowbar)
label.set_style(t, label.style_triangleup)
label.set_size(t, size.small )
else if cDn and low<=lower
j = label.new(bar_index, na)
//label.set_text(j, tostring(low))
label.set_color(j, color.green)
label.set_yloc(j, yloc.belowbar)
label.set_style(j, label.style_triangleup)
label.set_size(j, size.small )
if xUp
l = label.new(bar_index, na)
label.set_text(l, "Sell Alert")
label.set_color(l, color.red)
label.set_yloc(l, yloc.abovebar)
label.set_style(l, label.style_label_lower_left)
label.set_size(l, size.small)
else if cUp //and high>upper
l = label.new(bar_index, na)
//label.set_text(l, tostring(high))
label.set_color(l, color.red)
label.set_yloc(l, yloc.abovebar)
label.set_style(l, label.style_triangledown)
label.set_size(l, size.small )
else if c200 //and high>upper
l = label.new(bar_index, na)
//label.set_text(l, "Sell Alert")
label.set_color(l, color.red)
label.set_yloc(l, yloc.abovebar)
label.set_style(l, label.style_triangledown)
label.set_size(l, size.small)
if xUltra //and high>upper
l = label.new(bar_index, na)
label.set_text(l, "RSI > 75")
label.set_color(l, color.red)
label.set_yloc(l, yloc.abovebar)
label.set_style(l, label.style_label_down)
label.set_size(l, size.normal )
table.cell(table_id = Table, column = 0, row = 0, text = "SELL ALERT" )
table.cell_set_bgcolor(table_id = Table, column = 0, row = 0, bgcolor = color.red)
if eSellStrong and close<open
l = label.new(bar_index, na)
label.set_text(l, "SHORT")
label.set_color(l, color.red)
label.set_yloc(l, yloc.abovebar)
label.set_style(l, label.style_label_down)
table.cell(table_id = Table, column = 1, row = 0, text = "SHORT Alert M200")
table.cell_set_bgcolor(table_id = Table, column = 1, row = 0, bgcolor = color.red)
else if eSHORT and open>lower and close<middle
l = label.new(bar_index, na)
label.set_text(l, "Wait to buy")
label.set_color(l, color.white)
label.set_yloc(l, yloc.abovebar)
label.set_style(l, label.style_label_down )
//label.set_size(l, size.tiny )
//label.set_size(l, size.small)
table.cell(table_id = Table, column = 0, row = 0, text = "SHORT POSITION = " )
table.cell_set_bgcolor(table_id = Table, column = 0, row = 0, bgcolor = color.red)
else if eSHORTLow and close<open and close<e50 and close<middle
l = label.new(bar_index, na)
label.set_text(l, "Low SHORT")
label.set_color(l, color.red)
label.set_yloc(l, yloc.abovebar)
label.set_style(l, label.style_label_down)
label.set_size(l, size.small)
table.cell(table_id = Table, column = 0, row = 0, text = "WAIT POSITION...")
table.cell_set_bgcolor(table_id = Table, column = 0, row = 0, bgcolor = color.white)
else if eUp
l = label.new(bar_index, na)
label.set_text(l, "W A I T")
label.set_color(l, color.white)
label.set_yloc(l, yloc.abovebar)
label.set_style(l, label.style_label_lower_left)
label.set_size(l, size.tiny )
//table.cell(table_id = Table, column = 1, row = 2, text = "WAIT..." )
//table.cell_set_bgcolor(table_id = Table, column = 1, row = 2, bgcolor = color.white)
if eGOOD and close>e50 and close>open and close>middle
x = label.new(bar_index, na)
label.set_text(x, "LONG")
label.set_color(x, color.green)
label.set_yloc(x, yloc.belowbar)
label.set_style(x, label.style_label_up)
label.set_size(x, size.small)
table.cell(table_id = Table, column = 0, row = 0, text = "LONG POSITION ")
table.cell_set_bgcolor(table_id = Table, column = 0, row = 0, bgcolor = color.green)
if eGOOD and (e50 >e200) and open>middle and close>open
l = label.new(bar_index, na)
label.set_text(l, "Wait\nto sell")
label.set_color(l, color.green)
label.set_yloc(l, yloc.abovebar)
label.set_style(l, label.style_label_down)
label.set_size(l, size.small )
table.cell(table_id = Table, column = 1, row = 0, text = "WAIT to sell..." )
table.cell_set_bgcolor(table_id = Table, column = 1, row = 0, bgcolor = color.green)
else if cUltra //and close>open
l = label.new(bar_index, na)
label.set_text(l, "CCI>200")
label.set_color(l, color.red)
label.set_yloc(l, yloc.abovebar)
label.set_style(l, label.style_label_down)
label.set_size(l, size.small)
table.cell(table_id = Table, column = 1, row = 0, text = "SELL Alert !" )
table.cell_set_bgcolor(table_id = Table, column = 1, row = 0, bgcolor = color.red)
else if xUltra //and close>upper
l = label.new(bar_index, na)
label.set_text(l, "SELL ALERT")
label.set_color(l, color.red)
label.set_yloc(l, yloc.abovebar)
label.set_style(l, label.style_label_down)
label.set_size(l, size.normal )
table.cell(table_id = Table, column = 1, row = 0, text = "SELL ALERT" )
table.cell_set_bgcolor(table_id = Table, column = 1, row = 0, bgcolor = color.red)
if eSell
//l = label.new(bar_index, na)
//label.set_text(l, "Wait")
//label.set_color(l, color.white)
//label.set_yloc(l, yloc.abovebar)
//label.set_style(l, label.style_label_down)
table.cell(table_id = Table, column = 1, row = 0, text = "WAIT" )
table.cell_set_bgcolor(table_id = Table, column = 1, row = 0, bgcolor = color.white)
//label.set_size(l, size.small)
|
My Triple Supertrend | https://www.tradingview.com/script/bWnS06JH-My-Triple-Supertrend/ | dhafinskii | https://www.tradingview.com/u/dhafinskii/ | 106 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © aryhidayat12
//@version=4
study("My Triple Supertrend", overlay=true, resolution="", resolution_gaps=true)
atrPeriod = input(10, "ATR Length")
factor = input(1, "Factor")
[supertrend, direction] = supertrend(factor, atrPeriod)
bodyMiddle = plot((open + close) / 2, display=display.none)
upTrend = plot(direction < 0 ? supertrend : na, "Up Trend", color = color.green, style=plot.style_linebr)
downTrend = plot(direction < 0? na : supertrend, "Down Trend", color = color.red, style=plot.style_linebr)
fill(bodyMiddle, upTrend, color.new(color.green, 90), fillgaps=false)
fill(bodyMiddle, downTrend, color.new(color.red, 90), fillgaps=false)
atrPeriod2 = input(11, "ATR Length")
factor2 = input(2, "Factor")
[supertrend2, direction2] = supertrend(factor2, atrPeriod2)
upTrend2 = plot(direction2 < 0 ? supertrend2 : na, "Up Trend", color = color.green, style=plot.style_linebr)
downTrend2 = plot(direction2 < 0? na : supertrend2, "Down Trend", color = color.red, style=plot.style_linebr)
atrPeriod3 = input(12, "ATR Length")
factor3 = input(3, "Factor")
[supertrend3, direction3] = supertrend(factor3, atrPeriod3)
upTrend3 = plot(direction3 < 0 ? supertrend3 : na, "Up Trend", color = color.green, style=plot.style_linebr)
downTrend3 = plot(direction3 < 0? na : supertrend3, "Down Trend", color = color.red, style=plot.style_linebr) |
Portfolio Tracker [Anan] | https://www.tradingview.com/script/Zg2lAMYs-Portfolio-Tracker-Anan/ | Mohamed3nan | https://www.tradingview.com/u/Mohamed3nan/ | 251 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Mohamed3nan
/////////////////////////////////////////////////
// /\ //
// / \ _ __ __ _ _ __ //
// / /\ \ | '_ \ / _` | | '_ \ //
// / ____ \ | | | | | (_| | | | | | //
// /_/ \_\ |_| |_| \__,_| |_| |_| //
/////////////////////////////////////////////////
//@version=5
// ---------------------------------------------------------------------------------------------- //
indicator('Portfolio Tracker [Anan]', 'Portfolio Tracker [Anan]', true)
group_1 = 'Asset / Quantity / Avg. Buy/Sell Price'
use1 = input.bool(true, '', inline='1', group=group_1)
sym1 = input.symbol('BINANCE:BTCUSDT', '', inline='1', group=group_1)
qty1 = input.float(1, 'QTY', inline='1', group=group_1)
price1 = input.float(10000, 'Price', inline='1', group=group_1)
use2 = input.bool(false, '', inline='2', group=group_1)
sym2 = input.symbol('', '', inline='2', group=group_1)
qty2 = input.float(0, 'QTY', inline='2', group=group_1)
price2 = input.float(0, 'Price', inline='2', group=group_1)
use3 = input.bool(false, '', inline='3', group=group_1)
sym3 = input.symbol('', '', inline='3', group=group_1)
qty3 = input.float(0, 'QTY', inline='3', group=group_1)
price3 = input.float(0, 'Price', inline='3', group=group_1)
use4 = input.bool(false, '', inline='4', group=group_1)
sym4 = input.symbol('', '', inline='4', group=group_1)
qty4 = input.float(0, 'QTY', inline='4', group=group_1)
price4 = input.float(0, 'Price', inline='4', group=group_1)
use5 = input.bool(false, '', inline='5', group=group_1)
sym5 = input.symbol('', '', inline='5', group=group_1)
qty5 = input.float(0, 'QTY', inline='5', group=group_1)
price5 = input.float(0, 'Price', inline='5', group=group_1)
use6 = input.bool(false, '', inline='6', group=group_1)
sym6 = input.symbol('', '', inline='6', group=group_1)
qty6 = input.float(0, 'QTY', inline='6', group=group_1)
price6 = input.float(0, 'Price', inline='6', group=group_1)
use7 = input.bool(false, '', inline='7', group=group_1)
sym7 = input.symbol('', '', inline='7', group=group_1)
qty7 = input.float(0, 'QTY', inline='7', group=group_1)
price7 = input.float(0, 'Price', inline='7', group=group_1)
use8 = input.bool(false, '', inline='8', group=group_1)
sym8 = input.symbol('', '', inline='8', group=group_1)
qty8 = input.float(0, 'QTY', inline='8', group=group_1)
price8 = input.float(0, 'Price', inline='8', group=group_1)
use9 = input.bool(false, '', inline='9', group=group_1)
sym9 = input.symbol('', '', inline='9', group=group_1)
qty9 = input.float(0, 'QTY', inline='9', group=group_1)
price9 = input.float(0, 'Price', inline='9', group=group_1)
use10 = input.bool(false, '', inline='10', group=group_1)
sym10 = input.symbol('', '', inline='10', group=group_1)
qty10 = input.float(0, 'QTY', inline='10', group=group_1)
price10 = input.float(0, 'Price', inline='10', group=group_1)
group_table = 'Table Position & Size & Colors'
string tableYpos = input.string('top', '↕', inline='01', group=group_table, options=['top', 'middle', 'bottom'])
string tableXpos = input.string('right', '↔', inline='01', group=group_table, options=['left', 'center', 'right'], tooltip='Position on the chart.')
int tableRowHeight = input.int(0, '|', inline='02', group=group_table, minval=0, maxval=100)
int tableColWidth = input.int(0, '—', inline='02', group=group_table, minval=0, maxval=100, tooltip='0-100. Use 0 to auto-size height and width.')
string textSize_ = input.string('Small', 'Table Text Size', options=['Auto', 'Tiny', 'Small', 'Normal', 'Large', 'Huge'], group=group_table)
string textSize = textSize_ == 'Auto' ? size.auto : textSize_ == 'Tiny' ? size.tiny : textSize_ == 'Small' ? size.small : textSize_ == 'Normal' ? size.normal : textSize_ == 'Large' ? size.large : size.huge
color row_col = input.color(color.blue, 'Headers', inline='03', group=group_table)
color col_col = input.color(color.blue, ' ', inline='03', group=group_table)
color poscol = input.color(color.green, 'Profit/Loss', inline='04', group=group_table)
color neutralcolor = input.color(color.gray, '', inline='04', group=group_table)
color negcol = input.color(color.red, '', inline='04', group=group_table)
// ---------------------------------------------------------------------------------------------- //
var table anan = table.new(tableYpos + '_' + tableXpos, 8, 11, border_width=2)
table.cell(anan, 0, 0, 'Asset', text_color=col_col, bgcolor=color.new(col_col, 80), text_size=textSize, width=tableColWidth, height=tableRowHeight)
table.cell(anan, 1, 0, 'Price (24H%)', text_color=col_col, bgcolor=color.new(col_col, 80), text_size=textSize, width=tableColWidth, height=tableRowHeight)
table.cell(anan, 2, 0, 'Holdings', text_color=col_col, bgcolor=color.new(col_col, 80), text_size=textSize, width=tableColWidth, height=tableRowHeight)
table.cell(anan, 3, 0, 'Current Value', text_color=col_col, bgcolor=color.new(col_col, 80), text_size=textSize, width=tableColWidth, height=tableRowHeight)
table.cell(anan, 4, 0, 'Avg. Price', text_color=col_col, bgcolor=color.new(col_col, 80), text_size=textSize, width=tableColWidth, height=tableRowHeight)
table.cell(anan, 5, 0, 'Cost Value', text_color=col_col, bgcolor=color.new(col_col, 80), text_size=textSize, width=tableColWidth, height=tableRowHeight)
table.cell(anan, 6, 0, 'Profit/Loss', text_color=col_col, bgcolor=color.new(col_col, 80), text_size=textSize, width=tableColWidth, height=tableRowHeight)
table.cell(anan, 7, 0, 'Profit/Loss %', text_color=col_col, bgcolor=color.new(col_col, 80), text_size=textSize, width=tableColWidth, height=tableRowHeight)
// ---------------------------------------------------------------------------------------------- //
getCurPrice(sym) =>
request.security(sym, '12M', close)
getROC(sym) =>
request.security(sym, '1D', ta.roc(close, 1))
renderTable(cell, use, sym, qty, price) =>
curPrice = getCurPrice(sym)
roc = getROC(sym)
if use
table.cell(anan, 0, cell, sym, text_color=row_col, bgcolor=color.new(row_col, 80), text_size=textSize, width=tableColWidth, height=tableRowHeight)
table.cell(anan, 1, cell, str.tostring(curPrice) + ' (' + str.tostring(roc, '#.##') + '%)', text_color=roc > 0 ? poscol : roc < 0 ? negcol : neutralcolor, bgcolor=color.new(roc > 0 ? poscol : roc < 0 ? negcol : neutralcolor, 80), text_size=textSize, width=tableColWidth, height=tableRowHeight)
table.cell(anan, 2, cell, str.tostring(qty), text_color=poscol, bgcolor=color.new(poscol, 80), text_size=textSize, width=tableColWidth, height=tableRowHeight)
table.cell(anan, 3, cell, str.tostring(curPrice * qty), text_color=curPrice * qty > price * qty ? poscol : curPrice * qty < price * qty ? negcol : neutralcolor, bgcolor=color.new(curPrice * qty > price * qty ? poscol : curPrice * qty < price * qty ? negcol : neutralcolor, 80), text_size=textSize, width=tableColWidth, height=tableRowHeight)
table.cell(anan, 4, cell, str.tostring(price), text_color=curPrice > price ? poscol : curPrice < price ? negcol : neutralcolor, bgcolor=color.new(curPrice > price ? poscol : curPrice < price ? negcol : neutralcolor, 80), text_size=textSize, width=tableColWidth, height=tableRowHeight)
table.cell(anan, 5, cell, str.tostring(price * qty), text_color=curPrice * qty > price * qty ? poscol : curPrice * qty < price * qty ? negcol : neutralcolor, bgcolor=color.new(curPrice * qty > price * qty ? poscol : curPrice * qty < price * qty ? negcol : neutralcolor, 80), text_size=textSize, width=tableColWidth, height=tableRowHeight)
table.cell(anan, 6, cell, str.tostring(curPrice * qty - price * qty), text_color=curPrice * qty - price * qty > 0 ? poscol : curPrice * qty - price * qty < 0 ? negcol : neutralcolor, bgcolor=color.new(curPrice * qty - price * qty > 0 ? poscol : curPrice * qty - price * qty < 0 ? negcol : neutralcolor, 80), text_size=textSize, width=tableColWidth, height=tableRowHeight)
table.cell(anan, 7, cell, str.tostring((curPrice * qty - price * qty) / (price * qty) * 100, '#.##') + '%', text_color=curPrice * qty - price * qty > 0 ? poscol : curPrice * qty - price * qty < 0 ? negcol : neutralcolor, bgcolor=color.new(curPrice * qty - price * qty > 0 ? poscol : curPrice * qty - price * qty < 0 ? negcol : neutralcolor, 80), text_size=textSize, width=tableColWidth, height=tableRowHeight)
// ---------------------------------------------------------------------------------------------- //
renderTable(1, use1, sym1, qty1, price1)
renderTable(2, use2, sym2, qty2, price2)
renderTable(3, use3, sym3, qty3, price3)
renderTable(4, use4, sym4, qty4, price4)
renderTable(5, use5, sym5, qty5, price5)
renderTable(6, use6, sym6, qty6, price6)
renderTable(7, use7, sym7, qty7, price7)
renderTable(8, use8, sym8, qty8, price8)
renderTable(9, use9, sym9, qty9, price9)
renderTable(10, use10, sym10, qty10, price10)
// ---------------------------------------------------------------------------------------------- //
|
Portfolio Index | https://www.tradingview.com/script/Cluy2Psz-Portfolio-Index/ | CatalaniCD | https://www.tradingview.com/u/CatalaniCD/ | 5 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © CatalaniCD
//@version=4
study("Portfolio Index")
// input date
date = input(title = "Initial Date", type = input.time, defval=timestamp("01 Jan 2020 00:00 +0000"))
// input equity
equity = input(title = 'Equity', type = input.integer, defval = 10000, minval = 1)
// select portfolio components
// input portfolio tickers
// input percent
asset_0 = input(title = 'Portfolio 0', type = input.symbol, defval = "TSLA")
pct_0 = input(title = '%Holding', type = input.float, defval = 0.33)
asset_1 = input(title = 'Portfolio 1', type = input.symbol, defval = "AAPL")
pct_1 = input(title = '%Holding', type = input.float, defval = 0.33)
asset_2 = input(title = 'Portfolio 2', type = input.symbol, defval = "MSFT")
pct_2 = input(title = '%Holding', type = input.float, defval = 0.33)
// load prices
price_x = security(syminfo.ticker, resolution = timeframe.period, expression = close)
price_0 = security(symbol = asset_0, resolution = timeframe.period, expression = close)
price_1 = security(symbol = asset_1, resolution = timeframe.period, expression = close)
price_2 = security(symbol = asset_2, resolution = timeframe.period, expression = close)
log_returns(price) =>
change(log(price))
sim_returns(price) =>
exp(cum(change(log(price), 1)))
if time >= date
price_x := sim_returns(price_x) * equity
price_0 := sim_returns(price_0) * equity * pct_0
price_1 := sim_returns(price_1) * equity * pct_1
price_2 := sim_returns(price_2) * equity * pct_2
portfolio = array.avg(array.from(log_returns(price_0), log_returns(price_1), log_returns(price_2)))
index = cum(log_returns(price_x)) - cum(portfolio)
hline(price = 0.0, color = color.white)
plot(index) |
st_limits | https://www.tradingview.com/script/FObgvjFj-st-limits/ | IntelTrading | https://www.tradingview.com/u/IntelTrading/ | 34 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Alferow
//@version=4
study("st_limits", overlay = true)
n = input(30, step = 1, title = 'period')
h = highest(high, n)
l = lowest(low, n)
m1 = input(0.34, step = 0.01, title = 'koeff for min')
m2 = input(2.40, step = 0.01, title = 'koeff for max')
lh = h*m1
ll = l*m2
plot(lh, color=#00ffaa, linewidth = 2)
plot(ll, color=#ff1a00, linewidth = 2) |
Accumulation/Distribution % | https://www.tradingview.com/script/2SoEv1vf-Accumulation-Distribution/ | Skipper86 | https://www.tradingview.com/u/Skipper86/ | 1,028 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Skipper86
//@version=4
study(title="Accumulation/Distribution %", shorttitle="AD%", format=format.percent, precision=0, overlay=false, resolution="")
length = input(10, minval = 2, title="Calculation Period")
ad = sum((close==high and close==low or high==low ? 0 : ((close-open)/(high-low))*volume),length)
//logic tests taken from default Tradingview A/D function, algebraic formula taken from Bollinger on Bollinger Bands textbook page 151 Table 18.4
//function would be cumulative rather than a summation if this was the standard accumulation/distribution indicator but since it's a normalized oscillator,
//it's only looking back at the previous 10 (or whatever the calculation period is set to) bars
//side note: Tradingview A/D indicator doesn't include opening price. There are multiple versions of the A/D indicator.
norm = 100*ad/sum(volume,length)
//A/D data normalized based on calculation period, multiplied by 100 to avoid decimal values on vertical axis
normcolor = (norm > 0) and (norm > norm[1]) ? #08A515 : (norm > 0) and (norm <= norm[1]) ? #025F08: (norm < 0) and (norm < norm[1]) ? #BB0000 : (norm < 0) and (norm >= norm[1]) ? #660011 : #FF9F00
//This code sets the coloration for both the upper price plot and lower oscillator plot
//Chart type must be set to "bars" for the upper coloration to work properly
barcolor(normcolor)
//Bar Color (upper plot)
plot(norm, color=normcolor, style=plot.style_columns, title = "AD%")
//normalized ad (lower plot)
//End of Script
|
Identifying Trapped Traders | https://www.tradingview.com/script/BF4QFzzY-Identifying-Trapped-Traders/ | arunbabumvk_23 | https://www.tradingview.com/u/arunbabumvk_23/ | 130 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Meesemoo
//@version=4
study("Identifying Trapped Traders")
lookback = input(defval = 10, title = "How many bars lookback?", minval = 2, maxval = 500, type = input.integer)
trading_fees = input(defval = true, title = "Account for Trading fees?", type=input.bool)
fee = 0.0
if trading_fees
fee := (hl2 * 0.002)
trapped_buyers = 0.0
trapped_sellers = 0.0
for i = 0 to lookback
if high[i] > (hl2 - fee)
trapped_buyers := trapped_buyers + (hl2 - high[i])
if low[i] < (hl2 + fee)
trapped_sellers := trapped_sellers + (hl2 - low[i])
plot(trapped_buyers, color = color.red)
plot(trapped_sellers, color = color.green)
plot(0, color = color.black)
fill(plot(0), plot(trapped_buyers, color = color.red), color = color.red, transp = 80)
fill(plot(0), plot(trapped_sellers, color = color.green), color = color.green, transp = 80) |
Coral Trend Indicator [LazyBear] pine v4 | https://www.tradingview.com/script/AzQo1gRi-Coral-Trend-Indicator-LazyBear-pine-v4/ | Unknown_TracerBUNNY | https://www.tradingview.com/u/Unknown_TracerBUNNY/ | 255 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Unknown_TracerBUNNY
//@version=4
// original code by // @author LazyBear
// I have converted his code to latest PineScript version 4 | I am not the creator of this indicator!
// I am not the creator of this indicator!, I have only added few lines form line: 20 to line: 25
// and updated few syntax to latest pine version (eg:- blue to color.blue and similar things like that)
study(title="Coral Trend Indicator [LazyBear] || v4 pine by Unknown_TracerBunny",shorttitle="CTI", overlay=true)
src = input(title="Source", type=input.source, defval=close,group="CTI")
sm =input(21, title="Smoothing Period",group="CTI")
cd = input(0.4, title="Constant D",group="CTI")
bar_col=input(false, title="Color Bars",inline="br",group="Color mode")
flat = input(title="Line", type=input.color, defval=color.new(color.blue,0),inline="br",group="Color mode")
raise = input(title="Color", type=input.color, defval=color.new(color.green,0),inline="col",group="Style")
fall = input(title="Color", type=input.color, defval=color.new(color.red,0),inline="col",group="Style")
di = (sm - 1.0) / 2.0 + 1.0
c1 = 2 / (di + 1.0)
c2 = 1 - c1
c3 = 3.0 * (cd * cd + cd * cd * cd)
c4 = -3.0 * (2.0 * cd * cd + cd + cd * cd * cd)
c5 = 3.0 * cd + 1.0 + cd * cd * cd + 3.0 * cd * cd
var float i1 = na
var float i2 = na
var float i3 = na
var float i4 = na
var float i5 = na
var float i6 = na
i1 := c1*src + c2*nz(i1[1])
i2 := c1*i1 + c2*nz(i2[1])
i3 := c1*i2 + c2*nz(i3[1])
i4 := c1*i3 + c2*nz(i4[1])
i5 := c1*i4 + c2*nz(i5[1])
i6 := c1*i5 + c2*nz(i6[1])
Cto = -cd*cd*cd*i6 + c3*(i5) + c4*(i4) + c5*(i3)
// --------------------------------------------------------------------------
// For the Pinescript coders: Determining trend based on the mintick step.
// --------------------------------------------------------------------------
//bfrC = Cto - nz(Cto[1]) > syminfo.mintick ? green : Cto - nz(Cto[1]) < syminfo.mintick ? red : blue
bfrC = Cto > nz(Cto[1]) ? raise : Cto < nz(Cto[1]) ? fall : na
tc=bar_col?flat: bfrC
plot(Cto, title="Trend", linewidth=3, style=plot.style_stepline, color=tc,editable=false)
barcolor(bar_col?bfrC:na,editable=false)
shift_up = (bfrC[1] == fall and bfrC == raise)
shift_dn = (bfrC[1] == raise and bfrC == fall)
plotshape( shift_up, title = 'Buy',text="Buy",textcolor=raise, style = shape.triangleup, location = location.belowbar, color = #2dac32)
plotshape(shift_dn, title = 'Sell',text="Sell",textcolor=fall, style = shape.triangledown, location = location.abovebar, color = color.orange)
alertcondition(shift_up, title='Alert for Buy', message="Buy")
alertcondition(shift_dn, title='Alert for Sell', message="Sell")
|
Random Color Generator | https://www.tradingview.com/script/DkSomBm8-Random-Color-Generator/ | Trendoscope | https://www.tradingview.com/u/Trendoscope/ | 37 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © HeWhoMustNotBeNamed
// © RicardoSantos
//@version=5
indicator('Random Color Generator', overlay=true)
i_preset = input.string('Light+Dark', title='Background', options=['Light', 'Dark', 'Light+Dark', 'Custom'])
i_h_min = input.int(0, minval=0, maxval=127, title='H', group='HSLT', inline='H')
i_h_max = input.int(255, minval=128, maxval=255, title='', group='HSLT', inline='H')
i_s_min = input.int(0, minval=0, maxval=50, title='S', group='HSLT', inline='S')
i_s_max = input.int(100, minval=51, maxval=100, title='', group='HSLT', inline='S')
i_l_min = input.int(30, minval=0, maxval=51, title='L', group='HSLT', inline='L')
i_l_max = input.int(70, minval=51, maxval=100, title='', group='HSLT', inline='L')
i_transparency = input.int(0, minval=0, maxval=100, title='T', group='HSLT', inline='T')
// ************** This part of the code is taken from // © RicardoSantos
// https://www.tradingview.com/script/4jdGt6Xo-Function-HSL-color/
f_color_hsl(_hue, _saturation, _lightness, _transparency) => //{
// @function: returns HSL color.
// @reference: https://stackoverflow.com/questions/36721830/convert-hsl-to-rgb-and-hex
float _l1 = _lightness / 100.0
float _a = _saturation * math.min(_l1, 1.0 - _l1) / 100.0
float _rk = (0.0 + _hue / 30.0) % 12.0
float _r = 255.0 * (_l1 - _a * math.max(math.min(_rk - 3.0, 9.0 - _rk, 1.0), -1.0))
float _gk = (8.0 + _hue / 30.0) % 12.0
float _g = 255.0 * (_l1 - _a * math.max(math.min(_gk - 3.0, 9.0 - _gk, 1.0), -1.0))
float _bk = (4.0 + _hue / 30.0) % 12.0
float _b = 255.0 * (_l1 - _a * math.max(math.min(_bk - 3.0, 9.0 - _bk, 1.0), -1.0))
color.rgb(_r, _g, _b, _transparency)
//}
// ************** End of borrowed code
avoidLight = i_preset == 'Light' or i_preset == 'Light+Dark'
avoidDark = i_preset == 'Dark' or i_preset == 'Light+Dark'
custom = i_preset == 'Custom'
l_min = custom ? i_l_min : avoidDark ? 30 : 0
l_max = custom ? i_l_max : avoidLight ? 70 : 100
h_min = custom ? i_h_min : 0
h_max = custom ? i_h_max : 255
s_min = custom ? i_s_min : 0
s_max = custom ? i_s_max : 100
f_random_color(h_min, h_max, s_min, s_max, l_min, l_max, transparency) =>
f_color_hsl(math.random(h_min, h_max), math.random(s_min, s_max), math.random(l_min, l_max), transparency)
barcolor(f_random_color(h_min, h_max, s_min, s_max, l_min, l_max, i_transparency))
|
Drawdown - Price vs Fundamentals | https://www.tradingview.com/script/5de51xe5-Drawdown-Price-vs-Fundamentals/ | Trendoscope | https://www.tradingview.com/u/Trendoscope/ | 141 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © HeWhoMustNotBeNamed
//@version=4
study("Drawdown - Price vs Fundamentals")
i_reference = input("ath", title="Reference", options=["ath", "window"], group="Reference")
i_startTime = input(defval = timestamp("01 Jan 2010 00:00 +0000"), title = "Start Time", type = input.time, group="Reference")
i_endTime = input(defval = timestamp("01 Jan 2099 00:00 +0000"), title = "End Time", type = input.time, group="Reference")
inDateRange = time >= i_startTime and time <= i_endTime
var ath = high
var drawdown = 0.0
f_getFinancials(financial_id, period) => financial(syminfo.tickerid, financial_id, period)
f_getOptimalFinancialBasic(financial_id) =>
f_getFinancials(financial_id, syminfo.currency == "USD"? "FQ" : "FY")
f_get_ath_and_drawdown(ath, drawdown, value)=>
_ath = ath
_drawdown = drawdown
_ath := na(ath) or value > _ath? value : _ath
_drawdown := round((abs(_ath-value)/abs(_ath))*100)
[_ath, _drawdown]
tso = financial(syminfo.tickerid, "TOTAL_SHARES_OUTSTANDING", "FQ")
bvps = financial(syminfo.tickerid, "BOOK_VALUE_PER_SHARE", "FQ")
eps = financial(syminfo.tickerid, "EARNINGS_PER_SHARE", "TTM")
feps = earnings(syminfo.tickerid, earnings.estimate, lookahead = barmerge.lookahead_on)
rps = financial(syminfo.tickerid, "TOTAL_REVENUE", "TTM")/tso
frps = f_getOptimalFinancialBasic("SALES_ESTIMATES")/tso
var bvpsAth = bvps
var epsAth = eps
var fepsAth = feps
var rpsAth = rps
var frpsAth = frps
var bvpsDrawdown = 0.0
var epsDrawdown = 0.0
var fepsDrawdown = 0.0
var rpsDrawdown = 0.0
var frpsDrawdown = 0.0
if(i_reference == "ath" or inDateRange)
ath := high > ath? high : ath
drawdown := round(((ath-high)/ath)*100)
[_ath, _drawdown] = f_get_ath_and_drawdown(ath, drawdown, high)
ath := _ath
drawdown := _drawdown
[_bvpsAth, _bvpsDrawdown] = f_get_ath_and_drawdown(bvpsAth, bvpsDrawdown, bvps)
bvpsAth := _bvpsAth
bvpsDrawdown := _bvpsDrawdown
[_epsAth, _epsDrawdown] = f_get_ath_and_drawdown(epsAth, epsDrawdown, eps)
epsAth := _epsAth
epsDrawdown := _epsDrawdown
[_fepsAth, _fepsDrawdown] = f_get_ath_and_drawdown(fepsAth, fepsDrawdown, feps)
fepsAth := _fepsAth
fepsDrawdown := _fepsDrawdown
[_rpsAth, _rpsDrawdown] = f_get_ath_and_drawdown(rpsAth, rpsDrawdown, rps)
rpsAth := _rpsAth
rpsDrawdown := _rpsDrawdown
[_frpsAth, _frpsDrawdown] = f_get_ath_and_drawdown(frpsAth, frpsDrawdown, frps)
frpsAth := _frpsAth
frpsDrawdown := _frpsDrawdown
plot(drawdown, color = color.green, title="Price")
plot(bvpsDrawdown, color=color.red, title="Book Value")
plot(epsDrawdown, color=color.orange, title="Earnings")
plot(fepsDrawdown, color=color.fuchsia, title="Earning Estimates")
plot(rpsDrawdown, color=color.teal, title="Revenue")
plot(frpsDrawdown, color=color.aqua, title="Revenue Estimates") |
Drawdown Range | https://www.tradingview.com/script/UdXqUXEK-Drawdown-Range/ | Trendoscope | https://www.tradingview.com/u/Trendoscope/ | 123 | study | 5 | CC-BY-NC-SA-4.0 | // This work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © Trendoscope Pty Ltd
// ░▒
// ▒▒▒ ▒▒
// ▒▒▒▒▒ ▒▒
// ▒▒▒▒▒▒▒░ ▒ ▒▒
// ▒▒▒▒▒▒ ▒ ▒▒
// ▓▒▒▒ ▒ ▒▒▒▒▒▒▒▒▒▒▒
// ▒▒▒▒▒▒▒▒▒▒▒ ▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
// ▒ ▒ ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░▒▒▒▒▒▒▒▒
// ▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒
// ▒▒▒▒▒ ▒▒▒▒▒▒▒
// ▒▒▒▒▒▒▒▒▒
// ▒▒▒▒▒ ▒▒▒▒▒
// ░▒▒▒▒ ▒▒▒▒▓ ████████╗██████╗ ███████╗███╗ ██╗██████╗ ██████╗ ███████╗ ██████╗ ██████╗ ██████╗ ███████╗
// ▓▒▒▒▒ ▒▒▒▒ ╚══██╔══╝██╔══██╗██╔════╝████╗ ██║██╔══██╗██╔═══██╗██╔════╝██╔════╝██╔═══██╗██╔══██╗██╔════╝
// ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ██║ ██████╔╝█████╗ ██╔██╗ ██║██║ ██║██║ ██║███████╗██║ ██║ ██║██████╔╝█████╗
// ▒▒▒▒▒ ▒▒▒▒▒ ██║ ██╔══██╗██╔══╝ ██║╚██╗██║██║ ██║██║ ██║╚════██║██║ ██║ ██║██╔═══╝ ██╔══╝
// ▒▒▒▒▒ ▒▒▒▒▒ ██║ ██║ ██║███████╗██║ ╚████║██████╔╝╚██████╔╝███████║╚██████╗╚██████╔╝██║ ███████╗
// ▒▒ ▒
//@version=5
indicator('Drawdown Range[Trendoscope]', 'DD[Trendoscope]')
i_numberOfRanges = input.int(20, title='Number of ranges', options=[5, 10, 20, 25, 50, 100], group='Main')
i_percentile = input.bool(true, 'Percentile', group='Main')
i_reference = input.string('ath', title='Reference', options=['ath', 'window'], group='Reference')
i_startTime = input.time(defval=timestamp('01 Jan 2010 00:00 +0000'), title='Start Time', group='Reference')
i_endTime = input.time(defval=timestamp('01 Jan 2099 00:00 +0000'), title='End Time', group='Reference')
inDateRange = time >= i_startTime and time <= i_endTime
i_tablePosition = input.string(defval=position.middle_center, title='Table Position', options=[position.bottom_right, position.bottom_center, position.bottom_left, position.middle_right, position.middle_center, position.middle_left, position.top_right, position.top_center, position.top_left], group='Display')
i_displayRangeHeader = input.bool(true, 'Display Range Header', group='Display')
i_text_size = input.string(size.small, title='Text Size', options=[size.tiny, size.small, size.normal, size.large, size.huge], group='Display', inline='text')
i_headerColor = input.color(color.maroon, title='Header', group='Display', inline='GC')
i_neutralColor = input.color(#FFEEBB, title='Cell', group='Display', inline='GC')
i_presentColor = input.color(color.aqua, title='Present', group='Display', inline='Color')
i_maxColor = input.color(color.green, title='Max', group='Display', inline='Color')
i_minColor = input.color(color.orange, title='Min', group='Display', inline='Color')
f_get_ath_and_drawdown(ath, value) =>
_ath = ath
_ath := na(ath) or value > _ath ? value : _ath
_drawdown = math.round(math.abs(_ath - value) / math.abs(_ath) * 100)
[_ath, _drawdown]
var DIVISOR = i_numberOfRanges >= 50 ? 10 : 5
var ROWS = i_numberOfRanges / DIVISOR
var COLUMNS = DIVISOR
var CELLRANGE = 100 / i_numberOfRanges
var ROWRANGE = 100 / ROWS
var ath = high
var p_athDistanceRange = array.new_int(i_numberOfRanges, 0)
if i_reference == 'ath' or inDateRange
var dateStart = str.tostring(year) + '/' + str.tostring(month) + '/' + str.tostring(dayofmonth)
dateEnd = str.tostring(year) + '/' + str.tostring(month) + '/' + str.tostring(dayofmonth)
[_ath, _drawdown] = f_get_ath_and_drawdown(ath, high)
ath := _ath
index = math.min(math.max(math.round(_drawdown / CELLRANGE), 0), i_numberOfRanges - 1)
array.set(p_athDistanceRange, index, array.get(p_athDistanceRange, index) + 1)
var DISPLAY = table.new(position=i_tablePosition, columns=COLUMNS * 2 + 1, rows=ROWS, border_width=1)
maxRange = array.max(p_athDistanceRange)
minRange = array.min(p_athDistanceRange)
for _i = i_numberOfRanges - 1 to 0 by 1
if minRange != 0
break
minRange := array.min(array.slice(p_athDistanceRange, 0, _i))
minRange
table.cell(table_id=DISPLAY, column=0, row=0, text=dateStart + ' to ' + dateEnd, bgcolor=color.teal, text_color=color.white, text_size=i_text_size)
table.cell(table_id=DISPLAY, column=0, row=1, text=syminfo.tickerid, bgcolor=color.teal, text_color=color.white, text_size=i_text_size)
for _i = 0 to i_numberOfRanges - 1 by 1
_presentRangeTotal = array.get(p_athDistanceRange, _i)
_rangeSum = array.sum(p_athDistanceRange)
_row = (_i - _i % DIVISOR) / DIVISOR
_columnHeader = 2 * (_i % DIVISOR)
_column = _columnHeader + 1
_range_start = ROWRANGE * _row + CELLRANGE * _columnHeader / 2
_range_next = ROWRANGE * _row + CELLRANGE * (_columnHeader / 2 + 1)
_rangePercentage = math.round(_presentRangeTotal / _rangeSum * 100, 2)
_before = array.slice(p_athDistanceRange, 0, _i + 1)
_rangePercentile = math.round(array.sum(_before) * 100 / _rangeSum, 2)
_cellColor = index == _i ? i_presentColor : maxRange == _presentRangeTotal ? i_maxColor : minRange == _presentRangeTotal ? i_minColor : i_neutralColor
_percentDisplay = i_percentile ? _rangePercentile : _rangePercentage
if _percentDisplay != 0 and (_percentDisplay != 100 or _cellColor != i_neutralColor)
if i_displayRangeHeader
headerText = (i_percentile ? '0' : str.tostring(_range_start)) + ' - ' + str.tostring(_range_next)
table.cell(table_id=DISPLAY, column=_columnHeader + 1, row=_row, text=headerText, bgcolor=i_headerColor, text_color=color.white, text_size=i_text_size)
table.cell(table_id=DISPLAY, column=_column + 1, row=_row, text=str.tostring(_percentDisplay), bgcolor=_cellColor, text_color=color.black, text_size=i_text_size)
|
MTF Candlestick Patterns Screening [tanayroy] | https://www.tradingview.com/script/uvZiRkSh-MTF-Candlestick-Patterns-Screening-tanayroy/ | tanayroy | https://www.tradingview.com/u/tanayroy/ | 286 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tanayroy
//@version=4
study("MTF Candlestick Patterns Screening [tanayroy]",shorttitle='MTF Candles', overlay=true)
var trendRule1 = "SMA50"
var trendRule2 = "SMA50, SMA200"
var trendRule = input(trendRule1, "Detect Trend Based On", options=[trendRule1, trendRule2, "No detection"])
detect_trend = trendRule==trendRule1?1:trendRule==trendRule2?2:0
candle_range = input(7,title='Lookback Bars',type=input.integer,minval=1)
AbandonedBabyInput = input(title = "Abandoned Baby" ,defval=true)
DarkCloudCoverInput = input(title = "Dark Cloud Cover" ,defval=true)
DojiInput = input(title = "Doji" ,defval=true)
DojiStarInput = input(title = "Doji Star" ,defval=true)
DownsideTasukiGapInput = input(title = "Downside Tasuki Gap" ,defval=true)
DragonflyDojiInput = input(title = "Dragonfly Doji" ,defval=true)
EngulfingInput = input(title = "Engulfing" ,defval=true)
EveningDojiStarInput = input(title = "Evening Doji Star" ,defval=true)
EveningStarInput = input(title = "Evening Star" ,defval=true)
FallingThreeMethodsInput = input(title = "Falling Three Methods" ,defval=true)
FallingWindowInput = input(title = "Falling Window" ,defval=true)
GravestoneDojiInput = input(title = "Gravestone Doji" ,defval=true)
HammerInput = input(title = "Hammer" ,defval=true)
HangingManInput = input(title = "Hanging Man" ,defval=true)
HaramiCrossInput = input(title = "Harami Cross" ,defval=true)
HaramiInput = input(title = "Harami" ,defval=true)
InvertedHammerInput = input(title = "Inverted Hammer" ,defval=true)
KickingInput = input(title = "Kicking" ,defval=true)
LongLowerShadowInput = input(title = "Long Lower Shadow" ,defval=true)
LongUpperShadowInput = input(title = "Long Upper Shadow" ,defval=true)
MarubozuBlackInput = input(title = "Marubozu Black" ,defval=true)
MarubozuWhiteInput = input(title = "Marubozu White" ,defval=true)
MorningDojiStarInput = input(title = "Morning Doji Star" ,defval=true)
MorningStarInput = input(title = "Morning Star" ,defval=true)
OnNeckInput = input(title = "On Neck" ,defval=true)
PiercingInput = input(title = "Piercing" ,defval=true)
RisingThreeMethodsInput = input(title = "Rising Three Methods" ,defval=true)
RisingWindowInput = input(title = "Rising Window" ,defval=true)
ShootingStarInput = input(title = "Shooting Star" ,defval=true)
SpinningTopBlackInput = input(title = "Spinning Top Black" ,defval=true)
SpinningTopWhiteInput = input(title = "Spinning Top White" ,defval=true)
ThreeBlackCrowsInput = input(title = "Three Black Crows" ,defval=true)
ThreeWhiteSoldiersInput = input(title = "Three White Soldiers" ,defval=true)
TriStarInput = input(title = "Tri-Star" ,defval=true)
TweezerBottomInput = input(title = "Tweezer Bottom" ,defval=true)
TweezerTopInput = input(title = "Tweezer Top" ,defval=true)
UpsideTasukiGapInput = input(title = "Upside Tasuki Gap" ,defval=true)
//all bullish pattern
//"Rising Window – Bullish","Rising Three Methods – Bullish","Tweezer Bottom – Bullish","Upside Tasuki Gap – Bullish","Doji Star – Bullish",
//"Morning Doji Star – Bullish","Piercing – Bullish","Hammer – Bullish","Inverted Hammer – Bullish","Morning Star – Bullish","Marubozu White – Bullish",
//"Dragonfly Doji – Bullish","Harami Cross – Bullish","Harami – Bullish","Long Lower Shadow – Bullish","Three White Soldiers – Bullish","Engulfing – Bullish",
//"Abandoned Baby – Bullish","Tri-Star – Bullish","Kicking – Bullish"
//All bearish pattern
//"On Neck – Bearish","Falling Window – Bearish","Falling Three Methods – Bearish",
//"Tweezer Top – Bearish","Dark Cloud Cover – Bearish","Downside Tasuki Gap – Bearish","Evening Doji Star – Bearish","Doji Star – Bearish",
//"Hanging Man – Bearish","Shooting Star – Bearish","Evening Star – Bearish","Marubozu Black – Bearish","Gravestone Doji – Bearish",
//"Harami Cross – Bearish","Harami – Bearish","Long Upper Shadow – Bearish","Three Black Crows – Bearish","Engulfing – Bearish","Abandoned Baby – Bearish",
//"Tri-Star – Bearish","Kicking – Bearish"
//All neutral
//"Doji","Spinning Top White","Spinning Top Black"
candle_pattern_name = array.from("Rising Window – Bullish","Rising Three Methods – Bullish","Tweezer Bottom – Bullish","Upside Tasuki Gap – Bullish",
"Doji Star – Bullish","Morning Doji Star – Bullish","Piercing – Bullish","Hammer – Bullish","Inverted Hammer – Bullish","Morning Star – Bullish","Marubozu White – Bullish",
"Dragonfly Doji – Bullish","Harami Cross – Bullish","Harami – Bullish","Long Lower Shadow – Bullish","Three White Soldiers – Bullish","Engulfing – Bullish",
"Abandoned Baby – Bullish","Tri-Star – Bullish","Kicking – Bullish","On Neck – Bearish","Falling Window – Bearish","Falling Three Methods – Bearish",
"Tweezer Top – Bearish","Dark Cloud Cover – Bearish","Downside Tasuki Gap – Bearish","Evening Doji Star – Bearish","Doji Star – Bearish",
"Hanging Man – Bearish","Shooting Star – Bearish","Evening Star – Bearish","Marubozu Black – Bearish","Gravestone Doji – Bearish",
"Harami Cross – Bearish","Harami – Bearish","Long Upper Shadow – Bearish","Three Black Crows – Bearish","Engulfing – Bearish","Abandoned Baby – Bearish",
"Tri-Star – Bearish","Kicking – Bearish","Doji","Spinning Top White","Spinning Top Black")
var a5_mint_candle_array = array.new_bool(44)
var a15_mint_candle_array = array.new_bool(44)
var a30_mint_candle_array = array.new_bool(44)
var a1_hr_candle_array=array.new_bool(44)
var a2_hr_candle_array=array.new_bool(44)
var a4_hr_candle_array=array.new_bool(44)
var ad_candle_array=array.new_bool(44)
var aw_candle_array=array.new_bool(44)
var am_candle_array=array.new_bool(44)
var a5_mint_candle_array_bar=array.new_int(44)
var a15_mint_candle_array_bar=array.new_int(44)
var a30_mint_candle_array_bar=array.new_int(44)
var a1_hr_candle_array_bar=array.new_int(44)
var a2_hr_candle_array_bar=array.new_int(44)
var a4_hr_candle_array_bar=array.new_int(44)
var ad_candle_array_bar=array.new_int(44)
var aw_candle_array_bar=array.new_int(44)
var am_candle_array_bar=array.new_int(44)
//get candle pattern
//taken from tradingview builtin candle pattern
f_detect_candle_patterns(trend_detection)=>
C_DownTrend = true
C_UpTrend = true
if detect_trend==1
priceAvg = sma(close, 50)
C_DownTrend := close < priceAvg
C_UpTrend := close > priceAvg
if detect_trend==2
sma200 = sma(close, 200)
sma50 = sma(close, 50)
C_DownTrend := close < sma50 and sma50 < sma200
C_UpTrend := close > sma50 and sma50 > sma200
C_Len = 14 // ema depth for bodyAvg
C_ShadowPercent = 5.0 // size of shadows
C_ShadowEqualsPercent = 100.0
C_DojiBodyPercent = 5.0
C_Factor = 2.0
C_BodyHi = max(close, open)
C_BodyLo = min(close, open)
C_Body = C_BodyHi - C_BodyLo
C_BodyAvg = ema(C_Body, C_Len)
C_SmallBody = C_Body < C_BodyAvg
C_LongBody = C_Body > C_BodyAvg
C_UpShadow = high - C_BodyHi
C_DnShadow = C_BodyLo - low
C_HasUpShadow = C_UpShadow > C_ShadowPercent / 100 * C_Body
C_HasDnShadow = C_DnShadow > C_ShadowPercent / 100 * C_Body
C_WhiteBody = open < close
C_BlackBody = open > close
C_Range = high-low
C_IsInsideBar = C_BodyHi[1] > C_BodyHi and C_BodyLo[1] < C_BodyLo
C_BodyMiddle = C_Body / 2 + C_BodyLo
C_ShadowEquals = C_UpShadow == C_DnShadow or (abs(C_UpShadow - C_DnShadow) / C_DnShadow * 100) < C_ShadowEqualsPercent
and (abs(C_DnShadow - C_UpShadow) / C_UpShadow * 100) < C_ShadowEqualsPercent
C_IsDojiBody = C_Range > 0 and C_Body <= C_Range * C_DojiBodyPercent / 100
C_Doji = C_IsDojiBody and C_ShadowEquals
//bullish patterns
//"Rising Window – Bullish"
C_RisingWindowBullish = false
if C_UpTrend[1] and (C_Range!=0 and C_Range[1]!=0) and low > high[1] and RisingWindowInput
C_RisingWindowBullish := true
//"Rising Three Methods – Bullish"
C_RisingThreeMethodsBullish = false
if C_UpTrend[4] and (C_LongBody[4] and C_WhiteBody[4]) and (C_SmallBody[3] and C_BlackBody[3] and open[3]<high[4]
and close[3]>low[4]) and (C_SmallBody[2] and C_BlackBody[2] and open[2]<high[4] and close[2]>low[4])
and (C_SmallBody[1] and C_BlackBody[1] and open[1]<high[4] and close[1]>low[4]) and (C_LongBody and C_WhiteBody and close>close[4]) and RisingThreeMethodsInput
C_RisingThreeMethodsBullish := true
//"Tweezer Bottom – Bullish"
C_TweezerBottomBullish = false
if C_UpTrend[1] and (not C_IsDojiBody or (C_HasUpShadow and C_HasDnShadow)) and abs(low-low[1]) <= C_BodyAvg*0.05
and C_BlackBody[1] and C_WhiteBody and C_LongBody[1] and TweezerBottomInput
C_TweezerBottomBullish := true
//"Upside Tasuki Gap – Bullish"
C_UpsideTasukiGapBullish = false
if C_LongBody[2] and C_SmallBody[1] and C_UpTrend and C_WhiteBody[2] and C_BodyLo[1] > C_BodyHi[2] and C_WhiteBody[1]
and C_BlackBody and C_BodyLo >= C_BodyHi[2] and C_BodyLo <= C_BodyLo[1] and UpsideTasukiGapInput
C_UpsideTasukiGapBullish := true
//"Doji Star – Bullish"
C_DojiStarBullish = false
if C_DownTrend and C_BlackBody[1] and C_LongBody[1] and C_IsDojiBody and C_BodyHi < C_BodyLo[1] and DojiStarInput
C_DojiStarBullish := true
//"Morning Doji Star – Bullish"
C_MorningDojiStarBullish = false
if C_LongBody[2] and C_IsDojiBody[1] and C_LongBody and C_DownTrend and C_BlackBody[2] and C_BodyHi[1] < C_BodyLo[2]
and C_WhiteBody and C_BodyHi >= C_BodyMiddle[2] and C_BodyHi < C_BodyHi[2] and C_BodyHi[1] < C_BodyLo and MorningDojiStarInput
C_MorningDojiStarBullish := true
//"Piercing – Bullish"
C_PiercingBullish = false
if (C_DownTrend[1] and C_BlackBody[1] and C_LongBody[1]) and (C_WhiteBody and open <= low[1] and close > C_BodyMiddle[1] and close < open[1])
C_PiercingBullish := true and PiercingInput
//"Hammer – Bullish"
C_HammerBullish = false
if C_SmallBody and C_Body > 0 and C_BodyLo > hl2 and C_DnShadow >= C_Factor * C_Body and not C_HasUpShadow and HammerInput
if C_DownTrend
C_HammerBullish := true
//"Inverted Hammer – Bullish"
C_InvertedHammerBullish = false
if C_SmallBody and C_Body > 0 and C_BodyHi < hl2 and C_UpShadow >= C_Factor * C_Body and not C_HasDnShadow and InvertedHammerInput
if C_DownTrend
C_InvertedHammerBullish := true
//"Morning Star – Bullish"
C_MorningStarBullish = false
if C_LongBody[2] and C_SmallBody[1] and C_LongBody and MorningStarInput
if C_DownTrend and C_BlackBody[2] and C_BodyHi[1] < C_BodyLo[2] and C_WhiteBody and C_BodyHi >= C_BodyMiddle[2]
and C_BodyHi < C_BodyHi[2] and C_BodyHi[1] < C_BodyLo
C_MorningStarBullish := true
//"Marubozu White – Bullish"
C_MarubozuShadowPercentWhite = 5.0
C_MarubozuWhiteBullish = C_WhiteBody and C_LongBody and C_UpShadow <= C_MarubozuShadowPercentWhite/100*C_Body and
C_DnShadow <= C_MarubozuShadowPercentWhite/100*C_Body and C_WhiteBody and MarubozuWhiteInput
//"Dragonfly Doji – Bullish"
C_DragonflyDojiBullish = C_IsDojiBody and C_UpShadow <= C_Body and DragonflyDojiInput
//"Harami Cross – Bullish"
C_HaramiCrossBullish = C_LongBody[1] and C_BlackBody[1] and C_DownTrend[1] and C_IsDojiBody and high <= C_BodyHi[1] and low >= C_BodyLo[1] and HaramiCrossInput
//"Harami – Bullish"
C_HaramiBullish = C_LongBody[1] and C_BlackBody[1] and C_DownTrend[1] and C_WhiteBody and C_SmallBody and high <= C_BodyHi[1] and low >= C_BodyLo[1] and HaramiInput
//"Long Lower Shadow – Bullish"
C_LongLowerShadowPercent = 75.0
C_LongLowerShadowBullish = C_DnShadow > C_Range/100*C_LongLowerShadowPercent and LongLowerShadowInput
//"Three White Soldiers – Bullish"
C_3WSld_ShadowPercent = 5.0
C_3WSld_HaveNotUpShadow = C_Range * C_3WSld_ShadowPercent / 100 > C_UpShadow
C_ThreeWhiteSoldiersBullish = false
if C_LongBody and C_LongBody[1] and C_LongBody[2]
if C_WhiteBody and C_WhiteBody[1] and C_WhiteBody[2]
C_ThreeWhiteSoldiersBullish := close > close[1] and close[1] > close[2] and open < close[1] and open > open[1]
and open[1] < close[2] and open[1] > open[2] and C_3WSld_HaveNotUpShadow and C_3WSld_HaveNotUpShadow[1] and C_3WSld_HaveNotUpShadow[2] and ThreeWhiteSoldiersInput
//"Engulfing – Bullish"
C_EngulfingBullish = C_DownTrend and C_WhiteBody and C_LongBody and C_BlackBody[1] and C_SmallBody[1] and
close >= open[1] and open <= close[1] and ( close > open[1] or open < close[1] ) and EngulfingInput
//"Abandoned Baby – Bullish"
C_AbandonedBabyBullish = C_DownTrend[2] and C_BlackBody[2] and C_IsDojiBody[1] and low[2] > high[1] and C_WhiteBody and high[1] < low and AbandonedBabyInput
//"Tri-Star – Bullish"
C_3DojisBullish = C_Doji[2] and C_Doji[1] and C_Doji
C_BodyGapUpBullish = C_BodyHi[1] < C_BodyLo
C_BodyGapDnBullish = C_BodyLo[1] > C_BodyHi
C_TriStarBullish = C_3DojisBullish and C_DownTrend[2] and C_BodyGapDnBullish[1] and C_BodyGapUpBullish and TriStarInput
//"Kicking – Bullish"
C_MarubozuShadowPercent = 5.0
C_Marubozu = C_LongBody and C_UpShadow <= C_MarubozuShadowPercent/100*C_Body and C_DnShadow <= C_MarubozuShadowPercent/100*C_Body
C_MarubozuWhiteBullishKicking = C_Marubozu and C_WhiteBody
C_MarubozuBlackBullish = C_Marubozu and C_BlackBody
C_KickingBullish = C_MarubozuBlackBullish[1] and C_MarubozuWhiteBullishKicking and high[1] < low and KickingInput
//"On Neck – Bearish"
C_OnNeckBearish = false
if C_DownTrend and C_BlackBody[1] and C_LongBody[1] and C_WhiteBody and open < close[1] and C_SmallBody and C_Range!=0 and abs(close-low[1])<=C_BodyAvg*0.05
C_OnNeckBearish := true and OnNeckInput
//"Falling Window – Bearish"
C_FallingWindowBearish = false
if C_DownTrend[1] and (C_Range!=0 and C_Range[1]!=0) and high < low[1]
C_FallingWindowBearish := true and FallingWindowInput
//"Falling Three Methods – Bearish"
C_FallingThreeMethodsBearish = false
if C_DownTrend[4] and (C_LongBody[4] and C_BlackBody[4]) and (C_SmallBody[3] and C_WhiteBody[3] and open[3]>low[4]
and close[3]<high[4]) and (C_SmallBody[2] and C_WhiteBody[2] and open[2]>low[4] and close[2]<high[4]) and (C_SmallBody[1]
and C_WhiteBody[1] and open[1]>low[4] and close[1]<high[4]) and (C_LongBody and C_BlackBody and close<close[4]) and FallingThreeMethodsInput
C_FallingThreeMethodsBearish := true
//"Tweezer Top – Bearish"
C_TweezerTopBearish = false
if C_UpTrend[1] and (not C_IsDojiBody or (C_HasUpShadow and C_HasDnShadow)) and abs(high-high[1]) <= C_BodyAvg*0.05
and C_WhiteBody[1] and C_BlackBody and C_LongBody[1] and TweezerTopInput
C_TweezerTopBearish := true
//"Dark Cloud Cover – Bearish"
C_DarkCloudCoverBearish = false
if (C_UpTrend[1] and C_WhiteBody[1] and C_LongBody[1]) and (C_BlackBody and open >= high[1] and close < C_BodyMiddle[1] and close > open[1])
C_DarkCloudCoverBearish := true and DarkCloudCoverInput
//"Downside Tasuki Gap – Bearish"
C_DownsideTasukiGapBearish = false
if C_LongBody[2] and C_SmallBody[1] and C_DownTrend and C_BlackBody[2] and C_BodyHi[1] < C_BodyLo[2] and C_BlackBody[1]
and C_WhiteBody and C_BodyHi <= C_BodyLo[2] and C_BodyHi >= C_BodyHi[1] and DownsideTasukiGapInput
C_DownsideTasukiGapBearish := true
//"Evening Doji Star – Bearish"
C_EveningDojiStarBearish = false
if C_LongBody[2] and C_IsDojiBody[1] and C_LongBody and C_UpTrend and C_WhiteBody[2] and C_BodyLo[1] > C_BodyHi[2]
and C_BlackBody and C_BodyLo <= C_BodyMiddle[2] and C_BodyLo > C_BodyLo[2] and C_BodyLo[1] > C_BodyHi and EveningDojiStarInput
C_EveningDojiStarBearish := true
//"Doji Star – Bearish"
C_DojiStarBearish = false
if C_UpTrend and C_WhiteBody[1] and C_LongBody[1] and C_IsDojiBody and C_BodyLo > C_BodyHi[1] and DojiStarInput
C_DojiStarBearish := true
//"Hanging Man – Bearish"
C_HangingManBearish = false
if C_SmallBody and C_Body > 0 and C_BodyLo > hl2 and C_DnShadow >= C_Factor * C_Body and not C_HasUpShadow and HangingManInput
if C_UpTrend
C_HangingManBearish := true
//"Shooting Star – Bearish"
C_ShootingStarBearish = false
if C_SmallBody and C_Body > 0 and C_BodyHi < hl2 and C_UpShadow >= C_Factor * C_Body and not C_HasDnShadow and ShootingStarInput
if C_UpTrend
C_ShootingStarBearish := true
//"Evening Star – Bearish"
C_EveningStarBearish = false
if C_LongBody[2] and C_SmallBody[1] and C_LongBody and EveningStarInput
if C_UpTrend and C_WhiteBody[2] and C_BodyLo[1] > C_BodyHi[2] and C_BlackBody and C_BodyLo <= C_BodyMiddle[2]
and C_BodyLo > C_BodyLo[2] and C_BodyLo[1] > C_BodyHi
C_EveningStarBearish := true
//"Marubozu Black – Bearish"
C_MarubozuShadowPercentBearish = 5.0
C_MarubozuBlackBearish = C_BlackBody and C_LongBody and C_UpShadow <= C_MarubozuShadowPercentBearish/100*C_Body
and C_DnShadow <= C_MarubozuShadowPercentBearish/100*C_Body and C_BlackBody and MarubozuBlackInput
//"Gravestone Doji – Bearish"
C_GravestoneDojiBearish = C_IsDojiBody and C_DnShadow <= C_Body and GravestoneDojiInput
//"Harami Cross – Bearish"
C_HaramiCrossBearish = C_LongBody[1] and C_WhiteBody[1] and C_UpTrend[1] and C_IsDojiBody and high <= C_BodyHi[1] and low >= C_BodyLo[1] and HaramiCrossInput
//"Harami – Bearish"
C_HaramiBearish = C_LongBody[1] and C_WhiteBody[1] and C_UpTrend[1] and C_BlackBody and C_SmallBody and high <= C_BodyHi[1] and low >= C_BodyLo[1]
and HaramiInput
//"Long Upper Shadow – Bearish"
C_LongShadowPercent = 75.0
C_LongUpperShadowBearish = C_UpShadow > C_Range/100*C_LongShadowPercent and LongUpperShadowInput
//"Three Black Crows – Bearish"
C_3BCrw_ShadowPercent = 5.0
C_3BCrw_HaveNotDnShadow = C_Range * C_3BCrw_ShadowPercent / 100 > C_DnShadow
C_ThreeBlackCrowsBearish = false
if C_LongBody and C_LongBody[1] and C_LongBody[2] and ThreeBlackCrowsInput
if C_BlackBody and C_BlackBody[1] and C_BlackBody[2]
C_ThreeBlackCrowsBearish := close < close[1] and close[1] < close[2] and open > close[1] and open < open[1]
and open[1] > close[2] and open[1] < open[2] and C_3BCrw_HaveNotDnShadow and C_3BCrw_HaveNotDnShadow[1] and C_3BCrw_HaveNotDnShadow[2]
//"Engulfing – Bearish"
C_EngulfingBearish = C_UpTrend and C_BlackBody and C_LongBody and C_WhiteBody[1] and C_SmallBody[1] and close <= open[1]
and open >= close[1] and ( close < open[1] or open > close[1] ) and EngulfingInput
//"Abandoned Baby – Bearish"
C_AbandonedBabyBearish = C_UpTrend[2] and C_WhiteBody[2] and C_IsDojiBody[1] and high[2] < low[1] and C_BlackBody and low[1] > high and AbandonedBabyInput
//"Tri-Star – Bearish"
C_3Dojis = C_Doji[2] and C_Doji[1] and C_Doji
C_BodyGapUp = C_BodyHi[1] < C_BodyLo
C_BodyGapDn = C_BodyLo[1] > C_BodyHi
C_TriStarBearish = C_3Dojis and C_UpTrend[2] and C_BodyGapUp[1] and C_BodyGapDn and TriStarInput
//"Kicking – Bearish"
C_MarubozuBullishShadowPercent = 5.0
C_MarubozuBearishKicking = C_LongBody and C_UpShadow <= C_MarubozuBullishShadowPercent/100*C_Body
and C_DnShadow <= C_MarubozuBullishShadowPercent/100*C_Body
C_MarubozuWhiteBearish = C_MarubozuBearishKicking and C_WhiteBody
C_MarubozuBlackBearishKicking = C_MarubozuBearishKicking and C_BlackBody
C_KickingBearish = C_MarubozuWhiteBearish[1] and C_MarubozuBlackBearishKicking and low[1] > high and KickingInput
//"Doji"
C_DragonflyDoji = C_IsDojiBody and C_UpShadow <= C_Body
C_GravestoneDojiOne = C_IsDojiBody and C_DnShadow <= C_Body
CN_doji=C_Doji and not C_DragonflyDoji and not C_GravestoneDojiOne and DojiInput
//"Spinning Top White"
C_SpinningTopWhitePercent = 34.0
C_IsSpinningTopWhite = C_DnShadow >= C_Range / 100 * C_SpinningTopWhitePercent and C_UpShadow >= C_Range / 100 * C_SpinningTopWhitePercent
and not C_IsDojiBody
C_SpinningTopWhite = C_IsSpinningTopWhite and C_WhiteBody and SpinningTopWhiteInput
//"Spinning Top Black"
C_SpinningTopBlackPercent = 34.0
C_IsSpinningTop = C_DnShadow >= C_Range / 100 * C_SpinningTopBlackPercent and C_UpShadow >= C_Range / 100 * C_SpinningTopBlackPercent
and not C_IsDojiBody
C_SpinningTopBlack = C_IsSpinningTop and C_BlackBody and SpinningTopBlackInput
barEndTime = time_close
[C_RisingWindowBullish,C_RisingThreeMethodsBullish,C_TweezerBottomBullish,C_UpsideTasukiGapBullish,C_DojiStarBullish,
C_MorningDojiStarBullish ,C_PiercingBullish,C_HammerBullish,C_InvertedHammerBullish,C_MorningStarBullish,
C_MarubozuWhiteBullish,C_DragonflyDojiBullish,C_HaramiCrossBullish,C_HaramiBullish,C_LongLowerShadowBullish,
C_ThreeWhiteSoldiersBullish,C_EngulfingBullish,C_AbandonedBabyBullish,C_TriStarBullish,C_KickingBullish ,
C_OnNeckBearish,C_FallingWindowBearish,C_FallingThreeMethodsBearish,C_TweezerTopBearish,C_DarkCloudCoverBearish,
C_DownsideTasukiGapBearish,C_EveningDojiStarBearish,C_DojiStarBearish,C_HangingManBearish,
C_ShootingStarBearish,C_EveningStarBearish,C_MarubozuBlackBearish,C_GravestoneDojiBearish,
C_HaramiCrossBearish,C_HaramiBearish,C_LongUpperShadowBearish,C_ThreeBlackCrowsBearish,
C_EngulfingBearish,C_AbandonedBabyBearish,C_TriStarBearish,C_KickingBearish,
CN_doji,C_SpinningTopWhite,C_SpinningTopBlack,
barEndTime,bar_index]
//set array
f_set_array(array_name,bar_array_name,C_RisingWindowBullish,C_RisingThreeMethodsBullish,C_TweezerBottomBullish,C_UpsideTasukiGapBullish,C_DojiStarBullish,
C_MorningDojiStarBullish ,C_PiercingBullish,C_HammerBullish,C_InvertedHammerBullish,C_MorningStarBullish,
C_MarubozuWhiteBullish,C_DragonflyDojiBullish,C_HaramiCrossBullish,C_HaramiBullish,C_LongLowerShadowBullish,
C_ThreeWhiteSoldiersBullish,C_EngulfingBullish,C_AbandonedBabyBullish,C_TriStarBullish,C_KickingBullish ,
C_OnNeckBearish,C_FallingWindowBearish,C_FallingThreeMethodsBearish,C_TweezerTopBearish,C_DarkCloudCoverBearish,
C_DownsideTasukiGapBearish,C_EveningDojiStarBearish,C_DojiStarBearish,C_HangingManBearish,
C_ShootingStarBearish,C_EveningStarBearish,C_MarubozuBlackBearish,C_GravestoneDojiBearish,
C_HaramiCrossBearish,C_HaramiBearish,C_LongUpperShadowBearish,C_ThreeBlackCrowsBearish,
C_EngulfingBearish,C_AbandonedBabyBearish,C_TriStarBearish,C_KickingBearish,
CN_doji,C_SpinningTopWhite,C_SpinningTopBlack,
barEndTime,barindex)=>
if C_RisingWindowBullish
array.set(array_name,0,C_RisingWindowBullish)
array.set(bar_array_name,0,barindex)
if C_RisingThreeMethodsBullish
array.set(array_name,1,C_RisingThreeMethodsBullish)
array.set(bar_array_name,1,barindex)
if C_TweezerBottomBullish
array.set(array_name,2,C_TweezerBottomBullish)
array.set(bar_array_name,2,barindex)
if C_UpsideTasukiGapBullish
array.set(array_name,3,C_UpsideTasukiGapBullish)
array.set(bar_array_name,3,barindex)
if C_DojiStarBullish
array.set(array_name,4,C_DojiStarBullish)
array.set(bar_array_name,4,barindex)
if C_MorningDojiStarBullish
array.set(array_name,5,C_MorningDojiStarBullish)
array.set(bar_array_name,5,barindex)
if C_PiercingBullish
array.set(array_name,6,C_PiercingBullish)
array.set(bar_array_name,6,barindex)
if C_HammerBullish
array.set(array_name,7,C_HammerBullish)
array.set(bar_array_name,7,barindex)
if C_InvertedHammerBullish
array.set(array_name,8,C_InvertedHammerBullish)
array.set(bar_array_name,8,barindex)
if C_MorningStarBullish
array.set(array_name,9,C_MorningStarBullish)
array.set(bar_array_name,9,barindex)
if C_MarubozuWhiteBullish
array.set(array_name,10,C_MarubozuWhiteBullish)
array.set(bar_array_name,10,barindex)
if C_DragonflyDojiBullish
array.set(array_name,11,C_DragonflyDojiBullish)
array.set(bar_array_name,11,barindex)
if C_HaramiCrossBullish
array.set(array_name,12,C_HaramiCrossBullish)
array.set(bar_array_name,12,barindex)
if C_HaramiBullish
array.set(array_name,13,C_HaramiBullish)
array.set(bar_array_name,13,barindex)
if C_LongLowerShadowBullish
array.set(array_name,14,C_LongLowerShadowBullish)
array.set(bar_array_name,14,barindex)
if C_ThreeWhiteSoldiersBullish
array.set(array_name,15,C_ThreeWhiteSoldiersBullish)
array.set(bar_array_name,15,barindex)
if C_EngulfingBullish
array.set(array_name,16,C_EngulfingBullish)
array.set(bar_array_name,16,barindex)
if C_AbandonedBabyBullish
array.set(array_name,17,C_AbandonedBabyBullish)
array.set(bar_array_name,17,barindex)
if C_TriStarBullish
array.set(array_name,18,C_TriStarBullish)
array.set(bar_array_name,18,barindex)
if C_KickingBullish
array.set(array_name,19,C_KickingBullish )
array.set(bar_array_name,19,barindex)
if C_OnNeckBearish
array.set(array_name,20,C_OnNeckBearish)
array.set(bar_array_name,20,barindex)
if C_FallingWindowBearish
array.set(array_name,21,C_FallingWindowBearish)
array.set(bar_array_name,21,barindex)
if C_FallingThreeMethodsBearish
array.set(array_name,22,C_FallingThreeMethodsBearish)
array.set(bar_array_name,22,barindex)
if C_TweezerTopBearish
array.set(array_name,23,C_TweezerTopBearish)
array.set(bar_array_name,23,barindex)
if C_DarkCloudCoverBearish
array.set(array_name,24,C_DarkCloudCoverBearish )
array.set(bar_array_name,24,barindex)
if C_DownsideTasukiGapBearish
array.set(array_name,25,C_DownsideTasukiGapBearish)
array.set(bar_array_name,25,barindex)
if C_EveningDojiStarBearish
array.set(array_name,26,C_EveningDojiStarBearish)
array.set(bar_array_name,26,barindex)
if C_DojiStarBearish
array.set(array_name,27,C_DojiStarBearish)
array.set(bar_array_name,27,barindex)
if C_HangingManBearish
array.set(array_name,28,C_HangingManBearish)
array.set(bar_array_name,28,barindex)
if C_ShootingStarBearish
array.set(array_name,29,C_ShootingStarBearish)
array.set(bar_array_name,29,barindex)
if C_EveningStarBearish
array.set(array_name,30,C_EveningStarBearish)
array.set(bar_array_name,30,barindex)
if C_MarubozuBlackBearish
array.set(array_name,31,C_MarubozuBlackBearish)
array.set(bar_array_name,31,barindex)
if C_GravestoneDojiBearish
array.set(array_name,32,C_GravestoneDojiBearish)
array.set(bar_array_name,32,barindex)
if C_HaramiCrossBearish
array.set(array_name,33,C_HaramiCrossBearish)
array.set(bar_array_name,33,barindex)
if C_HaramiBearish
array.set(array_name,34,C_HaramiBearish)
array.set(bar_array_name,34,barindex)
if C_LongUpperShadowBearish
array.set(array_name,35,C_LongUpperShadowBearish)
array.set(bar_array_name,35,barindex)
if C_ThreeBlackCrowsBearish
array.set(array_name,36,C_ThreeBlackCrowsBearish)
array.set(bar_array_name,36,barindex)
if C_EngulfingBearish
array.set(array_name,37,C_EngulfingBearish)
array.set(bar_array_name,37,barindex)
if C_AbandonedBabyBearish
array.set(array_name,38,C_AbandonedBabyBearish)
array.set(bar_array_name,38,barindex)
if C_TriStarBearish
array.set(array_name,39,C_TriStarBearish)
array.set(bar_array_name,39,barindex)
if C_KickingBearish
array.set(array_name,40,C_KickingBearish)
array.set(bar_array_name,40,barindex)
if CN_doji
array.set(array_name,41,CN_doji)
array.set(bar_array_name,41,barindex)
if C_SpinningTopWhite
array.set(array_name,42,C_SpinningTopWhite)
array.set(bar_array_name,42,barindex)
if C_SpinningTopBlack
array.set(array_name,43,C_SpinningTopBlack)
array.set(bar_array_name,43,barindex)
[C_RisingWindowBullish,C_RisingThreeMethodsBullish,C_TweezerBottomBullish,C_UpsideTasukiGapBullish,C_DojiStarBullish,
C_MorningDojiStarBullish ,C_PiercingBullish,C_HammerBullish,C_InvertedHammerBullish,C_MorningStarBullish,
C_MarubozuWhiteBullish,C_DragonflyDojiBullish,C_HaramiCrossBullish,C_HaramiBullish,C_LongLowerShadowBullish,
C_ThreeWhiteSoldiersBullish,C_EngulfingBullish,C_AbandonedBabyBullish,C_TriStarBullish,C_KickingBullish ,
C_OnNeckBearish,C_FallingWindowBearish,C_FallingThreeMethodsBearish,C_TweezerTopBearish,C_DarkCloudCoverBearish,
C_DownsideTasukiGapBearish,C_EveningDojiStarBearish,C_DojiStarBearish,C_HangingManBearish,
C_ShootingStarBearish,C_EveningStarBearish,C_MarubozuBlackBearish,C_GravestoneDojiBearish,
C_HaramiCrossBearish,C_HaramiBearish,C_LongUpperShadowBearish,C_ThreeBlackCrowsBearish,
C_EngulfingBearish,C_AbandonedBabyBearish,C_TriStarBearish,C_KickingBearish,
CN_doji,C_SpinningTopWhite,C_SpinningTopBlack,
barEndTime,barindex ]=security(syminfo.tickerid,'5',f_detect_candle_patterns(detect_trend))
f_set_array(a5_mint_candle_array,a5_mint_candle_array_bar,C_RisingWindowBullish,C_RisingThreeMethodsBullish,
C_TweezerBottomBullish,C_UpsideTasukiGapBullish,C_DojiStarBullish,
C_MorningDojiStarBullish ,C_PiercingBullish,C_HammerBullish,C_InvertedHammerBullish,C_MorningStarBullish,
C_MarubozuWhiteBullish,C_DragonflyDojiBullish,C_HaramiCrossBullish,C_HaramiBullish,C_LongLowerShadowBullish,
C_ThreeWhiteSoldiersBullish,C_EngulfingBullish,C_AbandonedBabyBullish,C_TriStarBullish,C_KickingBullish ,
C_OnNeckBearish,C_FallingWindowBearish,C_FallingThreeMethodsBearish,C_TweezerTopBearish,C_DarkCloudCoverBearish,
C_DownsideTasukiGapBearish,C_EveningDojiStarBearish,C_DojiStarBearish,C_HangingManBearish,
C_ShootingStarBearish,C_EveningStarBearish,C_MarubozuBlackBearish,C_GravestoneDojiBearish,
C_HaramiCrossBearish,C_HaramiBearish,C_LongUpperShadowBearish,C_ThreeBlackCrowsBearish,
C_EngulfingBearish,C_AbandonedBabyBearish,C_TriStarBearish,C_KickingBearish,
CN_doji,C_SpinningTopWhite,C_SpinningTopBlack,
barEndTime,barindex)
[C_15RisingWindowBullish,C_15RisingThreeMethodsBullish,C_15TweezerBottomBullish,C_15UpsideTasukiGapBullish,C_15DojiStarBullish,
C_15MorningDojiStarBullish ,C_15PiercingBullish,C_15HammerBullish,C_15InvertedHammerBullish,C_15MorningStarBullish,
C_15MarubozuWhiteBullish,C_15DragonflyDojiBullish,C_15HaramiCrossBullish,C_15HaramiBullish,C_15LongLowerShadowBullish,
C_15ThreeWhiteSoldiersBullish,C_15EngulfingBullish,C_15AbandonedBabyBullish,C_15TriStarBullish,C_15KickingBullish ,
C_15OnNeckBearish,C_15FallingWindowBearish,C_15FallingThreeMethodsBearish,C_15TweezerTopBearish,C_15DarkCloudCoverBearish,
C_15DownsideTasukiGapBearish,C_15EveningDojiStarBearish,C_15DojiStarBearish,C_15HangingManBearish,
C_15ShootingStarBearish,C_15EveningStarBearish,C_15MarubozuBlackBearish,C_15GravestoneDojiBearish,
C_15HaramiCrossBearish,C_15HaramiBearish,C_15LongUpperShadowBearish,C_15ThreeBlackCrowsBearish,
C_15EngulfingBearish,C_15AbandonedBabyBearish,C_15TriStarBearish,C_15KickingBearish,
CN15_doji,C15_SpinningTopWhite,C15_SpinningTopBlack,
barEndTime15,barindex15 ]=security(syminfo.tickerid,'15',f_detect_candle_patterns(detect_trend))
f_set_array(a15_mint_candle_array,a15_mint_candle_array_bar,C_15RisingWindowBullish,C_15RisingThreeMethodsBullish,
C_15TweezerBottomBullish,C_15UpsideTasukiGapBullish,C_15DojiStarBullish,
C_15MorningDojiStarBullish ,C_15PiercingBullish,C_15HammerBullish,C_15InvertedHammerBullish,C_15MorningStarBullish,
C_15MarubozuWhiteBullish,C_15DragonflyDojiBullish,C_15HaramiCrossBullish,C_15HaramiBullish,C_15LongLowerShadowBullish,
C_15ThreeWhiteSoldiersBullish,C_15EngulfingBullish,C_15AbandonedBabyBullish,C_15TriStarBullish,C_15KickingBullish ,
C_15OnNeckBearish,C_15FallingWindowBearish,C_15FallingThreeMethodsBearish,C_15TweezerTopBearish,C_15DarkCloudCoverBearish,
C_15DownsideTasukiGapBearish,C_15EveningDojiStarBearish,C_15DojiStarBearish,C_15HangingManBearish,
C_15ShootingStarBearish,C_15EveningStarBearish,C_15MarubozuBlackBearish,C_15GravestoneDojiBearish,
C_15HaramiCrossBearish,C_15HaramiBearish,C_15LongUpperShadowBearish,C_15ThreeBlackCrowsBearish,
C_15EngulfingBearish,C_15AbandonedBabyBearish,C_15TriStarBearish,C_15KickingBearish,
CN15_doji,C15_SpinningTopWhite,C15_SpinningTopBlack,
barEndTime15,barindex15)
[C_30RisingWindowBullish,C_30RisingThreeMethodsBullish,C_30TweezerBottomBullish,C_30UpsideTasukiGapBullish,C_30DojiStarBullish,
C_30MorningDojiStarBullish ,C_30PiercingBullish,C_30HammerBullish,C_30InvertedHammerBullish,C_30MorningStarBullish,
C_30MarubozuWhiteBullish,C_30DragonflyDojiBullish,C_30HaramiCrossBullish,C_30HaramiBullish,C_30LongLowerShadowBullish,
C_30ThreeWhiteSoldiersBullish,C_30EngulfingBullish,C_30AbandonedBabyBullish,C_30TriStarBullish,C_30KickingBullish ,
C_30OnNeckBearish,C_30FallingWindowBearish,C_30FallingThreeMethodsBearish,C_30TweezerTopBearish,C_30DarkCloudCoverBearish,
C_30DownsideTasukiGapBearish,C_30EveningDojiStarBearish,C_30DojiStarBearish,C_30HangingManBearish,
C_30ShootingStarBearish,C_30EveningStarBearish,C_30MarubozuBlackBearish,C_30GravestoneDojiBearish,
C_30HaramiCrossBearish,C_30HaramiBearish,C_30LongUpperShadowBearish,C_30ThreeBlackCrowsBearish,
C_30EngulfingBearish,C_30AbandonedBabyBearish,C_30TriStarBearish,C_30KickingBearish,
CN30_doji,C30_SpinningTopWhite,C30_SpinningTopBlack,
barEndTime30,barindex30 ]=security(syminfo.tickerid,'30',f_detect_candle_patterns(detect_trend))
f_set_array(a30_mint_candle_array,a30_mint_candle_array_bar,C_30RisingWindowBullish,C_30RisingThreeMethodsBullish,
C_30TweezerBottomBullish,C_30UpsideTasukiGapBullish,C_30DojiStarBullish,
C_30MorningDojiStarBullish ,C_30PiercingBullish,C_30HammerBullish,C_30InvertedHammerBullish,C_30MorningStarBullish,
C_30MarubozuWhiteBullish,C_30DragonflyDojiBullish,C_30HaramiCrossBullish,C_30HaramiBullish,C_30LongLowerShadowBullish,
C_30ThreeWhiteSoldiersBullish,C_30EngulfingBullish,C_30AbandonedBabyBullish,C_30TriStarBullish,C_30KickingBullish ,
C_30OnNeckBearish,C_30FallingWindowBearish,C_30FallingThreeMethodsBearish,C_30TweezerTopBearish,C_30DarkCloudCoverBearish,
C_30DownsideTasukiGapBearish,C_30EveningDojiStarBearish,C_30DojiStarBearish,C_30HangingManBearish,
C_30ShootingStarBearish,C_30EveningStarBearish,C_30MarubozuBlackBearish,C_30GravestoneDojiBearish,
C_30HaramiCrossBearish,C_30HaramiBearish,C_30LongUpperShadowBearish,C_30ThreeBlackCrowsBearish,
C_30EngulfingBearish,C_30AbandonedBabyBearish,C_30TriStarBearish,C_30KickingBearish,
CN30_doji,C30_SpinningTopWhite,C30_SpinningTopBlack,
barEndTime30,barindex30)
[C_1_hrRisingWindowBullish,C_1_hrRisingThreeMethodsBullish,C_1_hrTweezerBottomBullish,C_1_hrUpsideTasukiGapBullish,C_1_hrDojiStarBullish,
C_1_hrMorningDojiStarBullish ,C_1_hrPiercingBullish,C_1_hrHammerBullish,C_1_hrInvertedHammerBullish,C_1_hrMorningStarBullish,
C_1_hrMarubozuWhiteBullish,C_1_hrDragonflyDojiBullish,C_1_hrHaramiCrossBullish,C_1_hrHaramiBullish,C_1_hrLongLowerShadowBullish,
C_1_hrThreeWhiteSoldiersBullish,C_1_hrEngulfingBullish,C_1_hrAbandonedBabyBullish,C_1_hrTriStarBullish,C_1_hrKickingBullish ,
C_1_hrOnNeckBearish,C_1_hrFallingWindowBearish,C_1_hrFallingThreeMethodsBearish,C_1_hrTweezerTopBearish,C_1_hrDarkCloudCoverBearish,
C_1_hrDownsideTasukiGapBearish,C_1_hrEveningDojiStarBearish,C_1_hrDojiStarBearish,C_1_hrHangingManBearish,
C_1_hrShootingStarBearish,C_1_hrEveningStarBearish,C_1_hrMarubozuBlackBearish,C_1_hrGravestoneDojiBearish,
C_1_hrHaramiCrossBearish,C_1_hrHaramiBearish,C_1_hrLongUpperShadowBearish,C_1_hrThreeBlackCrowsBearish,
C_1_hrEngulfingBearish,C_1_hrAbandonedBabyBearish,C_1_hrTriStarBearish,C_1_hrKickingBearish,
CN1_hr_doji,C1_hr_SpinningTopWhite,C1_hr_SpinningTopBlack,
barEndTime1_hr,barindex1_hr ]=security(syminfo.tickerid,'60',f_detect_candle_patterns(detect_trend))
f_set_array(a1_hr_candle_array,a1_hr_candle_array_bar,C_1_hrRisingWindowBullish,C_1_hrRisingThreeMethodsBullish,
C_1_hrTweezerBottomBullish,C_1_hrUpsideTasukiGapBullish,C_1_hrDojiStarBullish,
C_1_hrMorningDojiStarBullish ,C_1_hrPiercingBullish,C_1_hrHammerBullish,C_1_hrInvertedHammerBullish,C_1_hrMorningStarBullish,
C_1_hrMarubozuWhiteBullish,C_1_hrDragonflyDojiBullish,C_1_hrHaramiCrossBullish,C_1_hrHaramiBullish,C_1_hrLongLowerShadowBullish,
C_1_hrThreeWhiteSoldiersBullish,C_1_hrEngulfingBullish,C_1_hrAbandonedBabyBullish,C_1_hrTriStarBullish,C_1_hrKickingBullish ,
C_1_hrOnNeckBearish,C_1_hrFallingWindowBearish,C_1_hrFallingThreeMethodsBearish,C_1_hrTweezerTopBearish,C_1_hrDarkCloudCoverBearish,
C_1_hrDownsideTasukiGapBearish,C_1_hrEveningDojiStarBearish,C_1_hrDojiStarBearish,C_1_hrHangingManBearish,
C_1_hrShootingStarBearish,C_1_hrEveningStarBearish,C_1_hrMarubozuBlackBearish,C_1_hrGravestoneDojiBearish,
C_1_hrHaramiCrossBearish,C_1_hrHaramiBearish,C_1_hrLongUpperShadowBearish,C_1_hrThreeBlackCrowsBearish,
C_1_hrEngulfingBearish,C_1_hrAbandonedBabyBearish,C_1_hrTriStarBearish,C_1_hrKickingBearish,
CN1_hr_doji,C1_hr_SpinningTopWhite,C1_hr_SpinningTopBlack,
barEndTime1_hr,barindex1_hr)
[C_2_hrRisingWindowBullish,C_2_hrRisingThreeMethodsBullish,C_2_hrTweezerBottomBullish,C_2_hrUpsideTasukiGapBullish,C_2_hrDojiStarBullish,
C_2_hrMorningDojiStarBullish ,C_2_hrPiercingBullish,C_2_hrHammerBullish,C_2_hrInvertedHammerBullish,C_2_hrMorningStarBullish,
C_2_hrMarubozuWhiteBullish,C_2_hrDragonflyDojiBullish,C_2_hrHaramiCrossBullish,C_2_hrHaramiBullish,C_2_hrLongLowerShadowBullish,
C_2_hrThreeWhiteSoldiersBullish,C_2_hrEngulfingBullish,C_2_hrAbandonedBabyBullish,C_2_hrTriStarBullish,C_2_hrKickingBullish ,
C_2_hrOnNeckBearish,C_2_hrFallingWindowBearish,C_2_hrFallingThreeMethodsBearish,C_2_hrTweezerTopBearish,C_2_hrDarkCloudCoverBearish,
C_2_hrDownsideTasukiGapBearish,C_2_hrEveningDojiStarBearish,C_2_hrDojiStarBearish,C_2_hrHangingManBearish,
C_2_hrShootingStarBearish,C_2_hrEveningStarBearish,C_2_hrMarubozuBlackBearish,C_2_hrGravestoneDojiBearish,
C_2_hrHaramiCrossBearish,C_2_hrHaramiBearish,C_2_hrLongUpperShadowBearish,C_2_hrThreeBlackCrowsBearish,
C_2_hrEngulfingBearish,C_2_hrAbandonedBabyBearish,C_2_hrTriStarBearish,C_2_hrKickingBearish,
CN2_hr_doji,C2_hr_SpinningTopWhite,C2_hr_SpinningTopBlack,
barEndTime2_hr,barindex2_hr ]=security(syminfo.tickerid,'120',f_detect_candle_patterns(detect_trend))
f_set_array(a2_hr_candle_array,a2_hr_candle_array_bar,C_2_hrRisingWindowBullish,C_2_hrRisingThreeMethodsBullish,
C_2_hrTweezerBottomBullish,C_2_hrUpsideTasukiGapBullish,C_2_hrDojiStarBullish,
C_2_hrMorningDojiStarBullish ,C_2_hrPiercingBullish,C_2_hrHammerBullish,C_2_hrInvertedHammerBullish,C_2_hrMorningStarBullish,
C_2_hrMarubozuWhiteBullish,C_2_hrDragonflyDojiBullish,C_2_hrHaramiCrossBullish,C_2_hrHaramiBullish,C_2_hrLongLowerShadowBullish,
C_2_hrThreeWhiteSoldiersBullish,C_2_hrEngulfingBullish,C_2_hrAbandonedBabyBullish,C_2_hrTriStarBullish,C_2_hrKickingBullish ,
C_2_hrOnNeckBearish,C_2_hrFallingWindowBearish,C_2_hrFallingThreeMethodsBearish,C_2_hrTweezerTopBearish,C_2_hrDarkCloudCoverBearish,
C_2_hrDownsideTasukiGapBearish,C_2_hrEveningDojiStarBearish,C_2_hrDojiStarBearish,C_2_hrHangingManBearish,
C_2_hrShootingStarBearish,C_2_hrEveningStarBearish,C_2_hrMarubozuBlackBearish,C_2_hrGravestoneDojiBearish,
C_2_hrHaramiCrossBearish,C_2_hrHaramiBearish,C_2_hrLongUpperShadowBearish,C_2_hrThreeBlackCrowsBearish,
C_2_hrEngulfingBearish,C_2_hrAbandonedBabyBearish,C_2_hrTriStarBearish,C_2_hrKickingBearish,
CN2_hr_doji,C2_hr_SpinningTopWhite,C2_hr_SpinningTopBlack,
barEndTime2_hr,barindex2_hr)
[C_4_hrRisingWindowBullish,C_4_hrRisingThreeMethodsBullish,C_4_hrTweezerBottomBullish,C_4_hrUpsideTasukiGapBullish,C_4_hrDojiStarBullish,
C_4_hrMorningDojiStarBullish ,C_4_hrPiercingBullish,C_4_hrHammerBullish,C_4_hrInvertedHammerBullish,C_4_hrMorningStarBullish,
C_4_hrMarubozuWhiteBullish,C_4_hrDragonflyDojiBullish,C_4_hrHaramiCrossBullish,C_4_hrHaramiBullish,C_4_hrLongLowerShadowBullish,
C_4_hrThreeWhiteSoldiersBullish,C_4_hrEngulfingBullish,C_4_hrAbandonedBabyBullish,C_4_hrTriStarBullish,C_4_hrKickingBullish ,
C_4_hrOnNeckBearish,C_4_hrFallingWindowBearish,C_4_hrFallingThreeMethodsBearish,C_4_hrTweezerTopBearish,C_4_hrDarkCloudCoverBearish,
C_4_hrDownsideTasukiGapBearish,C_4_hrEveningDojiStarBearish,C_4_hrDojiStarBearish,C_4_hrHangingManBearish,
C_4_hrShootingStarBearish,C_4_hrEveningStarBearish,C_4_hrMarubozuBlackBearish,C_4_hrGravestoneDojiBearish,
C_4_hrHaramiCrossBearish,C_4_hrHaramiBearish,C_4_hrLongUpperShadowBearish,C_4_hrThreeBlackCrowsBearish,
C_4_hrEngulfingBearish,C_4_hrAbandonedBabyBearish,C_4_hrTriStarBearish,C_4_hrKickingBearish,
CN4_hr_doji,C4_hr_SpinningTopWhite,C4_hr_SpinningTopBlack,
barEndTime4_hr,barindex4_hr ]=security(syminfo.tickerid,'240',f_detect_candle_patterns(detect_trend))
f_set_array(a4_hr_candle_array,a4_hr_candle_array_bar,C_4_hrRisingWindowBullish,C_4_hrRisingThreeMethodsBullish,
C_4_hrTweezerBottomBullish,C_4_hrUpsideTasukiGapBullish,C_4_hrDojiStarBullish,
C_4_hrMorningDojiStarBullish ,C_4_hrPiercingBullish,C_4_hrHammerBullish,C_4_hrInvertedHammerBullish,C_4_hrMorningStarBullish,
C_4_hrMarubozuWhiteBullish,C_4_hrDragonflyDojiBullish,C_4_hrHaramiCrossBullish,C_4_hrHaramiBullish,C_4_hrLongLowerShadowBullish,
C_4_hrThreeWhiteSoldiersBullish,C_4_hrEngulfingBullish,C_4_hrAbandonedBabyBullish,C_4_hrTriStarBullish,C_4_hrKickingBullish ,
C_4_hrOnNeckBearish,C_4_hrFallingWindowBearish,C_4_hrFallingThreeMethodsBearish,C_4_hrTweezerTopBearish,C_4_hrDarkCloudCoverBearish,
C_4_hrDownsideTasukiGapBearish,C_4_hrEveningDojiStarBearish,C_4_hrDojiStarBearish,C_4_hrHangingManBearish,
C_4_hrShootingStarBearish,C_4_hrEveningStarBearish,C_4_hrMarubozuBlackBearish,C_4_hrGravestoneDojiBearish,
C_4_hrHaramiCrossBearish,C_4_hrHaramiBearish,C_4_hrLongUpperShadowBearish,C_4_hrThreeBlackCrowsBearish,
C_4_hrEngulfingBearish,C_4_hrAbandonedBabyBearish,C_4_hrTriStarBearish,C_4_hrKickingBearish,
CN4_hr_doji,C4_hr_SpinningTopWhite,C4_hr_SpinningTopBlack,
barEndTime4_hr,barindex4_hr)
[C_dRisingWindowBullish,C_dRisingThreeMethodsBullish,C_dTweezerBottomBullish,C_dUpsideTasukiGapBullish,C_dDojiStarBullish,
C_dMorningDojiStarBullish ,C_dPiercingBullish,C_dHammerBullish,C_dInvertedHammerBullish,C_dMorningStarBullish,
C_dMarubozuWhiteBullish,C_dDragonflyDojiBullish,C_dHaramiCrossBullish,C_dHaramiBullish,C_dLongLowerShadowBullish,
C_dThreeWhiteSoldiersBullish,C_dEngulfingBullish,C_dAbandonedBabyBullish,C_dTriStarBullish,C_dKickingBullish ,
C_dOnNeckBearish,C_dFallingWindowBearish,C_dFallingThreeMethodsBearish,C_dTweezerTopBearish,C_dDarkCloudCoverBearish,
C_dDownsideTasukiGapBearish,C_dEveningDojiStarBearish,C_dDojiStarBearish,C_dHangingManBearish,
C_dShootingStarBearish,C_dEveningStarBearish,C_dMarubozuBlackBearish,C_dGravestoneDojiBearish,
C_dHaramiCrossBearish,C_dHaramiBearish,C_dLongUpperShadowBearish,C_dThreeBlackCrowsBearish,
C_dEngulfingBearish,C_dAbandonedBabyBearish,C_dTriStarBearish,C_dKickingBearish,
CNd_doji,Cd_SpinningTopWhite,Cd_SpinningTopBlack,
barEndTimed,barindexd ]=security(syminfo.tickerid,'D',f_detect_candle_patterns(detect_trend))
f_set_array(ad_candle_array,ad_candle_array_bar,C_dRisingWindowBullish,C_dRisingThreeMethodsBullish,
C_dTweezerBottomBullish,C_dUpsideTasukiGapBullish,C_dDojiStarBullish,
C_dMorningDojiStarBullish ,C_dPiercingBullish,C_dHammerBullish,C_dInvertedHammerBullish,C_dMorningStarBullish,
C_dMarubozuWhiteBullish,C_dDragonflyDojiBullish,C_dHaramiCrossBullish,C_dHaramiBullish,C_dLongLowerShadowBullish,
C_dThreeWhiteSoldiersBullish,C_dEngulfingBullish,C_dAbandonedBabyBullish,C_dTriStarBullish,C_dKickingBullish ,
C_dOnNeckBearish,C_dFallingWindowBearish,C_dFallingThreeMethodsBearish,C_dTweezerTopBearish,C_dDarkCloudCoverBearish,
C_dDownsideTasukiGapBearish,C_dEveningDojiStarBearish,C_dDojiStarBearish,C_dHangingManBearish,
C_dShootingStarBearish,C_dEveningStarBearish,C_dMarubozuBlackBearish,C_dGravestoneDojiBearish,
C_dHaramiCrossBearish,C_dHaramiBearish,C_dLongUpperShadowBearish,C_dThreeBlackCrowsBearish,
C_dEngulfingBearish,C_dAbandonedBabyBearish,C_dTriStarBearish,C_dKickingBearish,
CNd_doji,Cd_SpinningTopWhite,Cd_SpinningTopBlack,
barEndTimed,barindexd)
[C_wRisingWindowBullish,C_wRisingThreeMethodsBullish,C_wTweezerBottomBullish,C_wUpsideTasukiGapBullish,C_wDojiStarBullish,
C_wMorningDojiStarBullish ,C_wPiercingBullish,C_wHammerBullish,C_wInvertedHammerBullish,C_wMorningStarBullish,
C_wMarubozuWhiteBullish,C_wDragonflyDojiBullish,C_wHaramiCrossBullish,C_wHaramiBullish,C_wLongLowerShadowBullish,
C_wThreeWhiteSoldiersBullish,C_wEngulfingBullish,C_wAbandonedBabyBullish,C_wTriStarBullish,C_wKickingBullish ,
C_wOnNeckBearish,C_wFallingWindowBearish,C_wFallingThreeMethodsBearish,C_wTweezerTopBearish,C_wDarkCloudCoverBearish,
C_wDownsideTasukiGapBearish,C_wEveningDojiStarBearish,C_wDojiStarBearish,C_wHangingManBearish,
C_wShootingStarBearish,C_wEveningStarBearish,C_wMarubozuBlackBearish,C_wGravestoneDojiBearish,
C_wHaramiCrossBearish,C_wHaramiBearish,C_wLongUpperShadowBearish,C_wThreeBlackCrowsBearish,
C_wEngulfingBearish,C_wAbandonedBabyBearish,C_wTriStarBearish,C_wKickingBearish,
CNw_doji,Cw_SpinningTopWhite,Cw_SpinningTopBlack,
barEndTimew,barindexw ]=security(syminfo.tickerid,'W',f_detect_candle_patterns(detect_trend))
f_set_array(aw_candle_array,aw_candle_array_bar,C_wRisingWindowBullish,C_wRisingThreeMethodsBullish,
C_wTweezerBottomBullish,C_wUpsideTasukiGapBullish,C_wDojiStarBullish,
C_wMorningDojiStarBullish ,C_wPiercingBullish,C_wHammerBullish,C_wInvertedHammerBullish,C_wMorningStarBullish,
C_wMarubozuWhiteBullish,C_wDragonflyDojiBullish,C_wHaramiCrossBullish,C_wHaramiBullish,C_wLongLowerShadowBullish,
C_wThreeWhiteSoldiersBullish,C_wEngulfingBullish,C_wAbandonedBabyBullish,C_wTriStarBullish,C_wKickingBullish ,
C_wOnNeckBearish,C_wFallingWindowBearish,C_wFallingThreeMethodsBearish,C_wTweezerTopBearish,C_wDarkCloudCoverBearish,
C_wDownsideTasukiGapBearish,C_wEveningDojiStarBearish,C_wDojiStarBearish,C_wHangingManBearish,
C_wShootingStarBearish,C_wEveningStarBearish,C_wMarubozuBlackBearish,C_wGravestoneDojiBearish,
C_wHaramiCrossBearish,C_wHaramiBearish,C_wLongUpperShadowBearish,C_wThreeBlackCrowsBearish,
C_wEngulfingBearish,C_wAbandonedBabyBearish,C_wTriStarBearish,C_wKickingBearish,
CNw_doji,Cw_SpinningTopWhite,Cw_SpinningTopBlack,
barEndTimew,barindexw)
[C_mRisingWindowBullish,C_mRisingThreeMethodsBullish,C_mTweezerBottomBullish,C_mUpsideTasukiGapBullish,C_mDojiStarBullish,
C_mMorningDojiStarBullish ,C_mPiercingBullish,C_mHammerBullish,C_mInvertedHammerBullish,C_mMorningStarBullish,
C_mMarubozuWhiteBullish,C_mDragonflyDojiBullish,C_mHaramiCrossBullish,C_mHaramiBullish,C_mLongLowerShadowBullish,
C_mThreeWhiteSoldiersBullish,C_mEngulfingBullish,C_mAbandonedBabyBullish,C_mTriStarBullish,C_mKickingBullish ,
C_mOnNeckBearish,C_mFallingWindowBearish,C_mFallingThreeMethodsBearish,C_mTweezerTopBearish,C_mDarkCloudCoverBearish,
C_mDownsideTasukiGapBearish,C_mEveningDojiStarBearish,C_mDojiStarBearish,C_mHangingManBearish,
C_mShootingStarBearish,C_mEveningStarBearish,C_mMarubozuBlackBearish,C_mGravestoneDojiBearish,
C_mHaramiCrossBearish,C_mHaramiBearish,C_mLongUpperShadowBearish,C_mThreeBlackCrowsBearish,
C_mEngulfingBearish,C_mAbandonedBabyBearish,C_mTriStarBearish,C_mKickingBearish,
CNm_doji,Cm_SpinningTopWhite,Cm_SpinningTopBlack,
barEndTimem,barindexm ]=security(syminfo.tickerid,'M',f_detect_candle_patterns(detect_trend))
f_set_array(am_candle_array,am_candle_array_bar,C_mRisingWindowBullish,C_mRisingThreeMethodsBullish,
C_mTweezerBottomBullish,C_mUpsideTasukiGapBullish,C_mDojiStarBullish,
C_mMorningDojiStarBullish ,C_mPiercingBullish,C_mHammerBullish,C_mInvertedHammerBullish,C_mMorningStarBullish,
C_mMarubozuWhiteBullish,C_mDragonflyDojiBullish,C_mHaramiCrossBullish,C_mHaramiBullish,C_mLongLowerShadowBullish,
C_mThreeWhiteSoldiersBullish,C_mEngulfingBullish,C_mAbandonedBabyBullish,C_mTriStarBullish,C_mKickingBullish ,
C_mOnNeckBearish,C_mFallingWindowBearish,C_mFallingThreeMethodsBearish,C_mTweezerTopBearish,C_mDarkCloudCoverBearish,
C_mDownsideTasukiGapBearish,C_mEveningDojiStarBearish,C_mDojiStarBearish,C_mHangingManBearish,
C_mShootingStarBearish,C_mEveningStarBearish,C_mMarubozuBlackBearish,C_mGravestoneDojiBearish,
C_mHaramiCrossBearish,C_mHaramiBearish,C_mLongUpperShadowBearish,C_mThreeBlackCrowsBearish,
C_mEngulfingBearish,C_mAbandonedBabyBearish,C_mTriStarBearish,C_mKickingBearish,
CNm_doji,Cm_SpinningTopWhite,Cm_SpinningTopBlack,
barEndTimem,barindexm)
var display_table=table.new(position.top_right, 2, 10, border_color=color.black,border_width = 2)
txt_candlels_5=''
txt_candlels_15=''
txt_candlels_30=''
txt_candlels_60=''
txt_candlels_120=''
txt_candlels_240=''
txt_candlels_d=''
txt_candlels_w=''
txt_candlels_m=''
f_bullish_bearish_text(num)=>
tt=''
if num <= 20
tt:='🟢'
else if num>20 and num <=40
tt:='🔴'
else
tt:='⚫'
tt
if barstate.islast
for a=0 to 43
sym=f_bullish_bearish_text(a)
if timeframe.period=='5'
if array.get(a5_mint_candle_array,a) and barindex-array.get(a5_mint_candle_array_bar,a)<=candle_range
txt_candlels_5:=txt_candlels_5+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindex-array.get(a5_mint_candle_array_bar,a))+' bars ago\n'
if array.get(a15_mint_candle_array,a) and barindex15-array.get(a15_mint_candle_array_bar,a)<=candle_range
txt_candlels_15:=txt_candlels_15+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindex15-array.get(a15_mint_candle_array_bar,a))+' bars ago\n'
if array.get(a30_mint_candle_array,a) and barindex30-array.get(a30_mint_candle_array_bar,a)<=candle_range
txt_candlels_30:=txt_candlels_30+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindex30-array.get(a30_mint_candle_array_bar,a))+' bars ago\n'
if array.get(a1_hr_candle_array,a) and barindex1_hr-array.get(a1_hr_candle_array_bar,a)<=candle_range
txt_candlels_60:=txt_candlels_60+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindex1_hr-array.get(a1_hr_candle_array_bar,a))+' bars ago\n'
if array.get(a2_hr_candle_array,a) and barindex2_hr-array.get(a2_hr_candle_array_bar,a)<=candle_range
txt_candlels_120:=txt_candlels_120+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindex2_hr-array.get(a2_hr_candle_array_bar,a))+' bars ago\n'
if array.get(a4_hr_candle_array,a) and barindex4_hr-array.get(a4_hr_candle_array_bar,a)<=candle_range
txt_candlels_240:=txt_candlels_240+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindex4_hr-array.get(a4_hr_candle_array_bar,a))+' bars ago\n'
if array.get(ad_candle_array,a) and barindexd-array.get(ad_candle_array_bar,a)<=candle_range
txt_candlels_d:=txt_candlels_d+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindexd-array.get(ad_candle_array_bar,a))+' bars ago\n'
if array.get(aw_candle_array,a) and barindexw-array.get(aw_candle_array_bar,a)<=candle_range
txt_candlels_w:=txt_candlels_w+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindexw-array.get(aw_candle_array_bar,a))+' bars ago\n'
if array.get(am_candle_array,a) and barindexm-array.get(am_candle_array_bar,a)<=candle_range
txt_candlels_m:=txt_candlels_m+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindexm-array.get(am_candle_array_bar,a))+' bars ago\n'
if timeframe.period=='15'
txt_candlels_5:='NA'
if array.get(a15_mint_candle_array,a) and barindex15-array.get(a15_mint_candle_array_bar,a)<=candle_range
txt_candlels_15:=txt_candlels_15+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindex15-array.get(a15_mint_candle_array_bar,a))+' bars ago\n'
if array.get(a30_mint_candle_array,a) and barindex30-array.get(a30_mint_candle_array_bar,a)<=candle_range
txt_candlels_30:=txt_candlels_30+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindex30-array.get(a30_mint_candle_array_bar,a))+' bars ago\n'
if array.get(a1_hr_candle_array,a) and barindex1_hr-array.get(a1_hr_candle_array_bar,a)<=candle_range
txt_candlels_60:=txt_candlels_60+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindex1_hr-array.get(a1_hr_candle_array_bar,a))+' bars ago\n'
if array.get(a2_hr_candle_array,a) and barindex2_hr-array.get(a2_hr_candle_array_bar,a)<=candle_range
txt_candlels_120:=txt_candlels_120+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindex2_hr-array.get(a2_hr_candle_array_bar,a))+' bars ago\n'
if array.get(a4_hr_candle_array,a) and barindex4_hr-array.get(a4_hr_candle_array_bar,a)<=candle_range
txt_candlels_240:=txt_candlels_240+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindex4_hr-array.get(a4_hr_candle_array_bar,a))+' bars ago\n'
if array.get(ad_candle_array,a) and barindexd-array.get(ad_candle_array_bar,a)<=candle_range
txt_candlels_d:=txt_candlels_d+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindexd-array.get(ad_candle_array_bar,a))+' bars ago\n'
if array.get(aw_candle_array,a) and barindexw-array.get(aw_candle_array_bar,a)<=candle_range
txt_candlels_w:=txt_candlels_w+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindexw-array.get(aw_candle_array_bar,a))+' bars ago\n'
if array.get(am_candle_array,a) and barindexm-array.get(am_candle_array_bar,a)<=candle_range
txt_candlels_m:=txt_candlels_m+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindexm-array.get(am_candle_array_bar,a))+' bars ago\n'
if timeframe.period=='30'
txt_candlels_5:='NA'
txt_candlels_15:='NA'
if array.get(a30_mint_candle_array,a) and barindex30-array.get(a30_mint_candle_array_bar,a)<=candle_range
txt_candlels_30:=txt_candlels_30+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindex30-array.get(a30_mint_candle_array_bar,a))+' bars ago\n'
if array.get(a1_hr_candle_array,a) and barindex1_hr-array.get(a1_hr_candle_array_bar,a)<=candle_range
txt_candlels_60:=txt_candlels_60+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindex1_hr-array.get(a1_hr_candle_array_bar,a))+' bars ago\n'
if array.get(a2_hr_candle_array,a) and barindex2_hr-array.get(a2_hr_candle_array_bar,a)<=candle_range
txt_candlels_120:=txt_candlels_120+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindex2_hr-array.get(a2_hr_candle_array_bar,a))+' bars ago\n'
if array.get(a4_hr_candle_array,a) and barindex4_hr-array.get(a4_hr_candle_array_bar,a)<=candle_range
txt_candlels_240:=txt_candlels_240+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindex4_hr-array.get(a4_hr_candle_array_bar,a))+' bars ago\n'
if array.get(ad_candle_array,a) and barindexd-array.get(ad_candle_array_bar,a)<=candle_range
txt_candlels_d:=txt_candlels_d+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindexd-array.get(ad_candle_array_bar,a))+' bars ago\n'
if array.get(aw_candle_array,a) and barindexw-array.get(aw_candle_array_bar,a)<=candle_range
txt_candlels_w:=txt_candlels_w+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindexw-array.get(aw_candle_array_bar,a))+' bars ago\n'
if array.get(am_candle_array,a) and barindexm-array.get(am_candle_array_bar,a)<=candle_range
txt_candlels_m:=txt_candlels_m+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindexm-array.get(am_candle_array_bar,a))+' bars ago\n'
if timeframe.period=='60'
txt_candlels_5:='NA'
txt_candlels_15:='NA'
txt_candlels_30:='NA'
if array.get(a1_hr_candle_array,a) and barindex1_hr-array.get(a1_hr_candle_array_bar,a)<=candle_range
txt_candlels_60:=txt_candlels_60+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindex1_hr-array.get(a1_hr_candle_array_bar,a))+' bars ago\n'
if array.get(a2_hr_candle_array,a) and barindex2_hr-array.get(a2_hr_candle_array_bar,a)<=candle_range
txt_candlels_120:=txt_candlels_120+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindex2_hr-array.get(a2_hr_candle_array_bar,a))+' bars ago\n'
if array.get(a4_hr_candle_array,a) and barindex4_hr-array.get(a4_hr_candle_array_bar,a)<=candle_range
txt_candlels_240:=txt_candlels_240+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindex4_hr-array.get(a4_hr_candle_array_bar,a))+' bars ago\n'
if array.get(ad_candle_array,a) and barindexd-array.get(ad_candle_array_bar,a)<=candle_range
txt_candlels_d:=txt_candlels_d+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindexd-array.get(ad_candle_array_bar,a))+' bars ago\n'
if array.get(aw_candle_array,a) and barindexw-array.get(aw_candle_array_bar,a)<=candle_range
txt_candlels_w:=txt_candlels_w+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindexw-array.get(aw_candle_array_bar,a))+' bars ago\n'
if array.get(am_candle_array,a) and barindexm-array.get(am_candle_array_bar,a)<=candle_range
txt_candlels_m:=txt_candlels_m+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindexm-array.get(am_candle_array_bar,a))+' bars ago\n'
if timeframe.period=='120'
txt_candlels_5:='NA'
txt_candlels_15:='NA'
txt_candlels_30:='NA'
txt_candlels_60:='NA'
if array.get(a2_hr_candle_array,a) and barindex2_hr-array.get(a2_hr_candle_array_bar,a)<=candle_range
txt_candlels_120:=txt_candlels_120+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindex2_hr-array.get(a2_hr_candle_array_bar,a))+' bars ago\n'
if array.get(a4_hr_candle_array,a) and barindex4_hr-array.get(a4_hr_candle_array_bar,a)<=candle_range
txt_candlels_240:=txt_candlels_240+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindex4_hr-array.get(a4_hr_candle_array_bar,a))+' bars ago\n'
if array.get(ad_candle_array,a) and barindexd-array.get(ad_candle_array_bar,a)<=candle_range
txt_candlels_d:=txt_candlels_d+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindexd-array.get(ad_candle_array_bar,a))+' bars ago\n'
if array.get(aw_candle_array,a) and barindexw-array.get(aw_candle_array_bar,a)<=candle_range
txt_candlels_w:=txt_candlels_w+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindexw-array.get(aw_candle_array_bar,a))+' bars ago\n'
if array.get(am_candle_array,a) and barindexm-array.get(am_candle_array_bar,a)<=candle_range
txt_candlels_m:=txt_candlels_m+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindexm-array.get(am_candle_array_bar,a))+' bars ago\n'
if timeframe.period=='240'
txt_candlels_5:='NA'
txt_candlels_15:='NA'
txt_candlels_30:='NA'
txt_candlels_60:='NA'
txt_candlels_120:='NA'
if array.get(a4_hr_candle_array,a) and barindex4_hr-array.get(a4_hr_candle_array_bar,a)<=candle_range
txt_candlels_240:=txt_candlels_240+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindex4_hr-array.get(a4_hr_candle_array_bar,a))+' bars ago\n'
if array.get(ad_candle_array,a) and barindexd-array.get(ad_candle_array_bar,a)<=candle_range
txt_candlels_d:=txt_candlels_d+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindexd-array.get(ad_candle_array_bar,a))+' bars ago\n'
if array.get(aw_candle_array,a) and barindexw-array.get(aw_candle_array_bar,a)<=candle_range
txt_candlels_w:=txt_candlels_w+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindexw-array.get(aw_candle_array_bar,a))+' bars ago\n'
if array.get(am_candle_array,a) and barindexm-array.get(am_candle_array_bar,a)<=candle_range
txt_candlels_m:=txt_candlels_m+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindexm-array.get(am_candle_array_bar,a))+' bars ago\n'
if timeframe.period=='D'
txt_candlels_5:='NA'
txt_candlels_15:='NA'
txt_candlels_30:='NA'
txt_candlels_60:='NA'
txt_candlels_120:='NA'
txt_candlels_240:='NA'
if array.get(ad_candle_array,a) and barindexd-array.get(ad_candle_array_bar,a)<=candle_range
txt_candlels_d:=txt_candlels_d+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindexd-array.get(ad_candle_array_bar,a))+' bars ago\n'
if array.get(aw_candle_array,a) and barindexw-array.get(aw_candle_array_bar,a)<=candle_range
txt_candlels_w:=txt_candlels_w+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindexw-array.get(aw_candle_array_bar,a))+' bars ago\n'
if array.get(am_candle_array,a) and barindexm-array.get(am_candle_array_bar,a)<=candle_range
txt_candlels_m:=txt_candlels_m+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindexm-array.get(am_candle_array_bar,a))+' bars ago\n'
if timeframe.period=='W'
txt_candlels_5:='NA'
txt_candlels_15:='NA'
txt_candlels_30:='NA'
txt_candlels_60:='NA'
txt_candlels_120:='NA'
txt_candlels_240:='NA'
txt_candlels_d:='NA'
if array.get(aw_candle_array,a) and barindexw-array.get(aw_candle_array_bar,a)<=candle_range
txt_candlels_w:=txt_candlels_w+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindexw-array.get(aw_candle_array_bar,a))+' bars ago\n'
if array.get(am_candle_array,a) and barindexm-array.get(am_candle_array_bar,a)<=candle_range
txt_candlels_m:=txt_candlels_m+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindexm-array.get(am_candle_array_bar,a))+' bars ago\n'
if timeframe.period=='M'
txt_candlels_5:='NA'
txt_candlels_15:='NA'
txt_candlels_30:='NA'
txt_candlels_60:='NA'
txt_candlels_120:='NA'
txt_candlels_240:='NA'
txt_candlels_d:='NA'
txt_candlels_w:='NA'
if array.get(am_candle_array,a) and barindexm-array.get(am_candle_array_bar,a)<=candle_range
txt_candlels_m:=txt_candlels_m+sym+array.get(candle_pattern_name,a)+' found '+
tostring(barindexm-array.get(am_candle_array_bar,a))+' bars ago\n'
if txt_candlels_5==''
txt_candlels_5:='No Pattern Detected'
if txt_candlels_15==''
txt_candlels_15:='No Pattern Detected'
if txt_candlels_30==''
txt_candlels_30:='No Pattern Detected'
if txt_candlels_60==''
txt_candlels_60:='No Pattern Detected'
if txt_candlels_120==''
txt_candlels_120:='No Pattern Detected'
if txt_candlels_240==''
txt_candlels_240:='No Pattern Detected'
if txt_candlels_d==''
txt_candlels_d:='No Pattern Detected'
if txt_candlels_w==''
txt_candlels_w:='No Pattern Detected'
if txt_candlels_m==''
txt_candlels_m:='No Pattern Detected'
table.cell(display_table,0,0,'Time Frame',text_color=color.white,bgcolor=#1848CC)
table.cell(display_table,1,0,'Candle Patterns found in '+tostring(candle_range)+' bars lookback',text_color=color.white,bgcolor=#1848CC)
table.cell(display_table,0,1,'5M',text_color=color.white,bgcolor=#1848CC)
table.cell(display_table,0,2,'15M',text_color=color.white,bgcolor=#1848CC)
table.cell(display_table,0,3,'30M',text_color=color.white,bgcolor=#1848CC)
table.cell(display_table,0,4,'1H',text_color=color.white,bgcolor=#1848CC)
table.cell(display_table,0,5,'2H',text_color=color.white,bgcolor=#1848CC)
table.cell(display_table,0,6,'4H',text_color=color.white,bgcolor=#1848CC)
table.cell(display_table,0,7,'D',text_color=color.white,bgcolor=#1848CC)
table.cell(display_table,0,8,'W',text_color=color.white,bgcolor=#1848CC)
table.cell(display_table,0,9,'M',text_color=color.white,bgcolor=#1848CC)
table.cell(display_table,1,1,txt_candlels_5,text_color=color.white,bgcolor=#1848CC)
table.cell(display_table,1,2,txt_candlels_15,text_color=color.white,bgcolor=#1848CC)
table.cell(display_table,1,3,txt_candlels_30,text_color=color.white,bgcolor=#1848CC)
table.cell(display_table,1,4,txt_candlels_60,text_color=color.white,bgcolor=#1848CC)
table.cell(display_table,1,5,txt_candlels_120,text_color=color.white,bgcolor=#1848CC)
table.cell(display_table,1,6,txt_candlels_240,text_color=color.white,bgcolor=#1848CC)
table.cell(display_table,1,7,txt_candlels_d,text_color=color.white,bgcolor=#1848CC)
table.cell(display_table,1,8,txt_candlels_w,text_color=color.white,bgcolor=#1848CC)
table.cell(display_table,1,9,txt_candlels_m,text_color=color.white,bgcolor=#1848CC)
|
Simple Watchlist with % Change Screener & Alerts | https://www.tradingview.com/script/dzZbb9mD-Simple-Watchlist-with-Change-Screener-Alerts/ | sharaaU7 | https://www.tradingview.com/u/sharaaU7/ | 712 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ralagh
//@version=4
// Change the Percentage input box to 1,2,3,4 etc for the desired % Alerts
// line 45 has the range for color gradient for heatmap
// alerts() are set for 2%
study("Simple Watchlist", format=format.price, precision=2, overlay=true)
res = input("D", "Timeframe")
pct = input(2, "Percentage for Alerts", minval=1, step=1)
colm = input(5, "Column multiplier", minval=4, step=1, maxval=7)
alert_strings = array.new_string(2)
array.set(alert_strings, 0, "")
array.set(alert_strings, 1, "")
table_row_count = array.new_int(1) //keeps track of number of total entries
array.set(table_row_count, 0, 0)
var UpTabl = table.new(position = position.bottom_center, columns = 7, rows = 9, bgcolor = color.rgb(255,255,255), border_width = 4, frame_color= color.black, frame_width = 2)
f_chgpct(_ticker)=>
[cl_dp, val_c0, hi_p, lo_p, rs_14] = security(_ticker, res, [close[1], close, high, low, rsi(close, 14)], lookahead = barmerge.lookahead_on)
p_chg = (val_c0 - cl_dp)/cl_dp * 100
_msg = _ticker + "~Cls-" + tostring(round(val_c0 * 100) / 100) + "/" + tostring(round(p_chg * 100) / 100) + "% ,"
if p_chg >= pct
_msg := _msg + "High~" + tostring(round(hi_p * 100) / 100) + ", Low~" + tostring(round(lo_p * 100) / 100) + "UP More Than-->" + tostring(pct) + "%▲▲"
array.set(alert_strings, 0, array.get(alert_strings, 0) + "\n" + _msg)
if p_chg < -pct
_msg := _msg + "High~" + tostring(round(hi_p * 100) / 100) + ", Low~" + tostring(round(lo_p * 100) / 100) + "Down More Than-->" + tostring(pct) + "%▼▼"
array.set(alert_strings, 1, array.get(alert_strings, 1) + "\n" + _msg)
if val_c0 >= 100
array.set(table_row_count, 0, array.get(table_row_count, 0) + 1)
if barstate.islast
table.cell(table_id = UpTabl, column = int((array.get(table_row_count, 0) - 1) / colm), height = 12, row = ((array.get(table_row_count, 0) - 1) % colm) +1, text = _ticker + "\n cls -: " + tostring(round(val_c0 * 1000) / 1000) + "\n chg ~: " + tostring(round(p_chg * 1000) / 1000) + "%"+ "\n RSI -: " + tostring(round(rs_14 * 100) / 100), text_size = size.large, text_halign=text.align_center, bgcolor=color.from_gradient(p_chg, -3, 3, color.rgb(255, 70, 70), color.rgb(0, 200, 100)))
f_chgpct(syminfo.tickerid)
f_chgpct(input('DJI', title=input.symbol))
f_chgpct(input('IXIC', title=input.symbol))
f_chgpct(input('SPX', title=input.symbol))
f_chgpct(input('RUT', title=input.symbol))
f_chgpct(input('AAPL', title=input.symbol))
f_chgpct(input('AMZN', title=input.symbol))
f_chgpct(input('FB', title=input.symbol))
f_chgpct(input('GOOG', title=input.symbol))
f_chgpct(input('NFLX', title=input.symbol))
f_chgpct(input('MSFT', title=input.symbol))
f_chgpct(input('NVDA', title=input.symbol))
f_chgpct(input('FDX', title=input.symbol))
f_chgpct(input('GLD', title=input.symbol))
f_chgpct(input('DIS', title=input.symbol))
f_chgpct(input('GOOG', title=input.symbol))
f_chgpct(input('NKE', title=input.symbol))
f_chgpct(input('MSFT', title=input.symbol))
f_chgpct(input('BABA', title=input.symbol))
f_chgpct(input('JNJ', title=input.symbol))
f_chgpct(input('TMO', title=input.symbol))
f_chgpct(input('SLV', title=input.symbol))
f_chgpct(input('IBM', title=input.symbol))
f_chgpct(input('TSLA', title=input.symbol))
f_chgpct(input('V', title=input.symbol))
f_chgpct(input('TMO', title=input.symbol))
f_chgpct(input('QQQ', title=input.symbol))
f_chgpct(input('IBM', title=input.symbol))
f_chgpct(input('SPY', title=input.symbol))
f_chgpct(input('ADBE', title=input.symbol))
f_chgpct(input('DOCU', title=input.symbol))
f_chgpct(input('CRM', title=input.symbol))
f_chgpct(input('BTCUSD', title=input.symbol))
f_chgpct(input('ETHUSD', title=input.symbol))
f_chgpct(input('LTCUSD', title=input.symbol))
f_chgpct(input('USDJPY', title=input.symbol))
if array.get(alert_strings, 0) != ""
alert(array.get(alert_strings, 0), alert.freq_once_per_bar_close)
if array.get(alert_strings, 1) != ""
alert(array.get(alert_strings, 1), alert.freq_once_per_bar_close) |
JS Bull/Bear Power | https://www.tradingview.com/script/nqXJYLgM-JS-Bull-Bear-Power/ | lizardojohnsonc | https://www.tradingview.com/u/lizardojohnsonc/ | 56 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © lizardojohnsonc
//@version=4
study("JS Bull/Bear Power", overlay = true, precision=0, max_labels_count= 10)
average_price = ema(close,2)
bear = (high - (open>close? open:close))
bull = ((open < close? open:close)-low)
barlenght = close > open ? close - open : open - close
sumbarlenght = sum(barlenght,60)
sumbull = ((sum(bear,60))/sumbarlenght)*100
sumbear = ((sum(bull,60))/sumbarlenght)*100
//bullPower = ((high - average_price)/average_price)*1000
//bearPower = ((low - average_price)/average_price)*1000
bullPower_converted = tostring(floor(sumbull))
bearPower_converted = tostring(floor(sumbear))
bull_label = label.new(x=bar_index, y=na, text=bullPower_converted, yloc=yloc.abovebar, textcolor=color.white, style=label.style_none, size=size.normal)
bear_label = label.new(x=bar_index, y=na, text=bearPower_converted, yloc=yloc.belowbar, textcolor=color.white, style=label.style_none, size=size.normal)
|
Out Of The Box | https://www.tradingview.com/script/ZDpYe95M-Out-Of-The-Box/ | chocolatebear | https://www.tradingview.com/u/chocolatebear/ | 10 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © chocolatebear
//@version=4
study("Out Of The Box", shorttitle="OOTB", overlay=true)
t = input(defval=close, title="top", type=input.source)
b = input(defval=close, title="bottom", type=input.source)
l = input(defval=60, title="length", type=input.integer, minval=1, maxval=1000)
d = input(defval=5, title="displacement", type=input.integer, minval=0, maxval=1000)
c = highest(t, l)
g = lowest(b, l)
m = ((c + g) * 0.5)
uf = (g + ((c - g)*0.618))
tf = (g + ((c - g)*0.786))
lf = (c - ((c - g)*0.618))
gf = (c - ((c - g)*0.786))
plot(c, title="ceiling", color=(color.green), linewidth=1, style=plot.style_line, offset=d)
plot(tf, title="top floor", color=color.green, linewidth=1, style=plot.style_line, offset=d)
plot(uf, title="upper floor", color=color.green, linewidth=1, style=plot.style_line, offset=d)
plot(m, title="mid", color=color.orange, linewidth=1, style=plot.style_line, offset=d)
plot(lf, title="lower floor", color=color.red, linewidth=1, style=plot.style_line, offset=d)
plot(gf, title="ground floor", color=color.red, linewidth=1, style=plot.style_line, offset=d)
plot(g, title="ground", color=color.red, linewidth=1, style=plot.style_line, offset=d) |
Pivot order block boxes [LM] | https://www.tradingview.com/script/bWRA4Y8e-Pivot-order-block-boxes-LM/ | lmatl | https://www.tradingview.com/u/lmatl/ | 627 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © lmatl
//@version=5
indicator('Pivot order block boxes [LM]', overlay=true, max_bars_back=500, max_boxes_count=500)
i_firstShowPivotBoxes = input.bool(true, 'Show first boxes', group='first pivot setting')
i_firstLeft = input.int(20, 'Left', group='first pivot setting')
i_firstRight = input.int(10, 'Right', group='first pivot setting')
i_firstBoxCount = input.int(5, title='Box count', group='first pivot setting')
i_firstPercentageChange = input.int(10, title='Percentage change on the right side of pivot', group='first pivot setting')
i_firstPivotHighColor = input.color(color.green, title='Pivot high color', group='first pivot setting')
i_firstPivotLowColor = input.color(color.red, title='Pivot low color', group='first pivot setting')
i_secondShowPivotBoxes = input.bool(false, 'Show second boxes', group='second pivot setting')
i_secondLeft = input.int(50, 'Left', group='second pivot setting')
i_secondRight = input.int(20, 'Right', group='second pivot setting')
i_secondBoxCount = input.int(5, title='Box count', group='second pivot setting')
i_secondPercentageChange = input.int(10, title='Percentage change on the right side of pivot', group='second pivot setting')
i_secondPivotHighColor = input.color(color.lime, title='Pivot high color', group='second pivot setting')
i_secondPivotLowColor = input.color(color.maroon, title='Pivot low color', group='second pivot setting')
firstBoxHighColor = color.new(i_firstPivotHighColor, 70)
firstBoxLowColor = color.new(i_firstPivotLowColor, 70)
secondBoxHighColor = color.new(i_secondPivotHighColor, 70)
secondBoxLowColor = color.new(i_secondPivotLowColor, 70)
var firstBoxArray = array.new_box()
var secondBoxArray = array.new_box()
f_isUpCandle(_index) =>
open[_index] <= close[_index]
f_extendArray(_boxArray) =>
if array.size(_boxArray) > 0
for _i = array.size(_boxArray) - 1 to 0 by 1
boxId = array.get(_boxArray, _i)
box.set_right(boxId, bar_index)
f_pivotHigh(_boxColor, _right, _left, _percentage) =>
pivotHigh = ta.pivothigh(high, _left, _right)
if not na(pivotHigh)
isPercentageChangeEnough = false
for i = 0 to _right + 1 by 1
if (pivotHigh - high[i]) / pivotHigh >= _percentage / 100
isPercentageChangeEnough := true
break
if isPercentageChangeEnough
int candleIndex = _right
for i = _right to _right + _left by 1
if f_isUpCandle(i)
candleIndex := i
break
rangeLow = low[candleIndex]
rangeHigh = high[candleIndex]
b = box.new(bar_index[candleIndex], rangeHigh, bar_index, rangeLow, bgcolor=_boxColor, border_style=line.style_dashed, border_color=_boxColor)
b
f_pivotLow(_boxColor, _right, _left, _percentage) =>
pivotLow = ta.pivotlow(low, _left, _right)
if not na(pivotLow)
isPercentageChangeEnough = false
for i = 0 to _right - 1 by 1
if (low[i] - pivotLow) / pivotLow >= _percentage / 100
isPercentageChangeEnough := true
break
if isPercentageChangeEnough
int candleIndex = _right
for i = _right to _right + _left by 1
if not f_isUpCandle(i)
candleIndex := i
break
rangeLow = low[candleIndex]
rangeHigh = high[candleIndex]
b = box.new(bar_index[candleIndex], rangeHigh, bar_index, rangeLow, bgcolor=_boxColor, border_style=line.style_dashed, border_color=_boxColor)
b
// first box pivots
if i_firstShowPivotBoxes
firstPivotHighBox = f_pivotHigh(firstBoxHighColor, i_firstRight, i_firstLeft, i_firstPercentageChange)
firstPivotLowBox = f_pivotLow(firstBoxLowColor, i_firstRight, i_firstLeft, i_firstPercentageChange)
if not na(firstPivotHighBox)
if array.size(firstBoxArray) == i_firstBoxCount
box.delete(array.shift(firstBoxArray))
array.push(firstBoxArray, firstPivotHighBox)
if not na(firstPivotLowBox)
if array.size(firstBoxArray) == i_firstBoxCount
box.delete(array.shift(firstBoxArray))
array.push(firstBoxArray, firstPivotLowBox)
f_extendArray(firstBoxArray)
// second pivot levels
if i_secondShowPivotBoxes
secondPivotHighBox = f_pivotHigh(secondBoxHighColor, i_secondRight, i_secondLeft, i_secondPercentageChange)
secondPivotLowBox = f_pivotLow(secondBoxLowColor, i_secondRight, i_secondLeft, i_secondPercentageChange)
if not na(secondPivotHighBox)
if array.size(secondBoxArray) == i_secondBoxCount
box.delete(array.shift(secondBoxArray))
array.push(secondBoxArray, secondPivotHighBox)
if not na(secondPivotLowBox)
if array.size(secondBoxArray) == i_secondBoxCount
box.delete(array.shift(secondBoxArray))
array.push(secondBoxArray, secondPivotLowBox)
f_extendArray(secondBoxArray)
|
Current to BTC [Morty] | https://www.tradingview.com/script/BGnlvOHP-Current-to-BTC-Morty/ | M0rty | https://www.tradingview.com/u/M0rty/ | 1,050 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Morty
//@version=5
indicator('Current to BTC [Morty]')
s2 = input.symbol(title='BTC Symbol', defval='BINANCE:BTCUSDTPERP')
f() =>
[open, high, low, close, syminfo.basecurrency]
[o1, h1, l1, c1, sym1] = request.security(syminfo.tickerid, timeframe.period, f())
[o2, h2, l2, c2, sym2] = request.security(s2, timeframe.period, f())
c = o1 / o2 < c1 / c2 ? #E2DED0 : #4E4F50
plotcandle(o1 / o2, h1 / h2, l1 / l2, c1 / c2, color=c, wickcolor=c, bordercolor=c)
// Donchian Channels
length = input.int(50, 'Donchian Channel Length', minval=1)
mid_ma_length = input.int(5, 'Midline moving avarage length', minval=1)
lower = ta.lowest(l1 / l2, length)
upper = ta.highest(h1 / h2, length)
basis = math.avg(upper, lower)
pallete = ta.ema(c1 / c2, mid_ma_length) > basis ? #76B947 : #F83839
plot(basis, 'Basis', color=pallete, linewidth=2)
u = plot(upper, 'Upper', color=color.new(#2962FF, 0))
l = plot(lower, 'Lower', color=color.new(#2962FF, 0))
fill(u, l, color=color.rgb(33, 150, 243, 95), title='Background')
// plot labels, e.g. DYDX/BTC
label0 = label.new(bar_index+2, basis, str.format("{0}/{1}", sym1, sym2), textcolor=color.white, style= label.style_label_left)
label.delete(label0[1])
|
vol_signal | https://www.tradingview.com/script/VjXfHBI9-vol-signal/ | voided | https://www.tradingview.com/u/voided/ | 95 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © voided
// USAGE
//
// This script gives signals based on a volatility forecast, e.g. for a stop
// loss. It is a simplified version of my other script "trend_vol_forecast",
// which incorporates a trend following system and measures performance. The "X"
// labels indicate when the price touches (exceeds) a forecast. The signal
// occurs when price crosses "fcst_up" or "fcst_down".
//
// There are only three parameters:
//
// - volatility window: this is the number of periods (bars) used in the
// historical volatility calculation. smaller number = reacts more
// quickly to changes, but is a "noisier" signal.
// - forecast periods: the number of periods for projecting a volatility
// forecast. for example, "21" on a daily chart means the plots will
// show the forecast from 21 days ago.
// - forecast stdev: the number of standard deviations in the forecast.
// for example, "2" means that price is expected to remain within
// the forecast plot ~95% of the time. A higher number produces a
// wider forecast.
//
// The output table shows:
//
// - realized vol: the volatility over the previous N periods, where N =
// "volatility window".
// - forecast vol: the realized volatility from N periods ago, where N =
// "forecast periods"
// - fcst_up/fcst_down (level): the price level of the forecast for the
// next N bars, where N = "forecast periods".
// - fcst_up/fcst_down (%): the difference between the current and
// forecast price, expressed as a whole number percentage.
//
// The plots show:
//
// - blue/red plot: the upper/lower forecast from "forecast periods" ago.
// - blue/red line: the upper/lower forecast for the next
// "forecast periods".
// - red/blue labels: an "X" where the price touched the forecast from
// "forecast periods" ago.
// + NOTE: pinescript only draws a limited number of labels.
// They will not appear very far into the past.
//
//
//@version=4
study("vol_signal", overlay = true)
// INPUTS
vol_window = input(title = "volatility window", type = input.integer, defval = 30)
fcst_periods = input(title = "forecast periods", type = input.float, defval = 21)
fcst_stdev = input(title = "forecast stdev", type = input.float, defval = 2)
// PROGRAM
r = log(close / close[1])
pd = time - time[1]
ppy = (365 * 24 * 60 * 60 * 1000) / pd
hv = sqrt(ema(pow(r, 2), vol_window) * ppy)
fcst = hv * fcst_stdev * sqrt(fcst_periods / ppy)
fcst_up = close[fcst_periods] * (1 + fcst[fcst_periods])
fcst_up_pct = abs((fcst_up - close) / close) * 100
fcst_down = close[fcst_periods] * (1 - fcst[fcst_periods])
fcst_down_pct = abs((fcst_down - close) / close) * 100
// OUTPUT
if barstate.islast
// table
fmt = "#.###"
cur_fcst_up = close * (1 + fcst)
cur_fcst_down = close * (1 - fcst)
fcst_ln_up = line.new(time, cur_fcst_up, int(time + fcst_periods * pd), cur_fcst_up, xloc = xloc.bar_time, color = color.blue)
fcst_ln_down = line.new(time, cur_fcst_down, int(time + fcst_periods * pd), cur_fcst_down, xloc = xloc.bar_time, color = color.red)
var ot = table.new(position.top_right, 2, 6)
table.cell(ot, 0, 0, "realized vol", bgcolor = color.new(color.green, 60))
table.cell(ot, 1, 0, tostring(hv * 100, fmt), bgcolor = color.new(color.green, 80))
table.cell(ot, 0, 1, "forecast vol", bgcolor = color.new(color.green, 60))
table.cell(ot, 1, 1, tostring(hv[fcst_periods] * 100, fmt), bgcolor = color.new(color.green, 80))
table.cell(ot, 0, 2, "fcst_up", bgcolor = color.new(color.blue, 60))
table.cell(ot, 1, 2, tostring(fcst_up, fmt), bgcolor = color.new(color.blue, 80))
table.cell(ot, 0, 3, "fcst_up_pct", bgcolor = color.new(color.blue, 60))
table.cell(ot, 1, 3, tostring(fcst_up_pct,fmt), bgcolor = color.new(color.blue, 80))
table.cell(ot, 0, 4, "fcst_down", bgcolor = color.new(color.red, 60))
table.cell(ot, 1, 4, tostring(fcst_down, fmt), bgcolor = color.new(color.red, 80))
table.cell(ot, 0, 5, "fcst_down_pct", bgcolor = color.new(color.red, 60))
table.cell(ot, 1, 5, tostring(fcst_down_pct, fmt), bgcolor = color.new(color.red, 80))
// plots and labels
plot(series = fcst_up, title = "fcst_up", color = color.blue, style = plot.style_stepline)
plot(series = fcst_down, title = "fcst_down", color = color.red, style = plot.style_stepline)
plot(fcst_up_pct, title = "fcst_up_pct", color = na, display = display.none)
plot(fcst_down_pct, title = "fcst_down_pct", color = na, display = display.none)
if low < fcst_down
label.new(bar_index, na, "x", yloc = yloc.belowbar, style = label.style_none, textcolor = color.red)
else if high > fcst_up
label.new(bar_index, na, "x", yloc = yloc.abovebar, style = label.style_none, textcolor = color.blue) |
0_dte | https://www.tradingview.com/script/Ug0GTGrF-0-dte/ | voided | https://www.tradingview.com/u/voided/ | 71 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © voided
//@version=4
study("0_dte", overlay = false)
// USAGE
//
// This script guages the probability of an underlying moving a certain amount
// on expiration day, to aid the popular "0 dte" strategy. The script counts
// how many next-day moves exceeded a given magnitude in the past, under
// similar conditions. The inputs are:
//
// - mark_mode:
// + "open": measures the magnitude as "open to close"--a true 0 dte.
// + "previous close": for lazy people who don't want to wake up
// early. measures magnitude from the previous day's close.
// - move_mode:
// + "percent": measures moves that exceed a given percentage.
// + "absolute": measures moves that exceed a point value.
// - move-dir: measure only up moves, down moves, or both.
// - vol_model: the model for realized volatility. (may add more later).
// - min_vol: only measure moves when realized vol is above this value.
// - max_vol: only measure moves when realized vol is below this value.
// - precision: number of digits printed in the output table.
//
// EXAMPLE:
// mark_mode: "previous close"
// move_mode: "percent"
// move_dir: "up"
// move_mag: 0.07
// vol_model: hv30
// min_vol: 0.2
// max_vol: 0.5
//
// These settings will count the number of trading days that closed 7%
// higher than the previous day's close, when the previous day's realized
// volatility (annualized) was between 20% and 50%.
//
// OUTPUTS:
//
// current vol: green plot. Today's realized vol. Shown for convenience.
// max and min vol: red plots. Also shown for convenience.
// count: the number of days that exceeded the chosen magnitude, when
// the previous day's realized volatility was within the chosen bounds.
// total: the total number of days where realized volatility was within
// the chosen bounds
// probability: count / total. the percentage of days that exceeded the
// move when volatility was within the bounds.
// move: plotted as a purple line. purple "X" labels are plotted above
// bars where the move exceeded the magnitude threshold and volatility
// was in-bounds. a "hit".
//
// This script is based on the idea that realized volatility has some bearing
// on future volatility. By seeing what happened in the past when volatility
// was close to its current value, we may be able to assess the probability
// that our short put will be in the money, tomorrow, and our account
// devastated.
var count = 0
mark_mode = input(title = "mark mode", options = [ "open", "previous close" ], defval = "open")
move_mode = input(title = "move mode", options = [ "percent", "absolute" ], defval = "percent")
move_dir = input(title = "move direction", options = [ "up", "down", "any" ], defval = "any")
move_mag = input(title = "move magnitude", type = input.float, defval = -1)
vol_model = input(title = "vol model", options = [ "hv30" ], defval = "hv30")
min_vol = input(title = "min vol", type = input.float, defval = -1.0)
max_vol = input(title = "max vol", type = input.float, defval = -1.0)
precision = input(title = "precision", type = input.integer, defval = 2)
var float v = 0.
if vol_model == "hv30"
v := sqrt(ema(pow(log(close / close[1]), 2), 30) * 252)
// else if ...
// define other volatility models here
var int total = 0
var float move = na
move := if move_mode == "percent"
if mark_mode == "open"
(close / open - 1)
else
(close / close[1] - 1)
else
if mark_mode == "open"
close - open
else
close - close[1]
move := if move_dir == "up"
move
else if move_dir == "down"
-move
else if move_dir == "any"
abs(move)
in_range = v[1] >= min_vol and v[1] <= max_vol
if move >= move_mag and in_range
label.new(x = bar_index, y = move, text = "X", style = label.style_none, textcolor = color.fuchsia)
count := count + 1
if in_range
total := total + 1
if barstate.islast
fmt = "#."
for i = 0 to precision
fmt := fmt + "#"
var ot = table.new(position.top_right, 2, 6)
lbl_clr = color.new(color.blue, 60)
stat_clr = color.new(color.blue, 80)
table.cell(ot, 0, 0, "current vol", bgcolor = lbl_clr)
table.cell(ot, 0, 1, "max vol", bgcolor = lbl_clr)
table.cell(ot, 0, 2, "min vol", bgcolor = lbl_clr)
table.cell(ot, 0, 3, "count", bgcolor = lbl_clr)
table.cell(ot, 0, 4, "total", bgcolor = lbl_clr)
table.cell(ot, 0, 5, "probability", bgcolor = lbl_clr)
table.cell(ot, 1, 0, tostring(v, fmt), bgcolor = stat_clr)
table.cell(ot, 1, 1, tostring(max_vol), bgcolor = stat_clr)
table.cell(ot, 1, 2, tostring(min_vol), bgcolor = stat_clr)
table.cell(ot, 1, 3, tostring(count), bgcolor = stat_clr)
table.cell(ot, 1, 4, tostring(total, fmt), bgcolor = stat_clr)
table.cell(ot, 1, 5, tostring(count / total, fmt), bgcolor = stat_clr)
plot(move, "move", color = color.fuchsia)
plot(v[1], "realized vol", color = color.green)
plot(move_mag, "magnitude", color = color.blue)
plot(min_vol, "min vol", color = color.red)
plot(max_vol, "max_vol", color = color.red) |
St_cumulative | https://www.tradingview.com/script/ySMARvnc-st-cumulative/ | IntelTrading | https://www.tradingview.com/u/IntelTrading/ | 54 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Alferow
//@version=4
study("St_cumulative", overlay=false)
p = input(30, title = 'period')
max = highest(p)
min = lowest(p)
med = (max + min)/2
graph = if close > open
high
else
low
delta = graph - med
sum = delta
for i = 1 to p
sum := sum + delta[i]
col_grow_above = #26A69A
col_grow_below = #FFCDD2
col_fall_above = #B2DFDB
col_fall_below = #EF5350
plot(sum, title="Histogram", style=plot.style_columns, color=(sum>=0 ? (sum[1] < sum ? col_grow_above : col_fall_above) : (sum[1] < sum ? col_grow_below : col_fall_below)))
|
ATR Start & Stop Bot | https://www.tradingview.com/script/zk6uaRh9-ATR-Start-Stop-Bot/ | mmoiwgg | https://www.tradingview.com/u/mmoiwgg/ | 379 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mmoiwgg
//@version=4
study(title="ATR Start & Stop Bot", overlay = true)
//Inputs
res = input(title="Timeframe (check tooltip)", type=input.resolution, defval= "240", tooltip="Set the timeframe to a 4 hour if you are not using a 4 hour chart.")
nATRPeriod = input(10, title="ATR Period", tooltip="Try using Period 5 and Multiplier 3.5 on the 4 hour chart if default settings are not the best.")
nATRMultip = input(3, title="ATR Multiplier", step=0.10, tooltip="Make sure you are using this on a 4 hour chart.")
resScript = security(syminfo.tickerid, res, nATRMultip * atr(nATRPeriod))
xATRTrailingStop = 0.0
xATRTrailingStop := iff(close > nz(xATRTrailingStop[1], 0) and close[1] > nz(xATRTrailingStop[1], 0), max(nz(xATRTrailingStop[1]), close - resScript),
iff(close < nz(xATRTrailingStop[1], 0) and close[1] < nz(xATRTrailingStop[1], 0), min(nz(xATRTrailingStop[1]), close + resScript),
iff(close > nz(xATRTrailingStop[1], 0), close - resScript, close + resScript)))
pos = 0.0
pos := iff(close[1] < nz(xATRTrailingStop[1], 0) and close > nz(xATRTrailingStop[1], 0), 1,
iff(close[1] > nz(xATRTrailingStop[1], 0) and close < nz(xATRTrailingStop[1], 0), -1, nz(pos[1], 0)))
color = pos == -1 ? color.red: pos == 1 ? color.green : color.blue
plot(xATRTrailingStop, color=color, linewidth=3, title="ATR Trailing Stop")
long = pos == 1
short = pos == -1
last_long = 0.0
last_short = 0.0
last_long := long ? time : nz(last_long[1])
last_short := short ? time : nz(last_short[1])
long_signal = crossover(last_long, last_short)
short_signal = crossover(last_short, last_long)
StartBot = long_signal
StopBot = short_signal
// Plots Candle Colors
colors = last_long > last_short ? color.green : color.red
plotcandle(open, high, low, close, color=colors)
//Alerts
alertcondition(StartBot, title='Start Bot', message='Start Bot')
alertcondition(StopBot, title='Stop Bot',message='Stop Bot') |
Premium Rolling APY Calculator | https://www.tradingview.com/script/jZCm1iLC-Premium-Rolling-APY-Calculator/ | fuyeiwk | https://www.tradingview.com/u/fuyeiwk/ | 109 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © fuyeiwk
//@version=4
study("Premium Rolling APY Calculator", precision=2, format=format.percent)
//study("FTX BTC Premium Rolling APY")
resolution = input(title="Resolution", type=input.resolution, defval="1440")
apy = input(title="Show numbers in annual", type=input.bool, defval=true)
base_symbol = input(title="Base Symbol" , type=input.symbol, defval="FTX:BTCUSD")
future_1 = input(title="", type=input.symbol, defval="FTX:BTC0624", group="Future Symbol 1", inline="1")
future_2 = input(title="", type=input.symbol, defval="FTX:BTC0930", group="Future Symbol 2", inline="2")
p1 = security(future_1 , resolution, close)
p2 = security(future_2 , resolution, close)
spot = security(base_symbol, resolution, close)
t1 = time
t2 = input(title="Expire at", type=input.time, defval=timestamp("24 Jun 2022 16:00 +0800"), group="Future Symbol 1", inline="1") // expire date time of q3 future
t3 = input(title="Expire at", type=input.time, defval=timestamp("30 Sep 2022 16:00 +0800"), group="Future Symbol 2", inline="2") // expire date time of q4 future
premium_1 = ((p1 - spot)/spot)
premium_2 = ((p2 - spot)/spot)
daysBetween(t1,t2) => float((t2-t1)/(1000*60*60*24))
d1 = daysBetween(t1, t2)
d2 = daysBetween(t1, t3)
rolling_1 = premium_1*(apy ? 365/d1 : 1)*100
rolling_2 = premium_2*(apy ? 365/d2 : 1)*100
plot(rolling_1, title="Q3 0924")
plot(rolling_2, title="Q4 1231", color=#ff3399)
hline(5, title="5% Line", color=#ffaa99, linestyle=hline.style_dashed)
|
Ticker Summary | https://www.tradingview.com/script/S7tfbTt5-Ticker-Summary/ | apxsfo | https://www.tradingview.com/u/apxsfo/ | 49 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © apxsfo
//@version=5
indicator('Ticker Summary', overlay=true)
mil_or_bil_or_unknown(val) =>
val >= 1000000000 ? str.tostring(math.round(val / 1000000000, 1)) + 'B' : val > 0 ? str.tostring(math.round(val / 1000000, 1)) + 'M' : '???'
reticule = input(title='ATR reticule', defval=true)
ma = input.int(title='Moving Average Bars', defval=10, options=[10, 20, 30, 50, 100, 200])
short_ratio_ma_length = input(defval=14, title='Short ratio days')
atrpDays = input(defval=14, title='ATRP days')
textColor = input.color(defval=color.orange, title="Text color")
maExtensionColor = input.color(defval=color.orange, title="Reticule MA extension color")
openExtensionColor = input.color(defval=color.yellow, title="Reticule Close extension color")
balance = input(title='Balance', defval=25000)
maxRisk = input.float(title='Max Risk %', defval=1)
atrValue = request.security(syminfo.tickerid, 'D', ta.atr(atrpDays))
atrp = atrValue / close * 100
atrpExtension = (close - ta.sma(close, ma)) / atrValue
valuePerSecond = ta.sma(volume * ((high + low + close) / 3) / 23400, 14)
rValue = balance * (maxRisk / 100) * close / ta.atr(14)
rFrequency = rValue / valuePerSecond
premarketUpperBand = open + atrValue
premarketDoubleUpperBand = open + atrValue * 2
premarketLowerBand = open - atrValue
premarketDoubleLowerBand = open - atrValue * 2
aveVolume = ta.sma(volume, short_ratio_ma_length)
finra_fnyx = 'QUANDL:FINRA/FNYX_' + syminfo.ticker
finra_fnsq = 'QUANDL:FINRA/FNSQ_' + syminfo.ticker
totalShortInterest = request.security(finra_fnyx, 'D', close, barmerge.gaps_on) + request.security(finra_fnsq, 'D', close, barmerge.gaps_on)
shortRatio = totalShortInterest / aveVolume
floatShares = request.financial(syminfo.tickerid, 'FLOAT_SHARES_OUTSTANDING', 'FY')
totalShares = request.financial(syminfo.tickerid, 'TOTAL_SHARES_OUTSTANDING', 'FY')
summaryText = 'Float: ' + mil_or_bil_or_unknown(floatShares) + '/' + mil_or_bil_or_unknown(totalShares) + '\nMkt cap: ' + mil_or_bil_or_unknown(totalShares * close) + '\nShort ratio: ' + str.tostring(math.round(shortRatio, 2)) + '\nATRP: ' + str.tostring(math.round(atrp, 2)) + '\nR freq: ' + str.tostring(math.round(rFrequency, 2)) + ' sec'
summaryLabel = label.new(bar_index + 4, (low + high)/2, summaryText, textcolor=textColor, color=color.new(color.black, 100), style=label.style_label_upper_left, textalign=text.align_right)
label.delete(summaryLabel[1])
doubleUpperLabel = label.new(bar_index, premarketDoubleUpperBand, textcolor=openExtensionColor, color=color.new(color.black, 100), text=reticule ? '+2' : '', style=label.style_label_right)
upperLabel = label.new(bar_index, premarketUpperBand, textcolor=openExtensionColor, color=color.new(color.black, 100), text=reticule ? '+1' : '', style=label.style_label_right)
openLabel = label.new(bar_index, open, textcolor=openExtensionColor, color=color.new(color.black, 100), text=reticule ? '+0' : '', style=label.style_label_right)
lowerLabel = label.new(bar_index, premarketLowerBand, textcolor=openExtensionColor, color=color.new(color.black, 100), text=reticule ? '-1' : '', style=label.style_label_right)
doubleLowerLabel = label.new(bar_index, premarketDoubleLowerBand, textcolor=openExtensionColor, color=color.new(color.black, 100), text=reticule ? '-2' : '', style=label.style_label_right)
noExtensionLabel = label.new(bar_index, ta.sma(close, ma), textcolor=maExtensionColor, color=color.new(color.black, 100), text=reticule ? '+0' : '', style=label.style_label_left)
oneExtensionLabel = label.new(bar_index, ta.sma(close, ma) + atrValue, textcolor=maExtensionColor, color=color.new(color.black, 100), text=reticule ? '+1' : '', style=label.style_label_left)
twoExtensionLabel = label.new(bar_index, ta.sma(close, ma) + 2 * atrValue, textcolor=maExtensionColor, color=color.new(color.black, 100), text=reticule ? '+2' : '', style=label.style_label_left)
threeExtensionLabel = label.new(bar_index, ta.sma(close, ma) + 3 * atrValue, textcolor=maExtensionColor, color=color.new(color.black, 100), text=reticule ? '+3' : '', style=label.style_label_left)
oneMinusExtensionLabel = label.new(bar_index, ta.sma(close, ma) - atrValue, textcolor=maExtensionColor, color=color.new(color.black, 100), text=reticule ? '+1' : '', style=label.style_label_left)
twoMinusExtensionLabel = label.new(bar_index, ta.sma(close, ma) - 2 * atrValue, textcolor=maExtensionColor, color=color.new(color.black, 100), text=reticule ? '+2' : '', style=label.style_label_left)
threeMinusExtensionLabel = label.new(bar_index, ta.sma(close, ma) - 3 * atrValue, textcolor=maExtensionColor, color=color.new(color.black, 100), text=reticule ? '+3' : '', style=label.style_label_left)
label.delete(doubleUpperLabel[1])
label.delete(upperLabel[1])
label.delete(openLabel[1])
label.delete(lowerLabel[1])
label.delete(doubleLowerLabel[1])
label.delete(noExtensionLabel[1])
label.delete(oneExtensionLabel[1])
label.delete(twoExtensionLabel[1])
label.delete(threeExtensionLabel[1])
label.delete(oneMinusExtensionLabel[1])
label.delete(twoMinusExtensionLabel[1])
label.delete(threeMinusExtensionLabel[1])
|
Fundamnetals + Strength + RiskManagement | https://www.tradingview.com/script/SsFOvpjv-Fundamnetals-Strength-RiskManagement/ | cvsinghh | https://www.tradingview.com/u/cvsinghh/ | 160 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// credits to© HeWhoMustNotBeNamed and @Tradingview
// cvsingh-Added Risk Management
//@version=4
study("Fundamnetals + Strenth + RiskManagement", overlay=true)
res = input("", title="Indicator Timeframe", type=input.resolution)
ratingSignal = input(defval = "All", title = "Rating is based on", options = ["MAs", "Oscillators", "All"])
Position = input(title="Table Position", defval=position.bottom_right,
options=[
position.bottom_center, position.bottom_left, position.bottom_right,
position.middle_center, position.middle_left, position.middle_right,
position.top_center, position.top_left, position.top_right
])
textSize = input(title="Text Size", defval=size.small, options=[size.huge, size.large, size.normal, size.small, size.tiny, size.auto])
capital = input(title="Capital", defval=100000, group="Risk Management")
risk = input(title="% Risk", defval=1, group="Risk Management")
lookback = input(title="Lookback for SL", defval=10, group="Risk Management")
viewFunda = input(title="View Fundamentals?", defval=true, group="Fundamentals")
viewSolvency = input(title="View Solvency?", defval=true, group="Fundamentals")
viewProfit = input(title="View Profitaility?", defval=true, group="Fundamentals")
viewLiquidity = input(title="View Liquidity?", defval=true, group="Fundamentals")
viewGrowth = input(title="View Growth?", defval=true, group="Fundamentals")
viewTech = input(title="View Technicals?", defval=true, group="Technicals")
viewStrenth = input(title="View Strenth?", defval=true, group="Technicals")
viewRisk= input(title="View RiskManagement?", defval=true, group="Technicals")
useMtf1 = input(false, "", type=input.bool, inline="mtf1", group="Show MTF")
mtf1 = input("60", "", type=input.resolution, inline="mtf1", group="Show MTF")
useMtf2 = input(false, "", type=input.bool, inline="mtf2", group="Show MTF")
mtf2 = input("240", "", type=input.resolution, inline="mtf2", group="Show MTF")
useMtf3 = input(true, "", type=input.bool, inline="mtf3", group="Show MTF")
mtf3 = input("1D", "", type=input.resolution, inline="mtf3", group="Show MTF")
useMtf4 = input(true, "", type=input.bool, inline="mtf4", group="Show MTF")
mtf4 = input("1W", "", type=input.resolution, inline="mtf4", group="Show MTF")
useMtf5 = input(true, "", type=input.bool, inline="mtf5", group="Show MTF")
mtf5 = input("1M", "", type=input.resolution, inline="mtf5", group="Show MTF")
colBuy = input(#5b9cf6, "Buy ", group="Color Settings", inline="Buy Colors")
colStrongBuy = input(#2962ff, "", group="Color Settings", inline="Buy Colors")
colNeutral = input(#a8adbc, "Neutral ", group="Color Settings", inline="Neutral")
colSell = input(#ef9a9a, "Sell ", group="Color Settings", inline="Sell Colors")
colStrongSell = input(#f44336, "", group="Color Settings", inline="Sell Colors")
tableTitleColor = input(#295b79, "Headers", group="Color Settings", inline="Headers")
period = "FY"
sl = lowest(low, lookback)
maxloss = capital*(risk/100)
position = int(maxloss/(close-sl))
invetment = close*position
f_getFinancials(financial_id, period) => financial(syminfo.tickerid, financial_id, period)
f_getColorByScore(score) => (score == 2 ? color.green : score == 1? color.lime : score == 0? color.silver : score == -1? color.orange : score == -2? color.red : color.purple)
f_getOptimalFinancialBasic(financial_id) =>
f_getFinancials(financial_id, syminfo.currency == "USD"? "FQ" : "FY")
//////Calculations
// Awesome Oscillator
AO() =>
sma(hl2, 5) - sma(hl2, 34)
// Stochastic RSI
StochRSI() =>
rsi1 = rsi(close, 14)
K = sma(stoch(rsi1, rsi1, rsi1, 14), 3)
D = sma(K, 3)
[K, D]
// Ultimate Oscillator
tl() => close[1] < low ? close[1]: low
uo(ShortLen, MiddlLen, LongLen) =>
Value1 = sum(tr, ShortLen)
Value2 = sum(tr, MiddlLen)
Value3 = sum(tr, LongLen)
Value4 = sum(close - tl(), ShortLen)
Value5 = sum(close - tl(), MiddlLen)
Value6 = sum(close - tl(), LongLen)
float UO = na
if Value1 != 0 and Value2 != 0 and Value3 != 0
var0 = LongLen / ShortLen
var1 = LongLen / MiddlLen
Value7 = (Value4 / Value1) * (var0)
Value8 = (Value5 / Value2) * (var1)
Value9 = (Value6 / Value3)
UO := (Value7 + Value8 + Value9) / (var0 + var1 + 1)
UO
// Ichimoku Cloud
donchian(len) => avg(lowest(len), highest(len))
ichimoku_cloud() =>
conversionLine = donchian(9)
baseLine = donchian(26)
leadLine1 = avg(conversionLine, baseLine)
leadLine2 = donchian(52)
[conversionLine, baseLine, leadLine1, leadLine2]
calcRatingMA(ma, src) => na(ma) or na(src) ? na : (ma == src ? 0 : ( ma < src ? 1 : -1 ))
calcRating(buy, sell) => buy ? 1 : ( sell ? -1 : 0 )
calcRatingAll() =>
//============== MA =================
SMA10 = sma(close, 10)
SMA20 = sma(close, 20)
SMA30 = sma(close, 30)
SMA50 = sma(close, 50)
SMA100 = sma(close, 100)
SMA200 = sma(close, 200)
EMA10 = ema(close, 10)
EMA20 = ema(close, 20)
EMA30 = ema(close, 30)
EMA50 = ema(close, 50)
EMA100 = ema(close, 100)
EMA200 = ema(close, 200)
HullMA9 = hma(close, 9)
// Volume Weighted Moving Average (VWMA)
VWMA = vwma(close, 20)
[IC_CLine, IC_BLine, IC_Lead1, IC_Lead2] = ichimoku_cloud()
// ======= Other =============
// Relative Strength Index, RSI
RSI = rsi(close,14)
// Stochastic
lengthStoch = 14
smoothKStoch = 3
smoothDStoch = 3
kStoch = sma(stoch(close, high, low, lengthStoch), smoothKStoch)
dStoch = sma(kStoch, smoothDStoch)
// Commodity Channel Index, CCI
CCI = cci(close, 20)
// Average Directional Index
float adxValue = na, float adxPlus = na, float adxMinus = na
[P, M, V] = dmi(14, 14)
adxValue := V
adxPlus := P
adxMinus := M
// Awesome Oscillator
ao = AO()
// Momentum
Mom = mom(close, 10)
// Moving Average Convergence/Divergence, MACD
[macdMACD, signalMACD, _] = macd(close, 12, 26, 9)
// Stochastic RSI
[Stoch_RSI_K, Stoch_RSI_D] = StochRSI()
// Williams Percent Range
WR = wpr(14)
// Bull / Bear Power
BullPower = high - ema(close, 13)
BearPower = low - ema(close, 13)
// Ultimate Oscillator
UO = uo(7,14,28)
if not na(UO)
UO := UO * 100
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
PriceAvg = ema(close, 50)
DownTrend = close < PriceAvg
UpTrend = close > PriceAvg
// calculate trading recommendation based on SMA/EMA
float ratingMA = 0
float ratingMAC = 0
float ratingSMA10 = na
if not na(SMA10)
ratingSMA10 := calcRatingMA(SMA10, close)
ratingMA := ratingMA + ratingSMA10
ratingMAC := ratingMAC + 1
float ratingSMA20 = na
if not na(SMA20)
ratingSMA20 := calcRatingMA(SMA20, close)
ratingMA := ratingMA + ratingSMA20
ratingMAC := ratingMAC + 1
float ratingSMA30 = na
if not na(SMA30)
ratingSMA30 := calcRatingMA(SMA30, close)
ratingMA := ratingMA + ratingSMA30
ratingMAC := ratingMAC + 1
float ratingSMA50 = na
if not na(SMA50)
ratingSMA50 := calcRatingMA(SMA50, close)
ratingMA := ratingMA + ratingSMA50
ratingMAC := ratingMAC + 1
float ratingSMA100 = na
if not na(SMA100)
ratingSMA100 := calcRatingMA(SMA100, close)
ratingMA := ratingMA + ratingSMA100
ratingMAC := ratingMAC + 1
float ratingSMA200 = na
if not na(SMA200)
ratingSMA200 := calcRatingMA(SMA200, close)
ratingMA := ratingMA + ratingSMA200
ratingMAC := ratingMAC + 1
float ratingEMA10 = na
if not na(EMA10)
ratingEMA10 := calcRatingMA(EMA10, close)
ratingMA := ratingMA + ratingEMA10
ratingMAC := ratingMAC + 1
float ratingEMA20 = na
if not na(EMA20)
ratingEMA20 := calcRatingMA(EMA20, close)
ratingMA := ratingMA + ratingEMA20
ratingMAC := ratingMAC + 1
float ratingEMA30 = na
if not na(EMA30)
ratingEMA30 := calcRatingMA(EMA30, close)
ratingMA := ratingMA + ratingEMA30
ratingMAC := ratingMAC + 1
float ratingEMA50 = na
if not na(EMA50)
ratingEMA50 := calcRatingMA(EMA50, close)
ratingMA := ratingMA + ratingEMA50
ratingMAC := ratingMAC + 1
float ratingEMA100 = na
if not na(EMA100)
ratingEMA100 := calcRatingMA(EMA100, close)
ratingMA := ratingMA + ratingEMA100
ratingMAC := ratingMAC + 1
float ratingEMA200 = na
if not na(EMA200)
ratingEMA200 := calcRatingMA(EMA200, close)
ratingMA := ratingMA + ratingEMA200
ratingMAC := ratingMAC + 1
float ratingHMA = na
if not na(HullMA9)
ratingHMA := calcRatingMA(HullMA9, close)
ratingMA := ratingMA + ratingHMA
ratingMAC := ratingMAC + 1
float ratingVWMA = na
if not na(VWMA)
ratingVWMA := calcRatingMA(VWMA, close)
ratingMA := ratingMA + ratingVWMA
ratingMAC := ratingMAC + 1
float ratingIC = na
if not (na(IC_Lead1) or na(IC_Lead2) or na(close) or na(close[1]) or na(IC_BLine) or na(IC_CLine))
ratingIC := calcRating(
IC_Lead1 > IC_Lead2 and close > IC_Lead1 and close < IC_BLine and close[1] < IC_CLine and close > IC_CLine,
IC_Lead2 > IC_Lead1 and close < IC_Lead2 and close > IC_BLine and close[1] > IC_CLine and close < IC_CLine)
if not na(ratingIC)
ratingMA := ratingMA + ratingIC
ratingMAC := ratingMAC + 1
ratingMA := ratingMAC > 0 ? ratingMA / ratingMAC : na
float ratingOther = 0
float ratingOtherC = 0
float ratingRSI = na
if not(na(RSI) or na(RSI[1]))
ratingRSI := calcRating(RSI < 30 and RSI[1] < RSI, RSI > 70 and RSI[1] > RSI)
ratingOtherC := ratingOtherC + 1
ratingOther := ratingOther + ratingRSI
float ratingStoch = na
if not(na(kStoch) or na(dStoch) or na(kStoch[1]) or na(dStoch[1]))
ratingStoch := calcRating(kStoch < 20 and dStoch < 20 and kStoch > dStoch and kStoch[1] < dStoch[1], kStoch > 80 and dStoch > 80 and kStoch < dStoch and kStoch[1] > dStoch[1])
ratingOtherC := ratingOtherC + 1
ratingOther := ratingOther + ratingStoch
float ratingCCI = na
if not(na(CCI) or na(CCI[1]))
ratingCCI := calcRating(CCI < -100 and CCI > CCI[1], CCI > 100 and CCI < CCI[1])
ratingOtherC := ratingOtherC + 1
ratingOther := ratingOther + ratingCCI
float ratingADX = na
if not(na(adxValue) or na(adxPlus[1]) or na(adxMinus[1]) or na(adxPlus) or na(adxMinus))
ratingADX := calcRating(adxValue > 20 and adxPlus[1] < adxMinus[1] and adxPlus > adxMinus, adxValue > 20 and adxPlus[1] > adxMinus[1] and adxPlus < adxMinus)
ratingOtherC := ratingOtherC + 1
ratingOther := ratingOther + ratingADX
float ratingAO = na
if not(na(ao) or na(ao[1]))
ratingAO := calcRating(crossover(ao,0) or (ao > 0 and ao[1] > 0 and ao > ao[1] and ao[2] > ao[1]), crossunder(ao,0) or (ao < 0 and ao[1] < 0 and ao < ao[1] and ao[2] < ao[1]))
ratingOtherC := ratingOtherC + 1
ratingOther := ratingOther + ratingAO
float ratingMOM = na
if not(na(Mom) or na(Mom[1]))
ratingMOM := calcRating(Mom > Mom[1], Mom < Mom[1])
ratingOtherC := ratingOtherC + 1
ratingOther := ratingOther + ratingMOM
float ratingMACD = na
if not(na(macdMACD) or na(signalMACD))
ratingMACD := calcRating(macdMACD > signalMACD, macdMACD < signalMACD)
ratingOtherC := ratingOtherC + 1
ratingOther := ratingOther + ratingMACD
float ratingStoch_RSI = na
if not(na(DownTrend) or na(UpTrend) or na(Stoch_RSI_K) or na(Stoch_RSI_D) or na(Stoch_RSI_K[1]) or na(Stoch_RSI_D[1]))
ratingStoch_RSI := calcRating(
DownTrend and Stoch_RSI_K < 20 and Stoch_RSI_D < 20 and Stoch_RSI_K > Stoch_RSI_D and Stoch_RSI_K[1] < Stoch_RSI_D[1],
UpTrend and Stoch_RSI_K > 80 and Stoch_RSI_D > 80 and Stoch_RSI_K < Stoch_RSI_D and Stoch_RSI_K[1] > Stoch_RSI_D[1])
if not na(ratingStoch_RSI)
ratingOtherC := ratingOtherC + 1
ratingOther := ratingOther + ratingStoch_RSI
float ratingWR = na
if not(na(WR) or na(WR[1]))
ratingWR := calcRating(WR < -80 and WR > WR[1], WR > -20 and WR < WR[1])
if not na(ratingWR)
ratingOtherC := ratingOtherC + 1
ratingOther := ratingOther + ratingWR
float ratingBBPower = na
if not(na(UpTrend) or na(DownTrend) or na(BearPower) or na(BearPower[1]) or na(BullPower) or na(BullPower[1]))
ratingBBPower := calcRating(
UpTrend and BearPower < 0 and BearPower > BearPower[1],
DownTrend and BullPower > 0 and BullPower < BullPower[1])
if not na(ratingBBPower)
ratingOtherC := ratingOtherC + 1
ratingOther := ratingOther + ratingBBPower
float ratingUO = na
if not(na(UO))
ratingUO := calcRating(UO > 70, UO < 30)
if not na(ratingUO)
ratingOtherC := ratingOtherC + 1
ratingOther := ratingOther + ratingUO
ratingOther := ratingOtherC > 0 ? ratingOther / ratingOtherC : na
float ratingTotal = 0
float ratingTotalC = 0
if not na(ratingMA)
ratingTotal := ratingTotal + ratingMA
ratingTotalC := ratingTotalC + 1
if not na(ratingOther)
ratingTotal := ratingTotal + ratingOther
ratingTotalC := ratingTotalC + 1
ratingTotal := ratingTotalC > 0 ? ratingTotal / ratingTotalC : na
[ratingTotal, ratingOther, ratingMA]
StrongBound = 0.5
WeakBound = 0.1
getSignal(ratingTotal, ratingOther, ratingMA) =>
float _res = ratingTotal
if ratingSignal == "MAs"
_res := ratingMA
if ratingSignal == "Oscillators"
_res := ratingOther
_res
[ratingTotalCurrent, ratingOtherCurrent, ratingMACurrent] = security(syminfo.tickerid, res, calcRatingAll())
[ratingTotal_mtf1, ratingOther_mtf1, ratingMA_mtf1] = security(syminfo.tickerid, mtf1, calcRatingAll())
[ratingTotal_mtf2, ratingOther_mtf2, ratingMA_mtf2] = security(syminfo.tickerid, mtf2, calcRatingAll())
[ratingTotal_mtf3, ratingOther_mtf3, ratingMA_mtf3] = security(syminfo.tickerid, mtf3, calcRatingAll())
[ratingTotal_mtf4, ratingOther_mtf4, ratingMA_mtf4] = security(syminfo.tickerid, mtf4, calcRatingAll())
[ratingTotal_mtf5, ratingOther_mtf5, ratingMA_mtf5] = security(syminfo.tickerid, mtf5, calcRatingAll())
tradeSignal = getSignal(ratingTotalCurrent, ratingOtherCurrent, ratingMACurrent)
calcRatingStatus(value) =>
if na(value)
"-"
else if -StrongBound > value
"Strong\nSell"
else if value < -WeakBound
"Sell "
else if value > StrongBound
"Strong\nBuy "
else if value > WeakBound
"Buy "
else
"Neutral"
allRatingsArray = array.from("All", calcRatingStatus(ratingTotalCurrent), calcRatingStatus(ratingTotal_mtf1), calcRatingStatus(ratingTotal_mtf2),
calcRatingStatus(ratingTotal_mtf3), calcRatingStatus(ratingTotal_mtf4), calcRatingStatus(ratingTotal_mtf5))
oscRatingsArray = array.from("Osc", calcRatingStatus(ratingOtherCurrent), calcRatingStatus(ratingOther_mtf1), calcRatingStatus(ratingOther_mtf2),
calcRatingStatus(ratingOther_mtf3), calcRatingStatus(ratingOther_mtf4), calcRatingStatus(ratingOther_mtf5))
maRatingsArray = array.from("MAs", calcRatingStatus(ratingMACurrent), calcRatingStatus(ratingMA_mtf1), calcRatingStatus(ratingMA_mtf2),
calcRatingStatus(ratingMA_mtf3), calcRatingStatus(ratingMA_mtf4), calcRatingStatus(ratingMA_mtf5))
currentRes = res==""?timeframe.period=="D"?"1D":
timeframe.period=="W"?"1W":
timeframe.period=="M"?"1M":
timeframe.period:res
allResArray = array.from("TF", currentRes, mtf1, mtf2, mtf3, mtf4, mtf5)
usedMtfArray = array.from(true, true, useMtf1, useMtf2, useMtf3, useMtf4, useMtf5)
removeUnused(duplicatedIndex) =>
if array.size(duplicatedIndex) > 0
for j=0 to array.size(duplicatedIndex)-1
int currentDupIndex = array.shift(duplicatedIndex)
array.remove(allResArray, currentDupIndex-j)
array.remove(usedMtfArray, currentDupIndex-j)
array.remove(allRatingsArray, currentDupIndex-j)
array.remove(oscRatingsArray, currentDupIndex-j)
array.remove(maRatingsArray, currentDupIndex-j)
eraseDuplicatedAndDisabledTf() =>
int[] duplicatedIndex = array.new_int()
for m=1 to array.size(allResArray)-1
bool isCurrentMtfDisabled = array.get(usedMtfArray, m) == false
if isCurrentMtfDisabled
array.push(duplicatedIndex, m)
removeUnused(duplicatedIndex)
for m=1 to array.size(allResArray)-1
int firstSearchElemIndex = array.indexof(allResArray, array.get(allResArray, m))
int lastSearchElemIndex = array.lastindexof(allResArray, array.get(allResArray, m))
if firstSearchElemIndex == lastSearchElemIndex or array.indexof(duplicatedIndex, lastSearchElemIndex) != -1
continue
string searchElem = array.get(allResArray, firstSearchElemIndex)
for i=firstSearchElemIndex+1 to lastSearchElemIndex
string currentElem = array.get(allResArray, i)
if searchElem == currentElem
array.push(duplicatedIndex, i)
removeUnused(duplicatedIndex)
poscond = tradeSignal > WeakBound
negcond = tradeSignal < -WeakBound
posseries = poscond ? tradeSignal : 0
negseries = negcond ? tradeSignal : 0
count_rising(plot) =>
v_plot = plot > 0 ? plot : -plot
var count = 0
if v_plot == 0
count := 0
else if v_plot >= v_plot[1]
count := min(5, count + 1)
else if v_plot < v_plot[1]
count := max(1, count - 1)
count
poscount = count_rising(posseries)
negcount = count_rising(negseries)
_pc = poscond ? poscount : negcond ? negcount : 0
colorTransp(col, transp) =>
red = color.r(col)
green = color.g(col)
blue = color.b(col)
color.rgb(red, green, blue, transp)
//hline(1, color=colorTransp(colBuy, 50), linestyle=hline.style_solid)
//hline(0.5, color=colorTransp(colBuy, 50), linestyle=hline.style_dashed)
//hline(-1, color=colorTransp(colSell, 50), linestyle=hline.style_solid)
//hline(-0.5, color=colorTransp(colSell, 50), linestyle=hline.style_dashed)
f_cellBgColor(_signal) =>
_returnColor = tableTitleColor
if _signal == "Sell "
_returnColor := colSell
else if _signal == "Strong\nSell"
_returnColor := colStrongSell
else if _signal == "Buy "
_returnColor := colBuy
else if _signal == "Strong\nBuy "
_returnColor := colStrongBuy
else if _signal == "Neutral" or _signal == "-"
_returnColor := colNeutral
_returnColor
f_cellAlign(_cellTitle) =>
_align = text.align_left
if _cellTitle == "MAs" or _cellTitle == "Osc" or _cellTitle == "All" or _cellTitle == "-"
_align := text.align_center
_align
f_addCell(_table, _column, _row, _cellTitle) =>
table.cell(_table, _column, _row, _cellTitle, text_color=color.white, text_halign=f_cellAlign(_cellTitle), bgcolor=f_cellBgColor(_cellTitle), text_size=size.small)
if barstate.islast
deq = f_getOptimalFinancialBasic("DEBT_TO_EQUITY")
dta = f_getOptimalFinancialBasic("DEBT_TO_ASSET")
ldta = f_getOptimalFinancialBasic("LONG_TERM_DEBT_TO_ASSETS")
altzscore = f_getOptimalFinancialBasic("ALTMAN_Z_SCORE")
springate = f_getFinancials("SPRINGATE_SCORE", "FY")
currentRatio = f_getOptimalFinancialBasic("CURRENT_RATIO")
quickRatio = f_getOptimalFinancialBasic("QUICK_RATIO")
sloanRatio = f_getOptimalFinancialBasic("SLOAN_RATIO")
interestCover = f_getOptimalFinancialBasic("INTERST_COVER")
roa = f_getOptimalFinancialBasic("RETURN_ON_ASSETS")
roe = f_getOptimalFinancialBasic("RETURN_ON_EQUITY")
roic = f_getOptimalFinancialBasic("RETURN_ON_INVESTED_CAPITAL")
netMargin = f_getFinancials("NET_MARGIN", "FY")
fcfMargin = f_getFinancials("FREE_CASH_FLOW_MARGIN", "FY")
pfScore = f_getOptimalFinancialBasic("PIOTROSKI_F_SCORE")
sgr = f_getOptimalFinancialBasic("SUSTAINABLE_GROWTH_RATE")
orientation = Position == position.bottom_center or Position == position.middle_center or Position == position.top_center? 2:
Position == position.bottom_left or Position == position.middle_left or Position == position.top_left? 1 : 3
var financialTable = table.new(position = Position, columns = 10, rows = 20, border_width = 1)
columnSolvency = orientation == 1? 2 : orientation == 3? 0 : 0
columnProfitability = orientation == 1? 2 : orientation == 3? 0 : 2
columnLiquidity = orientation == 1? 2 : orientation == 3? 0 : 4
columnGrowth = orientation == 1? 2 : orientation == 3? 0 : 6
columnRisk = orientation == 1? 2 : orientation == 3? 0 : 8
//columnStrenth = orientation == 1? 2 : orientation == 3? 0 : 10
rowSolvency = orientation == 2? 0 : 0
rowProfitability = orientation == 2? 0 : 5
rowLiquidity = orientation == 2? 0 : 10
rowGrowth = orientation == 2? 0 : 14
rowRisk = orientation == 2? 0 : 16
//rowStrenth = orientation == 2? 0 : 19
columnValSolvency = orientation == 1? 0 : orientation == 3? 1 : 0
columnValProfitability = orientation == 1? 0 : orientation == 3? 1 : 2
columnValLiquidity = orientation == 1? 0 : orientation == 3? 1 : 4
columnValGrowth = orientation == 1? 0 : orientation == 3? 1 : 6
columnValRisk = orientation == 1? 0 : orientation == 3? 1 : 8
//columnValStrenth = orientation == 1? 0 : orientation == 3? 1 : 10
rowValSolvency = orientation == 2? 1 : 0
rowValProfitability = orientation == 2? 1 : 5
rowValLiquidity = orientation == 2? 1 : 10
rowValGrowth = orientation == 2? 1 : 14
rowValRisk = orientation == 2? 1 : 16
//rowValStrenth = orientation == 2? 1 : 19
if (viewFunda == false)
viewSolvency := viewFunda
viewProfit := viewFunda
viewLiquidity := viewFunda
viewGrowth := viewFunda
if (viewTech == false)
viewRisk := viewTech
viewStrenth := viewTech
if (viewSolvency == true) //solvency
table.cell(table_id = financialTable, column = columnSolvency, row = rowSolvency , text = "Solvency", bgcolor=color.black, text_color=color.white, text_size=textSize)
if (viewProfit == true) //profitability
table.cell(table_id = financialTable, column = columnProfitability, row = rowProfitability, text = "Profitability", bgcolor=color.black, text_color=color.white, text_size=textSize)
if (viewLiquidity == true) //viewLiquidity
table.cell(table_id = financialTable, column = columnLiquidity, row = rowLiquidity, text = "Liquidity", bgcolor=color.black, text_color=color.white, text_size=textSize)
if (viewGrowth == true) //Growth
table.cell(table_id = financialTable, column = columnGrowth, row = rowGrowth, text = "Value/Growth", bgcolor=color.black, text_color=color.white, text_size=textSize)
if (viewRisk == true) //Risk
table.cell(table_id = financialTable, column = columnRisk, row = rowRisk , text = "Risk Management", bgcolor=color.black, text_color=color.white, text_size=textSize)
//if (viewStrenth == true) //Risk
// table.cell(table_id = financialTable, column = columnStrenth, row = rowStrenth , text = "Technical Strength", bgcolor=color.black, text_color=color.white, text_size=textSize)
if (viewSolvency == true) //solvency
deq_score = na(deq)? 0 : deq > 0.0 and deq <= 1.0 ? 2 : deq > 1.0 and deq <= 2.0 ? 1 : deq > 2 ? -1 : -2
table.cell(table_id = financialTable, column = columnValSolvency, row = rowValSolvency, text = "DEBT_TO_EQUITY", bgcolor=f_getColorByScore(deq_score), text_size=textSize)
table.cell(table_id = financialTable, column = columnValSolvency+1, row = rowValSolvency, text = tostring(deq), bgcolor=f_getColorByScore(deq_score), text_size=textSize)
dta_score = na(dta)? 0 : dta > 0.0 and dta <= 0.2 ? 2 : dta > 0.2 and dta <= 0.4 ? 1 : dta > 0.4 and dta <= 0.6 ? 0 : dta > 0.6 ? 1 : -2
table.cell(table_id = financialTable, column = columnValSolvency, row = rowValSolvency+1, text = "DEBT_TO_ASSET", bgcolor=f_getColorByScore(dta_score), text_size=textSize)
table.cell(table_id = financialTable, column = columnValSolvency+1, row = rowValSolvency+1, text = tostring(dta), bgcolor=f_getColorByScore(dta_score), text_size=textSize)
ldta_score = na(ldta)? 0 : ldta > 0.0 and ldta <= 0.2 ? 2 : ldta > 0.2 and ldta <= 0.4 ? 1 : ldta > 0.4 and ldta <= 0.6 ? 0 : ldta > 0.6 ? 1 : -2
table.cell(table_id = financialTable, column = columnValSolvency, row = rowValSolvency+2, text = "LONG_TERM_DEBT_TO_ASSETS", bgcolor=f_getColorByScore(ldta_score), text_size=textSize)
table.cell(table_id = financialTable, column = columnValSolvency+1, row = rowValSolvency+2, text = tostring(ldta), bgcolor=f_getColorByScore(ldta_score), text_size=textSize)
altz_score = na(altzscore)? 0 : altzscore > 5.0 ? 2 : altzscore > 3.0 ? 1 : altzscore > 1.8? 0 : altzscore > 1 ? -1 : -2
table.cell(table_id = financialTable, column = columnValSolvency, row = rowValSolvency+3, text = "ALTMAN_Z_SCORE", bgcolor=f_getColorByScore(altz_score), text_size=textSize)
table.cell(table_id = financialTable, column = columnValSolvency+1, row = rowValSolvency+3, text = tostring(altzscore), bgcolor=f_getColorByScore(altz_score), text_size=textSize)
//springate_score = na(springate)? 0 : springate > 0.862 ? 1 : -1
//table.cell(table_id = financialTable, column = columnValSolvency, row = rowValSolvency+4, text = "SPRINGATE_SCORE", bgcolor=f_getColorByScore(springate_score), text_size=textSize)
//table.cell(table_id = financialTable, column = columnValSolvency+1, row = rowValSolvency+4, text = tostring(springate), bgcolor=f_getColorByScore(springate_score), text_size=textSize)
if (viewProfit == true) //profitability
roe_score = na(roe)? 0 : roe >= 40? 2 : roe >=10 ? 1 : roe >=0 ? 0 : roe >= -20? -1 : -2
table.cell(table_id = financialTable, column = columnValProfitability, row = rowValProfitability, text = "RETURN_ON_EQUITY", bgcolor=f_getColorByScore(roe_score), text_size=textSize)
table.cell(table_id = financialTable, column = columnValProfitability+1, row = rowValProfitability, text = tostring(roe), bgcolor=f_getColorByScore(roe_score), text_size=textSize)
roa_score = na(roa)? 0 : roa >= 20? 2 : roa >=5 ? 1 : roa >=0 ? 0 : roa >= -10? -1 : -2
table.cell(table_id = financialTable, column = columnValProfitability, row = rowValProfitability+1, text = "RETURN_ON_ASSETS", bgcolor=f_getColorByScore(roa_score), text_size=textSize)
table.cell(table_id = financialTable, column = columnValProfitability+1, row = rowValProfitability+1, text = tostring(roa), bgcolor=f_getColorByScore(roa_score), text_size=textSize)
roic_score = na(roic)? 0 : roic >= 10? 2 : roic >=2 ? 1 : roic >=0 ? 0 : roic >= -5? -1 : -2
table.cell(table_id = financialTable, column = columnValProfitability, row = rowValProfitability+2, text = "RETURN_ON_INVESTED_CAPITAL", bgcolor=f_getColorByScore(roic_score), text_size=textSize)
table.cell(table_id = financialTable, column = columnValProfitability+1, row = rowValProfitability+2, text = tostring(roic), bgcolor=f_getColorByScore(roic_score), text_size=textSize)
netMargin_score = na(netMargin)? 0 : netMargin >= 20? 2 : netMargin >=10 ? 1 : netMargin >=0 ? 0 : netMargin >= -5? -1 : -2
table.cell(table_id = financialTable, column = columnValProfitability, row = rowValProfitability+3, text = "NET_MARGIN", bgcolor=f_getColorByScore(netMargin_score), text_size=textSize)
table.cell(table_id = financialTable, column = columnValProfitability+1, row = rowValProfitability+3, text = tostring(netMargin), bgcolor=f_getColorByScore(netMargin_score), text_size=textSize)
fcfMargin_score = na(fcfMargin)? 0 : fcfMargin >= 15? 2 : fcfMargin >=10 ? 1 : fcfMargin >=0 ? 0 : fcfMargin >= -10? -1 : -2
table.cell(table_id = financialTable, column = columnValProfitability, row = rowValProfitability+4, text = "FREE_CASH_FLOW_MARGIN", bgcolor=f_getColorByScore(fcfMargin_score), text_size=textSize)
table.cell(table_id = financialTable, column = columnValProfitability+1, row = rowValProfitability+4, text = tostring(fcfMargin), bgcolor=f_getColorByScore(fcfMargin_score), text_size=textSize)
if (viewLiquidity == true) //Liquidity
currentRatio_score = na(currentRatio)? 0 : currentRatio >= 1.2? (currentRatio <= 2.0 ? 2 : 1) : currentRatio >=1 ? 0 : currentRatio >=0.5 ? -1 : -2
table.cell(table_id = financialTable, column = columnValLiquidity, row = rowValLiquidity, text = "CURRENT_RATIO", bgcolor=f_getColorByScore(currentRatio_score), text_size=textSize)
table.cell(table_id = financialTable, column = columnValLiquidity+1, row = rowValLiquidity, text = tostring(currentRatio), bgcolor=f_getColorByScore(currentRatio_score), text_size=textSize)
quickRatio_score = na(quickRatio)? 0 : quickRatio >= 1.0? (quickRatio <= 2.0 ? 2 : 1) : quickRatio >=0.9 ? 0 : currentRatio >=0.4 ? -1 : -2
table.cell(table_id = financialTable, column = columnValLiquidity, row = rowValLiquidity+1, text = "QUICK_RATIO", bgcolor=f_getColorByScore(quickRatio_score), text_size=textSize)
table.cell(table_id = financialTable, column = columnValLiquidity+1, row = rowValLiquidity+1, text = tostring(quickRatio), bgcolor=f_getColorByScore(quickRatio_score), text_size=textSize)
//sloanRatio_score = na(sloanRatio)? 0 : abs(sloanRatio) < 10.0? 1 : abs(sloanRatio) < 25.0? 0 : -1
//table.cell(table_id = financialTable, column = columnValLiquidity, row = rowValLiquidity+2, text = "SLOAN_RATIO", bgcolor=f_getColorByScore(sloanRatio_score), text_size=textSize)
//table.cell(table_id = financialTable, column = columnValLiquidity+1, row = rowValLiquidity+2, text = tostring(sloanRatio), bgcolor=f_getColorByScore(sloanRatio_score), text_size=textSize)
interestCover_score = na(interestCover)? 0 : interestCover >3? 1 : interestCover >2? 0: -1
table.cell(table_id = financialTable, column = columnValLiquidity, row = rowValLiquidity+3, text = "INTERST_COVER", bgcolor=f_getColorByScore(interestCover_score), text_size=textSize)
table.cell(table_id = financialTable, column = columnValLiquidity+1, row = rowValLiquidity+3, text = tostring(interestCover), bgcolor=f_getColorByScore(interestCover_score), text_size=textSize)
if (viewGrowth == true) //Value/Growth
pf_score = na(pfScore)? 0 : pfScore >=8? 2 : pfScore >= 5 ? 1: pfScore >2 ? 0 : pfScore > 1? -1 : -2
table.cell(table_id = financialTable, column = columnValGrowth, row = rowValGrowth, text = "PIOTROSKI_F_SCORE", bgcolor=f_getColorByScore(pf_score), text_size=textSize)
table.cell(table_id = financialTable, column = columnValGrowth+1, row = rowValGrowth, text = tostring(pfScore), bgcolor=f_getColorByScore(pf_score), text_size=textSize)
sgr_score = na(sgr)? 0 : sgr > 10? 2 : sgr > 5? 1 : sgr > 0? 0 : sgr > -5 ? -1 : -2
table.cell(table_id = financialTable, column = columnValGrowth, row = rowValGrowth+1, text = "SUSTAINABLE_GROWTH_RATE", bgcolor=f_getColorByScore(sgr_score), text_size=textSize)
table.cell(table_id = financialTable, column = columnValGrowth+1, row = rowValGrowth+1, text = tostring(sgr), bgcolor=f_getColorByScore(sgr_score), text_size=textSize)
if (viewTech == true) //Value/
if (viewRisk == true) //Value/Growth
// risk_score = na(sl)? 0 : sl > 10? 2 : sl > 5? 1 : sl > 0? 0 : sl > -5 ? -1 : -2
table.cell(table_id = financialTable, column = columnValRisk, row = rowValRisk, text = "POSITION SIZE", bgcolor=#40dbc1, text_size=textSize)
table.cell(table_id = financialTable, column = columnValRisk+1, row = rowValRisk, text = tostring(position), bgcolor=#40dbc1, text_size=textSize)
table.cell(table_id = financialTable, column = columnValRisk, row = rowValRisk+1, text = "SL", bgcolor=#40dbc1, text_size=textSize)
table.cell(table_id = financialTable, column = columnValRisk+1, row = rowValRisk+1, text = tostring(sl), bgcolor=#40dbc1, text_size=textSize)
table.cell(table_id = financialTable, column = columnValRisk, row = rowValRisk+2, text = "INVESTMENT", bgcolor=#40dbc1, text_size=textSize)
table.cell(table_id = financialTable, column = columnValRisk+1, row = rowValRisk+2, text = tostring(invetment), bgcolor=#40dbc1, text_size=textSize)
//if (viewStrenth == true) //Strenth
// risk_score = na(sl)? 0 : sl > 10? 2 : sl > 5? 1 : sl > 0? 0 : sl > -5 ? -1 : -2
// table.cell(table_id = financialTable, column = columnValStrenth, row = rowValStrenth, text = "Current TF", bgcolor=f_getColorByScore(risk_score), text_size=textSize)
// table.cell(table_id = financialTable, column = columnValStrenth+1, row = rowValStrenth, text = tostring(position), bgcolor=f_getColorByScore(risk_score), text_size=textSize)
// table.cell(table_id = financialTable, column = columnValStrenth, row = rowValStrenth+1, text = "Daily", bgcolor=f_getColorByScore(risk_score), text_size=textSize)
// table.cell(table_id = financialTable, column = columnValStrenth+1, row = rowValStrenth+1, text = tostring(sl), bgcolor=f_getColorByScore(risk_score), text_size=textSize)
// table.cell(table_id = financialTable, column = columnValStrenth, row = rowValStrenth+2, text = "Weekly", bgcolor=f_getColorByScore(risk_score), text_size=textSize)
// table.cell(table_id = financialTable, column = columnValStrenth+1, row = rowValStrenth+2, text = tostring(invetment), bgcolor=f_getColorByScore(risk_score), text_size=textSize)
// table.cell(table_id = financialTable, column = columnValStrenth, row = rowValStrenth+3, text = "Monthly", bgcolor=f_getColorByScore(risk_score), text_size=textSize)
// //table.cell(table_id = financialTable, column = columnValStrenth+1, row = rowValStrenth+3, text = tostring(invetment), bgcolor=f_getColorByScore(risk_score), text_size=textSize)
// table.cell(table_id = financialTable, column = columnValStrenth+1, row = rowValStrenth+3, text = "Strong\nSell", text_color=color.white, bgcolor=f_cellBgColor("Strong\nSell"), text_size=textSize)
f_drawInfo() =>
var t1 = table.new(position.top_right, 4, array.size(allRatingsArray), frame_width=2, frame_color=color.white, border_width=1, border_color=color.white)
eraseDuplicatedAndDisabledTf()
timeframesCount = array.size(allResArray)
if timeframesCount < 3
for i=0 to timeframesCount-1
f_addCell(t1, i, 1, array.get(maRatingsArray, i))
f_addCell(t1, i, 2, array.get(oscRatingsArray, i))
f_addCell(t1, i, 3, array.get(allRatingsArray, i))
else
for i=0 to timeframesCount-1
f_addCell(t1, 0, i, array.get(allResArray, i))
if ratingSignal == "All"
f_addCell(t1, 1, i, array.get(maRatingsArray, i))
f_addCell(t1, 2, i, array.get(oscRatingsArray, i))
f_addCell(t1, 3, i, array.get(allRatingsArray, i))
if ratingSignal == "Oscillators"
f_addCell(t1, 1, i, array.get(oscRatingsArray, i))
if ratingSignal == "MAs"
f_addCell(t1, 1, i, array.get(maRatingsArray, i))
col_buy = color.from_gradient(tradeSignal, 0.0, 0.2, colNeutral, colStrongBuy)
col_sell = color.from_gradient(tradeSignal, -0.2, 0.0, colStrongSell, colNeutral)
col_gradient = color.from_gradient(tradeSignal, -0.2, 0.2, col_sell, col_buy)
if barstate.islast
if (viewStrenth == true)
f_drawInfo()
//plot(tradeSignal, title="Rating", linewidth = 1, style = plot.style_columns, color = color.new(col_gradient, 50 - _pc * 10))
//_cond1 = crossunder(tradeSignal, -WeakBound)
//alertcondition(_cond1, "Sell", "Ratings changed to Sell")
//_cond2 = crossover(tradeSignal, WeakBound)
//alertcondition(_cond2, "Buy", "Ratings changed to Buy")
//_cond3 = crossunder(tradeSignal, -StrongBound)
//alertcondition(_cond3, "Strong Sell", "Ratings changed to Strong Sell")
//_cond4 = crossover(tradeSignal, StrongBound)
//alertcondition(_cond4, "Strong Buy", "Ratings changed to Strong Buy") |
Kimchi Premium Indicator with Selectable Symbols | https://www.tradingview.com/script/YRCIlcsI/ | chanu_lev10k | https://www.tradingview.com/u/chanu_lev10k/ | 46 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © chanu_lev10k
//@version=4
study("Kimchi Premium Indicator with Selectable Symbols", overlay=false)
sym_krw = input(title="Select BTCKRW Market", type=input.symbol, defval="UPBIT:BTCKRW")
sym_usd = input(title="Select BTCUSD Market", type=input.symbol, defval="BYBIT:BTCUSD")
res = input(title="Resolution", type=input.resolution, defval="")
usdkrw = security("FX_IDC:USDKRW", res, close)
btckrw = security(sym_krw, res, close)
btcusd = security(sym_usd, res, close)
btcusd_to_krw = btcusd * usdkrw
kp = ((btckrw / btcusd_to_krw) - 1) * 100
plot(kp, style=plot.style_line, color=kp > 0 ? color.red : color.blue)
hline(0, title="zero line") |
colored VWAP | https://www.tradingview.com/script/FNbrnbRM/ | wy2333 | https://www.tradingview.com/u/wy2333/ | 80 | study | 3 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © wy2333
//@version=3
study("VWAP", overlay=true)
// There are five steps in calculating VWAP:
//
// 1. Calculate the Typical Price for the period. [(High + Low + Close)/3)]
// 2. Multiply the Typical Price by the period Volume (Typical Price x Volume)
// 3. Create a Cumulative Total of Typical Price. Cumulative(Typical Price x Volume)
// 4. Create a Cumulative Total of Volume. Cumulative(Volume)
// 5. Divide the Cumulative Totals.
//
// VWAP = Cumulative(Typical Price x Volume) / Cumulative(Volume)
cumulativePeriod = input(20, "Period")
typicalPrice = (high + low + close) / 3
typicalPriceVolume = typicalPrice * volume
cumulativeTypicalPriceVolume = sum(typicalPriceVolume, cumulativePeriod)
cumulativeVolume = sum(volume, cumulativePeriod)
vwapValue = cumulativeTypicalPriceVolume / cumulativeVolume
plot(vwapValue,linewidth=1,color=blue,transp=40,title="VWAP",editable=false)
//==========Short Trend Change K线变色功能==========
ConAqua = close >= vwapValue
ConBlack = close < vwapValue
ChangeColorAqua = (ConAqua) ? aqua:na
ChangeColorBlack = (ConBlack) ? black:na
barcolor(ChangeColorAqua,editable=false)
barcolor(ChangeColorBlack,editable=false)
|
REAL MARKET RATES | https://www.tradingview.com/script/cPzS8Xda-REAL-MARKET-RATES/ | csmottola71 | https://www.tradingview.com/u/csmottola71/ | 44 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © csmottola71
//@version=4
study("REAL MARKET RATES")
LC = input(title="Long Contracr", type=input.string, defval="GEH2022")
SC = input(title="Short Contract", type=input.string, defval="GEZ2021")
LongContract = security(LC, "D", close)
ShortContract = security(SC, "D", close)
Spread90 = LongContract-ShortContract
medVal=(LongContract+ShortContract)/2
rateBase=medVal+Spread90
rate=((100-rateBase)/medVal)*100
rateAnnual=rate*4
fedFunds=((security("FEDFUNDS", "D", close))/30)*360
realRate=rateAnnual+fedFunds
plot(realRate, color=color.yellow, title="RealRate") |
Volume Alerter | https://www.tradingview.com/script/gED9tUtB-Volume-Alerter/ | robszz4 | https://www.tradingview.com/u/robszz4/ | 92 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © robszz4
// @version=4
study("Volume Alerter", shorttitle = "VolAlrt", max_bars_back=500 ,overlay = true)
PerUp = input(150, minval=1, title="Percent Change Up")
isIncreasing = ((PerUp * .01)+1) * volume[1]
plotshape((volume > isIncreasing) ? PerUp: na, style=shape.arrowup, location=location.belowbar, color = color.green, size = size.normal, text="increased volume")
|
EMA Difference | https://www.tradingview.com/script/3eCUgbZw-EMA-Difference/ | mostafaid3 | https://www.tradingview.com/u/mostafaid3/ | 80 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mostafaid3
//@version=5
indicator("EMA Difference")
s_len = input.int(10,"Short EMA Length")
l_len = input.int(20,"Long EMA Length")
dif_1 = ta.ema(close,s_len)
dif_2 = ta.ema(close, l_len)
dif3 = dif_1 - dif_2
plot(dif3,style = plot.style_histogram) |
Price Ratios | https://www.tradingview.com/script/zWu6I7Xh-Price-Ratios/ | Trendoscope | https://www.tradingview.com/u/Trendoscope/ | 126 | study | 5 | MPL-2.0 | // 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('Price Ratios', overlay=true)
Position = input.string(title='Table Position', defval=position.top_center, options=[position.bottom_center, position.bottom_left, position.bottom_right, position.middle_center, position.middle_left, position.middle_right, position.top_center, position.top_left, position.top_right], group='Table Settings', inline='1')
textSize = input.string(title='Text Size', defval=size.small, options=[size.huge, size.large, size.normal, size.small, size.tiny, size.auto], group='Table Settings', inline='1')
headerBG = input.color(color.teal, title='Header', group='Colors', inline='gh')
headerText = input.color(color.white, title='', group='Colors', inline='gh')
valueBG = input.color(color.silver, title='Value', group='Colors', inline='gh')
valueText = input.color(color.black, title='', group='Colors', inline='gh')
f_secureSecurity(_symbol, _res, _src, _offset) =>
request.security(_symbol, _res, _src[_offset], lookahead=barmerge.lookahead_on)
f_getFinancials(financial_id, period) =>
request.financial(syminfo.tickerid, financial_id, period)
f_getColorByScore(score) =>
score == 2 ? color.green : score == 1 ? color.lime : score == 0 ? color.silver : score == -1 ? color.orange : score == -2 ? color.red : color.purple
var headerArray = array.new_string(0)
var valueArray = array.new_float(0)
add_financial_to_array(header, value) =>
array.push(headerArray, header)
array.push(valueArray, value)
f_getOptimalFinancialTTM(financial_id) =>
f_getFinancials(financial_id, syminfo.currency == 'USD' ? 'TTM' : 'FY')
f_getOptimalFinancialBasic(financial_id) =>
f_getFinancials(financial_id, syminfo.currency == 'USD' ? 'FQ' : 'FY')
optimalReso = syminfo.currency == 'USD' ? '3M' : '12M'
eps = f_getOptimalFinancialTTM('EARNINGS_PER_SHARE_BASIC')
pe = close / eps
revenue = f_getOptimalFinancialTTM('TOTAL_REVENUE')
tso = request.financial(syminfo.tickerid, 'TOTAL_SHARES_OUTSTANDING', 'FQ')
MarketCap = tso * close
ps = MarketCap / revenue
bps = f_getOptimalFinancialBasic('BOOK_VALUE_PER_SHARE')
pb = close / eps
pfcf = f_getOptimalFinancialBasic('PRICE_TO_FREE_CASH_FLOW')
ptb = f_getOptimalFinancialBasic('PRICE_TO_TANGIBLE_BOOK')
pef = f_getOptimalFinancialBasic('PRICE_EARNINGS_FORWARD')
psf = f_getOptimalFinancialBasic('PRICE_SALES_FORWARD')
orientation = Position == position.bottom_center or Position == position.middle_center or Position == position.top_center ? 2 : Position == position.bottom_left or Position == position.middle_left or Position == position.top_left ? 1 : 3
if barstate.islast
var financialTable = table.new(position=Position, columns=10, rows=10, border_width=1)
columnHeaderStart = 0
rowHeaderStart = 0
columnValueStart = orientation == 2 ? 0 : 1
rowValueStart = orientation == 2 ? 1 : 0
columnIncrement = orientation == 2 ? 1 : 0
rowIncrement = orientation == 2 ? 0 : 1
add_financial_to_array('Price To Earnings', pe)
add_financial_to_array('Price To Sales', ps)
add_financial_to_array('Price To Free Cash Flow', pfcf)
add_financial_to_array('Price To Book', pb)
add_financial_to_array('Price To Tangible Book', ptb)
add_financial_to_array('Price To Earnings Forward', pef)
add_financial_to_array('Price To Sales Forward', psf)
for i = 0 to array.size(headerArray) - 1 by 1
table.cell(table_id=financialTable, column=columnHeaderStart + i * columnIncrement, row=rowHeaderStart + i * rowIncrement, text=array.get(headerArray, i), bgcolor=headerBG, text_color=headerText, text_size=textSize)
table.cell(table_id=financialTable, column=columnValueStart + i * columnIncrement, row=rowValueStart + i * rowIncrement, text=str.tostring(math.round(array.get(valueArray, i), 2)), bgcolor=valueBG, text_color=valueText, text_size=textSize)
|
Advanced Volume Profile | https://www.tradingview.com/script/6698bIvm-Advanced-Volume-Profile/ | Morogan | https://www.tradingview.com/u/Morogan/ | 90 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// @version = 4
// @author = Morogan
// © Morogan
//
// ADVANCED VOLUME PROFILE (for 24/7 and Futures only)
//
// This script plots volume relative to an asset's historical volume profile.
//
// Usage:
// As a companion to my "Unusual Time Frame Volume" (UTF Volume) script, this plots volume against the same historical volume profile used for UTF Volume.
// The same high volume (relative to historical) threshold alert is available (yellow bar).
// Likewise, if the volume exceeds the historical threshold, but is below the alert threshold, the bar color is orange.
// At the top of the chart is an indicator which is green if a bar has higher volume than the previous bar.
// You can also set a threshold for this such that if the volume of a bar exceeds the previous bar by a certain multiplier which will turn the indicator yellow.
// For example, if the threshold is set to "1.5", then the indicator will be yellow (instead of green) on an increase in volume over the previous bar of 1.5x.
//
// NOTES:
// THIS SCRIPT CURRENTLY ONLY WORKS FOR ASSETS THAT TRADE 24/7 OR CBOE FUTURES HOURS!
// Make sure you set the "Asset Mode" and "Time Frame (minutes)" to values that match your asset and chart setting.
// For example, if you are trading Futures on a 2m chart, set the Asset Mode to Futures and Time Frame to 2m.
// If you are trading crypto on a 5m chart, set the Asset Mode to 24/7 and Time Frame to 5m.
// If the settings are not set appropriately, the output will be incorrect/invalid.
//
// If you choose a "Look-back (Days)" setting that is too far back given the time frame, the script will produce an error.
// I suggest playing with settings from "1" (compares volume to the previous day's volume) to the highest number that doesn't break the script.
// For example, at a 2m time frame, the maximum look-back will be "6" or "7" depending on which mode you are using.
// Longer chart time settings allow larger look-back values.
// I find that the default value ("6") does a decent job in general.
//
// Please feel free to reuse or further develop this script.
// I would greatly appreciate it if you would send me a message below if you find it useful.
study("Advanced Volume Profile", format=format.price, precision=2, resolution="")
tf = input(title="Time Frame (minutes)", type=input.integer, defval=2, minval=1, maxval=240)
am = input(title="Asset Mode", defval="24/7", options=["24/7", "Futures"])
lb = input(title="Look-back (Days)", type=input.integer, defval=6, minval=1, maxval=30)
th = input(title="Alert Threshold - High Volume Relative to Historical Profile", type=input.float, defval=1.32, minval=0, maxval=7)
tp = input(title="Alert Threshold - High Volume Relative to Prior Bar", type=input.float, defval=2, minval=0, maxval=7)
period = 1440 / tf
if am == "24/7"
period := 1440 / tf
if am == "Futures"
period := 1380 / tf
time_frame_average(avg_len) =>
ret_val = 0.0
for i = 1 to avg_len
ret_val := ret_val + volume[i*period]
ret_val/avg_len
avgVol = time_frame_average(lb)
Delta = volume - (th * avgVol)
secolor = Delta > 0 ? color.yellow : (Delta < 0) and (volume > avgVol) ? color.orange : color.blue
plot(volume, title="Volume", style=plot.style_columns, color=secolor, linewidth=1)
plot(avgVol, title="Historical Volume Profile", color=color.white, style=plot.style_stepline, linewidth=1)
PAL = (volume > volume[1])
pacolor = volume > tp * volume[1] ? color.yellow : (volume < tp * volume[1]) and (volume > volume[1]) ? color.green : color.new(color.black, 25)
plotshape(PAL, title="Volume Increase", location=location.top, style=shape.square, size=size.auto, color=pacolor)
//plotshape(not(PAL), title="Volume Decrease", location=location.top, style=shape.xcross, size=size.auto, color=color.new(color.black, 25)) |
Horizontal Line At Daily Moving Averages | https://www.tradingview.com/script/VZcYhii6-Horizontal-Line-At-Daily-Moving-Averages/ | DavidTammari | https://www.tradingview.com/u/DavidTammari/ | 145 | study | 3 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © davidtammari
//@version=3
study("Horizontal Line At Daily Moving Averages", overlay = true)
EMA9 = security(tickerid, "D", ema(close, 9))
MA20 = security(tickerid, "D", sma(close, 20))
MA50 = security(tickerid, "D", sma(close, 50))
MA100 = security(tickerid, "D", sma(close, 100))
MA200 = security(tickerid, "D", sma(close, 200))
plot(EMA9, trackprice = true, linewidth = 2, color = red, offset = -9999, title = "9 EMA")
plot(MA20, trackprice = true, linewidth = 2, color = navy, offset = -9999, title = "20 MA")
plot(MA50, trackprice = true, linewidth = 2, color = green, offset = -9999, title = "50 MA")
plot(MA100, trackprice = true, linewidth = 2, color = blue, offset = -9999, title = "100 MA")
plot(MA200, trackprice = true, linewidth = 2, color = purple, offset = -9999, title = "200 MA")
|
Most Power - Smooth EMA Haiken Ashi | https://www.tradingview.com/script/aNWpHK5M-most-power-smooth-ema-haiken-ashi/ | mostpower-app | https://www.tradingview.com/u/mostpower-app/ | 62 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mostpower-app - Most Power - Smooth EMA Haiken Ashi
//@version=4
study(title = "Most Power - Smooth EMA Haiken Ashi", overlay = true)
show_ema5 = input(title = "Show EMA 5", defval = true)
show_ema10 = input(title = "Show EMA 10", defval = true)
show_ema20 = input(title = "Show EMA 20", defval = true)
show_ema50 = input(title = "Show EMA 50", defval = true)
show_ema100 = input(title = "Show EMA 100", defval = true)
show_ema200 = input(title = "Show EMA 200", defval = true)
show_ema1000 = input(title = "Show EMA 1000", defval = true)
ema5 = 5
ema10 = 10
ema20 = 20
ema50 = 50
ema100 = 100
ema200 = 200
ema1000 = 1000
haclose1 = 0.0
haopen1 = 0.0
hahigh1 = 0.0
halow1 = 0.0
haclose2 = 0.0
haopen2 = 0.0
hahigh2 = 0.0
halow2 = 0.0
haclose3 = 0.0
haopen3 = 0.0
hahigh3 = 0.0
halow3 = 0.0
haclose4 = 0.0
haopen4 = 0.0
hahigh4 = 0.0
halow4 = 0.0
haclose5 = 0.0
haopen5 = 0.0
hahigh5 = 0.0
halow5 = 0.0
haclose6 = 0.0
haopen6 = 0.0
hahigh6 = 0.0
halow6 = 0.0
haclose7 = 0.0
haopen7 = 0.0
hahigh7 = 0.0
halow7 = 0.0
o1 = ema(open, ema5)
c1 = ema(close, ema5)
h1 = ema(high, ema5)
l1 = ema(low, ema5)
o2 = ema(open, ema10)
c2 = ema(close, ema10)
h2 = ema(high, ema10)
l2 = ema(low, ema10)
o3 = ema(open, ema20)
c3 = ema(close, ema20)
h3 = ema(high, ema20)
l3 = ema(low, ema20)
o4 = ema(open, ema50)
c4 = ema(close, ema50)
h4 = ema(high, ema50)
l4 = ema(low, ema50)
o5 = ema(open, ema100)
c5 = ema(close, ema100)
h5 = ema(high, ema100)
l5 = ema(low, ema100)
o6 = ema(open, ema200)
c6 = ema(close, ema200)
h6 = ema(high, ema200)
l6 = ema(low, ema200)
o7 = ema(open, ema1000)
c7 = ema(close, ema1000)
h7 = ema(high, ema1000)
l7 = ema(low, ema1000)
haclose1 := (o1 + h1 + l1 + c1) / 4
haopen1 := na(haopen1[1]) ? (o1 + c1) / 2 : (haopen1[1] + haclose1[1]) / 2
hahigh1 := max (h1, max(haopen1, haclose1))
halow1 := min (l1, min(haopen1, haclose1))
haclose2 := (o2 + h2 + l2 + c2) / 4
haopen2 := na(haopen2[1]) ? (o2 + c2)/2 : (haopen2[1] + haclose2[1]) / 2
hahigh2 := max (h2, max(haopen2, haclose2))
halow2 := min (l2, min(haopen2, haclose2))
haclose3 := (o3 + h3 + l3 + c3) / 4
haopen3 := na(haopen3[1]) ? (o3 + c3) / 2 : (haopen3[1] + haclose3[1]) / 2
hahigh3 := max (h3, max(haopen3, haclose3))
halow3 := min (l3, min(haopen3, haclose3))
haclose4 := (o4 + h4 + l4 + c4) / 4
haopen4 := na(haopen4[1]) ? (o4 + c4) / 2 : (haopen4[1] + haclose4[1]) / 2
hahigh4 := max (h4, max(haopen4, haclose4))
halow4 := min (l4, min(haopen4, haclose4))
haclose5 := (o5 + h5 + l5 + c5) / 4
haopen5 := na(haopen5[1]) ? (o5 + c5) / 2 : (haopen5[1] + haclose5[1]) / 2
hahigh5 := max (h5, max(haopen5, haclose5))
halow5 := min (l5, min(haopen5, haclose5))
haclose6 := (o6 + h6 + l6 + c6) / 4
haopen6 := na(haopen6[1]) ? (o6 + c6) / 2 : (haopen6[1] + haclose6[1]) / 2
hahigh6 := max (h6, max(haopen6, haclose6))
halow6 := min (l6, min(haopen6, haclose6))
haclose7 := (o7 + h7 + l7 + c7) / 4
haopen7 := na(haopen7[1]) ? (o7 + c7) / 2 : (haopen7[1] + haclose7[1]) / 2
hahigh7 := max (h7, max(haopen7, haclose7))
halow7 := min (l7, min(haopen7, haclose7))
o1_1 = ema(haopen1, ema5)
c1_1 = ema(haclose1, ema5)
h1_1 = ema(hahigh1, ema5)
l1_1 = ema(halow1, ema5)
o2_2 = ema(haopen2, ema10)
c2_2 = ema(haclose2, ema10)
h2_2 = ema(hahigh2, ema10)
l2_2 = ema(halow2, ema10)
o3_3 = ema(haopen3, ema20)
c3_3 = ema(haclose3, ema20)
h3_3 = ema(hahigh3, ema20)
l3_3 = ema(halow3, ema20)
o4_4 = ema(haopen4, ema50)
c4_4 = ema(haclose4, ema50)
h4_4 = ema(hahigh4, ema50)
l4_4 = ema(halow4, ema50)
o5_5 = ema(haopen5, ema100)
c5_5 = ema(haclose5, ema100)
h5_5 = ema(hahigh5, ema100)
l5_5 = ema(halow5, ema100)
o6_6 = ema(haopen6, ema200)
c6_6 = ema(haclose6, ema200)
h6_6 = ema(hahigh6, ema200)
l6_6 = ema(halow6, ema200)
o7_7 = ema(haopen7, ema1000)
c7_7 = ema(haclose7, ema1000)
h7_7 = ema(hahigh7, ema1000)
l7_7 = ema(halow7, ema1000)
col1 = o1_1 > c1_1 ? #FFF0F5 : #F0FFF0
col2 = o2_2 > c2_2 ? #FDBCB4 : #D0F0C0
col3 = o3_3 > c3_3 ? #FF9999 : #98FF98
col4 = o4_4 > c4_4 ? #D19FE8 : #F7E98E
col5 = o5_5 > c5_5 ? #848482 : #30D5C8
col6 = o6_6 > c6_6 ? #7a0000 : #076318
col7 = o7_7 > c7_7 ? #000000 : #000000
topline1 = plot(show_ema5 ? c1_1 : na, color = col1)
botline1 = plot(show_ema5 ? o1_1: na, color = col1)
fill(botline1,topline1, color=col1, transp=0, title="Ema 5")
// SCHA 2
topline2 = plot(show_ema10 ? c2_2 : na, color = col2)
botline2 = plot(show_ema10 ? o2_2: na, color = col2)
fill(botline2,topline2, color=col2, transp=0, title="Ema 10")
topline3 = plot(show_ema20 ? c3_3 : na, color = col3)
botline3 = plot(show_ema20 ? o3_3: na, color = col3)
fill(botline3,topline3, color=col3, transp=0, title="Ema 20")
topline4 = plot(show_ema50? c4_4 : na, color = col4)
botline4 = plot(show_ema50 ? o4_4: na, color = col4)
fill(botline4,topline4, color=col4, transp=0, title="Ema 50")
topline5 = plot(show_ema100 ? c5_5 : na, color = col5)
botline5 = plot(show_ema100 ? o5_5: na, color = col5)
fill(botline5,topline5, color=col5, transp=0, title="Ema 100")
topline6 = plot(show_ema200 ? c6_6 : na, color = col6)
botline6 = plot(show_ema200 ? o6_6: na, color = col6)
fill(botline6,topline6, color=col6, transp=0, title="Ema 200")
topline7 = plot(show_ema1000 ? c7_7 : na, color = col7)
botline7 = plot(show_ema1000 ? o7_7: na, color = col7)
fill(botline7,topline7, color=col7, transp=0, title="Ema 1000") |
My:HTF O/H/L/C | https://www.tradingview.com/script/vPn4gOBx/ | Thlem | https://www.tradingview.com/u/Thlem/ | 42 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Thlem
//@version=4
study("My:HTF O/H/L/C", overlay=true)
showCurrentDailyOpen = input(true, title="Show Current Daily Open - CDO", group="-- Current Daily --")
showCurrentDailyHigh = input(true, title="Show Current Daily High - CDH", group="-- Current Daily --")
showCurrentDailyLow = input(true, title="Show Current Daily Low - CDL", group="-- Current Daily --")
showCurrentWeeklyOpen = input(true, title="Show Current Weekly Open - CWO", group="-- Current Weekly --")
showCurrentWeeklyHigh = input(true, title="Show Current Weekly High - CWH", group="-- Current Weekly --")
showCurrentWeeklyLow = input(true, title="Show Current Weekly Low - CWL", group="-- Current Weekly --")
showCurrentMonthlyOpen = input(true, title="Show Current Monthly Open - CMO", group="-- Current Monthly --")
showCurrentMonthlyHigh = input(true, title="Show Current Monthly High - CMH", group="-- Current Monthly --")
showCurrentMonthlyLow = input(true, title="Show Current Monthly Low - CML", group="-- Current Monthly --")
showPreviousDailyOpen = input(true, title="Show Previous Daily Open - PDO", group="-- Previous Daily --")
showPreviousDailyHigh = input(true, title="Show Previous Daily High - PDH", group="-- Previous Daily --")
showPreviousDailyLow = input(true, title="Show Previous Daily Low - PDL", group="-- Previous Daily --")
showPreviousDailyClose = input(true, title="Show Previous Daily Close - PDC", group="-- Previous Daily --")
showPreviousWeeklyOpen = input(true, title="Show Previous Weekly Open - PWO", group="-- Previous Weekly --")
showPreviousWeeklyHigh = input(true, title="Show Previous Weekly High - PWH", group="-- Previous Weekly --")
showPreviousWeeklyLow = input(true, title="Show Previous Weekly Low - PWL", group="-- Previous Weekly --")
showPreviousWeeklyClose = input(true, title="Show Previous Weekly Close - PWC", group="-- Previous Weekly --")
showPreviousMonthlyOpen = input(true, title="Show Previous Monthly Open - PMO", group="-- Previous Monthly --")
showPreviousMonthlyHigh = input(true, title="Show Previous Monthly High - PMH", group="-- Previous Monthly --")
showPreviousMonthlyLow = input(true, title="Show Previous Monthly Low - PML", group="-- Previous Monthly --")
showPreviousMonthlyClose = input(true, title="Show Previous Monthly Close - PMC", group="-- Previous Monthly --")
[m_open, m_close, m_high, m_low] = security(syminfo.tickerid, '1M', [open[1], close[1], high[1], low[1]])
[w_open, w_close, w_high, w_low] = security(syminfo.tickerid, '1W', [open[1], close[1], high[1], low[1]])
[d_open, d_close, d_high, d_low] = security(syminfo.tickerid, '1D', [open[1], close[1], high[1], low[1]])
[cm_open, cm_high, cm_low] = security(syminfo.tickerid, '1M', [open, high, low])
[cw_open, cw_high, cw_low] = security(syminfo.tickerid, '1W', [open, high, low])
[cd_open, cd_high, cd_low] = security(syminfo.tickerid, '1D', [open, high, low])
labelXLoc(offset) => time_close + (( time_close - time_close[1] ) * offset )
barIndex = if (timeframe.ismonthly or timeframe.isweekly or timeframe.isdaily)
1
else if (timeframe.period == '240')
7
else if (timeframe.period == '120')
12
else if (timeframe.period == '180')
8
else if (timeframe.period == '60')
24
else if (timeframe.period == '15')
24*4
else if (timeframe.period == '1')
24*4
else
10
showDaily = timeframe.ismonthly == false and timeframe.isweekly == false
showWeekly = timeframe.ismonthly == false
/////////////////////////////////////////////////
// Current Daily price of interest
/////////////////////////////////////////////////
if (showDaily and showCurrentDailyOpen)
cd_open_line = line.new(bar_index[barIndex], cd_open, bar_index, cd_open, xloc.bar_index, extend=extend.right, color=color.white, style=line.style_solid, width=1)
cd_open_label = label.new (labelXLoc(15), cd_open, "CDO" , xloc.bar_time, yloc.price, color.white, label.style_label_left, color.black, size=size.normal )
line.delete(cd_open_line[1])
label.delete(cd_open_label[1])
if (showDaily and showCurrentDailyHigh)
cd_high_line = line.new(bar_index[barIndex], cd_high, bar_index, cd_high, xloc.bar_index, extend=extend.right, color=color.white, style=line.style_solid, width=1)
cd_high_label = label.new (labelXLoc(15), cd_high, "CDH" , xloc.bar_time, yloc.price, color.white, label.style_label_left, color.black, size=size.normal )
line.delete(cd_high_line[1])
label.delete(cd_high_label[1])
if (showDaily and showCurrentDailyLow)
cd_low_line = line.new(bar_index[barIndex], cd_low, bar_index, cd_low, xloc.bar_index, extend=extend.right, color=color.white, style=line.style_solid, width=1)
cd_low_label = label.new (labelXLoc(15), cd_low, "CDL" , xloc.bar_time, yloc.price, color.white, label.style_label_left, color.black, size=size.normal )
line.delete(cd_low_line[1])
label.delete(cd_low_label[1])
/////////////////////////////////////////////////
/////////////////////////////////////////////////
// Current Weekly price of interest
/////////////////////////////////////////////////
if (showWeekly and showCurrentWeeklyOpen)
cw_open_line = line.new(bar_index[barIndex], cw_open, bar_index, cw_open, xloc.bar_index, extend=extend.right, color=color.lime, style=line.style_solid, width=1)
cw_open_label = label.new (labelXLoc(55), cw_open, "CWO" , xloc.bar_time, yloc.price, color.lime, label.style_label_left, color.black, size=size.normal )
line.delete(cw_open_line[1])
label.delete(cw_open_label[1])
if (showWeekly and showCurrentWeeklyHigh)
cw_high_line = line.new(bar_index[barIndex], cw_high, bar_index, cw_high, xloc.bar_index, extend=extend.right, color=color.lime, style=line.style_solid, width=1)
cw_high_label = label.new (labelXLoc(55), cw_high, "CWH" , xloc.bar_time, yloc.price, color.lime, label.style_label_left, color.black, size=size.normal )
line.delete(cw_high_line[1])
label.delete(cw_high_label[1])
if (showWeekly and showCurrentWeeklyLow)
cw_low_line = line.new(bar_index[barIndex], cw_low, bar_index, cw_low, xloc.bar_index, extend=extend.right, color=color.lime, style=line.style_solid, width=1)
cw_low_label = label.new (labelXLoc(55), cw_low, "CWL" , xloc.bar_time, yloc.price, color.lime, label.style_label_left, color.black, size=size.normal )
line.delete(cw_low_line[1])
label.delete(cw_low_label[1])
/////////////////////////////////////////////////
/////////////////////////////////////////////////
// Current Monthly price of interest
/////////////////////////////////////////////////
if (showCurrentMonthlyOpen)
cm_open_line = line.new(bar_index[barIndex], cm_open, bar_index, cm_open, xloc.bar_index, extend=extend.right, color=color.aqua, style=line.style_solid, width=1)
cm_open_label = label.new (labelXLoc(115), cm_open, "CMO" , xloc.bar_time, yloc.price, color.aqua, label.style_label_left, color.black, size=size.normal )
line.delete(cm_open_line[1])
label.delete(cm_open_label[1])
if (showCurrentMonthlyHigh)
cm_high_line = line.new(bar_index[barIndex], cm_high, bar_index, cm_high, xloc.bar_index, extend=extend.right, color=color.aqua, style=line.style_solid, width=1)
cm_high_label = label.new (labelXLoc(115), cm_high, "CMH" , xloc.bar_time, yloc.price, color.aqua, label.style_label_left, color.black, size=size.normal )
line.delete(cm_high_line[1])
label.delete(cm_high_label[1])
if (showCurrentMonthlyLow)
cm_low_line = line.new(bar_index[barIndex], cm_low, bar_index, cm_low, xloc.bar_index, extend=extend.right, color=color.aqua, style=line.style_solid, width=1)
cm_low_label = label.new (labelXLoc(115), cm_low, "CML" , xloc.bar_time, yloc.price, color.aqua, label.style_label_left, color.black, size=size.normal )
line.delete(cm_low_line[1])
label.delete(cm_low_label[1])
/////////////////////////////////////////////////
/////////////////////////////////////////////////
// Previous Daily price of interest
/////////////////////////////////////////////////
if (showDaily and showPreviousDailyOpen)
d_open_line = line.new(bar_index[barIndex], d_open, bar_index, d_open, xloc.bar_index, extend=extend.right, color=color.white, style=line.style_solid, width=1)
d_open_label = label.new (labelXLoc(35), d_open, "PDO" , xloc.bar_time, yloc.price, color.white, label.style_label_left, color.black, size=size.normal )
line.delete(d_open_line[1])
label.delete(d_open_label[1])
if (showDaily and showPreviousDailyClose)
d_close_line = line.new(bar_index[barIndex], d_close, bar_index, d_close, xloc.bar_index, extend=extend.right, color=color.white, style=line.style_solid, width=1)
d_close_label = label.new (labelXLoc(35), d_close, "PDC" , xloc.bar_time, yloc.price, color.white, label.style_label_left, color.black, size=size.normal )
line.delete(d_close_line[1])
label.delete(d_close_label[1])
if (showDaily and showPreviousDailyHigh)
d_high_line = line.new(bar_index[barIndex], d_high, bar_index, d_high, xloc.bar_index, extend=extend.right, color=color.white, style=line.style_solid, width=1)
d_high_label = label.new (labelXLoc(35), d_high, "PDH" , xloc.bar_time, yloc.price, color.white, label.style_label_left, color.black, size=size.normal )
line.delete(d_high_line[1])
label.delete(d_high_label[1])
if (showDaily and showPreviousDailyLow)
d_low_line = line.new(bar_index[barIndex], d_low, bar_index, d_low, xloc.bar_index, extend=extend.right, color=color.white, style=line.style_solid, width=1)
d_low_label = label.new (labelXLoc(35), d_low, "PDL" , xloc.bar_time, yloc.price, color.white, label.style_label_left, color.black, size=size.normal )
line.delete(d_low_line[1])
label.delete(d_low_label[1])
/////////////////////////////////////////////////
/////////////////////////////////////////////////
// Previous Weekly price of interest
/////////////////////////////////////////////////
if (showWeekly and showPreviousWeeklyOpen)
w_open_line = line.new(bar_index[barIndex], w_open, bar_index, w_open, xloc.bar_index, extend=extend.right, color=color.lime, style=line.style_solid, width=1)
w_open_label = label.new (labelXLoc(75), w_open, "PWO" , xloc.bar_time, yloc.price, color.lime, label.style_label_left, color.black, size=size.normal )
line.delete(w_open_line[1])
label.delete(w_open_label[1])
if (showWeekly and showPreviousWeeklyClose)
w_close_line = line.new(bar_index[barIndex], w_close, bar_index, w_close, xloc.bar_index, extend=extend.right, color=color.lime, style=line.style_solid, width=1)
w_close_label = label.new (labelXLoc(75), w_close, "PWC" , xloc.bar_time, yloc.price, color.lime, label.style_label_left, color.black, size=size.normal )
line.delete(w_close_line[1])
label.delete(w_close_label[1])
if (showWeekly and showPreviousWeeklyHigh)
w_high_line = line.new(bar_index[barIndex], w_high, bar_index, w_high, xloc.bar_index, extend=extend.right, color=color.lime, style=line.style_solid, width=1)
w_high_label = label.new (labelXLoc(75), w_high, "PWH" , xloc.bar_time, yloc.price, color.lime, label.style_label_left, color.black, size=size.normal )
line.delete(w_high_line[1])
label.delete(w_high_label[1])
if (showWeekly and showPreviousWeeklyLow)
w_low_line = line.new(bar_index[barIndex], w_low, bar_index, w_low, xloc.bar_index, extend=extend.right, color=color.lime, style=line.style_solid, width=1)
w_low_label = label.new (labelXLoc(75), w_low, "PWL" , xloc.bar_time, yloc.price, color.lime, label.style_label_left, color.black, size=size.normal )
line.delete(w_low_line[1])
label.delete(w_low_label[1])
/////////////////////////////////////////////////
/////////////////////////////////////////////////
// Previous Monthly price of interest
/////////////////////////////////////////////////
if (showPreviousMonthlyOpen)
m_open_line = line.new(bar_index[barIndex], m_open, bar_index, m_open, xloc.bar_index, extend=extend.right, color=color.aqua, style=line.style_solid, width=1)
m_open_label = label.new (labelXLoc(125), m_open, "PMO" , xloc.bar_time, yloc.price, color.aqua, label.style_label_left, color.black, size=size.normal )
line.delete(m_open_line[1])
label.delete(m_open_label[1])
if (showPreviousMonthlyClose)
m_close_line = line.new(bar_index[barIndex], m_close, bar_index, m_close, xloc.bar_index, extend=extend.right, color=color.aqua, style=line.style_solid, width=1)
m_close_label = label.new (labelXLoc(125), m_close, "PMC" , xloc.bar_time, yloc.price, color.aqua, label.style_label_left, color.black, size=size.normal )
line.delete(m_close_line[1])
label.delete(m_close_label[1])
if (showPreviousMonthlyHigh)
m_high_line = line.new(bar_index[barIndex], m_high, bar_index, m_high, xloc.bar_index, extend=extend.right, color=color.aqua, style=line.style_solid, width=1)
m_high_label = label.new (labelXLoc(125), m_high, "PMH" , xloc.bar_time, yloc.price, color.aqua, label.style_label_left, color.black, size=size.normal )
line.delete(m_high_line[1])
label.delete(m_high_label[1])
if (showPreviousMonthlyLow)
m_low_line = line.new(bar_index[barIndex], m_low, bar_index, m_low, xloc.bar_index, extend=extend.right, color=color.aqua, style=line.style_solid, width=1)
m_low_label = label.new (labelXLoc(125), m_low, "PML" , xloc.bar_time, yloc.price, color.aqua, label.style_label_left, color.black, size=size.normal )
line.delete(m_low_line[1])
label.delete(m_low_label[1])
/////////////////////////////////////////////////
|
Cross Average Price | https://www.tradingview.com/script/aNPUZlnT/ | danyprat | https://www.tradingview.com/u/danyprat/ | 20 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © danyprat
//@version=4
study(title="Cross Average Price", shorttitle="CAP", precision=6, overlay=true)
plot(sma(close, 14),"14",color=#ff9f1c)
plot(sma(close, 50),"50",color=#ffffff)
plot(sma(close, 100),"100",color=#2ec4b6)
plot(sma(close, 200),"200",color=#ff0000)
valore14 = sma(close, 14)
valore50 = sma(close, 50)
valore100 = sma(close, 100)
valore200 = sma(close, 200)
s1 = iff(cross(valore14, valore50), avg(valore14,valore50), na)
plot(s1, style=plot.style_circles, linewidth=4, color=color.green)
s2 = iff(cross(valore14, valore100), avg(valore14,valore100), na)
plot(s2, style=plot.style_circles, linewidth=4, color=color.yellow)
s3 = iff(cross(valore14, valore200), avg(valore14,valore200), na)
plot(s3, style=plot.style_circles, linewidth=4, color=color.red)
|
Range over Volume | https://www.tradingview.com/script/Wx5LI2Hy-Range-over-Volume/ | GanesaPonraja | https://www.tradingview.com/u/GanesaPonraja/ | 43 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © GanesaPonraja
// set as a histogram and trade in direction of candles in 1 minute chart for all RoV values over 4.
plot ((atr(1)*4/(volume[0]/10)), style=plot.style_histogram)
hline(4,"action lne",color=color.blue,linestyle=hline.style_dotted, linewidth=2)
//@version=4
study("Range over Volume - use during Globex session NQ 1 minute for scalping") |
Three Golden By Moonalert | https://www.tradingview.com/script/bqbaMOSM/ | TED0Title | https://www.tradingview.com/u/TED0Title/ | 191 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TED0Title
//@version=4
//@version=4
study(shorttitle="3Goldens + 3EMA + MyBB", title="Bollinger Bands", overlay=true, resolution="")
length = input(20, minval=1)
src = input(close, title="Source")
mult = input(2.0, minval=0.001, maxval=50, title="StdDev")
basis = sma(src, length)
dev = mult * stdev(src, length)
upper = basis + dev
lower = basis - dev
offset = input(0, "Offset", type = input.integer, minval = -500, maxval = 500)
plot(basis, "Middle BB", color=#bad6d6, offset = offset)
p1 = plot(upper, "Upper BB", color=color.teal, offset = offset)
p2 = plot(lower, "Lower BB", color=color.teal, offset = offset)
fill(p1, p2, title = "Background", color=#126161)
//My928s
plot(ema(close, 20), color=#0088FA, linewidth=1, title='EMA 20')
plot(ema(close, 50), color=#FA00D0, linewidth=1, title='EMA 50')
plot(ema(close, 200), color=#FF7000, linewidth=2, title='EMA 200')
//input
condition1=input(title="Condition MACD Cross 0",type=input.bool,defval=true)
condition2=input(title="Condition MACD Cross Signal",type=input.bool,defval=false)
BB_length=input(title="BB_length",type=input.float,defval=2)
BB_StdDev=input(title="BB_StdDev",type=input.integer,defval=20)
RSI_length=input(title="BB_RSI",type=input.integer,defval=14)
Flast_MACD=input(title="Flast_MACD",type=input.integer,defval=12)
Slow_MACD=input(title="Slow_MACD",type=input.integer,defval=26)
Signal_MACD=input(title="Signal_MACD",type=input.integer,defval=9)
// indicator
[middle, uppermoon, lowerdown] = bb(close, BB_StdDev, BB_length)
rsi = rsi(close,RSI_length)
[macdLine, signalLine, histLine] = macd(close, 12, 26, 9)
//My
// conditon
l = if condition1==1 and condition2 == 0 and crossover(macdLine , 0)
l=1
else if condition1==0 and condition2 == 1 and crossover(macdLine , signalLine)
l=1
else
l=0
s = if condition1==1 and condition2 == 0 and crossunder(macdLine , 0)
s=1
else if condition1==0 and condition2 == 1 and crossunder(macdLine , signalLine)
s=1
else
s=0
h = if condition1==1 and condition2 == 0 and macdLine > 0
h=1
else if condition1==0 and condition2 == 1 and macdLine > signalLine
h=1
else
h=0
o = if condition1==1 and condition2 == 0 and macdLine < 0
o=1
else if condition1==0 and condition2 == 1 and macdLine < signalLine
o=1
else
o=0
r = rsi > 50
b = close > middle
con1 = close > middle and rsi > 50 and l
con2 = close > middle or rsi > 50 or h
con3 = close < middle and rsi < 50 and s
con4 = close > middle and rsi > 50 and h
con5 = close < middle and rsi < 50 and o
barcolor(con4? color.green: na)
barcolor(con5? color.red: na)
barcolor(con3? color.red : color.yellow)
plotshape(con1, style=shape.circle,size=size.tiny ,location=location.belowbar,color=color.green)
plotshape(con3, style=shape.circle ,size=size.tiny,color=color.red)
alertcondition(con1, title='Alert on Green Bar', message='Green Bar! signal Buy')
alertcondition(con3, title='Alert on Red Bar', message='Red Bar! signal Sell')
///My928s edits v3
|
Trigrams based on Candle Pattern | https://www.tradingview.com/script/Cwv7H00X/ | firerider | https://www.tradingview.com/u/firerider/ | 26 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=5
indicator('Trigrams', overlay=true)
bullish = close > open
bearish = close < open
body = math.abs(open - close)
lowerShadow = math.min(open, close) - low
upperShadow = high - math.max(close, open)
range_1 = high - low
///Trigram Conditions
/// Source: https://www.aguba.net/gupiao/10113.html
Heaven = bearish and math.abs(high - open) < 0.2 * body and math.abs(low - close) < 0.2 * body
Earth = bullish and math.abs(high - close) < 0.2 * body and math.abs(low - open) < 0.2 * body
Water = bullish and upperShadow >= 1.5 * body and upperShadow > 1.7 * lowerShadow
Mountain = bullish and lowerShadow >= 1.5 * body and lowerShadow > 1.7 * upperShadow
Flame = bearish and lowerShadow >= 1.5 * body and lowerShadow > 1.7 * upperShadow
Lake = bearish and upperShadow >= 1.5 * body and upperShadow > 1.7 * lowerShadow
Thunder = false
Wind = false
if not Heaven and not Earth and not Water and not Mountain and not Flame and not Lake
Thunder := bearish and high > open and low < close
Wind := bullish and high > close and low < open
Wind
///Plot the Trigrams
plotchar(Heaven, char='☰', location=location.abovebar, color=color.new(color.white, 0))
plotchar(Earth, char='☷', location=location.abovebar, color=color.new(color.black, 0))
plotchar(Thunder, char='☳', location=location.abovebar, color=color.new(color.yellow, 0))
plotchar(Water, char='☵', location=location.abovebar, color=color.new(color.aqua, 0))
plotchar(Mountain, char='☶', location=location.abovebar, color=color.new(color.maroon, 0))
plotchar(Wind, char='☴', location=location.abovebar, color=color.new(color.green, 0))
plotchar(Flame, char='☲', location=location.abovebar, color=color.new(color.red, 0))
plotchar(Lake, char='☱', location=location.abovebar, color=color.new(color.gray, 0))
|
Percent Change by AXU | https://www.tradingview.com/script/RycpQNTf/ | UnknownUnicorn17007895 | https://www.tradingview.com/u/UnknownUnicorn17007895/ | 65 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © a-x-u
//@version=4
study(title="Percent Change by AXU",shorttitle="PC %",overlay=0)
subHL=(high/low-1)*100
subOC=(close/open-1)*100
if(open>close)
subHL:=subHL*-1
subHL_color=color.white
subOC_color=color.white
if(subHL>0)
subHL_color:=color.green
if(subHL<0)
subHL_color:=color.red
if(subOC>0)
subOC_color:=color.green
if(subOC<0)
subOC_color:=color.red
plot(subHL,style=plot.style_circles,title="High-Low Percentage",color=subHL_color)
plot(subOC,style=plot.style_columns,title="Open-Close Percentage",color=subOC_color)
|
Nadaraya-Watson Smoothers [LuxAlgo] | https://www.tradingview.com/script/amRCTgFw-Nadaraya-Watson-Smoothers-LuxAlgo/ | LuxAlgo | https://www.tradingview.com/u/LuxAlgo/ | 6,105 | study | 5 | CC-BY-NC-SA-4.0 | // 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/
// © LuxAlgo
//@version=5
indicator("Nadaraya-Watson Smoothers [LuxAlgo]", "LuxAlgo - Nadaraya-Watson Smoothers", overlay = true, max_lines_count = 500, max_labels_count = 500, max_bars_back=500)
//------------------------------------------------------------------------------
//Settings
//-----------------------------------------------------------------------------{
h = input.float(8.,'Bandwidth', minval = 0)
src = input(close,'Source')
repaint = input(true, 'Repainting Smoothing', tooltip = 'Repainting is an effect where the indicators historical output is subject to change over time. Disabling repainting will cause the indicator to output the endpoint of the estimator')
//Style
upCss = input.color(color.teal, 'Colors', inline = 'inline1', group = 'Style')
dnCss = input.color(color.red, '', inline = 'inline1', group = 'Style')
//-----------------------------------------------------------------------------}
//Functions
//-----------------------------------------------------------------------------{
//Gaussian window
gauss(x, h) => math.exp(-(math.pow(x, 2)/(h * h * 2)))
//-----------------------------------------------------------------------------}
//Append lines
//-----------------------------------------------------------------------------{
n = bar_index
var ln = array.new_line(0)
if barstate.isfirst and repaint
for i = 0 to 499
array.push(ln,line.new(na,na,na,na))
//-----------------------------------------------------------------------------}
//End point method
//-----------------------------------------------------------------------------{
var coefs = array.new_float(0)
var den = 0.
if barstate.isfirst and not repaint
for i = 0 to 499
w = gauss(i, h)
coefs.push(w)
den := coefs.sum()
out = 0.
if not repaint
for i = 0 to 499
out += src[i] * coefs.get(i)
out /= den
//-----------------------------------------------------------------------------}
//Compute and display NWE
//-----------------------------------------------------------------------------{
float y2 = na
float y1 = na
float y1_d = na
line l = na
label lb = na
if barstate.islast and repaint
//Compute and set NWE point
for i = 0 to math.min(499,n - 1)
sum = 0.
sumw = 0.
//Compute weighted mean
for j = 0 to math.min(499,n - 1)
w = gauss(i - j, h)
sum += src[j] * w
sumw += w
y2 := sum / sumw
d = y2 - y1
//Set coordinate line
l := array.get(ln,i)
line.set_xy1(l,n-i+1,y1)
line.set_xy2(l,n-i,y2)
line.set_color(l,y2 > y1 ? dnCss : upCss)
line.set_width(l,2)
if d * y1_d < 0
label.new(n-i+1, src[i], y1_d < 0 ? '▲' : '▼'
, color = color(na)
, style = y1_d < 0 ? label.style_label_up : label.style_label_down
, textcolor = y1_d < 0 ? upCss : dnCss
, textalign = text.align_center)
y1 := y2
y1_d := d
//-----------------------------------------------------------------------------}
//Dashboard
//-----------------------------------------------------------------------------{
var tb = table.new(position.top_right, 1, 1
, bgcolor = #1e222d
, border_color = #373a46
, border_width = 1
, frame_color = #373a46
, frame_width = 1)
if repaint
tb.cell(0, 0, 'Repainting Mode Enabled', text_color = color.white, text_size = size.small)
//-----------------------------------------------------------------------------}
//Plot
//-----------------------------------------------------------------------------}
plot(repaint ? na : out, 'NWE Endpoint Estimator', out > out[1] ? upCss : dnCss)
//-----------------------------------------------------------------------------} |
NNFX ATR | https://www.tradingview.com/script/fV7VJpVs-NNFX-ATR/ | sueun123 | https://www.tradingview.com/u/sueun123/ | 185 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © sueun123
// @version=4
// This is a product of combining the in-built ATR provided by TradingView and Dillon Grech's ATR (https://www.tradingview.com/script/bbxfw74y-Indicator-ATR-Profit-Loss-DG/)
study(title = "NNFX ATR", shorttitle = "ATR", overlay = true, format = format.price, precision = 5) //Don't add scale = scale.right as the indicator will move all over the place
atrLength = input(title = "X", defval = 14, minval = 1)
atrProfit = input(title = "TP", defval = 1, type = input.float)
atrLoss = input(title = "SL", defval = 1.5, type = input.float)
smoothing = input(title="Smoothing", defval="RMA", options=["RMA", "SMA", "EMA", "WMA"])
function(source, length) =>
if smoothing == "RMA"
rma(source, atrLength)
else
if smoothing == "SMA"
sma(source, atrLength)
else
if smoothing == "EMA"
ema(source, atrLength)
else
wma(source, atrLength)
formula(number, decimals) =>
factor = pow(10, decimals)
int(number * factor) / factor
atr = formula(function(tr(true), atrLength),5)
//Buy
bAtrBuy = atrLength ? close + atr* atrProfit : close - atr* atrProfit
bAtrSell = atrLength ? close - atr* atrLoss : close + atr* atrLoss
plot(bAtrBuy, title = "Buy TP", color = color.blue, transp = 0, linewidth = 1, trackprice = true, editable= true)
plot(bAtrSell, title = "Buy SL", color = color.red, transp = 25, linewidth = 1, trackprice = true, editable = true)
//Sell
sAtrBuy = atrLength ? close - atr* atrProfit : close + atr* atrProfit
sAtrSell = atrLength ? close + atr* atrLoss : close - atr* atrLoss
plot(sAtrBuy, title = " Sell TP", color = color.blue, transp = 35, linewidth = 1, trackprice = true, editable = true)
plot(sAtrSell, title = "Sell SL", color = color.red, transp = 50, linewidth = 1, trackprice = true, editable = true)
//This one is way below price because I don't want there to be a 5th line inbetween the 2 TPs and SLs
plot(atr, title = " Main ATR", color = color.yellow, transp = 0, linewidth = 1, editable = true)
//---END--- |
trend_vol_forecast | https://www.tradingview.com/script/jPOlXcjx-trend-vol-forecast/ | voided | https://www.tradingview.com/u/voided/ | 41 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © voided
//@version=4
study("trend_vol_forecast", overlay = true)
// USAGE
//
// This script compares trend trading with a volatility stop to "buy and hold".
// Trades are taken with the trend, except when price exceeds a volatility
// forecast. The trend is defined by a moving average crossover. The forecast
// is based on projecting future volatility from historical volatility.
//
// The trend is defined by two parameters:
//
// - long: the length of a long ("slow") moving average.
// - short: the length of a short ("fast") moving average.
//
// The trend is up when the short moving average is above the long. Otherwise
// it is down.
//
// The volatility stop is defined by three parameters:
//
// - volatility window: determines the number of periods in the historical
// volatility calculation. More periods means a slower (smoother)
// estimate of historical volatility.
// - stop forecast periods: the number of periods in the volatility
// forecast. For example, "7" on a daily chart means that the volatility
// will be forecasted with a one week lag.
// - stop forecast stdev: the number of standard deviations in the stop
// forecast. For example, "2" means two standard deviations.
//
// EXAMPLE
//
// The default parameters are:
//
// - long: 50
// - short: 20
// - volatility window: 30
// - stop forecast periods: 7
// - stop forecast standard deviations: 1
//
// The trend will be up when the 20 period moving average is above the 50
// period moving average. On each bar, the historical volatility will be
// calculated from the previous 30 bars. If the historical volatility is 0.65
// (65%), then a forecast will be drawn as a fuchsia line, subtracting
// 0.65 * sqrt(7 / 365) from the closing price. If price at any point falls
// below the forecast, the volatility stop is in place, and the trend is
// negated.
//
// OUTPUTS
//
// Plots:
// - The trend is shown by painting the slow moving average green (up), red
// (down), or black (none; volatility stop).
// - The fast moving average is shown in faint blue
// - The previous volatility forecasts are shown in faint fuchsia
// - The current volatility forecast is shown as a fuchsia line, projecting
// into the future as far as it is valid.
//
// Tables:
// - The current historical volatility is given in the top right corner, as a
// whole number percentage.
// - The performance table shows the mean, standard deviation, and sharpe
// ratio of the volatility stop trend strategy, as well as buy and hold.
// If the trend is up, each period's return is added to the sample (the
// strategy is long). If the trend is down, the inverse of each period's
// return is added to the sample (the strategy is short). If there is no
// trend (the volatility stop is active), the period's return is excluded
// from the sample. Every period is added to the buy-and-hold strategy's
// sample. The total number of periods in each sample is also shown.
// INPUTS
long = input(title = "long ma lag", type = input.integer, defval = 50)
short = input(title = "short ma lag", type = input.integer, defval = 20)
vol_window = input(title = "volatility window", type = input.integer, defval = 30)
stop_fcst_periods = input(title = "stop forecast periods", type = input.float, defval = 7)
stop_fcst_stdev = input(title = "stop forecast stdev", type = input.float, defval = 1)
// PROGRAM
var all_returns = array.new_float(0)
var strategy_returns = array.new_float(0)
slow = ema(close, long)
fast = ema(close, short)
r = log(close / close[1])
pd = time - time[1]
ppy = (365 * 24 * 60 * 60 * 1000) / pd
hv = sqrt(ema(pow(r, 2), vol_window) * ppy)
fcst = hv * stop_fcst_stdev * sqrt(stop_fcst_periods / ppy)
fcst_up = close[stop_fcst_periods] * (1 + fcst[stop_fcst_periods])
fcst_down = close[stop_fcst_periods] * (1 - fcst[stop_fcst_periods])
up = fast > slow and close > fcst_down
down = fast < slow and close < fcst_up
if up
array.push(strategy_returns, r)
else if down
array.push(strategy_returns, -r)
array.push(all_returns, r)
// OUTPUT
if barstate.islast
fmt = "#.###"
fcst_up_next = close * (1 + fcst)
fcst_down_next = close * (1 - fcst)
fcst_ln_up = line.new(time, fcst_up_next, int(time + stop_fcst_periods * pd), fcst_up_next, xloc = xloc.bar_time, color = down ? color.fuchsia : na)
fcst_ln_down = line.new(time, fcst_down_next, int(time + stop_fcst_periods * pd), fcst_down_next, xloc = xloc.bar_time, color = up ? color.fuchsia : na)
dt = table.new(position.top_right, 2, 3, bgcolor = color.white)
table.cell(dt, 0, 0, "hv current")
table.cell(dt, 1, 0, tostring(hv * 100, fmt))
table.cell(dt, 0, 1, "stop level")
table.cell(dt, 1, 1, tostring(down ? fcst_down : up ? fcst_up : na, fmt))
table.cell(dt, 0, 2, "stop %")
table.cell(dt, 1, 2, tostring(down ? abs((fcst_down - close) / close) * 100 : up ? abs((fcst_up - close) / close) * 100 : na, fmt))
rt = table.new(position.middle_right, 5, 3, bgcolor = color.white)
table.cell(rt, 0, 0, "", bgcolor = na)
table.cell(rt, 1, 0, "mean")
table.cell(rt, 2, 0, "stdev")
table.cell(rt, 3, 0, "sharpe")
table.cell(rt, 4, 0, "samples")
bh_avg = array.avg(all_returns) * 100
bh_std = array.stdev(all_returns) * 100
bh_shr = bh_avg / bh_std
bh_smp = array.size(all_returns)
table.cell(rt, 0, 1, "buy and hold")
table.cell(rt, 1, 1, tostring(bh_avg, fmt))
table.cell(rt, 2, 1, tostring(bh_std, fmt))
table.cell(rt, 3, 1, tostring(bh_shr, fmt))
table.cell(rt, 4, 1, tostring(bh_smp))
str_avg = array.avg(strategy_returns) * 100
str_std = array.stdev(strategy_returns) * 100
str_shr = str_avg / str_std
str_smp = array.size(strategy_returns)
table.cell(rt, 0, 2, "strategy")
table.cell(rt, 1, 2, tostring(str_avg, fmt))
table.cell(rt, 2, 2, tostring(str_std, fmt))
table.cell(rt, 3, 2, tostring(str_shr, fmt))
table.cell(rt, 4, 2, tostring(str_smp))
// plots and labels
plot(slow, color = up ? color.green : down ? color.red : color.black)
plot(fast, color = color.new(color.blue, 80))
fcst_clr = color.new(color.fuchsia, 80)
plot(fcst_up, color = down ? fcst_clr : na, style = plot.style_stepline)
plot(fcst_down, color = up ? fcst_clr : na, style = plot.style_stepline)
if up and low < fcst_down
label.new(bar_index, low, "x", style = label.style_none, textcolor = color.fuchsia)
else if down and high > fcst_up
label.new(bar_index, high, "x", style = label.style_none, textcolor = color.fuchsia) |
Candle EMA | https://www.tradingview.com/script/SXFjqTpg-Candle-EMA/ | fikira | https://www.tradingview.com/u/fikira/ | 313 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © fikira
//@version=4
study("Candle EMA", shorttitle="Candema", overlay=false)
ema3 = ema(close, input( 3 , title="Length 1" ))
ema5 = ema(close, input( 5 , title="Length 2" ))
ema8 = ema(close, input( 8 , title="Length 3" ))
ema13 = ema(close, input(13 , title="Length 4" ))
c_up = input(color.new(#26a69a, 0), title="color up" )
c_dn = input(color.new(#ef5350, 0), title="color down")
max = max(ema3, ema5, ema8, ema13)
min = min(ema3, ema5, ema8, ema13)
ope = 0.
ope :=
(ema3 == max or ema3 == min) and (ema5 == max or ema5 == min) ? ema13 :
(ema3 == max or ema3 == min) and (ema8 == max or ema8 == min) ? ema13 :
(ema3 == max or ema3 == min) and (ema13 == max or ema13 == min) ? ema8 :
(ema3 == max or ema3 == min) and (ema8 == max or ema8 == min) ? ema13 :
(ema5 == max or ema5 == min) and (ema8 == max or ema8 == min) ? ema13 :
(ema5 == max or ema5 == min) and (ema13 == max or ema13 == min) ? ema8 :
ema5
clo = 0.
clo :=
(ema3 == max or ema3 == min) and (ema5 == max or ema5 == min) ? ema8 :
(ema3 == max or ema3 == min) and (ema8 == max or ema8 == min) ? ema5 :
(ema3 == max or ema3 == min) and (ema13 == max or ema13 == min) ? ema5 :
(ema3 == max or ema3 == min) and (ema8 == max or ema8 == min) ? ema5 :
(ema5 == max or ema5 == min) and (ema8 == max or ema8 == min) ? ema3 :
(ema5 == max or ema5 == min) and (ema13 == max or ema13 == min) ? ema3 :
ema3
plotcandle(ope, max, min, clo, title="", color=clo >= ope ? c_up : c_dn, wickcolor=clo >= ope ? c_up : c_dn, bordercolor=clo >= ope ? c_up : c_dn)
|
trend_vol_stop | https://www.tradingview.com/script/cuyL2IzN-trend-vol-stop/ | voided | https://www.tradingview.com/u/voided/ | 59 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © voided
//@version=4
study("trend_vol_stop", overlay = true, precision = 3)
// Usage:
//
// The inputs define the trend and the volatility stop.
//
// Trend:
// The trend is defined by a moving average crossover. When the short
// (or fast) moving average is above the long (slow) moving average, the
// trend is up. Otherwise, the trend is down. The inputs are:
//
// long: the number of periods in the long/slow moving average.
// short: the number of periods in the short/fast moving average.
//
// The slow moving average is shown in various colors (see explanation
// below. The fast moving average is a faint blue.
//
// Volatility stop:
// The volatility stop has two modes, percentage and rank. The percentage
// stop is given in terms of annualized volatility. The rank stop is given
// in terms of percentile.
//
// stop_pct and stop_rank are initialized with "-1". You need to set one of
// these to the values you want after adding the indicator to your chart.
// This is the only setting that requires your input.
//
// mode: choose "rank" for a rank stop, "percentage" for a percentage stop.
// vol_window: the number of periods in the historical volatility
// calculation. e.g. "30" means the volatility will be a weighted
// average of the previous 30 periods. applies to both types of stop.
// stop_pct: the volatility limit, annualized. for example, "50" means
// that the trend will not be followed when historical volatility rises
// above 50%.
// stop_rank: the trend will not be followed when the volatility is in the
// N-th percentile. for example, "75" means the trend will not be
// followed when the current historical volatility is greater than 75%
// of previous volatilities.
// rank_window: the number of periods in the rank percentile calculation.
// for example, if rank_window is "252" and "stop_rank" is "80", the
// trend will not be followed when current historical volatility is
// greater than 80% of the previous 252 historical volatilities.
//
// Outputs:
//
// The outputs include moving averages, to visually identify the trend,
// a volatility table, and a performance table.
//
// Moving averages:
// The slow moving average is colored green in an uptrend, red in a
// downtrend, and black when the volatility stop is in place.
//
// Volatility table:
// The volatility table gives the current historical volatility, annualized
// and expressed as a whole number percentage. E.g. "65" means the
// instrument's one standard deviation annual move is 65% of its price.
//
// The current rank is expressed, also as a whole number percentage. E.g.
// "15" means the current volatility is greater than 15% of previous
// volatilities. For convenience, the volatilities corresponding to the
// 0, 25, 50, 75, and 100th percentiles are also shown.
//
// Performance table:
// The performance table shows the current strategy's performance versus
// buy-and-hold. If the trend is up, the instrument's return for that
// period is added to the strategy's return, because the strategy is long.
// If the trend is down, the negative return is added, because the strategy
// is short. If the volatility stop is in (the slow moving average is
// black), that period's return is excluded from the strategy returns.
//
// Every period's return is added to the buy-and-hold returns.
//
// The table shows the average return, the standard deviation of returns,
// and the sharpe ratio (average return / standard deviation of returns).
// All figures are expressed as per-period, whole number percentages.
// For exmaple, "0.1" in the mean column on a daily chart means a
// 0.1% daily return.
//
// The number of periods (samples) for each strategy is also shown.
// INPUTS
long = input(title = "long ma lag", type = input.integer, defval = 50)
short = input(title = "short ma lag", type = input.integer, defval = 20)
mode = input(title = "mode", options = [ "percentage", "rank" ], defval = "rank")
vol_window = input(title = "volatility window", type = input.integer, defval = 30)
stop_pct = input(title = "stop percentage", type = input.float, defval = -1)
stop_rank = input(title = "stop rank", type = input.float, defval = -1)
rank_window = input(title = "rank window", type = input.integer, defval = 252)
// PROGRAM
var all_returns = array.new_float(0)
var strategy_returns = array.new_float(0)
slow = ema(close, long)
fast = ema(close, short)
ppy = (365 * 24 * 60 * 60 * 1000) / (time - time[1])
r = log(close / close[1])
hv = sqrt(ema(pow(r, 2), vol_window) * ppy) * 100
rank = percentrank(hv, rank_window)
var bool up = na
var bool down = na
if mode == "percentage"
up := fast > slow and hv < stop_pct and hv < stop_pct
down := fast < slow and hv < stop_pct and hv < stop_pct
else if mode == "rank"
up := fast > slow and rank < stop_rank and rank < stop_rank
down := fast < slow and rank < stop_rank and rank < stop_rank
if up
array.push(strategy_returns, r)
else if down
array.push(strategy_returns, -r)
array.push(all_returns, r)
rank_0 = percentile_nearest_rank(hv, rank_window, 0)
rank_25 = percentile_nearest_rank(hv, rank_window, 25)
rank_50 = percentile_nearest_rank(hv, rank_window, 50)
rank_75 = percentile_nearest_rank(hv, rank_window, 75)
rank_100 = percentile_nearest_rank(hv, rank_window, 100)
if barstate.islast
fmt = "#.##"
dt = table.new(position.top_right, 2, 7, bgcolor = color.white)
table.cell(dt, 0, 0, "hv current")
table.cell(dt, 1, 0, tostring(hv, fmt))
table.cell(dt, 0, 1, "rank current")
table.cell(dt, 1, 1, tostring(rank, fmt))
table.cell(dt, 0, 2, "0%")
table.cell(dt, 1, 2, tostring(rank_0, fmt))
table.cell(dt, 0, 3, "25%")
table.cell(dt, 1, 3, tostring(rank_25, fmt))
table.cell(dt, 0, 4, "50%")
table.cell(dt, 1, 4, tostring(rank_50, fmt))
table.cell(dt, 0, 5, "75%")
table.cell(dt, 1, 5, tostring(rank_75, fmt))
table.cell(dt, 0, 6, "100%")
table.cell(dt, 1, 6, tostring(rank_100, fmt))
rt = table.new(position.middle_right, 5, 3, bgcolor = color.white)
table.cell(rt, 0, 0, "", bgcolor = na)
table.cell(rt, 1, 0, "mean")
table.cell(rt, 2, 0, "stdev")
table.cell(rt, 3, 0, "sharpe")
table.cell(rt, 4, 0, "samples")
bh_avg = array.avg(all_returns) * 100
bh_std = array.stdev(all_returns) * 100
bh_shr = bh_avg / bh_std
bh_smp = array.size(all_returns)
table.cell(rt, 0, 1, "buy and hold")
table.cell(rt, 1, 1, tostring(bh_avg, fmt))
table.cell(rt, 2, 1, tostring(bh_std, fmt))
table.cell(rt, 3, 1, tostring(bh_shr, fmt))
table.cell(rt, 4, 1, tostring(bh_smp))
str_avg = array.avg(strategy_returns) * 100
str_std = array.stdev(strategy_returns) * 100
str_shr = str_avg / str_std
str_smp = array.size(strategy_returns)
table.cell(rt, 0, 2, "strategy")
table.cell(rt, 1, 2, tostring(str_avg, fmt))
table.cell(rt, 2, 2, tostring(str_std, fmt))
table.cell(rt, 3, 2, tostring(str_shr, fmt))
table.cell(rt, 4, 2, tostring(str_smp))
plot(slow, color = up ? color.green : down ? color.red : color.black)
plot(fast, color = color.new(color.blue, 80)) |
Three Week Tight Pattern Indicator | https://www.tradingview.com/script/vKtTduwS-Three-Week-Tight-Pattern-Indicator/ | GreatStockMark | https://www.tradingview.com/u/GreatStockMark/ | 100 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © GreatStockMarketer
//@version=4
study(title="Three Week Tight Pattern", overlay=true)
showLabels = input(title="Show Labels", type=input.bool, defval=true)
// truncate() truncates a given number to a certain number of decimals
truncate(number, decimals) =>
factor = pow(10, decimals)
int(number * factor) / factor
thisWkC = security(syminfo.ticker, 'W', close)
oneWkBackC = security(syminfo.ticker, 'W', close[1])
TwoWkBackC = security(syminfo.ticker, 'W', close[2])
ThreeWkBackC = security(syminfo.ticker, 'W', close[3])
pcChange2wk = truncate((oneWkBackC/TwoWkBackC),3)
pcChange1wk = truncate((thisWkC/TwoWkBackC),3)
pcChange0wk = truncate((thisWkC/oneWkBackC),3)
is0wkTight = (pcChange0wk < 1.015 and pcChange0wk > 0.985)? true: false
is1wkTight = (pcChange1wk < 1.015 and pcChange1wk > 0.985)? true: false
is2wkTight = (pcChange2wk < 1.015 and pcChange2wk > 0.985)? true: false
isthreeWeekTF = is0wkTight and is1wkTight and is2wkTight
if isthreeWeekTF and showLabels
label1 = label.new(bar_index[0], high[0], text="3W Tight", style=label.style_labeldown, color=color.white)
|
Green Line Breakout (GLB) - Public Use | https://www.tradingview.com/script/qfNJJ8Da-Green-Line-Breakout-GLB-Public-Use/ | GreatStockMark | https://www.tradingview.com/u/GreatStockMark/ | 84 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © GreatStockMarketer
//@version=4
study("Green Line Breakout", overlay = true)
int data_range = 470
float[] monthHighs = array.new_float(data_range, 0)
float[] GLValues = array.new_float(3, 0)
//float monthHigh = 0.0
float curentGLV = 0.00
float lastGLV = 0.00
int counter = 0
float val = na
//mnthHighValue(period) => security(syminfo.tickerid,"M",high[period],lookahead=true)
for _i = 0 to data_range-1
array.set(id=monthHighs, index=_i, value=high[data_range-_i])
//val := mnthHighValue(10)
for _j = 0 to data_range-1
if array.get(id=GLValues, index=0) < array.get(id=monthHighs, index=_j)
curentGLV := array.get(id=monthHighs, index=_j)
array.set(id=GLValues, index=0,value=curentGLV) //Holds the current GLV
counter := 0
if array.get(id=GLValues, index=0) > array.get(id=monthHighs, index=_j)
counter := counter + 1
if counter == 3 //and ((month(time) != month(timenow)) or (year(time) != year(timenow)))
lastGLV := array.get(id=GLValues, index=0)
array.set(id=GLValues, index=1,value=lastGLV) //Holds the current GLV
counter=0
if timeframe.ismonthly == false
array.set(id=GLValues, index=1,value=na)
plot(array.get(GLValues,1), color=timeframe.ismonthly?color.green:color.white, trackprice=true, show_last=1, linewidth=3) |
Sagar sir - N Continuous candle green with +ve % change | https://www.tradingview.com/script/RH75DUoI-Sagar-sir-N-Continuous-candle-green-with-ve-change/ | bhaving | https://www.tradingview.com/u/bhaving/ | 32 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © bhaving
//@version=4
study("N Continuous candle with % change", overlay=true)
//input
noOfCandles = input(title="Number Of Continuous Green Candles", defval=3)
percentageChange = input(title="Percentage Change", defval=20)
highest = highest(noOfCandles)
lowest = lowest(noOfCandles)
if percentageChange < 0
percentageChange := percentageChange * -1
if percentageChange == 0
percentageChange := 20
percent(n1, n2) =>
((n1 - n2) / n2) * 100
truncate(number, decimals) =>
factor = pow(10, decimals)
int(number * factor) / factor
// check for continuous green candle
checkForGreen() =>
result = close > open
for i=1 to noOfCandles - 1
result := result and (close[i] > open[i])
result
continousGreen = checkForGreen()
//calculate percentage and keep 2 decimal place
percentage = percent(highest, lowest)
percentage := truncate(percentage, 2)
if (continousGreen and percentage > percentageChange)
var label maLabel = na
percText = tostring(truncate(high, 2)) + "\n(" + tostring(percentage) + "%)"
maLabel := label.new(x=bar_index, y=na, yloc=yloc.abovebar,
style=label.style_labeldown, color=color.new(color.blue, 10),
text=percText,
textcolor=color.new(color.white, 10))
maLabel := label.new(x=bar_index - 2, y=na, yloc=yloc.belowbar,
style=label.style_label_up, color=color.new(color.blue, 10),
text=tostring(truncate(low[noOfCandles - 1], 2)),
textcolor=color.new(color.white, 10))
// resetting value except our condition match
percentage := continousGreen and percentage > percentageChange ? percentage : 0
highest := continousGreen and percentage > percentageChange ? highest : 0
lowest := continousGreen and percentage > percentageChange ? lowest : 0
// display values along with the sript name in top right corner
plotchar(percentage, "", "", location.top, color.yellow)
plotchar(highest, "", "", location.top, color.green)
plotchar(lowest, "", "", location.top, color.red) |
Gap Rider | https://www.tradingview.com/script/NSWvAC6x/ | eruscio | https://www.tradingview.com/u/eruscio/ | 24 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Emanuele Ruscio
//@version=4
study("Gap Rider", overlay=true)
//Configure Days pf the week variable
isMon() => dayofweek(time('D')) == dayofweek.monday
isTue() => dayofweek(time('D')) == dayofweek.tuesday
isWed() => dayofweek(time('D')) == dayofweek.wednesday
isThu() => dayofweek(time('D')) == dayofweek.thursday
isFri() => dayofweek(time('D')) == dayofweek.friday
isSat() => dayofweek(time('D')) == dayofweek.saturday
isSun() => dayofweek(time('D')) == dayofweek.sunday
//Configure Days of the week Input
showMon = input(true, title="Show Monday?", group = "========= Days of the Week =========")
showTue = input(true, title="Show Tuesday?", group = "========= Days of the Week =========")
showWed = input(true, title="Show Wednesday?", group = "========= Days of the Week =========")
showThu = input(true, title="Show Thursday?", group = "========= Days of the Week =========")
showFri = input(true, title="Show Friday?", group = "========= Days of the Week =========")
//Inputs
//==============================================================================
Lookback = input(10, title = "Loockback length for Statistics", group = "========= Lookback =========")
Select_Gap_Up = input(title = "Show Gap-up Flags", defval = true, group = "========= Gap Select =========", inline = "x")
Select_Gap_Down = input(title = "Show Gap-down Flags", defval = true, group = "========= Gap Select =========", inline = "x")
ATRThreshold_toggle = input(title = "Limit Gaps Within ATR Values", defval = false, group = "========= ATR Configure =========")
ATRUpper = input(title = "ATR Upper Threshold Value", defval = 50, step = 0.5, minval = 0, group = "========= ATR Configure =========", tooltip = " When 'Limit Gaps Within ATR Values' is turned on, only show Gaps below this value, and above Lower Threshold")
ATRLower = input(title = "ATR Lower Threshold Value", defval = 20, step = 0.5, minval = 0, group = "========= ATR Configure =========", tooltip = " When 'Limit Gaps Within ATR Values' is turned on, only show Gaps above this value, and below Upper Threshold")
ATRlength = input(title="Length", defval=14, minval=1, group = "========= ATR Configure =========")
smoothing = input(title="Smoothing", defval="RMA", options=["RMA", "SMA", "EMA", "WMA"], group = "========= ATR Configure =========")
Percent_Points = input(title = "Percent or Points for Gap Spread", defval = "Points", options = ["Percent", "Points"], group = "========= Gap Measurement =========")
gap_minimum = input(5, title = "Minimum difference in Price for Gap to occur (Flag)", step = 0.01, group = "========= Gap Measurement =========")
Confirm_Spread = input(5, title = "Minimum Distance for Gap Confirmation (Box)", step = 0.01, group = "========= Breakeven Measurement=========")
Large_Gap_toggle = input(title = "Only Show Large Gaps", defval = false, group = "========= Large Gap =========", tooltip = "Only show Gaps that form outside of the previous candle")
ATR_Lower_Limit = ATRThreshold_toggle ? ATRLower : 0
ATR_Upper_Limit = ATRThreshold_toggle ? ATRUpper : 99999
ma_function(source, ATRlength) =>
if smoothing == "RMA"
rma(source, ATRlength)
else
if smoothing == "SMA"
sma(source, ATRlength)
else
if smoothing == "EMA"
ema(source, ATRlength)
else
wma(source, ATRlength)
//plot(ma_function(tr(true), ATRlength), title = "ATR", color=color.new(#B71C1C, 0))
ATR = ma_function(tr(true), ATRlength)
//Variables
gap_value = abs(open - close[1])
var gap_min = 0.0
if (Percent_Points == "Percent")
gap_min := close * (gap_minimum/100)
else
gap_min := gap_minimum
Large_Gap = Large_Gap_toggle ? open > high[1] or open < low[1] : true
//==============================================================================
//INDICATOR 1 - Trigger
//==============================================================================
//Gap logic
gap = open != close[1] and ((isMon() and showMon) or (isTue() and showTue) or (isWed() and showWed) or (isThu() and showThu) or (isFri() and showFri)) and gap_value > gap_min and ATR > ATR_Lower_Limit and ATR < ATR_Upper_Limit and Large_Gap
gap_up = open > close[1] and ((isMon() and showMon) or (isTue() and showTue) or (isWed() and showWed) or (isThu() and showThu) or (isFri() and showFri)) and gap_value > gap_min and Select_Gap_Up and gap
gap_down = open < close[1] and ((isMon() and showMon) or (isTue() and showTue) or (isWed() and showWed) or (isThu() and showThu) or (isFri() and showFri)) and gap_value > gap_min and Select_Gap_Down and gap
gap_confirm_up = gap_up and abs(close - open) > Confirm_Spread
gap_confirm_down = gap_down and abs(close - open) > Confirm_Spread
Gap_Complete_up = gap_confirm_up and gap_up ? close > open and abs(open - close[1]) > gap_min ? "Win" : close < open and abs(open - close[1]) > gap_min ? "Lose" : na : na
Gap_Complete_down = gap_confirm_down and gap_down ? close < open and abs(open - close[1]) > gap_min ? "Win" : close > open and abs(open - close[1]) > gap_min ? "Lose" : na : na
No_Gap = not gap
Gap_Neutral = gap_value > gap_min and (Gap_Complete_up == na and Gap_Complete_down == na) and ((isMon() and showMon) or (isTue() and showTue) or (isWed() and showWed) or (isThu() and showThu) or (isFri() and showFri)) and (gap_up or gap_down)
//☐ ☑ ☒
//==============================================================================
//Plot Gap Flag
gap_color = gap_up ? color.green : gap_down ? color.red : color.yellow
plotchar(series = gap and (gap_up or gap_down), char = "⚑", color = gap_color, title = "Gap Flag")
//Plot Gap Boxes
plotchar(title = "Winning Gap-up Box", series = Gap_Complete_up == "Win" and gap_up , char = "☑", color = color.green, location = location.belowbar)
plotchar(title = "Losing Gap-up Box", series = Gap_Complete_up == "Lose" and gap_up, char = "☒", color = color.red, location = location.belowbar)
plotchar(title = "Break Even Gap Box", series =Gap_Neutral and (gap_up or gap_down) , char = "☐", color = color.yellow, location = location.belowbar)
plotchar(title = "Winning Gap-down Box", series = Gap_Complete_down == "Win" and gap_down , char = "☑", color = color.green, location = location.belowbar)
plotchar(title = "Losing Gap-down Box" , series = Gap_Complete_down == "Lose" and gap_down, char = "☒", color = color.red, location = location.belowbar)
//==============================================================================
//=========Consecutive Wins=========
Candles_Since_Win = barssince(Gap_Complete_up == "Win" or Gap_Complete_down == "Win")
Candles_Since_Lose = barssince(Gap_Complete_up == "Lose" or Gap_Complete_down == "Lose" or Gap_Neutral)
Candles_Since_Gap = barssince(No_Gap)
//Iterate Tally
var Win_Tally = 0
Consec_Win = if Candles_Since_Win == 0
Win_Tally := Win_Tally + 1
else if Candles_Since_Lose == 0
Win_Tally := 0
else if Candles_Since_Gap == 0
Win_Tally := Win_Tally[1]
//Configure Array
var c = array.new_int(Lookback, 0)
for i = (Lookback - 1) to 0
array.shift(c)
array.push(c,Consec_Win[i])
//=========Consecutive Losses=========
Candles_Since_Win_2 = barssince(Gap_Complete_up == "Win" or Gap_Complete_down == "Win" or Gap_Neutral)
Candles_Since_Lose_2 = barssince(Gap_Complete_up == "Lose" or Gap_Complete_down == "Lose")
//Iterate Tally
var Loss_Tally = 0
Consec_Loss = if Candles_Since_Lose_2 == 0
Loss_Tally := Loss_Tally + 1
else if Candles_Since_Win_2 == 0
Loss_Tally := 0
else if Candles_Since_Gap == 0
Loss_Tally := Loss_Tally[1]
//Configure Array
var d = array.new_int(Lookback, 0)
for i = (Lookback - 1) to 0
array.shift(d)
array.push(d,Consec_Loss[i])
//=========Consecutive Push=========
Candles_Since_Win_3 = barssince(Gap_Complete_up == "Win" or Gap_Complete_down == "Win")
Candles_Since_Lose_3 = barssince(Gap_Complete_up == "Lose" or Gap_Complete_down == "Lose")
Candles_Since_Push = barssince(Gap_Neutral and gap)
//Iterate Tally
var Push_Tally = 0
Consec_Push = if Candles_Since_Push == 0
Push_Tally := Push_Tally + 1
else if Candles_Since_Lose_3 == 0 or Candles_Since_Win_3 == 0
Push_Tally := 0
else if Candles_Since_Gap == 0
Push_Tally := Push_Tally[1]
//Configure Array
var e = array.new_int(Lookback, 0)
for i = (Lookback - 1) to 0
array.shift(e)
array.push(e,Consec_Push[i])
//========= Drawdown Calc=========
//Iterate Tally
// Tally = 0
// var DD_Tally = 0
// DD_Push = if gap and (Gap_Complete_up == "Win" or Gap_Complete_down == "Win" and (gap_up or gap_down))
// if DD_Tally == 0
// DD_Tally := 0
// else
// DD_Tally := DD_Tally + 1
// else if gap and (Gap_Complete_up == "Lose" or Gap_Complete_down == "Lose" and (gap_up or gap_down))
// DD_Tally := DD_Tally -1
// else
// DD_Tally := DD_Tally + 0
//Configure Array
var f = array.new_int(Lookback, 0)
// for i = (Lookback - 1) to 0
// array.shift(f)
// array.push(f,DD_Push[i])
DD_Tally_2 = 0
for i = (Lookback - 1) to 0
DD_Push = if gap[i] and (Gap_Complete_up[i] == "Win" or Gap_Complete_down[i] == "Win" and (gap_up[i] or gap_down[i]))
if DD_Tally_2 == 0
DD_Tally_2 := DD_Tally_2 + 0
else
DD_Tally_2 := DD_Tally_2 + 1
else if gap[i] and (Gap_Complete_up[i] == "Lose" or Gap_Complete_down[i] == "Lose" and (gap_up[i] or gap_down[i]))
DD_Tally_2 := DD_Tally_2 - 1
else if Gap_Neutral[i] and (gap_up[i] or gap_down[i])
DD_Tally_2 := DD_Tally_2 + 0
else
DD_Tally_2 := DD_Tally_2
array.shift(f)
array.push(f,DD_Push)
// lab = ""
// for i = 0 to array.size(f) - 1
// lab := lab + tostring(array.get(f, i)) + " "
// l = label.new(bar_index, close, lab)
// label.delete(l[1])
//==============================================================================
// Initiate Gaps Statistics
positive_gaps = 0
negative_gaps = 0
total_gaps = 0
Profit_gaps = 0
Push_gaps = 0
Lose_gaps = 0
Gap_Up_Wins = 0
Gap_up_Even = 0
Gap_Up_Loss = 0
Gap_down_Wins = 0
Gap_down_Even = 0
Gap_down_Loss = 0
Consecutive_Win = 0
//Calcualte Variables For Stats Table
for i = 0 to (Lookback - 1)
if gap_up[i] and gap[i]
positive_gaps := positive_gaps + 1
if gap_down[i] and gap[i]
negative_gaps := negative_gaps + 1
if gap[i] and (gap_up[i] or gap_down[i])
total_gaps := total_gaps + 1
if (Gap_Complete_up[i] == "Win") or (Gap_Complete_down[i] == "Win")
Profit_gaps := Profit_gaps + 1
if Gap_Neutral[i] and gap[i]
Push_gaps := Push_gaps + 1
if (Gap_Complete_up[i] == "Lose") or (Gap_Complete_down[i] == "Lose")
Lose_gaps := Lose_gaps + 1
if gap_up[i] and Gap_Complete_up[i] == "Win"
Gap_Up_Wins := Gap_Up_Wins + 1
if gap_up[i] and Gap_Neutral[i]
Gap_up_Even := Gap_up_Even + 1
if gap_up[i] and Gap_Complete_up[i] == "Lose"
Gap_Up_Loss := Gap_Up_Loss + 1
if gap_down[i] and Gap_Complete_down[i] == "Win"
Gap_down_Wins := Gap_down_Wins + 1
if gap_down[i] and Gap_Neutral[i]
Gap_down_Even := Gap_down_Even + 1
if gap_down[i] and Gap_Complete_down[i] == "Lose"
Gap_down_Loss := Gap_down_Loss + 1
//Plot Vertical line at lookback period
Line = line.new(bar_index[Lookback], low[Lookback] - close[Lookback]/20, bar_index[Lookback], high[Lookback] + close[Lookback]/20, color = color.red, style = line.style_dotted)
line.delete(Line[1])
//==============================================================================
//Configure Stats Table
Test_Table = table.new(position = position.bottom_right, columns = 1, rows = 17, bgcolor = #000000, frame_color = color.white, frame_width = 2)
table.cell(Test_Table, column = 0, row = 0, text_color = color.white, text_halign = text.align_center, text ="================== Statistics ==================")
table.cell(Test_Table, column = 0, row = 1, text_color = color.white, text_halign = text.align_left, text ="Total number of Gaps: " + tostring(total_gaps) + " (" + tostring(round((total_gaps/Lookback)*100,2)) + "% of sessions)")
table.cell(Test_Table, column = 0, row = 2, text_color = color.white, text_halign = text.align_left, text ="Total number of Gaps-up: " + tostring(positive_gaps) + " (" + tostring(round((positive_gaps/Lookback)*100,2)) + "% of sessions)")
table.cell(Test_Table, column = 0, row = 3, text_color = color.white, text_halign = text.align_left, text ="Total number of Gaps-down: " + tostring(negative_gaps) + " (" + tostring(round((negative_gaps/Lookback)*100,2)) + "% of sessions)")
table.cell(Test_Table, column = 0, row = 4, text_color = color.green, text_halign = text.align_left, text ="Total number of Profitable Gaps: " + tostring(Profit_gaps) + " (" + tostring(round((Profit_gaps/total_gaps)*100,2)) + "% of Gaps)")
table.cell(Test_Table, column = 0, row = 5, text_color = color.yellow, text_halign = text.align_left, text ="Total number of Break Even Gaps: " + tostring(Push_gaps) + " (" + tostring(round((Push_gaps/total_gaps)*100,2)) + "% of Gaps)")
table.cell(Test_Table, column = 0, row = 6, text_color = color.red, text_halign = text.align_left, text ="Total number of Losing Gaps: " + tostring(Lose_gaps) + " (" + tostring(round((Lose_gaps/total_gaps)*100,2)) + "% of Gaps)")
table.cell(Test_Table, column = 0, row = 7, text_color = color.white, text_halign = text.align_left, text ="Total number of Winning Gaps-Up: " + tostring(Gap_Up_Wins) + " (" + tostring(round((Gap_Up_Wins/positive_gaps)*100,2)) + "% of Gaps-up)")
table.cell(Test_Table, column = 0, row = 8, text_color = color.white, text_halign = text.align_left, text ="Total number of Neutral Gaps-Up: " + tostring(Gap_up_Even) + " (" + tostring(round((Gap_up_Even/positive_gaps)*100,2)) + "% of Gaps-up)")
table.cell(Test_Table, column = 0, row = 9, text_color = color.white, text_halign = text.align_left, text ="Total number of Losing Gaps-Up: " + tostring(Gap_Up_Loss) + " (" + tostring(round((Gap_Up_Loss/positive_gaps)*100,2)) + "% of Gaps-up)")
table.cell(Test_Table, column = 0, row = 10, text_color = color.white, text_halign = text.align_left, text ="Total number of Winning Gaps-Down: " + tostring(Gap_down_Wins) + " (" + tostring(round((Gap_down_Wins/negative_gaps)*100,2)) + "% of Gaps-down)")
table.cell(Test_Table, column = 0, row = 11, text_color = color.white, text_halign = text.align_left, text ="Total number of Neutral Gaps-Down: " + tostring(Gap_down_Even) + " (" + tostring(round((Gap_down_Even/negative_gaps)*100,2)) + "% of Gaps-down)")
table.cell(Test_Table, column = 0, row = 12, text_color = color.white, text_halign = text.align_left, text ="Total number of Losing Gaps-Down: " + tostring(Gap_down_Loss) + " (" + tostring(round((Gap_down_Loss/negative_gaps)*100,2)) + "% of Gaps-down)")
table.cell(Test_Table, column = 0, row = 13, text_color = color.green, text_halign = text.align_left, text ="Max Consecutive Winning Gaps: " + tostring(array.max(c)))
table.cell(Test_Table, column = 0, row = 14, text_color = color.yellow, text_halign = text.align_left, text ="Max Consecutive Break Even: " + tostring(array.max(e)))
table.cell(Test_Table, column = 0, row = 15, text_color = color.red, text_halign = text.align_left, text ="Max Consecutive Losing Gaps: " + tostring(array.max(d)))
table.cell(Test_Table, column = 0, row = 16, text_color = color.red, text_halign = text.align_left, text ="Max Drawdown: " + tostring(array.min(f)))
|
Percentile - Price vs Fundamentals | https://www.tradingview.com/script/2JRj8KlI-Percentile-Price-vs-Fundamentals/ | Trendoscope | https://www.tradingview.com/u/Trendoscope/ | 182 | study | 5 | MPL-2.0 | // 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('Percentile - Price vs Fundamentals')
//################################### INPUT ################################### //
i_numberOfRanges = input.int(100, title='Number of ranges', options=[5, 10, 20, 25, 50, 100, 200, 500, 1000], group='Main')
i_percentile = true
i_reference = input.string('ath', title='Reference', options=['ath', 'window'], group='Reference')
i_startTime = input.time(defval=timestamp('01 Jan 2010 00:00 +0000'), title='Start Time', group='Reference')
i_endTime = input.time(defval=timestamp('01 Jan 2099 00:00 +0000'), title='End Time', group='Reference')
inDateRange = time >= i_startTime and time <= i_endTime
i_displayHeader = input.bool(true, 'Display Header', group='Display', inline='text')
i_text_size = input.string(size.normal, title='', options=[size.tiny, size.small, size.normal, size.large, size.huge], group='Display', inline='text')
//################################### FUNDAMENTALS ################################### //
f_getFinancials(financial_id, period) =>
request.financial(syminfo.tickerid, financial_id, period)
f_getOptimalFinancialBasic(financial_id) =>
f_getFinancials(financial_id, syminfo.currency == 'USD' ? 'FQ' : 'FY')
tso = request.financial(syminfo.tickerid, 'TOTAL_SHARES_OUTSTANDING', 'FQ')
bvps = request.financial(syminfo.tickerid, 'BOOK_VALUE_PER_SHARE', 'FQ')
eps = request.financial(syminfo.tickerid, 'EARNINGS_PER_SHARE_BASIC', 'TTM')
rps = request.financial(syminfo.tickerid, 'TOTAL_REVENUE', 'TTM') / tso
ebitda = request.financial(syminfo.tickerid, 'EBITDA', 'TTM') / tso
ebit = f_getOptimalFinancialBasic('EBIT') / tso
fcf = f_getOptimalFinancialBasic('FREE_CASH_FLOW') / tso
//currentassets = f_getOptimalFinancialBasic("NCAVPS_RATIO")
nmargin = f_getOptimalFinancialBasic('NET_MARGIN')
gmargin = f_getOptimalFinancialBasic('GROSS_MARGIN')
omargin = f_getOptimalFinancialBasic('OPERATING_MARGIN')
emargin = f_getOptimalFinancialBasic('EBITDA_MARGIN')
fmargin = f_getOptimalFinancialBasic('FREE_CASH_FLOW_MARGIN')
roa = f_getOptimalFinancialBasic('RETURN_ON_ASSETS')
roe = f_getOptimalFinancialBasic('RETURN_ON_EQUITY')
roic = f_getOptimalFinancialBasic('RETURN_ON_INVESTED_CAPITAL')
ldta = 1 / f_getOptimalFinancialBasic('LONG_TERM_DEBT_TO_ASSETS')
dta = 1 / f_getOptimalFinancialBasic('DEBT_TO_ASSET')
dte = 1 / f_getOptimalFinancialBasic('DEBT_TO_EQUITY')
dtr = 1 / f_getOptimalFinancialBasic('DEBT_TO_REVENUE')
dteb = 1 / f_getOptimalFinancialBasic('DEBT_TO_EBITDA')
//################################### Random color generator ################################### //
// ************** This part of the code is taken from // © RicardoSantos
// https://www.tradingview.com/script/4jdGt6Xo-Function-HSL-color/
f_color_hsl(_hue, _saturation, _lightness, _transparency) => //{
// @function: returns HSL color.
// @reference: https://stackoverflow.com/questions/36721830/convert-hsl-to-rgb-and-hex
float _l1 = _lightness / 100.0
float _a = _saturation * math.min(_l1, 1.0 - _l1) / 100.0
float _rk = (0.0 + _hue / 30.0) % 12.0
float _r = 255.0 * (_l1 - _a * math.max(math.min(_rk - 3.0, 9.0 - _rk, 1.0), -1.0))
float _gk = (8.0 + _hue / 30.0) % 12.0
float _g = 255.0 * (_l1 - _a * math.max(math.min(_gk - 3.0, 9.0 - _gk, 1.0), -1.0))
float _bk = (4.0 + _hue / 30.0) % 12.0
float _b = 255.0 * (_l1 - _a * math.max(math.min(_bk - 3.0, 9.0 - _bk, 1.0), -1.0))
color.rgb(_r, _g, _b, _transparency)
//}
// ************** End of borrowed code
f_random_color() =>
f_color_hsl(math.random(0, 255), math.random(70, 100), math.random(30, 70), 0)
//################################### CONSTANTS AND ARRAYS ################################### //
var CELLRANGE = 100 / i_numberOfRanges
var NUMBER_OF_ELEMENTS = 20
var values = array.new_float(NUMBER_OF_ELEMENTS, 0)
array.set(values, 0, high)
array.set(values, 1, bvps)
array.set(values, 2, eps)
array.set(values, 3, rps)
array.set(values, 4, fcf)
array.set(values, 5, ebit)
array.set(values, 6, ebitda)
array.set(values, 7, nmargin)
array.set(values, 8, gmargin)
array.set(values, 9, omargin)
array.set(values, 10, emargin)
array.set(values, 11, fmargin)
array.set(values, 12, roa)
array.set(values, 13, roe)
array.set(values, 14, roic)
array.set(values, 15, ldta)
array.set(values, 16, dta)
array.set(values, 17, dte)
array.set(values, 18, dtr)
array.set(values, 19, dteb)
var colors = array.new_color(NUMBER_OF_ELEMENTS)
if barstate.isfirst
for _i = 0 to NUMBER_OF_ELEMENTS - 1 by 1
array.set(colors, _i, f_random_color())
var drawdownRange = array.new_int(i_numberOfRanges * NUMBER_OF_ELEMENTS, 0)
var athArray = array.new_float(NUMBER_OF_ELEMENTS, 0.0)
var drawdownArray = array.new_float(NUMBER_OF_ELEMENTS, 0.0)
var percentileArray = array.new_float(NUMBER_OF_ELEMENTS, 0.0)
//################################### LOGIC AND CALCULATION ################################### //
f_calculate_percentile_drawdown(values, drawdownRange, athArray, drawdownArray, percentileArray, i) =>
_ath = array.get(athArray, i)
_value = array.get(values, i)
_ath := _value > _ath ? _value : _ath
_drawdown = math.round(math.abs(_ath - _value) / math.abs(_ath) * 100)
_startIndex = i * i_numberOfRanges
_endIndex = (i + 1) * i_numberOfRanges
_index = _startIndex + math.min(math.max(math.round(_drawdown / CELLRANGE), 0), i_numberOfRanges - 1)
array.set(drawdownRange, _index, array.get(drawdownRange, _index) + 1)
_before = array.slice(drawdownRange, _index, _endIndex)
_full = array.slice(drawdownRange, _startIndex, _endIndex)
_percentile = math.round(array.sum(_before) * 100 / array.sum(_full), 2)
array.set(athArray, i, _ath)
array.set(drawdownArray, i, _drawdown)
array.set(percentileArray, i, _percentile)
if i_reference == 'ath' or inDateRange
if i_displayHeader
var dateStart = str.tostring(year) + '/' + str.tostring(month) + '/' + str.tostring(dayofmonth)
dateEnd = str.tostring(year) + '/' + str.tostring(month) + '/' + str.tostring(dayofmonth)
DISPLAY = table.new(position=position.top_center, columns=2, rows=1, border_width=1)
table.cell(table_id=DISPLAY, column=0, row=0, text=syminfo.ticker, bgcolor=color.teal, text_color=color.white, text_size=i_text_size)
table.cell(table_id=DISPLAY, column=1, row=0, text=dateStart + ' to ' + dateEnd, bgcolor=color.teal, text_color=color.white, text_size=i_text_size)
for i = 0 to NUMBER_OF_ELEMENTS - 1 by 1
f_calculate_percentile_drawdown(values, drawdownRange, athArray, drawdownArray, percentileArray, i)
//################################### PLOT ################################### //
plot(i_percentile ? array.get(percentileArray, 0) : -array.get(drawdownArray, 0), color=array.get(colors, 0), title='Price', linewidth=2)
plot(i_percentile ? array.get(percentileArray, 1) : -array.get(drawdownArray, 1), color=array.get(colors, 1), title='Book Value', linewidth=0)
plot(i_percentile ? array.get(percentileArray, 2) : -array.get(drawdownArray, 2), color=array.get(colors, 2), title='Earnings', linewidth=0)
plot(i_percentile ? array.get(percentileArray, 3) : -array.get(drawdownArray, 3), color=array.get(colors, 3), title='Revenue', linewidth=0)
plot(i_percentile ? array.get(percentileArray, 4) : -array.get(drawdownArray, 4), color=array.get(colors, 4), title='Free Cashflow', linewidth=0)
plot(i_percentile ? array.get(percentileArray, 5) : -array.get(drawdownArray, 5), color=array.get(colors, 5), title='EBIT', linewidth=0)
plot(i_percentile ? array.get(percentileArray, 6) : -array.get(drawdownArray, 6), color=array.get(colors, 6), title='EBITDA', linewidth=0)
plot(i_percentile ? array.get(percentileArray, 7) : -array.get(drawdownArray, 7), color=array.get(colors, 7), title='Net Margin', linewidth=0)
plot(i_percentile ? array.get(percentileArray, 8) : -array.get(drawdownArray, 8), color=array.get(colors, 8), title='Gross Margin', linewidth=0)
plot(i_percentile ? array.get(percentileArray, 9) : -array.get(drawdownArray, 9), color=array.get(colors, 9), title='Operating Margin', linewidth=0)
plot(i_percentile ? array.get(percentileArray, 10) : -array.get(drawdownArray, 10), color=array.get(colors, 10), title='EBITDA Margin', linewidth=0)
plot(i_percentile ? array.get(percentileArray, 11) : -array.get(drawdownArray, 11), color=array.get(colors, 11), title='Freecashflow Margin', linewidth=0)
plot(i_percentile ? array.get(percentileArray, 12) : -array.get(drawdownArray, 12), color=array.get(colors, 12), title='ROA', linewidth=0)
plot(i_percentile ? array.get(percentileArray, 13) : -array.get(drawdownArray, 13), color=array.get(colors, 13), title='ROE', linewidth=0)
plot(i_percentile ? array.get(percentileArray, 14) : -array.get(drawdownArray, 14), color=array.get(colors, 14), title='ROIC', linewidth=0)
plot(i_percentile ? array.get(percentileArray, 15) : -array.get(drawdownArray, 15), color=array.get(colors, 15), title='Long Debt/Assets', linewidth=0)
plot(i_percentile ? array.get(percentileArray, 16) : -array.get(drawdownArray, 16), color=array.get(colors, 16), title='Debt/Assets', linewidth=0)
plot(i_percentile ? array.get(percentileArray, 17) : -array.get(drawdownArray, 17), color=array.get(colors, 17), title='Debt/Equity', linewidth=0)
plot(i_percentile ? array.get(percentileArray, 18) : -array.get(drawdownArray, 18), color=array.get(colors, 18), title='Debt/Revenue', linewidth=0)
plot(i_percentile ? array.get(percentileArray, 19) : -array.get(drawdownArray, 19), color=array.get(colors, 19), title='Debt/EBITDA', linewidth=0)
|
[pp] Fib Alerts | https://www.tradingview.com/script/REKhtze8-pp-Fib-Alerts/ | pAulseperformance | https://www.tradingview.com/u/pAulseperformance/ | 283 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © pAulseperformance
// import pAulseperformance/webhook3commas/1 as w3c
// Added Realtime Lock to Avoid label repainting.
// Cleaned some code.
// Added level offset feature
//@version=5
indicator("[pp] Fib Alerts", overlay=true)
C_15 = color.maroon
C_1 = color.blue
C_4 = color.aqua
C_D = color.green
C_W = color.yellow
C_M = color.red
GROUP1 = "Levels"
i_useLog = input.bool(true, "Use Log", group=GROUP1, tooltip="Compute Fib levels on Logarithmic Scale. TODO")
i_offset = input.int(3, "Levels Offset", group=GROUP1)
i_fibBottom = input.price(1, "Bottom", confirm=true, inline="i_fibBottom", group=GROUP1)
i_C_Bottom = input.color(C_1, "", inline="i_fibBottom", group=GROUP1)
i_fibTop = input.price(0., "Top", confirm=true, inline="i_fibTop", group=GROUP1)
i_C_Top = input.color(C_1, "", inline="i_fibTop", group=GROUP1)
i_270On = input.bool(true, "", inline="i_270", group=GROUP1)
i_270 = input.float(-0.270, "", inline="i_270", group=GROUP1)
i_C_270 = input.color(C_15, "", inline="i_270", group=GROUP1)
i_270Dir = input.string("Sell", "", options=["Buy", "Sell", "None"], inline="i_270", group=GROUP1)
i_113On = input.bool(true, "", inline="i_113", group=GROUP1)
i_113 = input.float(-0.113, "", inline="i_113", group=GROUP1)
i_C_113 = input.color(C_15, "", inline="i_113", group=GROUP1)
i_113Dir = input.string("Sell", "", options=["Buy", "Sell", "None"], inline="i_113", group=GROUP1)
i_382On = input.bool(true, "", inline="i_382", group=GROUP1)
i_382 = input.float(0.382, "", inline="i_382", group=GROUP1)
i_C_382 = input.color(C_15, "", inline="i_382", group=GROUP1)
i_382Dir = input.string("Buy", "", options=["Buy", "Sell", "None"], inline="i_382", group=GROUP1)
i_50On = input.bool(true, "", inline="i_50", group=GROUP1)
i_50 = input.float(0.5, "", inline="i_50", group=GROUP1)
i_C_50 = input.color(C_15, "", inline="i_50", group=GROUP1)
i_50Dir = input.string("None", "", options=["Buy", "Sell", "None"], inline="i_50", group=GROUP1)
i_618On = input.bool(true, "", inline="i_618", group=GROUP1)
i_618 = input.float(0.618, "", inline="i_618", group=GROUP1)
i_C_618 = input.color(C_15, "", inline="i_618", group=GROUP1)
i_618Dir = input.string("Buy", "", options=["Buy", "Sell", "None"], inline="i_618", group=GROUP1)
i_707On = input.bool(true, "", inline="i_707", group=GROUP1)
i_707 = input.float(0.707, "", inline="i_707", group=GROUP1)
i_C_707 = input.color(C_15, "", inline="i_707", group=GROUP1)
i_707Dir = input.string("Buy", "", options=["Buy", "Sell", "None"], inline="i_707", group=GROUP1)
i_886On = input.bool(true, "", inline="i_886", group=GROUP1)
i_886 = input.float(0.886, "", inline="i_886", group=GROUP1)
i_C_886 = input.color(C_15, "", inline="i_886", group=GROUP1)
i_886Dir = input.string("None", "", options=["Buy", "Sell", "None"], inline="i_886", group=GROUP1)
GROUP2 = "Custom Alerts"
i_useCustomAlrt = input.bool(true, "Use Custom Alerts", group=GROUP2)
i_alertBuyTxt = input.string("Buy Alert Message", "Buy Alert Message", group=GROUP2)
i_alertSellTxt = input.string("Sell Alert Message", "Sell Alert Message", group=GROUP2)
GROUP3 = "3 Commas Integration"
i_usew3cAlrt = input.bool(false, "Use 3 Commas Alerts", group=GROUP3)
i_3commasBotid = input.int(6467052, "Bot Id", group=GROUP3)
i_3commasToken = input.string("5ceb-asdfsadfsdf-f4fsdfsdfdsf-44fsdf", "Email Token", group=GROUP3)
f_lockRealtime(_data) =>
// Locks reatime triggers in place so no repainting.
varip bool _newBool = false
if barstate.isnew
_newBool := _data
if _data
_newBool := _data
_newBool
f_line(_x1, _y1, _x2, _y2, _clr=color.blue) =>
var _l = line.new(_x1,_y1,_x2,_y2,extend=extend.none, color=_clr)
line.set_xy2(_l, _x2, _y2)
f_label(_x, _y, _txt, _clr)=>
var _l = label.new(_x, _y, _txt, color=_clr, style=label.style_label_left, textcolor=#FFFFFF)
label.set_x(_l, _x)
f_drawLevel(_bottom, _top, _level, bool _show=true, _clr=color.blue, _dir="None") =>
_sign = math.sign(_top - _bottom)
_diff = math.abs(_top - _bottom)
// _price = i_useLog ? _top * math.pow(_bottom/_top, _level) : _top - (_diff * _level*_sign)
_price = _top - (_diff * _level*_sign)
// Track price crosses, so we don't send the same alerts when price sits around fib level.
var _a_violations = array.new_float(na)
if _show
f_line(bar_index[1], _price, bar_index+i_offset, _price, _clr)
_text = str.tostring(_level) + (_dir == "Buy" ? ' ⬆':_dir == "Sell"? ' ⬇':"")
f_label(bar_index+i_offset, _price, _text, _clr)
_buyTrigger = ta.cross(close, _price) and not array.includes(_a_violations,_price) and _dir == "Buy"
if f_lockRealtime(_buyTrigger)
// Push to array so we don't trigger this alert again.
array.push(_a_violations,_price)
label.new(bar_index, _price, str.format("{0} @ {1}", _dir, _text), color=color.green,style=label.style_label_up, textcolor=color.white)
if i_useCustomAlrt
alert(i_alertBuyTxt)
// if i_usew3cAlrt
// alert(w3c.f_dealStart(i_3commasBotid, i_3commasToken))
_sellTrigger = ta.cross(close, _price) and not array.includes(_a_violations,_price) and _dir == "Sell"
if f_lockRealtime(_sellTrigger)
// Push to array so we don't trigger this alert again.
array.push(_a_violations,_price)
label.new(bar_index, _price, str.format("{0} @ {1}", _dir, _text), color=color.red, textcolor=color.white)
if i_useCustomAlrt
alert(i_alertSellTxt)
// if i_usew3cAlrt
// alert(w3c.f_closeMarket(i_3commasBotid, i_3commasToken))
f_drawFib(float _bottom, float _top) =>
if barstate.isrealtime or barstate.islastconfirmedhistory
f_drawLevel(_bottom, _top, i_270, i_270On, i_C_270, i_270Dir)
f_drawLevel(_bottom, _top, i_113, i_113On, i_C_113, i_113Dir)
f_drawLevel(_bottom, _top, 1, true, i_C_Bottom)
f_drawLevel(_bottom, _top, i_382, i_382On, i_C_382, i_382Dir)
f_drawLevel(_bottom, _top, i_50, i_50On, i_C_50, i_50Dir)
f_drawLevel(_bottom, _top, i_618, i_618On, i_C_618, i_618Dir)
f_drawLevel(_bottom, _top, i_707, i_707On, i_C_707, i_707Dir)
f_drawLevel(_bottom, _top, i_886, i_886On, i_C_886, i_886Dir)
f_drawLevel(_bottom, _top, 0, true, i_C_Top)
f_drawFib(i_fibBottom, i_fibTop)
|
Zigzag SAR | https://www.tradingview.com/script/fZ9VVoRT-Zigzag-SAR/ | Troptrap | https://www.tradingview.com/u/Troptrap/ | 80 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © mildSnail31034
//@version=4
study("Zigzag SAR",overlay=true)
showsar = input(title="Show Parabolic SAR", type=input.bool, defval=true)
start = input(title="SAR Start", type=input.float, step=0.001,defval=0.02)
increment = input(title="SAR increment", type=input.float, step=0.001,defval=0.02)
maxsar = input(title="SAR max", type=input.float, step=0.01, defval=0.2)
psar = sar(start,increment, maxsar)
dir = psar<close ? true : false
up = dir and dir[1]==false
dn = dir==false and dir[1]
sarcolor = dir ? color.green : color.red
lineupcolor = input(title="Zigzag up color", defval=color.green)
linedncolor = input(title="Zigzag down color", defval=color.red)
linewidth = input(title="Zigzag line width",type=input.integer,minval=1,maxval=4,defval=2)
plotsar = plot(showsar ? psar : na, title= "PSAR", style=plot.style_circles, color=sarcolor, linewidth=2 )
var line zzup = na
var line zzdn = na
var bt1 = 0
var bt2 = 0
var float hi = na
var float lo = na
if up
hi :=high
bt1 := time
zzup := line.new(bt2,lo,bt1,hi,color=lineupcolor, width =linewidth,xloc=xloc.bar_time)
if dn
lo :=low
bt2 := time
zzdn := line.new(bt1,hi,bt2,lo,color=linedncolor, width=linewidth,xloc=xloc.bar_time)
if (dir and high > hi)
hi :=high
bt1 := time
line.set_xy2(zzup,bt1,hi)
if (dir==false and low < lo)
lo := low
bt2 := time
line.set_xy2(zzdn,bt2,lo)
|
ATR-Adjusted RSI | https://www.tradingview.com/script/Und6fX4A-ATR-Adjusted-RSI/ | Sofien-Kaabar | https://www.tradingview.com/u/Sofien-Kaabar/ | 97 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Sofien-Kaabar
//@version=5
indicator("ATR-Adjusted RSI")
rsi = ta.rsi(close, 14)
atr = ta.atr(14)
rsi_atr = rsi / atr
rsi_atr_indicator = ta.rsi(rsi_atr, 14)
plot(rsi_atr_indicator, color = (rsi_atr_indicator > rsi_atr_indicator[1]) ? color.green : color.red)
hline(70)
hline(30)
|
T3 + BB | https://www.tradingview.com/script/vGA4j140/ | JCMR76 | https://www.tradingview.com/u/JCMR76/ | 54 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © JCMR76
//@version=4
study("T3 + BB + PIVOT", overlay=true)
// TRES EMAS - THREE EMA´s
periodo1 = input(8, title="Periodo 1, Length 1=", step =1, minval=1, maxval=300)
periodo2 = input(20, title="Periodo 2, Length 2=", step =1, minval=1, maxval=300)
periodo3 = input(200, title="Periodo 3, Length 3=", step =1, minval=1, maxval=1000)
plot(ema(close,periodo1), color=color.gray, linewidth=1)
plot(ema(close,periodo2), color=color.green, linewidth=1)
plot(ema(close,periodo3), color=color.purple, linewidth=3)
//BANDA BOLLINGER - BANDS BOLLINGER
longitudbb = input(20,title = "longitudBB, LenghtBB=", type = input.integer, step = 1, minval=1, maxval=50)
multbb = input(2.0, title = "Multiplicadorbb, EstDesv = ", type= input.float, step = 0.2, minval=0.2, maxval=20)
fuente = input(close, title="fuente", type=input.source)
[mm,banda_sup, banda_inf] = bb(fuente, longitudbb,multbb)
ps=plot(banda_sup, color=color.new(color.gray, 90))
pi=plot(banda_inf, color=color.new(color.gray, 90))
fill(ps,pi,color=color.new(color.gray,80))
//PIVOT - PIVOTE
dist = input(12, title ="distancia para el pivote/ distance to pivot ", type = input.integer, step = 1)
pl = pivotlow(low, dist, dist)
if not na(pl)
label.new(bar_index[dist], pl, text="Buy", style=label.style_label_up, textcolor=color.yellow, size=size.small, color=color.green)
ph = pivothigh(high, dist, dist)
if not na(ph)
label.new(bar_index[dist], ph, text="Sell",style=label.style_label_down, textcolor=color.yellow, size=size.small, color=color.red)
//PIVOT - PIVOTE
|
Glassnode SOPR for BTC | https://www.tradingview.com/script/xg898Zmb-glassnode-sopr-for-btc/ | ROBO_Trading | https://www.tradingview.com/u/ROBO_Trading/ | 508 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ROBO_Trading
//@version=4
study(title = "Glassnode SOPR", shorttitle="SOPR", overlay = false)
//Settings
coin = input(defval = "Bitcoin", options = ["Bitcoin", "Ethereum", "Litecoin"], title = "Cryptocurrency")
len = input(10, title = "SMA")
percent = input(4.0)
bg = input(true, title = "Need background")
//SOPR
symbol = coin == "Ethereum" ? "XTVCETH_SOPR" : coin == "Litecoin" ? "XTVCLTC_SOPR" : "XTVCBTC_SOPR"
sopr = security(symbol, "D", sma(close, len))
//Levels
uplevel = 1 + (percent / 100)
dnlevel = 1 - (percent / 100)
//Background
bgcol = bg == false ? na : sopr > uplevel ? color.red : sopr < dnlevel ? color.lime : na
bgcolor(bgcol, transp = 20)
//Lines
plot(sopr)
plot(uplevel, color = color.red)
plot(1.00, color = color.black)
plot(dnlevel, color = color.lime) |
Hx 9 Moving Averages | https://www.tradingview.com/script/pVL7qdQ6-Hx-9-Moving-Averages/ | HDrbx | https://www.tradingview.com/u/HDrbx/ | 100 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © HDrbx
//@version=5
indicator(title='Hx 9 Moving Averages', shorttitle='Hx 9 MA', overlay=true, timeframe='')
// (c) - HDrbx 2021
ma1Show = input.bool(title='', defval=true, inline='1')
ma1Type = input.string(title='MA1', defval='Hull', inline='1', options=['Sma', 'Ema', 'VWma', 'Wma', 'Rma', 'Hull', 'Smma'])
ma1Length = input.int(title='', defval=9, inline='1')
ma1Source = input.source(title='', defval=close, inline='1')
ma1Color = input.color(title='', defval=color.gray, inline='1')
ma2Show = input.bool(title='', defval=true, inline='2')
ma2Type = input.string(title='MA2', defval='Ema', inline='2', options=['Sma', 'Ema', 'VWma', 'Wma', 'Rma', 'Hull', 'Smma'])
ma2Length = input.int(title='', defval=10, inline='2')
ma2Source = input.source(title='', defval=close, inline='2')
ma2Color = input.color(title='', defval=color.red, inline='2')
ma3Show = input.bool(title='', defval=true, inline='3')
ma3Type = input.string(title='MA3', defval='Sma', inline='3', options=['Sma', 'Ema', 'VWma', 'Wma', 'Rma', 'Hull', 'Smma'])
ma3Length = input.int(title='', defval=10, inline='3')
ma3Source = input.source(title='', defval=close, inline='3')
ma3Color = input.color(title='', defval=color.orange, inline='3')
ma4Show = input.bool(title='', defval=true, inline='4')
ma4Type = input.string(title='MA4', defval='Ema', inline='4', options=['Sma', 'Ema', 'VWma', 'Wma', 'Rma', 'Hull', 'Smma'])
ma4Length = input.int(title='', defval=20, inline='4')
ma4Source = input.source(title='', defval=close, inline='4')
ma4Color = input.color(title='', defval=color.yellow, inline='4')
ma5Show = input.bool(title='', defval=true, inline='5')
ma5Type = input.string(title='MA5', defval='Ema', inline='5', options=['Sma', 'Ema', 'VWma', 'Wma', 'Rma', 'Hull', 'Smma'])
ma5Length = input.int(title='', defval=50, inline='5')
ma5Source = input.source(title='', defval=close, inline='5')
ma5Color = input.color(title='', defval=color.lime, inline='5')
ma6Show = input.bool(title='', defval=true, inline='6')
ma6Type = input.string(title='MA6', defval='Sma', inline='6', options=['Sma', 'Ema', 'VWma', 'Wma', 'Rma', 'Hull', 'Smma'])
ma6Length = input.int(title='', defval=50, inline='6')
ma6Source = input.source(title='', defval=close, inline='6')
ma6Color = input.color(title='', defval=color.green, inline='6')
ma7Show = input.bool(title='', defval=true, inline='7')
ma7Type = input.string(title='MA7', defval='Sma', inline='7', options=['Sma', 'Ema', 'VWma', 'Wma', 'Rma', 'Hull', 'Smma'])
ma7Length = input.int(title='', defval=100, inline='7')
ma7Source = input.source(title='', defval=close, inline='7')
ma7Color = input.color(title='', defval=color.blue, inline='7')
ma8Show = input.bool(title='', defval=true, inline='8')
ma8Type = input.string(title='MA8', defval='Sma', inline='8', options=['Sma', 'Ema', 'VWma', 'Wma', 'Rma', 'Hull', 'Smma'])
ma8Length = input.int(title='', defval=200, inline='8')
ma8Source = input.source(title='', defval=close, inline='8')
ma8Color = input.color(title='', defval=color.navy, inline='8')
ma9Show = input.bool(title='', defval=true, inline='9')
ma9Type = input.string(title='MA9', defval='VWma', inline='9', options=['Sma', 'Ema', 'VWma', 'Wma', 'Rma', 'Hull', 'Smma'])
ma9Length = input.int(title='', defval=200, inline='9')
ma9Source = input.source(title='', defval=close, inline='9')
ma9Color = input.color(title='', defval=color.purple, inline='9')
var grpLw = 'Line Width' // LINE WIDTH SECTION
hullLw = input.int(title=' hull', defval=2, minval=1, inline='0', group=grpLw)
smaLw = input.int(title='sma', defval=1, minval=1, inline='0', group=grpLw)
emaLw = input.int(title=' ema', defval=2, minval=1, inline='0', group=grpLw)
vwmaLw = input.int(title='vWma', defval=2, minval=1, inline='0', group=grpLw)
rmaLw = input.int(title='rma', defval=2, minval=1, inline='0', group=grpLw)
wmaLw = input.int(title='wma', defval=2, minval=1, inline='0', group=grpLw)
smmaLw = input.int(title='Smma', defval=1, minval=1, inline='0', group=grpLw)
smma(_src, _length) => //{
float _smma = 0.0
_smma := na(_smma[1]) ? ta.sma(_src, _length) : (_smma[1] * (_length - 1) + _src) / _length
_smma
//}
maSelect(_src, _length, _type) => //{
float _ma = _type == 'Sma' ? ta.sma(_src, _length) : _type == 'Ema' ? ta.ema(_src, _length) : _type == 'VWma' ? ta.vwma(_src, _length) : _type == 'Hull' ?
ta.hma(_src, _length) : _type == 'Wma' ? ta.wma(_src, _length) : _type == 'Rma' ? ta.rma(_src, _length) : _type == 'Smma' ? smma(_src, _length) : na
_ma
//}
lwSelect(_type) => //{
int _lineWidth = _type == 'Sma' ? smaLw : _type == 'Ema' ? emaLw : _type == 'VWma' ? vwmaLw : _type == 'Hull' ? hullLw : _type == 'Wma' ? wmaLw : _type == 'Rma' ? rmaLw : _type == 'Smma' ? smmaLw : 1
_lineWidth
//}
ma1 = maSelect(ma1Source, ma1Length, ma1Type)
ma2 = maSelect(ma2Source, ma2Length, ma2Type)
ma3 = maSelect(ma3Source, ma3Length, ma3Type)
ma4 = maSelect(ma4Source, ma4Length, ma4Type)
ma5 = maSelect(ma5Source, ma5Length, ma5Type)
ma6 = maSelect(ma6Source, ma6Length, ma6Type)
ma7 = maSelect(ma7Source, ma7Length, ma7Type)
ma8 = maSelect(ma8Source, ma8Length, ma8Type)
ma9 = maSelect(ma9Source, ma9Length, ma9Type)
plot(ma1Show ? ma1 : na, title='MA 1', color=ma1Color, linewidth=lwSelect(ma1Type))
plot(ma2Show ? ma2 : na, title='MA 2', color=ma2Color, linewidth=lwSelect(ma2Type))
plot(ma3Show ? ma3 : na, title='MA 3', color=ma3Color, linewidth=lwSelect(ma3Type))
plot(ma4Show ? ma4 : na, title='MA 4', color=ma4Color, linewidth=lwSelect(ma4Type))
plot(ma5Show ? ma5 : na, title='MA 5', color=ma5Color, linewidth=lwSelect(ma5Type))
plot(ma6Show ? ma6 : na, title='MA 6', color=ma6Color, linewidth=lwSelect(ma6Type))
plot(ma7Show ? ma7 : na, title='MA 7', color=ma7Color, linewidth=lwSelect(ma7Type))
plot(ma8Show ? ma8 : na, title='MA 8', color=ma8Color, linewidth=lwSelect(ma8Type))
plot(ma9Show ? ma9 : na, title='MA 9', color=ma9Color, linewidth=lwSelect(ma9Type))
// Thank You for reading my code ... hope you enjoyed or learned something :)
|
Elder's Force Index Color Bar | https://www.tradingview.com/script/Qrykk4D3/ | salted-fish | https://www.tradingview.com/u/salted-fish/ | 69 | study | 4 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © salted-fish
//@version=4
study(title="Elder's Force Index Color Bar", shorttitle="EFI color bar", overlay=true)
length_EFI = input(2, minval=1)
Length_EMA = input(6, "Length_EMA")
usevolume = input(true)
efi_short = usevolume ? ema(change(close) * volume, length_EFI) : ema(change(close), length_EFI)
ema = ema(efi_short, Length_EMA)
e_bulls = (efi_short > 0) and (ema > 0)
e_upsig = (efi_short < 0) and (ema > 0)
e_bears = (efi_short < 0) and (ema < 0)
e_downsig = (efi_short > 0) and (ema < 0)
e_color = e_bulls ? color.green : e_bears ? color.red : e_upsig ? #ffff03: #0011ff
barcolor(e_color) |
Slope of KAMA | https://www.tradingview.com/script/stJA6M5R-Slope-of-KAMA/ | Aanyka | https://www.tradingview.com/u/Aanyka/ | 39 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Aanyka
//@version=5
////////////////////////////////////////////////////////////
indicator(title='Slope of KAMA', shorttitle='Slope of KAMA', format=format.price, precision=2, timeframe='')
Length = input.int(21, minval=1)
xPrice = close
xvnoise = math.abs(xPrice - xPrice[1])
nAMA = 0.0
nfastend = 0.666
nslowend = 0.0645
nsignal = math.abs(xPrice - xPrice[Length])
nnoise = math.sum(xvnoise, Length)
nefratio = nnoise != 0 ? nsignal / nnoise : 0
nsmooth = math.pow(nefratio * (nfastend - nslowend) + nslowend, 2)
nAMA := nz(nAMA[1]) + nsmooth * (xPrice - nz(nAMA[1]))
nAMA2 = nAMA[1] - nAMA[2]
plot(nAMA2, color=color.new(color.blue, 0), title='Slope of KAMA', style=plot.style_columns)
|
Total Volume | https://www.tradingview.com/script/kX03UEJD-Total-Volume/ | pascorp | https://www.tradingview.com/u/pascorp/ | 80 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © pascorp
//@version=5
indicator("Total Volume")
sym1 = input.symbol(defval='BINANCE:BTCUSDT', title="Symbol 1")
sym2 = input.symbol(defval='BINANCE:BTCUSDT', title="Symbol 2")
sym3 = input.symbol(defval='BINANCE:BTCUSDT', title="Symbol 3")
sym4 = input.symbol(defval='BINANCE:BTCUSDT', title="Symbol 4")
sym5 = input.symbol(defval='BINANCE:BTCUSDT', title="Symbol 5")
sym6 = input.symbol(defval='BINANCE:BTCUSDT', title="Symbol 6")
sym7 = input.symbol(defval='BINANCE:BTCUSDT', title="Symbol 7")
sym8 = input.symbol(defval='BINANCE:BTCUSDT', title="Symbol 8")
sym9 = input.symbol(defval='BINANCE:BTCUSDT', title="Symbol 9")
sym10 = input.symbol(defval='BINANCE:BTCUSDT', title="Symbol 10")
n = input.int(defval=5, maxval=10, minval=1, title='Number exchange')
mode = input.string(defval='Sum', title='Type of algo', options=['Sum', 'Avg', 'Highest Volume-Weighted', 'Max'])
clrMode = input.string(defval='Highest Volume Exchange', title='Color histogram by', options=['Highest Volume Exchange', 'Classic', 'No Color'])
plotBase = input(true, title='Plot volume of the current exchange/broker')
vol1 = request.security(sym1, timeframe.period, volume)
vol2 = request.security(sym2, timeframe.period, volume)
vol3 = request.security(sym3, timeframe.period, volume)
vol4 = request.security(sym4, timeframe.period, volume)
vol5 = request.security(sym5, timeframe.period, volume)
vol6 = request.security(sym6, timeframe.period, volume)
vol7 = request.security(sym7, timeframe.period, volume)
vol8 = request.security(sym8, timeframe.period, volume)
vol9 = request.security(sym9, timeframe.period, volume)
vol10 = request.security(sym10, timeframe.period, volume)
volumeSum = switch n
1 => vol1
2 => vol1 + vol2
3 => vol1 + vol2 + vol3
4 => vol1 + vol2 + vol3 + vol4
5 => vol1 + vol2 + vol3 + vol4 + vol5
6 => vol1 + vol2 + vol3 + vol4 + vol5 + vol6
7 => vol1 + vol2 + vol3 + vol4 + vol5 + vol6 + vol7
8 => vol1 + vol2 + vol3 + vol4 + vol5 + vol6 + vol7 + vol8
9 => vol1 + vol2 + vol3 + vol4 + vol5 + vol6 + vol7 + vol8 + vol9
10=> vol1 + vol2 + vol3 + vol4 + vol5 + vol6 + vol7 + vol8 + vol9 + vol10
maxVol = array.new_float(0,0)
if n>=1
array.push(maxVol, vol1)
if n>=2
array.push(maxVol, vol2)
if n>=3
array.push(maxVol, vol3)
if n>=4
array.push(maxVol, vol4)
if n>=5
array.push(maxVol, vol5)
if n>=6
array.push(maxVol, vol6)
if n>=7
array.push(maxVol, vol7)
if n>=8
array.push(maxVol, vol8)
if n>=9
array.push(maxVol, vol9)
if n>=10
array.push(maxVol, vol10)
totVol = switch mode
'Sum' => volumeSum
'Avg' => volumeSum/n
'Highest Volume-Weighted' => (volumeSum + array.max(maxVol)) /(n+1)
'Max' => array.max(maxVol)
col1 = color.white
col2 = color.red
col3 = color.green
col4 = color.yellow
col5 = color.fuchsia
col6 = color.purple
col7 = color.aqua
col8 = color.lime
col9 = color.orange
col10 = color.olive
colorHistExchange = switch array.max(maxVol)
vol1 => col1
vol2 => col2
vol3 => col3
vol4 => col4
vol5 => col5
vol6 => col6
vol7 => col7
vol8 => col8
vol9 => col9
vol10=> col10
clrHist = switch clrMode
'Highest Volume Exchange' => colorHistExchange
'Classic' => close>open? color.green: color.red
'No Color' => color.blue
plot(plotBase? volume: na , style=plot.style_histogram, color=color.new(color.orange,50), linewidth=4)
plot(totVol, style=plot.style_histogram, color=clrHist, linewidth=2)
// ——————————————————————————————————————————————————————————————————
// >>>>>>>>>>>>>>>>>>>>>>>>> Table <<<<<<<<<<<<<<<<<<<<<<<<<<<<
// ——————————————————————————————————————————————————————————————————
showTab = input(true, title='Helping table', group='Table', inline='0')
tabLoc = input.string('Bottom Left', 'Location', options=['Top Right', 'Bottom Right', 'Top Left', 'Bottom Left'], group='Table', inline='1')
txtSize = input.string('Tiny', 'Size', options=['Tiny', 'Small', 'Normal', 'Large'], group='Table', inline='1')
txtCol = input.color(color.gray, 'Color', group='Table', inline='1')
var tablePosition = switch tabLoc
'Top Left' => position.top_left
'Bottom Left' => position.bottom_left
'Top Right' => position.top_right
'Bottom Right' => position.bottom_right
var tableTxtSize = switch txtSize
'Tiny' => size.tiny
'Small' => size.small
'Normal' => size.normal
'Large' => size.large
if showTab
new_table = table.new(tablePosition, 10, 2, border_color=txtCol, border_width=1, frame_color=txtCol, frame_width=1)
if barstate.islast
table.cell(new_table, 0, 0, sym1, text_color=color.black, text_size=tableTxtSize, bgcolor=col1)
table.cell(new_table, 0, 1, str.tostring(vol1), text_color=txtCol, text_size=tableTxtSize)
if n>=2
table.cell(new_table, 1, 0, sym2, text_color=color.black, text_size=tableTxtSize, bgcolor=col2)
table.cell(new_table, 1, 1, str.tostring(vol2), text_color=txtCol, text_size=tableTxtSize)
if n>=3
table.cell(new_table, 2, 0, sym3, text_color=color.black, text_size=tableTxtSize, bgcolor=col3)
table.cell(new_table, 2, 1, str.tostring(vol3), text_color=txtCol, text_size=tableTxtSize)
if n>=4
table.cell(new_table, 3, 0, sym4, text_color=color.black, text_size=tableTxtSize, bgcolor=col4)
table.cell(new_table, 3, 1, str.tostring(vol4), text_color=txtCol, text_size=tableTxtSize)
if n>=5
table.cell(new_table, 4, 0, sym5, text_color=color.black, text_size=tableTxtSize, bgcolor=col5)
table.cell(new_table, 4, 1, str.tostring(vol5), text_color=txtCol, text_size=tableTxtSize)
if n>=6
table.cell(new_table, 5, 0, sym6, text_color=color.black, text_size=tableTxtSize, bgcolor=col6)
table.cell(new_table, 5, 1, str.tostring(vol6), text_color=txtCol, text_size=tableTxtSize)
if n>=7
table.cell(new_table, 6, 0, sym7, text_color=color.black, text_size=tableTxtSize, bgcolor=col7)
table.cell(new_table, 6, 1, str.tostring(vol7), text_color=txtCol, text_size=tableTxtSize)
if n>=8
table.cell(new_table, 7, 0, sym8, text_color=color.black, text_size=tableTxtSize, bgcolor=col8)
table.cell(new_table, 7, 1, str.tostring(vol8), text_color=txtCol, text_size=tableTxtSize)
if n>=9
table.cell(new_table, 8, 0, sym9, text_color=color.black, text_size=tableTxtSize, bgcolor=col9)
table.cell(new_table, 8, 1, str.tostring(vol9), text_color=txtCol, text_size=tableTxtSize)
if n>=10
table.cell(new_table, 9, 0, sym10, text_color=color.black, text_size=tableTxtSize, bgcolor=col10)
table.cell(new_table, 9, 1, str.tostring(vol10), text_color=txtCol, text_size=tableTxtSize)
|
Drowdown Market | https://www.tradingview.com/script/90XpoP4T-Drowdown-Market/ | tmr0 | https://www.tradingview.com/u/tmr0/ | 38 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tmr0
//@version=5
indicator("tDDM", overlay=true)
perc1 = input.float(0.25, step=.05)
perc2 = input.float(0.5, step=.05)
perc3 = input.float(0.75, step=.05)
max = .0
max := max[1] > high ? max[1] : high
chdd1 = max * (1 - perc1)
chdd2 = max * (1 - perc2)
chdd3 = max * (1 - perc3)
ch0 = plot(high, display=display.none)
ch1 = plot(chdd1, display=display.none)
ch2 = plot(chdd2, display=display.none)
ch3 = plot(chdd3, display=display.none)
fill(ch0, ch1, color=high>chdd1?#00000000:color.red, transp=90)
fill(ch0, ch2, color=high>chdd2?#00000000:color.red, transp=90)
fill(ch0, ch3, color=high>chdd3?#00000000:color.red, transp=90)
|
Swing Comparator | https://www.tradingview.com/script/uv1WiXKa-Swing-Comparator/ | jarzido | https://www.tradingview.com/u/jarzido/ | 95 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// Author: jarzido
//@version=5
indicator("Swing Comparator")
cur = input.symbol(string("COINBASE:BTCUSD"), "Symbol 1")
alt = input.symbol("COINBASE:ETHUSD", "Symbol 2")
mal = input(title="Moving Average Length", defval=5)
eMal = input(title = "Extended MA Length", defval = 42)
stdMa = input(title="Stand Deviation MA Length", defval = 21)
ccInput = input(title="Correlation Coefficient Input", defval =ohlc4)
ccPeriod = input.int(title="Correlation Coefficient Period", defval =21, minval=2)
ccmm = input.float(title="Correlation Coefficient Min/max +/-", defval = 1, minval = 0)
clip = input(title="Clipping +/-", defval = 10)
cSrc = request.security(cur, timeframe.period, ccInput)
aSrc = request.security(alt, timeframe.period, ccInput)
//get currency pair vals. Just a helper method because I'm not too familiar with pine script
clophl(pair) =>
cl = request.security(pair, timeframe.period, close)
op = request.security(pair, timeframe.period, open)
h = request.security(pair, timeframe.period, high)
l = request.security(pair, timeframe.period, low)
[cl, op, h, l]
//spread
sp(pair, lag=0) =>
[cl, op, h, l] = clophl(pair)
clop = 100 * math.abs(op - cl) / op
hl = 100 * h/l
[clop, hl]
//normalized standard deviation
nStdBar(pair) =>
[cl, op, h, l] = clophl(pair)
float[] vals = array.from(cl[0], op[0], h[0], l[0])
array.stdev(vals)/array.avg(vals)
fun(ser, len) =>
val = ta.ema(ser, len) * 0.15
if val < -clip
-clip
else if val > clip
clip
else
val
[apCur, hlCur]= sp(cur)
[apAlt, hlAlt] = sp(alt)
stdev = nStdBar(cur) - nStdBar(alt)
opcl = fun(apCur - apAlt, mal)
rhl = fun(hlCur - hlAlt, mal)
ehlma = fun(hlCur - hlAlt, eMal)
sdevMa = fun(stdev, stdMa) * 200
c = ta.correlation(cSrc, aSrc, ccPeriod) * ccmm
plot(opcl, title="Difference OP-CL", color=#9e9121, style=plot.style_area)
plot(rhl, title="Ratio H/L", color=color.new(color.purple, 50), style=plot.style_area)
plot(ehlma, title="Extended H-L MA", color=#1fff3b, linewidth=2, trackprice=true)
plot(sdevMa, title="Standard Deviation", color=color.white, linewidth=2, trackprice=true)
plot(c, title="Correlation Coefficient", color=c > 0.975 * ccmm ? #1dff00 : c < -0.975 * ccmm? color.red : color.blue, linewidth=2, trackprice=false)
hline(0, title="Zero")
hline(1 * ccmm, title="CC Max Line", color=color.gray, linestyle=hline.style_dashed)
hline(-1 * ccmm, title="CC Min Line", color=color.gray, linestyle=hline.style_dashed) |
Secondary Chart with OverSized Candles | https://www.tradingview.com/script/7HuB9v0T-Secondary-Chart-with-OverSized-Candles/ | Protervus | https://www.tradingview.com/u/Protervus/ | 86 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Protervus
// _____ ______ _____ _______ _______ ______ _ _ _ _ _______
// |_____] |_____/ | | | |______ |_____/ \ / | | |______
// | | \_ |_____| | |______ | \_ \/ |_____| ______|
//
//@version=5
indicator("Secondary chart with OverSized Candles", shorttitle = "Chart and OV candles", overlay = true, scale = scale.left)
// Asset inputs
asset = input.symbol(title = "Source", defval="FTX:BTCUSD", group = "Sources", inline = "source")
posCandleColor = input.color(defval = color.new(#9598a1, 50), title = "Candles Color", group = "Sources", inline = "ccolors")
negCandlesColor = input.color(defval = color.new(#434651, 50), title = "", group = "Sources", inline = "ccolors")
showPriceline = input.bool(true, title = "Show Price Line", group = "Sources")
// Over-sized candles inputs
oversizeThreshold = input.float(5.0, minval=1.5, step=0.1, title="ATR Ratio Threshold", group = "Oversized Candles", inline = "oversize") // Size Ratio to ATR Threshold
atrLen = input.int(60, minval=1, title="ATR Length", group = "Oversized Candles", inline = "oversize")
posOvzColor = input.color(defval = color.new(color.green, 10), title = "Oversized Candles Color", group = "Oversized Candles", inline = "ovcolor")
negOvzColor = input.color(defval = color.new(color.red, 10), title = "", group = "Oversized Candles", inline = "ovcolor")
// Retrieve data for asset
CLOSE = request.security(asset, timeframe.period, close)
OPEN = request.security(asset, timeframe.period, open)
HIGH = request.security(asset, timeframe.period, high)
LOW = request.security(asset, timeframe.period, low)
ATR = request.security(asset, timeframe.period, ta.atr(atrLen))
cRange = request.security(asset, timeframe.period, ta.tr)
// Calculate ATR range
cRange := cRange <= 0 ? CLOSE * 0.00001 : cRange
ratio = cRange / ATR
// Condition for Over-Sized Candles
oversizeBull = OPEN < CLOSE and ratio >= oversizeThreshold
oversizeBear = OPEN > CLOSE and ratio >= oversizeThreshold
// Plot Labels
symbol = "⚡"
oversizeBull_label = oversizeBull ? label.new(
bar_index,
y = LOW,
text = symbol + "\n" + "Oversized\n" + str.tostring(ratio, "#.##"),
color = color.new(color.black, 75),
textcolor = posOvzColor,
style = label.style_label_upper_left,
yloc = yloc.price,
size = size.normal) : na
oversizeBear_label = oversizeBear ? label.new(
bar_index,
y = HIGH,
text = "Oversized\n" + str.tostring(ratio, "#.##") + "\n" + symbol,
color = color.new(color.black, 75),
textcolor = negOvzColor,
style = label.style_label_lower_left,
yloc = yloc.price,
size = size.normal) : na
// Print Candles w/ colors
candleColor = CLOSE > OPEN ? posCandleColor : negCandlesColor
if oversizeBull
candleColor := posOvzColor
if oversizeBear
candleColor := negOvzColor
plotcandle(OPEN, HIGH, LOW, CLOSE, title = "Candles", color = candleColor, wickcolor=candleColor, bordercolor=candleColor)
// Create Price Line
var line priceLine = na
if barstate.islast and showPriceline
line.delete(priceLine)
priceLine := line.new(bar_index, CLOSE, bar_index + 5, CLOSE, color = candleColor, extend=extend.both, style = line.style_dotted, width=1)
priceline_label = barstate.islast and showPriceline ? label.new(
bar_index + 10,
y = CLOSE,
text = str.tostring(asset) + " " + str.tostring(CLOSE, "#.##"),
color = color.new(color.black, 75),
textcolor = CLOSE > OPEN ? color.green : color.red,
style = label.style_label_left,
yloc = yloc.price,
size = size.normal) : na
label.delete(barstate.islast and showPriceline ? priceline_label[1] : na)
// Send Alerts
alertcondition(oversizeBull, message = "Bullish Oversized Candle")
alertcondition(oversizeBear, message = "Bearish Oversized Candle") |
Heikin ashi Doji | https://www.tradingview.com/script/fVjMM2xo-Heikin-ashi-Doji/ | K_M_M | https://www.tradingview.com/u/K_M_M/ | 91 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © K_M_M
//@version=5
indicator("Heikin ashi Doji", shorttitle = "HA_Doji", overlay=true)
C_Len = 14 // ta.ema depth for bodyAvg
C_ShadowPercent = 5.0 // size of shadows
C_ShadowEqualsPercent = 100.0
C_DojiBodyPercent = 5.0
C_Factor = 2.0 // shows the number of times the shadow dominates the candlestick body
//Heikin Ashi
ha_t = ticker.heikinashi(syminfo.tickerid)
ha_open = request.security(ha_t, timeframe.period, open)
ha_high = request.security(ha_t, timeframe.period, high)
ha_low = request.security(ha_t, timeframe.period, low)
ha_close = request.security(ha_t, timeframe.period, close)
C_BodyHi = math.max(ha_close, ha_open)
C_BodyLo = math.min(ha_close, ha_open)
C_Body = C_BodyHi - C_BodyLo
C_BodyAvg = ta.ema(C_Body, C_Len)
C_SmallBody = C_Body < C_BodyAvg
C_LongBody = C_Body > C_BodyAvg
C_UpShadow = ha_high - C_BodyHi
C_DnShadow = C_BodyLo - ha_low
C_HasUpShadow = C_UpShadow > C_ShadowPercent / 100 * C_Body
C_HasDnShadow = C_DnShadow > C_ShadowPercent / 100 * C_Body
C_WhiteBody = ha_open < ha_close
C_BlackBody = ha_open > ha_close
C_Range = ha_high-ha_low
C_IsInsideBar = C_BodyHi[1] > C_BodyHi and C_BodyLo[1] < C_BodyLo
C_BodyMiddle = C_Body / 2 + C_BodyLo
C_ShadowEquals = C_UpShadow == C_DnShadow or (math.abs(C_UpShadow - C_DnShadow) / C_DnShadow * 100) < C_ShadowEqualsPercent and (math.abs(C_DnShadow - C_UpShadow) / C_UpShadow * 100) < C_ShadowEqualsPercent
C_IsDojiBody = C_Range > 0 and C_Body <= C_Range * C_DojiBodyPercent / 100
C_Doji = C_IsDojiBody and C_ShadowEquals
patternLabelPosLow = ha_low - (ta.atr(30) * 0.6)
patternLabelPosHigh = ha_high + (ta.atr(30) * 0.6)
label_color_neutral = input(color.gray, "Label Color Neutral")
C_DojiNumberOfCandles = 1
C_DragonflyDoji = C_IsDojiBody and C_UpShadow <= C_Body
C_GravestoneDojiOne = C_IsDojiBody and C_DnShadow <= C_Body
alertcondition(C_Doji and not C_DragonflyDoji and not C_GravestoneDojiOne, title = "New pattern detected", message = "New Doji pattern detected")
if C_Doji and not C_DragonflyDoji and not C_GravestoneDojiOne
var ttDoji = "Doji\nWhen the open and close of a security are essentially equal to each other, a doji candle forms. The length of both upper and lower shadows may vary, causing the candlestick you are left with to either resemble a cross, an inverted cross, or a plus sign. Doji candles show the playout of buyer-seller indecision in a tug-of-war of sorts. As price moves either above or below the opening level during the session, the close is either at or near the opening level."
label.new(bar_index, patternLabelPosLow, text="D", style=label.style_label_up, color = label_color_neutral, textcolor=color.white, tooltip = ttDoji)
bgcolor(ta.highest(C_Doji?1:0, C_DojiNumberOfCandles)!=0 ? color.new(color.gray, 90) : na, offset=-(C_DojiNumberOfCandles-1)) |
Mansfield RS | https://www.tradingview.com/script/NTOUgRX9-Mansfield-RS/ | franmor01981 | https://www.tradingview.com/u/franmor01981/ | 119 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © franmor01981
// **** Standard Relative Performance indicator
//The formula for calculating standard relative performance indicator is quite simple:
//Code:
//RP = ( stock_close / index_close ) * 100
// **** Mansfield Relative Performance indicator
//The formula of this indicator is a bit more difficult than the regular Standard Relative Performance indicator:
//MRP = (( RP(today) / sma(RP(today), n)) - 1 ) * 100
//Where:
//RP = Standard Relative Performance indicator (see above)
//SMA = Simple moving average over n days.
//n = 52 for weekly charts, and n = 200 on daily charts
//@version=5
indicator("Mansfield RS")
// Retrieve the other symbol's data
sym = input.symbol(title="Symbol", defval="SP:SPX")
spx = request.security(sym, input.timeframe('W', "Resolution", options=['D', 'W', 'M']), close, gaps= barmerge.gaps_on)
RP = ( close / spx ) * 100
RP52W = ta.sma(RP,52)
MRP = (( RP / RP52W) - 1 ) * 10
color plotColor = color.white
if (MRP >= 0.0)
plotColor := color.green
else if (MRP < 0.0)
plotColor := color.red
plot(MRP, title= 'MA(52)', style=plot.style_area, color=plotColor) |
HTF Candles & Pivots | https://www.tradingview.com/script/ooOobeTa-HTF-Candles-Pivots/ | boitoki | https://www.tradingview.com/u/boitoki/ | 1,206 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © boitoki
//
// 🛟 https://boitoki.gitbook.io/htf-candles-and-pivots/
// =====================================================
//@version=5
indicator('HTF Candles & Pivots', 'HTF', overlay=true, max_lines_count=300, max_labels_count=100, max_boxes_count=300, max_bars_back=1000)
import boitoki/AwesomeColor/8 as ac
import boitoki/Pivots/9 as f
import boitoki/Utilities/5 as util
//////////////////////
// Define
//////////////////////
GP1 = '〈 〉PIVOTS'
GP2 = '〈 〉GENERAL'
GP3 = '〈 〉HTF CANDLE'
GP5 = '〈 〉RIGHT BAR'
GP6 = '〈 〉RIGHT BAR 〉EXPECTED PRICE RANGE'
GP7 = '〈 〉OPTIONS'
GP8 = '〈 〉HTF CANDLE 〉LABEL'
GP9 = '〈 〉EXPERIMENTAL'
GP10 = '〈 〉MESSAGE PANEL'
GP11 = '〈 〉RIGHT BAR 〉DOUBLE ZERO 00'
t_PP = 'PP'
t_R5 = 'R ⁵'
t_R4 = 'R ⁴'
t_R3 = 'R ³'
t_R2 = 'R ²'
t_R1 = 'R ¹'
t_S1 = 'S ¹'
t_S2 = 'S ²'
t_S3 = 'S ³'
t_S4 = 'S ⁴'
t_S5 = 'S ⁵'
t_BC = 'BC'
t_TC = 'TC'
f_pip = '{0,number,#.#}'
max_bars_count = 500
maximum_x = bar_index + max_bars_count
icon_paint = '🎨'
icon_clock = '⏱️'
icon_notif = '📢'
icon_calendar = '🗓'
icon_cross = '⚔️'
icon_danger = '⚠️'
icon_jp = '🇯🇵'
icon_en = '🇺🇸'
icon_talk = '💬'
separator_dot = ' • '
separator_br = '\n'
option_new = 'New only'
option_all = 'All'
option_shifted = "Shifted forward"
option_hide = '⊗ Hide'
option_lang1 = icon_en + ' English'
option_lang2 = icon_jp + ' 日本語'
is_1min = timeframe.isintraday and timeframe.multiplier <= 1
TRANSPARENT = color.new(color.black, 100)
//////////////////////
// Types
//////////////////////
// Message
type Message
string en = ''
string ja = ''
method get (Message this, int index) =>
array.get(array.from(this.en, this.ja), index)
// Position
type Position
int x1
int x2
float y1
float y2
// DayOfWeek
type DayOfWeek
string[] ja
string[] en
method get (DayOfWeek this, int dayIndex, int langIndex) =>
switch langIndex
0 => array.get(this.en, dayIndex)
1 => array.get(this.ja, dayIndex)
=> array.get(this.en, dayIndex)
var dayOfWeek = DayOfWeek.new(
array.from('', '日', '月', '火', '水', '木', '金', '土'),
array.from('', 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'))
//////////////////////
// Functions
//////////////////////
f_color (_package, _color, _vecna, _mono, _custom) =>
switch _package
'vecna' => _vecna
'mono' => _mono
'custom' => _custom
=> ac.package(_package, _color)
f_color (_name, _a, _b, _c, _d, _e, _f, _g, _h, _i, _v, _z) =>
switch _name
'monokai' => _a
'monokaipro' => _b
'panda' => _c
'gruvbox' => _d
'spacemacs light' => _e
'spacemacs dark' => _f
'guardians' => _g
'tradingview' => _h
'vecna' => _i
'mono' => _v
'custom' => _z
=> _i
f_pricerange_avg (_avg, _lookback) =>
x2 = math.min(_lookback*2, 4000)
x3 = math.min(_lookback*3, 4000)
math.avg(_avg, _avg[_lookback], _avg[x2], _avg[x3])
f_candle (_x1, _y1, _x2, _y2, _border_color, _bgcolor, _width, _style, _xloc) =>
box.new(_x1, _y1, _x2, _y2, _border_color, _width, _style, extend.none, _xloc, _bgcolor)
f_dz_freq_select (_type, _autovalue) =>
switch _type
'Auto' => _autovalue
=> str.tonumber(_type)
f_lang_index (_type) =>
switch _type
option_lang1 => 0
option_lang2 => 1
=> 0
//////////////////////
// Inputs
//////////////////////
i_htf_type = input.string('Auto', icon_clock + ' ', options=['Auto', '15', '30', '60', '120', '240', '360', '720', 'D', 'W', 'M', '2M', '3M', '4M', '6M', '12M'], inline='time', group=GP2)
i_color_name = str.replace_all(str.lower(input.string('monokai', icon_paint + ' ', options=['TradingView', 'monokai', 'monokaipro', 'panda', 'Gruvbox', 'Spacemacs light', 'Spacemacs dark', 'Guardians', 'st3', 'st4', 'mono', 'custom'], inline='color', group=GP2)), ' ', '_')
i_color_1 = input.color(color.green , '|', inline='color', group=GP2)
i_color_2 = input.color(color.red , '', inline='color', group=GP2)
i_color_3 = input.color(color.purple , '', inline='color', group=GP2)
i_color_4 = input.color(color.orange , '', inline='color', group=GP2)
i_color_5 = input.color(color.blue , '', inline='color', group=GP2)
i_color_6 = input.color(color.yellow , '', inline='color', group=GP2)
i_msg_lang = input.string(option_lang1, icon_talk + ' ', options=[option_lang1, option_lang2], group=GP2, inline='lang')
langIndex = f_lang_index(i_msg_lang)
// HTF Candle
// =============
option_display1 = 'Both'
option_display2 = 'Open-Close'
option_display3 = 'High-Low'
i_candle_display = input.string(option_display1, 'Display ', options=[option_display1, option_display2, option_display3, option_hide], group=GP3, inline='htf_display')
i_candle_show = i_candle_display != option_hide
i_candle_thickness = input.int(1, '', minval=0, group=GP3, inline='htf_display')
i_candle_line_transp = 10
i_candle_bg_transp = 96
i_candle_show_wick = input.bool(false, "Wick", group=GP3, inline='htf_display') and i_candle_show
i_candle_show_fill = input.bool(false, 'Hollow candles', group=GP3, inline='htf_display')
i_candle_show_wick := i_candle_display == option_display3 ? false : i_candle_show_wick
i_candle_access = input.string(option_shifted, "History ", options=[option_all, option_new, option_shifted], group=GP3, inline='htf_history')
i_candle_show_hl = i_candle_display == option_display3 or i_candle_display == option_display1
i_candle_show_oc = i_candle_display == option_display2 or i_candle_display == option_display1
i_candle_show_today = not input.bool(true, 'Don\'t show Today when Shifted', group=GP3, inline='htf_history')
var access_newonly = i_candle_access == option_new
var access_all = i_candle_access == option_all
var access_shifted = i_candle_access == option_shifted
var shift = access_shifted ? 1 : 0
// Wick style
var i_candle_wick_thickness = i_candle_thickness
var i_candle_wick_transp = 3
// Time division
i_tdiv_number = input.int(0, 'Divisions', options=[0, 2, 3, 4, 5, 6, 7, 8], group=GP3, inline='divisions_display', tooltip='Num. of divisions / Extend / Thickness')
i_tdiv_extend = input.string('None', '', options=['None', 'Both'], group=GP3, inline='divisions_display')
i_tdiv_extend := i_tdiv_extend == 'None' ? extend.none : extend.both
i_tdiv_thickness = input.int(1, '', minval=0, maxval=10, group=GP3, inline='divisions_display')
var i_tdiv_show = i_tdiv_number > 1
var i_tdiv_style = line.style_dotted
// Labels
// =============
option_candle_label1 = 'Price'
option_candle_label2 = 'Pips'
option_sep1 = 'dot'
option_sep2 = 'br'
i_candle_label = input.string(option_hide, 'Display ', options=[option_candle_label1, option_candle_label2, option_hide], inline='candle_labels', group=GP8)
i_candle_label_show = i_candle_label != option_hide
i_candle_label_size = input.string(size.small, '', options=[size.auto, size.tiny, size.small, size.normal, size.large, size.huge], inline='candle_labels', group=GP8)
i_candle_label_sep = input.string(option_sep1, '', options=[option_sep1, option_sep2], inline='candle_labels', group=GP8)
i_candle_label_position = label.style_label_upper_left
i_candle_label_tz = 'GMT+3'
i_labels_show_price = i_candle_label == option_candle_label1
i_labels_show_pips = i_candle_label == option_candle_label2
i_labels_show_htf = input.bool(true , 'TF' , inline='labels_options', group=GP8)
i_labels_show_avg = input.bool(false, 'Avg' , inline='labels_options', group=GP8)
i_labels_show_day = input.bool(false, 'Day' , inline='labels_options', group=GP8)
i_labels_show_tds = input.bool(false, 'TD Seq.', inline='labels_options', group=GP8)
i_label_transp = 10
// Right bar
// =====================
i_show_info_bar = input.bool(true, '', group=GP5, inline='rightbar_display')
i_info_bar_placement = input.int(2, 'Placement', group=GP5, inline='rightbar_display')
i_info_bar_color = input.color(#757575, '', group=GP5, inline='rightbar_display')
i_info_bar_show_prev_day = input.bool(true, 'Previous', group=GP5, inline='rightbar_items')
i_info_bar_show_prev_week = input.bool(false, 'Previous week', group=GP5, inline='rightbar_items')
i_info_bar_labels = input.bool(true, 'Labels', group=GP5)
i_info_bar_extend_lines = input.bool(false, 'Lines extended', group=GP5) and (not i_candle_show)
// Expected price range
// =====================
option_epr3 = 'Predict next'
option_epr4 = 'Developing'
i_epr_rightbar = input.bool(true, 'In Rightbar', group=GP6)
i_epr_history = input.string(option_hide, 'Chart plotting', options=[option_all, option_new, option_epr3, option_epr4, option_hide], group=GP6)
i_epr_show = i_epr_history != option_hide
i_epr_next = i_epr_history == option_epr3
i_epr_shifted = i_epr_next
i_epr_developing = i_epr_history == option_epr4
i_epr_transp = 98
i_epr_plot_base = input.string('open', 'Pivot', options=['open', 'hl2'], group=GP6)
// Double zero
// ============
i_00_rightbar = input.bool(true, 'In Rightbar', group=GP11)
i_00_freq = input.string('Auto', 'Freqency', options=['50', '100', '150', '200', '300', '400', '500', '1000', 'Auto'], group=GP11)
i_00_labels = input.bool(true, 'Labels', group=GP11)
i_00_extend = input.bool(false, 'Lines extended', group=GP11)
i_00_lines_count = 10
// Pivots
// =============
option_pivot_label1 = 'Levels'
option_pivot_label2 = 'Levels & Price'
option_pivot_label3 = 'Price'
i_pivots_type = input.string('Traditional', 'Display ', options=['Traditional', 'Fibonacci', 'Woodie', 'Classic', 'DM', 'Camarilla', 'Floor', 'Expected Pivot Points', 'PP only'], inline='pivots_display', group=GP1)
i_pivots_show_cpr = input.bool(false, 'CPR', inline='pivots_display', group=GP1)
i_pivots_history = input.string(option_hide, 'History ', options=[option_all, option_new, option_hide], inline='pivot_history', group=GP1)
i_pivots_show = i_pivots_history != option_hide
i_pivots_show_cpr := i_pivots_show_cpr and i_pivots_show
i_pivots_show_forecast = input.bool(false, 'Forecast', inline='pivot_history', group=GP1)
i_pivots_line_style = input.string(line.style_dotted, 'Line ', options=[line.style_solid, line.style_dotted, line.style_dashed], inline='pivot_line_style', group=GP1)
i_pivots_show_zone = input.bool(true, 'BG', inline='pivot_line_style', group=GP1) and not (i_pivots_type == 'Traditional' or i_pivots_type == 'DM')
i_pivots_show_zone := i_pivots_type == 'Expected Pivot Points' ? false : i_pivots_show_zone
i_pivots_line_thickness = 1
i_pivots_line_transp = 30
i_pivots_label_position = input.string(option_hide, 'Labels ', options=['Right', 'Left', option_hide], inline='pivot_label', group=GP1)
i_pivots_label_show = option_hide != i_pivots_label_position
i_pivots_label = input.string(option_pivot_label1, '', options=[option_pivot_label1, option_pivot_label3, option_pivot_label2], inline='pivot_label', group=GP1)
i_pivots_label_size = input.string(size.normal, '', options=[size.auto, size.tiny, size.small, size.normal, size.large, size.huge], inline='pivot_label', group=GP1)
i_pivots_zone_transp = 96
i_pivots_show_history = i_pivots_history == option_all
// Message panel
// ==============
i_show_messagebox = input.bool(true, 'Message panel', group=GP10, inline='message_text')
i_msg_size = input.string(size.normal, '', options=[size.auto, size.tiny, size.small, size.normal, size.large, size.huge], group=GP10, inline='message_text')
i_msg_color = input.color(color.gray, '', group=GP10, inline='message_text')
i_msg_tz = input.string('GMT+1', 'Time zone', options=['GMT-11', 'GMT-10', 'GMT-9', 'GMT-8', 'GMT-7', 'GMT-6', 'GMT-5', 'GMT-4', 'GMT-3', 'GMT-2', 'GMT-1', 'GMT', 'GMT+1', 'GMT+2', 'GMT+3', 'GMT+4', 'GMT+5', 'GMT+6', 'GMT+7', 'GMT+8', 'GMT+9', 'GMT+10', 'GMT+11', 'GMT+12'], group=GP10, inline='message_tz')
i_placement_y = input.string('bottom', 'Placement', options=['top', 'middle', 'bottom'], group=GP10, inline='message_placement')
i_placement_x = input.string('left', '', options=['left', 'center', 'right'], group=GP10, inline='message_placement')
i_placement = i_placement_y + '_' + i_placement_x
i_msg_thres = input.float(0.05, 'Threshold %', minval=0, step=0.05, group=GP10) / 100
i_msg_dot = true//input.bool(false, 'Display the dots', group=GP10)
i_msg_show_cal = input.bool(true, icon_calendar + ' Calendar', group=GP10)
i_msg_show_info = input.bool(false, icon_notif + ' Info', group=GP10)
i_msg_show_warn = input.bool(false, icon_danger + ' Warning', group=GP10)
// Options & Experimental
// ======================
i_clean_memory = input.bool(false, 'Memory saving', group=GP9)
i_labels_day_kanji = i_msg_lang == option_lang2
i_drawing_max = i_clean_memory ? 5 : 200
//////////////////////
// Colors
//////////////////////
c_none = color.new(color.black, 100)
c_bull = f_color(i_color_name, 'green' , #024873, ac.panda('light-gray') , i_color_1)
c_bear = f_color(i_color_name, 'red' , #730E0E, ac.panda('dark-gray') , i_color_2)
c_PP = f_color(i_color_name, 'purple' , #FD7CC2, ac.panda('dark-gray') , i_color_3), c_CPR = c_PP
c_RX = f_color(i_color_name, 'orange' , #FB9787, ac.panda('gray') , i_color_4), c_SX = c_RX
c_epr = f_color(i_color_name, 'blue' , #6EA2FA, ac.panda('light-gray') , i_color_5)
c_cur = f_color(i_color_name, 'orange' , #FB9787, ac.panda('gray') , i_color_6)
//////////////////////
// Messages / Text
//////////////////////
var message_expected_high = Message.new('Expected range high', '予想値幅高値')
var message_expected_low = Message.new('Expected range low', '予想値幅安値')
var message_prev_open = Message.new('Preivous open', '前日始値')
var message_prev_high = Message.new('Preivous high', '前日高値')
var message_prev_low = Message.new('Preivous low', '前日安値')
var message_prev_close = Message.new('Preivous close', '前日終値')
var message_prev_week_open = Message.new('Preivous week open', '先週始値')
var message_prev_week_high = Message.new('Preivous week high', '先週高値')
var message_prev_week_low = Message.new('Preivous week low', '先週安値')
var message_prev_week_close = Message.new('Preivous week close', '先週終値')
var text_w = Message.new('W', '週目')
var text_previous = Message.new('previous', '前日')
//////////////////////
// CALCULATIONS
//////////////////////
htf = i_htf_type == 'Auto' ? util.auto_htf() : i_htf_type
htf_changed = ta.change(time(htf))
htf_is_intraday = htf != 'W' and htf != 'M' and htf != '6M' and htf != '12M'
[O1, H1, L1, C1, O0, H0, L0, C0] = f.htf_ohlc(htf)
var counter = 0
if htf_changed
counter := 0
else
counter := counter + 1
////////////////////////
// RENDERING FUNCTIONS
////////////////////////
f_lang (_select, _opt1, _opt2) =>
switch _select
option_lang1 => _opt1
option_lang2 => _opt2
f_render_pivots_label (_x, _y, _text, _color, _style, _show) =>
label id = na
if _show
v_price = str.tostring(_y, format.mintick)
v_text = ''
if i_pivots_label == option_pivot_label1
v_text := _text
else if i_pivots_label == option_pivot_label2
v_text := _text + ' (' + v_price + ')'
else if i_pivots_label == option_pivot_label3
v_text := v_price
id := label.new(_x, _y, v_text, textcolor=_color, color=c_none, style=_style, size=i_pivots_label_size)
id
f_render_pivots_line (_x1, _y, _x2, _width, _color, _style, _show) =>
id = (_show and _y > 0) ? line.new(_x1, _y, _x2, _y, width=_width, color=color.new(_color, i_pivots_line_transp), style=_style) : na
id
f_render_pivots_box (_x1, _y1, _x2, _y2, _color, _show) =>
id = _show ? box.new(_x1, _y1, _x2, _y2, bgcolor=color.new(_color, i_pivots_zone_transp), border_color=c_none) : na
id
f_render_pivots (_show, _show_history, _next, _x1, _x2, _shift, _lines, _labels, _boxes, _should_delete) =>
if _show
O = _next ? O0 : O1
H = _next ? H0 : H1
L = _next ? L0 : L1
C = _next ? C0 : C1
[PP, R1, S1, R2, S2, R3, S3, R4, S4, R5, S5] = f.pivots(i_pivots_type, O, H, L, C)
[BC, TC, CPR] = f.cpr(H, L, C)
lines_start = array.size(_lines)
boxes_start = array.size(_boxes)
labels_start = array.size(_labels)
if (not _show_history) or _should_delete
util.clear_lines(_lines, 0)
util.clear_labels(_labels, 0)
util.clear_boxes(_boxes, 0)
// Lines
array.push(_lines, f_render_pivots_line(_x1, PP[_shift], _x2, math.max(2, i_pivots_line_thickness), c_PP, line.style_solid, true) )
array.push(_lines, f_render_pivots_line(_x1, R1[_shift], _x2, i_pivots_line_thickness, c_RX, i_pivots_line_style, true) )
array.push(_lines, f_render_pivots_line(_x1, R2[_shift], _x2, i_pivots_line_thickness, c_RX, i_pivots_line_style, true) )
array.push(_lines, f_render_pivots_line(_x1, R3[_shift], _x2, i_pivots_line_thickness, c_RX, i_pivots_line_style, true) )
array.push(_lines, f_render_pivots_line(_x1, R4[_shift], _x2, i_pivots_line_thickness, c_RX, i_pivots_line_style, true) )
array.push(_lines, f_render_pivots_line(_x1, R5[_shift], _x2, i_pivots_line_thickness, c_RX, i_pivots_line_style, true) )
array.push(_lines, f_render_pivots_line(_x1, S1[_shift], _x2, i_pivots_line_thickness, c_SX, i_pivots_line_style, true) )
array.push(_lines, f_render_pivots_line(_x1, S2[_shift], _x2, i_pivots_line_thickness, c_SX, i_pivots_line_style, true) )
array.push(_lines, f_render_pivots_line(_x1, S3[_shift], _x2, i_pivots_line_thickness, c_SX, i_pivots_line_style, true) )
array.push(_lines, f_render_pivots_line(_x1, S4[_shift], _x2, i_pivots_line_thickness, c_SX, i_pivots_line_style, true) )
array.push(_lines, f_render_pivots_line(_x1, S5[_shift], _x2, i_pivots_line_thickness, c_SX, i_pivots_line_style, true) )
array.push(_lines, f_render_pivots_line(_x1, BC[_shift], _x2, 1, c_CPR, line.style_dotted, i_pivots_show_cpr) )
array.push(_lines, f_render_pivots_line(_x1, TC[_shift], _x2, 1, c_CPR, line.style_dotted, i_pivots_show_cpr) )
// Boxes
array.push(_boxes, f_render_pivots_box(_x1, R1[_shift], _x2, R2, c_RX , i_pivots_show_zone) )
array.push(_boxes, f_render_pivots_box(_x1, R3[_shift], _x2, R4, c_RX , i_pivots_show_zone) )
array.push(_boxes, f_render_pivots_box(_x1, S1[_shift], _x2, S2, c_SX , i_pivots_show_zone) )
array.push(_boxes, f_render_pivots_box(_x1, S3[_shift], _x2, S4, c_SX , i_pivots_show_zone) )
array.push(_boxes, f_render_pivots_box(_x1, BC[_shift], _x2, TC, c_CPR, i_pivots_show_zone and i_pivots_show_cpr) )
// Labels
label_x = i_pivots_label_position == 'Left' ? _x1 : _x2
label_style = i_pivots_label_position == 'Left' ? label.style_label_right : label.style_label_left
array.push(_labels, f_render_pivots_label(label_x, PP[_shift], t_PP, color.new(c_PP , 20), label_style, i_pivots_label_show) )
array.push(_labels, f_render_pivots_label(label_x, R5[_shift], t_R5, color.new(c_RX , 30), label_style, i_pivots_label_show) )
array.push(_labels, f_render_pivots_label(label_x, R4[_shift], t_R4, color.new(c_RX , 30), label_style, i_pivots_label_show) )
array.push(_labels, f_render_pivots_label(label_x, R3[_shift], t_R3, color.new(c_RX , 30), label_style, i_pivots_label_show) )
array.push(_labels, f_render_pivots_label(label_x, R2[_shift], t_R2, color.new(c_RX , 30), label_style, i_pivots_label_show) )
array.push(_labels, f_render_pivots_label(label_x, R1[_shift], t_R1, color.new(c_RX , 30), label_style, i_pivots_label_show) )
array.push(_labels, f_render_pivots_label(label_x, S1[_shift], t_S1, color.new(c_SX , 30), label_style, i_pivots_label_show) )
array.push(_labels, f_render_pivots_label(label_x, S2[_shift], t_S2, color.new(c_SX , 30), label_style, i_pivots_label_show) )
array.push(_labels, f_render_pivots_label(label_x, S3[_shift], t_S3, color.new(c_SX , 30), label_style, i_pivots_label_show) )
array.push(_labels, f_render_pivots_label(label_x, S4[_shift], t_S4, color.new(c_SX , 30), label_style, i_pivots_label_show) )
array.push(_labels, f_render_pivots_label(label_x, S5[_shift], t_S5, color.new(c_SX , 30), label_style, i_pivots_label_show) )
array.push(_labels, f_render_pivots_label(label_x, BC[_shift], t_BC, color.new(c_CPR, 30), label_style, i_pivots_label_show and i_pivots_show_cpr) )
array.push(_labels, f_render_pivots_label(label_x, TC[_shift], t_TC, color.new(c_CPR, 30), label_style, i_pivots_label_show and i_pivots_show_cpr) )
if _show_history and (not _should_delete)
lines_step = array.size(_lines) - lines_start
boxes_step = array.size(_boxes) - boxes_start
labels_step = array.size(_labels) - labels_start
util.remove_lines(_lines , i_drawing_max, lines_start , lines_step)
util.remove_boxes(_boxes , i_drawing_max, boxes_start , boxes_step)
util.remove_labels(_labels, i_drawing_max, labels_start, labels_step)
///////////////
// HTF Candle
///////////////
f_render_tdiv (_x, _y1, _y2, _color, _transp, _show) =>
id = _show ? line.new(_x, _y1, _x, _y2, color=color.new(_color, _transp), width=i_tdiv_thickness, style=i_tdiv_style, extend=i_tdiv_extend) : na
id
f_get_div_x (_x1, _x2, _x3, _num) =>
math.round((_x2 - _x1) * (1/i_tdiv_number*_num)) + _x3
// Divisions:
f_render_divs (x1, x2, px1, px2, nx1, nx2, color01, color11, wick_transp, _show, _show_today) =>
if _show
var line split_1 = na, var line split_2 = na
var line split_3 = na, var line split_4 = na
var line split_5 = na, var line split_6 = na
var line split_7 = na
var line forecast_split_1 = na, var line forecast_split_2 = na
var line forecast_split_3 = na, var line forecast_split_4 = na
var line forecast_split_5 = na, var line forecast_split_6 = na
var line forecast_split_7 = na
var a_lines = array.new<line>()
if htf_changed
line.delete(split_1)
line.delete(split_2)
line.delete(split_3)
line.delete(split_4)
line.delete(split_5)
line.delete(split_6)
line.delete(split_7)
if access_newonly or access_all or access_shifted
split_x1 = f_get_div_x(x1, x2, x1, 1)
split_x2 = f_get_div_x(x1, x2, x1, 2)
split_x3 = f_get_div_x(x1, x2, x1, 3)
split_x4 = f_get_div_x(x1, x2, x1, 4)
split_x5 = f_get_div_x(x1, x2, x1, 5)
split_x6 = f_get_div_x(x1, x2, x1, 6)
split_x7 = f_get_div_x(x1, x2, x1, 7)
split_1 := f_render_tdiv(split_x1, H0[shift], L0[shift], color01[shift], wick_transp, i_tdiv_number > 1)
split_2 := f_render_tdiv(split_x2, H0[shift], L0[shift], color01[shift], wick_transp, i_tdiv_number > 2)
split_3 := f_render_tdiv(split_x3, H0[shift], L0[shift], color01[shift], wick_transp, i_tdiv_number > 3)
split_4 := f_render_tdiv(split_x4, H0[shift], L0[shift], color01[shift], wick_transp, i_tdiv_number > 4)
split_5 := f_render_tdiv(split_x5, H0[shift], L0[shift], color01[shift], wick_transp, i_tdiv_number > 5)
split_6 := f_render_tdiv(split_x6, H0[shift], L0[shift], color01[shift], wick_transp, i_tdiv_number > 6)
split_7 := f_render_tdiv(split_x7, H0[shift], L0[shift], color01[shift], wick_transp, i_tdiv_number > 7)
if access_all or access_shifted
split_x1 = f_get_div_x(px1, px2, px1, 1)
split_x2 = f_get_div_x(px1, px2, px1, 2)
split_x3 = f_get_div_x(px1, px2, px1, 3)
split_x4 = f_get_div_x(px1, px2, px1, 4)
split_x5 = f_get_div_x(px1, px2, px1, 5)
split_x6 = f_get_div_x(px1, px2, px1, 6)
split_x7 = f_get_div_x(px1, px2, px1, 7)
a_start = array.size(a_lines)
array.push(a_lines, f_render_tdiv(split_x1, H1[shift], L1[shift], color11[shift], wick_transp, i_tdiv_number > 1) )
array.push(a_lines, f_render_tdiv(split_x2, H1[shift], L1[shift], color11[shift], wick_transp, i_tdiv_number > 2) )
array.push(a_lines, f_render_tdiv(split_x3, H1[shift], L1[shift], color11[shift], wick_transp, i_tdiv_number > 3) )
array.push(a_lines, f_render_tdiv(split_x4, H1[shift], L1[shift], color11[shift], wick_transp, i_tdiv_number > 4) )
array.push(a_lines, f_render_tdiv(split_x5, H1[shift], L1[shift], color11[shift], wick_transp, i_tdiv_number > 5) )
array.push(a_lines, f_render_tdiv(split_x6, H1[shift], L1[shift], color11[shift], wick_transp, i_tdiv_number > 6) )
array.push(a_lines, f_render_tdiv(split_x7, H1[shift], L1[shift], color11[shift], wick_transp, i_tdiv_number > 7) )
util.remove_lines(a_lines, i_drawing_max, a_start, array.size(a_lines) - a_start)
if access_shifted and _show_today
split_x1 = math.min(maximum_x, f_get_div_x(x1, x2, nx1, 1))
split_x2 = math.min(maximum_x, f_get_div_x(x1, x2, nx1, 2))
split_x3 = math.min(maximum_x, f_get_div_x(x1, x2, nx1, 3))
split_x4 = math.min(maximum_x, f_get_div_x(x1, x2, nx1, 4))
split_x5 = math.min(maximum_x, f_get_div_x(x1, x2, nx1, 5))
split_x6 = math.min(maximum_x, f_get_div_x(x1, x2, nx1, 6))
split_x7 = math.min(maximum_x, f_get_div_x(x1, x2, nx1, 7))
forecast_split_1 := f_render_tdiv(split_x1, H0, L0, color01, wick_transp, i_tdiv_number > 1), line.delete(forecast_split_1[1])
forecast_split_2 := f_render_tdiv(split_x2, H0, L0, color01, wick_transp, i_tdiv_number > 2), line.delete(forecast_split_2[1])
forecast_split_3 := f_render_tdiv(split_x3, H0, L0, color01, wick_transp, i_tdiv_number > 3), line.delete(forecast_split_3[1])
forecast_split_4 := f_render_tdiv(split_x4, H0, L0, color01, wick_transp, i_tdiv_number > 4), line.delete(forecast_split_4[1])
forecast_split_5 := f_render_tdiv(split_x5, H0, L0, color01, wick_transp, i_tdiv_number > 5), line.delete(forecast_split_5[1])
forecast_split_6 := f_render_tdiv(split_x6, H0, L0, color01, wick_transp, i_tdiv_number > 6), line.delete(forecast_split_6[1])
forecast_split_7 := f_render_tdiv(split_x7, H0, L0, color01, wick_transp, i_tdiv_number > 7), line.delete(forecast_split_7[1])
else
if access_newonly or access_all
line.set_y1(split_1, H0), line.set_y2(split_1, L0)
line.set_y1(split_2, H0), line.set_y2(split_2, L0)
line.set_y1(split_3, H0), line.set_y2(split_3, L0)
line.set_y1(split_4, H0), line.set_y2(split_4, L0)
line.set_y1(split_5, H0), line.set_y2(split_5, L0)
line.set_y1(split_6, H0), line.set_y2(split_6, L0)
line.set_y1(split_7, H0), line.set_y2(split_7, L0)
if access_shifted and _show_today
line.set_y1(forecast_split_1, H0), line.set_y2(forecast_split_1, L0), line.set_color(forecast_split_1, color.new(color01, wick_transp))
line.set_y1(forecast_split_2, H0), line.set_y2(forecast_split_2, L0), line.set_color(forecast_split_2, color.new(color01, wick_transp))
line.set_y1(forecast_split_3, H0), line.set_y2(forecast_split_3, L0), line.set_color(forecast_split_3, color.new(color01, wick_transp))
line.set_y1(forecast_split_4, H0), line.set_y2(forecast_split_4, L0), line.set_color(forecast_split_4, color.new(color01, wick_transp))
line.set_y1(forecast_split_5, H0), line.set_y2(forecast_split_5, L0), line.set_color(forecast_split_5, color.new(color01, wick_transp))
line.set_y1(forecast_split_6, H0), line.set_y2(forecast_split_6, L0), line.set_color(forecast_split_6, color.new(color01, wick_transp))
line.set_y1(forecast_split_7, H0), line.set_y2(forecast_split_7, L0), line.set_color(forecast_split_7, color.new(color01, wick_transp))
true
//////////////
// Info Bar //
INFO_BAR_X1 = bar_index + i_info_bar_placement
f_render_info_bar (x1) =>
x2 = x1 + 4
col = color.new(i_info_bar_color, 30)
r = line.new(x1, high, x1, low, extend=extend.both, color=col, width=1), line.delete(r[1])
l = line.new(x2, high, x2, low, extend=extend.both, color=TRANSPARENT, width=1), line.delete(l[1])
true
f_render_info_bar_today (x1, o, h, l, c, _color) =>
x2 = x1 + 4
a = box.new(x1, h, x2, l, bgcolor=color.new(_color, 90), border_color=color.new(_color, 40), border_style=line.style_dotted), box.delete(a[1])
b = box.new(x1, o, x2, c, bgcolor=color.new(_color, 90), border_color=color.new(_color, 40)), box.delete(b[1])
f_render_info_bar_epr (x1, y1, y2, y3, y4) =>
if i_epr_rightbar
col1 = color.new(c_epr, 80)
col2 = color.new(c_epr, 50)
col3 = color.new(c_epr, 30)
x2 = x1 + 2
a = box.new(x1, y1, x2, y2, bgcolor=col1, border_color=col2, border_width=1), box.delete(a[1])
R2 = line.new(x1, y3, x2, y3, color=col3, width=5), line.delete(R2[1])
S2 = line.new(x1, y4, x2, y4, color=col3, width=5), line.delete(S2[1])
if i_info_bar_labels
b = label.new(x2, y1, message_expected_high.get(langIndex), color=TRANSPARENT, textcolor=col2, style=label.style_label_left), label.delete(b[1])
c = label.new(x2, y2, message_expected_low.get(langIndex), color=TRANSPARENT, textcolor=col2, style=label.style_label_left), label.delete(c[1])
f_render_info_bar_prev (x1, _o, _h, _l, _c, _labels, _show) =>
col1 = color.new(c_cur, 20)
col2 = color.new(c_cur, 70)
x2 = x1 + 2
if _show
o = line.new(x1, _o, x2, _o, color=col1, width=5), line.delete(o[1])
h = line.new(x1, _h, x2, _h, color=col2, width=5), line.delete(h[1])
l = line.new(x1, _l, x2, _l, color=col2, width=5), line.delete(l[1])
c = line.new(x1, _c, x2, _c, color=col1, width=5), line.delete(c[1])
if i_info_bar_extend_lines
o2 = line.new(x1, _o, x2, _o, color=col1, width=1, extend=extend.left), line.delete(o2[1])
h2 = line.new(x1, _h, x2, _h, color=col2, width=1, extend=extend.left), line.delete(h2[1])
l2 = line.new(x1, _l, x2, _l, color=col2, width=1, extend=extend.left), line.delete(l2[1])
c2 = line.new(x1, _c, x2, _c, color=col1, width=1, extend=extend.left), line.delete(c2[1])
if i_info_bar_labels
lo = label.new(x2, _o, array.get(_labels, 0), color=TRANSPARENT, textcolor=col1, style=label.style_label_left), label.delete(lo[1])
lh = label.new(x2, _h, array.get(_labels, 1), color=TRANSPARENT, textcolor=col2, style=label.style_label_left), label.delete(lh[1])
ll = label.new(x2, _l, array.get(_labels, 2), color=TRANSPARENT, textcolor=col2, style=label.style_label_left), label.delete(ll[1])
lc = label.new(x2, _c, array.get(_labels, 3), color=TRANSPARENT, textcolor=col1, style=label.style_label_left), label.delete(lc[1])
f_00_line (_y, x1, _width = 1, _style = line.style_dotted, _lines, _labels) =>
x2 = x1 + 4
col = i_info_bar_color
array.push(_lines, line.new(x1, _y, x2, _y, width=_width, color=col, style=_style) )
if i_00_extend
array.push(_lines, line.new(x1 - 1, _y, x1, _y, width=_width, color=color.new(col, 30), style=_style, extend=extend.left) )
if i_00_labels
array.push(_labels, label.new(x2, _y, str.tostring(_y, format.mintick), style=label.style_label_left, size=size.small, textcolor=color.new(col, 30), color=TRANSPARENT) )
f_render_info_bar_00 (x1, _range_avg, _pivot) =>
var dz_lines = array.new<line>()
var dz_labels = array.new<label>()
if i_00_rightbar
auto_freq_value = math.round(((_range_avg / syminfo.mintick) / 5) / 100) * 100
dz_freq = f_dz_freq_select(i_00_freq, auto_freq_value)
util.clear_lines(dz_lines)
util.clear_labels(dz_labels)
pivot = math.round(_pivot / syminfo.mintick / dz_freq) * syminfo.mintick * dz_freq
f_00_line(pivot, x1, 2, line.style_solid, dz_lines, dz_labels)
for i = 1 to i_00_lines_count
float upper = pivot + (syminfo.mintick * dz_freq * i)
float lower = pivot - (syminfo.mintick * dz_freq * i)
f_00_line(upper, x1, 1, line.style_dotted, dz_lines, dz_labels)
f_00_line(lower, x1, 1, line.style_dotted, dz_lines, dz_labels)
true
//////////////////////////
// Expected Price Range //
f_epr_pivot () =>
switch i_epr_plot_base
'open' => O0
'close' => C0
'hl2' => math.avg(H0, L0)
'hlc3' => math.avg(H0, L0, C0)
'ohl3' => math.avg(O0, H0, L0)
f_render_EPR (_x1, _x2, _px1, _px2, _nx1, _nx2, _avg, _show) =>
var a_arr = array.new<line>()
var b_arr = array.new<linefill>()
x1 = i_epr_shifted ? _nx1 : _x1
x2 = i_epr_shifted ? _nx2 : _x2
yc = f_epr_pivot()
R1 = yc + (_avg * 0.5)
S1 = yc - (_avg * 0.5)
R2 = yc + (_avg * 0.25)
S2 = yc - (_avg * 0.25)
color_alert = color.gray
is_over = H0 > R1 and L0 < S1
if _show and (not i_epr_developing)
var line epr_upper = na, var line epr_upper2 = na,
var line epr_lower = na, var line epr_lower2 = na
var linefill epr_fill = na
if htf_changed
if access_shifted
epr_upper := line.new(x1, R1, x2, R1, width=1, color=c_epr, style=line.style_dotted)
epr_upper2 := line.new(x1, R2, x2, R2, width=1, color=c_epr, style=line.style_dotted)
epr_lower := line.new(x1, S1, x2, S1, width=1, color=c_epr, style=line.style_dotted)
epr_lower2 := line.new(x1, S2, x2, S2, width=1, color=c_epr, style=line.style_dotted)
epr_fill := linefill.new(epr_lower, epr_upper, color.new(c_epr, i_epr_transp))
a_start = array.size(a_arr)
b_start = array.size(b_arr)
array.push(a_arr, epr_upper), array.push(a_arr, epr_upper2)
array.push(a_arr, epr_lower), array.push(a_arr, epr_lower2)
array.push(b_arr, epr_fill)
if i_epr_history == option_new or i_epr_history == option_epr3
line.delete(epr_upper[1]), line.delete(epr_upper2[1])
line.delete(epr_lower[1]), line.delete(epr_lower2[1])
linefill.delete(epr_fill[1])
util.remove_lines (a_arr, i_drawing_max + 1, a_start, array.size(a_arr) - a_start)
util.remove_linefills(b_arr, i_drawing_max + 1, b_start, array.size(b_arr) - b_start)
else
if access_shifted
line.set_y1(epr_upper, R1), line.set_y2(epr_upper, R1)
line.set_x1(epr_upper, x1), line.set_x2(epr_upper, x2)
line.set_y1(epr_upper2, R2), line.set_y2(epr_upper2, R2)
line.set_x1(epr_upper2, x1), line.set_x2(epr_upper2, x2)
line.set_y1(epr_lower, S1), line.set_y2(epr_lower, S1)
line.set_x1(epr_lower, x1), line.set_x2(epr_lower, x2)
line.set_y1(epr_lower2, S2), line.set_y2(epr_lower2, S2)
line.set_x1(epr_lower2, x1), line.set_x2(epr_lower2, x2)
[R1, S1, R2, S2, is_over]
////////////
// Labels //
f_label (_htf, _chg, _avg, _day, _td, _ts, _offset = 0) =>
t = array.new<string>()
offset = math.min(_offset, 500)
//if _day != 0
// label.new(bar_index, na, str.tostring(day), yloc=yloc.abovebar, size=size.tiny, color=c_none, textcolor=color.gray)
if i_labels_show_htf
array.push(t, _htf)
if i_labels_show_day and (not na(_day))
array.push(t, dayOfWeek.get(_day[offset], langIndex))
if i_labels_show_price and i_labels_show_avg
array.push(t, str.tostring(_chg, format.mintick) + '(' + str.tostring(_avg, format.mintick) + ')')
else if i_labels_show_price
array.push(t, str.tostring(_chg, format.mintick))
if i_labels_show_pips and i_labels_show_avg
array.push(t, str.format(f_pip, util.toPips(_chg)) + str.format(' ('+ f_pip +')', util.toPips(_avg)))
else if i_labels_show_pips
array.push(t, str.format(f_pip, util.toPips(_chg)))
// 1分足以下ではTDSの計算が行えません
if (not is_1min) and i_labels_show_tds and (_td > 0 or _ts > 0)
t_td = _td > 0 ? '▲'+str.tostring(_td) : ''
t_ts = _ts > 0 ? '▼'+str.tostring(_ts) : ''
array.push(t, t_td + t_ts)
array.join(t, i_candle_label_sep == option_sep1 ? separator_dot : separator_br)
f_render_labels (_htf, x1, x2, px1, px2, nx1, nx2, color01, color11, _avg, _day, _td0, _ts0, _td1, _ts1, _show, _show_today) =>
if _show
var label note = na
var label n_note = na
var a_labels = array.new<label>()
p_offset = 0
c_offset = 0
if access_all
p_offset := (x1 - px1) * 1 // 1 day ago
else if access_shifted
p_offset := (x1 - px1) * 2 // 2 days ago
c_offset := (x1 - px1) * 1 // 1 day ago
v_note_n = f_label(_htf, H0[shift] - L0[shift], _avg, _day, _td1, _ts1)
v_note_c = f_label(_htf, H1[shift] - L1[shift], _avg, _day, _td0[0], _ts0[0], c_offset)
v_note_p = f_label(_htf, H1[shift] - L1[shift], _avg, _day, _td0[shift], _ts0[shift], p_offset)
if htf_changed
label.delete(note)
label.delete(n_note)
if access_newonly or access_all or access_shifted
note := label.new(x1, L0[shift], v_note_c, style=i_candle_label_position, color=c_none, textcolor=color.new(color01[shift], i_label_transp), size=i_candle_label_size, textalign=text.align_left)
true
if access_all or access_shifted
a_start = array.size(a_labels)
array.push(a_labels, label.new(px1, L1[shift], v_note_p, style=i_candle_label_position, color=c_none, textcolor=color.new(color11[shift], i_label_transp), size=i_candle_label_size, textalign=text.align_left))
util.remove_labels(a_labels, i_drawing_max, a_start, 1)
true
if access_shifted and _show_today
n_note := label.new(nx1, L0, v_note_n, style=i_candle_label_position, color=c_none, textcolor=color.new(color01, i_label_transp), size=i_candle_label_size, textalign=text.align_left)
true
true
else
if access_newonly or access_all
label.set_y(note, L0)
label.set_text(note, v_note_n)
label.set_textcolor(note, color.new(color01, i_label_transp))
true
else if access_shifted and _show_today
label.set_text(note, v_note_c)
label.set_y(n_note, L0)
label.set_text(n_note, v_note_n)
label.set_textcolor(n_note, color.new(color01, i_label_transp))
true
true
true
//////////
// Wick //
f_render_wick (_x1, _x2, _xc, _px1, _px2, _pxc, _nx1, _nx2, _nxc, color01, color11, _show, _show_today) =>
if _show
var line h = na
var line l = na
var line n_h = na
var line n_l = na
var a_lines = array.new<line>()
if htf_changed
line.delete(h)
line.delete(l)
line.delete(n_h)
line.delete(n_l)
if access_newonly or access_all or access_shifted
x = _xc
h := line.new(x, H0[shift], x, math.max(O0[shift], C0[shift]), color=color.new(color01[shift], i_candle_wick_transp), width=i_candle_wick_thickness)
l := line.new(x, L0[shift], x, math.min(O0[shift], C0[shift]), color=color.new(color01[shift], i_candle_wick_transp), width=i_candle_wick_thickness)
if access_all or access_shifted
a_start = array.size(a_lines)
x = _pxc
array.push(a_lines, line.new(x, H1[shift], x, math.max(O1[shift], C1[shift]), color=color.new(color11[shift], i_candle_wick_transp), width=i_candle_wick_thickness) )
array.push(a_lines, line.new(x, L1[shift], x, math.min(O1[shift], C1[shift]), color=color.new(color11[shift], i_candle_wick_transp), width=i_candle_wick_thickness) )
util.remove_lines(a_lines, i_drawing_max, a_start, array.size(a_lines) - a_start)
if access_shifted and _show_today
x = _nxc
n_h := line.new(x, H0, x, math.max(O0, C0), color=color.new(color01, i_candle_wick_transp), width=i_candle_wick_thickness), line.delete(n_l[1])
n_l := line.new(x, L0, x, math.min(O0, C0), color=color.new(color01, i_candle_wick_transp), width=i_candle_wick_thickness), line.delete(n_h[1])
true
else
if access_newonly or access_all
line.set_y1(h, H0)
line.set_y2(h, math.max(O0, C0))
line.set_color(h, color.new(color01, i_candle_wick_transp))
line.set_y1(l, L0)
line.set_y2(l, math.min(O0, C0))
line.set_color(l, color.new(color01, i_candle_wick_transp))
if access_shifted and _show_today
x = _nxc - math.round(i_candle_wick_thickness / 2)
line.set_x1(n_h, x), line.set_x2(n_h, x)
line.set_y1(n_h, H0)
line.set_y2(n_h, math.max(O0, C0))
line.set_color(n_h, color.new(color01, i_candle_wick_transp))
line.set_x1(n_l, x), line.set_x2(n_l, x)
line.set_y1(n_l, L0)
line.set_y2(n_l, math.min(O0, C0))
line.set_color(n_l, color.new(color01, i_candle_wick_transp))
true
true
/////////////
// CANDLES //
f_render_candles (_x1, _x2, _px1, _px2, _nx1, _nx2, color0, color01, color1, color11, _show, _show_today) =>
if _show
var box hl = na
var box oc = na
var box p_hl = na
var box p_oc = na
var box n_oc = na
var box n_hl = na
var a = array.new<box>()
i_hl_bg_transp = (i_candle_thickness == 0 and i_candle_show_hl) ? 90 : 96
i_oc0_bg_transp = (i_candle_thickness == 0 and i_candle_show_hl) ? 100 : (i_candle_thickness == 0) ? 90 : 94
i_oc1_bg_transp = (i_candle_thickness == 0 and i_candle_show_hl) ? 100 : (i_candle_thickness == 0) ? 90 : 94
_width = i_candle_thickness
if i_candle_show_fill
i_oc0_bg_transp := O0[shift] > C0[shift] ? 0 : i_oc0_bg_transp
i_oc1_bg_transp := O1[shift] > C1[shift] ? 0 : i_oc1_bg_transp
if htf_changed
box.delete(hl)
box.delete(oc)
box.delete(n_oc)
box.delete(n_hl)
if access_newonly or access_all or access_shifted
if i_candle_show_hl
hl := f_candle(_x1, H0[shift], _x2, L0[shift], color01[shift], color.new(color0[shift], i_hl_bg_transp), _width, line.style_dotted, xloc.bar_index)
if i_candle_show_oc
oc := f_candle(_x1, O0[shift], _x2, C0[shift], color01[shift], color.new(color0[shift], i_oc0_bg_transp), _width, line.style_solid, xloc.bar_index)
if access_all or access_shifted
a_start = array.size(a)
if i_candle_show_hl
array.push(a, f_candle(_px1, H1[shift], _px2, L1[shift], color11[shift], color.new(color1[shift], i_hl_bg_transp), _width, line.style_dotted, xloc.bar_index))
if i_candle_show_oc
array.push(a, f_candle(_px1, O1[shift], _px2, C1[shift], color11[shift], color.new(color1[shift], i_oc1_bg_transp), _width, line.style_solid, xloc.bar_index))
util.remove_boxes(a, i_drawing_max, a_start, array.size(a) - a_start)
if access_shifted and _show_today
if i_candle_show_hl
n_hl := f_candle(_nx1, H0, _nx2, L0, color01, color0, _width, line.style_dotted, xloc.bar_index), box.delete(n_hl[1])
if i_candle_show_oc
n_oc := f_candle(_nx1, O0, _nx2, C0, color01, color0, _width, line.style_solid, xloc.bar_index), box.delete(n_oc[1])
else
if access_newonly or access_all
box.set_top(hl, H0)
box.set_bottom(hl, L0)
box.set_bgcolor(hl, color.new(color0, i_hl_bg_transp))
box.set_border_color(hl, color01)
box.set_top(oc, math.max(O0, C0))
box.set_bottom(oc, math.min(O0, C0))
box.set_bgcolor(oc, color.new(color0, i_oc0_bg_transp))
box.set_border_color(oc, color01)
if access_shifted and _show_today
box.set_right(oc, _x2)
box.set_right(hl, _x2)
box.set_left(n_oc, _nx1)
box.set_right(n_oc, _nx2)
box.set_top(n_oc, math.max(O0, C0))
box.set_bottom(n_oc, math.min(O0, C0))
box.set_bgcolor(n_oc, color.new(color0, i_oc0_bg_transp))
box.set_border_color(n_oc, color01)
box.set_left(n_hl, _nx1)
box.set_right(n_hl, _nx2)
box.set_top(n_hl, H0)
box.set_bottom(n_hl, L0)
box.set_bgcolor(n_hl, color.new(color0, i_hl_bg_transp))
box.set_border_color(n_hl, color01)
//////////
// MAIN //
[wopen, whigh, wlow, wclose] = request.security(syminfo.tickerid, '1W', [open[1], high[1], low[1], close[1]])
f_render_main (_htf, _trans, _btransp) =>
// for exports variables
var plot_o = 0.0, var plot_o0 = 0.0
var plot_c = 0.0, var plot_c0 = 0.0
var plot_h = 0.0, var plot_h0 = 0.0
var plot_l = 0.0, var plot_l0 = 0.0
var price_range = 0.0
var day = 0
var TD0 = 0
var TS0 = 0
var pvt_lines = array.new<line>(), var pvt_labels = array.new<label>(), var pvt_boxes = array.new<box>()
var pvt_lines_next = array.new<line>(), var pvt_labels_next = array.new<label>(), var pvt_boxes_next = array.new<box>()
var pvt_lines_past = array.new<line>(), var pvt_labels_past = array.new<label>(), var pvt_boxes_past = array.new<box>()
color0 = O0 < C0 ? color.new(c_bull, _trans) : color.new(c_bear, _trans)
color01 = O0 < C0 ? color.new(c_bull, _btransp) : color.new(c_bear, _btransp)
color1 = O1 < C1 ? color.new(c_bull, _trans) : color.new(c_bear, _trans)
color11 = O1 < C1 ? color.new(c_bull, _btransp) : color.new(c_bear, _btransp)
// Positions
//
// |----P----| |--------| |----N----|
// px1 px2 x1 x2 nx1 nx2
// pxc xc nxc
px1 = ta.valuewhen(htf_changed, bar_index, 1)
x1 = ta.valuewhen(htf_changed, bar_index, 0)
px2 = x1 - 1
pxc = math.round(math.avg(px2, px1))
x2 = (px2 - px1) + x1
xc = math.round(math.avg(x2, x1))
nx1 = (2 * x1) - px1
nx2 = (x2 - x1) + nx1
x2 := math.min(x2, bar_index + max_bars_count)
nx1 := math.min(nx1, bar_index + max_bars_count)
nx2 := math.min(nx2, bar_index + max_bars_count)
nxc = math.round(math.avg(nx2, nx1))
// t = Position.new(x1 , x2 )
// p = Position.new(px1, px2)
// n = Position.new(nx1, nx2)
four_days_ago = is_1min ? 0 : ((x1 - px1) * 4)
price_range_avg = f_pricerange_avg(price_range, x2 - x1)
//a = label.new(px1, close, 'px1', yloc=yloc.price), label.delete(a[1])
//b = label.new( x1, close, 'x1', yloc=yloc.price), label.delete(b[1])
//d = label.new( x2, close, 'x2', yloc=yloc.price), label.delete(d[1])
//c = label.new(nx1, close, 'nx1', yloc=yloc.price , style=label.style_label_up), label.delete(c[1])
//e = label.new(nx2, close, 'nx2', yloc=yloc.price), label.delete(e[1])
if htf_changed
price_range := (H1 - L1)
day := htf_is_intraday ? dayofweek(time, i_candle_label_tz) : na
TD0 := C0 > C0[four_days_ago] ? TD0 + 1 : 0
TS0 := C0 < C0[four_days_ago] ? TS0 + 1 : 0
if access_newonly or access_all or access_shifted
plot_o := O0[shift], plot_c := C0[shift]
plot_h := H0[shift], plot_l := L0[shift]
plot_o0 := O0, plot_c0 := C0
plot_h0 := H0, plot_l0 := L0
f_render_pivots(i_pivots_show, false, false, x1 , x2 , 0, pvt_lines, pvt_labels, pvt_boxes, false)
f_render_pivots(i_pivots_show and i_pivots_show_history, i_pivots_show_history, false, px1, px2, 1, pvt_lines_past, pvt_labels_past, pvt_boxes_past, false)
true
if (not i_candle_show)
line.new(px2, high, px2, low, extend=extend.both, color=color.new(ac.panda('lightgray'), 30), style=line.style_dotted)
else
if access_newonly or access_all
plot_o := O0, plot_c := C0
plot_h := H0, plot_l := L0
if access_shifted
f_render_pivots(i_pivots_show_forecast, false, true, nx1, nx2, 0, pvt_lines_next, pvt_labels_next, pvt_boxes_next, true)
true
TD1 = (C0 > C0[four_days_ago] ? TD0 + 1 : 0)
TS1 = (C0 < C0[four_days_ago] ? TS0 + 1 : 0)
f_render_wick(x1, x2, xc, px1, px2, pxc, nx1, nx2, nxc, color01, color11, i_candle_show_wick, i_candle_show_today)
f_render_divs(x1, x2, px1, px2, nx1, nx2, color01, color11, i_candle_wick_transp, i_tdiv_show, i_candle_show_today)
f_render_candles(x1, x2, px1, px2, nx1, nx2, color0, color01, color1, color11, i_candle_show, i_candle_show_today)
f_render_labels(_htf, x1, x2, px1, px2, nx1, nx2, color01, color11, price_range_avg, day, TD0, TS0, TD1, TS1, i_candle_label_show, i_candle_show_today)
[plot_epr_R1, plot_epr_S1, plot_epr_R2, plot_epr_S2, epr_over] = f_render_EPR(x1, x2, px1, px2, nx1, nx2, price_range_avg, i_epr_show)
if i_show_info_bar
info_bar_x = i_candle_show ? x2 + i_info_bar_placement : INFO_BAR_X1
info_bar_labels_1 = array.from(message_prev_open.get(langIndex), message_prev_high.get(langIndex), message_prev_low.get(langIndex), message_prev_close.get(langIndex))
info_bar_labels_2 = array.from(message_prev_week_open.get(langIndex), message_prev_week_high.get(langIndex), message_prev_week_low.get(langIndex), message_prev_week_close.get(langIndex))
f_render_info_bar(info_bar_x)
f_render_info_bar_00(info_bar_x, plot_epr_R1 - plot_epr_S1, math.avg(H0, L0))
f_render_info_bar_prev(info_bar_x, O1, H1, L1, C1, info_bar_labels_1, i_info_bar_show_prev_day)
f_render_info_bar_prev(info_bar_x, wopen, whigh, wlow, wclose, info_bar_labels_2, i_info_bar_show_prev_week)
f_render_info_bar_epr(info_bar_x, plot_epr_R1, plot_epr_S1, plot_epr_R2, plot_epr_S2)
f_render_info_bar_today(info_bar_x, O0, H0, L0, C0, color0)
[plot_o, plot_h, plot_l, plot_c, plot_o0, plot_h0, plot_l0, plot_c0, plot_epr_R1, plot_epr_S1, plot_epr_R2, plot_epr_S2, epr_over]
[o, h, l, c, o0, h0, l0, c0, R1, S1, R2, S2, epr_over] = f_render_main(htf, i_candle_bg_transp, i_candle_line_transp)
pp = math.avg(h, l, c)
///////////////
// Plotting
///////////////
plot(o, 'HTF Open' , linewidth=2, display=display.none)
plot(h, 'HTF High' , linewidth=2, display=display.none)
plot(l, 'HTF Low' , linewidth=2, display=display.none)
plot(c, 'HTF Close' , linewidth=2, display=display.none)
plot(i_epr_show and i_epr_developing ? math.avg(H0, L0) : na, 'EPR middle', linewidth=1, color=c_epr)
plot(i_epr_show and i_epr_developing ? R1 : na, 'EPR top' , linewidth=2, color=c_epr)
plot(i_epr_show and i_epr_developing ? S1 : na, 'EPR bottom' , linewidth=2, color=c_epr)
plotshape((not htf_changed) and ta.cross(o, close) ? o : na, 'Crossed open' , color=color.orange, style=shape.xcross, location=location.absolute, size=size.tiny, display=display.none)
plotshape((not htf_changed) and ta.cross(h, close) ? h : na, 'Crossed high' , color=color.orange, style=shape.xcross, location=location.absolute, size=size.tiny, display=display.none)
plotshape((not htf_changed) and ta.cross(l, close) ? l : na, 'Crossed low' , color=color.orange, style=shape.xcross, location=location.absolute, size=size.tiny, display=display.none)
plotshape((not htf_changed) and ta.cross(c, close) ? c : na, 'Crossed close', color=color.orange, style=shape.xcross, location=location.absolute, size=size.tiny, display=display.none)
plotshape((not htf_changed) and (i_candle_access == option_new or i_candle_access == option_all) and ta.change(h) > 0, 'New high', style=shape.labelup, color=color.blue, location=location.bottom, size=size.tiny, display=display.none) // Work on 'new only' or 'All'
plotshape((not htf_changed) and (i_candle_access == option_new or i_candle_access == option_all) and ta.change(l) < 0, 'New low', style=shape.labeldown, color=color.red, location=location.bottom, size=size.tiny, display=display.none) // Work on 'new only' or 'All'
///////////////////
// Message panel //
f_emojicolor (_v) =>
switch _v
icon_danger => ac.package(i_color_name, 'yellow')
=> i_msg_color
f_get_cal (_time, _lang, _tz) =>
mydate = dayofmonth(_time, _tz)
mydayofweek = dayofweek(_time, _tz)
myweekofmonth = str.tostring(math.floor((mydate + (6 - mydayofweek)) / 7 + 1))
en = dayOfWeek.get(mydayofweek, 0) + '. ' + str.format_time(_time, 'dd/MM/yyyy', _tz) + ' ' + myweekofmonth + text_w.get(0)
ja = str.format_time(_time, 'yyyy年MM月dd日', _tz) + '(' + dayOfWeek.get(mydayofweek, 1) + ')' + ' ' + myweekofmonth + text_w.get(1)
text_cal = Message.new(en, ja)
text_cal.get(langIndex)
a_table = array.new<string>()
a_icons = array.new<string>()
is_muted_info = counter < 10
msg_price = math.avg(open, close, hlc3)
var msg_prefix = access_shifted ? text_previous.get(langIndex) : ''
var msg_cross_high = Message.new('Price is crossing '+ msg_prefix +' High.', msg_prefix + '高値とクロス')
var msg_approach_high = Message.new('Price is approaching '+ msg_prefix + ' High.', msg_prefix + '高値にアプローチ')
var msg_cross_open = Message.new('Price is crossing '+ msg_prefix + ' Open.', msg_prefix + '始値とクロス')
var msg_approach_open = Message.new('Price is approaching '+ msg_prefix + ' Open.', msg_prefix + '始値にアプローチ')
var msg_cross_low = Message.new('Price is crossing '+ msg_prefix + ' Low.', msg_prefix + '安値とクロス')
var msg_approach_low = Message.new('Price is approaching '+ msg_prefix + ' Low.', msg_prefix + '安値にアプローチ')
var msg_cross_close = Message.new('Price is crossing '+ msg_prefix + ' Close.', msg_prefix + '終値とクロス')
var msg_approach_close = Message.new('Price is approaching '+ msg_prefix + ' Close.', msg_prefix + '終値にアプローチ')
var msg_cross_pp = Message.new('Price is crossing PP.', 'PPとクロス')
var msg_approach_pp = Message.new('Price is approaching PP.', 'PPにアプローチ')
var msg_epr = Message.new('The expected price range was broken.', '予想値幅を超えました')
if i_msg_show_info
if ta.cross(msg_price, h)
array.push(a_table, msg_cross_high.get(langIndex))
array.push(a_icons, icon_cross)
else if math.abs((h - msg_price) / msg_price) <= i_msg_thres
array.push(a_table, msg_approach_high.get(langIndex))
array.push(a_icons, icon_notif)
if ta.cross(msg_price, o)
array.push(a_table, msg_cross_open.get(langIndex))
array.push(a_icons, icon_cross)
else if math.abs((o - msg_price) / msg_price) <= i_msg_thres
array.push(a_table, msg_approach_open.get(langIndex))
array.push(a_icons, icon_notif)
if ta.cross(msg_price, l)
array.push(a_table, msg_cross_low.get(langIndex))
array.push(a_icons, icon_cross)
else if math.abs((l - msg_price) / msg_price) <= i_msg_thres
array.push(a_table, msg_approach_low.get(langIndex))
array.push(a_icons, icon_notif)
if (not is_muted_info) and ta.cross(msg_price, c)
array.push(a_table, msg_cross_close.get(langIndex))
array.push(a_icons, icon_cross)
else if (not is_muted_info) and math.abs((c - msg_price) / msg_price) <= i_msg_thres
array.push(a_table, msg_approach_close.get(langIndex))
array.push(a_icons, icon_notif)
if ta.cross(msg_price, pp)
array.push(a_table, msg_cross_pp.get(langIndex))
array.push(a_icons, icon_cross)
else if math.abs((pp - msg_price) / msg_price) <= i_msg_thres
array.push(a_table, msg_approach_pp.get(langIndex))
array.push(a_icons, icon_notif)
if i_msg_show_warn
if epr_over
array.push(a_table, msg_epr.get(langIndex))
array.push(a_icons, icon_danger)
tbl = table.new(i_placement, 3, 4)
f_timeformat (_v) => _v > 9 ? str.tostring(_v) : '0'+str.tostring(_v)
f_insert_row (_tbl, _y, _msg, _text_color, _bgcolor) =>
table.cell(_tbl, 0, _y, _msg, text_color=_text_color, text_size=i_msg_size, text_valign=text.align_top, text_halign=text.align_left, bgcolor=_bgcolor)
table.merge_cells(_tbl, 0, _y, 2, _y)
if i_show_messagebox and barstate.islast
y = 0
if array.size(a_table) > 0
for i = 0 to array.size(a_table) - 1
y := i
msg = array.get(a_table, i)
icon = array.get(a_icons, i)
mytime = icon == icon_calendar ? timenow : time
now = f_timeformat(hour(mytime, i_msg_tz)) + ':' + f_timeformat(minute(mytime, i_msg_tz))
now := icon == icon_calendar ? '' : now
table.cell(tbl, 0, y, now, text_color=i_msg_color, text_size=i_msg_size, text_valign=text.align_top)
table.cell(tbl, 1, y, icon, text_color=f_emojicolor(icon), text_size=i_msg_size, text_valign=text.align_top)
table.cell(tbl, 2, y, msg, text_color=i_msg_color, text_size=i_msg_size, text_valign=text.align_top, text_halign=text.align_left)
if i_msg_show_cal
y := y + 1
msg = f_get_cal(timenow, i_msg_lang, i_msg_tz)
f_insert_row(tbl, y, msg, i_msg_color, c_none)
if is_1min
y := y + 1
msg = icon_danger + ' ' + f_lang(i_msg_lang, 'It doesn\'t display correctly on the 1 min.', '1分足では正常に表示できません')
f_insert_row(tbl, y, msg, ac.package(i_color_name, 'red'), color.new(ac.package(i_color_name, 'black'), 10))
plotshape(i_msg_dot and math.abs((o - msg_price) / msg_price) <= i_msg_thres ? o : na, 'Message test (Open)', color=ac.tradingview('orange'), style=shape.circle, size=size.tiny, location=location.absolute, display=display.none)
plotshape(i_msg_dot and math.abs((h - msg_price) / msg_price) <= i_msg_thres ? h : na, 'Message test (High)', color=ac.tradingview('orange'), style=shape.circle, size=size.tiny, location=location.absolute, display=display.none)
plotshape(i_msg_dot and math.abs((l - msg_price) / msg_price) <= i_msg_thres ? l : na, 'Message test (Low)', color=ac.tradingview('orange'), style=shape.circle, size=size.tiny, location=location.absolute, display=display.none)
plotshape(i_msg_dot and math.abs((c - msg_price) / msg_price) <= i_msg_thres and (not is_muted_info) ? c : na, 'Message test (Close)', color=ac.tradingview('orange'), style=shape.circle, size=size.tiny, location=location.absolute, display=display.none)
plotshape(i_msg_dot and math.abs((pp- msg_price) / msg_price) <= i_msg_thres ? pp: na, 'Message test (PP)', color=ac.tradingview('orange'), style=shape.circle, size=size.tiny, location=location.absolute, display=display.none)
plot(h + (msg_price * i_msg_thres), display=display.none, editable=false)
|
Levels Of Greed [AstrideUnicorn] | https://www.tradingview.com/script/Mu6dpueK-Levels-Of-Greed-AstrideUnicorn/ | AstrideUnicorn | https://www.tradingview.com/u/AstrideUnicorn/ | 99 | study | 5 | MPL-2.0 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AstrideUnicorn
//@version=5
indicator("Levels Of Greed", overlay=true)
// Define the source price series for the indicator calculations
source = close
// The indicator inputs
length = input.int(defval=70, minval=30, maxval=150, title = "Window",
tooltip="Higher values are better for measuring longer up-trends.")
stability = input.int(defval=20, minval=10, maxval=20,
title = "Levels Stability", tooltip="The higher the value is,
the more stable and long the levels are, but the lag slightly increases.")
mode = input.string(defval="Cool Guys Mode", options=['Cool Guys Mode','Serious Guys Mode'])
// Calculate the current base level as the recent lowest price
current_low= ta.lowest(high,length)
// Calculate the rolling standard deviation of the source price
stdev = ta.stdev(source,4*length)
// Define the condition that an up-move has started (the price is above the latest
// low for a specified amount of bars)
condition1 = ta.highest(current_low,stability)
== ta.lowest(current_low,stability)
// During a decline don't update the rolling standard deviation on each bar,
// to fix the distance between the levels of fear
if condition1
stdev:=stdev[1]
// Calculate the levels of fear
greed_level_1 = current_low + 1*stdev
greed_level_2 = current_low + 2*stdev
greed_level_3 = current_low + 3*stdev
greed_level_4 = current_low + 4*stdev
greed_level_5 = current_low + 5*stdev
greed_level_6 = current_low + 6*stdev
greed_level_7 = current_low + 7*stdev
// Store the previous value of base level
current_low_previous = ta.valuewhen(condition1==true, current_low, 1)
// Define the conditional color of the fear levels to make them visible only
//during a decline
greed_levels_color = condition1?color.green:na
// Plot the levels of fear
plot(greed_level_1, color= greed_levels_color, linewidth=1)
plot(greed_level_2, color= greed_levels_color, linewidth=2)
plot(greed_level_3, color= greed_levels_color, linewidth=3)
plot(greed_level_4, color= greed_levels_color, linewidth=4)
plot(greed_level_5, color= greed_levels_color, linewidth=5)
plot(greed_level_6, color= greed_levels_color, linewidth=6)
plot(greed_level_7, color= greed_levels_color, linewidth=7)
// Prolongate the levels of fear when a decline is over and a rebound has started
greed_levels_color_previous = condition1==false?color.green:na
plot(ta.valuewhen(condition1==true, greed_level_1, 1),
color= greed_levels_color_previous, linewidth=1)
plot(ta.valuewhen(condition1==true, greed_level_2, 1),
color= greed_levels_color_previous, linewidth=2)
plot(ta.valuewhen(condition1==true, greed_level_3, 1),
color= greed_levels_color_previous, linewidth=3)
plot(ta.valuewhen(condition1==true, greed_level_4, 1),
color= greed_levels_color_previous, linewidth=4)
plot(ta.valuewhen(condition1==true, greed_level_5, 1),
color= greed_levels_color_previous, linewidth=5)
plot(ta.valuewhen(condition1==true, greed_level_6, 1),
color= greed_levels_color_previous, linewidth=6)
plot(ta.valuewhen(condition1==true, greed_level_7, 1),
color= greed_levels_color_previous, linewidth=7)
// Condition that defines the position of the fear levels labels: on the fourth
// bar after a new set of fear levels is formed.
draw_label_condition = ta.barssince(condition1[1]==false and condition1==true)==3
// Condition that checks if the mode for the labels is the Cool Guys Mode
coolmode = mode == "Cool Guys Mode"
// Plot the labels if the Cool Guys Mode is selected
plotchar(coolmode and draw_label_condition?greed_level_1:na,location=location.absolute, char = "😌", size=size.small)
plotchar(coolmode and draw_label_condition?greed_level_2:na,location=location.absolute, char = "😋", size=size.small)
plotchar(coolmode and draw_label_condition?greed_level_3:na,location=location.absolute, char = "😃", size=size.small)
plotchar(coolmode and draw_label_condition?greed_level_4:na,location=location.absolute, char = "😮", size=size.small)
plotchar(coolmode and draw_label_condition?greed_level_5:na,location=location.absolute, char = "😍", size=size.small)
plotchar(coolmode and draw_label_condition?greed_level_6:na,location=location.absolute, char = "🤪", size=size.small)
plotchar(coolmode and draw_label_condition?greed_level_7:na,location=location.absolute, char = "🤑", size=size.small)
// Plot the labels if the Serious Guys Mode is selected
plotchar(coolmode==false and draw_label_condition?greed_level_1:na,location=location.absolute, char = "1", size=size.small)
plotchar(coolmode==false and draw_label_condition?greed_level_2:na,location=location.absolute, char = "2", size=size.small)
plotchar(coolmode==false and draw_label_condition?greed_level_3:na,location=location.absolute, char = "3", size=size.small)
plotchar(coolmode==false and draw_label_condition?greed_level_4:na,location=location.absolute, char = "4", size=size.small)
plotchar(coolmode==false and draw_label_condition?greed_level_5:na,location=location.absolute, char = "5", size=size.small)
plotchar(coolmode==false and draw_label_condition?greed_level_6:na,location=location.absolute, char = "6", size=size.small)
plotchar(coolmode==false and draw_label_condition?greed_level_7:na,location=location.absolute, char = "7", size=size.small)
|
Subsets and Splits