Backtester in q

https://learninghub.kx.com/forums/topic/backtester-in-q

Good morning everyone,

I am trying to implement a backtesting engine in q, starting with a simple logic as described below:

  1. Generate a table with signals (a fast-moving average crossing above the slow-moving average indicates a long signal, and vice versa for a short signal).

  2. Position management -> Measure, at the moment the signal is generated, if the stop loss or take profit is reached first, assigning a positive or negative value depending on the result, assigning an order ID for each signal.

  3. Generate an equity line based on the results.

I am trying different approaches, but I still haven't found an efficient solution for part 2, which is position management.

Is there any article dedicated to this topic? Any advice on this? Unfortunately, I haven't found anything online that addresses these issues.

Thank you.

Hi @rgiu70

I have reached out to our team to see if there are any helpful articles/documents they would recommend.

In the meantime, I suggest you reach out to other users on our Slack community. Here you are able to get a more real-time response.

Many thanks,

Megan