A
A
0
at https://mozilla.org/MPL/2.0/
// © Deewithme
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0
at https://mozilla.org/MPL/2.0/
// © Deewithme
// This source code is subject to the terms of the Mozilla Public License 2.0 at
https://mozilla.org/MPL/2.0/
// © Pmgjill
//@version=5
indicator("FluidTrades - SMC", overlay = true, max_labels_count = 500,
max_boxes_count = 500, max_lines_count = 500, max_bars_back = 1000)
lbLeft = 20
lbRight = 20
//FUNCTIONS
lineStyle(s) =>
if s == 'Solid'
line.style_solid
else if s == 'Dotted'
line.style_dotted
else
line.style_dashed
//VARS
var int bullSignalIndex = 0
var int bearSignalIndex = 0
//CALCULATIONS
pLow = ta.pivotlow(low, lbLeft, lbRight)
pHigh = ta.pivothigh(high, lbLeft, lbRight)
lp = ta.lowest(low, lbLeft)
hp = ta.highest(high, lbLeft)
bullishSFP = low < pLowVal and close > pLowVal and open > pLowVal and low == lp and
lowestClose >= pLowVal
bearishSFP = high > pHighVal and close < pHighVal and open < pHighVal and high ==
hp and highestClose <= pHighVal
bullCond = bullishSFP[3] and (close > pLowVal) and (close[1] > pLowVal[1]) and
(close[2] > pLowVal[2]) and bar_index >= bullSignalIndex + cooldownPeriod
bearCond = bearishSFP[3] and (close < pHighVal) and (close[1] < pHighVal[1]) and
(close[2] < pHighVal[2]) and bar_index >= bearSignalIndex + cooldownPeriod
if bearCond
bearSignalIndex := bar_index
bearLine := line.new(prevHighIndex, pHighVal, bar_index-3, pHighVal,
color=bearColor, width=bearWidth, style=lineStyle(bearStyle))
if array.size(swingHighArr) >= 3
label.delete(array.shift(swingHighArr))
label.delete(array.shift(swingHighTextArr))
if array.size(swingLowArr) >= 3
label.delete(array.shift(swingLowArr))
label.delete(array.shift(swingLowTextArr))
//PLOTS
plotshape(bullCond, text='LIQUZ', color=bullColor, textcolor=bullColor,
location=location.belowbar, offset = -3)
plotshape(bearCond, text='LIQUZ', color=bearColor, textcolor=bearColor,
location=location.abovebar, offset = -3)
//ALERTS
alertcondition(bullishSFP, title='Bullish Sweep', message='{{ticker}} Bullish
Sweep, Price:{{close}}')
alertcondition(bearishSFP, title='Bearish Sweep', message='{{ticker}} Bearish
Sweep, Price:{{close}}')
// Functions
supertrend(_src, factor, atrLen) =>
atr = ta.atr(atrLen)
upperBand = _src + factor * atr
lowerBand = _src - factor * atr
prevLowerBand = nz(lowerBand[1])
prevUpperBand = nz(upperBand[1])
lowerBand := lowerBand > prevLowerBand or close[1] < prevLowerBand ?
lowerBand : prevLowerBand
upperBand := upperBand < prevUpperBand or close[1] > prevUpperBand ?
upperBand : prevUpperBand
int direction = na
float superTrend = na
prevSuperTrend = superTrend[1]
if na(atr[1])
direction := 1
else if prevSuperTrend == prevUpperBand
direction := close > upperBand ? -1 : 1
else
direction := close < lowerBand ? 1 : -1
superTrend := direction == -1 ? lowerBand : upperBand
[superTrend, direction]
lr_slope(_src, _len) =>
x = 0.0, y = 0.0, x2 = 0.0, xy = 0.0
for i = 0 to _len - 1
val = _src[i]
per = i + 1
x += per
y += val
x2 += per * per
xy += val * per
_slp = (_len * xy - x * y) / (_len * x2 - x * x)
_avg = y / _len
_int = _avg - _slp * x / _len + _slp
[_slp, _avg, _int]
lr_dev(_src, _len, _slp, _avg, _int) =>
upDev = 0.0, dnDev = 0.0
val = _int
for j = 0 to _len - 1
price = high[j] - val
if price > upDev
upDev := price
price := val - low[j]
if price > dnDev
dnDev := price
price := _src[j]
val += _slp
[upDev, dnDev]
// Get Components
ocAvg = math.avg(open, close)
sma1 = ta.sma(close, 5)
sma2 = ta.sma(close, 6)
sma3 = ta.sma(close, 7)
sma4 = ta.sma(close, 8)
sma5 = ta.sma(close, 9)
sma6 = ta.sma(close, 10)
sma7 = ta.sma(close, 11)
sma8 = ta.sma(close, 12)
sma9 = ta.sma(close, 13)
//@version=5
//ndicator("Simplealgo.io v5 "
//, overlay = true
/// max_labels_count = 500
//, max_lines_count = 500
// max_boxes_count = 500// max_bars_back = 500)
//
===================================================================================
====
// MODULO DE SEÑALES PARA MEGA POWER
//
===================================================================================
====
//@version=5
//indicator("Trendlines with Breaks [LuxAlgo]", "LuxAlgo - Trendlines with Breaks",
overlay = true)
//------------------------------------------------------------------------------
//Settings
//-----------------------------------------------------------------------------{
length = input.int(14, 'Swing Detection Lookback')
mult = input.float(1., 'Slope', minval = 0, step = .1)
calcMethod = input.string('Atr', 'Slope Calculation Method', options =
['Atr','Stdev','Linreg'])
backpaint = input(true, tooltip = 'Backpainting offset displayed elements in the
past. Disable backpainting to see real time information returned by the
indicator.')
//Style
upCss = input.color(color.teal, 'Up Trendline Color', group = 'Style')
dnCss = input.color(color.red, 'Down Trendline Color', group = 'Style')
showExt = input(true, 'Show Extended Lines')
//-----------------------------------------------------------------------------}
//Calculations
//-----------------------------------------------------------------------------{
var upper = 0.
var lower = 0.
var slope_ph = 0.
var slope_pl = 0.
n = bar_index
src = close
var upos = 0
var dnos = 0
upos := phh ? 0 : close > upper - slope_ph * length ? 1 : upos
dnos := pll ? 0 : close < lower + slope_pl * length ? 1 : dnos
//-----------------------------------------------------------------------------}
//Extended Lines
//-----------------------------------------------------------------------------{
var uptl = line.new(na,na,na,na, color = upCss, style = line.style_dashed, extend
= extend.right)
var dntl = line.new(na,na,na,na, color = dnCss, style = line.style_dashed, extend
= extend.right)
//-----------------------------------------------------------------------------}
//Plots
//-----------------------------------------------------------------------------{
plot(backpaint ? upper : upper - slope_ph * length, 'Upper', color = phh ? na :
upCss, offset = -offset)
plot(backpaint ? lower : lower + slope_pl * length, 'Lower', color = pll ? na :
dnCss, offset = -offset)
//Breakouts
plotshape(upos > upos[1] ? low : na, "Upper Break"
, shape.labelup
, location.absolute
, upCss
, text = "B"
, textcolor = color.white
, size = size.tiny)
//-----------------------------------------------------------------------------}
//Alerts
//-----------------------------------------------------------------------------{
//SETTINGS
//
box_ob = input.bool(false, title = 'Toggle Order Block', group = 'On & Off
functionality',inline = 'overlayLine2')
box_hide_gray = input.bool(true, title = 'Hide gray boxes', group = 'On & Off
functionality',inline = 'overlayLine2')
trendTable = input.bool(true, title = 'Show Trend Table', group = 'On & Off
functionality',inline = 'overlayLine5')
trendCalc = input.string(defval = "EMA", title = "Trend Mode",
options=["Supertrend", "EMA"], group = 'On & Off functionality',inline =
'overlayLine5')
showDXY = input.bool(false, title = 'Show DXY', group = 'On & Off
functionality',inline = 'overlayLine5')
//
//END SETTINGS
//
//
//FUNCTIONS
//
else if swing_type == -1
if array.get(array, 0) >= array.get(array, 1)
label_text := 'HL'
else
label_text := 'LL'
label.new(bar_index - swing_length, array.get(array,0), text = label_text,
style=label.style_label_up, textcolor = swing_type_color, color =
color.new(swing_type_color, 100), size = size.tiny)
atr_threshold = atr * 2
okay_to_draw = true
for i = 0 to array.size(box_array) - 1
top = box.get_top(array.get(box_array, i))
bottom = box.get_bottom(array.get(box_array, i))
poi = (top + bottom) / 2
if box_type == 1
box_top := array.get(value_array, 0)
box_bottom := box_top - atr_buffer
poi := (box_top + box_bottom) / 2
else if box_type == -1
box_bottom := array.get(value_array, 0)
box_top := box_bottom + atr_buffer
poi := (box_top + box_bottom) / 2
//delete oldest box, and then create a new box and add it to the array
if box_type == 1 and okay_to_draw and enableDS
box.delete( array.get(box_array, array.size(box_array) - 1) )
f_array_add_pop(box_array, box.new( left = box_left, top = box_top, right =
box_right, bottom = box_bottom, border_color = supply_outline_color,
bgcolor = supply_color, extend = extend.right, text = 'SUPPLY',
text_halign = text.align_center, text_valign = text.align_center, text_color =
poi_label_color, text_size = size.small, xloc = xloc.bar_index))
if zone_type == 1
for i = 0 to array.size(box_array) - 1
level_to_break = box.get_top(array.get(box_array,i))
// if ta.crossover(close, level_to_break)
if close >= level_to_break
copied_box = box.copy(array.get(box_array,i))
f_array_add_pop(bos_array, copied_box)
mid = (box.get_top(array.get(box_array,i)) +
box.get_bottom(array.get(box_array,i))) / 2
box.set_top(array.get(bos_array,0), mid)
box.set_bottom(array.get(bos_array,0), mid)
box.set_extend( array.get(bos_array,0), extend.none)
box.set_right( array.get(bos_array,0), bar_index)
box.set_text( array.get(bos_array,0), 'BOS' )
box.set_text_color( array.get(bos_array,0), bos_label_color)
box.set_text_size( array.get(bos_array,0), size.small)
box.set_text_halign( array.get(bos_array,0), text.align_center)
box.set_text_valign( array.get(bos_array,0), text.align_center)
box.delete(array.get(box_array, i))
box.delete(array.get(label_array, i))
if zone_type == -1
for i = 0 to array.size(box_array) - 1
level_to_break = box.get_bottom(array.get(box_array,i))
// if ta.crossunder(close, level_to_break)
if close <= level_to_break
copied_box = box.copy(array.get(box_array,i))
f_array_add_pop(bos_array, copied_box)
mid = (box.get_top(array.get(box_array,i)) +
box.get_bottom(array.get(box_array,i))) / 2
box.set_top(array.get(bos_array,0), mid)
box.set_bottom(array.get(bos_array,0), mid)
box.set_extend( array.get(bos_array,0), extend.none)
box.set_right( array.get(bos_array,0), bar_index)
box.set_text( array.get(bos_array,0), 'BOS' )
box.set_text_color( array.get(bos_array,0), bos_label_color)
box.set_text_size( array.get(bos_array,0), size.small)
box.set_text_halign( array.get(bos_array,0), text.align_center)
box.set_text_valign( array.get(bos_array,0), text.align_center)
box.delete(array.get(box_array, i))
box.delete(array.get(label_array, i))
for i = 0 to array.size(box_array) - 1
box.set_right(array.get(box_array, i), bar_index + 100)
//
//END FUNCTIONS
//
//
//CALCULATIONS
//
// CALCULATE ATR
atr = ta.atr(50)
f_extend_box_endpoint(current_supply_box)
f_extend_box_endpoint(current_demand_box)
//ZIG ZAG
h = ta.highest(high, swing_length * 2 + 1)
l = ta.lowest(low, swing_length * 2 + 1)
f_isMin(len) =>
l == low[len]
f_isMax(len) =>
h == high[len]
f_drawLine() =>
_li_color = show_zigzag ? zigzag_color : color.new(#ffffff,100)
line.new(timeHigh - swing_length, lastHigh, timeLow - swing_length, lastLow,
xloc.bar_index, color=_li_color, width=2)
if dirUp
if f_isMin(swing_length) and low[swing_length] < lastLow
lastLow := low[swing_length]
timeLow := bar_index
line.delete(li)
li := f_drawLine()
li
if not dirUp
if f_isMax(swing_length) and high[swing_length] > lastHigh
lastHigh := high[swing_length]
timeHigh := bar_index
line.delete(li)
li := f_drawLine()
li
if f_isMin(swing_length) and low[swing_length] < lastHigh
lastLow := low[swing_length]
timeLow := bar_index
dirUp := true
li := f_drawLine()
if f_isMax(swing_length) and high[swing_length] > lastLow
lastHigh := high[swing_length]
timeHigh := bar_index
dirUp := false
li := f_drawLine()
li
// if barstate.islast
// label.new(x = bar_index + 10, y = close[1], text =
str.tostring( array.size(current_supply_poi) ))
// label.new(x = bar_index + 20, y = close[1], text =
str.tostring( box.get_bottom( array.get(current_supply_box, 0))))
// label.new(x = bar_index + 30, y = close[1], text =
str.tostring( box.get_bottom( array.get(current_supply_box, 1))))
// label.new(x = bar_index + 40, y = close[1], text =
str.tostring( box.get_bottom( array.get(current_supply_box, 2))))
// label.new(x = bar_index + 50, y = close[1], text =
str.tostring( box.get_bottom( array.get(current_supply_box, 3))))
// label.new(x = bar_index + 60, y = close[1], text =
str.tostring( box.get_bottom( array.get(current_supply_box, 4))))
// VWAP
// showVWAP = input(true, "on/off VWAP")
// Input options
averageData = input.source(close, title="Average Data Source")
// Calculate the volume-weighted average price and its 'noise' bands
vwapData = ta.vwap(averageData)
// Plot the average and its band
plot(showVWAP ? vwapData : na, color=color.red, title="VWAP",style =
plot.style_circles)
// EMA
is_newbar_(res) =>
ta.change(time(res)) != 0
in_session = not na(t)
is_first = in_session and not in_session[1]
orb_high = float(na)
orb_low = float(na)
if is_first
orb_high := high
orb_low := low
orb_low
else
orb_high := orb_high[1]
orb_low := orb_low[1]
orb_low
if high > orb_high and in_session
orb_high := high
orb_high
if low < orb_low and in_session
orb_low := low
orb_low
//Volume Profile
//.....................................................//
// Functions
-----------------------------------------------------------------------------------
//
//
-----------------------------------------------------------------------------------
----------- //
//
-----------------------------------------------------------------------------------
----------- //
// Volume Profile (Price by Volume) / Volume Histogram
------------------------------------------ //
if array.size(a_histogram) > 0
for i = 1 to array.size(a_histogram)
line.delete(array.shift(a_histogram))
if priceLevels
f_drawLabelX(bar_index + (profilePlacement == 'Right' ? profileWidth +
horizontalOffset : 0), priceHighest, str.tostring(priceHighest, format.mintick),
xloc.bar_index, yloc.price, color.new(upVolumeColor , 89), profilePlacement ==
'Left' and volumePlacement == 'Top' ? label.style_label_left :
label.style_label_down, upVolumeColor , size.normal, text.align_left, 'Profile
High - during last ' + str.tostring(lookbackLength) + ' bars\n %' +
str.tostring((priceHighest - priceLowest) / priceLowest * 100, '#.##') + ' higher
than the Profile Low')
f_drawLabelX(bar_index + (profilePlacement == 'Right' ? profileWidth +
horizontalOffset : 0), priceLowest , str.tostring(priceLowest , format.mintick),
xloc.bar_index, yloc.price, color.new(downVolumeColor, 89), profilePlacement ==
'Left' and volumePlacement == 'Bottom' ? label.style_label_left :
label.style_label_up , downVolumeColor, size.normal, text.align_left, 'Profile Low
- during last ' + str.tostring(lookbackLength) + ' bars\n %' +
str.tostring((priceHighest - priceLowest) / priceHighest * 100, '#.##') + ' lower
than the Profile High')
if volumeMA
array.push(a_histogram, line.new(bar_index[barIndex],
(volumePlacement == 'Top' ? priceHighest * (1 + priceChangeRate * .05) :
priceLowest * (1 - priceChangeRate * .05)) * (1 + (volumePlacement == 'Top' ? 1 :
-1) * nzVolume[barIndex] / volumeHighest * priceChangeRate / volumeHistHight /
volumeMARate[barIndex]), bar_index[barIndex + 1], (volumePlacement == 'Top' ?
priceHighest * (1 + priceChangeRate * .05) : priceLowest * (1 - priceChangeRate
* .05)) * (1 + (volumePlacement == 'Top' ? 1 : -1) * nzVolume[barIndex + 1] /
volumeHighest * priceChangeRate / volumeHistHight / volumeMARate[barIndex + 1]),
xloc.bar_index, extend.none, volumeMAColor, line.style_solid, 2))
if pointOfControl
array.push(a_profile, box.new(bar_index - lookbackLength + 1, priceLowest +
(array.indexof(volumeStorageT, array.max(volumeStorageT)) + .40) * priceStep,
bar_index + (profilePlacement == 'Right' ? profileWidth : 0), priceLowest +
(array.indexof(volumeStorageT, array.max(volumeStorageT)) + .60) * priceStep,
pocColor, bgcolor = pocColor ))
if priceLevels
f_drawLabelX(bar_index + (profilePlacement == 'Right' ?
horizontalOffset + 5 : 7), priceLowest + (array.indexof(volumeStorageT,
array.max(volumeStorageT)) + .5) * priceStep, str.tostring(priceLowest +
(array.indexof(volumeStorageT, array.max(volumeStorageT)) + .5) * priceStep,
format.mintick), xloc.bar_index, yloc.price, color.new(pocColor, 89),
(profilePlacement == 'Right' ? label.style_label_up : label.style_label_left),
color.new(pocColor, 0), size.normal, text.align_left, 'Point Of Control Price')
if profileDisplay == 'Up/Down'
startBoxIndex := profilePlacement == 'Right' ? bar_index + profileWidth
+ horizontalOffset - int(array.get(volumeStorageB, level) /
array.max(volumeStorageB) * (profileWidth - 9) / 2) : bar_index - lookbackLength +
1
endBoxIndex := profilePlacement == 'Right' ? bar_index + profileWidth
+ horizontalOffset: startBoxIndex + int( array.get(volumeStorageB, level) /
array.max(volumeStorageB) * (profileWidth - 9) / 2)
array.push(a_profile, box.new(startBoxIndex, priceLowest + (level +
0.1) * priceStep, endBoxIndex, priceLowest + (level + 0.9) * priceStep,
upVolumeColor, bgcolor = upVolumeColor ))
if bullBearStr
bullBearPower = 2 * array.get(volumeStorageB, level) -
array.get(volumeStorageT, level)
startBoxIndex := profilePlacement == 'Right' ? bar_index + profileWidth
+ 1 + horizontalOffset + (bullBearPower > 0 ? 1 : -1) * int(bullBearPower /
array.max(volumeStorageT) * (profileWidth - 9) * 1.75) : bar_index - lookbackLength
endBoxIndex := profilePlacement == 'Right' ? bar_index + profileWidth
+ 1 + horizontalOffset: startBoxIndex + (bullBearPower > 0 ? -1 : 1) *
int(bullBearPower / array.max(volumeStorageT) * (profileWidth - 9) * 1.75 )
array.push(a_profile, box.new(startBoxIndex, priceLowest + (level +
0.1) * priceStep, endBoxIndex, priceLowest + (level + 0.9) * priceStep,
bullBearPower > 0 ? bbStrUpColor : bbStrDownColor, bgcolor = bullBearPower > 0 ?
bbStrUpColor : bbStrDownColor ))
// What's the accuracy I can expect from this version of the indicator?
// I'd say it's about 95% the same as the one you would pay
//ORDER BLOCK
// box_ob = input.bool(true, "Toggle Order Block", group="ORDER BLOCK")
// box_hide_gray = input.bool(true, "Hide gray boxes", group="ORDER BLOCK")
bos_type = input.string("Close and Open", "MSB trigger", ["High and Low",
"Close and Open"], group="ORDER BLOCK")
box_sv = input.bool(true, "Plot Order Block boxes", group="ORDER BLOCK")
box_test_delay = input.int(3, "Delay to count test of Order Block box", 1,
group="ORDER BLOCK")
box_fill_delay = input.int(3, "Delay to count fill of Order Block box", 1,
group="ORDER BLOCK")
box_test_sv = input.bool(true, "Dim tested Order Block boxes", group="ORDER
BLOCK")
box_stop_sv = input.bool(true, "Stop plotting filled Order Block boxes",
group="ORDER BLOCK")
// Get components
// Colors
green = #00DD00, green50 = color.new(green, 50), green20 = color.new(green,
80)
red = #DD0000, red50 = color.new(red, 50), red20 = color.new(red, 80)
silver = #B2B5BE, silver50 = color.new(silver, 50), silver20 = color.new(silver,
80)
// Plots
//////////////////////////////////////////////////////////////////////
// //
// REVISION HISTORY //
// v 1.0 Initial release //
// v 1.1 Added interface elements and refactored code //
// v. 1.2 Added ability to set EMA length //
// //
//////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
/////////////////
//
//
// This indicator is an English version of the "Mtf Supertrend Table"
//
// coded by FxTraderProAsistan. Credit goes to him. I have
//
// modified this version for my own needs, in the English language.
//
// Future enhancements will include alerts to changes in
//
// directions on the time frames specified.
//
//
//
///////////////////////////////////////////////////////////////////////////////////
/////////////////
// Statistics Table
// --------
grp2 = 'Trend Table'
// trendTable = input(true, 'Show Trend Table', group=grp2)
// Dashboard Settings
grp3 = 'Table Display'
dashColor = input.color(color.new(#00b2ff,0) , 'Background Color ',
group=grp3)
upColor = input.color(color.green , 'Up Trend Color ', group=grp3)
downColor = input.color(color.red , 'Down Trend Color ', group=grp3)
TablePos = input.string('Bottom Right', 'Table Position', ['Top Right', 'Top
Center', 'Middle Right', 'Bottom Left',"Bottom Right"], group=grp3)
TablePosTextCol = input.color(color.black, 'Text Color', group=grp3)
//------------------------
grp4 = 'SuperTrend Settings'
atrPeriod = input(10, "ATR Length", group = grp4)
factor = input.float(3.0, "Factor", step = 0.01, group = grp4)
conditionSuper = 0.0
// EMA Calculation
is20EMAHigherThan50EMA() =>
ema20 = ta.ema(close, fastEMA)
ema50 = ta.ema(close, slowEMA)
ema20 > ema50 ? -1 : 1
if trendCalc == "EMA"
emadirection = is20EMAHigherThan50EMA()
conditionSuper := emadirection < 0 ? 1 : emadirection > 0 ? -1 : na
functionSuper()=>
conditionSuper
if na(containsLetters)
if str.tonumber(timeframe) % 60 == 0
result = "H" + str.tostring(str.tonumber(timeframe) / 60)
else
result = "M" + str.tostring(str.tonumber(timeframe))
else
result = containsLetters
fTable(colNumber,times,symbol )=>
// Depending upon user input, use the appropriate calculation for newSuper
(Supertrend)
newSuper = request.security(symbol, times, functionSuper())
newSuperDirection = newSuper == 1 ? " Up " : newSuper == -1 ? "Down" : na
superColor=functionSuperColor(newSuperDirection)
if trendTable
table.cell(SuperTrendTable, 0, 0, "TimeFrame" ,
text_color=TablePosTextCol, text_size=textSize, bgcolor=dashColor)
table.cell(SuperTrendTable, 0, 1, syminfo.ticker,
text_color=TablePosTextCol, text_size=textSize, bgcolor=dashColor)
if symbol != "DXY"
table.cell(SuperTrendTable,colNumber, 0, tfDes ,
text_color=TablePosTextCol, text_size=textSize, bgcolor=dashColor)
table.cell(SuperTrendTable,colNumber, 1, newSuperDirection,
text_color=TablePosTextCol, text_size=textSize, bgcolor=superColor, tooltip =
str.tostring(symbol))
if showDXY and symbol == "DXY"
table.cell(SuperTrendTable, 0, 3, "DXY" ,
text_color=TablePosTextCol, text_size=textSize, bgcolor=dashColor)
table.cell(SuperTrendTable,colNumber, 3, newSuperDirection,
text_color=TablePosTextCol, text_size=textSize, bgcolor=superColor, tooltip =
str.tostring(symbol))
symbol = syminfo.tickerid
dxy = syminfo.ticker("TVC:DXY")
if showtimes1
fTable(1,times1, symbol)
if showtimes2
fTable(2,times2, symbol)
if showtimes3
fTable(3,times3, symbol)
if showtimes4
fTable(4,times4, symbol)
if showtimes5
fTable(5,times5, symbol)
if showtimes6
fTable(6,times6, symbol)
//general
f_barssince(_cond, _count) =>
_barssince = bar_index - ta.valuewhen(_cond, bar_index, _count)
_barssince
// Trendlines
gr5 = 'Trendlines'
showPriceTl = false
newestTL = true
newestBreak = true
// periodlen = input.string('Adaptive', 'Trendline Term', ['Long Term', 'Short
Term','Adaptive'])
period = (periodlen == 'Adaptive' ? 30 : periodlen == 'Long Term' ? 40 : periodlen
== 'Short Term' ? 20 : 0)
//period = input(30, 'Trendline Period')
srcI = input.string('Wick', 'TrendLine Source', ['Close Body', 'Wick'])
srcL = srcI=='Wick'? low : close
srcH = srcI=='Wick'? high : close
lStyleI = input.string('Solid', 'TrendLine Style', ['Solid', 'Dashed',
'Dotted'])
y2_mult = 1
lStyle = lStyleI=='Solid'? line.style_solid : lStyleI=='Dashed'?
line.style_dashed : line.style_dotted
lWidth = input(1, 'TrendLine Width')
lColor = color.blue
supTextCol = color.red
resTextCol = color.blue
truncate(number) =>
factor = math.pow(10, dec)
int(number * factor) / factor
x1 = ta.valuewhen(cond_, time[x1Bar_], 0)
x2 = ta.valuewhen(cond_, time[x2Bar_], 0)
y1 = ta.valuewhen(cond_, y1Val_, 0)
y2 = ta.valuewhen(cond_, y2Val_, 0)
slope_ = ta.valuewhen(cond_, (y2-y1)/(x2-x1), 0)
a_trendline
currentPrice
find_loc(strength) =>
ret = array.size(sr_strength)
for i = ret > 0 ? array.size(sr_strength) - 1 : na to 0 by 1
if strength <= array.get(sr_strength, i)
break
ret := i
ret
ret
if phsa or plsa
//because of new calculation, remove old S/R levels
array.clear(sr_up_level)
array.clear(sr_dn_level)
array.clear(sr_strength)
//find S/R zones
for x = 0 to array.size(pivotvals) - 1 by 1
[hi, lo, strength] = get_sr_vals(x)
if check_sr(hi, lo, strength)
loc = find_loc(strength)
// if strength is in first levels sr then insert it to the arrays
if loc < levels and strength >= min_strength
array.insert(sr_strength, loc, strength)
array.insert(sr_up_level, loc, hi)
array.insert(sr_dn_level, loc, lo)
// keep size of the arrays = 5
if array.size(sr_strength) > levels
array.pop(sr_strength)
array.pop(sr_up_level)
array.pop(sr_dn_level)
for x = 1 to 10 by 1
line.delete(array.get(sr_lines_, x))
label.delete(array.get(sr_labels_, x))
label.delete(array.get(timef_labels, x))
f_crossed_over() =>
ret = false
for x = 0 to array.size(sr_up_level) > 0 ? array.size(sr_up_level) - 1 : na by
1
float mid = math.round_to_mintick((array.get(sr_up_level, x) +
array.get(sr_dn_level, x)) / 2)
if close[1] <= mid and close > mid
ret := true
ret
ret
f_crossed_under() =>
ret = false
for x = 0 to array.size(sr_up_level) > 0 ? array.size(sr_up_level) - 1 : na by
1
float mid = math.round_to_mintick((array.get(sr_up_level, x) +
array.get(sr_dn_level, x)) / 2)
if close[1] >= mid and close < mid
ret := true
ret
ret
//RSI
// rsicol = input.bool(false, title='Show RSI colors?', group='Settings',
tooltip='Show RSI Levels On Bars')
srcRSI = close
lenRSI = input.int(14, minval=1, title='RSI Length', group='RSI Settings')
up = ta.rma(math.max(ta.change(srcRSI), 0), lenRSI)
down = ta.rma(-math.min(ta.change(srcRSI), 0), lenRSI)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - 100 / (1 + up / down)
///////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////
//@version=5
//indicator("Merged Inside Bar & Breakout/Breakdown with Volume Confirmation",
overlay=true)
// If the current bar is an inside bar, set mhigh and mlow to the previous bar's
high and low
if (isInsideBar())
mhigh := high[1]
mlow := low[1]
// HMI Inputs
var incount = 1
var inside = false
var topinside = 0.0
var lowinside = 0.0
//////////
// This source code is subject to the terms of the Mozilla Public License 2.0 at
https://mozilla.org/MPL/2.0/
// © LudoGH68
//@version=5
import LudoGH68/Drawings_public/1 as d
getLineStyle(lineOption) =>
lineOption == "┈" ? line.style_dotted : lineOption == "╌" ? line.style_dashed :
line.style_solid
get_structure_highest_bar(lookback) =>
for i = 0 to lookback - 1 by 1
if high[i+1] > high[i+2] and high[i] <= high[i+1] and ((i+1) * -1) >=
maxBar
idx := (i+1) * -1
//break
get_structure_lowest_bar(lookback) =>
for i = 0 to lookback - 1 by 1
if low[i+1] < low[i+2] and low[i] >= low[i+1] and ((i+1) * -1) >=
minBar
idx := (i+1) * -1
//break
is_structure_high_broken(_highStructBreakPrice, _structureHigh,
_structureHighStartIndex, _structureDirection) =>
var bool res = false
res
// Structures
isStructBodyCandleBreak = input(true, title='Break with candle\'s body',
group="Structures")
isCurrentStructToShow = input(true, title='Display current structure',
group="Structures")
bullishBosColor = input(color.silver, 'Bullish BOS Color', group="Structures")
bearishBosColor = input(color.silver, 'Bearish BOS Color', group="Structures")
bosLineStyleOption = input.string("─", title="BOS Style", group="Structures",
options=["─", "┈", "╌"])
bosLineStyle = getLineStyle(bosLineStyleOption)
bosLineWidth = input.int(1, title="BOS Width", group="Structures", minval=1,
maxval=5)
bullishChochColor = input(color.yellow, 'Bullish CHoCH Color', group="Structures")
bearishChochColor = input(color.yellow, 'Bearish CHoCH Color', group="Structures")
chochLineStyleOption = input.string("─", title="CHoCH Style", group="Structures",
options=["─", "┈", "╌"])
chochLineStyle = getLineStyle(chochLineStyleOption)
chochLineWidth = input.int(1, title="MSB Width", group="Structures", minval=1,
maxval=5)
currentStructColor = input(color.blue, 'Current structure Color',
group="Structures")
currentStructLineStyleOption = input.string("─", title="Current structure Style",
group="Structures", options=["─", "┈", "╌"])
currentStructLineStyle = getLineStyle(currentStructLineStyleOption)
currentStructLineWidth = input.int(1, title="Current structure Width",
group="Structures", minval=1, maxval=5)
structHistoryNbr = input.int(10, 'Number of break to show', minval=1, maxval=50)
// Fibonacci 1
isFibo1ToShow = input(true, title = "", group="Structure Fibonacci", inline =
"Fibo1")
fibo1Value = input.float(0.786, title = "", group="Structure Fibonacci", inline =
"Fibo1")
fibo1Color = input(#64b5f6, title = "", group="Structure Fibonacci", inline =
"Fibo1")
fibo1StyleOption = input.string("─", title = "", group="Structure Fibonacci",
options=["─", "┈", "╌"], inline = "Fibo1")
fibo1Style = getLineStyle(fibo1StyleOption)
fibo1LineWidth = input.int(1, title = "", group="Structure Fibonacci", minval=1,
maxval=5, inline = "Fibo1")
// Fibonacci 2
isFibo2ToShow = input(true, title = "", group="Structure Fibonacci", inline =
"Fibo2")
fibo2Value = input.float(0.705, title = "", group="Structure Fibonacci", inline =
"Fibo2")
fibo2Color = input(#f23645, title = "", group="Structure Fibonacci", inline =
"Fibo2")
fibo2StyleOption = input.string("─", title = "", group="Structure Fibonacci",
options=["─", "┈", "╌"], inline = "Fibo2")
fibo2Style = getLineStyle(fibo2StyleOption)
fibo2LineWidth = input.int(1, title = "", group="Structure Fibonacci", minval=1,
maxval=5, inline = "Fibo2")
// Fibonacci 3
isFibo3ToShow = input(true, title = "", group="Structure Fibonacci", inline =
"Fibo3")
fibo3Value = input.float(0.618, title = "", group="Structure Fibonacci", inline =
"Fibo3")
fibo3Color = input(#089981, title = "", group="Structure Fibonacci", inline =
"Fibo3")
fibo3StyleOption = input.string("─", title = "", group="Structure Fibonacci",
options=["─", "┈", "╌"], inline = "Fibo3")
fibo3Style = getLineStyle(fibo3StyleOption)
fibo3LineWidth = input.int(1, title = "", group="Structure Fibonacci", minval=1,
maxval=5, inline = "Fibo3")
// Fibonacci 3
isFibo4ToShow = input(true, title = "", group="Structure Fibonacci", inline =
"Fibo4")
fibo4Value = input.float(0.5, title = "", group="Structure Fibonacci", inline =
"Fibo4")
fibo4Color = input(#4caf50, title = "", group="Structure Fibonacci", inline =
"Fibo4")
fibo4StyleOption = input.string("─", title = "", group="Structure Fibonacci",
options=["─", "┈", "╌"], inline = "Fibo4")
fibo4Style = getLineStyle(fibo4StyleOption)
fibo4LineWidth = input.int(1, title = "", group="Structure Fibonacci", minval=1,
maxval=5, inline = "Fibo4")
// Fibonacci 5
isFibo5ToShow = input(true, title = "", group="Structure Fibonacci", inline =
"Fibo5")
fibo5Value = input.float(0.382, title = "", group="Structure Fibonacci", inline =
"Fibo5")
fibo5Color = input(#81c784, title = "", group="Structure Fibonacci", inline =
"Fibo5")
fibo5StyleOption = input.string("─", title = "", group="Structure Fibonacci",
options=["─", "┈", "╌"], inline = "Fibo5")
fibo5Style = getLineStyle(fibo5StyleOption)
fibo5LineWidth = input.int(1, title = "", group="Structure Fibonacci", minval=1,
maxval=5, inline = "Fibo5")
box.set_right(value, bar_index)
box.set_right(value, bar_index)
// Arrays variable
var array<line> structureLines = array.new_line(0)
var array<label> structureLabels = array.new_label(0)
var array<box> fvgBoxes = array.new_box(0)
var array<bool> fvgTypes = array.new_bool(0)
var array<bool> isFvgMitigated = array.new_bool(0)
// Price variables
var float structureHigh = 0.0
var float structureLow = 0.0
var float fibo1Price = 0.0
var float fibo2Price = 0.0
var float fibo3Price = 0.0
var float fibo4Price = 0.0
var float fibo5Price = 0.0
// Index variable
var int structureHighStartIndex = 0
var int structureLowStartIndex = 0
var int structureDirection = 0
var int fibo1StartIndex = 0
var int fibo2StartIndex = 0
var int fibo3StartIndex = 0
var int fibo4StartIndex = 0
var int fibo5StartIndex = 0
// Line variable
var line structureHighLine = na
var line structureLowLine = na
var line fibo1Line = na
var line fibo2Line = na
var line fibo3Line = na
var line fibo4Line = na
var line fibo5Line = na
// Label variable
var label fibo1Label = na
var label fibo2Label = na
var label fibo3Label = na
var label fibo4Label = na
var label fibo5Label = na
//
//
//
===================================================================================
=======
// FAIR VALUE GAP FINDER PROCESSING
//
===================================================================================
=======
//
//
// Define FVG type
isBullishFVG = high[3] < low[1]
isBearishFVG = low[3] > high[1]
// Draw FVG
FVGDraw(fvgBoxes, fvgTypes, isFvgMitigated)
//
//
//
===================================================================================
=======
// STRUCTURES PROCESSING
//
===================================================================================
=======
//
//
// Initialize value for bar 0
if(bar_index == 0)
structureHighStartIndex := bar_index
structureLowStartIndex := bar_index
structureHigh := high
structureLow := low
//if((low < structureLow and low[1] >= structureLow and low[2] >= structureLow and
low[3] >= structureLow and bar_index[1] > structureLowStartIndex and bar_index[2]
> structureLowStartIndex and bar_index[3] > structureLowStartIndex) or
(structureDirection == 2 and low < structureLow))
if(isStuctureLowBroken)
// Check if structures to show is upper than user parameter
if(array.size(structureLines) >= structHistoryNbr)
plot(na)