# Machine learning - assigning a value to each tradable moment

I've been looking at machine learning trading strategies for some time and realized recently that I've been neglecting a very important part of the equation in terms of training an effective model.

In reading about other machine learning strategies, I've noticed that most strategies revolve around trading in and out at fixed durations, which 1) doesn't really reflect "real" trading and 2) probably makes finding a profitable strategy more difficult by imposing unnecessary time constraints.

For a model that more flexibly determines entries and exits (similar to a human trader), my thoughts are that the process can be broken down into three parts:

1. Determining input data: Recent prices, indicator values, etc.
2. Assigning a value at each point in time: This would be an attempt to distill future price movements down to a single value or a small number of values. For example, a value of 0.01 might imply that a 1% profit can be obtained by buying at a given point in time.
3. Determining trading rules given a trained model: This could include whether to use a stop loss, whether to rely on continuous model outputs or only use the model to determine the trade entry with a defined set of rules after the trade is opened, etc.

My focus has mainly been in #1, but I'm starting to think that #2 should be the starting point.

To illustrate an example, the value of the market at the first X below could be defined as the vertical distance between it and the second X since that's the maximum amount that could made on that trade given a threshold for determining swings and pivot points.

I've tried something like this but it struggles, I think because of the fact that the assigned value is not smooth and jumps when the peak is reached (i.e., the value changes from the distance from the current price to the peak, a small positive number, to the distance between the peak and the next trough, which would be a large negative number).

Another method I've tried is to assign a weighting to a forward looking range using a lognormal curve:

The idea is that a certain number of periods in the future is prioritized (i.e., the highest point in the curve - just above 2 in this example but realistically it would be something like 10+ if trying to trade with 1m bars) and the value assigned to each bar decreases over time after the peak. This actually does appear to work to a degree, but I don't think it's quite flexible enough.

I'd like to be able to combine the two approaches so that larger weightings are assigned to areas around peaks and troughs rather than at a fixed future point. Here's a rough example of what I mean, where each X represents a pivot point and the red line would represent the weights assigned at various points in time.

The idea is to prioritize peaks/troughs as these are opportunities to profit but assign greater values to pivot points where price stays near the point rather than a quick reversion. So in this example, even though the second X marking the peak is well above the first X and therefore shows large maximum gain potential, the price was not very stable around that point so the value assigned to the upswing would be discounted somewhat. By comparion, the first and last X are slightly more stable in that price spends more time around those points, which might imply a higher probability of profitably exiting short trades.

This is very open-ended and just one approach, but I would be curious to hear if anyone else has tried to address the question of assigning value for a flexible duration ML strategy. This is potentially unique to the ML problem since rule based strategies presumably don't go through a training process, but given the numerous articles out there about ML trading, it seems like a hugely undervalued aspect of building a successful strategy.