0

I'm looking at the version 4 documentation (https://www.tradingview.com/pine-script-docs/en/v4/index.html and I'm not sure I'm finding what I need:

I'd like to have a function which, for some price P, determines the number of times the real price p crossed that value within the most recent candle.

Ex. if price P was above high / below low, then crossing number of C(p,P)=0.

Ex2. if price p was monotonic, then for any P in the candle, C(p,P)= 1.

Simson
  • 3,373
  • 2
  • 24
  • 38
bmf
  • 55
  • 1
  • 7
  • Have you tried using a counter? What have you tried? – vitruvius Feb 09 '20 at 18:44
  • There's no ability to found out how many times an event happened (even number of trades) on a candle. – Michel_T. Feb 09 '20 at 19:04
  • @Michael_T. Do you mean on a candle or also equivalently during a period of time specified by the user. Trades by whom? – bmf Feb 09 '20 at 19:18
  • 1
    You're best guess is zooming in the chart time. For instance, if you're looking at 15min chart, change it to 1min and there will be 15 extra data points from which you can try to figure out how many crosses occurred within a 15 min bar. Other than this option, I agree with @Michel_T: there is no such ability – Glauco Esturilio Feb 10 '20 at 08:49
  • This is a great resource: You will need to use var with some variables to capture your highs and lows, then you can reference these later as a crossover like an indicator. So the same way you would que ma crossovers and such. The link below is a great resource to use. https://backtest-rookies.com/2018/04/06/tradingview-track-when-something-happened/ – JG IV Oct 09 '21 at 18:13
  • crosses = cross(a, b) then do a for loop in crosses – nurettin Mar 18 '22 at 13:19

0 Answers0