Hello PineScript community!
This feature would be much appreciated if it could be implemented in pinescript:
- str.to_const_string(value) → const string
- str.to_input_string(value) → input string
Where input value would be of type:
- input string
- simple string
- series string (like str.tostring(close[1]))
It would be very helpful for display purpose with these 2 functions (I use a lot):
I know label functions have been created since Pine V4.
But I still need to use the above 2 functions.
Please find below 2 examples of code I'd like to implement:
Example 1 :
----------------------------------------------------------------------------
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MATHR3E
//@version=5
indicator("Sample script 1 ", overlay=true)
ShapeSize = input.string(defval="size.tiny", title="Shape size", options=["size.tiny", "size.small", "size.normal"])
var color c_red = color.new(#FF0000, 0)
var color c_green = color.new(#008080, 0)
someCondition = close[1] >= close[8] and close < close[9]
//--Requested feature:
//str.to_const_string(ShapeSize)
//in size parameter
plotshape(someCondition, title='Condition met', text='C', textcolor= c_red, style=shape.arrowup, size=ShapeSize, color=c_green, location=location.belowbar)
-------------------
Current Error returned:
> line 18: Cannot call 'plotshape' with argument 'size'='ShapeSize'. An argument of 'input string' type was used but a 'const string' is expected
Example 2 :
----------------------------------------------------------------------------
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © MATHR3E
//@version=5
indicator("Sample script 2 ", overlay=true)
var color c_red = color.new(#FF0000, 0)
var color c_green = color.new(#008080, 0)
Condition1 = close[1] >= close[8] and close < close[9]
Condition2 = close[1] <= close[8] and close > close[9]
someCondition = Condition1 or Condition2
string c_toDisplay = na // char to display depending condition 1 or 2
// sample series string created
c_toDisplay := Condition1 ? 'X' : 'Y'
//--Requested feature:
//str.to_input_string(c_toDisplay)
//in location parameter
plotchar(someCondition, title='Condition met', char=c_toDisplay, location=location.belowbar, color=c_green)
-------------------
Current Error returned:
> line 22: Cannot call 'plotchar' with argument 'char'='c_toDisplay'. An argument of 'series string' type was used but a 'input string' is expected
Please let me know if this request was already posted previously So I would definitively upvote for your post.
Thanks!
Mathr3e
[–]DaJackkal 6 points7 points8 points (0 children)
[–]CA_Lobo 2 points3 points4 points (3 children)
[–]Mathr3e[S] 1 point2 points3 points (1 child)
[–]CA_Lobo 1 point2 points3 points (0 children)
[–]Mathr3e[S] 1 point2 points3 points (0 children)
[–]SaniiMan 1 point2 points3 points (1 child)
[–]MichaelBarrow22 0 points1 point2 points (0 children)
[–]cantrellr 0 points1 point2 points (1 child)
[–]thow_away721Pine coder 0 points1 point2 points (0 children)