Milvetti_Pineconnector_LibraryLibrary "Milvetti_Pineconnector_Library"
This library has methods that provide practical signal transmission for Pineconnector.Developed By Milvetti
buy(licenseId, symbol, risk, sl, tp, beTrigger, beOffset, trailTrig, trailDist, trailStep, atrTimeframe, atrTrigger, atrPeriod, atrMultiplier, atrShift, spread, accFilter, secret, comment)
Create a buy order message
Parameters:
licenseId (string) : License Id. This is a unique identifier found in the Pineconnector Licensing Dashboard.
symbol (string) : Symbol. Default is syminfo.ticker
risk (float) : Risk. Function depends on the “Volume Type” selected in the EA
sl (float) : StopLoss. Place stop-loss. Computation is based on the Target Type selected in the EA. Default is 0(inactive)
tp (float) : TakeProfit. Place take-profit. Computation is based on the Target Type selected in the EA. Default is 0(inactive)
beTrigger (float) : Breakeven will be activated after the position gains this number of pips. Ensure > 0
beOffset (float) : Offset from entry price. 0 means the SL will be placed exactly at entry price. 1 means 1 pip above the entry price for buy trades and 1 pip below for sell trades.
trailTrig (int) : Trailing stop-loss will be activated after a trade gains this number of pips. Default is 0(inactive)
trailDist (int) : SL will be opened at traildist after trailtrig is met, even if you do not have a SL placed.. Default is 0(inactive)
trailStep (int) : Moves trailing stop-loss once price moves to favourable by a specified number of pips. Default is 0(inactive)
atrTimeframe (string) : ATR Trailing Stop will be based on the specified timeframe in minutes and will only update once per bar close. Default is Timeframe.Period
atrTrigger (float) : Activate the trigger of ATR Trailing after market moves favourably by a number of pips. Default is 0(inactive)
atrPeriod (int) : ATR averaging period. Default is 0
atrMultiplier (float) : Multiple of ATR to utilise in the new SL computation. Default is 1
atrShift (float) : Relative shift of price information, 0 uses latest candle, 1 uses second last, etc. Default is 0
spread (float) : Enter the position only if the spread is equal or less than the specified value in pips. Default is 0(inactive)
accFilter (float) : Enter the position only if the account requirement is met. Default is 0(inactive)
secret (string)
comment (string) : Comment. Add a string into the order’s comment section. Default is "Symbol+Timeframe"
sell(licenseId, symbol, risk, sl, tp, beTrigger, beOffset, trailTrig, trailDist, trailStep, atrTimeframe, atrTrigger, atrPeriod, atrMultiplier, atrShift, spread, accFilter, secret, comment)
Create a buy order message
Parameters:
licenseId (string) : License Id. This is a unique identifier found in the Pineconnector Licensing Dashboard.
symbol (string) : Symbol. Default is syminfo.ticker
risk (float) : Risk. Function depends on the “Volume Type” selected in the EA
sl (float) : StopLoss. Place stop-loss. Computation is based on the Target Type selected in the EA. Default is 0(inactive)
tp (float) : TakeProfit. Place take-profit. Computation is based on the Target Type selected in the EA. Default is 0(inactive)
beTrigger (float) : Breakeven will be activated after the position gains this number of pips. Ensure > 0
beOffset (float) : Offset from entry price. 0 means the SL will be placed exactly at entry price. 1 means 1 pip above the entry price for buy trades and 1 pip below for sell trades.
trailTrig (int) : Trailing stop-loss will be activated after a trade gains this number of pips. Default is 0(inactive)
trailDist (int) : SL will be opened at traildist after trailtrig is met, even if you do not have a SL placed.. Default is 0(inactive)
trailStep (int) : Moves trailing stop-loss once price moves to favourable by a specified number of pips. Default is 0(inactive)
atrTimeframe (string) : ATR Trailing Stop will be based on the specified timeframe in minutes and will only update once per bar close. Default is Timeframe.Period
atrTrigger (float) : Activate the trigger of ATR Trailing after market moves favourably by a number of pips. Default is 0(inactive)
atrPeriod (int) : ATR averaging period. Default is 0
atrMultiplier (float) : Multiple of ATR to utilise in the new SL computation. Default is 1
atrShift (float) : Relative shift of price information, 0 uses latest candle, 1 uses second last, etc. Default is 0
spread (float) : Enter the position only if the spread is equal or less than the specified value in pips. Default is 0(inactive)
accFilter (float) : Enter the position only if the account requirement is met. Default is 0(inactive)
secret (string)
comment (string) : Comment. Add a string into the order’s comment section. Default is "Symbol+Timeframe"
buyLimit(licenseId, symbol, pending, risk, sl, tp, beTrigger, beOffset, trailTrig, trailDist, trailStep, atrTimeframe, atrTrigger, atrPeriod, atrMultiplier, atrShift, spread, accFilter, secret, comment)
Create a buy limit order message
Parameters:
licenseId (string) : License Id. This is a unique identifier found in the Pineconnector Licensing Dashboard.
symbol (string) : Symbol. Default is syminfo.ticker
pending (float) : Computing pending order entry price. EA Options: Pips, Specified Price, Percentage
risk (float) : Risk. Function depends on the “Volume Type” selected in the EA
sl (float) : StopLoss. Place stop-loss. Computation is based on the Target Type selected in the EA. Default is 0(inactive)
tp (float) : TakeProfit. Place take-profit. Computation is based on the Target Type selected in the EA. Default is 0(inactive)
beTrigger (float) : Breakeven will be activated after the position gains this number of pips. Ensure > 0
beOffset (float) : Offset from entry price. 0 means the SL will be placed exactly at entry price. 1 means 1 pip above the entry price for buy trades and 1 pip below for sell trades.
trailTrig (int) : Trailing stop-loss will be activated after a trade gains this number of pips. Default is 0(inactive)
trailDist (int) : SL will be opened at traildist after trailtrig is met, even if you do not have a SL placed.. Default is 0(inactive)
trailStep (int) : Moves trailing stop-loss once price moves to favourable by a specified number of pips. Default is 0(inactive)
atrTimeframe (string) : ATR Trailing Stop will be based on the specified timeframe in minutes and will only update once per bar close. Default is Timeframe.Period
atrTrigger (float) : Activate the trigger of ATR Trailing after market moves favourably by a number of pips. Default is 0(inactive)
atrPeriod (int) : ATR averaging period. Default is 0
atrMultiplier (float) : Multiple of ATR to utilise in the new SL computation. Default is 1
atrShift (float) : Relative shift of price information, 0 uses latest candle, 1 uses second last, etc. Default is 0
spread (float) : Enter the position only if the spread is equal or less than the specified value in pips. Default is 0(inactive)
accFilter (float) : Enter the position only if the account requirement is met. Default is 0(inactive)
secret (string)
comment (string) : Comment. Add a string into the order’s comment section. Default is "Symbol+Timeframe"
buyStop(licenseId, symbol, pending, risk, sl, tp, beTrigger, beOffset, trailTrig, trailDist, trailStep, atrTimeframe, atrTrigger, atrPeriod, atrMultiplier, atrShift, spread, accFilter, secret, comment)
Create a buy stop order message
Parameters:
licenseId (string) : License Id. This is a unique identifier found in the Pineconnector Licensing Dashboard.
symbol (string) : Symbol. Default is syminfo.ticker
pending (float) : Computing pending order entry price. EA Options: Pips, Specified Price, Percentage
risk (float) : Risk. Function depends on the “Volume Type” selected in the EA
sl (float) : StopLoss. Place stop-loss. Computation is based on the Target Type selected in the EA. Default is 0(inactive)
tp (float) : TakeProfit. Place take-profit. Computation is based on the Target Type selected in the EA. Default is 0(inactive)
beTrigger (float) : Breakeven will be activated after the position gains this number of pips. Ensure > 0
beOffset (float) : Offset from entry price. 0 means the SL will be placed exactly at entry price. 1 means 1 pip above the entry price for buy trades and 1 pip below for sell trades.
trailTrig (int) : Trailing stop-loss will be activated after a trade gains this number of pips. Default is 0(inactive)
trailDist (int) : SL will be opened at traildist after trailtrig is met, even if you do not have a SL placed.. Default is 0(inactive)
trailStep (int) : Moves trailing stop-loss once price moves to favourable by a specified number of pips. Default is 0(inactive)
atrTimeframe (string) : ATR Trailing Stop will be based on the specified timeframe in minutes and will only update once per bar close. Default is Timeframe.Period
atrTrigger (float) : Activate the trigger of ATR Trailing after market moves favourably by a number of pips. Default is 0(inactive)
atrPeriod (int) : ATR averaging period. Default is 0
atrMultiplier (float) : Multiple of ATR to utilise in the new SL computation. Default is 1
atrShift (float) : Relative shift of price information, 0 uses latest candle, 1 uses second last, etc. Default is 0
spread (float) : Enter the position only if the spread is equal or less than the specified value in pips. Default is 0(inactive)
accFilter (float) : Enter the position only if the account requirement is met. Default is 0(inactive)
secret (string)
comment (string) : Comment. Add a string into the order’s comment section. Default is "Symbol+Timeframe"
sellLimit(licenseId, symbol, pending, risk, sl, tp, beTrigger, beOffset, trailTrig, trailDist, trailStep, atrTimeframe, atrTrigger, atrPeriod, atrMultiplier, atrShift, spread, accFilter, secret, comment)
Create a sell limit order message
Parameters:
licenseId (string) : License Id. This is a unique identifier found in the Pineconnector Licensing Dashboard.
symbol (string) : Symbol. Default is syminfo.ticker
pending (float) : Computing pending order entry price. EA Options: Pips, Specified Price, Percentage
risk (float) : Risk. Function depends on the “Volume Type” selected in the EA
sl (float) : StopLoss. Place stop-loss. Computation is based on the Target Type selected in the EA. Default is 0(inactive)
tp (float) : TakeProfit. Place take-profit. Computation is based on the Target Type selected in the EA. Default is 0(inactive)
beTrigger (float) : Breakeven will be activated after the position gains this number of pips. Ensure > 0
beOffset (float) : Offset from entry price. 0 means the SL will be placed exactly at entry price. 1 means 1 pip above the entry price for buy trades and 1 pip below for sell trades.
trailTrig (int) : Trailing stop-loss will be activated after a trade gains this number of pips. Default is 0(inactive)
trailDist (int) : SL will be opened at traildist after trailtrig is met, even if you do not have a SL placed.. Default is 0(inactive)
trailStep (int) : Moves trailing stop-loss once price moves to favourable by a specified number of pips. Default is 0(inactive)
atrTimeframe (string) : ATR Trailing Stop will be based on the specified timeframe in minutes and will only update once per bar close. Default is Timeframe.Period
atrTrigger (float) : Activate the trigger of ATR Trailing after market moves favourably by a number of pips. Default is 0(inactive)
atrPeriod (int) : ATR averaging period. Default is 0
atrMultiplier (float) : Multiple of ATR to utilise in the new SL computation. Default is 1
atrShift (float) : Relative shift of price information, 0 uses latest candle, 1 uses second last, etc. Default is 0
spread (float) : Enter the position only if the spread is equal or less than the specified value in pips. Default is 0(inactive)
accFilter (float) : Enter the position only if the account requirement is met. Default is 0(inactive)
secret (string)
comment (string) : Comment. Add a string into the order’s comment section. Default is "Symbol+Timeframe"
sellStop(licenseId, symbol, pending, risk, sl, tp, beTrigger, beOffset, trailTrig, trailDist, trailStep, atrTimeframe, atrTrigger, atrPeriod, atrMultiplier, atrShift, spread, accFilter, secret, comment)
Create a sell stop order message
Parameters:
licenseId (string) : License Id. This is a unique identifier found in the Pineconnector Licensing Dashboard.
symbol (string) : Symbol. Default is syminfo.ticker
pending (float) : Computing pending order entry price. EA Options: Pips, Specified Price, Percentage
risk (float) : Risk. Function depends on the “Volume Type” selected in the EA
sl (float) : StopLoss. Place stop-loss. Computation is based on the Target Type selected in the EA. Default is 0(inactive)
tp (float) : TakeProfit. Place take-profit. Computation is based on the Target Type selected in the EA. Default is 0(inactive)
beTrigger (float) : Breakeven will be activated after the position gains this number of pips. Ensure > 0
beOffset (float) : Offset from entry price. 0 means the SL will be placed exactly at entry price. 1 means 1 pip above the entry price for buy trades and 1 pip below for sell trades.
trailTrig (int) : Trailing stop-loss will be activated after a trade gains this number of pips. Default is 0(inactive)
trailDist (int) : SL will be opened at traildist after trailtrig is met, even if you do not have a SL placed.. Default is 0(inactive)
trailStep (int) : Moves trailing stop-loss once price moves to favourable by a specified number of pips. Default is 0(inactive)
atrTimeframe (string) : ATR Trailing Stop will be based on the specified timeframe in minutes and will only update once per bar close. Default is Timeframe.Period
atrTrigger (float) : Activate the trigger of ATR Trailing after market moves favourably by a number of pips. Default is 0(inactive)
atrPeriod (int) : ATR averaging period. Default is 0
atrMultiplier (float) : Multiple of ATR to utilise in the new SL computation. Default is 1
atrShift (float) : Relative shift of price information, 0 uses latest candle, 1 uses second last, etc. Default is 0
spread (float) : Enter the position only if the spread is equal or less than the specified value in pips. Default is 0(inactive)
accFilter (float) : Enter the position only if the account requirement is met. Default is 0(inactive)
secret (string)
comment (string) : Comment. Add a string into the order’s comment section. Default is "Symbol+Timeframe"
Formatting
Milvetti_TraderPost_LibraryLibrary "Milvetti_TraderPost_Library"
This library has methods that provide practical signal transmission for traderpost.Developed By Milvetti
cancelOrders(symbol)
This method generates a signal in JSON format that cancels all orders for the specified pair. (If you want to cancel stop loss and takeprofit orders together, use the “exitOrder” method.
Parameters:
symbol (string)
exitOrders(symbol)
This method generates a signal in JSON format that close all orders for the specified pair.
Parameters:
symbol (string)
createOrder(ticker, positionType, orderType, entryPrice, signalPrice, qtyType, qty, stopLoss, stopType, stopValue, takeProfit, profitType, profitValue, timeInForce)
This function is designed to send buy or sell orders to traderpost. It can create customized orders by flexibly specifying parameters such as order type, position type, entry price, quantity calculation method, stop-loss, and take-profit. The purpose of the function is to consolidate all necessary details for opening a position into a single structure and present it as a structured JSON output. This format can be sent to trading platforms via webhooks.
Parameters:
ticker (string) : The ticker symbol of the instrument. Default value is the current chart's ticker (syminfo.ticker).
positionType (string) : Determines the type of order (e.g., "long" or "buy" for buying and "short" or "sell" for selling).
orderType (string) : Defines the order type for execution. Options: "market", "limit", "stop". Default is "market"
entryPrice (float) : The price level for entry orders. Only applicable for limit or stop orders. Default is 0 (market orders ignore this).
signalPrice (float) : Optional. Only necessary when using relative take profit or stop losses, and the broker does not support fetching quotes to perform the calculation. Default is 0
qtyType (string) : Determines how the order quantity is calculated. Options: "fixed_quantity", "dollar_amount", "percent_of_equity", "percent_of_position".
qty (float) : Quantity value. Can represent units of shares/contracts or a dollar amount, depending on qtyType.
stopLoss (bool) : Enable or disable stop-loss functionality. Set to `true` to activate.
stopType (string) : Specifies the stop-loss calculation type. Options: percent, "amount", "stopPrice", "trailPercent", "trailAmount". Default is "stopPrice"
stopValue (float) : Stop-loss value based on stopType. Can be a percentage, dollar amount, or a specific stop price. Default is "stopPrice"
takeProfit (bool) : Enable or disable take-profit functionality. Set to `true` to activate.
profitType (string) : Specifies the take-profit calculation type. Options: "percent", "amount", "limitPrice". Default is "limitPrice"
profitValue (float) : Take-profit value based on profitType. Can be a percentage, dollar amount, or a specific limit price. Default is 0
timeInForce (string) : The time in force for your order. Options: day, gtc, opg, cls, ioc and fok
Returns: Return result in Json format.
addTsl(symbol, stopType, stopValue, price)
This method adds trailing stop loss to the current position. “Price” is the trailing stop loss starting level. You can leave price blank if you want it to start immediately
Parameters:
symbol (string)
stopType (string) : Specifies the trailing stoploss calculation type. Options: "trailPercent", "trailAmount".
stopValue (float) : Stop-loss value based on stopType. Can be a percentage, dollar amount.
price (float) : The trailing stop loss starting level. You can leave price blank if you want it to start immediately. Default is current price.
tacLibrary "tac"
Customised techninal analysis functions
sar(start, inc, max)
returns parabolic sar with lagging value
Parameters:
start (float) : float: Start
inc (float) : float: Increment
max (float) : float: Maximum
Returns: Actual sar value and lagging sar value
ToolsFluentLibrary "ToolsFluent"
Fluent data holder object with retrieval and modification functions
set(fluent, key, value)
Returns Fluent object after setting related fluent value
Parameters:
fluent (Fluent) : Fluent Fluent object
key (string) : string|int Key to be set
value (int) : int|float|bool|string|color Value to be set
Returns: Fluent
set(fluent, key, value)
Parameters:
fluent (Fluent)
key (string)
value (float)
set(fluent, key, value)
Parameters:
fluent (Fluent)
key (string)
value (bool)
set(fluent, key, value)
Parameters:
fluent (Fluent)
key (string)
value (string)
set(fluent, key, value)
Parameters:
fluent (Fluent)
key (string)
value (color)
set(fluent, key, value)
Parameters:
fluent (Fluent)
key (int)
value (int)
set(fluent, key, value)
Parameters:
fluent (Fluent)
key (int)
value (float)
set(fluent, key, value)
Parameters:
fluent (Fluent)
key (int)
value (bool)
set(fluent, key, value)
Parameters:
fluent (Fluent)
key (int)
value (string)
set(fluent, key, value)
Parameters:
fluent (Fluent)
key (int)
value (color)
get(fluent, key, default)
Returns Fluent object key's value or default value when key not found
Parameters:
fluent (Fluent) : Fluent object
key (string)
default (int) : int|float|bool|string|color Value to be returned when key not exists
Returns: int|float|bool|string|color
get(fluent, key, default)
Parameters:
fluent (Fluent)
key (string)
default (float)
get(fluent, key, default)
Parameters:
fluent (Fluent)
key (string)
default (bool)
get(fluent, key, default)
Parameters:
fluent (Fluent)
key (string)
default (string)
get(fluent, key, default)
Parameters:
fluent (Fluent)
key (string)
default (color)
get(fluent, key, default)
Parameters:
fluent (Fluent)
key (int)
default (int)
get(fluent, key, default)
Parameters:
fluent (Fluent)
key (int)
default (float)
get(fluent, key, default)
Parameters:
fluent (Fluent)
key (int)
default (bool)
get(fluent, key, default)
Parameters:
fluent (Fluent)
key (int)
default (string)
get(fluent, key, default)
Parameters:
fluent (Fluent)
key (int)
default (color)
Fluent
Fluent - General purpose data holder object
Fields:
msi (map) : map String key, integer value info holder map. Default: na
msf (map) : map String key, float value info holder map. Default: na
msb (map) : map String key, boolean value info holder map. Default: na
mss (map) : map String key, string value info holder map. Default: na
msc (map) : map String key, color value info holder map. Default: na
mii (map) : map Integer key, integer value info holder map. Default: na
mif (map) : map Integer key, float value info holder map. Default: na
mib (map) : map Integer key, boolean value info holder map. Default: na
mis (map) : map Integer key, string value info holder map. Default: na
mic (map) : map Integer key, color value info holder map. Default: na
ToolsPosLibrary "ToolsPos"
Library for general purpose position helpers
new_pos(state, price, when, index)
Returns new PosInfo object
Parameters:
state (series PosState) : Position state
price (float) : float Entry price
when (int) : int Entry bar time UNIX. Default: time
index (int) : int Entry bar index. Default: bar_index
Returns: PosInfo
new_tp(pos, price, when, index, info)
Returns PosInfo object with new take profit info object
Parameters:
pos (PosInfo) : PosInfo object
price (float) : float Entry price
when (int) : int Entry bar time UNIX. Default: time
index (int) : int Entry bar index. Default: bar_index
info (Info type from aybarsm/Tools/14) : Info holder object. Default: na
Returns: PosInfo
new_re(pos, price, when, index, info)
Returns PosInfo object with new re-entry info object
Parameters:
pos (PosInfo) : PosInfo object
price (float) : float Entry price
when (int) : int Entry bar time UNIX. Default: time
index (int) : int Entry bar index. Default: bar_index
info (Info type from aybarsm/Tools/14) : Info holder object. Default: na
Returns: PosInfo
PosTPInfo
PosTPInfo - Position Take Profit info object
Fields:
price (series float) : float Take profit price
when (series int) : int Take profit bar time UNIX. Default: time
index (series int) : int Take profit bar index. Default: bar_index
info (Info type from aybarsm/Tools/14) : Info holder object
PosREInfo
PosREInfo - Position Re-Entry info object
Fields:
price (series float) : float Re-entry price
when (series int) : int Re-entry bar time UNIX. Default: time
index (series int) : int Take profit bar index. Default: bar_index
info (Info type from aybarsm/Tools/14) : Info holder object
PosInfo
PosInfo - Position info object
Fields:
state (series PosState) : Position state
price (series float) : float Entry price
when (series int) : int Entry bar time UNIX. Default: time
index (series int) : int Entry bar index. Default: bar_index
tp (array) : PosTPInfo Take profit info. Default: na
re (array) : PosREInfo Re-entry info. Default: na
info (Info type from aybarsm/Tools/14) : Info holder object
ToolsCollectionLibrary "ToolsCollection"
Helper functions for collection (map/array) type operations
get(container, key, default)
Returns Map key's value with default return value option
Parameters:
container (map) : Map object
key (string) : Key to be checked
default (bool) : Default return value when key not found. Default: false
Returns: bool
get(container, key, default)
Returns Map key's value with default return value option
Parameters:
container (map) : Map object
key (string) : Key to be checked
default (int) : Default return value when key not found. Default: -1
Returns: int
get(container, key, default)
Returns Map key's value with default return value option
Parameters:
container (map) : Map object
key (string) : Key to be checked
default (float) : Default return value when key not found. Default: -1
Returns: float
get(container, key, default)
Returns Map key's value with default return value option
Parameters:
container (map) : Map object
key (string) : Key to be checked
default (string) : Default return value when key not found. Default: ''
Returns: string
get(container, key, default)
Returns Map key's value with default return value option
Parameters:
container (map) : Map object
key (string) : Key to be checked
default (color) : Default return value when key not found. Default: color.white
Returns: color
get(container, key, default)
Returns Map key's value with default return value option
Parameters:
container (map) : Map object
key (int) : Key to be checked
default (bool) : Default return value when key not found. Default: false
Returns: bool
get(container, key, default)
Returns Map key's value with default return value option
Parameters:
container (map) : Map object
key (int) : Key to be checked
default (int) : Default return value when key not found. Default: -1
Returns: int
get(container, key, default)
Returns Map key's value with default return value option
Parameters:
container (map) : Map object
key (int) : Key to be checked
default (float) : Default return value when key not found. Default: -1
Returns: float
get(container, key, default)
Returns Map key's value with default return value option
Parameters:
container (map) : Map object
key (int) : Key to be checked
default (string) : Default return value when key not found. Default: ''
Returns: string
get(container, key, default)
Returns Map key's value with default return value option
Parameters:
container (map) : Map object
key (int) : Key to be checked
default (color) : Default return value when key not found. Default: color.white
Returns: color
get(container, key, default)
Returns Array key's value with default return value option
Parameters:
container (array) : Array object
key (int) : Key to be checked
default (bool) : Default return value when key not found. Default: false
Returns: bool
get(container, key, default)
Returns Array key's value with default return value option
Parameters:
container (array) : Array object
key (int) : Key to be checked
default (int) : Default return value when key not found. Default: -1
Returns: bool
get(container, key, default)
Returns Array key's value with default return value option
Parameters:
container (array) : Array object
key (int) : Key to be checked
default (float) : Default return value when key not found. Default: -1
Returns: bool
get(container, key, default)
Returns Array key's value with default return value option
Parameters:
container (array) : Array object
key (int) : Key to be checked
default (string) : Default return value when key not found. Default: ''
Returns: bool
get(container, key, default)
Returns Array key's value with default return value option
Parameters:
container (array) : Array object
key (int) : Key to be checked
default (color) : Default return value when key not found. Default: color.white
Returns: bool
ToolsMapLibrary "ToolsMap"
Helper functions for map type operations
map_def(container, key, default)
Returns Map key's value with default return value option
Parameters:
container (map) : Map object
key (string) : Key to be checked
default (bool) : Default return value when key not found. Default: false
Returns: bool
map_def(container, key, default)
Returns Map key's value with default return value option
Parameters:
container (map) : Map object
key (string) : Key to be checked
default (int) : Default return value when key not found. Default: -1
Returns: int
map_def(container, key, default)
Returns Map key's value with default return value option
Parameters:
container (map) : Map object
key (string) : Key to be checked
default (float) : Default return value when key not found. Default: -1
Returns: float
map_def(container, key, default)
Returns Map key's value with default return value option
Parameters:
container (map) : Map object
key (string) : Key to be checked
default (string) : Default return value when key not found. Default: ''
Returns: string
map_def(container, key, default)
Returns Map key's value with default return value option
Parameters:
container (map) : Map object
key (string) : Key to be checked
default (color) : Default return value when key not found. Default: color.white
Returns: color
map_def(container, key, default)
Returns Map key's value with default return value option
Parameters:
container (map) : Map object
key (int) : Key to be checked
default (bool) : Default return value when key not found. Default: false
Returns: bool
map_def(container, key, default)
Returns Map key's value with default return value option
Parameters:
container (map) : Map object
key (int) : Key to be checked
default (int) : Default return value when key not found. Default: -1
Returns: int
map_def(container, key, default)
Returns Map key's value with default return value option
Parameters:
container (map) : Map object
key (int) : Key to be checked
default (float) : Default return value when key not found. Default: -1
Returns: float
map_def(container, key, default)
Returns Map key's value with default return value option
Parameters:
container (map) : Map object
key (int) : Key to be checked
default (string) : Default return value when key not found. Default: ''
Returns: string
map_def(container, key, default)
Returns Map key's value with default return value option
Parameters:
container (map) : Map object
key (int) : Key to be checked
default (color) : Default return value when key not found. Default: color.white
Returns: color
ToolsLibrary "Tools"
Common tools
movingAverage(maType, maSource, maLength)
dynamically returns MA
Parameters:
maType (string) : ma type
maSource (float) : ma source
maLength (simple int) : ma length
Returns: ta.{sma,rma,ema,wma,vwma,hma}
display_valueOVERVIEW
This script is a tinny library for creating and displaying formatted values in TradingView scripts. It provides a structured way to present key information like titles, percentages, currency values, decimals, and integers with clear formatting. This allows you to coordinate your strings in advance and hold one item to use for calling your string to a label, box, table.. Made for day to day use of most typical use cases, more advanced techniques should be used for complicated scenarios.
Building Blocks
User Defined Types (UDTs)
The script defines a UDT called `DisplayValue` to encapsulate the components of a display value:
* title : The title or label of the value.
* format_string : The string used to format the value (e.g., "{0} - 1,number,percent}").
* value : The actual value to be displayed.
* format : An enum value specifying the desired format (percent, currency, etc.).
Enums
The `DisplayFormat` enum provides predefined constants for various formatting options, making the code more readable and less prone to errors.
Functions
* create() : This function creates a new `DisplayValue` instance. It takes the title, value, and desired format as arguments and generates the appropriate format string.
* to_string() : This function converts a `DisplayValue` instance into a formatted string ready for display on the chart.
How to Use
1. Import the library:
import kaigouthro/display_value/1as dv
2. Create a DisplayValue instance:
myValue = dv.create("My Percentage", 0.5, dv.DisplayFormat.percent)
3. Convert it to a string:
formattedString = dv.to_string(myValue)
4. Display the formatted string:
label.new(bar_index, high, formattedString)
Example
//@version=5
import kaigouthro/display_value/1 as dv
myValue = dv.create("Profit", 0.15, dv.DisplayFormat.percent)
formattedString = dv.to_string(myValue)
label.new(bar_index, high, formattedString)
This will display a label on the chart with the text "Profit - 15%".
### Notes
* The library handles the formatting details, making it easier to display values consistently in your scripts.
* The use of enums and UDTs improves code organization and readability.
--------
Library "display_value"
create(display_name, display_value, display_format)
Gets the appropriate format string based on the display format.
Parameters:
display_name (string) : (string) The name of the display value. Default is na.
display_value (float)
display_format (series DisplayFormat)
Returns: (DisplayValue) A new DisplayValue instance with the formatted value.
to_string(item)
Converts the display value to a string with the specified format.
Parameters:
item (DisplayValue) : (DisplayValue) The display value to convert to a string.
Returns: (string) The string representation of the display value.
DisplayValue
Structure representing a display value.
Fields:
title (series string) : (string) The title of the display value.
format_string (series string) : (string) The format string to use for display.
value (series float) : (float) The value to display.
format (series DisplayFormat) : (DisplayFormat) The format to use.
formattingUtilitiesLibrary "formattingUtilities"
toPercentageString(x, decimals)
: Converts a decimal number into a string formatted as percentage.
Parameters:
x (float) : (simple float): Float number to be converted
decimals (int) : (simple int): Number of decimals to apply
Returns: : Returns a string with x as percentage.
toFactorString(x, decimals)
: Converts a decimal number into a string formatted as Factor.
Parameters:
x (float) : (simple float): Float number to be converted
decimals (int) : (simple int): Number of decimals to apply
Returns: : Returns a string with x as a Factor.
toCurrencyString(x, decimals)
: Converts a decimal number into a string formatted as currency.
Parameters:
x (float) : (simple float): Float number to be converted
decimals (int) : (simple int): Number of decimals to apply
Returns: : Returns a string with x as currency.
toNumberString(x, decimals)
: Converts a decimal number into a string formatted as decimal.
Parameters:
x (float) : (simple float): Float number to be converted
decimals (int) : (simple int): Number of decimals to apply
Returns: : Returns a string with x as a decimal.
colorByAboveBelow(x, reference, above, below, equal)
: Returns a different color if the reference is above, below or equal to x.
Parameters:
x (float) : (simple float): The number that will be tested, above, below or equal.
reference (float) : (simple float): The reference for for determining if x is above, below or equal.
above (color)
below (color)
equal (color)
Returns: : The color returned if above, below or equal.
utilitiesLibrary "utilities"
toPercentageString(x, decimals)
: Converts a decimal number into a string formatted as percentage.
Parameters:
x (float) : (simple float): Float number to be converted
decimals (int) : (simple int): Number of decimals to apply
Returns: : Returns a string with x as percentage.
toFactorString(x, decimals)
: Converts a decimal number into a string formatted as Factor.
Parameters:
x (float) : (simple float): Float number to be converted
decimals (int) : (simple int): Number of decimals to apply
Returns: : Returns a string with x as a Factor.
toCurrencyString(x, decimals)
: Converts a decimal number into a string formatted as currency.
Parameters:
x (float) : (simple float): Float number to be converted
decimals (int) : (simple int): Number of decimals to apply
Returns: : Returns a string with x as currency.
toNumberString(x, decimals)
: Converts a decimal number into a string formatted as decimal.
Parameters:
x (float) : (simple float): Float number to be converted
decimals (int) : (simple int): Number of decimals to apply
Returns: : Returns a string with x as a decimal.
StyleLibraryLibrary "StyleLibrary"
A small library of Pine Script functions that return built-in style variables.
method sizeStyle(size)
Takes a `string` that returns the corresponding built-in size style variable.
Namespace types: series string, simple string, input string, const string
Parameters:
size (string) : A `string` representing a built-in size style: `"Tiny"`, `"Small"`, `"Normal"`, `"Large"`,
`"Huge"`, `"Auto"`.
Returns: The respective built-in size style variable.
method sizeStyle(size)
Takes a `sizeStyle` that returns the corresponding built-in size style variable.
Namespace types: series sizeStyle
Parameters:
size (series sizeStyle) : A `sizeStyle` representing a built-in size style variable.
Returns: The respective built-in size style variable.
method lineStyle(style)
Takes a `string` that returns the corresponding built-in line style variable.
Namespace types: series string, simple string, input string, const string
Parameters:
style (string) : A `string` representing a built-in line style: `"Dashed"`, `"Dotted"`, `"Solid"`.
Returns: The respective built-in line style variable.
method lineStyle(style)
Takes a `lineStyle` that returns the corresponding built-in line style variable.
Namespace types: series lineStyle
Parameters:
style (series lineStyle) : A `lineStyle` representing a built-in line style variable.
Returns: The respective built-in line style variable.
method labelStyle(style)
Takes a `string` that returns the corresponding built-in label style variable.
Namespace types: series string, simple string, input string, const string
Parameters:
style (string) : A `string` representing a built-in label style:
`"Arrow Down"`, `"Arrow Up"`, `"Circle"`, `"Cross"`, `"Diamond"`, `"Flag"`,
`"Label Center"`, `"Label Down"`, `"Label Left"`, `"Label Lower Left"`,
`"Label Lower Right"`, `"Label Right"`, `"Label Up"`, `"Label Upper Left"`,
`"Label Upper Right"`, `"None"`, `"Square"`, `"Text Outline"`, `"Triangle Down"`,
`"Triangle Up"`, `"XCross"`.
Returns: The respective built-in label style variable.
method labelStyle(style)
Takes a `labelStyle` that returns the corresponding built-in label style variable.
Namespace types: series labelStyle
Parameters:
style (series labelStyle) : A `labelStyle` representing a built-in label style variable.
Returns: The respective built-in label style variable.
method fontStyle(font)
Takes a `string` that returns the corresponding built-in font style variable.
Namespace types: series string, simple string, input string, const string
Parameters:
font (string) : A `string` representing a built-in font style: `"Default"`, `"Monospace"`.
Returns: The respective built-in font style variable.
method positionStyle(position)
Takes a `string` that returns the corresponding built-in position style variable.
Namespace types: series string, simple string, input string, const string
Parameters:
position (string) : A `string` representing a built-in position style:
`"Bottom Center", `"Bottom Left", `"Bottom Right", `"Middle Center", `"Middle Left",
`"Middle Right", `"Top Center", `"Top Left", `"Top Right".
Returns: The respective built-in position style variable.
method displayStyle(display)
Takes a `simple string` that returns the corresponding built-in display style variable.
Namespace types: simple string, input string, const string
Parameters:
display (simple string) : A `simple string` representing a built-in display style: `"All"`, `"Data Window"`,
`"None"`, `"Pane"`, `"Price Scale"`, `"Status Line"`.
Returns: The respective built-in display style variable.
Harmonic Patterns Library [TradingFinder]🔵 Introduction
Harmonic patterns blend geometric shapes with Fibonacci numbers, making these numbers fundamental to understanding the patterns.
One person who has done a lot of research on harmonic patterns is Scott Carney.Scott Carney's research on harmonic patterns in technical analysis focuses on precise price structures based on Fibonacci ratios to identify market reversals.
Key patterns include the Gartley, Bat, Butterfly, and Crab, each with specific alignment criteria. These patterns help traders anticipate potential market turning points and make informed trading decisions, enhancing the predictability of technical analysis.
🟣 Understanding 5-Point Harmonic Patterns
In the current library version, you can easily draw and customize most XABCD patterns. These patterns often form M or W shapes, or a combination of both. By calculating the Fibonacci ratios between key points, you can estimate potential price movements.
All five-point patterns share a similar structure, differing only in line lengths and Fibonacci ratios. Learning one pattern simplifies understanding others.
🟣 Exploring the Gartley Pattern
The Gartley pattern appears in both bullish (M shape) and bearish (W shape) forms. In the bullish Gartley, point X is below point D, and point A surpasses point C. Point D marks the start of a strong upward trend, making it an optimal point to place a buy order.
The bearish Gartley mirrors the bullish pattern with inverted Fibonacci ratios. In this scenario, point D indicates the start of a significant price drop. Traders can place sell orders at this point and buy at lower prices for profit in two-way markets.
🟣 Analyzing the Butterfly Pattern
The Butterfly pattern also manifests in bullish (M shape) and bearish (W shape) forms. It resembles the Gartley pattern but with point D lower than point X in the bullish version.
The Butterfly pattern involves deeper price corrections than the Gartley, leading to more significant price fluctuations. Point D in the bullish Butterfly indicates the beginning of a sharp price rise, making it an entry point for buy orders.
The bearish Butterfly has inverted Fibonacci ratios, with point D marking the start of a sharp price decline, ideal for sell orders followed by buying at lower prices in two-way markets.
🟣 Insights into the Bat Pattern
The Bat pattern, appearing in bullish (M shape) and bearish (W shape) forms, is one of the most precise harmonic patterns. It closely resembles the Butterfly and Gartley patterns, differing mainly in Fibonacci levels.
The bearish Bat pattern shares the Fibonacci ratios with the bullish Bat, with an inverted structure. Point D in the bearish Bat marks the start of a significant price drop, suitable for sell orders followed by buying at lower prices for profit.
🟣 The Crab Pattern Explained
The Crab pattern, found in both bullish (M shape) and bearish (W shape) forms, is highly favored by analysts. Discovered in 2000, the Crab pattern features a larger final wave correction compared to other harmonic patterns.
The bearish Crab shares Fibonacci ratios with the bullish version but in an inverted form. Point D in the bearish Crab signifies the start of a sharp price decline, making it an ideal point for sell orders followed by buying at lower prices for profitable trades.
🟣 Understanding the Shark Pattern
The Shark pattern appears in bullish (M shape) and bearish (W shape) forms. It differs from previous patterns as point C in the bullish Shark surpasses point A, with unique level measurements.
The bearish Shark pattern mirrors the Fibonacci ratios of the bullish Shark but is inverted. Point D in the bearish Shark indicates the start of a sharp price drop, ideal for placing sell orders and buying at lower prices to capitalize on the pattern.
🟣 The Cypher Pattern Overview
The Cypher pattern is another that appears in both bullish (M shape) and bearish (W shape) forms. It resembles the Shark pattern, with point C in the bullish Cypher extending beyond point A, and point D forming within the XA line.
The bearish Cypher shares the Fibonacci ratios with the bullish Cypher but in an inverted structure. Point D in the bearish Cypher marks the start of a significant price drop, perfect for sell orders followed by buying at lower prices.
🟣 Introducing the Nen-Star Pattern
The Nen-Star pattern appears in both bullish (M shape) and bearish (W shape) forms. In the bullish Nen-Star, point C extends beyond point A, and point D, the final point, forms outside the XA line, making CD the longest wave.
The bearish Nen-Star has inverted Fibonacci ratios, with point D indicating the start of a significant price drop. Traders can place sell orders at point D and buy at lower prices to profit from this pattern in two-way markets.
The 5-point harmonic patterns, commonly referred to as XABCD patterns, are specific geometric price structures identified in financial markets. These patterns are used by traders to predict potential price movements based on historical price data and Fibonacci retracement levels.
Here are the main 5-point harmonic patterns :
Gartley Pattern
Anti-Gartley Pattern
Bat Pattern
Anti-Bat Pattern
Alternate Bat Pattern
Butterfly Pattern
Anti-Butterfly Pattern
Crab Pattern
Anti-Crab Pattern
Deep Crab Pattern
Shark Pattern
Anti- Shark Pattern
Anti Alternate Shark Pattern
Cypher Pattern
Anti-Cypher Pattern
🔵 How to Use
To add "Order Block Refiner Library", you must first add the following code to your script.
import TFlab/Harmonic_Chart_Pattern_Library_TradingFinder/1 as HP
🟣 Parameters
XABCD(Name, Type, Show, Color, LineWidth, LabelSize, ShVF, FLPC, FLPCPeriod, Pivot, ABXAmin, ABXAmax, BCABmin, BCABmax, CDBCmin, CDBCmax, CDXAmin, CDXAmax) =>
Parameters:
Name (string)
Type (string)
Show (bool)
Color (color)
LineWidth (int)
LabelSize (string)
ShVF (bool)
FLPC (bool)
FLPCPeriod (int)
Pivot (int)
ABXAmin (float)
ABXAmax (float)
BCABmin (float)
BCABmax (float)
CDBCmin (float)
CDBCmax (float)
CDXAmin (float)
CDXAmax (float)
🟣 Genaral Parameters
Name : The name of the pattern.
Type: Enter "Bullish" to draw a Bullish pattern and "Bearish" to draw an Bearish pattern.
Show : Enter "true" to display the template and "false" to not display the template.
Color : Enter the desired color to draw the pattern in this parameter.
LineWidth : You can enter the number 1 or numbers higher than one to adjust the thickness of the drawing lines. This number must be an integer and increases with increasing thickness.
LabelSize : You can adjust the size of the labels by using the "size.auto", "size.tiny", "size.smal", "size.normal", "size.large" or "size.huge" entries.
🟣 Logical Parameters
ShVF : If this parameter is on "true" mode, only patterns will be displayed that they have exact format and no noise can be seen in them. If "false" is, the patterns displayed that maybe are noisy and do not exactly correspond to the original pattern.
FLPC : if Turned on, you can see this ability of patterns when their last pivot is formed. If this feature is off, it will see the patterns as soon as they are formed. The advantage of this option being clear is less formation of fielded patterns, and it is accompanied by the lateest pattern seeing and a sharp reduction in reward to risk.
FLPCPeriod : Using this parameter you can determine that the last pivot is based on Pivot period.
Pivot : You need to determine the period of the zigzag indicator. This factor is the most important parameter in pattern recognition.
ABXAmin : Minimum retracement of "AB" line compared to "XA" line.
ABXAmax : Maximum retracement of "AB" line compared to "XA" line.
BCABmin : Minimum retracement of "BC" line compared to "AB" line.
BCABmax : Maximum retracement of "BC" line compared to "AB" line.
CDBCmin : Minimum retracement of "CD" line compared to "BC" line.
CDBCmax : Maximum retracement of "CD" line compared to "BC" line.
CDXAmin : Minimum retracement of "CD" line compared to "XA" line.
CDXAmax : Maximum retracement of "CD" line compared to "XA" line.
🟣 Function Outputs
This library has two outputs. The first output is related to the alert of the formation of a new pattern. And the second output is related to the formation of the candlestick pattern and you can draw it using the "plotshape" tool.
Candle Confirmation Logic :
Example :
import TFlab/Harmonic_Chart_Pattern_Library_TradingFinder/1 as HP
PP = input.int(3, 'ZigZag Pivot Period')
ShowBull = input.bool(true, 'Show Bullish Pattern')
ShowBear = input.bool(true, 'Show Bearish Pattern')
ColorBull = input.color(#0609bb, 'Color Bullish Pattern')
ColorBear = input.color(#0609bb, 'Color Bearish Pattern')
LineWidth = input.int(1 , 'Width Line')
LabelSize = input.string(size.small , 'Label size' , options = )
ShVF = input.bool(false , 'Show Valid Format')
FLPC = input.bool(false , 'Show Formation Last Pivot Confirm')
FLPCPeriod =input.int(2, 'Period of Formation Last Pivot')
//Call function
= HP.XABCD('Bullish Bat', 'Bullish', ShowBull, ColorBull , LineWidth, LabelSize ,ShVF, FLPC, FLPCPeriod, PP, 0.382, 0.50, 0.382, 0.886, 1.618, 2.618, 0.85, 0.9)
= HP.XABCD('Bearish Bat', 'Bearish', ShowBear, ColorBear , LineWidth, LabelSize ,ShVF, FLPC, FLPCPeriod, PP, 0.382, 0.50, 0.382, 0.886, 1.618, 2.618, 0.85, 0.9)
//Alert
if BearAlert
alert('Bearish Harmonic')
if BullAlert
alert('Bulish Harmonic')
//CandleStick Confirm
plotshape(BearCandleConfirm, style = shape.arrowdown, color = color.red)
plotshape(BullCandleConfirm, style = shape.arrowup, color = color.green, location = location.belowbar )
ObjectsLibrary "Objects"
A collection of frequently used objects functions in my scripts.
method getType(this)
Identifies an object's type.
Namespace types: series int, simple int, input int, const int
Parameters:
this (int) : Object to inspect.
Returns: A string representation of the type.
method getType(this)
Namespace types: series float, simple float, input float, const float
Parameters:
this (float)
method getType(this)
Namespace types: series bool, simple bool, input bool, const bool
Parameters:
this (bool)
method getType(this)
Namespace types: series color, simple color, input color, const color
Parameters:
this (color)
method getType(this)
Namespace types: series string, simple string, input string, const string
Parameters:
this (string)
method getType(this)
Namespace types: series line
Parameters:
this (line)
method getType(this)
Namespace types: series linefill
Parameters:
this (linefill)
method getType(this)
Namespace types: series box
Parameters:
this (box)
method getType(this)
Namespace types: series polyline, series polyline, series polyline, series polyline
Parameters:
this (polyline)
method getType(this)
Namespace types: series label
Parameters:
this (label)
method getType(this)
Namespace types: series table
Parameters:
this (table)
method getType(this)
Namespace types: chart.point
Parameters:
this (chart.point)
Dark & Light Theme [TradingFinder] Switching Colors Library🔵 Introduction
One of the challenges of script users is matching the colors used in indicators or strategies. By default, colors are chosen to display based on either the dark theme or the light theme.
In scripts with a large number of colors used, changing all colors to better display in dark mode or light mode can be a difficult and tedious process.
This library provides developers with the ability to adjust the colors used in their scripts based on the theme of the display.
🔵 Logic
To categorize the color spectrum, the range from 0 to 255 of all three main colors red, green and blue was divided into smaller ranges.
Blue color, which is more effective in darkening or lightening colors, is divided into 8 categories, red color into 5 categories, and green color into 3 categories, because it has little effect on darkening or brightening colors.
The combination of these categories creates 120 different modes for the color range, which leads to a more accurate identification of the color and its brightness, and helps to decide how to change it.
Except for these 120 modes, there are 2 other modes that are related to colors almost white or black, which makes a total of 122 modes.
🔵 How to Use
First, you can add the library to your code as shown in the example below.
import TFlab/Dark_Light_Theme_TradingFinder_Switching_Colors_Library/1 as SC
🟣 Parameters
SwitchingColorMode(Color, Mode) =>
Parameters:
Color (color)
Mode (string)
Color : In this parameter, enter the color you want to adjust based on light mode and dark mode.
Mode : Three modes "Off", "Light" and "Dark" are included in this parameter. "Light" mode is for color adjustment for use in "Light Mode".
"Dark" mode is for color adjustment for use in "Dark Mode" and "Off" mode turns off the color adjustment function and the input color to the function is the same as the output color.
🔵 Function Outputs
OriginalColor = input.color(color.red)
= SC.SwitchingColorMode(OriginalColor, Mode)
ComplexLibrary "Complex"
This library includes user-defined complex type, and functions to perform basic arithmetic operations on complex numbers.
real(radius, angle)
Calculates the real part of a complex number based on its polar coordinates.
Parameters:
radius (float)
angle (float)
imag(radius, angle)
Calculates the imaginary part of a complex number based on its polar coordinates.
Parameters:
radius (float)
angle (float)
rds(real, imag)
Calculates the radius of a complex number based on its cartesian coordinates.
Parameters:
real (float)
imag (float)
ang(real, imag)
Calculates the angle of a complex number based on its cartesian coordinates.
Parameters:
real (float)
imag (float)
method realP(c)
Calculates the real part of a complex number represented in polar coordinates.
Namespace types: complex
Parameters:
c (complex) : A complex number expressed in polar coordinates.
method imagP(c)
Calculates the imaginary part of a complex number represented in polar coordinates.
Namespace types: complex
Parameters:
c (complex) : A complex number expressed in polar coordinates.
method rdsC(c)
Calculates the radius of a complex number represented in cartesian coordinates.
Namespace types: complex
Parameters:
c (complex) : A complex number expressed in cartesian coordinates.
method angC(c)
Calculates the angle of a complex number represented in cartesian coordinates.
Namespace types: complex
Parameters:
c (complex) : A complex number expressed in cartesian coordinates.
method toCart(c)
Converts a complex number from its polar representation to cartesian.
Namespace types: complex
Parameters:
c (complex) : A complex number expressed in polar coordinates.
method toPolar(c)
Converts a complex number from its cartesian representation to polar.
Namespace types: complex
Parameters:
c (complex) : A complex number expressed in cartesian coordinates.
method addC(c, z)
Calculates the addition of two complex numbers represented in cartesian coordinates.
Namespace types: complex
Parameters:
c (complex) : First complex number expressed in cartesian coordinates.
z (complex) : Second complex number expressed in cartesian coordinates.
method addP(c, z)
Calculates the addition of two complex numbers represented in polar coordinates. Performing addition and subtraction operations in cartesian form of complex numbers is more efficient.
Namespace types: complex
Parameters:
c (complex) : First complex number expressed in polar coordinates.
z (complex) : Second complex number expressed in polar coordinates.
method subC(c, z)
Calculates the subtraction of two complex numbers represented in cartesian coordinates.
Namespace types: complex
Parameters:
c (complex) : First complex number expressed in cartesian coordinates.
z (complex) : Second complex number expressed in cartesian coordinates.
method subP(c, z)
Calculates the subtraction of two complex numbers represented in polar coordinates.
Namespace types: complex
Parameters:
c (complex) : First complex number expressed in polar coordinates.
z (complex) : Second complex number expressed in polar coordinates.
method multC(c, z)
Calculates the multiplication of two complex numbers represented in cartesian coordinates. Performing multiplication in polar form of complex numbers is more efficient.
Namespace types: complex
Parameters:
c (complex) : First complex number expressed in cartesian coordinates.
z (complex) : Second complex number expressed in cartesian coordinates.
method multP(c, z)
Calculates the multiplication of two complex numbers represented in polar coordinates.
Namespace types: complex
Parameters:
c (complex) : First complex number expressed in polar coordinates.
z (complex) : Second complex number expressed in polar coordinates.
method powC(c, exp, shift)
Exponentiates a complex number represented in cartesian coordinates.
Namespace types: complex
Parameters:
c (complex) : A complex number expressed in cartesian coordinates.
exp (float) : The exponent.
shift (float) : The phase shift of the operation. The shift is equal to 2kπ, where k is an integer number from zero to the denominator of the exponent (exclusive). Calculation of the shift value is not included in the function since it isn't always needed and for the purpose of efficiency. Use a for loop to obtain all possible results.
method powP(c, exp, shift)
Exponentiates a complex number represented in polar coordinates.
Namespace types: complex
Parameters:
c (complex) : A complex number expressed in polar coordinates.
exp (float) : The exponent.
shift (float) : The phase shift of the operation. The shift is equal to 2kπ, where k is an integer number from zero to the denominator of the exponent (exclusive). Calculation of the shift value is not included in the function since it isn't always needed and for the purpose of efficiency. Use a for loop to obtain all possible results.
method invC(c)
Calculates the multiplicative inverse of a complex number represented in cartesian coordinates.
Namespace types: complex
Parameters:
c (complex)
method invP(c)
Calculates the multiplicative inverse of a complex number represented in polar coordinates.
Namespace types: complex
Parameters:
c (complex)
method negC(c)
Negates a complex number represented in cartesian coordinates.
Namespace types: complex
Parameters:
c (complex)
method negP(c)
Negates a complex number represented in polar coordinates.
Namespace types: complex
Parameters:
c (complex)
method con(c)
Calculates the conjugate of a complex number in either forms.
Namespace types: complex
Parameters:
c (complex)
method fAddC(c, d)
Calculates the addition of a complex number represented in cartesian coordinates and a real number.
Namespace types: complex
Parameters:
c (complex) : A complex number expressed in cartesian coordinates.
d (float)
Returns: The complex number resulted by the addition in cartesian form.
method fAddP(c, d)
Calculates the addition of a complex number represented in polar coordinates and a real number.
Namespace types: complex
Parameters:
c (complex) : A complex number expressed in polar coordinates.
d (float)
Returns: The complex number resulted by the addition in polar form.
method fMultC(c, d)
Calculates the multiplication of a complex number represented in cartesian coordinates and a real number.
Namespace types: complex
Parameters:
c (complex) : A complex number expressed in cartesian coordinates.
d (float)
Returns: The complex number resulted by the multiplication in cartesian form.
method fMultP(c, d)
Calculates the multiplication of a complex number represented in polar coordinates and a real number.
Namespace types: complex
Parameters:
c (complex) : A complex number expressed in polar coordinates.
d (float)
Returns: The complex number resulted by the multiplication in polar form.
complex
Complex number expressed in polar or cartesian coordinates.
Fields:
R (series float) : Real part or radius of the complex number.
J (series float) : Imaginary part or angle (phase) of the complex number.
iP (series bool) : This field is employed to keep track of the coordinates of the number. Note that the functions do not verify this field for the purpose of efficiency.
BinaryLibrary "Binary"
This library includes functions to convert between decimal and binary numeral formats, and logical and arithmetic operations on binary numbers.
method toBin(value)
Converts the provided boolean value into binary integers (0 or 1).
Namespace types: series bool, simple bool, input bool, const bool
Parameters:
value (bool) : The boolean value to be converted.
Returns: The converted value in binary integers.
method dec2bin(value, iBits, fBits)
Converts a decimal number into its binary representation.
Namespace types: series float, simple float, input float, const float
Parameters:
value (float) : The decimal number to be converted.
iBits (int) : The number of binary digits allocated for the integer part.
fBits (int) : The number of binary digits allocated for the fractional part.
Returns: An array containing the binary digits for the integer part at the rightmost positions and the digits for the fractional part at the leftmost positions. The array indexes correspond to the bit positions.
method bin2dec(value, iBits, fBits)
Converts a binary number into its decimal representation.
Namespace types: array
Parameters:
value (array) : The binary number to be converted.
iBits (int) : The number of binary digits allocated for the integer part.
fBits (int) : The number of binary digits allocated for the fractional part.
Returns: The converted value in decimal format.
method lgcAnd(a, b)
Bitwise logical AND of two binary numbers. The result of ANDing two binary digits is 1 only if both digits are 1, otherwise, 0.
Namespace types: array
Parameters:
a (array) : First binary number.
b (array) : Second binary number.
Returns: An array containing the logical AND of the inputs.
method lgcOr(a, b)
Bitwise logical OR of two binary numbers. The result of ORing two binary digits is 0 only if both digits are 0, otherwise, 1.
Namespace types: array
Parameters:
a (array) : First binary number.
b (array) : Second binary number.
Returns: An array containing the logical OR of the inputs.
method lgcXor(a, b)
Bitwise logical XOR of two binary numbers. The result of XORing two binary digits is 1 only if ONE of the digits is 1, otherwise, 0.
Namespace types: array
Parameters:
a (array) : First binary number.
b (array) : Second binary number.
Returns: An array containing the logical XOR of the inputs.
method lgcNand(a, b)
Bitwise logical NAND of two binary numbers. The result of NANDing two binary digits is 0 only if both digits are 1, otherwise, 1.
Namespace types: array
Parameters:
a (array) : First binary number.
b (array) : Second binary number.
Returns: An array containing the logical NAND of the inputs.
method lgcNor(a, b)
Bitwise logical NOR of two binary numbers. The result of NORing two binary digits is 1 only if both digits are 0, otherwise, 0.
Namespace types: array
Parameters:
a (array) : First binary number.
b (array) : Second binary number.
Returns: An array containing the logical NOR of the inputs.
method lgcNot(a)
Bitwise logical NOT of a binary number. The result of NOTing a binary digit is 0 if the digit is 1, or vice versa.
Namespace types: array
Parameters:
a (array) : A binary number.
Returns: An array containing the logical NOT of the input.
method lgc2sC(a)
2's complement of a binary number. The 2's complement of a binary number N with n digits is defined as 2^(n) - N.
Namespace types: array
Parameters:
a (array) : A binary number.
Returns: An array containing the 2's complement of the input.
method shift(value, direction, newBit)
Shifts a binary number in the specified direction by one position.
Namespace types: array
Parameters:
value (array)
direction (int) : The direction of the shift operation.
newBit (int) : The bit to be inserted into the unoccupied slot.
Returns: A tuple of the shifted binary number and the serial output of the shift operation.
method multiShift(value, direction, newBits)
Shifts a binary number in the specified direction by multiple positions.
Namespace types: array
Parameters:
value (array)
direction (int) : The direction of the shift operation.
newBits (array)
Returns: A tuple of the shifted binary number and the serial output of the shift operation.
method crclrShift(value, direction, count)
Circularly shifts a binary number in the specified direction by multiple positions. Each ejected bit is inserted from the opposite side.
Namespace types: array
Parameters:
value (array)
direction (int) : The direction of the shift operation.
count (int) : The number of positions to be shifted by.
Returns: The shifted binary number.
method arithmeticShift(value, direction, count)
Performs arithmetic shift on a binary number in the specified direction by multiple positions. Every new bit is 0 if the shift is leftward, otherwise, it equals the sign bit.
Namespace types: array
Parameters:
value (array)
direction (int) : The direction of the shift operation.
count (int) : The number of positions to be shifted by.
Returns: The shifted binary number.
method add(a, b, carry)
Performs arithmetic addition on two binary numbers.
Namespace types: array
Parameters:
a (array) : First binary number.
b (array) : Second binary number.
carry (int) : The input carry of the operation.
Returns: The result of the arithmetic addition of the inputs.
method sub(a, b, carry)
Performs arithmetic subtraction on two binary numbers.
Namespace types: array
Parameters:
a (array) : First binary number.
b (array) : Second binary number. The number to be subtracted.
carry (int) : The input carry of the operation.
Returns: The result of the arithmetic subtraction of the input b from the input a.
ColourUtilitiesLibrary "ColourUtilities"
Utility functions for colour manipulation
adjust_colour(rgb, desaturation_amount, transparency_amount)
to reduce saturation or increase transparency of an RGB colour
Parameters:
rgb (color)
desaturation_amount (float) : 0 means no desaturation (colours remains as-is), and 1 means full desaturation (colour turns grey). Can also be used inversely with negative numbers
transparency_amount (float) : How much more transparent the default transparency should become. E.g. with a value of 0.5, a transparency of 0 becomes 50 and 40 becomes 70. A value of 1 makes it fully transparent, en -1 fully opaque.
Returns: color with adjusted saturation and transparency
method apply_default_palette(self, palette_name)
Some nice looking colour palettes, consisting of 6 gradient colours, are already defined here and can be quickly applied to the Palette class
Namespace types: Palette
Parameters:
self (Palette)
palette_name (string) : Currently there are 4 6-coloured palettes available: "GYTS flux signal", "GYTS purple", "GYTS flux filter" and "GYTS maroon"
Returns: None, as it populates the Palette class with pre-defined colours
method get_colour(self, colour_no, transparency)
Retrieves colour from the palette and possibly changes transparency if set
Namespace types: Palette
Parameters:
self (Palette)
colour_no (int) : from the palette
transparency (int) : to possibly change the default transparency of the palette
Returns: colour
method get_dynamic_colour(self, x, mid_point, colour_lb, colour_ub, trend_lookback, use_rate)
Retrieves a colour based on strength and direction of the passed series
Namespace types: Palette
Parameters:
self (Palette)
x (float) : the input data series
mid_point (float) : value as a cutoff point where the bullish/bearish colour scenario
colour_lb (float) : value (lower bound) where to apply the bearish colour at full strength
colour_ub (float) : value (upper bound) where to apply the bullish colour at full strength
trend_lookback (int) : how much bars back to check if there was a consistent move into a certain direction, otherwise a the neutral colour from the centre of the palette will be used.
use_rate (bool) : whether to use the rate (proportional difference with previous `x` value) or the input series `x` directly
Returns: colour
Palette
Fields:
transparency (series__integer)
palette (array__color)
Order Block Drawing [TradingFinder]🔵 Introduction
Perhaps one of the most challenging tasks for Pine script developers (especially beginners) is properly drawing order blocks. While utilizing the latest technical analysis methods for "Price Action," beginners heavily rely on accurately plotting "Supply" and "Demand" zones, following concepts like "Smart Money Concept" and "ICT".
However, drawing "Order Blocks" may pose a challenge for developers. Therefore, to minimize bugs, increase accuracy, and speed up the process of coding order blocks, we have released the "Order Block Drawing" library.
Below, you can read more details about how to use this library.
Important :
This library has direct and indirect outputs. The indirect output includes the ranges of order blocks plotted on the chart. However, the direct output is a "Boolean" value that becomes "true" only when the price touches an order block, colloquially termed as "Mitigate." You can use this output for setting up alerts.
🔵 How to Use
First, you can add the library to your code as shown in the example below.
import TFlab/OrderBlockDrawing_TradingFinder/1
🟣Parameters
OBDrawing(OBType, TriggerCondition, DistalPrice, ProximalPrice, Index, OBValidDis, Show, ColorZone) =>
Parameters:
• OBType (string)
• TriggerCondition (bool)
• DistalPrice (float)
• ProximalPrice (float)
• Index (int)
• OBValidDis (int)
• Show (bool)
• ColorZone (color)
OBType : All order blocks are summarized into two types: "Supply" and "Demand." You should input your order block type in this parameter. Enter "Demand" for drawing demand zones and "Supply" for drawing supply zones.
TriggerCondition : Input the condition under which you want the order block to be drawn in this parameter.
DistalPrice : Generally, if each zone is formed by two lines, the farthest line from the price is termed "Distal." This input receives the price of the "Distal" line.
ProximalPrice : Generally, if each zone is formed by two lines, the nearest line to the price is termed "Proximal" line.
Index : This input receives the value of the "bar_index" at the beginning of the order block. You should store the "bar_index" value at the occurrence of the condition for the order block to be drawn and input it here.
OBValidDis : Order blocks continue to be drawn until a new order block is drawn or the order block is "Mitigate." You can specify how many candles after their initiation order blocks should continue. If you want no limitation, enter the number 4998.
Show : You may need to manage whether to display or hide order blocks. When this input is "On", order blocks are displayed, and when it's "Off", order blocks are not displayed.
ColorZone : You can input your preferred color for drawing order blocks.
🔵 Function Outputs
This function has only one output. This output is of type "Boolean" and becomes "true" only when the price touches an order block. Each order block can be touched only once and then loses its validity. You can use this output for alerts.
= Drawing.OBDrawing('Demand', Condition, Distal, Proximal, Index, 4998, true, Color)
MarkdownUtilsLibrary "MarkdownUtils"
This library shows all of CommonMark's formatting elements that are currently (2024-03-30)
available in Pine Script® and gives some hints on how to use them.
The documentation will be in the tooltip of each of the following functions. It is also
logged into Pine Logs by default if it is called. We can disable the logging by setting `pLog = false`.
mediumMathematicalSpace()
Medium mathematical space that can be used in e.g. the library names like `Markdown Utils`.
Returns: The medium mathematical space character U+205F between those double quotes " ".
zeroWidthSpace()
Zero-width space.
Returns: The zero-width character U+200B between those double quotes "".
stableSpace(pCount)
Consecutive space characters in Pine Script® are replaced by a single space character on output.
Therefore we require a "stable" space to properly indent text e.g. in Pine Logs. To use it in code blocks
of a description like this one, we have to copy the 2(!) characters between the following reverse brackets instead:
# > <
Those are the zero-width character U+200B and a space.
Of course, this can also be used within a text to add some extra spaces.
Parameters:
pCount (simple int)
Returns: A zero-width space combined with a space character.
headers(pLog)
Headers
```
# H1
## H2
### H3
#### H4
##### H5
###### H6
```
*results in*
# H1
## H2
### H3
#### H4
##### H5
###### H6
*Best practices*: Add blank line before and after each header.
Parameters:
pLog (bool)
paragrahps(pLog)
Paragraphs
```
First paragraph
Second paragraph
```
*results in*
First paragraph
Second paragraph
Parameters:
pLog (bool)
lineBreaks(pLog)
Line breaks
```
First row
Second row
```
*results in*
First row\
Second row
Parameters:
pLog (bool)
emphasis(pLog)
Emphasis
With surrounding `*` and `~` we can emphasize text as follows. All emphasis can be arbitrarily combined.
```
*Italics*, **Bold**, ***Bold italics***, ~~Scratch~~
```
*results in*
*Italics*, **Bold**, ***Bold italics***, ~~Scratch~~
Parameters:
pLog (bool)
blockquotes(pLog)
Blockquotes
Lines starting with at least one `>` followed by a space and text build block quotes.
```
Text before blockquotes.
> 1st main blockquote
>
> 1st main blockquote
>
>> 1st 1-nested blockquote
>
>>> 1st 2-nested blockquote
>
>>>> 1st 3-nested blockquote
>
>>>>> 1st 4-nested blockquote
>
>>>>>> 1st 5-nested blockquote
>
>>>>>>> 1st 6-nested blockquote
>
>>>>>>>> 1st 7-nested blockquote
>
> 2nd main blockquote, 1st paragraph, 1st row\
> 2nd main blockquote, 1st paragraph, 2nd row
>
> 2nd main blockquote, 2nd paragraph, 1st row\
> 2nd main blockquote, 2nd paragraph, 2nd row
>
>> 2nd nested blockquote, 1st paragraph, 1st row\
>> 2nd nested blockquote, 1st paragraph, 2nd row
>
>> 2nd nested blockquote, 2nd paragraph, 1st row\
>> 2nd nested blockquote, 2nd paragraph, 2nd row
Text after blockquotes.
```
*results in*
Text before blockquotes.
> 1st main blockquote
>
>> 1st 1-nested blockquote
>
>>> 1st 2-nested blockquote
>
>>>> 1st 3-nested blockquote
>
>>>>> 1st 4-nested blockquote
>
>>>>>> 1st 5-nested blockquote
>
>>>>>>> 1st 6-nested blockquote
>
>>>>>>>> 1st 7-nested blockquote
>
> 2nd main blockquote, 1st paragraph, 1st row\
> 2nd main blockquote, 1st paragraph, 2nd row
>
> 2nd main blockquote, 2nd paragraph, 1st row\
> 2nd main blockquote, 2nd paragraph, 2nd row
>
>> 2nd nested blockquote, 1st paragraph, 1st row\
>> 2nd nested blockquote, 1st paragraph, 2nd row
>
>> 2nd nested blockquote, 2nd paragraph, 1st row\
>> 2nd nested blockquote, 2nd paragraph, 2nd row
Text after blockquotes.
*Best practices*: Add blank line before and after each (nested) blockquote.
Parameters:
pLog (bool)
lists(pLog)
Paragraphs
#### Ordered lists
The first line starting with a number combined with a delimiter `.` or `)` starts an ordered
list. The list's numbering starts with the given number. All following lines that also start
with whatever number and the same delimiter add items to the list.
#### Unordered lists
A line starting with a `-`, `*` or `+` becomes an unordered list item. All consecutive items with
the same start symbol build a separate list. Therefore every list can only have a single symbol.
#### General information
To start a new list either use the other delimiter or add some non-list text between.
List items in Pine Script® allow line breaks but cannot have paragraphs or blockquotes.
Lists Pine Script® cannot be nested.
```
1) 1st list, 1st item, 1st row\
1st list, 1st item, 2nd row
1) 1st list, 2nd item, 1st row\
1st list, 2nd item, 2nd row
1) 1st list, 2nd item, 1st row\
1st list, 2nd item, 2nd row
1. 2nd list, 1st item, 1st row\
2nd list, 1st item, 2nd row
Intermediary text.
1. 3rd list
Intermediary text (sorry, unfortunately without proper spacing).
8. 4th list, 8th item
8. 4th list, 9th item
Intermediary text.
- 1st list, 1st item
- 1st list, 2nd item
* 2nd list, 1st item
* 2nd list, 2nd item
Intermediary text.
+ 3rd list, 1st item
+ 3rd list, 2nd item
```
*results in*
1) 1st list, 1st item, 1st row\
1st list, 1st item, 2nd row
1) 1st list, 2nd item, 1st row\
1st list, 2nd item, 2nd row
1) 1st list, 2nd item, 1st row\
1st list, 2nd item, 2nd row
1. 2nd list, 1st item, 1st row\
2nd list, 1st item, 2nd row
Intermediary text.
1. 3rd list
Intermediary text (sorry, unfortunately without proper spacing).
8. 4th list, 8th item
8. 4th list, 9th item
Intermediary text.
- 1st list, 1st item
- 1st list, 2nd item
* 2nd list, 1st item
* 2nd list, 2nd item
Intermediary text.
+ 3rd list, 1st item
+ 3rd list, 2nd item
Parameters:
pLog (bool)
code(pLog)
### Code
`` `Inline code` `` is formatted like this.
To write above line we wrote `` `` `Inline code` `` ``.
And to write that line we added another pair of `` `` `` around that code and
a zero-width space of function between the inner `` `` ``.
### Code blocks
can be formatted like that:
~~~
```
export method codeBlock() =>
"code block"
```
~~~
Or like that:
```
~~~
export method codeBlock() =>
"code block"
~~~
```
To write ````` within a code block we can either surround it with `~~~`.
Or we "escape" those ````` by only the zero-width space of function (stableSpace) in between.
To escape \` within a text we use `` \` ``.
Parameters:
pLog (bool)
horizontalRules(pLog)
Horizontal rules
At least three connected `*`, `-` or `_` in a separate line build a horizontal rule.
```
Intermediary text.
---
Intermediary text.
***
Intermediary text.
___
Intermediary text.
```
*results in*
Intermediary text.
---
Intermediary text.
***
Intermediary text.
___
Intermediary text.
*Best practices*: Add blank line before and after each horizontal rule.
Parameters:
pLog (bool)
tables(pLog)
Tables
A table consists of a single header line with columns separated by `|`
and followed by a row of alignment indicators for either left (`---`, `:---`), centered (`:---:`) and right (`---:`)
A table can contain several rows of data.
The table can be written as follows but hasn't to be formatte like that. By adding (stableSpace)
on the correct side of the header we could even adjust the spacing if we don't like it as it is. Only around
the column separator we should only use a usual space on each side.
```
Header 1 | Header 1 | Header 2 | Header 3
--- | :--- | :----: | ---:
Left (Default) | Left | Centered | Right
Left (Default) | Left | Centered | Right
```
*results in*
Header 1 | Header 1 | Header 2 | Header 3
--- | :--- | :----: | ---:
Left (Default) | Left | Centered | Right
Left (Default) | Left | Centered | Right
Parameters:
pLog (bool)
links(pLog)
## Links.
### Inline-style
` (Here should be the link to the TradingView homepage)`\
results in (Here should be the link to the TradingView homepage)
` (Here should be the link to the TradingView homepage "Trading View tooltip")`\
results in (Here should be the link to the TradingView homepage "Trading View tooltip")
### Reference-style
One can also collect all links e.g. at the end of a description and use a reference to that as follows.
` `\
results in .
` `\
results in .
` `\
results in .
` (../tradingview/scripts/readme)`\
results in (../tradingview/scripts/readme).
### URLs and email
URLs are also identified by the protocol identifier, email addresses by `@`. They can also be surrounded by `<` and `>`.
Input | Result
--- | ---
`Here should be the link to the TradingView homepage` | Here should be the link to the TradingView homepage
`` |
`support@tradingview.com` | support@tradingview.com
`` |
## Images
We can display gif, jp(e)g and png files in our documentation, if we add `!` before a link.
### Inline-style:
`! (Here should be the link to the favicon of the TradingView homepage "Trading View icon")`
results in
! (Here should be the link to the favicon of the TradingView homepage "Trading View icon")\
### Reference-style:
`! `
results in
!
## References for reference-style links
Even though only the formatted references are visible here in the output, this text is also followed
by the following references with links in the style
` : Referenced link`
```
: Here should be the link to the TradingView homepage "Trading view text-reference tooltip"
: Here should be the link to the TradingView homepage "Trading view number-reference tooltip"
: Here should be the link to the TradingView homepage "Trading view self-reference tooltip"
: Here should be the link to the favicon of the TradingView homepage "Trading View icon (reference)"
```
: Here should be the link to the TradingView homepage "Trading view text-reference tooltip"
: Here should be the link to the TradingView homepage "Trading view number-reference tooltip"
: Here should be the link to the TradingView homepage "Trading view self-reference tooltip"
: Here should be the link to the favicon of the TradingView homepage "Trading View icon (reference)"
Parameters:
pLog (bool)
taskLists(pLog)
Task lists.
Other Markdown implementations can also display task lists for list items like `- ` respective `- `.
This can only be simulated by inline code `` ´ ` ``.
Make sure to either add a line-break `\` at the end of the line or a new paragraph by a blank line.
### Task lists
` ` Finish library
` ` Finish library
Parameters:
pLog (bool)
escapeMd(pLog)
Escaping Markdown syntax
To write and display Markdown syntax in regular text, we have to escape it. This can be done
by adding `\` before the Markdown syntax. If the Markdown syntax consists of more than one character
in some cases also the character of function can be helpful if a command consists of
more than one character if it is placed between the separate characters of the command.
Parameters:
pLog (bool)
test()
Calls all functions of above script.
Alert Sender Library [TradingFinder]Library "AlertSenderLibrary_TradingFinder"
🔵 Introduction
The "Alert Sender Library" is a management and production program for "Alert Messages" that enables the creation of unique messages for any type of signal generated by indicators or strategies.
These messages include the direction of the signal, symbol, time frame, the date and time the condition was triggered, prices related to the signal, and a personal message from you. To make better and more optimal use of this "library", you should carefully study " Key Features" and "How to Use".
🔵 Key Features
Automatic Detection of Appropriate Type :
Using two parameters, "AlertType" and "DetectionType", which you must enter at the beginning into the "AlertSender" function, the type of the alert message is determined.
For example, if you select one of the "DetectionType"s such as "Order Block Signal", "Signal", and "Setup", your alert type will be chosen based on "Long" and "Short". Whether it's "Long" or "Short" depends on the "AlertType" you have set to either "Bullish" or "Bearish".
Automatic Symbol Detection :
Whenever you add an alert for a specific symbol, if you want the name of that symbol to be in your message text, you must manually write the name of the symbol in your message. One of the capabilities of the "Alert Sender" is the automatic detection of the symbol and adding it to the message text.
Automatic Time Frame Detection :
When adding your alert, the "Alert Sender" detects the time frame of the symbol you intend to add the alert for and adds it to the text. This feature is very practical and can prevent traders from making mistakes.
For example, a trader might add alerts for a specific symbol using a specific indicator in different time frames, taking the main signal in the 1-hour time frame and only a confirmation signal in the 15-minute time frame. This feature helps to identify in which time frame the signal is set.
Detection of Date and Time When the Signal is Triggered :
You can have the date and time at the moment the message is sent. This feature has various uses. For example, if you use the Webhook URL feature to send messages to a Telegram channel, there might be issues with alert delivery on your server, causing delays, and you might receive the message when it has lost its validity.
With this feature, you can match the sending time of the message from TradingView with the receipt time in your messenger and detect if there is a delay in message delivery.
Important :
You can also set the Time Zone you wish to receive the date and time based on.
Display of "Key Prices" :
Key prices can vary based on the type of signals. For example, when the "DetectionType" is in "Order Block Signal" mode, the key prices are the "Distal" and "Proximal" prices. Or if the "DetectionType" is in "Setup" mode, the key prices are "Entry", "Stop Loss", and "Take Profit".
Receipt of Personal "Messages" :
You can enter your personal message using "input.string" or "input.text_area" in addition to the messages that are automatically created.
Beautiful and Functional Display of Messages :
The titles of messages sent by "AlertSender" are displayed using related emojis to prevent mistakes due to visual errors, enhancing beauty.
🔵 How to Use
🟣 Familiarity with Function and Parameters
AlertSender(Condition, Alert, AlertName, AlertType, DetectionType, SetupData, Frequency, UTC, MoreInfo, Message, o, h, l, c, Entry, TP, SL, Distal, Proximal)
Parameters:
- Condition (bool)
- Alert (string)
- AlertName (string)
- AlertType (string)
- DetectionType (string)
- SetupData (string)
- Frequency (string)
- UTC (string)
- MoreInfo (string)
- Message (string)
- o (float)
- h (float)
- l (float)
- c (float)
- Entry (float)
- TP (float)
- SL (float)
- Distal (float)
- Proximal (float)
To add "Alert Sender Library", you must first add the following code to your script.
import TFlab/AlertSenderLibrary_TradingFinder/1
🟣 Parameters
"Condition" : This parameter is a Boolean. You need to set it based on the condition that, when met (or fired), you want to receive an alert. The output should be either "true" or "false".
"Alert" : This parameter accepts one of two inputs, "On" or "Off". If set to "On", the alarm is active; if "Off", the alarm is deactivated. This input is useful when you have numerous alerts in an indicator or strategy and need to activate only a few of them. "Alert" is a string parameter.
Alert = input.string('On', 'Alert', , 'If you turn on the Alert, you can receive alerts and notifications after setting the "Alert".', group = 'Alert')
"AlertName" : This is a string parameter where you can enter the name you choose for your alert.
AlertName = input.string('Order Blocks Finder ', 'Alert Name', group = 'Alert')
"AlertType" : The inputs for this parameter are "Bullish" or "Bearish". If the condition selected in the "Condition" parameter is of a bullish bias, you should set this parameter to "Bullish", and if the condition is of a bearish bias, it should be set to "Bearish". "AlertType" is a string parameter.
"DetectionType" : This parameter's predefined inputs include "Order Block Signal", "Signal", "Setup", and "Analysis". You may provide other inputs, but some functionalities, like "Key Price", might be lost. "DetectionType" is a string parameter.
"SetupData" :
If "DetectionType" is set to "Setup", you must specify "SetupData" as either "Basic" or "Full". In "Basic" mode, only the "Entry" price needs to be defined in the function, and "TP" (Take Profit) and "SL" (Stop Loss) can be any number or NA. In "Full" mode, you need to define "Entry", "SL", and "TP". "Setup" is a string parameter.
"Frequency" : This string parameter defines the announcement frequency. Choices include: "All" (activates the alert every time the function is called), "Once Per Bar" (activates the alert only on the first call within the bar), and "Once Per Bar Close" (the alert is activated only by a call at the last script execution of the real-time bar upon closing). The default setting is "Once per Bar".
Frequency = input.string('Once Per Bar', 'Message Frequency', , 'The triggering frequency. Possible values are: All (all function calls trigger the alert), Once Per Bar (the first function call during the bar triggers the alert), Per Bar Close (the function call triggers the alert only when it occurs during the last script iteration of the real-time bar, when it closes). The default is alert.freq_once_per_bar.', group = 'Alert')
"UTC" : With this parameter, you can set the Time Zone for the date and time of the alert's dispatch. "UTC" is a string parameter and can be set as "UTC-4", "UTC+1", "UTC+9", or any other Time Zone.
UTC = input.string('UTC', 'Show Alert time by Time Zone', group = 'Alert')
"MoreInfo" : This parameter can take one of two inputs, "On" or "Off", which are strings. Additional information, including "Time" and "Key Price", is included. If set to "On", this information is received; if "Off", it is not displayed in the sent message.
MoreInfo = input.string('On', 'Display More Info', , group = 'Alert')
"Message" : This parameter captures the user's personal message through an input and displays it at the end of the sent message. It is a string input.
MessageBull = input.text_area('Long Position', 'Long Signal Message', group = 'Alert') MessageBear = input.text_area('Short Position', 'Short Signal Message', group = 'Alert')
"o" (Open Price): A floating-point number representing the opening price of the candle. This input is necessary when the "DetectionType" is set to "Signal". Otherwise, it can be any number or "na".
"h" (High Price): A float variable for the highest price of the candle. Required when "DetectionType" is "Signal"; in other cases, any number or "na" is acceptable.
"l" (Low Price): A float representing the lowest price of the candle. This field must be filled if "DetectionType" is "Signal". If not, it can be any number or "na".
"c" (Close Price): A floating-point variable indicating the closing price of the candle. Needed for "Signal" type detections; otherwise, it can take any value or "na".
"Entry" : A float variable indicating the entry price into a trading setup. This is relevant when "DetectionType" is in "Setup" mode. In other scenarios, it can be any number or "na". It denotes the price at which the trade setup is entered.
"TP" (Take Profit): A float that is necessary when "DetectionType" is "Setup" and "SetupData" is "Full". Otherwise, it can be any number or "na". It signifies the price target for taking profits in a trading setup.
"SL" (Stop Loss): A float required when "DetectionType" is "Setup" and "SetupData" is "Full". It can be any number or "na" in other cases. This value represents the price at which a stop loss is set to limit losses.
"Distal" : A float important for "Order Block Signal" detection. It can be any number or "na" if not in use. This variable indicates the price reaching the distal line of an order block.
"Proximal" : A float needed for "Order Block Signal" detection mode. It can take any value or "na" otherwise. It marks the price reaching the proximal line of an order block.
commonThe "Pineify/common" library presents a specialized toolkit crafted to empower traders and script developers with state-of-the-art time manipulation functions on the TradingView platform. It is instead a foundational utility aimed at enriching your script's ability to process and interpret time-based data with unparalleled precision.
Key Features
String Splitter:
The 'str_split_into_two' function is a universal string handler that separates any given input into two distinct strings based on a specified delimiter. This function is especially useful in parsing time strings or any scenario where a string needs to be divided into logical parts efficiently.
Example:
= str_split_into_two("a:b", ":")
// a = "a"
// b = "b"
Time Parser:
With 'time_to_hour_minute', users can effortlessly convert a time string into numerical hours and minutes. This function is pivotal for those who need to exact specific time series data or wish to schedule their trades down to the minute.
Example:
= time_to_hour_minute("02:30")
// time_hour = 2
// time_minute = 30
Unix Time Converter
The 'time_range_to_unix_time' function transcends traditional boundaries by converting a given time range into Unix timestamp format. This integration of date, time, and timezone, accounts for a comprehensive approach, allowing scripts to make timed decisions, perform historical analyses, and account for international markets across different time zones.
Example:
// Support 'hhmm-hhmm' and 'hh:mm-hh:mm'
= time_range_to_unix_time("09:30-12:00")
Summary:
Each function is meticulously designed to minimize complexity and maximize versatility. Whether you are a programmer seeking to streamline your code, or a trader requiring precise timing for your strategies, our library provides the logical framework that aligns with your needs.
The "Pineify/common" library is the bridge between high-level time concepts and actionable trading insights. It serves a multitude of purposes – from crafting elegant time-based triggers to dissecting complex string data. Embrace the power of precision with "Pineify/common" and elevate your TradingView scripting experience to new heights.
TableLibrary "Table"
This library provides an easy way to convert arrays and matrixes of data into tables. There are a few different implementations of each function so you can get more or less control over the appearance of the tables. The basic rule of thumb is that all matrix rows must have the same number of columns, and if you are providing multiple arrays/matrixes to specify additional colors (background/text), they must have the same number of rows/columns as the data array. Finally, you do have the option of spanning cells across rows or columns with some special syntax in the data cell. Look at the examples to see how the arrays and matrixes need to be built before they can be used by the functions.
floatArrayToCellArray(floatArray)
Helper function that converts a float array to a Cell array so it can be rendered with the fromArray function
Parameters:
floatArray (float ) : (array) the float array to convert to a Cell array.
Returns: array The Cell array to return.
stringArrayToCellArray(stringArray)
Helper function that converts a string array to a Cell array so it can be rendered with the fromArray function
Parameters:
stringArray (string ) : (array) the array to convert to a Cell array.
Returns: array The Cell array to return.
floatMatrixToCellMatrix(floatMatrix)
Helper function that converts a float matrix to a Cell matrix so it can be rendered with the fromMatrix function
Parameters:
floatMatrix (matrix) : (matrix) the float matrix to convert to a string matrix.
Returns: matrix The Cell matrix to render.
stringMatrixToCellMatrix(stringMatrix)
Helper function that converts a string matrix to a Cell matrix so it can be rendered with the fromMatrix function
Parameters:
stringMatrix (matrix) : (matrix) the string matrix to convert to a Cell matrix.
Returns: matrix The Cell matrix to return.
fromMatrix(CellMatrix, position, verticalOffset, transposeTable, textSize, borderWidth, tableNumRows, blankCellText)
Takes a CellMatrix and renders it as a table.
Parameters:
CellMatrix (matrix) : (matrix) The Cells to be rendered in a table
position (string) : (string) Optional. The position of the table. Defaults to position.top_right
verticalOffset (int) : (int) Optional. The vertical offset of the table from the top or bottom of the chart. Defaults to 0.
transposeTable (bool) : (bool) Optional. Will transpose all of the data in the matrices before rendering. Defaults to false.
textSize (string) : (string) Optional. The size of text to render in the table. Defaults to size.small.
borderWidth (int) : (int) Optional. The width of the border between table cells. Defaults to 2.
tableNumRows (int) : (int) Optional. The number of rows in the table. Not required, defaults to the number of rows in the provided matrix. If your matrix will have a variable number of rows, you must provide the max number of rows or the function will error when it attempts to set a cell value on a row that the table hadn't accounted for when it was defined.
blankCellText (string) : (string) Optional. Text to use cells when adding blank rows for vertical offsetting.
fromMatrix(dataMatrix, position, verticalOffset, transposeTable, textSize, borderWidth, tableNumRows, blankCellText)
Renders a float matrix as a table.
Parameters:
dataMatrix (matrix) : (matrix_float) The data to be rendered in a table
position (string) : (string) Optional. The position of the table. Defaults to position.top_right
verticalOffset (int) : (int) Optional. The vertical offset of the table from the top or bottom of the chart. Defaults to 0.
transposeTable (bool) : (bool) Optional. Will transpose all of the data in the matrices before rendering. Defaults to false.
textSize (string) : (string) Optional. The size of text to render in the table. Defaults to size.small.
borderWidth (int) : (int) Optional. The width of the border between table cells. Defaults to 2.
tableNumRows (int) : (int) Optional. The number of rows in the table. Not required, defaults to the number of rows in the provided matrix. If your matrix will have a variable number of rows, you must provide the max number of rows or the function will error when it attempts to set a cell value on a row that the table hadn't accounted for when it was defined.
blankCellText (string) : (string) Optional. Text to use cells when adding blank rows for vertical offsetting.
fromMatrix(dataMatrix, position, verticalOffset, transposeTable, textSize, borderWidth, tableNumRows, blankCellText)
Renders a string matrix as a table.
Parameters:
dataMatrix (matrix) : (matrix_string) The data to be rendered in a table
position (string) : (string) Optional. The position of the table. Defaults to position.top_right
verticalOffset (int) : (int) Optional. The vertical offset of the table from the top or bottom of the chart. Defaults to 0.
transposeTable (bool) : (bool) Optional. Will transpose all of the data in the matrices before rendering. Defaults to false.
textSize (string) : (string) Optional. The size of text to render in the table. Defaults to size.small.
borderWidth (int) : (int) Optional. The width of the border between table cells. Defaults to 2.
tableNumRows (int) : (int) Optional. The number of rows in the table. Not required, defaults to the number of rows in the provided matrix. If your matrix will have a variable number of rows, you must provide the max number of rows or the function will error when it attempts to set a cell value on a row that the table hadn't accounted for when it was defined.
blankCellText (string) : (string) Optional. Text to use cells when adding blank rows for vertical offsetting.
fromArray(dataArray, position, verticalOffset, transposeTable, textSize, borderWidth, blankCellText)
Renders a Cell array as a table.
Parameters:
dataArray (Cell ) : (array) The data to be rendered in a table
position (string) : (string) Optional. The position of the table. Defaults to position.top_right
verticalOffset (int) : (int) Optional. The vertical offset of the table from the top or bottom of the chart. Defaults to 0.
transposeTable (bool) : (bool) Optional. Will transpose all of the data in the matrices before rendering. Defaults to false.
textSize (string) : (string) Optional. The size of text to render in the table. Defaults to size.small.
borderWidth (int) : (int) Optional. The width of the border between table cells. Defaults to 2.
blankCellText (string) : (string) Optional. Text to use cells when adding blank rows for vertical offsetting.
fromArray(dataArray, position, verticalOffset, transposeTable, textSize, borderWidth, blankCellText)
Renders a string array as a table.
Parameters:
dataArray (string ) : (array_string) The data to be rendered in a table
position (string) : (string) Optional. The position of the table. Defaults to position.top_right
verticalOffset (int) : (int) Optional. The vertical offset of the table from the top or bottom of the chart. Defaults to 0.
transposeTable (bool) : (bool) Optional. Will transpose all of the data in the matrices before rendering. Defaults to false.
textSize (string) : (string) Optional. The size of text to render in the table. Defaults to size.small.
borderWidth (int) : (int) Optional. The width of the border between table cells. Defaults to 2.
blankCellText (string) : (string) Optional. Text to use cells when adding blank rows for vertical offsetting.
fromArray(dataArray, position, verticalOffset, transposeTable, textSize, borderWidth, blankCellText)
Renders a float array as a table.
Parameters:
dataArray (float ) : (array_float) The data to be rendered in a table
position (string) : (string) Optional. The position of the table. Defaults to position.top_right
verticalOffset (int) : (int) Optional. The vertical offset of the table from the top or bottom of the chart. Defaults to 0.
transposeTable (bool) : (bool) Optional. Will transpose all of the data in the matrices before rendering. Defaults to false.
textSize (string) : (string) Optional. The size of text to render in the table. Defaults to size.small.
borderWidth (int) : (int) Optional. The width of the border between table cells. Defaults to 2.
blankCellText (string) : (string) Optional. Text to use cells when adding blank rows for vertical offsetting.
debug(message, position)
Renders a debug message in a table at the desired location on screen.
Parameters:
message (string) : (string) The message to render.
position (string) : (string) Optional. The position of the debug message. Defaults to position.middle_right.
Cell
Type for each cell's content and appearance
Fields:
content (series string)
bgColor (series color)
textColor (series color)
align (series string)
colspan (series int)
rowspan (series int)