A Problem of Prediction with Decision Tree We know, roughly speaking, the algorithm of decision tree is like an approximation with piecewise constants.
For example, suppose we have a function $f$ from $[0,1]$ to $\mathbb R$. Then we can use decision tree to approximate it, i.e. using piecewise constant functions to approximate it. The trained model can tell us an output for any given input $a\in [0,1]$. But it cannot predict an output for an input $b\in [2,3]$.
Now, let us take the $x$-axis as time and the $y$-axis as stock price. Suppose the time interval is $[1,100]$, where every integer means one day. Then by doing decision tree, we will have a model. But this model can only be used to predict the stock price of any time in $[1,100]$, not for the future. That's, we cannot use it to predict the stock price at time $101$, which is outside $[1,100]$.
But there are people using decision tree to predict the stock prices. Why can they make sense of the reasoning? [I tried to read their sample codes but without clear comments along with them I couldn't really understand the logics.]
Thanks for helping me make sense of the logics.

As also pointed out in the comments section, time is usually not in your feature list when you do time series prediction with tree-based algorithms.
Typical features are target values at previous time instants, other hand crafted features like  weekend, evening indicators etc.
