Multi-Session Viewer and AnalyzerFully customizable multi-session viewer that takes session analysis to the next level. It allows you to fully customize each session to your liking. Includes a feature that highlights certain periods of time on the chart and a Time Range Marker.
It helps you analyze the instrument that you trade and pinpoint which times are more volatile than others. It also helps you choose the best time to trade your instrument and align your life schedule with the market.
NZDUSD Example:
- 3 major sessions displayed.
- Although this is NZDUSD, Sydney is not the best time to trade this pair. Volatility picks up at Tokyo open.
- I have time to trade in the evening from 18:00 to 22:00 PST. I live in a different time zone, whereas market is based on EST. How does the pair behave during the time I am available to trade based on my time zone? Time Range Marker feature allows you to see this clearly on the chart (black lines).
- I have some time in the morning to trade during New York session, but there is no way I am waking up at 05:00 PST. 06:30 PST seems doable. Blue highlighted area is good time to trade during New York session based on what Bob said. It seem like this aligns with when I am available and when I am able to trade. Volatility is also at its peak.
- I am also available to trade between London close and Tokyo open on some days of the week, but... based on what I see, green highlighted area is clearly showing that I probably don't want to waste my time trading this pair from London close and until Tokyo open. I will use this time for something else rather than be stuck in a range.
Индикаторы и стратегии
Easy Read Short‑Term EMA CrossoverThis TradingView panel shows a multi-indicator setup for analyzing the S&P 500 Index (SPX):
Main chart (top): displays price candles with two Exponential Moving Averages (EMA 8 and 21). When the short-term EMA (blue) crosses above the long-term EMA (red), it gives a Buy signal; when it crosses below, a Sell signal appears — helping identify short-term trend shifts.
Middle panel: shows the Easy-Read RSI, highlighting overbought (OB) and oversold (OS) zones. When RSI moves above 70 it signals potential weakness (sell), and below 30 suggests a rebound zone (buy).
Bottom panel: plots the Easy-Read MACD, which tracks momentum by comparing short- and long-term moving averages. When the MACD line crosses above the Signal line, it indicates bullish momentum; crossing below suggests bearish momentum.
Together, these three indicators provide a layered view of trend, momentum, and potential entry/exit points.
Higher Timeframe CandlesOverlay Higher Timeframe Candles on Lower Timeframes
Select any higher timeframe to overlay on your lower timeframe to easily see LTF market structure within HTF candles.
Please report any bugs or request improvements in the comments.
Obj_XABCD_HarmonicLibrary "Obj_XABCD_Harmonic"
Harmonic XABCD Pattern object and associated methods. Easily validate, draw, and get information about harmonic patterns. See example code at the end of the script for details.
init_params(pct_error, pct_asym, types, w_e, w_p, w_d)
Create a harmonic parameters object (used by xabcd_harmonic object for pattern validation and scoring).
Parameters:
pct_error (float) : Allowed % error of leg retracement ratio versus the defined harmonic ratio
pct_asym (float) : Allowed leg length/period asymmetry % (a leg is considered invalid if it is this % longer or shorter than the average length of the other legs)
types (array) : Array of pattern types to validate (1=Gartley, 2=Bat, 3=Butterfly, 4=Crab, 5=Shark, 6=Cypher)
w_e (float) : Weight of ratio % error (used in score calculation, dft = 1)
w_p (float) : Weight of PRZ confluence (used in score calculation, dft = 1)
w_d (float) : Weight of Point D / PRZ confluence (used in score calculation, dft = 1)
Returns: harmonic_params object instance. It is recommended to store and reuse this object for multiple xabcd_harmonic objects rather than creating new params objects unnecessarily.
init(x, a, b, c, d, params, tp, p)
Initialize an xabcd_harmonic object instance from a given set of points
If the pattern is valid, an xabcd_harmonic object instance is returned. If you want to specify your
own validation and scoring parameters, you can do so by passing a harmonic_params object (params).
Or, if you prefer to do your own validation, you can explicitly pass the harmonic pattern type (tp)
and validation will be skipped. You can also pass in an existing xabcd_harmonic instance if you wish
to re-initialize it (e.g. for re-validation and/or re-scoring).
Parameters:
x (point type from dlmysolutions/Pattern/1) : Point X
a (point type from dlmysolutions/Pattern/1) : Point A
b (point type from dlmysolutions/Pattern/1) : Point B
c (point type from dlmysolutions/Pattern/1) : Point C
d (point type from dlmysolutions/Pattern/1) : Point D
params (harmonic_params) : harmonic_params used to validate and score the pattern. Validation will be skipped if a type (tp) is explicitly passed in.
tp (int) : Pattern type
p (xabcd_harmonic) : xabcd_harmonic object instance to initialize (optional, for re-validation/re-scoring)
Returns: xabcd_harmonic object instance if a valid harmonic, else na
init(xX, xY, aX, aY, bX, bY, cX, cY, dX, dY, params, tp, p)
Initialize an xabcd_harmonic object instance from a given set of x and y coordinate values.
If the pattern is valid, an xabcd_harmonic object instance is returned. If you want to specify your
own validation and scoring parameters, you can do so by passing a harmonic_params object (params).
Or, if you prefer to do your own validation, you can explicitly pass the harmonic pattern type (tp)
and validation will be skipped. You can also pass in an existing xabcd_harmonic instance if you wish
to re-initialize it (e.g. for re-validation and/or re-scoring).
Parameters:
xX (int) : Point X bar index (required)
xY (float) : Point X price/level (required)
aX (int) : Point A bar index (required)
aY (float) : Point A price/level (required)
bX (int) : Point B bar index (required)
bY (float) : Point B price/level (required)
cX (int) : Point C bar index (required)
cY (float) : Point C price/level (required)
dX (int) : Point D bar index
dY (float) : Point D price/level
params (harmonic_params) : harmonic_params used to validate and score the pattern. Validation will be skipped if a type (tp) is explicitly passed in.
tp (int) : Pattern type
p (xabcd_harmonic) : xabcd_harmonic object instance to initialize (optional, for re-validation/re-scoring)
Returns: xabcd_harmonic object instance if a valid harmonic, else na
init(pattern, params, tp, p)
Initialize an xabcd_harmonic object instance from a given pattern
If the pattern is valid, an xabcd_harmonic object instance is returned. If you want to specify your
own validation and scoring parameters, you can do so by passing a harmonic_params object (params).
Or, if you prefer to do your own validation, you can explicitly pass the harmonic pattern type (tp)
and validation will be skipped. You can also pass in an existing xabcd_harmonic instance if you wish
to re-initialize it (e.g. for re-validation and/or re-scoring).
Parameters:
pattern (pattern type from dlmysolutions/Pattern/1) : Pattern
params (harmonic_params) : harmonic_params used to validate and score the pattern. Validation will be skipped if a type (tp) is explicitly passed in.
tp (int) : Pattern type
p (xabcd_harmonic) : xabcd_harmonic object instance to initialize (optional, for re-validation/re-scoring)
Returns: xabcd_harmonic object instance if a valid harmonic, else na
method get_name(p)
Get the pattern name
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic) : Instance of xabcd_harmonic object
Returns: Pattern name (string)
method get_symbol(p)
Get the pattern symbol
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic) : Instance of xabcd_harmonic object
Returns: Pattern symbol (1 byte string)
method get_pid(p)
Get the Pattern ID. Patterns of the same type with the same coordinates will have the same Pattern ID.
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic) : Instance of xabcd_harmonic object
Returns: Pattern ID (string)
method set_target(p, target, target_lvl, calc_target)
Set value for a target. Use the calc_target parameter to automatically calculate the target for a specific harmonic ratio.
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic) : Instance of xabcd_harmonic object
target (int) : Target (1 or 2)
target_lvl (float) : Target price/level (required if calc_target is not specified)
calc_target (string) : Target to auto calculate (required if target is not specified)
Options:
Returns: Target price/level (float)
method erase_pattern(p)
Erase the pattern
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic) : Instance of xabcd_harmonic object
Returns: p
method draw_pattern(p, clr)
Draw the pattern
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic) : Instance of xabcd_harmonic object
clr (color)
Returns: Pattern lines
method erase_label(p)
Erase the pattern label
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic) : Instance of xabcd_harmonic object
Returns: p
method draw_label(p, clr, txt_clr, txt, tooltip)
Draw the pattern label. Default text is the pattern name.
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic) : Instance of xabcd_harmonic object
clr (color) : Label color
txt_clr (color) : Text color
txt (string) : Label text
tooltip (string) : Tooltip text
Returns: Label
harmonic_params
Validation and scoring parameters for a Harmonic Pattern object (xabcd_harmonic)
Fields:
pct_error (series float) : Allowed % error of leg retracement ratio versus the defined harmonic ratio
pct_asym (series float)
types (array)
w_e (series float)
w_p (series float)
w_d (series float)
xabcd_harmonic
Harmonic Pattern object
Fields:
bull (series bool) : Bullish pattern flag
tp (series int)
x (point type from dlmysolutions/Pattern/1)
a (point type from dlmysolutions/Pattern/1)
b (point type from dlmysolutions/Pattern/1)
c (point type from dlmysolutions/Pattern/1)
d (point type from dlmysolutions/Pattern/1)
r_xb (series float)
re_xb (series float)
r_ac (series float)
re_ac (series float)
r_bd (series float)
re_bd (series float)
r_xd (series float)
re_xd (series float)
score (series float)
score_eAvg (series float)
score_prz (series float)
score_eD (series float)
prz_bN (series float)
prz_bF (series float)
prz_xN (series float)
prz_xF (series float)
t1Hit (series bool) : Target 1 flag
t1 (series float)
t2Hit (series bool)
t2 (series float)
sHit (series bool) : Stop flag
stop (series float) : Stop level
entry (series float) : Entry level
eHit (series bool)
e (point type from dlmysolutions/Pattern/1)
invalid_d (series bool)
pLines (array)
pLabel (series label)
pid (series string)
params (harmonic_params)
PatternLibrary "Pattern"
Pattern object definitions and functions. Easily draw and keep track of patterns, legs, and points.
Supported pattern types:
Type Leg validation # legs
"xabcd" Direction 3 or 4 (point D not required)
"zigzag" Direction >= 2
"free" None >= 2
Summary of exported types and associated methods/functions:
type point A point on the chart (x,y)
draw_label() Draw a point label
erase_label() Erase a point label
type leg A pattern leg (i.e. point A to point B)
leg_init() Initialize/instantiate a leg
draw() Draw a leg
erase() Erase a leg
leg_getLineTerms() Get the slope and y-intercept of a leg
leg_getPrice() Get price (Y) at a given bar index (X) within a leg
type pattern A pattern (set of at least 2 connected legs)
pattern_init() Initialize/instantiate a pattern
draw() Draw a pattern
erase() Erase a pattern
*See bottom of the script for example usage*
erase_label(this)
Delete the point label
Parameters:
this (point) : Point
Returns: Void
draw_label(this, position, clr, transp, txt_clr, txt, tooltip, size)
Draw the point label
Parameters:
this (point) : Point
position (string)
clr (color)
transp (float)
txt_clr (color)
txt (string)
tooltip (string)
size (string)
Returns: line
leg_init(a, b, prev, next, line)
Initialize a pattern leg
Parameters:
a (point) : Point A (required)
b (point) : Point B (required)
prev (leg) : Previous leg
next (leg) : Next leg
line (line) : Line
Returns: New instance of leg object
erase(this)
Delete the pattern leg
Parameters:
this (leg) : Leg
Returns: Void
erase(this)
Delete the pattern lines
Parameters:
this (pattern) : Pattern
Returns: Void
draw(this, clr, style, transp, width)
Draw the pattern leg
Parameters:
this (leg) : Leg
clr (color) : Color
style (string) : Style ("solid", "dotted", "dashed", "arrowleft", "arrowright")
transp (float) : Transparency
width (int) : Width
Returns: line
draw(this, clr, style, transp, width)
Draw the pattern
Parameters:
this (pattern) : Pattern
clr (color) : Color
style (string) : Style ("solid", "dotted", "dashed", "arrowleft", "arrowright")
transp (float) : Transparency
width (int) : Width
Returns: line
leg_getLineTerms(this)
Get the slope and y-intercept of a leg
Parameters:
this (leg) : Leg
Returns:
leg_getPrice(this, index)
Get the price (Y) at a given bar index (X) within the leg
Parameters:
this (leg) : Leg
index (int) : Bar index
Returns: Price (float)
pattern_init(legs, tp, name, subType, pid)
Initialize a pattern object from a given set of legs
Parameters:
legs (array) : Array of pattern legs (required)
tp (string) : Pattern type ("zigzag", "xabcd", or "free". dft = "free")
name (string) : Pattern name
subType (string) : Pattern subtype
pid (string) : Pattern Identifier string
Returns: New instance of pattern object, if one was successfully created
pattern_init(points, tp, name, subType, pid)
Initialize a pattern object from a given set of points
Parameters:
points (array)
tp (string) : Pattern type ("zigzag", "xabcd", or "free". dft = "free")
name (string) : Pattern name
subType (string) : Pattern subtype
pid (string) : Pattern Identifier string
Returns: New instance of pattern object, if one was successfully created
point
A point on the chart (x,y)
Fields:
x (series int) : Bar index (x coordinate)
y (series float)
label (series label)
leg
A pattern leg (point A to point B)
Fields:
a (point) : Point A
b (point)
deltaX (series int)
deltaY (series float)
prev (leg)
next (leg)
retrace (series float)
line (series line)
pattern
A pattern (set of at least 2 connected legs)
Fields:
legs (array)
type (series string)
subType (series string)
name (series string)
pid (series string)
DrawLibrary "Draw"
Draw patterns, lines, labels, shapes etc.
pat_colors(bull, buLn, beLn, ltxt)
Parameters:
bull (bool)
buLn (color)
beLn (color)
ltxt (color)
size(size)
Parameters:
size (string)
label_style(style)
Parameters:
style (string)
line_style(style)
Parameters:
style (string)
font_size(size)
Parameters:
size (string)
xabcd(xX, xY, aX, aY, bX, bY, cX, cY, dX, dY, iE, bull, bu, be)
Draw XABCD pattern
Parameters:
xX (int)
xY (float)
aX (int)
aY (float)
bX (int)
bY (float)
cX (int)
cY (float)
dX (int)
dY (float)
iE (float)
bull (bool)
bu (color)
be (color)
xabcd_inProgress(bull, type, tLimit, entry, stop, t1, t2, bcNt, bcFt, xaNt, xaFt, xX, xY, aY, bX, bY, cY, dX, dY, cBu, cBe, lTxt)
draw PRZ, entry, stop, targets, and projected reversal paths for XABCD pattern
Parameters:
bull (bool)
type (int)
tLimit (int)
entry (float)
stop (float)
t1 (float)
t2 (float)
bcNt (float)
bcFt (float)
xaNt (float)
xaFt (float)
xX (int)
xY (float)
aY (float)
bX (int)
bY (float)
cY (float)
dX (int)
dY (float)
cBu (color)
cBe (color)
lTxt (color)
xabcd_incInProgress(bull, type, tLimit, entry, xX, xY, aY, bX, bY, cX, cY, dY, cBu, cBe, lTxt)
Parameters:
bull (bool)
type (int)
tLimit (int)
entry (float)
xX (int)
xY (float)
aY (float)
bX (int)
bY (float)
cX (int)
cY (float)
dY (float)
cBu (color)
cBe (color)
lTxt (color)
xabcd_inProgress2(bull, tLimit, entry, stop, t1, t2, xadl, bcdl, xcdl, xX, xY, bX, bY, dX, dY, cBu, cBe, lTxt)
draw PRZ, entry, stop, targets, and projected reversal paths for XABCD pattern
Parameters:
bull (bool)
tLimit (int)
entry (float)
stop (float)
t1 (float)
t2 (float)
xadl (float)
bcdl (float)
xcdl (float)
xX (int)
xY (float)
bX (int)
bY (float)
dX (int)
dY (float)
cBu (color)
cBe (color)
lTxt (color)
eHitLbl(x, e, dX, dY, bull, lOnly)
Draw entry hit label
Parameters:
x (int)
e (float)
dX (int)
dY (float)
bull (bool)
lOnly (bool)
tHitLbl(x, tgt, eX, eY, bull)
Draw target hit label
Parameters:
x (int)
tgt (float)
eX (int)
eY (float)
bull (bool)
sHitLbl(x, s, eX, eY, bull)
Draw stop hit label
Parameters:
x (int)
s (float)
eX (int)
eY (float)
bull (bool)
level(y, x, type, length, extend, padding, b_style, colr, txt_color, txt, txt_loc, txt_size)
Draw a level (box)
Parameters:
y (float)
x (int)
type (int)
length (int)
extend (string)
padding (float)
b_style (string)
colr (color)
txt_color (color)
txt (string)
txt_loc (string)
txt_size (string)
incTtTxt(tp, name, xbr, xbre, acr, acre, bcN, bcF, xaN, xaF, score, e)
Parameters:
tp (int)
name (string)
xbr (float)
xbre (float)
acr (float)
acre (float)
bcN (float)
bcF (float)
xaN (float)
xaF (float)
score (float)
e (float)
TALibrary "TA"
General technical analysis functions
div_bull(pS, iS, cp_length_after, cp_length_before, pivot_length, lookback, lookback_pivs, no_broken, pW, iW, hidW, regW)
Test for bullish divergence
Parameters:
pS (float) : Price series (float)
iS (float) : Indicator series (float)
cp_length_after (simple int) : Bars after current (divergent) pivot low to be considered a valid pivot (optional int)
cp_length_before (simple int) : Bars before current (divergent) pivot low to be considered a valid pivot (optional int)
pivot_length (simple int) : Bars before and after prior pivot low to be considered valid pivot (optional int)
lookback (simple int) : Bars back to search for prior pivot low (optional int)
lookback_pivs (simple int) : Pivots back to search for prior pivot low (optional int)
no_broken (simple bool) : Flag to only consider divergence valid if the pivot-to-pivot trendline is unbroken (optional bool)
pW (simple float) : Weight of change in price, used in degree of divergence calculation (optional float)
iW (simple float) : Weight of change in indicator, used in degree of divergence calculation (optional float)
hidW (simple float) : Weight of hidden divergence, used in degree of divergence calculation (optional float)
regW (simple float) : Weight of regular divergence, used in degree of divergence calculation (optional float)
Returns:
flag = true if divergence exists (bool)
degree = degree (strength) of divergence (float)
type = 1 = regular, 2 = hidden (int)
lx1 = x coordinate 1 (int)
ly1 = y coordinate 1 (float)
lx2 = x coordinate 2 (int)
ly2 = y coordinate 2 (float)
div_bear(pS, iS, cp_length_after, cp_length_before, pivot_length, lookback, lookback_pivs, no_broken, pW, iW, hidW, regW)
Test for bearish divergence
Parameters:
pS (float) : Price series (float)
iS (float) : Indicator series (float)
cp_length_after (simple int) : Bars after current (divergent) pivot high to be considered a valid pivot (optional int)
cp_length_before (simple int) : Bars before current (divergent) pivot highto be considered a valid pivot (optional int)
pivot_length (simple int) : Bars before and after prior pivot high to be considered valid pivot (optional int)
lookback (simple int) : Bars back to search for prior pivot high (optional int)
lookback_pivs (simple int) : Pivots back to search for prior pivot high (optional int)
no_broken (simple bool) : Flag to only consider divergence valid if the pivot-to-pivot trendline is unbroken (optional bool)
pW (simple float) : Weight of change in price, used in degree of divergence calculation (optional float)
iW (simple float) : Weight of change in indicator, used in degree of divergence calculation (optional float)
hidW (simple float) : Weight of hidden divergence, used in degree of divergence calculation (optional float)
regW (simple float) : Weight of regular divergence, used in degree of divergence calculation (optional float)
Returns:
flag = true if divergence exists (bool)
degree = degree (strength) of divergence (float)
type = 1 = regular, 2 = hidden (int)
lx1 = x coordinate 1 (int)
ly1 = y coordinate 1 (float)
lx2 = x coordinate 2 (int)
ly2 = y coordinate 2 (float)
test_cd(cd, bc, xa, xc, ad, pErr, p_types)
Validate CD leg of XABCD
Parameters:
cd (float)
bc (float)
xa (float)
xc (float)
ad (float)
pErr (float)
p_types (array)
pat_xabcd_testSym(xax, abx, bcx, cdx, pAsym)
Validate ΔX symmetry of XABCD pattern
Parameters:
xax (int)
abx (int)
bcx (int)
cdx (int)
pAsym (float)
harmonic_xabcd_validate(xX, xY, aX, aY, bX, bY, cX, cY, dX, dY, pErr, pAsym, gart, bat, bfly, crab, shark, cyph)
Validate harmonic XABCD pattern
Parameters:
xX (int) : X coordinate of point X (int)
xY (float) : Y coordinate of point X (float)
aX (int) : X coordinate of point A (int)
aY (float) : Y coordinate of point A (float)
bX (int) : X coordinate of point B (int)
bY (float) : Y coordinate of point B (float)
cX (int) : X coordinate of point C (int)
cY (float) : Y coordinate of point C (float)
dX (int) : X coordinate of point D (int)
dY (float) : Y coordinate of point D (float)
pErr (float) : Acceptable percent error of leg ratios (does not apply to legs defined within a range) (float)
pAsym (float) : Acceptable percent asymmetry of leg ΔX (each leg tested against average ΔX of prior legs) (float)
gart (bool) : Flag to validate Gartley pattern (bool)
bat (bool) : Flag to validate Bat pattern (bool)
bfly (bool) : Flag to validate Butterfly pattern (bool)
crab (bool) : Flag to validate Crab pattern (bool)
shark (bool) : Flag to validate Shark pattern (bool)
cyph (bool) : Flag to validate Cypher pattern (bool)
Returns:
flag = true if valid harmonic
t1 = true if valid gartley
t2 = true if valid bat
t3 = true if valid butterfly
t4 = true if valid crab
t5 = true if valid shark
t6 = true if valid cypher
harmonic_xabcd_validateIncomplete(xX, xY, aX, aY, bX, bY, cX, cY, pErr, pAsym, gart, bat, bfly, crab, shark, cyph)
Validate the first 3 legs of a harmonic XABCD pattern
Parameters:
xX (int) : X coordinate of point X (int)
xY (float) : Y coordinate of point X (float)
aX (int) : X coordinate of point A (int)
aY (float) : Y coordinate of point A (float)
bX (int) : X coordinate of point B (int)
bY (float) : Y coordinate of point B (float)
cX (int) : X coordinate of point C (int)
cY (float) : Y coordinate of point C (float)
pErr (float) : Acceptable percent error of leg ratios (does not apply to legs defined within a range) (float)
pAsym (float) : Acceptable percent asymmetry of leg ΔX (each leg tested against average ΔX of prior legs) (float)
gart (bool) : Flag to validate Gartley pattern (bool)
bat (bool) : Flag to validate Bat pattern (bool)
bfly (bool) : Flag to validate Butterfly pattern (bool)
crab (bool) : Flag to validate Crab pattern (bool)
shark (bool) : Flag to validate Shark pattern (bool)
cyph (bool) : Flag to validate Cypher pattern (bool)
Returns:
flag = true if valid harmonic
t1 = true if valid gartley
t2 = true if valid bat
t3 = true if valid butterfly
t4 = true if valid crab
t5 = true if valid shark
t6 = true if valid cypher
harmonic_xabcd_prz(type, xY, aY, bY, cY)
Get the potential reversal zone (PRZ) levels of a harmonic XABCD pattern
Parameters:
type (int) : Harmonic pattern type (int - 1 = Gartley, 2 = Bat, 3 = Butterfly, 4 = Crab, 5 = Shark, 6 = Cypher)
xY (float) : Y coordinate of point X (float)
aY (float) : Y coordinate of point A (float)
bY (float) : Y coordinate of point B (float)
cY (float) : Y coordinate of point C (float)
Returns:
bc_u = nearest BC retracement/extension level (nearest to point C)
bc_l = farthest BC retracement/extension level (nearest to point C)
xa_u = nearest XA retracement/extension level (or the only XA level, if applicable)
xa_l = farthest XA retracement/extension level (or na if not applicable)
harmonic_xabcd_przClosest(l1, l2, l3, l4)
Get the confluent PRZ levels (i.e. the two closest PRZ levels)
Order of arguments does not matter
Parameters:
l1 (float) : level 1 (float)
l2 (float) : level 2 (float)
l3 (float) : level 3 (float)
l4 (float) : level 4 (optional, float)
Returns:
lL = lower confluent PRZ level
lH = higher confluent PRZ level
harmonic_xabcd_przRange(l1, l2, l3, l4)
Get upper and lower PRZ levels
Parameters:
l1 (float)
l2 (float)
l3 (float)
l4 (float)
harmonic_xabcd_eD(cpl1, cpl2, xY, aY, dY)
Measure closeness of D to either of the two closest PRZ levels, relative to height of the XA leg
Parameters:
cpl1 (float)
cpl2 (float)
xY (float)
aY (float)
dY (float)
harmonic_xabcd_przScore(xY, aY, l1, l2, l3, l4)
Measure the closeness of the two closest PRZ levels, relative to the height of the XA leg
Parameters:
xY (float)
aY (float)
l1 (float)
l2 (float)
l3 (float)
l4 (float)
harmonic_xabcd_rAndE(type, l, l1, l2)
Get the ratio of two pattern legs, and the percent error from the theoretical harmonic ratio
Order of arguments does not matter
Parameters:
type (int) : Harmonic pattern type (int - 1 = Gartley, 2 = Bat, 3 = Butterfly, 4 = Crab)
l (string) : Leg ID ("xab", "abc", "bcd", or "xad") (string)
l1 (float) : Line 1 height (float)
l2 (float) : Line 2 height (float)
Returns:
harmonic_xabcd_eAvg(xbre, acre, bdre, xdre, xcdre)
Get the avg retracement ratio % error
Parameters:
xbre (float)
acre (float)
bdre (float)
xdre (float)
xcdre (float)
pat_xabcd_asym(xX, aX, bX, cX, dX)
Get the avg asymmetry %
Parameters:
xX (int)
aX (int)
bX (int)
cX (int)
dX (int)
harmonic_xabcd_entry(t, tp, xY, aY, bY, cY, dY, e_afterC, e_lvlc, e_afterD, e_lvldPct)
Get potential entry levels for a harmonic XABCD pattern
Parameters:
t (bool)
tp (int)
xY (float)
aY (float)
bY (float)
cY (float)
dY (float)
e_afterC (bool)
e_lvlc (string)
e_afterD (bool)
e_lvldPct (float)
xabcd_entryHit(t, afterC, afterD, dX, e_afterC, e_afterD, dValBars)
Determine if entry level was reached. Assumes pattern is active/not timed out.
Parameters:
t (bool)
afterC (float)
afterD (float)
dX (int)
e_afterC (bool)
e_afterD (bool)
dValBars (int)
pat_xabcd_validate(xX, xY, aX, aY, bX, bY, cX, cY, dX, dY, xab, abc, bcd, xad, xcd, pErr, pAsym)
Validate custom XABCD pattern
Parameters:
xX (int) : X coordinate of point X (int)
xY (float) : Y coordinate of point X (float)
aX (int) : X coordinate of point A (int)
aY (float) : Y coordinate of point A (float)
bX (int) : X coordinate of point B (int)
bY (float) : Y coordinate of point B (float)
cX (int) : X coordinate of point C (int)
cY (float) : Y coordinate of point C (float)
dX (int) : X coordinate of point D (int)
dY (float) : Y coordinate of point D (float)
xab (float)
abc (float)
bcd (float)
xad (float)
xcd (float)
pErr (float) : Acceptable percent error of leg ratios (does not apply to legs defined within a range) (float)
pAsym (float) : Acceptable percent asymmetry of leg ΔX (each leg tested against average ΔX of prior legs) (float)
Returns: TRUE if pattern is valid
pat_xabcd_validateIncomplete(xX, xY, aX, aY, bX, bY, cX, cY, xab, abc, pErr, pAsym)
Validate the first 3 legs of a custom XABCD pattern
Parameters:
xX (int) : X coordinate of point X (int)
xY (float) : Y coordinate of point X (float)
aX (int) : X coordinate of point A (int)
aY (float) : Y coordinate of point A (float)
bX (int) : X coordinate of point B (int)
bY (float) : Y coordinate of point B (float)
cX (int) : X coordinate of point C (int)
cY (float) : Y coordinate of point C (float)
xab (float)
abc (float)
pErr (float) : Acceptable percent error of leg ratios (does not apply to legs defined within a range) (float)
pAsym (float) : Acceptable percent asymmetry of leg ΔX (each leg tested against average ΔX of prior legs) (float)
Returns: TRUE if first 3 legs are valid
pat_xabcd_prz(xY, aY, bY, cY, xad, bcd, xcd)
Get the potential reversal zone (PRZ) levels of a custom XABCD pattern
Parameters:
xY (float) : Y coordinate of point X (float)
aY (float) : Y coordinate of point A (float)
bY (float) : Y coordinate of point B (float)
cY (float) : Y coordinate of point C (float)
xad (float)
bcd (float)
xcd (float)
Returns:
pat_xabcd_avgDev(xX, xY, aX, aY, bX, bY, cX, cY, dX, dY)
Get the average deviation of an XABCD pattern
Parameters:
xX (int)
xY (float)
aX (int)
aY (float)
bX (int)
bY (float)
cX (int)
cY (float)
dX (int)
dY (float)
harmonic_xabcd_score(tp, xX, xY, aX, aY, bX, bY, cX, cY, dX, dY)
Get score values for a pattern
Parameters:
tp (int)
xX (int)
xY (float)
aX (int)
aY (float)
bX (int)
bY (float)
cX (int)
cY (float)
dX (int)
dY (float)
harmonic_xabcd_scoreTot(asym, eavg, przscore, eD, tp, w_a, w_e, w_p, w_d)
Get total weighted score value for a pattern
Parameters:
asym (float)
eavg (float)
przscore (float)
eD (float)
tp (int)
w_a (float)
w_e (float)
w_p (float)
w_d (float)
harmonic_xabcd_targets(xY, aY, bY, cY, dY, tgt1, tgt2, tgt3)
Get target level
Parameters:
xY (float)
aY (float)
bY (float)
cY (float)
dY (float)
tgt1 (string)
tgt2 (string)
tgt3 (string)
harmonic_xabcd_stop(stop, stopPct, bull, xY, dY, upper, lower, t1, eY)
Get stop level
Parameters:
stop (string)
stopPct (float)
bull (bool)
xY (float)
dY (float)
upper (float)
lower (float)
t1 (float)
eY (float)
harmonic_xabcd_fibDispTxt(tp)
Get fib ratio display text
Parameters:
tp (int)
harmonic_xabcd_symbol(tp)
Get pattern symbol
Parameters:
tp (int)
pat_xabcd(x_is_low, pivot_length, source, conf_length, incomplete)
Determine if an XABCD pattern has just completed (i.e. point D is on the previous bar)
Parameters:
x_is_low (bool) : Flag to determine if point X is a low pivot, i.e. bullish pattern (bool, dft = true)
pivot_length (int) : Number of bars before and after a valid pivot (int, dft = 5)
source (float) : Source series (float, dft = na, will use high and low series)
conf_length (int) : Number of trailing bars after pivot point D to confirm a valid pattern (int, dft = 1)
incomplete (bool) : Flag to return an incomplete XABC pattern (bool, dft = false)
Returns:
flag = true if valid XABCD pattern completed on previous bar
xx = X coordinate of point X (int)
xy = Y coordinate of point X (float)
ax = X coordinate of point A (int)
ay = Y coordinate of point A (float)
bx = X coordinate of point B (int)
by = Y coordinate of point B (float)
cx = X coordinate of point C (int)
cy = Y coordinate of point C (float)
dx = X coordinate of point D (int)
dy = Y coordinate of point D (float)
pat_xabcdIncomplete(x_is_low, pivot_length, source, conf_length)
Determine if an XABCD pattern is in progress (point C was just confirmed)
Parameters:
x_is_low (bool) : Flag to determine if point X is a low pivot, i.e. bullish M pattern (bool, dft = true)
pivot_length (int) : Number of bars before and after a valid pivot (int, dft = 5)
source (float) : Source series (float, dft = na, will use high and low series)
conf_length (int) : Number of trailing bars after pivot point D to confirm a valid pattern (int, dft = 1)
Returns:
flag = true if valid XABC pattern completed on bar_index
xx = X coordinate of point X (int)
xy = Y coordinate of point X (float)
ax = X coordinate of point A (int)
ay = Y coordinate of point A (float)
bx = X coordinate of point B (int)
by = Y coordinate of point B (float)
cx = X coordinate of point C (int)
cy = Y coordinate of point C (float)
dx = X coordinate of point D (int)
dy = Y coordinate of point D (float)
success(eX, stop, t1, t2)
Determine if trade is successful
Parameters:
eX (int) : Entry bar index (int)
stop (float) : Stop level (float)
t1 (float) : Target 1 level (float)
t2 (float) : Target 2 level (float)
Returns:
tradeClosed(eX, eY, stop, t1h, t2h, t1, t2)
Determine if Target or Stop was hit on the current bar
Parameters:
eX (int)
eY (float)
stop (float)
t1h (bool)
t2h (bool)
t1 (float)
t2 (float)
TrigLibrary "Trig"
Trigonometric functions
rt_get_angleAlpha(a, b, c, deg)
Get angle α of a right triangle, given the lengths of its sides
Parameters:
a (float) : length of leg a (float)
b (float) : length of leg b (float)
c (float) : length of hypotenuse (float)
deg (simple bool) : flag to return angle in degrees (bool - default = false)
Returns: angle α in radians (or degrees if deg == true)
rt_get_angleAlphaFromLine(x1, y1, x2, y2, l, deg)
Get angle α of a right triangle formed by the given line
Parameters:
x1 (int) : x coordinate 1 (int - optional, required if argument l is not specified)
y1 (float) : y coordinate 1 (float - optional, required if argument l is not specified)
x2 (int) : x coordinate 2 (int - optional, required if argument l is not specified)
y2 (float) : y coordinate 2 (float - optional, required if argument l is not specified)
l (line) : line object (line - optional, required if x1, y1, x2, and y2 agruments are not specified)
deg (simple bool) : flag to return angle in degrees (bool - default = false)
Returns: angle α in radians (or degrees if deg == true)
rt_get_angleBeta(a, b, c, deg)
Get angle β of a right triangle, given the lengths of its sides
Parameters:
a (float) : length of leg a (float)
b (float) : length of leg b (float)
c (float) : length of hypotenuse (float)
deg (simple bool) : flag to return angle in degrees (bool - default = false)
Returns: angle β in radians (or degrees if deg == true)
rt_get_angleBetaFromLine(x1, y1, x2, y2, l, deg)
Get angle β of a right triangle formed by the given line
Parameters:
x1 (int) : x coordinate 1 (int - optional, required if argument l is not specified)
y1 (float) : y coordinate 1 (float - optional, required if argument l is not specified)
x2 (int) : x coordinate 2 (int - optional, required if argument l is not specified)
y2 (float) : y coordinate 2 (float - optional, required if argument l is not specified)
l (line) : line object (line - optional, required if x1, y1, x2, and y2 agruments are not specified)
deg (simple bool) : flag to return angle in degrees (bool - default = false)
Returns: angle β in radians (or degrees if deg == true)
AlgebraLibrary "Algebra"
line_fromXy(x1, y1, x2, y2)
Get line slope and y-intercept from coordinates
Parameters:
x1 (int) : x coordinate 1 (int - bar index)
y1 (float) : y coordinate 1 (float - price/value)
x2 (int) : x coordinate 2 (int - bar index)
y2 (float) : y coordinate 2 (float - price/value)
Returns: of line
line_getPrice(x, slope, yInt)
Get price at X coordinate, given line slope and y-intercept
Parameters:
x (int) : x coordinate to solve for y (int - bar index)
slope (float) : slope of line (float)
yInt (float) : y-intercept of line (float)
Returns: y (price/value)
line_getPrice_fromXy(x, x1, y1, x2, y2)
Get price at X coordinate, given two points on a line
Parameters:
x (int) : x coordinate to solve for y (int - bar index)
x1 (int) : x coordinate 1 (int - bar index)
y1 (float) : y coordinate 1 (float - price/value)
x2 (int) : x coordinate 2 (int - bar index)
y2 (float) : y coordinate 2 (float - price/value)
Returns: y (price/value)
line_getRtSides(x1, y1, x2, y2, l)
Get length of sides of a right triangle formed by a given line
Parameters:
x1 (int) : x coordinate 1 (int - optional, required if argument l is not specified)
y1 (float) : y coordinate 1 (float - optional, required if argument l is not specified)
x2 (int) : x coordinate 2 (int - optional, required if argument l is not specified)
y2 (float) : y coordinate 2 (float - optional, required if argument l is not specified)
l (line) : line object (line - optional, required if x1, y1, x2, y2 agruments are not specified)
Returns:
line_length(x1, y1, x2, y2, l)
Get length of line, given a line object or two sets of coordinates
Parameters:
x1 (int) : x coordinate 1 (int - optional, required if argument l is not specified)
y1 (float) : y coordinate 1 (float - optional, required if argument l is not specified)
x2 (int) : x coordinate 2 (int - optional, required if argument l is not specified)
y2 (float) : y coordinate 2 (float - optional, required if argument l is not specified)
l (line) : line object (line - optional, required if x1, y1, x2, y2 agruments are not specified)
Returns: length of line (float)
FibonacciLibrary "Fibonacci"
General Fibonacci functions. Get fib numbers, ratios, etc.
fib_derived(f, precision)
Get the precise Fibonacci ratio, to the specified number of decimal places
Parameters:
f (float) : Fibonacci ratio (string, in form #.###)
precision (simple int) : Number of decimal places (optional int, dft = 16, max = 32)
Returns: Precise Fibonacci ratio (float)
* Deprecated (use fib_precise() instead), but keeping it here for science / experimenting with derivations
fib_precise(f, precision)
Get the precise Fibonacci ratio, to the specified number of decimal places
Parameters:
f (float) : Fibonacci ratio (string, in form #.###)
precision (simple int) : Number of decimal places (optional int, dft = 16, max = 16)
Returns: Precise Fibonacci ratio (float)
fib_from_string(r)
Get fib ratio value from string
Parameters:
r (string) : Fib ratio string (e.g. ".618")
Returns: Fibonacci ratio value (float)
fib_n(n)
Calculate the Nth number in the Fibonacci sequence
Parameters:
n (int) : Index/number in sequence (int)
Returns: Fibonacci number (int)
UtilitiesLibrary "Utilities"
General utilities
print_series(s, skip_na, position, show_index, from_index, to_index)
Print series values
Parameters:
s (string) : Series (string)
skip_na (simple bool) : Flag to skip na values (optional bool, dft = false)
position (simple string) : Position to print the Table (optional string, dft = position.bottom_center)
show_index (simple bool) : Flag to show series indices (optional bool, dft = true)
from_index (int) : First index to print (optional int, dft = 0)
to_index (int) : Last index to print (optional int, dft = last_bar_index)
Returns: Table object, if series was printed
print(v, position, at_index)
Print value
Parameters:
v (string) : Value (string)
position (simple string) : Position to print the Table (optional string, dft = position.bottom_center)
at_index (int) : Index at which to print (optional int, dft = bar_index)
Returns: Table object, if value was printed
print(v, position, at_index)
Print value
Parameters:
v (int) : Value (int)
position (simple string) : Position to print the Table (optional string, dft = position.bottom_center)
at_index (int) : Index at which to print (optional int, dft = bar_index)
Returns: Table object, if value was printed
print(v, position, at_index)
Print value
Parameters:
v (float) : Value (float)
position (simple string) : Position to print the Table (optional string, dft = position.bottom_center)
at_index (int) : Index at which to print (optional int, dft = bar_index)
Returns: Table object, if value was printed
print(v, position, at_index)
Print value
Parameters:
v (bool) : Value (bool)
position (simple string) : Position to print the Table (optional string, dft = position.bottom_center)
at_index (int) : Index at which to print (optional int, dft = bar_index)
Returns: Table object, if value was printed
boolToIntArr(a)
return array of offsets (int) of true values
Parameters:
a (array)
intToBoolArr(a, n)
Parameters:
a (array)
n (int)
ارتداد من القاع فلتر ارتداد من القاع مع ملاحظة انه يعمل كتنبيه في القائمة
Bottom bounce filter, note that it works as an alert in the menu
EV/FCFThis script in the 6 version of Pine brings you the most accurate multiple of "fundamental valuation" in my opinion. EV/FCF gives you a real metric of how profitable is the company in this exact moment and also if the company is overvaluated or undervaluated.
Confluence AutoEntry (1m/5m/15m) for Alertatron//@version=5
indicator("Confluence AutoEntry (1m/5m/15m) for Alertatron", overlay=true, max_lines_count=500, max_labels_count=500)
// =========================
// 参数
// =========================
tf1 = input.timeframe("1", "周期-1")
tf2 = input.timeframe("5", "周期-2")
tf3 = input.timeframe("15", "周期-3")
ema1 = input.int(10, "EMA1")
ema2 = input.int(30, "EMA2")
ema3 = input.int(60, "EMA3")
rLen = input.int(14, "RSI 长度")
thr1 = input.int(60, "阈值-周期1 (0~100)", minval=0, maxval=100)
thr2 = input.int(60, "阈值-周期2 (0~100)", minval=0, maxval=100)
thr3 = input.int(60, "阈值-周期3 (0~100)", minval=0, maxval=100)
// 下单资金(USDT)
usdtPerTrade = input.float(500, "每次下单金额(USDT)", step=5)
// 下单类型(市价/限价)
orderType = input.string("market", "下单类型", options= , tooltip="market=市价;limit=限价(使用 entry 作为限价)")
// 两步延续触发
useTwoStep = input.bool(true, "启用两步延续触发", tooltip="收盘仅“武装”,下一根或后续“延续突破”才真正发单;关闭=收盘即发一次信号")
bufferPct = input.float(0.08, "延续触发缓冲(%)", step=0.01, tooltip="突破需要超过武装价的百分比")
armBars = input.int(1, "武装有效bar数", minval=1, tooltip="超时未触发则自动取消武装")
// 可选:在 JSON 中附带 token
attachToken = input.bool(false, "在 JSON 中附带 token 字段")
longToken = input.string("", "多头 token(可留空)")
shortToken = input.string("", "空头 token(可留空)")
// 图形显示
showShapes = input.bool(true, "图表显示三角/武装/触发标记")
showTriggerLabel = input.bool(true, "触发时显示【入场/TP/SL/Qty】标签")
// 「平衡」展示用 TP/SL 百分比(仅用于标签展示,不发到 Alertatron)
tpPct = input.float(2.0, "展示用:TP百分比(%)")
slPct = input.float(1.0, "展示用:SL百分比(%)")
// =========================
// 工具函数
// =========================
f_score(tf) =>
_c = request.security(syminfo.tickerid, tf, close, barmerge.gaps_off, barmerge.lookahead_off)
_e1 = request.security(syminfo.tickerid, tf, ta.ema(close, ema1), barmerge.gaps_off, barmerge.lookahead_off)
_e2 = request.security(syminfo.tickerid, tf, ta.ema(close, ema2), barmerge.gaps_off, barmerge.lookahead_off)
_e3 = request.security(syminfo.tickerid, tf, ta.ema(close, ema3), barmerge.gaps_off, barmerge.lookahead_off)
_r = request.security(syminfo.tickerid, tf, ta.rsi(close, rLen), barmerge.gaps_off, barmerge.lookahead_off)
_m = request.security(syminfo.tickerid, tf, ta.sma(ta.change(close), 5), barmerge.gaps_off, barmerge.lookahead_off)
_ok1 = _c > _e1 ? 1 : 0
_ok2 = _e1 >= _e2 ? 1 : 0
_ok3 = _e2 >= _e3 ? 1 : 0
_ok4 = _r > 50 ? 1 : 0
_ok5 = _m >= 0 ? 1 : 0
(_ok1 + _ok2 + _ok3 + _ok4 + _ok5) / 5.0 * 100.0
// 价格按最小跳动取整
tickRound(x) =>
syminfo.mintick > 0 ? math.round(x / syminfo.mintick) * syminfo.mintick : x
// 数字 -> 价格串
sPrice(x) =>
str.tostring(x, format.mintick)
// 小数点四舍五入(用于数量展示)
roundN(x, n) =>
_f = math.pow(10.0, n)
math.round(x * _f) / _f
sQty(x) =>
str.tostring(roundN(x, 6))
// 去掉交易所前缀和 .P 后缀,得到 BASEQUOTE(如 ETHUSDC)
cleanSymbol() =>
_s = syminfo.ticker
_arr = str.split(_s, ":")
_last = array.get(_arr, array.size(_arr) - 1)
str.replace_all(_last, ".P", "")
// =========================
// 多周期评分 -> 一致方向
// =========================
score1 = f_score(tf1)
score2 = f_score(tf2)
score3 = f_score(tf3)
dir1 = score1 >= thr1 ? 1 : -1
dir2 = score2 >= thr2 ? 1 : -1
dir3 = score3 >= thr3 ? 1 : -1
conf_long = dir1 == 1 and dir2 == 1 and dir3 == 1
conf_short = dir1 == -1 and dir2 == -1 and dir3 == -1
// =========================
// 两步法:收盘“武装” + 下一根/后续“延续触发”
// =========================
var bool armLong = false
var float armLongPx = na
var int armLongUntil = na
var bool armShort = false
var float armShortPx = na
var int armShortUntil = na
if barstate.isconfirmed
if conf_long
armLong := true
armLongPx := close
armLongUntil := bar_index + armBars
if conf_short
armShort := true
armShortPx := close
armShortUntil := bar_index + armBars
longTrigPrice = armLong ? armLongPx * (1 + bufferPct/100.0) : na
shortTrigPrice = armShort ? armShortPx * (1 - bufferPct/100.0) : na
triggerLong = useTwoStep ? (armLong and high >= longTrigPrice) : (barstate.isconfirmed and conf_long)
triggerShort = useTwoStep ? (armShort and low <= shortTrigPrice) : (barstate.isconfirmed and conf_short)
// 触发后立刻卸载武装;超时未触发亦卸载
if triggerLong
armLong := false
if triggerShort
armShort := false
if bar_index > armLongUntil
armLong := false
if bar_index > armShortUntil
armShort := false
// =========================
// 发单用价位(在触发时会被使用)
// =========================
float entryL = tickRound(useTwoStep ? longTrigPrice : close)
float entryS = tickRound(useTwoStep ? shortTrigPrice : close)
float tpL = tickRound(entryL * (1 + tpPct/100.0))
float slL = tickRound(entryL * (1 - slPct/100.0))
float tpS = tickRound(entryS * (1 - tpPct/100.0))
float slS = tickRound(entryS * (1 + slPct/100.0))
// —— 展示标签直接使用上面算好的 entryL/entryS/tpL/slL/tpS/slS
if showTriggerLabel and barstate.isconfirmed
if triggerLong
_txt = "LONG Entry: " + sPrice(entryL) + " TP: " + sPrice(tpL) + " SL: " + sPrice(slL) + " EstQty: " + sQty(usdtPerTrade/entryL)
label.new(bar_index, low, text=_txt, style=label.style_label_up, textcolor=color.white, color=color.new(color.lime, 0))
if triggerShort
_txt = "SHORT Entry: " + sPrice(entryS) + " TP: " + sPrice(tpS) + " SL: " + sPrice(slS) + " EstQty: " + sQty(usdtPerTrade/entryS)
label.new(bar_index, high, text=_txt, style=label.style_label_down, textcolor=color.white, color=color.new(color.red, 0))
// ============ 构造 JSON(按方向用不同 signal 名,所有数值写入) ============
buildMsg(_side, _entry, _tp, _sl) =>
_sig = _side == "buy" ? "open_long" : "open_short"
_token = attachToken ? ',"token":"' + (_side == "buy" ? longToken : shortToken) + '"' : ""
_msg = '{"signal":"' + _sig + '"'
_msg := _msg + ',"side":"' + _side + '"'
_msg := _msg + ',"symbol":"' + cleanSymbol() + '"'
_msg := _msg + ',"order_type":"market"'
_msg := _msg + ',"usdt_per_trade":' + str.tostring(usdtPerTrade)
_msg := _msg + ',"entry":' + sPrice(_entry)
_msg := _msg + ',"tp":' + sPrice(_tp)
_msg := _msg + ',"sl":' + sPrice(_sl)
_msg := _msg + _token + "}"
_msg
msgLong = buildMsg("buy", entryL, tpL, slL)
msgShort = buildMsg("sell", entryS, tpS, slS)
// =========================
// 报警 & 发单(在 TradingView 里选择 Any alert() function call;Webhook 填机器人 URL;Message 留空)
// =========================
alertcondition(triggerLong, title="多仓开仓(…)", message="LONG")
alertcondition(triggerShort, title="空仓开仓(…)", message="SHORT")
if barstate.isconfirmed
if triggerLong
alert(message = msgLong, freq = alert.freq_once_per_bar_close)
if triggerShort
alert(message = msgShort, freq = alert.freq_once_per_bar_close)
// =========================
// 可视化:形态+触发线
// =========================
plotshape(showShapes and conf_long and barstate.isconfirmed, title="收盘-多武装", style=shape.triangleup, color=color.new(color.green, 0), size=size.tiny, text="ARM L", location=location.belowbar)
plotshape(showShapes and conf_short and barstate.isconfirmed, title="收盘-空武装", style=shape.triangledown, color=color.new(color.red, 0), size=size.tiny, text="ARM S", location=location.abovebar)
plotshape(showShapes and triggerLong, title="触发-开多", style=shape.labelup, color=color.new(color.lime, 0), text="▶ LONG", location=location.belowbar, size=size.tiny)
plotshape(showShapes and triggerShort, title="触发-开空", style=shape.labeldown, color=color.new(color.maroon,0), text="▶ SHORT", location=location.abovebar, size=size.tiny)
plot(useTwoStep and armLong ? armLongPx : na, "武装价-L", color=color.new(color.green, 70), style=plot.style_circles, linewidth=1)
plot(useTwoStep and armShort ? armShortPx : na, "武装价-S", color=color.new(color.red, 70), style=plot.style_circles, linewidth=1)
plot(useTwoStep ? longTrigPrice : na, "触发线-L", color=color.new(color.lime, 0), style=plot.style_linebr, linewidth=1)
plot(useTwoStep ? shortTrigPrice : na, "触发线-S", color=color.new(color.maroon, 0), style=plot.style_linebr, linewidth=1)
// =========================
// 可视化:触发时弹出【入场/TP/SL/Qty】标签(仅展示用)
// =========================
if showTriggerLabel and barstate.isconfirmed
if triggerLong
_qtyL = usdtPerTrade > 0 and entryL > 0 ? (usdtPerTrade / entryL) : na
_txtL = "LONG Entry: " + sPrice(entryL) + " TP: " + sPrice(tpL) + " SL: " + sPrice(slL) + " EstQty: " + sQty(_qtyL)
label.new(bar_index, low, text=_txtL, style=label.style_label_up, textcolor=color.white, color=color.new(color.lime, 0))
if triggerShort
_qtyS = usdtPerTrade > 0 and entryS > 0 ? (usdtPerTrade / entryS) : na
_txtS = "SHORT Entry: " + sPrice(entryS) + " TP: " + sPrice(tpS) + " SL: " + sPrice(slS) + " EstQty: " + sQty(_qtyS)
label.new(bar_index, high, text=_txtS, style=label.style_label_down, textcolor=color.white, color=color.new(color.red, 0))
Macros Kill Zones Fusionadas (:20 - :40) / :50 - :10)//@version=6
indicator("Macros Kill Zones Fusionadas (:20 - :40) / :50 - :10)", overlay=true, max_lines_count=500, max_labels_count=500, max_boxes_count=500)
// =======================
// === CONFIGURACIÓN ===
showLines = input.bool(true, "Mostrar líneas verticales")
showShading = input.bool(false, "Sombreado opcional")
shadeColor = input.color(color.new(color.gray, 85), "Color sombreado")
lineColor = color.new(color.gray, 50)
lineWidth = input.int(1, "Grosor líneas", 1, 3)
lookbackBars = input.int(200, "Lookback", 20, 2000)
// Calcular extremos del gráfico
ht = ta.highest(high, lookbackBars)
lt = ta.lowest(low, lookbackBars)
yTop = ht * 1.02
yBot = lt * 0.98
// Hora local en minutos
local_min = hour * 60 + minute
// =======================
// === MACROS ACTIVAS POR DEFECTO ===
m0 = input.bool(false,"12:20am a 12:40am")
m1 = input.bool(false,"1:20am a 1:40am")
m2 = input.bool(true, "2:20am a 2:40am")
m3 = input.bool(true, "3:20am a 3:40am")
m4 = input.bool(true, "4:20am a 4:40am")
m5 = input.bool(false,"5:20am a 5:40am")
m6 = input.bool(false,"6:20am a 6:40am")
m7 = input.bool(true, "7:20am a 7:40am")
m8 = input.bool(true, "8:20am a 8:40am")
m9 = input.bool(true, "9:20am a 9:40am")
m10 = input.bool(true, "10:20am a 10:40am")
m11 = input.bool(false,"11:20am a 11:40am")
m12 = input.bool(false,"12:20pm a 12:40pm")
m13 = input.bool(false,"1:20pm a 1:40pm")
m14 = input.bool(false,"2:20pm a 2:40pm")
m15 = input.bool(false,"3:20pm a 3:40pm")
m16 = input.bool(false,"4:20pm a 4:40pm")
m17 = input.bool(false,"5:20pm a 5:40pm")
m18 = input.bool(false,"6:20pm a 6:40pm")
m19 = input.bool(false,"7:20pm a 7:40pm")
m20 = input.bool(false,"8:20pm a 8:40pm")
m21 = input.bool(false,"9:20pm a 9:40pm")
m22 = input.bool(false,"10:20pm a 10:40pm")
m23 = input.bool(false,"11:20pm a 11:40pm")
// =======================
// === FUNCIÓN DE DIBUJO AJUSTADA ===
f_drawLines(on, startHour) =>
startMin = startHour * 60 + 20
endMin = startHour * 60 + 40
inRange = local_min >= startMin and local_min <= endMin // incluir minuto :40
if on and showLines
if local_min == startMin or local_min == endMin // dibujar línea exacta inicio y fin
line.new(bar_index, yTop, bar_index, yBot, xloc=xloc.bar_index, color=lineColor, width=lineWidth)
inRange
// =======================
// === CHEQUEO DE MACROS ACTIVAS ===
in_any_macro = f_drawLines(m0,0) or f_drawLines(m1,1) or f_drawLines(m2,2) or f_drawLines(m3,3) or
f_drawLines(m4,4) or f_drawLines(m5,5) or f_drawLines(m6,6) or f_drawLines(m7,7) or
f_drawLines(m8,8) or f_drawLines(m9,9) or f_drawLines(m10,10) or f_drawLines(m11,11) or
f_drawLines(m12,12) or f_drawLines(m13,13) or f_drawLines(m14,14) or f_drawLines(m15,15) or
f_drawLines(m16,16) or f_drawLines(m17,17) or f_drawLines(m18,18) or f_drawLines(m19,19) or
f_drawLines(m20,20) or f_drawLines(m21,21) or f_drawLines(m22,22) or f_drawLines(m23,23)
// =======================
// === SOMBREADO OPCIONAL ===
bgcolor(showShading and in_any_macro ? shadeColor : na)
// =======================
// === INDICADOR 2: Macro :50 - :10 ===
// =======================
//#region
var line EXT = array.new_line()
var label LBL = array.new_label()
oneDayMS = 86400000
oneBarMS = time_close - time
noColor = color.new(#ffffff, 100)
// Ajuste de línea sobre vela
one = ta.highest(timeframe.in_seconds("15") / timeframe.in_seconds(timeframe.period)) + syminfo.mintick * 10
y_btm_Line1 = one
y_top_Line1 = one + syminfo.mintick * 5
//#region
_macroC = input.color(color.new(color.gray, 60), title="Macro Color", inline='main')
_mode = input.string("On Chart", title="", inline='main', options= )
_showL = input.bool(true, title="Macro Label?", inline='sh')
_mTxt = input.bool(true, title="Show Time?", inline='sh')
_extt = input.bool(false, title="Macro Projections?", inline='sh')
_bgm = input.color(color.new(#4caf50, 70), title="Macro Color", inline='bc')
//#endregion
//#region
time_isMacro(int H_start, int M_start, int H_end, int M_end) =>
h = hour(time, "America/New_York")
m = minute(time, "America/New_York")
h == H_start ? (H_start != H_end ? m >= M_start : m >= M_start and m < M_end) : (h > H_start ? (h == H_end ? m < M_end : h < H_end) : false)
_controlMacroLine(line _lines, label _lbl, bool _time) =>
if _time
_lbl.last().set_x(math.round(math.avg(_lines.get(_lines.size() - 2).get_x1(), time)))
if high > _lines.last().get_y2() - syminfo.mintick * 10
_lines.get(_lines.size() - 2).set_y2(high + (syminfo.mintick * 10))
_lines.last().set_y1(high + (syminfo.mintick * 10))
_lines.last().set_y2(high + (syminfo.mintick * 10))
LBL.last().set_y(high + (syminfo.mintick * 10))
if na(_lines.last().get_x2()) or _lines.last().get_x2() == time
_lines.last().set_x2(time + oneBarMS)
method memoryCleanLine(line A) =>
if A.size() > 300
for i = 0 to 3
A.shift().delete()
method memoryCleanLabel(label A) =>
if A.size() > 100
A.shift().delete()
macroOC(line LINES, bool _time, string _kzTime, bool _friday) =>
dly = _friday ? oneDayMS * 3 : oneDayMS
_txt = _mTxt ? _kzTime : ""
if not _time and _time
_vline1 = line.new(time, y_btm_Line1, time, y_top_Line1, xloc=xloc.bar_time, color=_macroC, width=1)
LINES.push(_vline1)
_hline = line.new(time, y_top_Line1, time + oneBarMS, y_top_Line1, xloc=xloc.bar_time, color=_macroC, width=1)
LINES.push(_hline)
if _extt
EXT.push(line.new(time, high, time, _vline1.get_y2(), xloc=xloc.bar_time, color=_macroC, style=line.style_dotted))
if _mode == "On Chart"
LBL.push(label.new(time,
LINES.get(LINES.size() - 2).get_y2(),
_showL ? _txt : "",
xloc=xloc.bar_time,
style=label.style_label_down,
color=noColor,
textcolor=_macroC,
size=size.small))
if _time and not _time and LINES.size() > 0
_vline2 = line.new(time, y_btm_Line1, time, y_top_Line1, xloc=xloc.bar_time, color=_macroC, width=1)
LBL.last().set_x(math.round(math.avg(LINES.get(LINES.size() - 2).get_x1(), time)))
if y_top_Line1 > LINES.get(LINES.size() - 2).get_y2()
LINES.get(LINES.size() - 2).set_y2(y_top_Line1)
LINES.last().set_y1(y_top_Line1)
LINES.last().set_y2(y_top_Line1)
LBL.last().set_y(y_top_Line1)
else if y_top_Line1 < LINES.get(LINES.size() - 2).get_y2()
_vline2.set_y2(LINES.get(LINES.size() - 2).get_y2())
if _extt
EXT.push(line.new(time, high, time, _vline2.get_y2(), xloc=xloc.bar_time, color=_macroC, style=line.style_dotted))
LINES.push(_vline2)
if LINES.size() > 0 and LBL.size() > 0
_controlMacroLine(LINES, LBL, _time)
//#endregion
//#region
// Declaración de los 24 intervalos cronológicos
var line _LINES1 = array.new_line()
var line _LINES2 = array.new_line()
var line _LINES3 = array.new_line()
var line _LINES4 = array.new_line()
var line _LINES5 = array.new_line()
var line _LINES6 = array.new_line()
var line _LINES7 = array.new_line()
var line _LINES8 = array.new_line()
var line _LINES9 = array.new_line()
var line _LINES10 = array.new_line()
var line _LINES11 = array.new_line()
var line _LINES12 = array.new_line()
var line _LINES13 = array.new_line()
var line _LINES14 = array.new_line()
var line _LINES15 = array.new_line()
var line _LINES16 = array.new_line()
var line _LINES17 = array.new_line()
var line _LINES18 = array.new_line()
var line _LINES19 = array.new_line()
var line _LINES20 = array.new_line()
var line _LINES21 = array.new_line()
var line _LINES22 = array.new_line()
var line _LINES23 = array.new_line()
var line _LINES24 = array.new_line()
// Inputs de activación
show1 = input.bool(false, title="00:50 - 01:10")
show2 = input.bool(false, title="01:50 - 02:10")
show3 = input.bool(true, title="02:50 - 03:10")
show4 = input.bool(true, title="03:50 - 04:10")
show5 = input.bool(false, title="04:50 - 05:10")
show6 = input.bool(false, title="05:50 - 06:10")
show7 = input.bool(false, title="06:50 - 07:10")
show8 = input.bool(true, title="07:50 - 08:10")
show9 = input.bool(true, title="08:50 - 09:10")
show10 = input.bool(true, title="09:50 - 10:10")
show11 = input.bool(false, title="10:50 - 11:10")
show12 = input.bool(false, title="11:50 - 12:10")
show13 = input.bool(false, title="12:50 - 13:10")
show14 = input.bool(false, title="13:50 - 14:10")
show15 = input.bool(false, title="14:50 - 15:10")
show16 = input.bool(false, title="15:50 - 16:10")
show17 = input.bool(false, title="16:50 - 17:10")
show18 = input.bool(false, title="17:50 - 18:10")
show19 = input.bool(false, title="18:50 - 19:10")
show20 = input.bool(false, title="19:50 - 20:10")
show21 = input.bool(false, title="20:50 - 21:10")
show22 = input.bool(false, title="21:50 - 22:10")
show23 = input.bool(false, title="22:50 - 23:10")
show24 = input.bool(false, title="23:50 - 00:10")
// Tiempos
time1 = time_isMacro(0,50,1,10)
time2 = time_isMacro(1,50,2,10)
time3 = time_isMacro(2,50,3,10)
time4 = time_isMacro(3,50,4,10)
time5 = time_isMacro(4,50,5,10)
time6 = time_isMacro(5,50,6,10)
time7 = time_isMacro(6,50,7,10)
time8 = time_isMacro(7,50,8,10)
time9 = time_isMacro(8,50,9,10)
time10 = time_isMacro(9,50,10,10)
time11 = time_isMacro(10,50,11,10)
time12 = time_isMacro(11,50,12,10)
time13 = time_isMacro(12,50,13,10)
time14 = time_isMacro(13,50,14,10)
time15 = time_isMacro(14,50,15,10)
time16 = time_isMacro(15,50,16,10)
time17 = time_isMacro(16,50,17,10)
time18 = time_isMacro(17,50,18,10)
time19 = time_isMacro(18,50,19,10)
time20 = time_isMacro(19,50,20,10)
time21 = time_isMacro(20,50,21,10)
time22 = time_isMacro(21,50,22,10)
time23 = time_isMacro(22,50,23,10)
time24 = time_isMacro(23,50,0,10)
//#region
plotMacro(_show, _LINES, _time, _lbl) =>
if _show
macroOC(_LINES, _time, _lbl, dayofweek(time) == dayofweek.friday and syminfo.type != 'crypto')
plotMacro(show1, _LINES1, time1, "00:50 - 01:10")
plotMacro(show2, _LINES2, time2, "01:50 - 02:10")
plotMacro(show3, _LINES3, time3, "02:50 - 03:10")
plotMacro(show4, _LINES4, time4, "03:50 - 04:10")
plotMacro(show5, _LINES5, time5, "04:50 - 05:10")
plotMacro(show6, _LINES6, time6, "05:50 - 06:10")
plotMacro(show7, _LINES7, time7, "06:50 - 07:10")
plotMacro(show8, _LINES8, time8, "07:50 - 08:10")
plotMacro(show9, _LINES9, time9, "08:50 - 09:10")
plotMacro(show10, _LINES10, time10, "09:50 - 10:10")
plotMacro(show11, _LINES11, time11, "10:50 - 11:10")
plotMacro(show12, _LINES12, time12, "11:50 - 12:10")
plotMacro(show13, _LINES13, time13, "12:50 - 13:10")
plotMacro(show14, _LINES14, time14, "13:50 - 14:10")
plotMacro(show15, _LINES15, time15, "14:50 - 15:10")
plotMacro(show16, _LINES16, time16, "15:50 - 16:10")
plotMacro(show17, _LINES17, time17, "16:50 - 17:10")
plotMacro(show18, _LINES18, time18, "17:50 - 18:10")
plotMacro(show19, _LINES19, time19, "18:50 - 19:10")
plotMacro(show20, _LINES20, time20, "19:50 - 20:10")
plotMacro(show21, _LINES21, time21, "20:50 - 21:10")
plotMacro(show22, _LINES22, time22, "21:50 - 22:10")
plotMacro(show23, _LINES23, time23, "22:50 - 23:10")
plotMacro(show24, _LINES24, time24, "23:50 - 00:10")
//#endregion
//#region
_LINES1.memoryCleanLine()
_LINES2.memoryCleanLine()
_LINES3.memoryCleanLine()
_LINES4.memoryCleanLine()
_LINES5.memoryCleanLine()
_LINES6.memoryCleanLine()
_LINES7.memoryCleanLine()
_LINES8.memoryCleanLine()
_LINES9.memoryCleanLine()
_LINES10.memoryCleanLine()
_LINES11.memoryCleanLine()
_LINES12.memoryCleanLine()
_LINES13.memoryCleanLine()
_LINES14.memoryCleanLine()
_LINES15.memoryCleanLine()
_LINES16.memoryCleanLine()
_LINES17.memoryCleanLine()
_LINES18.memoryCleanLine()
_LINES19.memoryCleanLine()
_LINES20.memoryCleanLine()
_LINES21.memoryCleanLine()
_LINES22.memoryCleanLine()
_LINES23.memoryCleanLine()
_LINES24.memoryCleanLine()
EXT.memoryCleanLine()
LBL.memoryCleanLabel()
//#endregion
ATRThis script displays the Average True Range (ATR) value and the ATR as a percentage of the current closing price directly on the main chart as a clean table, with no lines or plots. It allows users to easily monitor both absolute volatility and its relative magnitude, making comparisons across different assets intuitive. The display position is customizable, offering flexibility for personal chart layouts. Ideal for traders seeking quick volatility insights, risk management guidance, or portfolio-wide comparisons.
Quantum Portfolio vs NASDAQ (Base: May 2, 2021)This custom Pine Script indicator tracks and compares the cumulative performance of a multi-asset “Quantum Portfolio” against the NASDAQ 100 benchmark, rebased to a common starting point on May 2, 2021.
Both series are normalized to a base value of 100 on that date, allowing direct visual comparison of percentage growth or decline over time.
Thematic Portfolio: Quantum Computing & Core TechThis indicator tracks the aggregated performance of a curated thematic portfolio representing the Quantum Computing & Core Technology sector.
It combines leading equities and ETFs with predefined weights to reflect a diversified exposure across quantum hardware, AI infrastructure, and semiconductor backbones.
Composition:
Stocks: Rigetti (RGTI), IonQ (IONQ), D-Wave (QBTS), Palantir (PLTR), Intel (INTC), Arqit (ARQQ)
ETFs: BUG, QTUM, SOXX, IHAK
Methodology:
Each component’s normalized performance is weighted according to its strategic importance within the theme (R&D intensity, infrastructure leverage, and hardware dependence). The indicator dynamically aggregates the weighted series to visualize the cumulative return of the quantum computing ecosystem versus traditional benchmarks.
Intended use:
Compare thematic returns vs. S&P 500 or NASDAQ
Identify macro inflection points in the quantum tech narrative
Backtest thematic exposure strategies or structure twin-win / delta-one certificates
Note: This script is for analytical and educational purposes only and does not constitute financial advice.
Simple Moving AveragesIn Pine Script v6, the standard method for plotting indicators is still the plot function, and it should be recognized. However, if you are getting an "Undeclared identifier 'plot'" error, double-check these points:
Make sure your script is still using indicator() (not study()) at the top.
The script must not use indentation or syntax errors that break context.
Confirm Pine Script version is set correctly with //@version=6.
Here is a fully corrected Pine Script v6 template for your moving averages scenario using
Flux AI PullBack System (Hybrid Pro)Flux AI PullBack System (Hybrid Pro)
//Session-Aware | Adaptive Confluence | Grace Confirm Logic//
Overview:
The Flux AI PullBack System (Hybrid Pro v5) is an adaptive, session-aware pullback indicator designed to identify high-probability continuation setups within trending markets. It automatically adjusts between “Classic” and “Enhanced” logic modes based on volatility, volume, and ATR slope, allowing it to perform seamlessly across different market sessions (Asian, London, and New York).
Core Features:
Hybrid Auto Mode — Dynamically switches between Classic (fast-moving) and Enhanced (strict) modes.
Session-Aware Context — Optimized for intraday trading in ES, NQ, and SPY.
Grace Confirmation Logic — Validates pullbacks with a follow-through condition to reduce noise.
Adaptive EMA Zone (38/62) — Highlights pullback areas with dynamic aqua fill and transparency linked to trend strength.
Noise Suppression Filter — Prevents false pullbacks during EMA crossovers or unstable transitions.
Weighted Confluence Model — Combines trend, ATR, volume, and swing structure for confirmation strength.
Pine v6 Compliant Alerts — Constant-string safe, ready for webhooks and automation.
Visual Elements:
Aqua EMA Zone: Displays the “breathing” pullback band (tightens during volatility spikes).
PB↑ / PB↓ Markers: Confirmed pullbacks with subtle transparency and fixed label size.
Bar Highlights: Yellow for pullbacks; ice-blue for confirmed continuation.
Use Cases
Perfect for:
Intraday trend traders
0DTE SPX / ES scalpers
Futures traders (NQ, MNQ, MES)
Algorithmic strategy builders using webhooks
Recommended Timeframes:
1–15 minute charts (scalping / intraday)
Higher timeframes for swing confirmations.
Attribution:
This open-source script was inspired by Chris Moody’s “CM Slingshot System” and JustUncleL’s Pullback Tools, but it was built from scratch using AI-assisted code refinement (ChatGPT).
All logic and enhancements are original, not derived from proprietary software.
License: MIT (Open Source)
© 2025 Ken Anderson — You may modify, use, or redistribute with credit.
Keywords:
Pullback, Reversal, AI Trading, EMA Zone, Session Aware, Futures Trading, SPX, ES, NQ, ATR Filter, Volume Confirmation, Flux System, Pine Script v6, Non-Repainting, Adaptive Trading Indicator.
FVG_Liquidity_SignalFVGs: classic 3-bar gaps (bullish when low > high , bearish when high < low ). Zones are drawn and auto-pruned.
Liquidity sweep: price takes out the last swing low/high (pivot) and then reclaims it on the close.
Signals:
BUY when we get a bull sweep and the bar taps a recent bull FVG and closes back above its upper edge.
SELL is the mirror image.
SL/TP guides: SL at swept swing; TP = RR × risk (visual only).
FVG Donchian Channel strategy30min FVG + Donchian Channel strategy
buy sell by 30min fvg
and stoploss , take profit by Donchian Channel
Run the strategy on the 1min timeframe!
Mercury Retrograde — Daily boxes & bottom % (stable v6)水星逆行のアノマリー検証。対象は日経225の過去5年の値動き。水星逆行開始時の終値と水星逆行終了時の終値を比較。上昇率・下落率に応じて色分け。
Verification of Mercury Retrograde Anomalies. Subject: Nikkei 225 price movements over the past five years. Comparing closing prices at the start and end of Mercury retrograde periods. Color-coded based on percentage increase/decrease.






















