CryptoQuebec Suite// This source code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org
// Crypto Quebec & StefB.
//@version=6
indicator("CryptoQuebec Suite", overlay = true, max_labels_count = 500, max_lines_count = 500, max_boxes_count = 500, max_bars_back = 500)
//strategy("UT BOT Amélioré pour le Day Trading Crypto", overlay=true, initial_capital=1000, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
// Version 2.0 order block ajustable colors
// Version 2.1 draw swing High/low
// Version 2.2 Changed the wording of "Area of interest" for "Premium Zone" and "Discount Zone"
// Version 2.3 Added the price to the auto fib levels.
// Version 2.4 Correction. Added 3 digits after the dot of the auto fib. This was lost when the price has been added.
// Version 2.4.01 Added few fib levels. (0, -0.272, -0.414, -0.618).
// Version 2.4.02 Added few fib levels. (1, 1.272, 1.414, 1.618).
// Version 2.4.03 Made a small change in the label of 240L, 240H, DL and DH. Change 240 for 4h and H/L for Lo/Hi
// Version 2.4.04 Added digits after the dot for more price precision into the Fib levels.
// Version 2.4.05 Added Entry long/short indicator base on EMA. Also added the trailing stop line.
// Version 2.4.06 Added Trail Stop enable/disable option. Moved the Buy/Sell label farther from the candles.
// Version 2.4.07 Added Trend info table with active trading session
// Version 2.4.08 Small adjustment in the trend table and FIB lines more visible.
// Version 2.4.09 Changed the indicator name for CryptoQuebe Suite.
//---------------------------------------------------------------------------------------------------------------------
//CONSTANTS & STRINGS & INPUTS
//---------------------------------------------------------------------------------------------------------------------
BULLISH = +1
BEARISH = -1
showHighLowSwingsTooltip = 'Highlight most recent strong and weak high/low points on the chart'
bullC = input.color(defval = #14D990, title = "Bull Color", group = "Smart Money Concepts", inline = "7")
bearC = input.color(defval = #F24968, title = "Bear Color", group = "Smart Money Concepts", inline = "7")
showInt = input.bool(defval = true, title = "Show Internals", group = "Smart Money Concepts")
intSens = input.int(3, "Internals Sensitivity", options = , group = "Smart Money Concepts", inline = "20")
intStru = input.string(defval = "All", title = "Internal Structure", options = , inline = "30", group = "Smart Money Concepts")
showExt = input.bool(defval = true, title = "Show Externals" ,group = "Smart Money Concepts")
extSens = input.int(25, "Externals Sensitivity", options = ,group = "Smart Money Concepts", inline = "21")
extStru = input.string(defval = "All", title = "External Structure", options = , inline = "31", group = "Smart Money Concepts")
showOB = input.bool(defval = true, title = "Show Order Blocks" ,group = "Swing Blocks")
//----------------------------------------------
//showHighLowSwingsInput = input(true, 'Show Strong/Weak High/Low', group = "Smart Money Concepts", tooltip = showHighLowSwingsTooltip)
BullOBColor = input.color(color.new(#3179f5, 80), 'Internal Bullish OB',group = "Swing Blocks")
BearOBColor = input.color(color.new(#f77c80, 80), 'Internal Bearish OB',group = "Swing Blocks")
//---------------------------------------------------------------------------
showLast = input.int(defval = 10, title = "Swing Order Blocks", minval = 0, group = "Swing Blocks")
showHHLH = input.bool(defval = true, title = "Show HH/LH", group = "Swing Blocks")
showHLLL = input.bool(defval = true, title = "Show LH/LL", group = "Swing Blocks")
showAOE = input.bool(defval = true, title = "Show Premium/Discount", group = "Swing Blocks")
//showAOE = input.bool(defval = true, title = "Show Area of Interest", group = "Swing Blocks")
show1D = input.bool(defval = true, title = "Show Previous Day High", group = "High/Low")
show1DLab = input.bool(defval = true, title = "Show 1 Day Labels", group = "High/Low")
show4H = input.bool(defval = true, title = "Show 4 Hour High", group = "High/Low")
show4hLab = input.bool(defval = true, title = "Show 4 Hour Labels", group = "High/Low")
showFVG = input.bool(defval = true, title = "Show Fair Value Gaps", group = "FVG")
contract = input.bool(defval = false, title = "Contract Violated FVG", group = "FVG")
closeOnly = input.bool(defval = false, title = "Show Closest Up/Down FVG Only", group = "FVG")
fvgcol = input.color(defval = #F2B807, title = "FVG Color", group = "FVG")
fvgtra = input.int(defval = 80, minval = 0, maxval = 100, title = "FVG Transparency", group = "FVG")
showFibs = input.bool(defval = true, title = "Show Auto Fibs", group = "Auto Fibs")
// extSensFibs = input.int(25, "Fibs Sensitivity", options = , group = "Auto Fibs", inline = "22")
show0_618 = input.bool(defval = true, title = "", inline = "1", group = "Auto Fibs")
show0_414 = input.bool(defval = true, title = "", inline = "2", group = "Auto Fibs")
show0_272 = input.bool(defval = true, title = "", inline = "3", group = "Auto Fibs")
show0 = input.bool(defval = true, title = "", inline = "4", group = "Auto Fibs")
show236 = input.bool(defval = true, title = "", inline = "5", group = "Auto Fibs")
show382 = input.bool(defval = true, title = "", inline = "6", group = "Auto Fibs")
show5 = input.bool(defval = true, title = "", inline = "7", group = "Auto Fibs")
show618 = input.bool(defval = true, title = "", inline = "8", group = "Auto Fibs")
show65 = input.bool(defval = true, title = "", inline = "9", group = "Auto Fibs")
show786 = input.bool(defval = true, title = "", inline = "10", group = "Auto Fibs")
show1 = input.bool(defval = true, title = "", inline = "11", group = "Auto Fibs")
show1_272 = input.bool(defval = true, title = "", inline = "12", group = "Auto Fibs")
show1_414 = input.bool(defval = true, title = "", inline = "13", group = "Auto Fibs")
show1_618 = input.bool(defval = true, title = "", inline = "14", group = "Auto Fibs")
fib1 = input.float(defval = -0.618, title = "", minval = -0.618, step = 0.01, inline = "1", group = "Auto Fibs")
fib2 = input.float(defval = -0.414, title = "", minval = -0.618, step = 0.01, inline = "2", group = "Auto Fibs")
fib3 = input.float(defval = -0.272, title = "", minval = -0.618, step = 0.01, inline = "3", group = "Auto Fibs")
fib4 = input.float(defval = 0, title = "", minval = 0, step = 0.01, inline = "4", group = "Auto Fibs")
fib5 = input.float(defval = .236, title = "", minval = 0, step = 0.01, inline = "5", group = "Auto Fibs")
fib6 = input.float(defval = .382, title = "", minval = 0, step = 0.01, inline = "6", group = "Auto Fibs")
fib7 = input.float(defval = .5, title = "", minval = 0, step = 0.01, inline = "7", group = "Auto Fibs")
fib8 = input.float(defval = .618, title = "", minval = 0, step = 0.01, inline = "8", group = "Auto Fibs")
fib9 = input.float(defval = .65, title = "", minval = 0, step = 0.01, inline = "9", group = "Auto Fibs")
fib10 = input.float(defval = .786, title = "", minval = 0, step = 0.01, inline = "10", group = "Auto Fibs")
fib11 = input.float(defval = 1, title = "", minval = 0, step = 0.01, inline = "11", group = "Auto Fibs")
fib12 = input.float(defval = 1.272, title = "", minval = 0, step = 0.01, inline = "12", group = "Auto Fibs")
fib13 = input.float(defval = 1.414, title = "", minval = 0, step = 0.01, inline = "13", group = "Auto Fibs")
fib14 = input.float(defval = 1.618, title = "", minval = 0, step = 0.01, inline = "14", group = "Auto Fibs")
fib1col = input.color(title = "", defval = color.orange, inline = "1", group = "Auto Fibs")
fib2col = input.color(title = "", defval = color.orange, inline = "2", group = "Auto Fibs")
fib3col = input.color(title = "", defval = color.orange, inline = "3", group = "Auto Fibs")
fib4col = input.color(title = "", defval = color.gray, inline = "4", group = "Auto Fibs")
fib5col = input.color(title = "", defval = color.white, inline = "5", group = "Auto Fibs")
fib6col = input.color(title = "", defval = color.white, inline = "6", group = "Auto Fibs")
fib7col = input.color(title = "", defval = color.red, inline = "7", group = "Auto Fibs")
fib8col = input.color(title = "", defval = color.green, inline = "8", group = "Auto Fibs")
fib9col = input.color(title = "", defval = color.green, inline = "9", group = "Auto Fibs")
fib10col = input.color(title = "", defval = color.white, inline = "10", group = "Auto Fibs")
fib11col = input.color(title = "", defval = color.gray, inline = "11", group = "Auto Fibs")
fib12col = input.color(title = "", defval = color.orange, inline = "12", group = "Auto Fibs")
fib13col = input.color(title = "", defval = color.orange, inline = "13", group = "Auto Fibs")
fib14col = input.color(title = "", defval = color.orange, inline = "14", group = "Auto Fibs")
//---------------------------------------------------------------------------------------------------------------------
//DATA STRUCTURES & VARIABLES
//---------------------------------------------------------------------------------------------------------------------
// @type UDT representing last swing extremes (top & bottom)
// @field top last top swing price
// @field bottom last bottom swing price
// @field barTime last swing bar time
// @field barIndex last swing bar index
// @field lastTopTime last top swing time
// @field lastBottomTime last bottom swing time
type trailingExtremes
float top
float bottom
int barTime
int barIndex
int lastTopTime
int lastBottomTime
// @type UDT representing trend bias
// @field bias BULLISH or BEARISH
type trend
int bias
var bigData = map.new()
// @variable swing trend bias
var trend swingTrend = trend.new(0)
// @variable last trailing swing high and low
var trailingExtremes trailing = trailingExtremes.new()
// @variable color for swing bullish structures
var swingBullishColor = color.green //styleInput == MONOCHROME ? MONO_BULLISH : swingBullColorInput
// @variable color for swing bearish structures
var swingBearishColor = color.red //styleInput == MONOCHROME ? MONO_BEARISH : swingBearColorInput
if bigData.size() == 0
bigData.put("moving", 0)
bigData.put("upaxis", 0.0)
bigData.put("upaxis2", 0)
bigData.put("dnaxis", 0.0)
bigData.put("dnaxis2", 0)
bigData.put("upside", 1)
bigData.put("downside", 1)
= request.security(syminfo.tickerid, "1D", [high , low , high, low, time , time])
var highArr = array.new_float(), var lowArr = array.new_float()
var timeArr = array.new_int (), var volArr = array.new_float()
var closeArr = array.new_float(), var openArr = array.new_float()
highArr.unshift(high), lowArr.unshift(low)
timeArr.unshift(time), volArr.unshift(volume)
closeArr.unshift(close), openArr.unshift(open)
type rollingTF
float highTF = 0
float lowTF = 1e8
int highTFt = 0
int lowTFt = 0
float volTF = 0
map rTFdraw
map rTFlabel
// Convert time period in text
f_convert_tf_to_text(tf) =>
tf == "240" ? "H4" : tf == "1D" ? "D" : tf == "60" ? "1h" : tf == "15" ? "15m" : tf
// Create the labels fo each level
offset = 10 // Ajustez cette valeur selon le décalage souhaité
// Ajust the label position in case of overide
f_adjust_label_position(x, offset) =>
x + offset
// @function tfDraw
// @param tfDiff Specifies the timeframe difference for the high/low calculations.
// @param showRollingLab Indicates whether to display rolling labels for timeframes.
// @param tf Specifies the timeframe as a string.
// @param showLevels Determines if the high/low levels for the timeframe should be shown.
// @returns A tuple with the total volume (TFhrdata.volTF) and the rolling volume array (volRolling).
method tfDraw(int tfDiff, bool showRollingLab, string tf, bool showLevels) =>
TFhrdata = rollingTF.new(), var volRolling = array.new()
if highArr.size() > tfDiff
for i = 0 to tfDiff
if showLevels and barstate.islast
getHigh = highArr.get(i), getLow = lowArr.get(i),
getTime = timeArr.get(i)
TFhrdata.highTF := math.max(TFhrdata.highTF, getHigh)
TFhrdata.lowTF := math.min(TFhrdata.lowTF , getLow )
if TFhrdata.highTF == getHigh
TFhrdata.highTFt := timeArr.get(i)
if TFhrdata.lowTF == getLow
TFhrdata.lowTFt := timeArr.get(i)
TFhrdata.volTF += volArr.get(i)
volRolling.push(TFhrdata.volTF)
var lineDraw = rollingTF.new(rTFdraw = map.new(), rTFlabel = map.new())
if showLevels
switch lineDraw.rTFdraw.size() == 0
true => lineDraw.rTFdraw.put("High", line.new(TFhrdata.highTFt, TFhrdata.highTF, time, TFhrdata.highTF,
xloc = xloc.bar_time, color = color.aqua)),
lineDraw.rTFdraw.put("Low" , line.new(TFhrdata.lowTFt , TFhrdata.lowTF , time, TFhrdata.lowTF ,
xloc = xloc.bar_time, color = color.aqua))
=> lineDraw.rTFdraw.get("High").set_xy1(TFhrdata.highTFt, TFhrdata.highTF),
lineDraw.rTFdraw.get("High").set_xy2(time, TFhrdata.highTF),
lineDraw.rTFdraw.get("Low").set_xy1(TFhrdata.lowTFt, TFhrdata.lowTF),
lineDraw.rTFdraw.get("Low").set_xy2(time, TFhrdata.lowTF)
if showRollingLab
switch lineDraw.rTFlabel.size() == 0
true => lineDraw.rTFlabel.put("High", label.new(f_adjust_label_position(bar_index, offset), TFhrdata.highTF, xloc = xloc.bar_time, textcolor = color.aqua, text = f_convert_tf_to_text(tf) + " Hi", style = label.style_label_left, size = size.normal, color = #00000000)),
lineDraw.rTFlabel.put("Low", label.new(f_adjust_label_position(bar_index, offset), TFhrdata.lowTF, xloc = xloc.bar_time, textcolor = color.aqua, text = f_convert_tf_to_text(tf) + " Lo", style = label.style_label_left, size = size.normal, color = #00000000))
=> lineDraw.rTFlabel.get("High") .set_xy(time, TFhrdata.highTF),
lineDraw.rTFlabel.get("Low") .set_xy(time, TFhrdata.lowTF)
// @function tfDrawLower
// @param showRollingLab Indicates whether to display rolling labels for lower timeframes.
// @param tf Specifies the lower timeframe as a string.
// @param showLevels Determines if the high/low levels for the lower timeframe should be shown.
// @returns (volume and volume array)
tfDrawLower(bool showRollingLab, simple string tf, bool showLevels) =>
simple int end = switch tf
"240" => 240
"1D" => 1440
= request.security_lower_tf(syminfo.tickerid, "1", )
var oArr = array.new_float()
var hArr = array.new_float()
var lArr = array.new_float()
var cArr = array.new_float()
var vArr = array.new_float()
var tArr = array.new_int()
TFhrdata = rollingTF.new(), var volRolling = array.new()
if h.size() > 0
for i = 0 to h.size() - 1
oArr.push(o.get(i))
hArr.push(h.get(i))
lArr.push(l.get(i))
cArr.push(c.get(i))
vArr.push(v.get(i))
tArr.push(t.get(i))
if hArr.size() > end
oArr.shift()
hArr.shift()
lArr.shift()
cArr.shift()
vArr.shift()
tArr.shift()
for i = 0 to hArr.size() - 1
if showLevels
getHigh = hArr.get(i), getLow = lArr.get(i),
getTime = tArr.get(i)
TFhrdata.highTF := math.max(TFhrdata.highTF, getHigh)
TFhrdata.lowTF := math.min(TFhrdata.lowTF , getLow)
if TFhrdata.highTF == getHigh
TFhrdata.highTFt := tArr.get(i)
if TFhrdata.lowTF == getLow
TFhrdata.lowTFt := tArr.get(i)
TFhrdata.volTF += vArr.get(i)
volRolling.push(TFhrdata.volTF)
var lineDraw = rollingTF.new(rTFdraw = map.new(), rTFlabel = map.new())
if showLevels
switch lineDraw.rTFdraw.size() == 0
true => lineDraw.rTFdraw.put("High", line.new(TFhrdata.highTFt, TFhrdata.highTF, time, TFhrdata.highTF,
xloc = xloc.bar_time, color = color.aqua)),
lineDraw.rTFdraw.put("Low" , line.new(TFhrdata.lowTFt , TFhrdata.lowTF , time, TFhrdata.lowTF ,
xloc = xloc.bar_time, color = color.aqua))
=> lineDraw.rTFdraw.get("High").set_xy1(TFhrdata.highTFt, TFhrdata.highTF),
lineDraw.rTFdraw.get("High").set_xy2(time, TFhrdata.highTF),
lineDraw.rTFdraw.get("Low").set_xy1(TFhrdata.lowTFt, TFhrdata.lowTF),
lineDraw.rTFdraw.get("Low").set_xy2(time, TFhrdata.lowTF)
if showRollingLab
switch lineDraw.rTFlabel.size() == 0
true => lineDraw.rTFlabel.put("High", label.new(f_adjust_label_position(bar_index, 0), TFhrdata.highTF, xloc = xloc.bar_time, textcolor = color.aqua, text = f_convert_tf_to_text(tf) + " Hi", style = label.style_label_left, size = size.normal, color = #00000000)),
lineDraw.rTFlabel.put("Low" , label.new(f_adjust_label_position(bar_index, 0), TFhrdata.lowTF, xloc = xloc.bar_time, textcolor = color.aqua, text = f_convert_tf_to_text(tf) + " Lo", style = label.style_label_left, size = size.normal, color = #00000000))
=> lineDraw.rTFlabel.get("High") .set_xy(time, TFhrdata.highTF),
lineDraw.rTFlabel.get("Low") .set_xy(time, TFhrdata.lowTF)
var r4hrbars = math.floor(timeframe.in_seconds("240") / timeframe.in_seconds(timeframe.period))
var rDbars = math.floor(timeframe.in_seconds("1D") / timeframe.in_seconds(timeframe.period))
= switch
timeframe.in_seconds() <= 60 => r4hrbars.tfDraw(show4hLab, "240", show4H)
=> tfDrawLower(show4hLab, "240", show4H)
= switch
timeframe.in_seconds() <= 60 => rDbars.tfDraw(show1DLab, "1D", show1D)
=> tfDrawLower(show1DLab, "1D", show1D)
// @function calculatePivots
// @param length Specifies the lookback length for high/low pivot calculations.
// @returns A tuple with top and bottom swing values.
calculatePivots(length)=>
var int intraCalc = 0
if bar_index > length + 1
up = highArr.slice(0, length).max()
dn = lowArr .slice(0, length).min()
cHi = highArr.get(length)
cLo = lowArr .get(length)
intraCalc := switch
cHi > up => 0
cLo < dn => 1
=> intraCalc
topSwing = switch
intraCalc == 0 and intraCalc != 0 => cHi
=> 0
botSwing = switch
intraCalc == 1 and intraCalc != 1 => cLo
=> 0
= calculatePivots(extSens)
= calculatePivots(intSens)
var label upLabel = array.new_label(1)
var label dnLabel = array.new_label(1)
var box highBlock = array.new_box()
var box lowBlock = array.new_box()
drawChar(x, y, str, col, down) =>
style = switch down
true => label.style_label_down
=> label.style_label_up
line.new (int(x), y, bar_index, y, color = col, style = line.style_dashed)
label.new(math.round(math.avg(x, bar_index)), y, str, color = #00000000, textcolor = col, style = style, size = size.small)
// @function drawStructureExt
// @returns Counter indicating the structure direction: 1 for bullish, -1 for bearish, 0 for neutral.
drawStructureExt() =>
var int counter = 0
if bigUpper != 0
bigData.put("upside", 1)
x1 = bar_index - extSens
txt = switch bigUpper > bigData.get("upaxis")
true => 'HH'
=> 'LH'
if showHHLH
upLabel.set(0, label.new(x1, bigUpper, txt,
color = color.new(color.white, 100),
textcolor = bearC,
style = label.style_label_down,
size = size.small
))
if showOB
highBlock.push(box.new(x1, bigUpper, last_bar_index + 5, bigUpper * .998, border_color = BearOBColor, bgcolor = BearOBColor))
bigData.put("upaxis" , bigUpper)
bigData.put("upaxis2", x1)
counter := 1
if bigLower != 0
bigData.put("downside", 1)
x1 = bar_index - extSens
txt = switch bigLower < bigData.get("dnaxis")
true => "LL"
=> "HL"
if showHLLL == true
dnLabel.set(0, label.new(x1, bigLower, txt, color = #ffffff00,
textcolor = bullC,
style = label.style_label_up,
size = size.small
))
if showOB
lowBlock.push(box.new(x1, bigLower, last_bar_index + 5, bigLower * 1.002, border_color = BullOBColor, bgcolor = BullOBColor))
//border_color = color.new(color.blue, 60),//75),
//bgcolor = color.new(color.blue, 70)//95)
//))
bigData.put("dnaxis" , bigLower)
bigData.put("dnaxis2", x1)
counter := -1
if showExt
if ta.crossover(close, bigData.get("upaxis"))
if bigData.get("upside") != 0
str = switch bigData.get("moving") < 0
true => extStru != "BoS" ? 'CHoCH' : ""
=> extStru != 'CHoCH' ? 'BoS' : ""
if extStru == "All" or str.contains(extStru, str)
drawChar(bigData.get("upaxis2"), bigData.get("upaxis"), str, bullC, true)
bigData.put("upside", 0)
bigData.put("moving", 1)
if ta.crossunder(close, bigData.get("dnaxis"))
if bigData.get("downside") != 0
str = switch bigData.get("moving") > 0
true => extStru != "BoS" ? 'CHoCH' : ""
=> extStru != 'CHoCH' ? 'BoS' : ""
if extStru == "All" or str.contains(extStru, str)
drawChar(bigData.get("dnaxis2"), bigData.get("dnaxis"), str, bearC, false)
bigData.put("downside", 0)
bigData.put("moving", -1)
counter
counter = drawStructureExt()
// @function updateBox
// @param id Array of boxes to update based on the bar index.
// @returns void
method updateBox(array id) =>
if id.size() > 0
for i = 0 to id.size() - 1
id.get(i).set_right(last_bar_index + 5)
method cleanseLevel(array id, bool isHighBlock) =>
if id.size() > 0
for i = id.size() - 1 to 0
condition = switch isHighBlock
true => close >= id.get(i).get_top()
=> close <= id.get(i).get_bottom()
if condition
id.remove(i).delete()
if id.size() > showLast and showLast != 0
for i = id.size() - showLast to 0
id.remove(i).delete()
highBlock.cleanseLevel(true)
lowBlock .cleanseLevel(false)
if barstate.islast
highBlock.updateBox()
lowBlock .updateBox()
// @function updateMain
// @param id Line object for updating based on price structure pivots.
// @returns void
// @description Updates the main line indicator to match the latest high/low price levels.
method updateMain(line id) =>
hi = 0.0
lo = 1e8
if showFibs
= calculatePivots(25)
var int counterFibs = 0
if bigUpperFibs != 0
counterFibs := 1
if bigLowerFibs != 0
counterFibs := -1
if counterFibs == 1
hi := 0.0
id.set_xy1(int(bigData.get("upaxis2")), bigData.get("upaxis"))
for i = 0 to bar_index - int(bigData.get("dnaxis2"))
getLow = lowArr.get(i)
lo := math.min(getLow, lo)
if lo == getLow
id.set_xy2(bar_index - i, lo)
else if counterFibs == -1
lo := 1e8
id.set_xy1(int(bigData.get("dnaxis2")), bigData.get("dnaxis"))
for i = 0 to bar_index - bigData.get("upaxis2")
getHigh = highArr.get(i)
hi := math.max(highArr.get(i), hi)
if hi == getHigh
id.set_xy2(bar_index - i, hi)
if id.get_x2() < id.get_x1()
x2 = id.get_x2(), x1 = id.get_x1()
y2 = id.get_y2(), y1 = id.get_y1(),
id.set_xy2(x1, y1),
id.set_xy1(x2, y2)
switch id.get_y2() < id.get_y1()
true => id.set_color(#F24968)
=> id.set_color(#14D990)
0
var main = line.new(dnLabel.first().get_x(), dnLabel.first().get_y(), upLabel.first().get_x(), upLabel.first().get_y(),
style = line.style_dashed,
width = 2
)
main.updateMain()
//-----------------------------------FIB----------------------------------------------------------
// @function quickLine
// @param getX2 The x-coordinate for the endpoint of the line.
// @param y The y-coordinate for the line’s position.
// @param color The color of the line to be drawn.
// @returns void
// @description Draws a horizontal line on the chart with specific attributes.
quickLine(getX2, y, color) =>
line.new(getX2, y, bar_index + 5, y, color = color.new(color, 50))
// @function quickLabel
// @param y The y-coordinate for the label’s position.
// @param txt Text content of the label.
// @param color The text color of the label.
// @returns void
// @description Places a label with given text and color at a specified y-coordinate.
quickLabel(y, txt, color) =>
label.new(bar_index + 5, y, text = str.tostring(txt), color = #00000000, style = label.style_label_left, textcolor = color)
// @function drawFibs
// @returns void
// @description Draws Fibonacci retracement levels based on recent price action.
drawFibs() =>
if barstate.islast
var fibLine = array.new(14)
var fibLab = array.new(14)
if fibLine.size() > 0
for i = 0 to fibLine.size() - 1
fibLine .get(i).delete()
fibLab .get(i).delete()
if showFibs
getY2 = main.get_y2(), sub = main.get_y1() - getY2,
getX1 = main.get_x1(), getX2 = main.get_x2()
for i = 0 to fibLine.size() - 1
mod = i % fibLine.size() - 1
= switch mod
0 =>
1 =>
2 =>
3 =>
4 =>
5 =>
6 =>
7 =>
8 =>
9 =>
10 =>
11 =>
12 =>
13 =>
fibLine.set(i, quickLine (getX2, y, col))
// Combine text level and price
priceLabel = str.tostring(y, "#.#####")
combinedText = txt + " (" + priceLabel + ")" // Prix entre parenthèses
fibLab.set(i, quickLabel(y, combinedText, col))
drawFibs()
// @function drawStructureInternals
// @returns void
// @description Draws internal structures for smaller price swings based on user-defined settings.
drawStructureInternals() =>
if showInt
var keyValues = map.new()
if keyValues.size() == 0
keyValues.put("movingSmall", 0)
if smallUpper != 0
keyValues.put("upsideSmall", 1)
keyValues.put("upaxisSmall", smallUpper)
keyValues.put("upaxis2Small", bar_index - intSens)
if smallLower != 0
keyValues.put("downsideSmall", 1)
keyValues.put("dnaxisSmall", smallLower)
keyValues.put("dnaxis2Small", bar_index - intSens)
if ta.crossover(close, keyValues.get("upaxisSmall"))
if keyValues.get("upsideSmall") != 0
str = switch
keyValues.get("movingSmall") < 0 => intStru != "BoS" ? 'I-CHoCH' : ""
=> intStru != "CHoCH" ? 'I-BoS' : ""
if intStru == "All" or str.contains(str, intStru)
drawChar(keyValues.get("upaxis2Small"), keyValues.get("upaxisSmall"), str, bullC, true)
keyValues.put("upsideSmall", 0)
keyValues.put("movingSmall", 1)
if ta.crossunder(close, keyValues.get("dnaxisSmall"))
if keyValues.get("downsideSmall") != 0
str = switch
keyValues.get("movingSmall") > 0 => intStru != "BoS" ? 'I-CHoCH' : ""
=> intStru != "CHoCH" ? 'I-BoS' : ""
if intStru == "All" or str.contains(str, intStru)
drawChar(keyValues.get("dnaxis2Small"), keyValues.get("dnaxisSmall"), str, bearC, false)
keyValues.put("downsideSmall", 0)
keyValues.put("movingSmall", -1)
drawStructureInternals()
// @function drawAOE
// @returns void
// @description Draws the Premium and Discount Zones on the chart based on recent highs and lows.
drawAOE() =>
atr = ta.atr(14)
if showAOE
if closeArr.size() > 50
aoi = closeArr.slice(0, 50)
aoi2 = openArr .slice(0, 50)
maxaoiH = math.max(aoi.max(), aoi2.max())
minaoiL = math.min(aoi.min(), aoi2.min())
var aoeLevels = map.new()
if aoeLevels.size() == 0
aoeLevels.put("High",
box.new(bar_index , maxaoiH * 1.01, bar_index + 5, maxaoiH,
border_color = #00000000,
bgcolor = color.new(#F24968, 90),
text = "Premium Zone", //"Area of Interest" ,
text_size = size.normal,//.small,
text_color = color.new(#F24968, 33)
))
aoeLevels.put("Low",
box.new(bar_index , minaoiL, bar_index + 5, minaoiL * .99,
border_color = #00000000,
bgcolor = color.new(#14D990, 90),
text = "Discount Zone", //"Area of Interest" ,
text_size = size.normal,//size.small,
text_color = color.new(#14D990, 33)
))
getHighBox = aoeLevels.get("High")
if close <= getHighBox.get_top() * 1.01
getHighBox.set_lefttop (bar_index , maxaoiH + atr)
getHighBox.set_rightbottom (bar_index + 5, maxaoiH)
getHighBox.set_text ("Premium Zone") //"Area of Interest")
else
getHighBox.set_lefttop (bar_index + 5, maxaoiH + atr)
getHighBox.set_rightbottom (bar_index + 5, maxaoiH + atr)
getHighBox.set_text ("")
getLowBox = aoeLevels.get("Low")
if close >= getLowBox.get_bottom() * .99
getLowBox.set_lefttop (bar_index , minaoiL)
getLowBox.set_rightbottom (bar_index + 5, minaoiL - atr)
getLowBox.set_text ("Discount Zone") //"Area of Interest")
else
getLowBox.set_lefttop (bar_index + 5, minaoiL)
getLowBox.set_rightbottom (bar_index + 5, - atr)
getLowBox.set_text ("")
drawAOE()
var table tab2 = table.new(position.top_right, 13, 13, bgcolor = #20222C, border_color = #363843, frame_color = #363843, border_width = 1, frame_width = 1)
nyHour = hour (timenow, "America/New_York")
nyMinute = minute(timenow, "America/New_York")
// @function fvg
// @param direction Determines the direction for fair value gap (FVG) detection: positive for up, negative for down.
// @returns An array of FVG boxes in the specified direction.
// @description Identifies fair value gaps (FVGs) and stores them in an array of boxes for visual representation.
fvg(direction) =>
var fvgMat = matrix.new(5), var fvgDrawings = array.new()
fvgMat.add_col(0, array.from(math.sign(close - open), close, high, low, time))
if fvgMat.columns() > 3
fvgMat.remove_col(fvgMat.columns() - 1)
if fvgMat.row(0).sum() == direction
getDir = math.sign(direction)
= switch getDir
-1 =>
=>
col = switch closeOnly
true => #00000000
=> color.new(fvgcol, fvgtra)
fvgDrawings.push(
box.new(int(fvgMat.get(4, 1)),y, last_bar_time, y1, xloc = xloc.bar_time,
border_color = col, bgcolor = col)
)
fvgDrawings
if showFVG
fvgDn = fvg(-3)
fvgUp = fvg(3)
if fvgDn.size() > 0
for i = fvgDn.size() - 1 to 0
getfvg = fvgDn.get(i)
if high >= getfvg.get_top()
getfvg.delete()
fvgDn.remove(i)
else if contract
if high > getfvg.get_bottom()
getfvg.set_bottom(high)
if fvgUp.size() > 0
for i = fvgUp.size() - 1 to 0
getfvg = fvgUp.get(i)
if low <= getfvg.get_bottom()
getfvg.delete()
fvgUp.remove(i)
else if contract
if low < getfvg.get_top()
getfvg.set_top(low)
if closeOnly and barstate.islast
minDist = matrix.new(1, 2, 20e20)
if fvgDn.size() > 0
for i = fvgDn.size() - 1 to 0
getBottom = fvgDn.get(i).get_bottom()
minDist.set(0, 1, math.min(minDist.get(0, 1), math.abs(close - getBottom)))
if math.abs(close - getBottom) == minDist.get(0, 1)
minDist.set(0, 0, i)
fvgDn.get(i).set_right(fvgDn.get(i).get_left())
fvgDn.get(int(minDist.get(0, 0))).set_bgcolor(color.new(fvgcol, fvgtra))
fvgDn.get(int(minDist.get(0, 0))).set_border_color(color.new(fvgcol, fvgtra))
fvgDn.get(int(minDist.get(0, 0))).set_right(last_bar_time)
minDist.set(0, 0, 0)
minDist.set(0, 1, 20e20)
if fvgUp.size() > 0
for i = fvgUp.size() - 1 to 0
getTop = fvgUp.get(i).get_top()
minDist.set(0, 1, math.min(minDist.get(0, 1), math.abs(close - getTop)))
if math.abs(close - getTop) == minDist.get(0, 1)
minDist.set(0, 0, i)
fvgUp.get(i).set_right(fvgUp.get(i).get_left())
fvgUp.get(int(minDist.get(0, 0))).set_bgcolor(color.new(fvgcol, fvgtra))
fvgUp.get(int(minDist.get(0, 0))).set_border_color(color.new(fvgcol, fvgtra))
fvgUp.get(int(minDist.get(0, 0))).set_right(last_bar_time)
// @function calculateTimeDifference
// @param timestamp1 The starting timestamp for time difference calculation.
// @param timestamp2 The ending timestamp for time difference calculation.
// @returns A tuple containing hours and minutes as integers.
// @description Calculates the time difference between two timestamps, outputting hours and minutes.
//calculateTimeDifference(timestamp1, timestamp2) =>
// timeDifference = timestamp2 - timestamp1
// hours = math.floor(timeDifference / 3600000)
// minutes = math.floor((timeDifference % 3600000) / 60000)
//
//dayAdjustment = (hour(timenow, "America/New_York") < 2) ? dayofmonth(timenow) + 1 : dayofmonth(timenow)
//dayAdjustment2 = nyHour >= 20 or nyHour < 2 ? dayofmonth(timenow) + 1 : dayofmonth(timenow)
// @function timeIsInRange
// @param startHour The start hour of the time range.
// @param startMinute The start minute of the time range.
// @param endHour The end hour of the time range.
// @param endMinute The end minute of the time range.
// @returns Boolean indicating if the current time is within the specified range.
// @description Checks if the current time falls within a specified range based on New York timezone.
//timeIsInRange(startHour, startMinute, endHour, endMinute) =>
// (nyHour > startHour or (nyHour == startHour and nyMinute >= startMinute)) and (nyHour < endHour or (nyHour == endHour and nyMinute <= endMinute))
// = switch
// timeIsInRange(9, 30, 16, 0) =>
// timeIsInRange(20, 0, 2 , 0) =>
// timeIsInRange(3, 0, 11, 30) =>
// =>
// = calculateTimeDifference(timenow, timetilchange)
//timetilchange2 = switch
// timeIsInRange(9, 30, 16, 0) => timestamp("America/New_York", year(timenow), month(timenow), dayofmonth(timenow), 20, 0, 0)
// timeIsInRange(20, 0, 2 , 0) => timestamp("America/New_York", year(timenow), month(timenow), dayofmonth(timenow), 3, 0, 0)
// timeIsInRange(3, 0, 11, 30) => timestamp("America/New_York", year(timenow), month(timenow), dayofmonth(timenow), 9, 30, 0)
// => na
//if na(timetilchange2)
// timetilchange2 := switch
// nyHour < 9 or (nyHour == 9 and nyMinute < 30) => timestamp("America/New_York", year(timenow), month(timenow), dayofmonth(timenow), 9, 30, 0)
// nyHour < 20 or (nyHour >= 16 and nyHour < 20) => timestamp("America/New_York", year(timenow), month(timenow), dayofmonth(timenow), 20, 0, 0)
// nyHour < 3 or (nyHour >= 2 and nyHour < 3) => timestamp("America/New_York", year(timenow), month(timenow), dayofmonth(timenow), 3, 0, 0)
// => na
// = calculateTimeDifference(timenow, timetilchange2)
//method getActivity(array id, float id2) =>
// if id.size() > 0
// volPerc1 = id.percentile_nearest_rank(10)
// volPerc2 = id.percentile_nearest_rank(33)
// volPerc3 = id.percentile_nearest_rank(50)
// volPerc4 = id.percentile_nearest_rank(66)
// volPerc5 = id.percentile_nearest_rank(90)
// log.warning(str.tostring(volPerc1) + " " + str.tostring(volPerc2) + " " + str.tostring(volPerc3) + " " + str.tostring(volPerc4) + " " + str.tostring(volPerc5))
// activity = switch
// id2 <= volPerc1 => "Very Low"
// id2 <= volPerc2 => "Low"
// id2 <= volPerc3 => "Average"
// id2 <= volPerc4 => "High"
// => "Very High"
// activity
//if barstate.islast
// hr4Act = vol4hrArr.getActivity(vol4hr)
// D1Act = vol1DArr .getActivity(vol1D)
// str = str.tostring(timetilchange)
// ch = str.substring(str, str.pos(str, ".") + 1, str.length(str))
// nu = str.tonumber(ch) * 6
// nu2 = str.substring(str.tostring(nu), 0, 2)
// table.cell(tab2, 0, 2, text = "Session:" , text_color = color.white, text_halign = text.align_left)
// table.cell(tab2, 0, 3, text = "Session Close:" , text_color = color.white, text_halign = text.align_left)
// table.cell(tab2, 0, 4, text = "Next Session:" , text_color = color.white, text_halign = text.align_left)
// table.cell(tab2, 0, 5, text = "Next Session Open:" , text_color = color.white, text_halign = text.align_left)
// table.cell(tab2, 0, 6, text = "4-Hr Volume:" , text_color = color.white, text_halign = text.align_left)
// table.cell(tab2, 0, 7, text = "24-Hr Volume:" , text_color = color.white, text_halign = text.align_left)
// table.cell(tab2, 1, 2, text = stringCol , text_color = color.white)
// table.cell(tab2, 1, 3, text = stringCol != "Dead Zone" ? str.tostring(hours)+ "h" + str.tostring(minutes) + "m": "Dead Zone", text_color = color.white)
// table.cell(tab2, 1, 4, text =stringCol2, text_color = color.white)
// table.cell(tab2, 1, 5, text = str.tostring(hours2) + "h:" + str.tostring(minutes2) + "m", text_color = color.white)
// table.cell(tab2, 1, 6, text = hr4Act, text_color = color.white)
// table.cell(tab2, 1, 7, text = D1Act, text_color = color.white)
nyHour2 = hour (time, "America/New_York")
nyMinute2 = minute(time, "America/New_York")
// @function timeIsInRange2
// @param startHour The starting hour for checking the time range.
// @param startMinute The starting minute within the hour.
// @param endHour The ending hour for checking the time range.
// @param endMinute The ending minute within the hour.
// @returns Boolean indicating if the current time is within the specified range.
// @description Checks if the current chart time falls within a specified time range.
timeIsInRange2(startHour, startMinute, endHour, endMinute) =>
if endHour >= startHour
(nyHour2 > startHour or (nyHour2 == startHour and nyMinute2 >= startMinute)) and
(nyHour2 < endHour or (nyHour2 == endHour and nyMinute2 <= endMinute))
else
(nyHour2 > startHour or (nyHour2 == startHour and nyMinute2 >= startMinute)) or
(nyHour2 < endHour or (nyHour2 == endHour and nyMinute2 <= endMinute))
nyCol = input.color(defval = #f24968, title = "NY Color")
asCol = input.color(defval = #14D990, title = "Asia Color")
loCol = input.color(defval = #F2B807, title = "London Color")
tra = input.int(defval = 98, minval = 0, maxval = 100, title = "Transparency")
bgcolor(timeIsInRange2(9, 30, 16, 0) ? color.new(nyCol, tra) : na)
bgcolor(timeIsInRange2(20, 0, 2 , 0) ? color.new(asCol, tra) : na)
bgcolor(timeIsInRange2(3, 0, 11, 30) ? color.new(loCol, tra) : na)
//---------------------------------------Entry/Exit-------------------------------------------------------
// "Entry/Exit signal"
Entry_exit_ena = input.bool(defval = true, title = "Entry/Exit Signal" ,group = "Entry/exit Signal")
a = input.float(1.5, title="Key Value. 'This changes the sensitivity'", group = "Entry/exit Signal")
c = input.int(7, title="ATR Period", group = "Entry/exit Signal")
ma_length = input.int(50, minval=1, title="Période de la Moyenne Mobile", group = "Entry/exit Signal")
Trail_Stop_ENA = input.bool(defval = true, title = "Trail Stop" ,group = "Entry/exit Signal")
Trail_stop_col = input.color(title = "Trailing stop color", defval = color.yellow, group = "Entry/exit Signal")
//if Entry_exit_ena
// Paramètres de la Moyenne Mobile (Filtre de Tendance)
// Calculs de base
xATR = ta.atr(c)
nLoss = a * xATR
src = close
// Calcul de l'UT BOT Trailing Stop
var float xATRTrailingStop = 0.0
xATRTrailingStop := if src > nz(xATRTrailingStop ) and src > nz(xATRTrailingStop )
math.max(nz(xATRTrailingStop ), src - nLoss)
else if src < nz(xATRTrailingStop ) and src < nz(xATRTrailingStop )
math.min(nz(xATRTrailingStop ), src + nLoss)
else if src > nz(xATRTrailingStop )
src - nLoss
else
src + nLoss
// Calcul de la Moyenne Mobile
ma = ta.ema(close, ma_length)
// Condition de tendance
is_uptrend = close > ma
is_downtrend = close < ma
// Signaux d'achat et de vente selon le trend
buy = ta.crossover(src, xATRTrailingStop) and is_uptrend
sell = ta.crossunder(src, xATRTrailingStop) and is_downtrend
// Tracé de l'UT BOT Trailing Stop
plot(Trail_Stop_ENA ? xATRTrailingStop : na, color=buy ? color.green : sell ? color.red : Trail_stop_col, linewidth=2, title="Trailing Stop Style")
// Indication des signaux sur le graphique
if buy and Entry_exit_ena
label.new(bar_index, low, text='Buy', style=label.style_label_up, yloc=yloc.belowbar ,color=color.green, textcolor=color.white, size=size.small)
if sell and Entry_exit_ena
label.new(bar_index, high, text='Sell', style=label.style_label_down, yloc=yloc.abovebar, color=color.red, textcolor=color.white, size=size.small)
alertcondition(buy, "Buy/Long", "Buy Long")
alertcondition(sell, "Sell/Short", "Sell/Short")
// ----------------------------------------Trend table-----------------------------------------------
// Paramètres utilisateur
afficher_tableau = input.bool(true, "Afficher le tableau", group="Trend Table")
periode_ema = input.int(200, minval=1, title="Période EMA pour les tendances", group="Trend Table")
periode_ema_btc = input.int(200, minval=1, title="Période EMA pour la tendance BTC", group="Trend Table")
// Configuration des périodes de tendance avec un menu déroulant lisible
periode1 = input.string("15m", "Période de tendance 1", options= , group="Trend Table")
periode2 = input.string("1h", "Période de tendance 2", options= , group="Trend Table")
periode3 = input.string("4h", "Période de tendance 3", options= , group="Trend Table")
periode4 = input.string("Day", "Période de tendance 4", options= , group="Trend Table")
// Période de tendance pour le BTC
btc_periode_tendance = input.string("4h", "Période de tendance BTC", options= , group="Trend Table")
// Couleurs pour les tendances
color_haussier = color.green
color_baissier = color.red
// Couleurs de fond alternées pour les lignes (définies globalement)
bg_color_odd = color.new(color.gray, 90) // Gris très clair pour les lignes impaires
bg_color_even = color.new(color.gray, 70) // Gris clair pour les lignes paires
// Fonction de mapping des périodes lisibles en valeurs temporelles standard
f_mapper_periode(timeframe_lisible) =>
switch timeframe_lisible
"5m" => "5"
"15m" => "15"
"1h" => "60"
"4h" => "240"
"8h" => "480"
"12h" => "720"
"Day" => "D"
=> timeframe_lisible // Cas par défaut si aucune correspondance n'est trouvée
// Mapper les périodes sélectionnées
periode1_mapped = f_mapper_periode(periode1)
periode2_mapped = f_mapper_periode(periode2)
periode3_mapped = f_mapper_periode(periode3)
periode4_mapped = f_mapper_periode(periode4)
btc_periode_tendance_mapped = f_mapper_periode(btc_periode_tendance)
// Fonction pour déterminer la session actuelle en utilisant l'heure du graphique (UTC-5)
f_session_actuelle() =>
heure = hour(time)
minute_ = minute(time)
heure_mod = heure * 60 + minute_
sessions_actives = ""
// Définir les plages horaires des sessions en UTC-5
// Session Asie (19:00 - 04:00)
if (heure_mod >= (19 * 60) or heure_mod < (4 * 60))
sessions_actives := sessions_actives + "Asie, "
// Session Londres (03:00 - 12:00)
if (heure_mod >= (3 * 60) and heure_mod < (12 * 60))
sessions_actives := sessions_actives + "Londres, "
// Session New York (08:00 - 17:00)
if (heure_mod >= (8 * 60) and heure_mod < (17 * 60))
sessions_actives := sessions_actives + "NY, "
// Nettoyer la chaîne de caractères pour enlever la virgule finale
if (str.endswith(sessions_actives, ", "))
sessions_actives := str.substring(sessions_actives, 0, str.length(sessions_actives) - 2)
// Si aucune session n'est active
sessions_actives := sessions_actives == "" ? "Hors session" : sessions_actives
sessions_actives
session_actuelle = f_session_actuelle()
// Fonction pour calculer la tendance basée sur l'EMA sans lookahead
f_tendance(symbole, timeframe_tendance, periode_ema) =>
= request.security(symbole, timeframe_tendance, , barmerge.gaps_off, barmerge.lookahead_off)
tendance = cours > ema_valeur ? "Haussier" : "Baissier"
tendance
// Calcul de la tendance du BTC
tendance_btc = f_tendance("BINANCE:BTCUSDT", btc_periode_tendance_mapped, periode_ema_btc)
// Calcul des tendances pour les périodes spécifiées
tendance_periode1 = f_tendance(syminfo.tickerid, periode1_mapped, periode_ema)
tendance_periode2 = f_tendance(syminfo.tickerid, periode2_mapped, periode_ema)
tendance_periode3 = f_tendance(syminfo.tickerid, periode3_mapped, periode_ema)
tendance_periode4 = f_tendance(syminfo.tickerid, periode4_mapped, periode_ema)
// Fonction pour obtenir le nom du ticker actuel
f_ticker_actuel() =>
syminfo.ticker
// Obtenir le ticker actuel
ticker_actuel = f_ticker_actuel()
// Affichage du tableau
if afficher_tableau
// Création du tableau
var table mon_tableau = table.new(position=position.top_right, columns=2, rows=7, bgcolor=color.new(color.black, 0), frame_color=color.new(color.gray, 0), frame_width=1)
if barstate.isfirst
// Première colonne (libellés)
table.cell(table_id=mon_tableau, row=0, column=0, text="Session actuelle:", text_color=color.white, bgcolor=bg_color_even)
table.cell(table_id=mon_tableau, row=1, column=0, text="Tendance:", text_color=color.white, bgcolor=bg_color_odd, text_halign=text.align_right)
table.cell(table_id=mon_tableau, row=6, column=0, text="BTC (" + btc_periode_tendance + "):", text_color=color.white, text_halign=text.align_right, bgcolor=bg_color_even)
table.cell(table_id=mon_tableau, row=2, column=0, text= ticker_actuel + " (" + periode1 + "):", text_color=color.white, bgcolor=bg_color_odd)
table.cell(table_id=mon_tableau, row=3, column=0, text="(" + periode2 + "):", text_color=color.white, text_halign=text.align_right, bgcolor=bg_color_even)
table.cell(table_id=mon_tableau, row=4, column=0, text="(" + periode3 + "):", text_color=color.white, text_halign=text.align_right, bgcolor=bg_color_odd)
table.cell(table_id=mon_tableau, row=5, column=0, text="(" + periode4 + "):", text_color=color.white, text_halign=text.align_right, bgcolor=bg_color_even)
// Définir les couleurs de fond pour les cellules de tendance
trend_btc_color = tendance_btc == "Haussier" ? color.green : color.red
trend_periode1_color = tendance_periode1 == "Haussier" ? color.green : color.red
trend_periode2_color = tendance_periode2 == "Haussier" ? color.green : color.red
trend_periode3_color = tendance_periode3 == "Haussier" ? color.green : color.red
trend_periode4_color = tendance_periode4 == "Haussier" ? color.green : color.red
// Mise à jour des valeurs avec les couleurs appropriées
table.cell(table_id=mon_tableau, row=0, column=1, text=session_actuelle, text_color=color.yellow, bgcolor=bg_color_even)
table.cell(table_id=mon_tableau, row=1, column=1, text="", bgcolor=bg_color_odd)
table.cell(table_id=mon_tableau, row=6, column=1, text=tendance_btc, text_color=color.white, bgcolor=trend_btc_color)
table.cell(table_id=mon_tableau, row=2, column=1, text=tendance_periode1, text_color=color.white, bgcolor=trend_periode1_color)
table.cell(table_id=mon_tableau, row=3, column=1, text=tendance_periode2, text_color=color.white, bgcolor=trend_periode2_color)
table.cell(table_id=mon_tableau, row=4, column=1, text=tendance_periode3, text_color=color.white, bgcolor=trend_periode3_color)
table.cell(table_id=mon_tableau, row=5, column=1, text=tendance_periode4, text_color=color.white, bgcolor=trend_periode4_color)
// Optionnel : Ajouter une étiquette de débogage pour vérifier la session actuelle
// label.new(bar_index, high, text="Session: " + session_actuelle, style=label.style_label_down, color=color.blue, textcolor=color.white, size=size.small, yloc=yloc.abovebar)
Breadth Indicators
EMA (25, 50, 100)Three EMA (25, 50, 100) with three color (red, orange and yellow) with tre different line widht.
Advanced Crypto Scalper ComboIncluded Tools (Advanced Combo):
MACD with Histogram Reversal Detection – momentum shift entry
Bollinger Band Squeeze Breakout – pre-breakout warning
ATR-Based Dynamic TP/SL – for volatility-based risk
RSI/MACD Divergence Detection – reversal confirmation
Order Block / Supply & Demand Zones – smart money zones
Features You’ll See on Chart:
Bollinger Bands and Squeeze background
MACD Cross signals with histogram confirmation
Bullish/Bearish RSI divergence detection
Dynamic Take-Profit / Stop-Loss using ATR
Visual markers for simple demand/supply zones
Micro Channel Alert Pro//@version=6
indicator("Micro Channel Alert Pro", overlay=true)
// === تنظیمات
len = input.int(7, "Micro Channel Length", minval=3, maxval=10)
emaLength = input.int(20, "EMA Length")
minTrendStrength = input.float(0.002, "Min Trend Strength (%)", step=0.0001)
angleThreshold = input.float(25.0, "Min Channel Angle (degrees)")
cooldownBars = input.int(10, "Cooldown after Signal", minval=1)
// === محاسبه EMA و قدرت روند
ema = ta.ema(close, emaLength)
trendStrength = math.abs(ema - ema ) / ema
isTrending = trendStrength > minTrendStrength
// === محاسبه زاویه رگرسیون (به درجه)
regNow = ta.linreg(close, len, 0)
regPrev = ta.linreg(close, len, 1)
angleClose = math.atan(regNow - regPrev) * 180 / math.pi
// === بررسی ساختار HL یا LH
isHL = true
isLH = true
for i = 1 to len - 1
isHL := isHL and (low > low ) and (high > high )
isLH := isLH and (low < low ) and (high < high )
// === بررسی نوسان پایین (کندلهای کوچک)
avgRange = ta.sma(high - low, len)
avgBody = ta.sma(math.abs(close - open), len)
lowVolatility = avgBody / avgRange < 0.6
// === شرایط سیگنال
microUp = isTrending and isLH and angleClose > angleThreshold and lowVolatility and close > high
microDn = isTrending and isHL and angleClose < -angleThreshold and lowVolatility and close < low
// === جلوگیری از سیگنال تکراری
var int lastSignalBar = na
cooldownOk = na(lastSignalBar) or (bar_index - lastSignalBar > cooldownBars)
signalUp = microUp and cooldownOk
signalDn = microDn and cooldownOk
if signalUp or signalDn
lastSignalBar := bar_index
// === نمایش روی چارت
plotshape(signalUp, title="Micro Up", location=location.belowbar, style=shape.labelup, color=color.green, text="Micro ↑")
plotshape(signalDn, title="Micro Down", location=location.abovebar, style=shape.labeldown, color=color.red, text="Micro ↓")
// === آلارم
alertcondition(signalUp, title="Micro Channel Up Alert", message="Micro Channel Up Detected!")
alertcondition(signalDn, title="Micro Channel Down Alert", message="Micro Channel Down Detected!")
BRKT SMART - VWAPVolumeCVDOI (Agg BINANCE OKX)This script is a powerful breakout detection tool designed to capture real market intent by combining VWAP structure, volume surges, and derivatives market data from multiple top-tier exchanges (BINANCE + OKX).
It identifies:
✅ True breakouts with confirmation from volume, Open Interest delta (OIΔ), and directional aggression (CVD)
⚠️ Fake breakouts (traps) where the market lacks new commitment (negative OIΔ and counter-pressure)
🔁 Retests after breakout to help time re-entries or add-ons
🔍 Key Features:
🧠 Aggregated OI & Volume from BINANCE and OKX for a more accurate picture of institutional activity
⚙️ Fully customizable thresholds for volume, OIΔ, and CVD delta
🎯 Optional cooldown between signals to avoid noise
📉 Visual markers for:
Breakouts (BRK↑ / BRK↓)
Traps (FAL↑ / FAL↓)
Retests (Ret↑ / Ret↓)
🟦 VWAP as central structure reference
🔧 Parameters You Can Adjust:
Volume strength (x times the average)
Minimum/maximum thresholds for OIΔ and CVD
Cooldown time between signals
Pullback detection window
Forex Overwiew True Strenght IndexNew oscillator for all currencies—I’m about to add NOK, SEK, and other lower-volume currencies that are interesting due to their lack of correlation with the major ones.
Líneas Horizontales cada 100 Pips - XAUUSDlineas horizontales, del oro cada 100pips para valores sicologicos y tener una mejor operativa
UTBot + EMA Filter (HA + ATR Logic)UT+ EMA = hightest winrate >90% for scalping
UT+ EMA = hightest winrate >90% for scalping
UT+ EMA = hightest winrate >90% for scalping
UT+ EMA = hightest winrate >90% for scalping
My script1// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org
2// © Lkkahar99
3
4//@version=6
5indicator("My script")
6plot(close)
7
Nifty/BankNifty Scanner - RSI, MACD, BB, VWAP1. RSI (Relative Strength Index)
Purpose: Measures market momentum and identifies overbought (>70) or oversold (<30) conditions.
Benefit: Helps catch potential reversal zones or trend exhaustion points.
📈 2. MACD (Moving Average Convergence Divergence)
Purpose: Detects changes in trend direction via crossovers of the MACD line and signal line.
Benefit: Flags bullish and bearish momentum shifts, useful for confirming trade entries/exits.
📉 3. Bollinger Bands
Purpose: Shows volatility using a moving average with upper/lower bands.
Benefit: When price touches the upper/lower bands, it may indicate overextended conditions—potential reversal or breakout areas.
🟠 4. VWAP (Volume Weighted Average Price)
Purpose: Tracks the average price traded based on both volume and price.
Benefit: Acts as a dynamic support/resistance level, especially useful for intraday trading in Nifty/Bank Nifty. Crossing VWAP often signals institutional buying/selling zones.
✅ Overall Benefits
Combines momentum, trend, volatility, and volume-based signals
Helps in multi-angle analysis—confirming trades with multiple indicators
Useful for intraday and swing trading on Nifty/Bank Nifty
Clean visuals and alerts make decision-making faster
Z-Score V2Z-Score Reversal Indicator for TradingView
Catch Overextended Trends & Potential Reversals Using Statistical Z-Scores
📌 Overview
This indicator calculates the Z-score of price movements, helping traders identify overbought and oversold conditions based on standard deviations from the mean.
Plots the Z-score (forest green line) to visualize momentum strength.
Key levels at ±1, ±2, ±3 standard deviations (dashed white lines) highlight potential reversal zones.
Customizable lookback period to adjust sensitivity.
Ideal for:
Mean-reversion strategies
Trend exhaustion detection
Breakout confirmation
📊 How It Works (The Math Behind It)
The Z-score measures how far the current price is from its mean, normalized by standard deviation.
🔹 Formula:
Z = (X − μ) / σ
X = Current price (or selected source)
μ = Simple Moving Average (SMA) over the lookback period
σ = Standard deviation over the lookback period
🎯 Trading Applications
Reversal Trading (Mean Reversion):
Short near +2 or +3 (expecting a pullback toward the mean).
Long near -2 or -3 (expecting a bounce toward the mean).
Trend Continuation (Breakout Confirmation):
If price breaks above +2 or +3, momentum may continue further.
If price breaks below -2 or -3, downtrend may accelerate.
Divergence Detection:
If price makes a new high but Z-score fails to reach prior highs, weakening momentum (bearish divergence).
If price makes a new low but Z-score fails to reach prior lows, potential bullish reversal.
⚙️ Customization Options
Adjustable Lookback Period – Modify sensitivity (shorter = more responsive, longer = smoother).
Source Selection – Apply to close, open, hl2, etc.
Clean Visuals – Plotlines do not distort scaling (only Z-score affects autofit).
Multi-Element CFD Indicator ]Multi-Element CFD Indicator
Simple but very effective script that finds areas of support and resistance through ticks exchange. Only works with CFDs
(You must enter in the settings the value corresponding to the CFD, example: US500 = 500, DAX30 = 30, FRANCE40 = 40 etc ...)
Z Score (Multi-Timeframe)This indicator plots the Z-score of price based on a user-defined timeframe and length. The Z-score measures how far the current price deviates from its historical mean in terms of standard deviations, making it ideal for identifying overbought and oversold conditions in mean reversion setups.
Features:
Adjustable lookback period and standard deviation thresholds
Selectable source price (e.g., close, hl2, ohlc4)
Multi-timeframe support for higher-timeframe confluence
Clean subgraph layout with visual reference lines at ±1 and ±2 standard deviations
This tool is best used in confluence with other indicators or price action for scalping, swing trading, or momentum fading strategies.
Filled/Unfilled Candles + Gap ZonesFilled unfilled filled candlestick
To help traders identify bullish/bearish candles and price gaps that may offer trade opportunities.
---
Features:
1. Candle Coloring:
Green = Unfilled Bullish Candle (close > open).
Red = Filled Bearish Candle (close < open).
2. Gap Detection:
Detects Gap-Up (today's open > yesterday's high).
Detects Gap-Down (today's open < yesterday's low).
3. Gap Zones:
Draws a box around the gap area.
If price fills the gap, the box color turns green to confirm.
4. Alerts:
Alerts you when a gap is filled, signaling potential reversal or continuation setup.
nova_v2🌟 Key Features of the Target Trend Indicator 🌟
🎯 Market Trend Identification: The indicator utilizes advanced technology based on modified moving averages and the ATR indicator to determine the current market direction with incredible precision!
🎨 Candlestick Coloring: It changes the color of candlesticks according to the identified trend, making it super easy for traders to visually understand the prevailing direction at a glance!
🚀 Target Level Identification: The indicator automatically calculates three potential price targets and marks them with clear lines and precise labels - no more guesswork!
📊 Entry and Exit Points Clarification: It clearly identifies the appropriate entry point and stop-loss level, helping traders manage risk effectively and maximize profits!
⚙️ Flexible Settings: It allows users to adjust parameters such as trend length and target levels according to their specific trading needs and preferences!
💼 How to Benefit from the Indicator 💼
You can use the Target Trend Indicator in several trading strategies:
🌊 Trading with the Trend: Traders can use the indicator's signals to enter trades that align with the general market direction for higher probability setups!
💰 Multiple Profit-Taking Strategy: With three target levels, traders can implement a partial exit strategy at each target level to lock in profits while letting winners run!
↩️ Market Reversal Point Detection: The indicator helps identify potential turning points in the market, allowing traders to adjust their strategies accordingly and stay ahead of the crowd!
🔍 Practical Application 🔍
The indicator works effectively on the 15-minute timeframe and is perfect for active traders who prefer shorter timeframes. However, it can also be used on other timeframes by adjusting the parameters accordingly!
The indicator relies on an advanced algorithm that combines exponential moving averages (EMA) and the Average True Range (ATR) indicator to provide accurate signals. It also offers visual market analysis by highlighting potential support and resistance areas!
📈 Potential Results 📈
Using this indicator can help traders:
Improve the risk-to-reward ratio in trades for better overall portfolio performance!
Identify more precise entry and exit points to maximize profits!
Gain a better understanding of market dynamics and trends for smarter trading decisions!
Make more confident trading decisions with less emotional influence - trade like a pro!
RNDR Reentry SystemStrategy for Render for daily trading
It helps getting in and out depending on volume, shape of the candles in the chart, uptrend, Overbought and oversold signals.
🟢🟥 Liquidity Grabs + Volumen Alto by ernesto[Crypto CLEAN]Name: 🟢🟥 Liquidity Grabs + High Volume
This indicator identifies potential liquidity grabs at both swing highs and swing lows, confirmed by a high volume spike. It's designed specifically for crypto trading and works across all timeframes.
🔍 What it does:
Detects possible stop hunts / liquidity sweeps.
Confirms with volume higher than the average (user-defined multiplier).
Marks the event with a clean label above or below the candle (no background coloring).
Great for spotting institutional moves or whale activity.
Compatible with any asset and timeframe.
📌 How it works:
A swing high is considered a liquidity grab if the high breaks recent highs and volume is elevated.
A swing low is a grab if the low breaks recent lows with high volume.
Labels show:
🟥 High Liquidity Grab (above candle)
🟩 Low Liquidity Grab (below candle)
🔔 Alerts included so you never miss a move.
ballenas by ErnestoWhat does this indicator do?
High Volume:
Calculates the average volume of the last n candles (configurable).
Marks candles with volume greater than the average multiplied by a factor (adjustable).
Candle Body:
Marks candles with a large body compared to their range (adjustable ratio).
Direction:
Green circle (buy): When the candle is bullish (close > open) and meets high volume and a large body.
Red circle (sell): When the candle is bearish (close < open) with high volume and a large body.
Automatic alerts: You will receive an alert when an institutional buy or sell is detected.
📊 How to use it?
Open the Pine Editor in TradingView.
Copy and paste this code.
Click Save and then Add to Chart.
Configure alerts according to your needs.
With this, you'll have a real-time indicator that displays circles on the candle itself when large volume purchases or sales are detected.
ballenas by ErnestoWhat does this indicator do?
High Volume:
Calculates the average volume of the last n candles (configurable).
Marks candles with volume greater than the average multiplied by a factor (adjustable).
Candle Body:
Marks candles with a large body compared to their range (adjustable ratio).
Direction:
Green circle (buy): When the candle is bullish (close > open) and meets high volume and a large body.
Red circle (sell): When the candle is bearish (close < open) with high volume and a large body.
Automatic alerts: You will receive an alert when an institutional buy or sell is detected.
📊 How to use it?
Open the Pine Editor in TradingView.
Copy and paste this code.
Click Save and then Add to Chart.
Configure alerts according to your needs.
With this, you'll have a real-time indicator that displays circles on the candle itself when large volume purchases or sales are detected.