Problem executing a condition in PineScript

16 Views Asked by At

I encounter the following problem, I have the following constant:

opTime = bbr > 1 buyZone = bbr < 0 sellZone = bbr <= 0.5 and bbr >= 0.48

I don't think it's necessary to explain it, but to make the post clearer I'll do it without any problem: :)

enter image description here

In the image you can see 2 highlights in the graph, one green and one red, basically what I am trying to achieve is that when the line crosses a value, I plot green and when it passes by the other place I mark red without taking into account the red lines that are close to the green ones

Basically, what I want to achieve is that it executes in the following order:

  1. When a downward crossover of 0% occurs, buyZone is executed.
  2. The line is held in opTime making sure I crossed 100%.
  3. When the line goes down again and crosses 50%, sellZone is executed and plots the red line.

The problem from what I understand is in sellZone, which I can't find a way for it to take opTime into account as the first instance and if it is fulfilled, only at the end do I run it. This is PineScript by the way

Sorry my English, it's not the best haha

sellZone = (bbr > 0)[2] and (bbr <= 0.5 and bbr >= 0.48)[1] (no funciona como deberia)

0

There are 0 best solutions below