Given ohlcv
data such as
q) ohlcv
ticker time open high low close volume
------------------------------------------------------------------------
IBM 2024.04.08D09:15:00.000000000 2925.2 2930.15 2922 2929 38088
IBM 2024.04.08D09:16:00.000000000 2931 2935 2929.4 2933.3 33140
IBM 2024.04.08D09:17:00.000000000 2932.3 2934 2931.8 2933.9 18341
IBM 2024.04.08D09:18:00.000000000 2934.25 2934.3 2930.5 2930.5 16803
IBM 2024.04.08D09:19:00.000000000 2930.5 2932 2929.2 2931.45 33574
what’d be an efficient way of finding all the rows where if a trade was initiated, over the next n
bars (including the given entry bar), the profit at any time in the window exceeds a threshold p
, but before a negative loss limit l
is hit?