Docs

ITMScript

List the crosses in a table

Record each cross of two averages as a row in a table, with the close and the gap between the averages.

Record each cross of two averages as a row, with the close and the gap between the averages on that bar.

itm
//@itmscript 2
study("Cross log", overlay=true)
fastLen = input.int(9, "Fast length", min=2, max=200)
slowLen = input.int(21, "Slow length", min=3, max=500)
fast = ta.ema(close, fastLen)
slow = ta.ema(close, slowLen)
plot(fast, "Fast", color=color.blue, width=1, style=line)
plot(slow, "Slow", color=color.orange, width=1, style=line)
events(ta.crossover(fast, slow), "Crosses up", close=close, gap=fast - slow, sort=-t, limit=20)
events(ta.crossunder(fast, slow), "Crosses down", close=close, gap=fast - slow, sort=-t, limit=20)

What you see

The two averages are drawn over the candles. The study also builds two tables, one for crosses up and one for crosses down. A row has the bar time, the close and the gap between the averages. The newest row is first and each table holds at most 20 rows.

The tables are not drawn on the chart. The Outputs group of the builder chooses where each one is shown.

Change these inputs

  • Fast length. The window of the fast average, from 2 to 200 bars.
  • Slow length. The window of the slow average, from 3 to 500 bars.

The row limit is written in the script. Change limit=20 to keep more or fewer rows, from 1 to 1000.