Hello everyone I just can't fix a problem. I have signal code like that:
crossingrule = ta.crossover(line1,line2 ) or ta.crossunder (line1, line2) ? color.lime :color.orange
but when I check this on the screen. It gives me only the last bar's condition.
I want this code to scan last 5 days or like 2 days. how can I add a code what should I write and where)?
I found a code like barssince and it works but I don't want bars to be counted I want a specific time like "last 5 days". not "last 5 bars"
ta.crossover(Buy1,buy2)
returns True if:
Buy1
was lower than the value of the Series buy2
Buy1
is higher than the value of the Series buy2
This means the value of Buy1
has crossed over the value of buy2
.
Extending upon your comment I suggest a mechanical approach (especially if you are new to Pine).
To check for crossover on the current day, you'd use ta.crossover(Buy1,buy2)
as above. To check if a crossover happened a day ago (provided you are on the Daily chart), you can do either:
- ta.crossover(Buy1[1],buy2[1]) OR
- ta.crossover(Buy1,buy2)[1] // I suggest this one
The crossover two days ago will be ta.crossover(Buy1,buy2)[2]
and you get the idea for the rest. You can chain together a large condition or you can show the last 5 days on a row in your table.