How select a value from a series and put it in an integer variable
I need to pick up a value from a series and put it in a hline().
-
Sevent months and not even a reply.
Is there any kind of coercion in Pine Script? -
-
Hi! Sorry, I think this topic has been lost. Really apologize.
You can pass to hline only literal numbers.
Everything you get from a series must be given to a plot() call not a hline().-
Hi, don't worry. I'have to delete my accounts on the forum and TView, how can i do?
-
-
-
-
-
For reference http://goo.gl/VLFkaE has a similar issue about type coercion.
-
-
-
-
//try function to convert or cast a series value to an integer or float
series_to_int(series_value) =>
func_var_int = 0 // cast as integer
//make mutable
func_var_int := floor(series_value)
func_var_int := round(func_var_int)-
I tried it and it returns a "type_unknown" ...
series_to_int(series_value) =>
func_var_int = 0 // cast as integer
//make mutable
func_var_int := floor(series_value)
func_var_int := round(func_var_int)
hline(series_to_int(round(close)))
Cannot call `hline` with arguments (type_unknown, color=const color); available overloads: hline(float, const string, color, integer, integer, const bool, string) => hline -
-
-
-
-
If it is loose typing, like JS, it is ok;
if it is strong typing, casting should work;
Please allow it work! -
-
TV seems less and less involved here. Starting to to read the top of this page as a disclaimer: "TradingView monitors but is not active in this community."
-
-
A second 5-year-old request for this elementary feature that every other language has, and nothing. :sad face:
-
-
hline() wasn't designed to accept a series, but this will work:
//@version=4
study("hline() replicant", overlay=true)
plot(close-1.0, color=#FF0000ff, trackprice=true, show_last=1, linewidth=2) -