0
votes

I have a script that can plot many sell signals in a row and I want to number them if there is no buy signal in between the sell signals, so the first signal is p1sell, second is p2sell etc... if there is a buy signal then the count restarts.... any idea how to tackle this?

This is what I have so far, p1sell is correct but the other ones aren't-

//first sellsignal since buysignal
p1sell=barssince(SellSignal)<barssince(BuySignal) and barssince(SellSignal[1])>barssince(BuySignal)

//second sellsignal since first sellsignal without buysignal
p2sell=barssince(SellSignal)<barssince(BuySignal) and barssince(SellSignal[1])<barssince(BuySignal)

//third sellsignal since second sell signal without buysignal
p3sell=barssince(SellSignal)<barssince(BuySignal) and barssince(SellSignal[1])<barssince(BuySignal)
1
It's not too clear what you want to do. Can you please elaborate more your question? There is no sellA nor sellB in your example. Do you want to number sell signals, name them or count them? Please clarify - Glauco Esturilio
i want to count the number of consecutive sell signals and number them. If there is a buy signal in between the sell signals the count restarts - bckbymath

1 Answers

0
votes
//@version=4
study("", "", true)
condA = rising(close, 3)
condB = falling(close, 3)
var countB = 0
countB := condA ? 0 : condB ? countB + 1 : countB
plotchar(condA, "condA", "▲", location.top)
plotchar(condB, "condB", "▼", location.top)
plotchar(countB, "countB", "", location.top)