Reputation: 27
I want to add conditions in a timeframe.multiplier
I have try this code but the plot line is "Undeclared identifier"
I try to search the solution but i don't find.
indicator("My script")
// ————— Converts current chart timeframe into a float minutes value.
f_tfInMinutes() =>
_tfInMinutes = timeframe.multiplier * (
timeframe.isseconds ? 1. / 60 :
timeframe.isminutes ? 1. :
timeframe.isdaily ? 60. * 24 :
timeframe.isweekly ? 60. * 24 * 7 :
timeframe.ismonthly ? 60. * 24 * 30.4375 : na)
if f_tfInMinutes() == 15
float my_time = f_tfInMinutes() + 15
else if f_tfInMinutes() == 30
float my_time = f_tfInMinutes() + 30
else if f_tfInMinutes() == 60
float my_time = f_tfInMinutes() + 180
plot(my_time)
Thanks for your help
Upvotes: 0
Views: 350
Reputation: 6865
You have to declare the my_time
variable, and then assign values. Like this:
//@version=5
indicator("My script")
float my_time = na
// ————— Converts current chart timeframe into a float minutes value.
f_tfInMinutes() =>
_tfInMinutes = timeframe.multiplier * (
timeframe.isseconds ? 1. / 60 :
timeframe.isminutes ? 1. :
timeframe.isdaily ? 60. * 24 :
timeframe.isweekly ? 60. * 24 * 7 :
timeframe.ismonthly ? 60. * 24 * 30.4375 : na)
if f_tfInMinutes() == 15
my_time := f_tfInMinutes() + 15
else if f_tfInMinutes() == 30
my_time := f_tfInMinutes() + 30
else if f_tfInMinutes() == 60
my_time := f_tfInMinutes() + 180
plot(my_time)
Upvotes: 1