WHAlertCommandLibrary "WHAlertCommand"
f_WH_Risk(risk_Type_)
Parameters:
risk_Type_ (string)
f_WH_Open_Position(uuid_, enable_Buy_, enable_Sell, enable_All_Group_Members_, enable_Close_Opposite_Side_, enable_Risk_, risk_Type_, signal_Type_Buy_Or_Sell)
Parameters:
uuid_ (string)
enable_Buy_ (bool)
enable_Sell (bool)
enable_All_Group_Members_ (bool)
enable_Close_Opposite_Side_ (bool)
enable_Risk_ (bool)
risk_Type_ (string)
signal_Type_Buy_Or_Sell (string)
f_WH_TP(uuid_, position_Size_Percent_, side_)
Parameters:
uuid_ (string)
position_Size_Percent_ (float)
side_ (string)
f_WH_MARKET_CLOSE(uuid_, side_)
Parameters:
uuid_ (string)
side_ (string)
חפש סקריפטים עבור "alert"
FinandyHookLibLibrary "FinandyHookLib"
TODO: add library description here
createOrderJson(model, hook_secret, options)
Parameters:
model (orderModel type from Hamster-Coder/OrderLib/7)
hook_secret (string)
options (textFormatOptions)
textFormatOptions
Fields:
price_format (series__string)
percent_format (series__string)
SAT_BACKTEST @description TODO: Regroupement of useful functionsLibrary "SAT_BACKTEST"
ex_timezone(tz)
switch case return exact @timezone for timezone input
Parameters:
tz (simple string)
Returns: syminfo.timezone or tz
if_in_date_range(usefromDate, fromDate, usetoDate, toDate, src_timezone, dst_timezone)
if_in_date_range : check if @time_close is range
Parameters:
usefromDate (simple bool)
fromDate (simple int)
usetoDate (simple bool)
toDate (simple int)
src_timezone (simple string)
dst_timezone (simple string)
Returns: true if @time_close is range
if_in_session(useSessionStart, sessionStartHour, sessionStartMinute, useSessionEnd, sessionEndHour, sessionEndMinute, useSessionDay, mon, tue, wed, thu, fri, sat, sun, src_timezone, dst_timezone)
if_in_session : check if @time_close is range
Parameters:
useSessionStart (simple bool)
sessionStartHour (simple int)
sessionStartMinute (simple int)
useSessionEnd (simple bool)
sessionEndHour (simple int)
sessionEndMinute (simple int)
useSessionDay (simple bool)
mon (simple bool)
tue (simple bool)
wed (simple bool)
thu (simple bool)
fri (simple bool)
sat (simple bool)
sun (simple bool)
src_timezone (simple string)
dst_timezone (simple string)
Returns: true if @time_close is range
jsonLibrary "json"
JSON Easy Object Create/stringiffy
Functions to add/write JSON
new (name , kind) -> object
set (_item , _obj , _key ) -> key index for parent object's array
add (_obj , _key , _item ) -> key index for parent object's array
write (object , kind ) -> stringified object // (enter kind to cut off key )
============================================
obj
obj Object storage container/item
Fields:
key : (string ) item name
kind : (string ) item's type(for writing)
item : (string ) item (converted to string)
keys : (string ) keys of all sub-items and objects
items : (obj ) nested obj off individual subitems (for later...)
============================================
new(_name, _kind)
create multitype object
Parameters:
_name : (string) Name off object
_kind : (string) Preset Type (_OBJECT if a container item)
Returns: object container/item 2-in-1
============================================
add(_item, _obj, _key)
Set item to object obj item (same as set, prep for future Pine methods)
Parameters:
_item : ( int / float / bool / string )
_obj : (obj multi-type-item object)
_key : ( string )
set(_item, _obj, _key)
Set item to object obj item (same as add, prep for future Pine methods)
Parameters:
_item : ( int / float / bool / string )
_obj : (obj multi-type-item object)
_key : ( string )
addstore(_parent, _child)
Add a object as a subobject to storage (Future upgrade to write/edit)
Parameters:
_parent : to insert obj into
_child : to be inserted
setstore(_child, _parent)
Add a object as a subobject to storage (Future upgrade to write/edit)
Parameters:
_child : to be inserted
_parent : to insert obj into
add(_parent, _child)
Add a object as a string rendered item
Parameters:
_parent : to insert obj into
_child : to be inserted
set(_child, _parent)
Add a object as a string rendered item
Parameters:
_child : to be inserted
_parent : to insert obj into
============================================
write(_object, _key, _itemname)
Write object to string Object
Parameters:
_object : (obj)
_key : (array<(string/int)> )/(string)
_itemname : (string)
Returns: stringified flattened object.
clean_output(_str)
Clean JSON final output
Parameters:
_str : string json item
Returns: cleaned string
libcompressLibrary "libcompress"
numbers compressor for large output data compression
compress_fp24()
converts float to base64 (4 chars) | 24 bits: 1 sign + 5 exponent + 18 mantissa
Returns: 4-character base64_1/5/18 representation of x
compress_ufp18()
converts unsigned float to base64 (3 chars) | 18 bits: 5 exponent + 13 mantissa
Returns: 3-character base64_0/5/13 representation of x
compress_int()
converts int to base64
PineHelperLibrary "PineHelper"
This library provides various functions to reduce your time.
recent_opentrade_entry_bar_index()
get a recent opentrade entry bar_index
Returns: (int) bar_index
recent_closedtrade_entry_bar_index()
get a recent closedtrade entry bar_index
Returns: (int) bar_index
recent_closedtrade_exit_bar_index()
get a recent closedtrade exit bar_index
Returns: (int) bar_index
all_opnetrades_roi()
get all aopentrades roi
Returns: (float) roi
bars_since_recent_opentrade_entry()
get bars since recent opentrade entry
Returns: (int) number of bars
bars_since_recent_closedtrade_entry()
get bars since recent closedtrade entry
Returns: (int) number of bars
bars_since_recent_closedtrade_exit()
get bars since recent closedtrade exit
Returns: (int) number of bars
recent_opentrade_entry_id()
get recent opentrade entry ID
Returns: (string) entry ID
recent_closedtrade_entry_id()
get recent closedtrade entry ID
Returns: (string) entry ID
recent_closedtrade_exit_id()
get recent closedtrade exit ID
Returns: (string) exit ID
recent_opentrade_entry_price()
get recent opentrade entry price
Returns: (float) price
recent_closedtrade_entry_price()
get recent closedtrade entry price
Returns: (float) price
recent_closedtrade_exit_price()
get recent closedtrade exit price
Returns: (float) price
recent_opentrade_entry_time()
get recent opentrade entry time
Returns: (int) time
recent_closedtrade_entry_time()
get recent closedtrade entry time
Returns: (int) time
recent_closedtrade_exit_time()
get recent closedtrade exit time
Returns: (int) time
time_since_recent_opentrade_entry()
get time since recent opentrade entry
Returns: (int) time
time_since_recent_closedtrade_entry()
get time since recent closedtrade entry
Returns: (int) time
time_since_recent_closedtrade_exit()
get time since recent closedtrade exit
Returns: (int) time
recent_opentrade_size()
get recent opentrade size
Returns: (float) size
recent_closedtrade_size()
get recent closedtrade size
Returns: (float) size
all_opentrades_size()
get all opentrades size
Returns: (float) size
recent_opentrade_profit()
get recent opentrade profit
Returns: (float) profit
all_opentrades_profit()
get all opentrades profit
Returns: (float) profit
recent_closedtrade_profit()
get recent closedtrade profit
Returns: (float) profit
recent_opentrade_max_runup()
get recent opentrade max runup
Returns: (float) runup
recent_closedtrade_max_runup()
get recent closedtrade max runup
Returns: (float) runup
recent_opentrade_max_drawdown()
get recent opentrade maxdrawdown
Returns: (float) mdd
recent_closedtrade_max_drawdown()
get recent closedtrade maxdrawdown
Returns: (float) mdd
max_open_trades_drawdown()
get max open trades drawdown
Returns: (float) mdd
recent_opentrade_commission()
get recent opentrade commission
Returns: (float) commission
recent_closedtrade_commission()
get recent closedtrade commission
Returns: (float) commission
qty_by_percent_of_equity(percent)
get qty by percent of equtiy
Parameters:
percent : (series float) percent that you want to set
Returns: (float) quantity
qty_by_percent_of_position_size(percent)
get size by percent of position size
Parameters:
percent : (series float) percent that you want to set
Returns: (float) size
is_day_change()
get bool change of day
Returns: (bool) day is change or not
is_in_trade()
get bool using number of bars
Returns: (bool) allowedToTrade
discord_message(name, message)
get json format discord message
Parameters:
name : (string) name of bot
message : (string) message that you want to send
Returns: (string) json format string
telegram_message(chat_id, message)
get json format telegram message
Parameters:
chat_id : (string) chatId of bot
message : (string) message that you want to send
Returns: (string) json format string
Binance_Min_Limit_Order_amount_libraryLibrary "Binance_Min_Limit_Order_amount_library"
TODO: This library give us the minimum Limit Order amount for the contract in Binance.
m_qty(n_v, m_fee, t_fee, cost, m_t)
TODO: it give us the Minimum Qty for the trading in Binance
Parameters:
n_v : TODO: min_notional_value. 5 dollar is the minimum notional amount in Binance at the moment.
m_fee : TODO: maker_fee %
t_fee : TODO: taker_fee %
cost : TODO: your investing money
m_t : TODO: if you want Limit_Order, put the "T", if you want Market_Order, put the "M" defval="M"
Returns: TODO: for the coin of binance on your chart,
Reference: www.binance.com
LevelsManagerLibrary "LevelsManager"
TODO: Track up to 6 TakeProfits and 1 StopLoss achievement for one or many of your buy/sell conditions.
manageTrade(bool, bool, bool, string, string, float, float, bool, bool, bool, bool, bool, bool, float, float, float, float, float, float, float)
Track TakeProfits and StopLoss achievement for one or many of your buy/sell conditions. CHECK the commented section: "Function @manageTrade" for Description
Parameters:
bool : useSignal.
bool : b_gameOVer.
bool : b_gameOVer.
string : bName.
string : sName.
float : buyEntrySource.
float : sellEntrySource.
bool : useTp1.
bool : useTp2.
bool : useTp3.
bool : useTp4.
bool : useTp5.
bool : useTp6.
float : tp1x.
float : tp2x.
float : tp3x.
float : tp4x.
float : tp5x.
float : tp6x.
float : slx.
Returns: check commented section: "Function @manageTrade".
showOnlyFirstOccurence(booleanInput)
Single out the occurence of a bool series between to 2 bool series.
Parameters:
booleanInput : to activate or deactivate occurences filtering.
Returns: filterred or not bool series.
RouterOrdersIronLibrary "RouterOrdersIron"
Library for routing orders to the Binance exchange.
MsgDoLongMKT(id, symbol, balance)
Returns json for Iron to buy a symbol for the amount of the balance with market order.
Parameters:
id : ID of your Iron router.
symbol : Symbol for a trade, BTC example
balance : The amount for which to carry out the transaction.
Returns: true
MsgDoShortMKT(id, symbol, balance)
Returns json for Iron to sell a symbol for the amount of the balance with market order.
Parameters:
id : ID of your Iron router.
symbol : Symbol for a trade, BTC example
balance : The amount for which to carry out the transaction.
Returns: true
MsgDoLongLR(id, symbol, balance)
Returns json for Iron to buy a symbol for the amount of the balance. It is set at the best price and is re-set each time if a new price has risen before the application.
Parameters:
id : ID of your Iron router.
symbol : Symbol for a trade, BTC example
balance : The amount for which to carry out the transaction.
Returns: true
MsgDoShortLR(id, symbol, balance)
Returns json for Iron to sell a symbol for the amount of the balance. It is set at the best price and is re-set each time if a new price has risen before the application.
Parameters:
id : ID of your Iron router.
symbol : Symbol for a trade, BTC example
balance : The amount for which to carry out the transaction.
Returns: true
DoLongMKT(id, symbol, balance)
Buy a symbol for the amount of the balance. It is send market order to Iron.
Parameters:
id : ID of your Iron router.
symbol : Symbol for a trade, BTC example
balance : The amount for which to carry out the transaction.
Returns: true
DoShortMKT(id, symbol, balance)
Sell a symbol for the amount of the balance. It is send market order to Iron.
Parameters:
id : ID of your Iron router.
symbol : Symbol for a trade, BTC example
balance : The amount for which to carry out the transaction.
Returns: true
DoLongLR(id, symbol, balance)
Buy a symbol for the amount of the balance. It is set at the best price and is re-set each time if a new price has risen before the application.
Parameters:
id : ID of your Iron router.
symbol : Symbol for a trade, BTC example
balance : The amount for which to carry out the transaction.
Returns: true
DoShortLR(id, symbol, balance)
Sell a symbol for the amount of the balance. It is set at the best price and is re-set each time if a new price has risen before the application.
Parameters:
id : ID of your Iron router.
symbol : Symbol for a trade, BTC example
balance : The amount for which to carry out the transaction.
Returns: true
GetQty(price, balance)
Get Qty for strategy on balance
Parameters:
price : Order price
balance : The amount for which to carry out the transaction.
Returns: Qty for strategy order TV
TradingHookLibrary "TradingHook"
This library is a client script for making a webhook signal formatted string to TradingHook webhook server.
buy_message(password, amount, order_name) Make a buy Message for TradingHook.
Parameters:
password : (string) password that you set in .env file.
amount : (float) amount. If not set, your strategy qty will be sent.
order_name : (string) order_name. The default name is "Order".
Returns: (string) A string containing the formatted webhook message.
sell_message(password, percent, order_name) Make a sell message for TradingHook.
Parameters:
password : (string) password that you set in .env file.
percent : (string) what percentage of your quantity you want to sell.
order_name : (string) order_name. The default name is "Order".
Returns: (string) A string containing the formatted webhook message.
You can use TradingHook WebServer open source code in github(github.com)
Timed_exit_alert_for_webhookLibrary "Timed_exit_alert_for_webhook"
TODO: add library description here
fun(x) TODO: add function description here
Parameters:
x : TODO: add parameter x description here
Returns: TODO: add what function returns
for exiting FCM like Tradovate and AMP using API and python MT5 and Webhooks
the writer take no responsibility for trades made using this script its written for informational purposes only
MakeLoveNotWarLibrary "MakeLoveNotWar"
Make Love Not War, place a flag of support on your chart!
flag(pos, text_size) Make Love Not War function.
Parameters:
pos : string, position.
text_size : string, text size.
Returns: table.
The Divergent LibraryLibrary "TheDivergentLibrary"
The Divergent Library is only useful when combined with the Pro version of The Divergent - Advanced divergence indicator . This is because the Basic (free) version of The Divergent does not expose the "Divergence Signal" value.
Usage instructions:
1. Create a new chart
2. Add The Divergent (Pro) indicator to your chart
3. Create a new strategy, import this library, add a "source" input, link it to "The Divergent: Divergence Signal", and use the library to decode the divergence signals from The Divergent (You can find example strategy code published in our profile)
4. Act on the divergences signalled by The Divergent
---
isRegularBullishEnabled(context) Returns a boolean value indicating whether Regular Bullish divergence detection is enabled in The Divergent.
Parameters:
context : The context of The Divergent Library.
Returns: A boolean value indicating whether Regular Bullish divergence detection is enabled in The Divergent.
isHiddenBullishEnabled(context) Returns a boolean value indicating whether Hidden Bullish divergence detection is enabled in The Divergent.
Parameters:
context : The context of The Divergent Library.
Returns: A boolean value indicating whether Hidden Bullish divergence detection is enabled in The Divergent.
isRegularBearishEnabled(context) Returns a boolean value indicating whether Regular Bearish divergence detection is enabled in The Divergent.
Parameters:
context : The context of The Divergent Library.
Returns: A boolean value indicating whether Regular Bearish divergence detection is enabled in The Divergent.
isHiddenBearishEnabled(context) Returns a boolean value indicating whether Hidden Bearish divergence detection is enabled in The Divergent.
Parameters:
context : The context of The Divergent Library.
Returns: A boolean value indicating whether Hidden Bearish divergence detection is enabled in The Divergent.
getPivotDetectionSource(context) Returns the 'Pivot Detection Source' setting of The Divergent. The returned value can be either "Oscillator" or "Price".
Parameters:
context : The context of The Divergent Library.
Returns: One of the following string values: "Oscillator" or "Price".
getPivotDetectionMode(context) Returns the 'Pivot Detection Mode' setting of The Divergent. The returned value can be either "Bodies" or "Wicks".
Parameters:
context : The context of The Divergent Library.
Returns: One of the following string values: "Bodies" or "Wicks".
isLinked(context) Returns a boolean value indicating the link status to The Divergent indicator.
Parameters:
context : The context of The Divergent Library.
Returns: A boolean value indicating the link status to The Divergent indicator.
init(firstBarSignal, displayLinkStatus, debug) Initialises The Divergent Library's context with the signal produced by The Divergent on the first bar. The value returned from this function is called the "context of The Divergent Library". Some of the other functions of this library requires you to pass in this context.
Parameters:
firstBarSignal : The signal from The Divergent indicator on the first bar.
displayLinkStatus : A boolean value indicating whether the Link Status window should be displayed in the bottom left corner of the chart. Defaults to true.
debug : A boolean value indicating whether the Link Status window should display debug information. Defaults to false.
Returns: A bool array containing the context of The Divergent Library.
processSignal(signal) Processes a signal from The Divergent and returns a 5-tuple with the decoded signal: [ int divergenceType, int priceBarIndexStart, int priceBarIndexEnd, int oscillatorBarIndexStart, int oscillatorBarIndexEnd]. `divergenceType` can be one of the following values: na → No divergence was detected, 1 → Regular Bullish, 2 → Regular Bullish early, 3 → Hidden Bullish, 4 → Hidden Bullish early, 5 → Regular Bearish, 6 → Regular Bearish early, 7 → Hidden Bearish, 8 → Hidden Bearish early.
Parameters:
signal : The signal from The Divergent indicator.
Returns: A 5-tuple with the following values: [ int divergenceType, int priceBarIndexStart, int priceBarIndexEnd, int oscillatorBarIndexStart, int oscillatorBarIndexEnd].
DiscordWebhookFunctionLibrary "DiscordWebhookFunction"
discordMarkdown(_str, _italic, _bold, _code, _strike, _under) Convert string to markdown formatting User can combine any function at the same time.
Parameters:
_str : String input
_italic : Italic
_bold : Bold
_code : Code markdown
_strike : Strikethrough
_under : Underline
Returns: string Markdown formatted string.
discordWebhookJSON(_username, _avatarImgUrl, _contentText, _bodyTitle, _descText, _bodyUrl, _embedCol, _timestamp, _authorName, _authorUrl, _authorIconUrl, _footerText, _footerIconUrl, _thumbImgUrl, _imageUrl) Convert data to JSON format for Discord Webhook Integration.
Parameters:
_username : Override bot (webhook) username string / name,
_avatarImgUrl : Override bot (webhook) avatar by image URL,
_contentText : Main content page message,
_bodyTitle : Custom Webhook's embed message body title,
_descText : Webhook's embed message body description,
_bodyUrl : Webhook's embed body direct link URL,
_embedCol : Webhook's embed color,
_timestamp : Timestamp,
_authorName : Webhook's embed author name / title,
_authorUrl : Webhook's embed author direct link URL,
_authorIconUrl : Webhook's embed author icon by image URL,
_footerText : Webhook's embed footer text / title,
_footerIconUrl : Webhook's embed footer icon by image URL,
_thumbImgUrl : Webhook's embed thumbnail image URL,
_imageUrl : Webhook's embed body image URL.
Returns: string Single-line JSON format
[ALERTS] MA Cross HildiIch habe nur einige Modifikationen vorgenommen, so dass es meinen Bedürfnissen gerecht wird. Das Skript dient lediglich dazu die gleiche Einstellungen auf mehreren Konten nutzen zu können. Allein die Farbe und die Symbole habe ich noch nicht Automatisiert übertragen.
mfg Hildi Channel
Alert WhiteBox ShiftMAStrategy
The blue line is SMA .
The lime line = SMA - the shift parameter (%).
Red line = SMA + shift parameter (%).
Strategy uses limit orders. For opening of positions and for closing of positions.
If the price is lower than the lime line - opens a long position.
If the price is higher than the red line - opens a short position.
The position is closed on the blue line ( SMA ). Long and short.
Customizable trailing Stop For Manual EntriesHere's how to create a trailing stop with a manual buy order, on an exchange that does not support native trailing stops. Code can easily be copy+pasted into your normal algos.
To set the entry price for your manual trade, specify the bar time when the trade was made. Note that the time you specify needs to correspond to an opening time on your chart--if it's a 3 hour chart, 6 pm or 9 pm will work, but 8 PM will not. It's not as bad as it sounds though, read on :)
Per usual I keep multiple options open.
Special features in this script:
Change time frame for trailing
Specify trailing parameter (high, close, hlc3, etc.)
Change time frame for stop loss trigger (use a shorter time frame for earlier exits!)
Specify trigger parameter (close, low, hlc3, etc.)
Remember that annoying issue where you might not be able to precisely specify entry price, because you want to use 3 hour closing prices for your trailing stop but you bought in at 7:41 pm? Add this indicator to a 1 minute chart and set your start time to 19:41, then set the trailing time frame to 3 hours!
Next stop is v2, where we take profits along the way before stop loss gets triggered.
Fractal ModelFractal Model - Higher Timeframe Analysis with Market Structure Labeling
A higher timeframe candle visualization tool enhanced with fractal pattern detection and market structure labeling system for pivot-based price action analysis.
What This Script Does:
This indicator displays higher timeframe candles on your current chart and identifies key pivot formations using a systematic labeling approach. It helps traders understand market structure and potential reversal points through comprehensive pivot analysis.
Key Features:
• Higher Timeframe Visualization: Shows HTF candles without switching timeframes
• Market Structure Labeling: Identifies pivot components with C2, C3, and C4 labels
• Fractal Pattern Detection: Marks areas where price is likely to form wicks based on pivot logic
• Sweep Confirmation: Detects when price sweeps previous levels but closes opposite
• Fair Value Gap Detection: Identifies imbalance zones between candle ranges
• Alert System: Sends alerts when fractal pattern formations are confirmed using pivot logic
• Silver Fractal Pattern Alerts: Special alerts during specific market hours
How Market Structure Labeling Works:
The labeling system identifies pivot formations based on their structure:
• C2: The pivot candle that "sticks out" - this is the candle that creates the pivot point using standard pivot logic
• C3: The distribution candle that follows a 3-candle pivot formation - this is where we expect distribution or sharp moves after the sticking out candle
• C4: The distribution candle that follows a 4+ candle pivot formation - this is where we expect distribution or sharp moves after the sticking out candle (used when the pivot extends beyond 3 candles)
CISD (Candle In Series Distribution):
CISD represents price recovering from the aggressive move that went into a higher timeframe candle extreme. It's the price action that follows after a significant move into a HTF level, showing how the market distributes or consolidates after the initial aggressive move.
Fair Value Gaps (FVG):
FVG identifies imbalance zones between candle ranges where price left a gap. These zones often act as support/resistance levels and are areas where price tends to return to fill the imbalance.
Volume Imbalance (VI):
Volume Imbalance detection identifies areas where there's an imbalance in volume between candles, often indicating institutional activity or significant order flow changes.
Projections:
The indicator calculates projection levels based on the range of the series that was broken. These projections extend from the break point and can help identify potential target levels for price movement.
Sweep Logic:
A sweep occurs when price breaks a previous high or low but then closes back in the opposite direction, creating a "wick" or "liquidity grab." This often indicates that the level was tested and rejected, potentially leading to a reversal.
Silver Fractal Patterns:
Special fractal patterns that occur during specific market hours (4th-5th candle of the trading day or 4th candle after 1PM ET). These patterns have additional confirmation requirements and are considered higher probability setups due to their timing in relation to market structure.
Position Sizing:
The indicator includes position sizing calculations based on risk parameters, helping traders determine appropriate position sizes based on their account balance and risk tolerance.
Alert System:
The indicator provides alerts when:
• Fractal pattern formations are created and confirmed
• Price sweeps fractal pattern levels with proper confirmation
• Silver fractal pattern formations occur during specific market hours
• Fractal pattern sweep confirmations are triggered
Practical Usage:
1. Add the indicator to your chart
2. Watch for fractal pattern formations (highlighted zones)
3. Look for C2, C3, C4 labels to understand pivot structure
4. Use sweep confirmations for entry timing
5. Set up alerts for fractal pattern confirmations and sweeps
Technical Implementation:
Logarithmic Midpoint Calculation:
The fractal pattern levels are calculated using logarithmic midpoint analysis:
• Log Values: log_high = ln(high), log_low = ln(low), log_open = ln(open), log_close = ln(close)
• Wick Analysis: upper_wick = log_high - max(log_open, log_close), lower_wick = min(log_open, log_close) - log_low
• Body Size: body_size = |log_close - log_open|
• Midpoint Logic: If max(upper_wick, lower_wick) > body_size, use wick-based midpoint; otherwise use (log_high + log_low)/2
• Final Level: Fractal pattern level = exp(log_mid_level)
Fractal Pattern Formation Conditions:
The indicator detects several types of fractal patterns:
Standard Patterns:
• Standard Bearish: last_closed.h > prev_closed.h AND last_closed.c < prev_closed.h
• Standard Bullish: last_closed.l < prev_closed.l AND last_closed.c > prev_closed.l
Expansive Patterns (Higher timeframe context):
• Expansive Bearish: prev_closed.h > prev_prev_closed.h AND last_closed.c < max(prev_closed.o, prev_closed.c)
• Expansive Bullish: prev_closed.l < prev_prev_closed.l AND last_closed.c > min(prev_closed.o, prev_closed.c)
Pro-trend Patterns (Midpoint-based):
• Pro-trend Bearish: last_closed.h > mid_level AND last_closed.h < prev_closed.o AND last_closed.c < prev_closed.l
• Pro-trend Bullish: last_closed.l < mid_level AND last_closed.l > prev_closed.o AND last_closed.c > prev_closed.h
Sweep Confirmation Logic:
• Pivot Detection: Uses ta.pivothigh(high, 1, 2) and ta.pivotlow(low, 1, 2)
• Touch Detection: Price must touch fractal pattern level (high > level OR open > level) AND close opposite
• Confirmation Requirements: Pivot must form before touch, close must break beyond pivot level
• Alert Trigger: Sweep confirmed when all conditions are met
Silver Fractal Pattern Conditions:
Special fractal patterns during specific market hours (4th-5th candle of day or 4th candle after 1PM ET) with additional confirmation requirements.
HTF Auto-Detection:
Automatically selects appropriate higher timeframes: 1m→15m, 3m→30m, 5m→1h, 15m→4h, 30m-1h→1D, 4h-8h→1W, 1D→1M.
Based on HTF Candles by Fadi, enhanced with fractal pattern detection, sweep logic, market structure labeling system, and comprehensive alert functionality.
Note: This tool is for educational purposes and should be used in conjunction with proper risk management and market analysis.
Global Risk Terminal – Multi-Asset Macro Sentiment IndicatorDescription:
The Global Risk Terminal is a sophisticated macro sentiment indicator that synthesizes signals from three key cross-asset relationships to produce a single, actionable risk appetite score. It is designed to help traders and investors identify whether global markets are in a risk-on (growth-seeking) or risk-off (defensive) regime. The indicator analyzes the behavior of commodities, equities, bonds, and currencies to generate a comprehensive view of market conditions.
Indicator Output:
The Global Risk Terminal produces a normalized risk score ranging from -1 to +1:
Positive values indicate risk-on conditions (growth assets favored)
Negative values indicate risk-off conditions (safe-haven assets favored)
Core Components:
Growth Pulse (Copper to Gold Ratio, HG/GC)
Purpose: Measures investor preference for industrial growth versus safe-haven assets.
Interpretation:
Rising ratio → Copper outperforming gold → Risk-on environment
Falling ratio → Gold outperforming copper → Risk-off environment
Flat ratio → Transitional market phase
Technical Implementation: Dual moving average slope method (fast MA default 20, slow MA default 40). Positive slope = +1, negative slope = -1, flat slope = 0
Equity Rotation (Russell 2000 to S&P 500 Ratio, RTY/ES)
Purpose: Tracks rotation between small-cap and large-cap equities, revealing market risk appetite.
Interpretation:
Rising ratio → Small-caps outperforming → Strong risk-on
Falling ratio → Large-caps outperforming → Defensive positioning
Technical Implementation: Dual moving average slope method (same as Growth Pulse)
Flow Gauge (10-Year Treasury to US Dollar Index, ZN/DXY)
Purpose: Captures liquidity conditions and cross-asset capital flows.
Interpretation:
Rising ratio → Treasury prices rising or USD weakening → Liquidity expansion, risk-on environment
Falling ratio → Treasury prices falling or USD strengthening → Liquidity contraction, risk-off environment
Technical Implementation: Dual moving average slope method
Composite Risk Score Calculation:
Analyze each component for trend using dual moving averages
Assign signal values: +1 (risk-on), -1 (risk-off), 0 (neutral)
Average the three signals:
Risk Score = (Growth Pulse + Equity Rotation + Flow Gauge) / 3
Optional smoothing with exponential moving average (default 3 periods) to reduce noise
Interpreting the Risk Score:
+0.66 to +1.0: Full risk-on – favor cyclical sectors, small-caps, growth strategies
+0.33 to +0.66: Moderate risk-on – mostly bullish environment, watch for fading momentum
-0.33 to +0.33: Neutral/transition – markets in flux, signals mixed, exercise caution
-0.66 to -0.33: Cautious risk-off – favor defensive sectors, reduce high-beta exposure
-1.0 to -0.66: Full risk-off – strong defensive positioning, prioritize safe-haven assets
How to Use the Global Risk Terminal to Frame Trades:
Aligning Trades with Market Regime
Risk-On (+0.33 and above): Look for buying opportunities in cyclical stocks, high-beta equities, commodities, and emerging markets. Use long entries for swing trades or intraday positions, following confirmed price action.
Risk-Off (-0.33 and below): Shift focus to defensive sectors, large-cap quality stocks, U.S. Treasuries, and safe-haven currencies. Prefer short entries or reduced exposure in risky assets.
Entry and Exit Framing
Use the risk score as a macro filter before executing trades:
Example: The risk score is +0.7 (strong risk-on). Prefer long positions in equities or commodities that are showing bullish confirmation on your regular chart.
Conversely, if the risk score is -0.7 (strong risk-off), avoid aggressive longs and consider short or defensive trades.
Watch for threshold crossings (+/-0.33, +/-0.66) as potential inflection points for adjusting position size, stop-loss levels, or sector rotation.
Confirming Trade Decisions
Combine the Global Risk Terminal with price action, volume, and trend indicators:
If equities rally but the risk score is declining, this may indicate a fragile rally driven by few leaders—trade cautiously.
If equities fall but the risk score is rising, consider counter-trend entries or buying dips.
Risk Management and Position Sizing
Strong alignment across components → increase position size and hold with wider stops
Mixed or neutral signals → reduce exposure, tighten stops, or avoid new trades
Defensive regimes → rotate into stable, low-volatility assets and increase cash buffer
Framing Trades Across Timeframes
Use the indicator as a strategic guide rather than a precise timing tool. Even without the MTF table:
Daily trend alignment → Guide swing trade bias
Shorter timeframe price action → Refine entry points and stop placement
Example: Daily chart shows +0.6 risk score → identify high-probability long setups using intraday technical patterns (breakouts, trend continuation).
Sector and Asset Rotation
Risk-On: Focus on cyclical sectors (financials, industrials, materials, energy), small-caps, high-beta instruments
Risk-Off: Focus on defensive sectors (utilities, consumer staples, healthcare), large-caps, safe-haven instruments
Alert Integration
Set alerts on the risk score to notify you when markets move from neutral to risk-on or risk-off regimes. Use these alerts to plan entries, exits, or portfolio adjustments in advance.
Customization Options:
Moving Average Length (5–100): Adjust sensitivity of trend detection
Score Smoothing (1–10): Reduce noise or see raw risk score
Visual Themes: Six preset themes (Cyber, Ocean, Sunset, Monochrome, Matrix, Custom)
Display Options: Show or hide component dashboards, main header, risk level lines, gradient fill, and component signals
Label Size: Tiny, Small, Normal, Large
Alert Conditions:
Risk score crosses above +0.66 → Strong risk-on
Risk score crosses below -0.66 → Strong risk-off
Risk score crosses zero → Neutral line
Risk score crosses above +0.33 → Moderate risk-on
Risk score crosses below -0.33 → Moderate risk-off
Data Sources:
HG1! – Copper Futures (COMEX)
GC1! – Gold Futures (COMEX)
RTY1! – Russell 2000 E-mini Futures (CME)
ES1! – S&P 500 E-mini Futures (CME)
ZN1! – 10-Year U.S. Treasury Note Futures (CBOT)
DXY – U.S. Dollar Index (ICE)
Notes and Limitations:
Works best during clear macro regimes and aligned trends
Use with price action, volume, and other technical tools
Not a standalone trading system; serves as a macro context filter
Equal weighting assumes all three components are equally important, but market conditions may vary
Past performance does not guarantee future results
Conclusion:
The Global Risk Terminal consolidates complex cross-asset signals into a simple, actionable score that informs market regime, portfolio positioning, sector rotation, and trading decisions. Its user-friendly layout and extensive customization options make it suitable for traders of all experience levels seeking macro-driven insights. By framing trades around risk score thresholds and combining macro context with tactical execution, traders can identify higher-probability opportunities and optimize position sizing, entries, and exits across a wide range of market conditions.
AI Predictive Market Movement ProAI Predictive Market Movement Pro is a next-generation, data-driven trading strategy designed to analyze trend strength, momentum, and volatility in real time to forecast potential market direction. Using advanced normalization and weighted scoring, this strategy generates a Predictive Score that identifies optimal BUY and SELL opportunities with visual clarity.
It dynamically adapts to market conditions through adjustable parameters for trend, momentum, and volatility, combined with customizable Take-Profit (TP) and Stop-Loss (SL) levels. The AI-inspired algorithm detects market reversals and continuation points with high precision, helping traders stay on the right side of price movement.
Key Features:
📈 Intelligent Predictive Scoring (trend, momentum, volatility weighted blend)
⚡ Auto-generated Buy/Sell signals with visual markers
🎯 Customizable Take-Profit and Stop-Loss percentages
🧩 Adjustable sensitivity for more conservative or aggressive trading styles
🌈 Dynamic color visualization for market bias (green = bullish, red = bearish)
🔔 Integrated TradingView alerts for real-time notifications
Ideal For:
Scalpers, day traders, and swing traders who want a smart, adaptive, and visually intuitive AI-powered trading companion.