Suggestion: steps since trade entered

I would be since to know how many steps have past since the last trade was entered (either long or short).
With this we can get the data set at the time a position was opened. This or any data set in between are of higher interest.

What do you think?

We’ll be adding a builtin function soon which gives you the number of bars since a condition was last true. That should help? You can feed it your entry/exit rules as parameter.

You can write one up yourself if you don’t want to wait, of course.

It will be similar to Consecutive

If I do even very simple loops with basic checks they easily exceed the time limit. But when I use built-in functions they run fast and never blow the limit.

Even when I copy the internals of a built-in function from the documenttion and run it, it runs into the limit very very fast.
Looks like the built-in functions are somewhat pre-compiled and run much faster compared to the script.

I guess something like Consecutive to find the last truthy condition is a good approach.

This is coming as a built-in today:

1 Like

Now that I’m using this function I realise that it doesn’t help if the condition is also true at a time after the position has been opened.

My original goal was to detect higher lows after a buy position has opened (and vice versa) to secure wins.

I dont know if its possible within the current API (you’ll have to ask Nikola - he’s very helpful!) but at some point in the future if there is a “is open” variable to indicate you have a current open position, then this being true could feed into the counter condition (using the “not” desciptor as you want it false rather than true) so that the counter only resets once the entry conditions are met AND a position is not currently open…

may work, may not…? food for thought either way

Would be great to have some flag. Let’s wait then.