lib_drawing_compositesLibrary "lib_drawing_composites"
methods to draw and manage composite obejects. Based on Trendoscope's added Triangle and Polygon composite objects, fixed tostring method output to be actual json
method tostring(this, format_date, format, tz, pretty)
Converts lib_drawing_types/LineProperties object to a json string representation
Namespace types: D.Point
Parameters:
this (Point type from HeWhoMustNotBeNamed/DrawingTypes/2) : lib_drawing_types/LineProperties object
format_date (simple bool)
format (simple string)
tz (simple string)
pretty (simple bool) : if true adds a line feed after every property and a space before properties (default: true)
Returns: string representation of lib_drawing_types/LineProperties
method tostring(this, pretty)
Converts lib_drawing_types/LabelProperties object to a json string representation
Namespace types: D.LineProperties
Parameters:
this (LineProperties type from HeWhoMustNotBeNamed/DrawingTypes/2) : lib_drawing_types/LabelProperties object
pretty (simple bool) : if true adds a line feed after every property and a space before properties (default: true)
Returns: string representation of lib_drawing_types/LabelProperties
method tostring(this, format_date, format, tz, pretty)
Converts lib_drawing_types/BoxProperties object to a json string representation
Namespace types: D.Line
Parameters:
this (Line type from HeWhoMustNotBeNamed/DrawingTypes/2) : lib_drawing_types/BoxProperties object
format_date (simple bool)
format (simple string)
tz (simple string)
pretty (simple bool) : if true adds a line feed after every property and a space before properties (default: true)
Returns: string representation of lib_drawing_types/BoxProperties
method tostring(this, pretty)
Converts lib_drawing_types/BoxText object to a json string representation
Namespace types: D.LabelProperties
Parameters:
this (LabelProperties type from HeWhoMustNotBeNamed/DrawingTypes/2) : lib_drawing_types/BoxText object
pretty (simple bool) : if true adds a line feed after every property and a space before properties (default: true)
Returns: string representation of lib_drawing_types/BoxText
method tostring(this, format_date, format, tz, pretty)
Converts lib_drawing_types/TriangleProperties object to a json string representation
Namespace types: D.Label
Parameters:
this (Label type from HeWhoMustNotBeNamed/DrawingTypes/2) : lib_drawing_types/TriangleProperties object
format_date (simple bool)
format (simple string)
tz (simple string)
pretty (simple bool) : if true adds a line feed after every property and a space before properties (default: true)
Returns: string representation of lib_drawing_types/TriangleProperties
method tostring(this, format_date, format, tz, pretty)
Namespace types: D.Linefill
Parameters:
this (Linefill type from HeWhoMustNotBeNamed/DrawingTypes/2)
format_date (simple bool)
format (simple string)
tz (simple string)
pretty (simple bool)
method tostring(this, pretty)
Namespace types: D.BoxProperties
Parameters:
this (BoxProperties type from HeWhoMustNotBeNamed/DrawingTypes/2)
pretty (simple bool)
method tostring(this, pretty)
Namespace types: D.BoxText
Parameters:
this (BoxText type from HeWhoMustNotBeNamed/DrawingTypes/2)
pretty (simple bool)
method tostring(this, format_date, format, tz, pretty)
Namespace types: D.Box
Parameters:
this (Box type from HeWhoMustNotBeNamed/DrawingTypes/2)
format_date (simple bool)
format (simple string)
tz (simple string)
pretty (simple bool)
method tostring(this, pretty)
Namespace types: DC.TriangleProperties
Parameters:
this (TriangleProperties type from robbatt/lib_drawing_composite_types/1)
pretty (simple bool)
method tostring(this, format_date, format, tz, pretty)
Namespace types: DC.Triangle
Parameters:
this (Triangle type from robbatt/lib_drawing_composite_types/1)
format_date (simple bool)
format (simple string)
tz (simple string)
pretty (simple bool)
method tostring(this, format_date, format, tz, pretty)
Namespace types: DC.Trianglefill
Parameters:
this (Trianglefill type from robbatt/lib_drawing_composite_types/1)
format_date (simple bool)
format (simple string)
tz (simple string)
pretty (simple bool)
method tostring(this, format_date, format, tz, pretty)
Namespace types: DC.Polygon
Parameters:
this (Polygon type from robbatt/lib_drawing_composite_types/1)
format_date (simple bool)
format (simple string)
tz (simple string)
pretty (simple bool)
method tostring(this, format_date, format, tz, pretty)
Namespace types: DC.Polygonfill
Parameters:
this (Polygonfill type from robbatt/lib_drawing_composite_types/1)
format_date (simple bool)
format (simple string)
tz (simple string)
pretty (simple bool)
method delete(this)
Namespace types: DC.Trianglefill
Parameters:
this (Trianglefill type from robbatt/lib_drawing_composite_types/1)
method delete(this)
Namespace types: DC.Triangle
Parameters:
this (Triangle type from robbatt/lib_drawing_composite_types/1)
method delete(this)
Namespace types: DC.Triangle
Parameters:
this (Triangle type from robbatt/lib_drawing_composite_types/1)
method delete(this)
Namespace types: DC.Trianglefill
Parameters:
this (Trianglefill type from robbatt/lib_drawing_composite_types/1)
method delete(this)
Namespace types: DC.Polygon
Parameters:
this (Polygon type from robbatt/lib_drawing_composite_types/1)
method delete(this)
Namespace types: DC.Polygonfill
Parameters:
this (Polygonfill type from robbatt/lib_drawing_composite_types/1)
method delete(this)
Namespace types: DC.Polygon
Parameters:
this (Polygon type from robbatt/lib_drawing_composite_types/1)
method delete(this)
Namespace types: DC.Polygonfill
Parameters:
this (Polygonfill type from robbatt/lib_drawing_composite_types/1)
method clear(this)
Namespace types: DC.Triangle
Parameters:
this (Triangle type from robbatt/lib_drawing_composite_types/1)
method clear(this)
Namespace types: DC.Trianglefill
Parameters:
this (Trianglefill type from robbatt/lib_drawing_composite_types/1)
method clear(this)
Namespace types: DC.Polygon
Parameters:
this (Polygon type from robbatt/lib_drawing_composite_types/1)
method clear(this)
Namespace types: DC.Polygonfill
Parameters:
this (Polygonfill type from robbatt/lib_drawing_composite_types/1)
method draw(this, is_polygon_section)
Namespace types: DC.Triangle
Parameters:
this (Triangle type from robbatt/lib_drawing_composite_types/1)
is_polygon_section (bool)
method draw(this)
Namespace types: DC.Trianglefill
Parameters:
this (Trianglefill type from robbatt/lib_drawing_composite_types/1)
method draw(this, is_polygon)
Namespace types: DC.Triangle
Parameters:
this (Triangle type from robbatt/lib_drawing_composite_types/1)
is_polygon (bool)
method draw(this)
Namespace types: DC.Polygon
Parameters:
this (Polygon type from robbatt/lib_drawing_composite_types/1)
method draw(this)
Namespace types: DC.Trianglefill
Parameters:
this (Trianglefill type from robbatt/lib_drawing_composite_types/1)
method draw(this)
Namespace types: DC.Polygonfill
Parameters:
this (Polygonfill type from robbatt/lib_drawing_composite_types/1)
method draw(this)
Namespace types: DC.Polygon
Parameters:
this (Polygon type from robbatt/lib_drawing_composite_types/1)
method draw(this)
Namespace types: DC.Polygonfill
Parameters:
this (Polygonfill type from robbatt/lib_drawing_composite_types/1)
method createCenter(this, other)
Namespace types: D.Point
Parameters:
this (Point type from HeWhoMustNotBeNamed/DrawingTypes/2)
other (Point type from HeWhoMustNotBeNamed/DrawingTypes/2)
method createCenter(this)
Namespace types: D.Point
Parameters:
this (Point type from HeWhoMustNotBeNamed/DrawingTypes/2)
method createCenter(this, other1, other2)
Namespace types: D.Point
Parameters:
this (Point type from HeWhoMustNotBeNamed/DrawingTypes/2)
other1 (Point type from HeWhoMustNotBeNamed/DrawingTypes/2)
other2 (Point type from HeWhoMustNotBeNamed/DrawingTypes/2)
method createLabel(this, labeltext, tooltip, properties)
Namespace types: D.Line
Parameters:
this (Line type from HeWhoMustNotBeNamed/DrawingTypes/2)
labeltext (string)
tooltip (string)
properties (LabelProperties type from HeWhoMustNotBeNamed/DrawingTypes/2)
method createLabel(this, labeltext, tooltip, properties)
Namespace types: DC.Triangle
Parameters:
this (Triangle type from robbatt/lib_drawing_composite_types/1)
labeltext (string)
tooltip (string)
properties (LabelProperties type from HeWhoMustNotBeNamed/DrawingTypes/2)
method createTriangle(this, p2, p3, properties)
Namespace types: D.Point
Parameters:
this (Point type from HeWhoMustNotBeNamed/DrawingTypes/2)
p2 (Point type from HeWhoMustNotBeNamed/DrawingTypes/2)
p3 (Point type from HeWhoMustNotBeNamed/DrawingTypes/2)
properties (TriangleProperties type from robbatt/lib_drawing_composite_types/1)
method createTrianglefill(this, fill_color, transparency)
Namespace types: DC.Triangle
Parameters:
this (Triangle type from robbatt/lib_drawing_composite_types/1)
fill_color (color)
transparency (int)
method createPolygonfill(this, fill_color, transparency)
Namespace types: DC.Polygon
Parameters:
this (Polygon type from robbatt/lib_drawing_composite_types/1)
fill_color (color)
transparency (int)
method createPolygon(points, properties)
Namespace types: D.Point
Parameters:
points (Point type from HeWhoMustNotBeNamed/DrawingTypes/2)
properties (TriangleProperties type from robbatt/lib_drawing_composite_types/1)
Display
lib_drawing_composite_typesLibrary "lib_drawing_composite_types"
User Defined Types for basic drawing structure. Other types and methods will be built on these. (added type Triangle and Polygon to )
TriangleProperties
TriangleProperties object
Fields:
border_color (series color) : Box border color. Default is color.blue
fill_color (series color) : Fill color
fill_transparency (series int)
border_width (series int) : Box border width. Default is 1
border_style (series string) : Box border style. Default is line.style_solid
xloc (series string) : defines if drawing needs to be done based on bar index or time. default is xloc.bar_index
Triangle
Triangle object
Fields:
p1 (Point type from HeWhoMustNotBeNamed/DrawingTypes/2) : point one
p2 (Point type from HeWhoMustNotBeNamed/DrawingTypes/2) : point two
p3 (Point type from HeWhoMustNotBeNamed/DrawingTypes/2) : point three
properties (TriangleProperties) : Triangle properties
l12 (series line) : line object created
l23 (series line) : line object created
l31 (series line) : line object created
Trianglefill
Trianglefill object
Fields:
triangle (Triangle) : to create a linefill for
fill_color (series color) : Fill color
transparency (series int) : Fill transparency range from 0 to 100
object (series linefill) : linefill object created
Polygon
Polygon object
Fields:
center (Point type from HeWhoMustNotBeNamed/DrawingTypes/2) : Point that triangles are using as common center
triangles (Triangle ) : an array of triangles that form the Polygon
Polygonfill
Polygonfill object
Fields:
_polygon (Polygon) : to create a fill for
_fills (Trianglefill ) : an array of Trianglefill objects that match the array of triangles in _polygon
lib_colorLibrary "lib_color"
offset_mono(original, offset, transparency)
get offset color
Parameters:
original (simple color) : original color
offset (float) : offset for new color
transparency (float) : transparency for new color
Returns: offset color
lib_colorsLibrary "lib_colors"
offset_mono(original, offset, transparency)
get offset color
Parameters:
original (simple color) : original color
offset (float) : offset for new color
transparency (float) : transparency for new color
Returns: offset color
CNTLibraryLibrary "CNTLibrary"
Custom Functions To Help Code In Pinescript V5
Coded By Christian Nataliano
First Coded In 10/06/2023
Last Edited In 22/06/2023
Huge Shout Out To © ZenAndTheArtOfTrading and his ZenLibrary V5, Some Of The Custom Functions Were Heavily Inspired By Matt's Work & His Pine Script Mastery Course
Another Shout Out To The TradingView's Team Library ta V5
//====================================================================================================================================================
// Custom Indicator Functions
//====================================================================================================================================================
GetKAMA(KAMA_lenght, Fast_KAMA, Slow_KAMA)
Calculates An Adaptive Moving Average Based On Perry J Kaufman's Calculations
Parameters:
KAMA_lenght (int) : Is The KAMA Lenght
Fast_KAMA (int) : Is The KAMA's Fastes Moving Average
Slow_KAMA (int) : Is The KAMA's Slowest Moving Average
Returns: Float Of The KAMA's Current Calculations
GetMovingAverage(Source, Lenght, Type)
Get Custom Moving Averages Values
Parameters:
Source (float) : Of The Moving Average, Defval = close
Lenght (simple int) : Of The Moving Average, Defval = 50
Type (string) : Of The Moving Average, Defval = Exponential Moving Average
Returns: The Moving Average Calculation Based On Its Given Source, Lenght & Calculation Type (Please Call Function On Global Scope)
GetDecimals()
Calculates how many decimals are on the quote price of the current market © ZenAndTheArtOfTrading
Returns: The current decimal places on the market quote price
Truncate(number, decimalPlaces)
Truncates (cuts) excess decimal places © ZenAndTheArtOfTrading
Parameters:
number (float)
decimalPlaces (simple float)
Returns: The given number truncated to the given decimalPlaces
ToWhole(number)
Converts pips into whole numbers © ZenAndTheArtOfTrading
Parameters:
number (float)
Returns: The converted number
ToPips(number)
Converts whole numbers back into pips © ZenAndTheArtOfTrading
Parameters:
number (float)
Returns: The converted number
GetPctChange(value1, value2, lookback)
Gets the percentage change between 2 float values over a given lookback period © ZenAndTheArtOfTrading
Parameters:
value1 (float)
value2 (float)
lookback (int)
BarsAboveMA(lookback, ma)
Counts how many candles are above the MA © ZenAndTheArtOfTrading
Parameters:
lookback (int)
ma (float)
Returns: The bar count of how many recent bars are above the MA
BarsBelowMA(lookback, ma)
Counts how many candles are below the MA © ZenAndTheArtOfTrading
Parameters:
lookback (int)
ma (float)
Returns: The bar count of how many recent bars are below the EMA
BarsCrossedMA(lookback, ma)
Counts how many times the EMA was crossed recently © ZenAndTheArtOfTrading
Parameters:
lookback (int)
ma (float)
Returns: The bar count of how many times price recently crossed the EMA
GetPullbackBarCount(lookback, direction)
Counts how many green & red bars have printed recently (ie. pullback count) © ZenAndTheArtOfTrading
Parameters:
lookback (int)
direction (int)
Returns: The bar count of how many candles have retraced over the given lookback & direction
GetSwingHigh(Lookback, SwingType)
Check If Price Has Made A Recent Swing High
Parameters:
Lookback (int) : Is For The Swing High Lookback Period, Defval = 7
SwingType (int) : Is For The Swing High Type Of Identification, Defval = 1
Returns: A Bool - True If Price Has Made A Recent Swing High
GetSwingLow(Lookback, SwingType)
Check If Price Has Made A Recent Swing Low
Parameters:
Lookback (int) : Is For The Swing Low Lookback Period, Defval = 7
SwingType (int) : Is For The Swing Low Type Of Identification, Defval = 1
Returns: A Bool - True If Price Has Made A Recent Swing Low
//====================================================================================================================================================
// Custom Risk Management Functions
//====================================================================================================================================================
CalculateStopLossLevel(OrderType, Entry, StopLoss)
Calculate StopLoss Level
Parameters:
OrderType (int) : Is To Determine A Long / Short Position, Defval = 1
Entry (float) : Is The Entry Level Of The Order, Defval = na
StopLoss (float) : Is The Custom StopLoss Distance, Defval = 2x ATR Below Close
Returns: Float - The StopLoss Level In Actual Price As A
CalculateStopLossDistance(OrderType, Entry, StopLoss)
Calculate StopLoss Distance In Pips
Parameters:
OrderType (int) : Is To Determine A Long / Short Position, Defval = 1
Entry (float) : Is The Entry Level Of The Order, NEED TO INPUT PARAM
StopLoss (float) : Level Based On Previous Calculation, NEED TO INPUT PARAM
Returns: Float - The StopLoss Value In Pips
CalculateTakeProfitLevel(OrderType, Entry, StopLossDistance, RiskReward)
Calculate TakeProfit Level
Parameters:
OrderType (int) : Is To Determine A Long / Short Position, Defval = 1
Entry (float) : Is The Entry Level Of The Order, Defval = na
StopLossDistance (float)
RiskReward (float)
Returns: Float - The TakeProfit Level In Actual Price
CalculateTakeProfitDistance(OrderType, Entry, TakeProfit)
Get TakeProfit Distance In Pips
Parameters:
OrderType (int) : Is To Determine A Long / Short Position, Defval = 1
Entry (float) : Is The Entry Level Of The Order, NEED TO INPUT PARAM
TakeProfit (float) : Level Based On Previous Calculation, NEED TO INPUT PARAM
Returns: Float - The TakeProfit Value In Pips
CalculateConversionCurrency(AccountCurrency, SymbolCurrency, BaseCurrency)
Get The Conversion Currecny Between Current Account Currency & Current Pair's Quoted Currency (FOR FOREX ONLY)
Parameters:
AccountCurrency (simple string) : Is For The Account Currency Used
SymbolCurrency (simple string) : Is For The Current Symbol Currency (Front Symbol)
BaseCurrency (simple string) : Is For The Current Symbol Base Currency (Back Symbol)
Returns: Tuple Of A Bollean (Convert The Currency ?) And A String (Converted Currency)
CalculateConversionRate(ConvertCurrency, ConversionRate)
Get The Conversion Rate Between Current Account Currency & Current Pair's Quoted Currency (FOR FOREX ONLY)
Parameters:
ConvertCurrency (bool) : Is To Check If The Current Symbol Needs To Be Converted Or Not
ConversionRate (float) : Is The Quoted Price Of The Conversion Currency (Input The request.security Function Here)
Returns: Float Price Of Conversion Rate (If In The Same Currency Than Return Value Will Be 1.0)
LotSize(LotSizeSimple, Balance, Risk, SLDistance, ConversionRate)
Get Current Lot Size
Parameters:
LotSizeSimple (bool) : Is To Toggle Lot Sizing Calculation (Simple Is Good Enough For Stocks & Crypto, Whilst Complex Is For Forex)
Balance (float) : Is For The Current Account Balance To Calculate The Lot Sizing Based Off
Risk (float) : Is For The Current Risk Per Trade To Calculate The Lot Sizing Based Off
SLDistance (float) : Is The Current Position StopLoss Distance From Its Entry Price
ConversionRate (float) : Is The Currency Conversion Rate (Used For Complex Lot Sizing Only)
Returns: Float - Position Size In Units
ToLots(Units)
Converts Units To Lots
Parameters:
Units (float) : Is For How Many Units Need To Be Converted Into Lots (Minimun 1000 Units)
Returns: Float - Position Size In Lots
ToUnits(Lots)
Converts Lots To Units
Parameters:
Lots (float) : Is For How Many Lots Need To Be Converted Into Units (Minimun 0.01 Units)
Returns: Int - Position Size In Units
ToLotsInUnits(Units)
Converts Units To Lots Than Back To Units
Parameters:
Units (float) : Is For How Many Units Need To Be Converted Into Lots (Minimun 1000 Units)
Returns: Float - Position Size In Lots That Were Rounded To Units
ATRTrail(OrderType, SourceType, ATRPeriod, ATRMultiplyer, SwingLookback)
Calculate ATR Trailing Stop
Parameters:
OrderType (int) : Is To Determine A Long / Short Position, Defval = 1
SourceType (int) : Is To Determine Where To Calculate The ATR Trailing From, Defval = close
ATRPeriod (simple int) : Is To Change Its ATR Period, Defval = 20
ATRMultiplyer (float) : Is To Change Its ATR Trailing Distance, Defval = 1
SwingLookback (int) : Is To Change Its Swing HiLo Lookback (Only From Source Type 5), Defval = 7
Returns: Float - Number Of The Current ATR Trailing
DangerZone(WinRate, AvgRRR, Filter)
Calculate Danger Zone Of A Given Strategy
Parameters:
WinRate (float) : Is The Strategy WinRate
AvgRRR (float) : Is The Strategy Avg RRR
Filter (float) : Is The Minimum Profit It Needs To Be Out Of BE Zone, Defval = 3
Returns: Int - Value, 1 If Out Of Danger Zone, 0 If BE, -1 If In Danger Zone
IsQuestionableTrades(TradeTP, TradeSL)
Checks For Questionable Trades (Which Are Trades That Its TP & SL Level Got Hit At The Same Candle)
Parameters:
TradeTP (float) : Is The Trade In Question Take Profit Level
TradeSL (float) : Is The Trade In Question Stop Loss Level
Returns: Bool - True If The Last Trade Was A "Questionable Trade"
//====================================================================================================================================================
// Custom Strategy Functions
//====================================================================================================================================================
OpenLong(EntryID, LotSize, LimitPrice, StopPrice, Comment, CommentValue)
Open A Long Order Based On The Given Params
Parameters:
EntryID (string) : Is The Trade Entry ID, Defval = "Long"
LotSize (float) : Is The Lot Size Of The Trade, Defval = 1
LimitPrice (float) : Is The Limit Order Price To Set The Order At, Defval = Na / Market Order Execution
StopPrice (float) : Is The Stop Order Price To Set The Order At, Defval = Na / Market Order Execution
Comment (string) : Is The Order Comment, Defval = Long Entry Order
CommentValue (string) : Is For Custom Values In The Order Comment, Defval = Na
Returns: Void
OpenShort(EntryID, LotSize, LimitPrice, StopPrice, Comment, CommentValue)
Open A Short Order Based On The Given Params
Parameters:
EntryID (string) : Is The Trade Entry ID, Defval = "Short"
LotSize (float) : Is The Lot Size Of The Trade, Defval = 1
LimitPrice (float) : Is The Limit Order Price To Set The Order At, Defval = Na / Market Order Execution
StopPrice (float) : Is The Stop Order Price To Set The Order At, Defval = Na / Market Order Execution
Comment (string) : Is The Order Comment, Defval = Short Entry Order
CommentValue (string) : Is For Custom Values In The Order Comment, Defval = Na
Returns: Void
TP_SLExit(FromID, TPLevel, SLLevel, PercentageClose, Comment, CommentValue)
Exits Based On Predetermined TP & SL Levels
Parameters:
FromID (string) : Is The Trade ID That The TP & SL Levels Be Palced
TPLevel (float) : Is The Take Profit Level
SLLevel (float) : Is The StopLoss Level
PercentageClose (float) : Is The Amount To Close The Order At (In Percentage) Defval = 100
Comment (string) : Is The Order Comment, Defval = Exit Order
CommentValue (string) : Is For Custom Values In The Order Comment, Defval = Na
Returns: Void
CloseLong(ExitID, PercentageClose, Comment, CommentValue, Instant)
Exits A Long Order Based On A Specified Condition
Parameters:
ExitID (string) : Is The Trade ID That Will Be Closed, Defval = "Long"
PercentageClose (float) : Is The Amount To Close The Order At (In Percentage) Defval = 100
Comment (string) : Is The Order Comment, Defval = Exit Order
CommentValue (string) : Is For Custom Values In The Order Comment, Defval = Na
Instant (bool) : Is For Exit Execution Type, Defval = false
Returns: Void
CloseShort(ExitID, PercentageClose, Comment, CommentValue, Instant)
Exits A Short Order Based On A Specified Condition
Parameters:
ExitID (string) : Is The Trade ID That Will Be Closed, Defval = "Short"
PercentageClose (float) : Is The Amount To Close The Order At (In Percentage) Defval = 100
Comment (string) : Is The Order Comment, Defval = Exit Order
CommentValue (string) : Is For Custom Values In The Order Comment, Defval = Na
Instant (bool) : Is For Exit Execution Type, Defval = false
Returns: Void
BrokerCheck(Broker)
Checks Traded Broker With Current Loaded Chart Broker
Parameters:
Broker (string) : Is The Current Broker That Is Traded
Returns: Bool - True If Current Traded Broker Is Same As Loaded Chart Broker
OpenPC(LicenseID, OrderType, UseLimit, LimitPrice, SymbolPrefix, Symbol, SymbolSuffix, Risk, SL, TP, OrderComment, Spread)
Compiles Given Parameters Into An Alert String Format To Open Trades Using Pine Connector
Parameters:
LicenseID (string) : Is The Users PineConnector LicenseID
OrderType (int) : Is The Desired OrderType To Open
UseLimit (bool) : Is If We Want To Enter The Position At Exactly The Previous Closing Price
LimitPrice (float) : Is The Limit Price Of The Trade (Only For Pending Orders)
SymbolPrefix (string) : Is The Current Symbol Prefix (If Any)
Symbol (string) : Is The Traded Symbol
SymbolSuffix (string) : Is The Current Symbol Suffix (If Any)
Risk (float) : Is The Trade Risk Per Trade / Fixed Lot Sizing
SL (float) : Is The Trade SL In Price / In Pips
TP (float) : Is The Trade TP In Price / In Pips
OrderComment (string) : Is The Executed Trade Comment
Spread (float) : is The Maximum Spread For Execution
Returns: String - Pine Connector Order Syntax Alert Message
ClosePC(LicenseID, OrderType, SymbolPrefix, Symbol, SymbolSuffix)
Compiles Given Parameters Into An Alert String Format To Close Trades Using Pine Connector
Parameters:
LicenseID (string) : Is The Users PineConnector LicenseID
OrderType (int) : Is The Desired OrderType To Close
SymbolPrefix (string) : Is The Current Symbol Prefix (If Any)
Symbol (string) : Is The Traded Symbol
SymbolSuffix (string) : Is The Current Symbol Suffix (If Any)
Returns: String - Pine Connector Order Syntax Alert Message
//====================================================================================================================================================
// Custom Backtesting Calculation Functions
//====================================================================================================================================================
CalculatePNL(EntryPrice, ExitPrice, LotSize, ConversionRate)
Calculates Trade PNL Based On Entry, Eixt & Lot Size
Parameters:
EntryPrice (float) : Is The Trade Entry
ExitPrice (float) : Is The Trade Exit
LotSize (float) : Is The Trade Sizing
ConversionRate (float) : Is The Currency Conversion Rate (Used For Complex Lot Sizing Only)
Returns: Float - The Current Trade PNL
UpdateBalance(PrevBalance, PNL)
Updates The Previous Ginve Balance To The Next PNL
Parameters:
PrevBalance (float) : Is The Previous Balance To Be Updated
PNL (float) : Is The Current Trade PNL To Be Added
Returns: Float - The Current Updated PNL
CalculateSlpComm(PNL, MaxRate)
Calculates Random Slippage & Commisions Fees Based On The Parameters
Parameters:
PNL (float) : Is The Current Trade PNL
MaxRate (float) : Is The Upper Limit (In Percentage) Of The Randomized Fee
Returns: Float - A Percentage Fee Of The Current Trade PNL
UpdateDD(MaxBalance, Balance)
Calculates & Updates The DD Based On Its Given Parameters
Parameters:
MaxBalance (float) : Is The Maximum Balance Ever Recorded
Balance (float) : Is The Current Account Balance
Returns: Float - The Current Strategy DD
CalculateWR(TotalTrades, LongID, ShortID)
Calculate The Total, Long & Short Trades Win Rate
Parameters:
TotalTrades (int) : Are The Current Total Trades That The Strategy Has Taken
LongID (string) : Is The Order ID Of The Long Trades Of The Strategy
ShortID (string) : Is The Order ID Of The Short Trades Of The Strategy
Returns: Tuple Of Long WR%, Short WR%, Total WR%, Total Winning Trades, Total Losing Trades, Total Long Trades & Total Short Trades
CalculateAvgRRR(WinTrades, LossTrades)
Calculates The Overall Strategy Avg Risk Reward Ratio
Parameters:
WinTrades (int) : Are The Strategy Winning Trades
LossTrades (int) : Are The Strategy Losing Trades
Returns: Float - The Average RRR Values
CAGR(StartTime, StartPrice, EndTime, EndPrice)
Calculates The CAGR Over The Given Time Period © TradingView
Parameters:
StartTime (int) : Is The Starting Time Of The Calculation
StartPrice (float) : Is The Starting Price Of The Calculation
EndTime (int) : Is The Ending Time Of The Calculation
EndPrice (float) : Is The Ending Price Of The Calculation
Returns: Float - The CAGR Values
//====================================================================================================================================================
// Custom Plot Functions
//====================================================================================================================================================
EditLabels(LabelID, X1, Y1, Text, Color, TextColor, EditCondition, DeleteCondition)
Edit / Delete Labels
Parameters:
LabelID (label) : Is The ID Of The Selected Label
X1 (int) : Is The X1 Coordinate IN BARINDEX Xloc
Y1 (float) : Is The Y1 Coordinate IN PRICE Yloc
Text (string) : Is The Text Than Wants To Be Written In The Label
Color (color) : Is The Color Value Change Of The Label Text
TextColor (color)
EditCondition (int) : Is The Edit Condition of The Line (Setting Location / Color)
DeleteCondition (bool) : Is The Delete Condition Of The Line If Ture Deletes The Prev Itteration Of The Line
Returns: Void
EditLine(LineID, X1, Y1, X2, Y2, Color, EditCondition, DeleteCondition)
Edit / Delete Lines
Parameters:
LineID (line) : Is The ID Of The Selected Line
X1 (int) : Is The X1 Coordinate IN BARINDEX Xloc
Y1 (float) : Is The Y1 Coordinate IN PRICE Yloc
X2 (int) : Is The X2 Coordinate IN BARINDEX Xloc
Y2 (float) : Is The Y2 Coordinate IN PRICE Yloc
Color (color) : Is The Color Value Change Of The Line
EditCondition (int) : Is The Edit Condition of The Line (Setting Location / Color)
DeleteCondition (bool) : Is The Delete Condition Of The Line If Ture Deletes The Prev Itteration Of The Line
Returns: Void
//====================================================================================================================================================
// Custom Display Functions (Using Tables)
//====================================================================================================================================================
FillTable(TableID, Column, Row, Title, Value, BgColor, TextColor, ToolTip)
Filling The Selected Table With The Inputed Information
Parameters:
TableID (table) : Is The Table ID That Wants To Be Edited
Column (int) : Is The Current Column Of The Table That Wants To Be Edited
Row (int) : Is The Current Row Of The Table That Wants To Be Edited
Title (string) : Is The String Title Of The Current Cell Table
Value (string) : Is The String Value Of The Current Cell Table
BgColor (color) : Is The Selected Color For The Current Table
TextColor (color) : Is The Selected Color For The Current Table
ToolTip (string) : Is The ToolTip Of The Current Cell In The Table
Returns: Void
DisplayBTResults(TableID, BgColor, TextColor, StartingBalance, Balance, DollarReturn, TotalPips, MaxDD)
Filling The Selected Table With The Inputed Information
Parameters:
TableID (table) : Is The Table ID That Wants To Be Edited
BgColor (color) : Is The Selected Color For The Current Table
TextColor (color) : Is The Selected Color For The Current Table
StartingBalance (float) : Is The Account Starting Balance
Balance (float)
DollarReturn (float) : Is The Account Dollar Reture
TotalPips (float) : Is The Total Pips Gained / loss
MaxDD (float) : Is The Maximum Drawdown Over The Backtesting Period
Returns: Void
DisplayBTResultsV2(TableID, BgColor, TextColor, TotalWR, QTCount, LongWR, ShortWR, InitialCapital, CumProfit, CumFee, AvgRRR, MaxDD, CAGR, MeanDD)
Filling The Selected Table With The Inputed Information
Parameters:
TableID (table) : Is The Table ID That Wants To Be Edited
BgColor (color) : Is The Selected Color For The Current Table
TextColor (color) : Is The Selected Color For The Current Table
TotalWR (float) : Is The Strategy Total WR In %
QTCount (int) : Is The Strategy Questionable Trades Count
LongWR (float) : Is The Strategy Total WR In %
ShortWR (float) : Is The Strategy Total WR In %
InitialCapital (float) : Is The Strategy Initial Starting Capital
CumProfit (float) : Is The Strategy Ending Cumulative Profit
CumFee (float) : Is The Strategy Ending Cumulative Fee (Based On Randomized Fee Assumptions)
AvgRRR (float) : Is The Strategy Average Risk Reward Ratio
MaxDD (float) : Is The Strategy Maximum DrawDown In Its Backtesting Period
CAGR (float) : Is The Strategy Compounded Average GRowth In %
MeanDD (float) : Is The Strategy Mean / Average Drawdown In The Backtesting Period
Returns: Void
//====================================================================================================================================================
// Custom Pattern Detection Functions
//====================================================================================================================================================
BullFib(priceLow, priceHigh, fibRatio)
Calculates A Bullish Fibonacci Value (From Swing Low To High) © ZenAndTheArtOfTrading
Parameters:
priceLow (float)
priceHigh (float)
fibRatio (float)
Returns: The Fibonacci Value Of The Given Ratio Between The Two Price Points
BearFib(priceLow, priceHigh, fibRatio)
Calculates A Bearish Fibonacci Value (From Swing High To Low) © ZenAndTheArtOfTrading
Parameters:
priceLow (float)
priceHigh (float)
fibRatio (float)
Returns: The Fibonacci Value Of The Given Ratio Between The Two Price Points
GetBodySize()
Gets The Current Candle Body Size IN POINTS © ZenAndTheArtOfTrading
Returns: The Current Candle Body Size IN POINTS
GetTopWickSize()
Gets The Current Candle Top Wick Size IN POINTS © ZenAndTheArtOfTrading
Returns: The Current Candle Top Wick Size IN POINTS
GetBottomWickSize()
Gets The Current Candle Bottom Wick Size IN POINTS © ZenAndTheArtOfTrading
Returns: The Current Candle Bottom Wick Size IN POINTS
GetBodyPercent()
Gets The Current Candle Body Size As A Percentage Of Its Entire Size Including Its Wicks © ZenAndTheArtOfTrading
Returns: The Current Candle Body Size IN PERCENTAGE
GetTopWickPercent()
Gets The Current Top Wick Size As A Percentage Of Its Entire Body Size
Returns: Float - The Current Candle Top Wick Size IN PERCENTAGE
GetBottomWickPercent()
Gets The Current Bottom Wick Size As A Percentage Of Its Entire Bodu Size
Returns: Float - The Current Candle Bottom Size IN PERCENTAGE
BullishEC(Allowance, RejectionWickSize, EngulfWick, NearSwings, SwingLookBack)
Checks If The Current Bar Is A Bullish Engulfing Candle
Parameters:
Allowance (int) : To Give Flexibility Of Engulfing Pattern Detection In Markets That Have Micro Gaps, Defval = 0
RejectionWickSize (float) : To Filter Out long (Upper And Lower) Wick From The Bullsih Engulfing Pattern, Defval = na
EngulfWick (bool) : To Specify If We Want The Pattern To Also Engulf Its Upper & Lower Previous Wicks, Defval = false
NearSwings (bool) : To Specify If We Want The Pattern To Be Near A Recent Swing Low, Defval = true
SwingLookBack (int) : To Specify How Many Bars Back To Detect A Recent Swing Low, Defval = 10
Returns: Bool - True If The Current Bar Matches The Requirements of a Bullish Engulfing Candle
BearishEC(Allowance, RejectionWickSize, EngulfWick, NearSwings, SwingLookBack)
Checks If The Current Bar Is A Bearish Engulfing Candle
Parameters:
Allowance (int) : To Give Flexibility Of Engulfing Pattern Detection In Markets That Have Micro Gaps, Defval = 0
RejectionWickSize (float) : To Filter Out long (Upper And Lower) Wick From The Bearish Engulfing Pattern, Defval = na
EngulfWick (bool) : To Specify If We Want The Pattern To Also Engulf Its Upper & Lower Previous Wicks, Defval = false
NearSwings (bool) : To Specify If We Want The Pattern To Be Near A Recent Swing High, Defval = true
SwingLookBack (int) : To Specify How Many Bars Back To Detect A Recent Swing High, Defval = 10
Returns: Bool - True If The Current Bar Matches The Requirements of a Bearish Engulfing Candle
Hammer(Fib, ColorMatch, NearSwings, SwingLookBack, ATRFilterCheck, ATRPeriod)
Checks If The Current Bar Is A Hammer Candle
Parameters:
Fib (float) : To Specify Which Fibonacci Ratio To Use When Determining The Hammer Candle, Defval = 0.382 Ratio
ColorMatch (bool) : To Filter Only Bullish Closed Hammer Candle Pattern, Defval = false
NearSwings (bool) : To Specify If We Want The Doji To Be Near A Recent Swing Low, Defval = true
SwingLookBack (int) : To Specify How Many Bars Back To Detect A Recent Swing Low, Defval = 10
ATRFilterCheck (float) : To Filter Smaller Hammer Candles That Might Be Better Classified As A Doji Candle, Defval = 1
ATRPeriod (simple int) : To Change ATR Period Of The ATR Filter, Defval = 20
Returns: Bool - True If The Current Bar Matches The Requirements of a Hammer Candle
Star(Fib, ColorMatch, NearSwings, SwingLookBack, ATRFilterCheck, ATRPeriod)
Checks If The Current Bar Is A Hammer Candle
Parameters:
Fib (float) : To Specify Which Fibonacci Ratio To Use When Determining The Hammer Candle, Defval = 0.382 Ratio
ColorMatch (bool) : To Filter Only Bullish Closed Hammer Candle Pattern, Defval = false
NearSwings (bool) : To Specify If We Want The Doji To Be Near A Recent Swing Low, Defval = true
SwingLookBack (int) : To Specify How Many Bars Back To Detect A Recent Swing Low, Defval = 10
ATRFilterCheck (float) : To Filter Smaller Hammer Candles That Might Be Better Classified As A Doji Candle, Defval = 1
ATRPeriod (simple int) : To Change ATR Period Of The ATR Filter, Defval = 20
Returns: Bool - True If The Current Bar Matches The Requirements of a Hammer Candle
Doji(MaxWickSize, MaxBodySize, DojiType, NearSwings, SwingLookBack)
Checks If The Current Bar Is A Doji Candle
Parameters:
MaxWickSize (float) : To Specify The Maximum Lenght Of Its Upper & Lower Wick, Defval = 2
MaxBodySize (float) : To Specify The Maximum Lenght Of Its Candle Body IN PERCENT, Defval = 0.05
DojiType (int)
NearSwings (bool) : To Specify If We Want The Doji To Be Near A Recent Swing High / Low (Only In Dragonlyf / Gravestone Mode), Defval = true
SwingLookBack (int) : To Specify How Many Bars Back To Detect A Recent Swing High / Low (Only In Dragonlyf / Gravestone Mode), Defval = 10
Returns: Bool - True If The Current Bar Matches The Requirements of a Doji Candle
BullishIB(Allowance, RejectionWickSize, EngulfWick, NearSwings, SwingLookBack)
Checks If The Current Bar Is A Bullish Harami Candle
Parameters:
Allowance (int) : To Give Flexibility Of Harami Pattern Detection In Markets That Have Micro Gaps, Defval = 0
RejectionWickSize (float) : To Filter Out long (Upper And Lower) Wick From The Bullsih Harami Pattern, Defval = na
EngulfWick (bool) : To Specify If We Want The Pattern To Also Engulf Its Upper & Lower Previous Wicks, Defval = false
NearSwings (bool) : To Specify If We Want The Pattern To Be Near A Recent Swing Low, Defval = true
SwingLookBack (int) : To Specify How Many Bars Back To Detect A Recent Swing Low, Defval = 10
Returns: Bool - True If The Current Bar Matches The Requirements of a Bullish Harami Candle
BearishIB(Allowance, RejectionWickSize, EngulfWick, NearSwings, SwingLookBack)
Checks If The Current Bar Is A Bullish Harami Candle
Parameters:
Allowance (int) : To Give Flexibility Of Harami Pattern Detection In Markets That Have Micro Gaps, Defval = 0
RejectionWickSize (float) : To Filter Out long (Upper And Lower) Wick From The Bearish Harami Pattern, Defval = na
EngulfWick (bool) : To Specify If We Want The Pattern To Also Engulf Its Upper & Lower Previous Wicks, Defval = false
NearSwings (bool) : To Specify If We Want The Pattern To Be Near A Recent Swing High, Defval = true
SwingLookBack (int) : To Specify How Many Bars Back To Detect A Recent Swing High, Defval = 10
Returns: Bool - True If The Current Bar Matches The Requirements of a Bearish Harami Candle
//====================================================================================================================================================
// Custom Time Functions
//====================================================================================================================================================
BarInSession(sess, useFilter)
Determines if the current price bar falls inside the specified session © ZenAndTheArtOfTrading
Parameters:
sess (simple string)
useFilter (bool)
Returns: A boolean - true if the current bar falls within the given time session
BarOutSession(sess, useFilter)
Determines if the current price bar falls outside the specified session © ZenAndTheArtOfTrading
Parameters:
sess (simple string)
useFilter (bool)
Returns: A boolean - true if the current bar falls outside the given time session
DateFilter(startTime, endTime)
Determines if this bar's time falls within date filter range © ZenAndTheArtOfTrading
Parameters:
startTime (int)
endTime (int)
Returns: A boolean - true if the current bar falls within the given dates
DayFilter(monday, tuesday, wednesday, thursday, friday, saturday, sunday)
Checks if the current bar's day is in the list of given days to analyze © ZenAndTheArtOfTrading
Parameters:
monday (bool)
tuesday (bool)
wednesday (bool)
thursday (bool)
friday (bool)
saturday (bool)
sunday (bool)
Returns: A boolean - true if the current bar's day is one of the given days
AUSSess()
Checks If The Current Australian Forex Session In Running
Returns: Bool - True If Currently The Australian Session Is Running
ASIASess()
Checks If The Current Asian Forex Session In Running
Returns: Bool - True If Currently The Asian Session Is Running
EURSess()
Checks If The Current European Forex Session In Running
Returns: Bool - True If Currently The European Session Is Running
USSess()
Checks If The Current US Forex Session In Running
Returns: Bool - True If Currently The US Session Is Running
UNIXToDate(Time, ConversionType, TimeZone)
Converts UNIX Time To Datetime
Parameters:
Time (int) : Is The UNIX Time Input
ConversionType (int) : Is The Datetime Output Format, Defval = DD-MM-YYYY
TimeZone (string) : Is To Convert The Outputed Datetime Into The Specified Time Zone, Defval = Exchange Time Zone
Returns: String - String Of Datetime
TooltipLibrary "Tooltip"
This library helps creating and managing nice looking data (key/value) tooltips that you can use for
labels. The tooltips data key/value will align automatically. It is optional to convert the data to a values only string too.
method addSpacesToKey(this)
Calculates the amount of spaces needed after the key to make it the key least 4 characters wide.
Namespace types: Data
Parameters:
this (Data) : (Data) The Data.
method addTabs(this, longestKeyLength)
Calculates the amount of tabs to be used.
Namespace types: Data
Parameters:
this (Data) : (Data) The Data.
longestKeyLength (int)
method longestKeyLength(this)
Returns the length of the longest key string in the array.
Namespace types: Data
Parameters:
this (Data ) : (Tooltip) The object to work with.
@return (int) The length of the key.
method toString(tooltips, withKey)
Helper function for the tooltip.
Namespace types: Data
Parameters:
tooltips (Data )
withKey (bool) : (bool) Wether to create a string with keys in it.
@return (string) The string
new()
Creates a new array to store tooltip data in
@return (Data) The data array.
Data
Key/Value pair for tooltips
Fields:
key (series string)
value (series string)
AoDivergenceLibrary_Library "AoDivergenceLibrary_"
this has functions which calculate and plot divergences which are used for ao divergences. essentially, this finds divergences by using the ao divergence logic. this logic has been used in "AO Hid & Reg Div with LC & Kernel".
regBullDivergence(swingLow, osc, colour)
Parameters:
swingLow (bool)
osc (float)
colour (color)
regBearDivergence(swingHigh, osc, colour)
Parameters:
swingHigh (bool)
osc (float)
colour (color)
hidBullDivergence(swingHigh, osc, colour)
Parameters:
swingHigh (bool)
osc (float)
colour (color)
hidBearDivergence(swingHigh, osc, colour)
Parameters:
swingHigh (bool)
osc (float)
colour (color)
AlgebraLibLibrary "AlgebraLib"
f_signaldraw(_side, _date)
: Draw a simple label with Buy or Sell signal
Parameters:
_side (string)
_date (int)
Returns: : VOID, it draws a new label
JavaScript-style Debug ConsoleThis library provides a JavaScript-style debug console to Pine Coders. It supports the most commonly used utilities from the WHATWG Console Standard including the following:
• console.log
• console.debug
• console.info
• console.warn
• console.error
• console.assert
• console.count
• console.countReset
• console.group
• console.groupEnd
• console.clear
In addition to the WHATWG standard, this library also supports the following methods:
• console.show
• console.hide
FEATURES
• Follows the WHATWG Console Standard, which is widely adopted by all major JavaScript runtimes including browsers and Node.js.
• Provides an out-of-box UI with pre-configured theming, ensuring a clean and professional-looking console.
• Allows for easy UI customizations to fit your personal preferences.
• Has extremely simple import and initialization, making it easy to integrate with your existing codebase.
USAGE
1. Import this library:
import algotraderdev/Console/1
2. Initialize the console object:
var console = Console.new()
// You can also specify optional params to customize the look & feel.
var console = Console.new(
position = position.bottom_right,
max_rows = 50,
width = 0,
text_size = size.normal,
background_color = #000000CC,
timestamp_color = #AAAAAA,
info_message_color = #DDDDDD,
debug_message_color = #AAAAAA,
warn_message_color = #FFEB3B,
error_message_color = #ff3c00)
3. Use the console object to debug your code. Here are some examples:
// Basic logging
console.log('hello world!') // prints 'hello world'
console.warn('warn') // prints 'warn' in yellow
console.error('error') // prints 'error' in red
console.clear() // clears the console
// Assertion
console.assert(a.isEmpty(), 'array should be empty') // prints 'assertion failed: array should be empty' if the array is not empty
// Counter
console.count('fooFunction') // prints 'fooFunction: 1'
console.count('fooFunction') // prints 'fooFunction: 2'
console.countReset('fooFunction') // resets the counter
console.count('fooFunction') // prints 'fooFunction: 1'
// Group
console.log('A')
console.group()
console.log('B')
console.group()
console.log('C')
console.log('D')
console.groupEnd()
console.log('E')
console.groupEnd()
console.log('F')
// prints
// A
// B
// C
// D
// E
// F
// Hide and show
console.hide()
console.show()
Mad_StandardpartsLibrary "Mad_Standardparts"
This are my Standardparts used in upcoming scipts
roundTo(_value, _decimals)
Round a floating point value to a specified number of decimal places.
@description This function takes a floating point value and rounds it to a specified number of decimal places.
Parameters:
_value (float) : The floating point value to be rounded.
_decimals (int) : The number of decimal places to round to. Must be a non-negative integer.
Returns: The rounded value, as a floating point number.
clear_all()
Delete all drawings on the chart.
@description This function deletes all drawings on the chart, including lines, boxes, and labels.
Returns: None.
shifting(_value)
Create a string of spaces to shift text over by a specified amount.
@description This function takes an integer value and returns a string consisting of that many spaces, which can be used to shift text over in a PineScript chart.
Parameters:
_value (int) : The number of spaces to create in the output string.
Returns: A string consisting of the specified number of spaces.
fromLog(_value)
Convert a linear value to a logarithmic value.
@description This function takes a linear value and converts it to a logarithmic value, using the formula specified in the code.
Parameters:
_value (float)
Returns: The corresponding logarithmic value, as a floating point number.
toLog(_value)
Convert a logarithmic value to a linear value.
@description This function takes a logarithmic value and converts it to a linear value, using the formula specified in the code.
Parameters:
_value (float)
Returns: The corresponding linear value, as a floating point number.
f_getbartime()
Calculate the time per bar on the chart.
@description This function calculates the time per bar on the chart based on the first 100 bars.
Returns: The time per bar, as an integer value.
Cleaner Screeners LibraryLibrary "cleanscreens"
Screener Panel.
This indicator displays a panel with a list of symbols and their indications.
It can be used as a screener for multiple timess and symbols
in any timeframe and with any indication in any combination.
#### Features
Multiple timeframes
Multiple symbols
Multiple indications per group
Vertical or horizontal layouts
Acceepts External Inputs
Customizable colors with 170 presets included (dark and light)
Customizable icons
Customizable text size and font
Customizable cell size width and height
Customizable frame width and border width
Customizable position
Customizable strong and weak values
Accepts any indicator as input
Only 4 functions to call, easy to use
#### Usage
Initialize the panel with _paneel = cleanscreens.init()
Add groupd with _screener = cleanscreens.Screener(_paneel, "Group Name")
Add indicators to screeener groups with cleanscreens.Indicator(_screener, "Indicator Name", _source)
Update the panel with cleanscreens.display(_paneel)
Thanks @ PineCoders , and the Group members for setting the bar high.
# local setup for methods on our script
import kaigouthro/cleanscreen/1
method Screener ( panel p, string _name) => cleanscreens.Screener ( p, _name)
method Indicator ( screener s , string _tf, string name, float val) => cleanscreens.Indicator ( s , _tf, name, val)
method display ( panel p ) => cleanscreens.display ( p )
init(_themein, loc)
# Panel init
> init a panel for all the screens
Parameters:
_themein (string) : string: Theme Preset Name
loc (int) : int :
1 = left top,
2 = middle top,
3 = right top,
4 = left middle,
5 = middle middle,
6 = right middle,
7 = left bottom,
8 = middle bottom,
9 = right bottom
Returns: panel
method Screener(p, _name)
# Screener - Create a new screener
### Example:
cleanscreens.new(panel, 'Crpyto Screeners')
Namespace types: panel
Parameters:
p (panel)
_name (string)
method Indicator(s, _tf, name, val)
# Indicator - Create a new Indicator
### Example:
cleanscreens.Inidcator('1h', 'RSI', ta.rsi(close, 14))
Namespace types: screener
Parameters:
s (screener)
_tf (string)
name (string)
val (float)
method display(p)
# Display - Display the Panel
### Example:
cleanscreens.display(panel)
Namespace types: panel
Parameters:
p (panel)
indication
single indication for a symbol screener
Fields:
name (series string)
icon (series string)
rating (series string)
value (series float)
col (series color)
tf (series string)
tooltip (series string)
normalized (series float)
init (series bool)
screener
single symbol screener
Fields:
ticker (series string)
icon (series string)
rating (series string)
value (series float)
bg (series color)
fg (series color)
items (indication )
init (series bool)
config
screener configuration
Fields:
strong (series float)
weak (series float)
theme (series string)
vert (series bool)
cellwidth (series float)
cellheight (series float)
textsize (series string)
font (series int)
framewidth (series int)
borders (series int)
position (series string)
icons
screener Icons
Fields:
buy (series string)
sell (series string)
strong (series string)
panel
screener panel object
Fields:
items (screener )
table (series table)
config (config)
theme (theme type from kaigouthro/theme_engine/1)
icons (icons)
Boxes_PlotIn the world of data visualization, heatmaps are an invaluable tool for understanding complex datasets. They use color gradients to represent the values of individual data points, allowing users to quickly identify patterns, trends, and outliers in their data. In this post, we will delve into the history of heatmaps, and then discuss how its implemented.
The "Boxes_Plot" library is a powerful and versatile tool for visualizing multiple indicators on a trading chart using colored boxes, commonly known as heatmaps. These heatmaps provide a user-friendly and efficient method for analyzing the performance and trends of various indicators simultaneously. The library can be customized to display multiple charts, adjust the number of rows, and set the appropriate offset for proper spacing. This allows traders to gain insights into the market and make informed decisions.
Heatmaps with cells are interesting and useful for several reasons. Firstly, they allow for the visualization of large datasets in a compact and organized manner. This is especially beneficial when working with multiple indicators, as it enables traders to easily compare and contrast their performance. Secondly, heatmaps provide a clear and intuitive representation of the data, making it easier for traders to identify trends and patterns. Finally, heatmaps offer a visually appealing way to present complex information, which can help to engage and maintain the interest of traders.
History of Heatmaps
The concept of heatmaps can be traced back to the 19th century when French cartographer and sociologist Charles Joseph Minard used color gradients to visualize statistical data. He is well-known for his 1869 map, which depicted Napoleon's disastrous Russian campaign of 1812 using a color gradient to represent the dwindling size of Napoleon's army.
In the 20th century, heatmaps gained popularity in the fields of biology and genetics, where they were used to visualize gene expression data. In the early 2000s, heatmaps found their way into the world of finance, where they are now used to display stock market data, such as price, volume, and performance.
The boxes_plot function in the library expects a normalized value from 0 to 100 as input. Normalizing the data ensures that all values are on a consistent scale, making it easier to compare different indicators. The function also allows for easy customization, enabling users to adjust the number of rows displayed, the size of the boxes, and the offset for proper spacing.
One of the key features of the library is its ability to automatically scale the chart to the screen. This ensures that the heatmap remains clear and visible, regardless of the size or resolution of the user's monitor. This functionality is essential for traders who may be using various devices and screen sizes, as it enables them to easily access and interpret the heatmap without needing to make manual adjustments.
In order to create a heatmap using the boxes_plot function, users need to supply several parameters:
1. Source: An array of floating-point values representing the indicator values to display.
2. Name: An array of strings representing the names of the indicators.
3. Boxes_per_row: The number of boxes to display per row.
4. Offset (optional): An integer to offset the boxes horizontally (default: 0).
5. Scale (optional): A floating-point value to scale the size of the boxes (default: 1).
The library also includes a gradient function (grad) that is used to generate the colors for the heatmap. This function is responsible for determining the appropriate color based on the value of the indicator, with higher values typically represented by warmer colors such as red and lower values by cooler colors such as blue.
Implementing Heatmaps as a Pine Script Library
In this section, we'll explore how to create a Pine Script library that can be used to generate heatmaps for various indicators on the TradingView platform. The library utilizes colored boxes to represent the values of multiple indicators, making it simple to visualize complex data.
We'll now go over the key components of the code:
grad(src) function: This function takes an integer input 'src' and returns a color based on a predefined color gradient. The gradient ranges from dark blue (#1500FF) for low values to dark red (#FF0000) for high values.
boxes_plot() function: This is the main function of the library, and it takes the following parameters:
source: an array of floating-point values representing the indicator values to display
name: an array of strings representing the names of the indicators
boxes_per_row: the number of boxes to display per row
offset (optional): an integer to offset the boxes horizontally (default: 0)
scale (optional): a floating-point value to scale the size of the boxes (default: 1)
The function first calculates the screen size and unit size based on the visible chart area. Then, it creates an array of box objects representing each data point. Each box is assigned a color based on the value of the data point using the grad() function. The boxes are then plotted on the chart using the box.new() function.
Example Usage:
In the example provided in the source code, we use the Relative Strength Index (RSI) and the Stochastic Oscillator as the input data for the heatmap. We create two arrays, 'data_1' containing the RSI and Stochastic Oscillator values, and 'data_names_1' containing the names of the indicators. We then call the 'boxes_plot()' function with these arrays, specifying the desired number of boxes per row, offset, and scale.
Conclusion
Heatmaps are a versatile and powerful data visualization tool with a rich history, spanning multiple fields of study. By implementing a heatmap library in Pine Script, we can enhance the capabilities of the TradingView platform, making it easier for users to visualize and understand complex financial data. The provided library can be easily customized and extended to suit various use cases and can be a valuable addition to any trader's toolbox.
Library "Boxes_Plot"
boxes_plot(source, name, boxes_per_row, offset, scale)
Parameters:
source (float ) : - an array of floating-point values representing the indicator values to display
name (string ) : - an array of strings representing the names of the indicators
boxes_per_row (int) : - the number of boxes to display per row
offset (int) : - an optional integer to offset the boxes horizontally (default: 0)
scale (float) : - an optional floating-point value to scale the size of the boxes (default: 1)
CurrentlyPositionIndicatorLibrary "CurrentlyPositionIndicator"
Currently position indicator
run(_index, _price, _stoploss, _high, _low, _side, _is_entered, _colors, _position_left, _box_width)
Currently positions indicator
Parameters:
_index (int) : entry index
_price (float) : entry price
_stoploss (float) : stoploss price
_high (float) : range high
_low (float) : range low
_side (int)
_is_entered (bool) : is entered
_colors (color ) : color array
_position_left (int) : Left position
_box_width (int) : box's width
Returns: TODO: add what function returns
ObjectHelpersLibrary "ObjectHelpers"
Line | Box | Label | Linefill -- Maker, Setter, Getter Library
TODO: add table functionality
set(object)
set all params for `line`, `box`, `label`, `linefill` objects with 1 function
***
## Overloaded
***
```
method set(line Line, int x1=na, float y1=na, int x2=na, float y2=na,string xloc=na,string extend=na,color color=na,string style=na,int width=na,bool update=na) => line
```
### Params
- **Line** `line` - line object | `required`
- **x1** `int` - value to set x1
- **y1** `float` - value to set y1
- **x2** `int` - value to set x2
- **y2** `float` - value to set y2
- **xloc** `int` - value to set xloc
- **yloc** `int` - value to set yloc
- **extend** `string` - value to set extend
- **color** `color` - value to set color
- **style** `string` - value to set style
- **width** `int` - value to set width
- **update** `bool` - value to set update
***
```
method set(box Box,int left=na,float top=na,int right=na, float bottom=na,color bgcolor=na,color border_color=na,string border_style=na,int border_width=na,string extend=na,string txt=na,color text_color=na,string text_font_family=na,string text_halign=na,string text_valign=na,string text_wrap=na,bool update=false) => box
```
### Params
- **Box** `box` - box object
- **left** `int` - value to set left
- **top** `float` - value to set top
- **right** `int` - value to set right
- **bottom** `float` - value to set bottom
- **bgcolor** `color` - value to set bgcolor
- **border_color** `color` - value to set border_color
- **border_style** `string` - value to set border_style
- **border_width** `int` - value to set border_width
- **extend** `string` - value to set extend
- **txt** `string` - value to set _text
- **text_color** `color` - value to set text_color
- **text_font_family** `string` - value to set text_font_family
- **text_halign** `string` - value to set text_halign
- **text_valign** `string` - value to set text_valign
- **text_wrap** `string` - value to set text_wrap
- **update** `bool` - value to set update
***
```
method set(label Label,int x=na,float y=na, string txt=na,string xloc=na,color color=na,color textcolor=na,string size=na,string style=na,string textalign=na,string tooltip=na,string text_font_family=na,bool update=false) => label
```
### Paramas
- **Label** `label` - label object
- **x** `int` - value to set x
- **y** `float` - value to set y
- **txt** `string` - value to set text add`"+++"` to the _text striing to have the current label text concatenated to the location of the "+++")
- **textcolor** `color` - value to set textcolor
- **size** `string` - value to set size
- **style** `string` - value to set style (use "flip" ,as the style to have label flip to top or bottom of bar depending on if open > close and vice versa)
- **text_font_family** `string` - value to set text_font_family
- **textalign** `string` - value to set textalign
- **tooltip** `string` - value to set tooltip
- **update** `bool` - update label to next bar
***
```
method set(linefill Linefill=na,line line1=na,line line2=na,color color=na) => linefill
```
### Params
- **linefill** `linefill` - linefill object
- **line1** `line` - line object
- **line2** `line` - line object
- **color** `color` - color
Parameters:
object (obj)
Returns: `line`, `box`, `label`, `linefill`
method set(Line, x1, y1, x2, y2, xloc, extend, color, style, width, update)
set the location params of a line with 1 function auto detects time or bar_index for xloc param
Namespace types: series line
Parameters:
Line (line) : `line` - line object | `required`
x1 (int) : `int` - value to set x1
y1 (float) : `float` - value to set y1
x2 (int) : `int` - value to set x2
y2 (float) : `float` - value to set y2
xloc (string) : `int` - value to set xloc
extend (string) : `string` - value to set extend
color (color) : `color` - value to set color
style (string) : `string` - value to set style
width (int) : `int` - value to set width
update (bool) : `bool` - value to set update
Returns: `line`
method set(Box, left, top, right, bottom, bgcolor, border_color, border_style, border_width, extend, txt, text_color, text_font_family, text_halign, text_valign, text_wrap, update)
set the location params of a box with 1 function
Namespace types: series box
Parameters:
Box (box) : `box` - box object | `required`
left (int) : `int` - value to set left
top (float) : `float` - value to set top
right (int) : `int` - value to set right
bottom (float) : `float` - value to set bottom
bgcolor (color) : `color` - value to set bgcolor
border_color (color) : `color` - value to set border_color
border_style (string) : `string` - value to set border_style
border_width (int) : `int` - value to set border_width
extend (string) : `string` - value to set extend
txt (string) : `string` - value to set _text
text_color (color) : `color` - value to set text_color
text_font_family (string) : `string` - value to set text_font_family
text_halign (string) : `string` - value to set text_halign
text_valign (string) : `string` - value to set text_valign
text_wrap (string) : `string` - value to set text_wrap
update (bool) : `bool` - value to set update
Returns: `box`
method set(Label, x, y, txt, xloc, color, textcolor, size, style, textalign, tooltip, text_font_family, update)
set the location params of a label with 1 function auto detects time or bar_index for xloc param
Namespace types: series label
Parameters:
Label (label) : `label` | `required`
x (int) : `int` - value to set x
y (float) : `float` - value to set y
txt (string) : `string` - value to set text add`"+++"` to the _text striing to have the current label text concatenated to the location of the "+++")
xloc (string)
color (color)
textcolor (color) : `color` - value to set textcolor
size (string) : `string` - value to set size
style (string) : `string` - value to set style (use "flip" ,as the style to have label flip to top or bottom of bar depending on if open > close and vice versa)
textalign (string) : `string` - value to set textalign
tooltip (string) : `string` - value to set tooltip
text_font_family (string) : `string` - value to set text_font_family
update (bool) : `bool` - update label to next bar
Returns: `label`
method set(Linefill, line1, line2, color)
change the 1 or 2 of the lines in a linefill object
Namespace types: series linefill
Parameters:
Linefill (linefill)
line1 (line) : `line` - line object
line2 (line) : `line` - line object
color (color) : `color` - color
Returns: `linefill`
get(object)
get all of the location variables for `line`, `box`, `label` objects or the line objects from a `linefill`
***
## Overloaded
***
```
method get(line Line) =>
```
### Params
- **Line** `line` - line object | `required`
***
```
method get(box Box) =>
```
### Params
- **Box** `box` - box object | `required`
***
```
method get(label Label) =>
```
### Paramas
- **Label** `label` - label object | `required`
***
```
method get(linefill Linefill) =>
```
### Params
- **Linefill** `linefill` - linefill object | `required`
Parameters:
object (obj)
Returns: ` `
method get(Line)
Gets the location paramaters of a Line
Namespace types: series line
Parameters:
Line (line) : `line` - line object
Returns:
method get(Box)
Gets the location paramaters of a Box
Namespace types: series box
Parameters:
Box (box) : `box` - box object
Returns:
method get(Label)
Gets the `x`, `y`, `text` of a Label
Namespace types: series label
Parameters:
Label (label) : `label` - label object
Returns:
method get(Linefill)
Gets `line 1`, `line 2` from a Linefill
Namespace types: series linefill
Parameters:
Linefill (linefill) : `linefill` - linefill object
Returns:
method set_x(Line, x1, x2)
set the `x1`, `x2` of a line
***
### Params
- **Line** `line` - line object | `required`
- **x1** `int` - value to set x1 | `required`
- **x2** `int` - value to set x2 | `required`
Namespace types: series line
Parameters:
Line (line) : `line` - line object
x1 (int) : `int` - value to set x1
x2 (int) : `int` - value to set x2
Returns: `line`
method set_y(Line, y1, y2)
set `y1`, `y2` of a line
***
### Params
- **Line** `line` - line object | `required`
- **y1** `float` - value to set y1 | `required`
- **y2** `float` - value to set y2 | `required`
Namespace types: series line
Parameters:
Line (line) : `line` - line object
y1 (float) : `float` - value to set y1
y2 (float) : `float` - value to set y2
Returns: `line`
method Line(x1, y1, x2, y2, extend, color, style, width)
Similar to `line.new()` but can detect time or bar_index for xloc param and has defaults for all params but `x1`, `y1`, `x2`, `y2`
***
### Params
- **x1** `int` - value to set
- **y1** `float` - value to set
- **x2** `int` - value to set
- **y2** `float` - value to set
- **extend** `string` - extend value to set line
- **color** `color` - color to set line
- **style** `string` - style to set line
- **width** `int` - width to set line
Namespace types: series int, simple int, input int, const int
Parameters:
x1 (int) : `int` - value to set
y1 (float) : `float` - value to set
x2 (int) : `int` - value to set
y2 (float) : `float` - value to set
extend (string) : `string` - extend value to set line
color (color) : `color` - color to set line
style (string) : `string` - style to set line
width (int) : `int` - width to set line
Returns: `line`
method Box(left, top, right, bottom, extend, border_color, bgcolor, text_color, border_width, border_style, txt, text_halign, text_valign, text_size, text_wrap)
similar to box.new() with the but can detect xloc param and has defaults for everything but location params
***
### Params
- **left** `int` - value to set
- **top** `float` - value to set
- **right** `int` - value to set
- **bottom** `float` - value to set
- **extend** `string` - extend value to set box
- **border_color** `color` - color to set border
- **bgcolor** `color` - color to set background
- **text_color** `color` - color to set text
- **border_width** `int` - width to set border
- **border_style** `string` - style to set border
- **txt** `string` - text to set
- **text_halign** `string` - horizontal alignment to set text
- **text_valign** `string` - vertical alignment to set text
- **text_size** `string` - size to set text
- **text_wrap** `string` - wrap to set text
Namespace types: series int, simple int, input int, const int
Parameters:
left (int) : `int` - value to set
top (float) : `float` - value to set
right (int) : `int` - value to set
bottom (float) : `float` - value to set
extend (string) : `string` - extend value to set box
border_color (color) : `color` - color to set border
bgcolor (color) : `color` - color to set background
text_color (color) : `color` - color to set text
border_width (int) : `int` - width to set border
border_style (string) : `string` - style to set border
txt (string) : `string` - text to set
text_halign (string) : `string` - horizontal alignment to set text
text_valign (string) : `string` - vertical alignment to set text
text_size (string) : `string` - size to set text
text_wrap (string) : `string` - wrap to set text
Returns: `box`
method Label(txt, x, y, yloc, color, textcolor, style, size, textalign, text_font_family, tooltip)
Similar to label.new() but can detect time or bar_index for xloc param and has defaults for all params but x, y, txt, tooltip
***
### Params
- **txt** `string` - string to set
- **x** `int` - value to set
- **y** `float` - value to set
- **yloc** `string` - y location to set
- **color** `color` - label color to set
- **textcolor** `color` - text color to set
- **style** `string` - style to set
- **size** `string` - size to set
- **textalign** `string` - text alignment to set
- **text_font_family** `string` - font family to set
- **tooltip** `string` - tooltip to set
Namespace types: series string, simple string, input string, const string
Parameters:
txt (string) : `string` - string to set
x (int) : `int` - value to set
y (float) : `float` - value to set
yloc (string) : `string` - y location to set
color (color) : `color` - label color to set
textcolor (color) : `color` - text color to set
style (string) : `string` - style to set
size (string) : `string` - size to set
textalign (string) : `string` - text alignment to set
text_font_family (string) : `string` - font family to set
tooltip (string) : `string` - tooltip to set
Returns: `label`
obj
Fields:
obj (series__string)
Console📕 Console Library
🔷 Introduction
This script is an adaptation of the classic JavaScript console script. It provides a simple way to display data in a console-like table format for debugging purposes.
While there are many nice console/logger scripts out there, my personal goal was to achieve inline functionality and visual object (label, lines) logging .
🔷 How to Use
◼ 1. Import the Console library into your script:
import cryptolinx/Console/1
- or -
Instead of the library namespace, you can define a custom namespace as alias.
import cryptolinx/Console/1 as c
◼ 2. Create and init a new `` object.
The `init()` method is used to initialize the console object with default settings. It can be used to customize it.
// When using the `var` keyword in a declaration, the logs will act as ever-forwarding.
// Without `var`, the `console` variable will be redeclared every time `bar` is called.
// var console = Console.terminal.new(log_position=position.bottom_left, prefix = '> ', show_no = true)
- or -
If you has set up an alias before.
var console = c.terminal.new().init()
◼ 3. Logging
// inline ✨
array testArray = array.new(3, .0).log(console)
// basic
console.log(testArray)
// inline ✨
var testLabel = label.new(bar_index, close, 'Label Text').log(console)
// basic
console.log(testLabel)
// It is also possible to use `().` for literals ✨.
int a = 100
testCalc = (5 * 100).log(console) + a.log(console) // SUM: 600
console.
.empty()
.log('SUM' + WS + testCalc.tostring())
◼ 4. Visibility
Finally, we need to call the `show()` method to display the logged messages in the console.
console.show(true) // True by default. Simply turn it on or off
new_line_dot_3Library "new_line"
TODO: plot line based on 3 points.
new_line(x_1, x_2, x_3, y_1, y_2, y_3)
TODO: plot line based on 3 points. (each different)
Parameters:
x_1 (int)
x_2 (int)
x_3 (int)
y_1 (float)
y_2 (float)
y_3 (float)
Returns: TODO: new line based on each different 3 values.
UtilsLibrary "Utils"
Utility functions. Mathematics, colors, and auxiliary algorithms.
setTheme(vc, theme)
Set theme for levels (predefined colors).
Parameters:
vc : (valueColorSpectrum) Object to associate a color with a value, taking into account the previous value and its levels.
theme : (int) Theme (predefined colors).
0 = 'User defined'
1 = 'Spectrum Blue-Green-Red'
2 = 'Monokai'
3 = 'Green'
4 = 'Purple'
5 = 'Blue'
6 = 'Red'
Returns: (void)
setTheme(vc, colorLevel_Lv1, colorLevel_Lv1_Lv2, colorLevel_Lv2_Lv3, colorLevel_Lv3_Lv4, colorLevel_Lv4_Lv5, colorLevel_Lv5)
Set theme for levels (customized colors).
Parameters:
vc : (valueColorSpectrum) Object to associate a color with a value, taking into account the previous value and its levels
colorLevel_Lv1 : (color) Color associeted with value when below Level 1.
colorLevel_Lv1_Lv2 : (color) Color associeted with value when between Level 1 and 2.
colorLevel_Lv2_Lv3 : (color) Color associeted with value when between Level 2 and 3.
colorLevel_Lv3_Lv4 : (color) Color associeted with value when between Level 3 and 4.
colorLevel_Lv4_Lv5 : (color) Color associeted with value when between Level 4 and 5.
colorLevel_Lv5 : (color) Color associeted with value when above Level 5.
Returns: (void)
setCurrentColorValue(vc)
Set color to a current value, taking into account the previous value and its levels
Parameters:
vc : (valueColorSpectrum) Object to associate a color with a value, taking into account the previous value and its levels
Returns: (void)
setCurrentColorValue(vc, gradient)
Set color to a current value, taking into account the previous value.
Parameters:
vc : (valueColor) Object to associate a color with a value, taking into account the previous value
gradient
Returns: (void)
setCustomLevels(vc, level1, level2, level3, level4, level5)
Set boundaries for custom levels.
Parameters:
vc : (valueColorSpectrum) Object to associate a color with a value, taking into account the previous value and its levels
level1 : (float) Boundary for level 1
level2 : (float) Boundary for level 2
level3 : (float) Boundary for level 3
level4 : (float) Boundary for level 4
level5 : (float) Boundary for level 5
Returns: (void)
getPeriodicColor(originalColor, density)
Returns a periodic color. Useful for creating dotted lines for example.
Parameters:
originalColor : (color) Original color.
density : (float) Density of color. Expression used in modulo to obtain the integer remainder.
If the remainder equals zero, the color appears, otherwise it remains hidden.
Returns: (color) Periodic color.
dinamicZone(source, sampleLength, pcntAbove, pcntBelow)
Get Dynamic Zones
Parameters:
source : (float) Source
sampleLength : (int) Sample Length
pcntAbove : (float) Calculates the top of the dynamic zone, considering that the maximum values are above x% of the sample
pcntBelow : (float) Calculates the bottom of the dynamic zone, considering that the minimum values are below x% of the sample
Returns: A tuple with 3 series of values: (1) Upper Line of Dynamic Zone;
(2) Lower Line of Dynamic Zone; (3) Center of Dynamic Zone (x = 50%)
valueColorSpectrum
# Object to associate a color with a value, taking into account the previous value and its levels.
Fields:
currentValue
previousValue
level1
level2
level3
level4
level5
currentColorValue
colorLevel_Lv1
colorLevel_Lv1_Lv2
colorLevel_Lv2_Lv3
colorLevel_Lv3_Lv4
colorLevel_Lv4_Lv5
colorLevel_Lv5
theme
valueColor
# Object to associate a color with a value, taking into account the previous value
Fields:
currentValue
previousValue
currentColorValue
colorUp
colorDown
Commission-aware Trade LabelsCommission-aware Trade Labels
Description:
This library provides an easy way to visualize take-profit and stop-loss levels on your chart, taking into account trading commissions. The library calculates and displays the net profit or loss, along with other useful information such as risk/reward ratio, shares, and position size.
Features:
Configurable take-profit and stop-loss prices or percentages.
Set entry amount or shares.
Calculates and displays the risk/reward ratio.
Shows net profit or loss, considering trading commissions.
Customizable label appearance.
Usage:
Add the script to your chart.
Create an Order object for take-profit and stop-loss with desired configurations.
Call target_label() and stop_label() methods for each order object.
Example:
target_order = Order.new(take_profit_price=27483, stop_loss_price=28000, shares=0.2)
stop_order = Order.new(stop_loss_price=29000, shares=1)
target_order.target_label()
stop_order.stop_label()
This script is a powerful tool for visualizing your trading strategy's performance and helps you make better-informed decisions by considering trading commissions in your profit and loss calculations.
Library "tradelabels"
entry_price(this)
Parameters:
this : Order object
@return entry_price
take_profit_price(this)
Parameters:
this : Order object
@return take_profit_price
stop_loss_price(this)
Parameters:
this : Order object
@return stop_loss_price
is_long(this)
Parameters:
this : Order object
@return entry_price
is_short(this)
Parameters:
this : Order object
@return entry_price
percent_to_target(this, target)
Parameters:
this : Order object
target : Target price
@return percent
risk_reward(this)
Parameters:
this : Order object
@return risk_reward_ratio
shares(this)
Parameters:
this : Order object
@return shares
position_size(this)
Parameters:
this : Order object
@return position_size
commission_cost(this, target_price)
Parameters:
this : Order object
@return commission_cost
target_price
net_result(this, target_price)
Parameters:
this : Order object
target_price : The target price to calculate net result for (either take_profit_price or stop_loss_price)
@return net_result
create_take_profit_label(this, prefix, size, offset_x, bg_color, text_color)
Parameters:
this
prefix
size
offset_x
bg_color
text_color
create_stop_loss_label(this, prefix, size, offset_x, bg_color, text_color)
Parameters:
this
prefix
size
offset_x
bg_color
text_color
create_entry_label(this, prefix, size, offset_x, bg_color, text_color)
Parameters:
this
prefix
size
offset_x
bg_color
text_color
create_line(this, target_price, line_color, offset_x, line_style, line_width, draw_entry_line)
Parameters:
this
target_price
line_color
offset_x
line_style
line_width
draw_entry_line
Order
Order
Fields:
entry_price : Entry price
stop_loss_price : Stop loss price
stop_loss_percent : Stop loss percent, default 2%
take_profit_price : Take profit price
take_profit_percent : Take profit percent, default 6%
entry_amount : Entry amount, default 5000$
shares : Shares
commission : Commission, default 0.04%
L_Trade_BoundariesLibrary "L_Trade_Boundaries"
Trade Boundaries suggest a strength of the security with respect to previous lows. The "L" implies library, and the trade boundaries implies it could be utilized for price strengths. Though, this should not be used as a single parameter to trade wildly. This library can be imported to a custom indicator to utilized the custom functions. There are moving averages attached at the bottom right of the canvas (overlay) to benchmark the closing price with respect to Moving Averages: 20, 28, and 200 (i.e., "D" if timeframe == "D") respectively. The Volume Indicator located at the top of the canvas is a default function (function already made by the trading view) this shows the volume with respect to the selected time frame. All of the indicators tell a story with regard to the security price (in strength terms).
What is available in this Library?
Litmus Color
> This is a function will change color of two numbers, if the first number is less than the second, the color will be red; otherwise, the color will be green.
Lister
> This is simply using an array by revisiting previous lows and plotting to the current time frame (i.e., "D"). There is a custom frequency input for the function, it will go back as much as the implied/specified length. Note: I am still learning how to use array, use this function with discretion. I would also appreciate if there are suggestions commented below.
Moving Average
> This function invokes three moving average metrics: 20, 28, and 200 respectively. The values are displayed at the bottom right of the canvas.
Timeframe Highlight
> This function checks for the input timeframe (i.e., "D", "W", "M") and if the time frame happens to be the same, it will give a "true" result. This result can be utilized for highlighting the positive results on the canvas (the red lines).
litmus_color(value1, value2)
Parameters:
value1
value2
lister(length)
Parameters:
length
moving_averages()
timeframe_highlight(timeframe)
Parameters:
timeframe
ThemeLibraryLibrary "ThemeLibrary"
TODO: add library description here
theme(_theme)
: a library of themed colors
Parameters:
_theme : : the theme color to fetch
Returns: : an array of colors
Drawings_publicLibrary "Drawings_public"
: Functions to manage drawings on the chart
extend_line(lineId, labelId)
: Extend specific line with its label
Parameters:
lineId
labelId
update_line_coordinates(lineId, labelId, x1, y1, x2, y2)
: Update specific line coordinates with its label
Parameters:
lineId
labelId
x1
y1
x2
y2
update_label_coordinates(labelId, value)
: Update coordinates of a label
Parameters:
labelId
value
delete_line(lineId, labelId)
: Delete specific line with its label
Parameters:
lineId
labelId
update_box_coordinates(boxId, labelId, left, top, right, bottom)
: Update specific box coordinates with its label
Parameters:
boxId
labelId
left
top
right
bottom
delete_box(boxId, labelId)
: Delete specific box with its label
Parameters:
boxId
labelId
TableBuilderLibrary "TableBuilder"
A helper library to make it simpler to create tables in pinescript
This is a simple table building library that I created because I personally feel that the built-in table building method is too verbose. It features chaining methods and variable arguments.
There are many features that are lacking because the implementation is early, and there may be antipatterns because I am not familiar with the runtime behavior like pinescript. If you have any comments on code improvements or features you want, please comment :D
WarCalendarLibrary "WarCalendar"
This library is a data provider for important Dates and Times from the Economic Calendar.
events()
Returns the list of dates supported by this library as a string array.
Returns: array : Names of events supported by this library
warstart()