An easy way to output messages to a console like table using a a simple "print" function that can be called from anywhere in your code including functions.
█ Supports:
- Scrollable console messages - Customisable number of displayed messages - More than one "console" for different types of output if required - The ability to choose which message to start viewing from (useful if the message list is long) - The ability to place the console table at different positions on the chart to mitigate against overwriting an existing table.
█ Limitations: The "scrollbar" handle is actually a modified time widget handle. As the handle is grabbed and moved left or right across the chart bars, this script calculates the offset of the bar being pointed to from the last bar in the chart and uses that as the console message offset. However, It isn't possible to position this on the last chart bar with code. So there are two solutions: 1) Manually change timestamp of the variable scrollStart to the current time (roughly) eg. scrollStart = "25 Dec 2022 14:30 +0000" 2) Use a higher timeframe (Weeks or Months) and visually find the scroll bar. If it is to the right of the chart bars the console output will read NaN. Grab the handle and move it left and it will snap to the last chart candle position. If it is to the left then find it and move it to the right as needed.
█ Notes On Usage - Import the library as console (the call will be console.print(...) ) - Assign a console variable name and call the console.initialise function eg. var con1=console.initialise() - Use the console.print() function to print a message or messages This takes two parameters: _consoleName :this is the console name you are printing to _message: this is the message that you want to display. It is a string and can be built in the normal way using any pinescript string functions like str.tostring() etc - Use the console.display function to display the messages. To work as intended this display function should be placed at the last line with the following code if i_showMessages ....if i_displayTable == "con1" ........display(con1, i_lineOffset, i_rowsToDisplay, i_gotoMsg, posn)
(More "consoles" can be written to and the example code provided with the library shows this in more detail. Also, the indents don't show in these notes)
Lastly, placement of a console.print() without a qualifying "if" statement will occur for every bar. This may be desired. If not then use under an if statement (example in the supplied code).
initialise() initialise: creates the message array Parameters: none: Returns: message array: this is assigned to the "console" identifier
print(_consoleName, _message) used to output the desired text string to the console Parameters: _consoleName: : the message array _message: : the console message Returns: none
display(_consoleName, _lineOffset, _rowsToDisplay, _gotoMsg, _posn) display: placed in the last section of code. Displays the console messages Parameters: _consoleName: : the message array _lineOffset: : the setting of the scroll bar (time widget) _rowsToDisplay: : how many rows to show in the console table _gotoMsg: : which message to display from (default is 0) _posn: : where the console table will be displayed Returns: none
Dans le plus pur esprit TradingView, l'auteur a publié ce code Pine en tant que bibliothèque open-source afin que d'autres programmeurs Pine de notre communauté puissent le réutiliser. Bravo à l'auteur! Vous pouvez utiliser cette bibliothèque en privé ou dans d'autres publications à code source ouvert, mais la réutilisation de ce code dans une publication est régie par nos Règles.
Les informations et les publications ne sont pas destinées à être, et ne constituent pas, des conseils ou des recommandations en matière de finance, d'investissement, de trading ou d'autres types de conseils fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.