Tim F
Tim F

Reputation: 1

Pine script horizontal line triggers

I have made a script to plot horizontal lines as a study with area below them, like this:

source = close
hline(215 or 375)

buyEntry = crossover(source, 215)
sellEntry = crossover(source, 375)

But it seems silly to do that for every order and line. I currently have about 200 lines that I want to have in the script.

So instead I would like the the script to look something like this:

Spot(275 or 275 or 275... ect)
Risk(215 or 315 or 415...ect)

buyEntry = crossover(source, Spot)
sellEntry = crossover(source, Risk)

This way with every 100$ a buy will trigger at the 15 level and sell at the 75 level.

Is there a simple way to do this? I can not figure out how to bundle all the vertical lines.

I already have a basic separate study to plot my horizontal lines by area like this:

plot(375, title="risk", style=area, color=#808080, transp=60, histbase=215)

If there is a way to make this easier? Also, I'm not allowed to have more than 64 plots and would like more.

Upvotes: 0

Views: 1698

Answers (1)

vitvlkv
vitvlkv

Reputation: 852

Unfortunately you cannot call 'hline' in a loop. And there is no way to expand the limit of 64 plots per script.

Maybe you should implement a little bit more complex logic in your code instead of coding 100500 plots/hlines?...

Upvotes: 1

Related Questions