
\documentclass[11pt]{article}
\usepackage[margin=0.5in]{geometry}

% Core packages
\usepackage{amsmath,amssymb,enumitem}
\usepackage{tikz-cd}
\usepackage{multicol}

% Paragraphs
\setlength{\parindent}{0pt}
\setlength{\parskip}{1\baselineskip}

\title{Simulated Trades}
\author{algorembrant}
\date{\today}

\begin{document}
\maketitle

\begin{abstract}
This paper presents a comprehensive framework for generating simulated trade signals through lookahead analysis. We introduce a systematic methodology with mathematical formalization for calculating entry prices, stoploss levels, takeprofit targets, recovery prices, and adverse loss levels, along with their associated ratios. The framework employs a scoring system to determine valid trades and organizes the resulting data for use in reinforcement learning applications. Our approach provides a novel dataset structure that captures optimal price levels and timing information for each time index.
\end{abstract}

\section{Notations}

Let:
\begin{align*}
  t &= \text{be the \textcolor{red}{time-index}}\\
  \overrightarrow{t} &= \text{be the \textcolor{red}{time-index from lookahead}, where } \overrightarrow{t} \in \{t+n\}, \text{ with } n \in \{0,1,2,\ldots,\infty\},\\
  \overline{t} &= \text{be any time-index in between } t \text{ and } \overrightarrow{t} \text{, where } t \le \overline{t} \le \overrightarrow{t} \\
  E_t &= \text{be the \textcolor{red}{Entry Price} at } t \\
  \Omega_{\overrightarrow{t}} &= \text{be the \textcolor{red}{Stoploss Price} at } \overrightarrow{t} \\
  T_{\overrightarrow{t}} &= \text{be the \textcolor{red}{Takeprofit Price} at } \overrightarrow{t} \\
  R_{\overrightarrow{t}} &= \text{be the \textcolor{red}{Recovery Price} at } \overrightarrow{t} \\
  A_{\overrightarrow{t}} &= \text{be the \textcolor{red}{Adverseloss Price} at } \overrightarrow{t} \\
  Q_{\overrightarrow{t}} &= \text{be the \textcolor{red}{$A_{\overrightarrow{t}}:\Omega_{\overrightarrow{t}}$ Ratio} or Q-Ratio at } \overrightarrow{t} \\
  W_{\overrightarrow{t}} &= \text{be the \textcolor{red}{$R_{\overrightarrow{t}}:T_{\overrightarrow{t}}$ Ratio} or W-Ratio at } \overrightarrow{t} \\
  Y_{\overrightarrow{t}} &= \text{be the \textcolor{red}{$\Omega_{\overrightarrow{t}}:T_{\overrightarrow{t}}$ Ratio} or Y-Ratio at } \overrightarrow{t} \\
  V_t &= \{E_t, \Omega_{\overrightarrow{t}}, T_{\overrightarrow{t}}, R_{\overrightarrow{t}}, A_{\overrightarrow{t}}, Q_{\overrightarrow{t}}, W_{\overrightarrow{t}}, Y_{\overrightarrow{t}}\} \text{, be the \textcolor{red}{Set of all Values}, where values at } \overrightarrow{t} \text{ are carried by } t \\
  P &\in \{H,O,C,L\} = \text{be the \textcolor{red}{Price} with } \{ \text{High, Open, Close, Low} \} \text{ respectively} \\
  \Omega_t &= \text{be } \Omega_{\overrightarrow{t}} \text{ brought back to time-index } t \\
  T_t &= \text{be } T_{\overrightarrow{t}} \text{ brought back to time-index } t \\
  R_t &= \text{be } R_{\overrightarrow{t}} \text{ brought back to time-index } t \\
  A_t &= \text{be } A_{\overrightarrow{t}} \text{ brought back to time-index } t \\
  Q_t &= \text{be } Q_{\overrightarrow{t}} \text{ brought back to time-index } t \\
  W_t &= \text{be } W_{\overrightarrow{t}} \text{ brought back to time-index } t \\
  Y_t &= \text{be } Y_{\overrightarrow{t}} \text{ brought back to time-index } t \\
  V_t &= \{E_t, \Omega_t, T_t, R_t, A_t, Q_t, W_t, Y_t\} = \{E_t, \Omega_{\overrightarrow{t}}, T_{\overrightarrow{t}}, R_{\overrightarrow{t}}, A_{\overrightarrow{t}}, Q_{\overrightarrow{t}}, W_{\overrightarrow{t}}, Y_{\overrightarrow{t}}\} \\
  \mathcal{T}_t^{\text{null}} &= \text{be the null or invalid trade, representing no trade at time-index } t \\
  \mathcal{T}_t^{\text{valid}} &= \text{be the valid trade, representing an eligible trade (either buyside or sellside) at time-index } t \\
  J^T_{\overrightarrow{t}} &= \text{be the timeout time for Takeprofit target, from lookahead } \overrightarrow{t} \\
  J^R_{\overrightarrow{t}} &= \text{be the timeout time for Recovery target, from lookahead } \overrightarrow{t} \\
  F^T_{\overrightarrow{t}} &= \text{be the Close Price at timeout for Takeprofit target, from lookahead } \overrightarrow{t} \\
  F^R_{\overrightarrow{t}} &= \text{be the Close Price at timeout for Recovery target, from lookahead } \overrightarrow{t} \\
  J^T_t &= \text{be } J^T_{\overrightarrow{t}} \text{ brought back to time-index } t \\
  J^R_t &= \text{be } J^R_{\overrightarrow{t}} \text{ brought back to time-index } t \\
  F^T_t &= \text{be } F^T_{\overrightarrow{t}} \text{ brought back to time-index } t \\
  F^R_t &= \text{be } F^R_{\overrightarrow{t}} \text{ brought back to time-index } t
\end{align*}

\newpage

\section{Values at Time-Index $t$}

\subsection{Entry Price}

By default, we use a 3-minute timeframe. We always buy and sell at $E_t$ (we enter at the Open Price based on the previous bar's Close price, therefore $E_t = O_t$) at the same time-index.

\subsection{Stoploss Price}

We begin by calculating our \textcolor{red}{average of maximum imaginary adverse excursion}, formalized as:

\begin{align}
    \omega &= \frac{1}{K}\sum_{t=0}^{K-1} 
    \begin{cases}
        \max\left(O_{-t} - L_{-t},\; |O_{-t}-C_{-t-1}|,\; |L_{-t}-C_{-t-1}|\right), & \text{if } O_{-t} < C_{-t} \\[6pt]
        \max\left(|O_{-t} - H_{-t}|,\; |O_{-t}-C_{-t-1}|,\; |H_{-t}-C_{-t-1}|\right), & \text{if } O_{-t} > C_{-t}
    \end{cases}
\end{align}

This captures the average of wicks and gaps within the total lookback $\textcolor{blue}{K}$. The default value is $K=20$ with a step of $1$, which does not include high-low ranges.

Therefore, the stoploss placement is:

\begin{align}
    \Omega_t &= 
    \begin{cases} 
        O_t -(\omega_{t-1} \cdot s_t\cdot m), & \text{for } E_t^{\text{buyside}} \\[4pt] 
        O_t +(\omega_{t-1} \cdot s_t \cdot m), & \text{for } E_t^{\text{sellside}} 
    \end{cases}
    \quad \text{\textcolor{red}{Stoploss Price}}
\end{align}

Where $s_t$ is the live spread at the time-index provided by the broker in real time, and $\textcolor{blue}{m}$ is a multiplier. The default value is $m=10$ with a step of $5$. The index $-1$ from $\omega_{t-1}$ ensures our projected stoploss is valid and not exposed to lookahead bias.

\section{Values at Time-Index Lookahead $\overrightarrow{t}$}

\subsection{Recovery Price}

We calculate $P^{\text{extreme}}_{\overline{t}}$ as time moves forward:

\begin{align}
    P^{\text{extreme}}_{\overline{t}} =
    \begin{cases}
        \displaystyle\max_{t \le \overline{t} \le \overrightarrow{t}} [\max P_{\overline{t}}], & \text{for } E_t^{\text{buyside}} \\[10pt]
        \displaystyle\min_{t \le \overline{t} \le \overrightarrow{t}} [\min P_{\overline{t}}], & \text{for } E_t^{\text{sellside}}
    \end{cases}
    \quad \text{where } P_{\overline{t}} \in \{H_{\overrightarrow{t}}, O_{\overrightarrow{t}}, C_{\overrightarrow{t}}, L_{\overrightarrow{t}}\}
\end{align}

\begin{align}
    S_{\overrightarrow{t}} =
    \begin{cases}
        \left| \Omega_t - \displaystyle\max_{t \le \overline{t} \le \overrightarrow{t}} [\max P_{\overline{t}}] \right| \times d + \Omega_t, & \text{for } E_t^{\text{buyside}} \\[12pt]
        \left| \Omega_t - \displaystyle\min_{t \le \overline{t} \le \overrightarrow{t}} [\min P_{\overline{t}}] \right| \times d - \Omega_t, & \text{for } E_t^{\text{sellside}}
    \end{cases}
    \quad \text{Stop Criterion}
\end{align}

Where $\textcolor{blue}{d}$ is the divisor, with default value $d = 0.50$ and step $0.10$. The $S_{\overrightarrow{t}}$ serves as a criterion: if the price breaches the boundary, we register that time as:

\begin{align}
    R_{\overrightarrow{t}} = 
    \begin{cases}
        [\min P_{\overline{t}}] < S_{\overrightarrow{t}}^{\text{buyside}} \implies C_{\overrightarrow{t}}, & \text{for } E_t^{\text{buyside}} \\[6pt]
        [\max P_{\overline{t}}] > S_{\overrightarrow{t}}^{\text{sellside}} \implies C_{\overrightarrow{t}}, & \text{for } E_t^{\text{sellside}}
    \end{cases}
    \quad \text{\textcolor{red}{Recovery Price}}
\end{align}

\subsection{Takeprofit Price}

With $R_{\overrightarrow{t}}$ established, we calculate the optimal takeprofit levels:

\begin{align}
    T_{\overrightarrow{t}} =
    \begin{cases}
        \displaystyle\left(\max_{t_{E_t} \le \overline{t} \le \overrightarrow{t}_{R_{\overrightarrow{t}}}} [\max P_{\overline{t}}] \right) - (s_t \times l), & \text{for } E_t^{\text{buyside}} \\[12pt]
        \displaystyle\left(\min_{t_{E_t} \le \overline{t} \le \overrightarrow{t}_{R_{\overrightarrow{t}}}} [\min P_{\overline{t}}] \right) + (s_t \times l), & \text{for } E_t^{\text{sellside}}
    \end{cases}
    \quad \text{\textcolor{red}{Takeprofit Price}}
\end{align}

Where $l$ is a multiplier with default value $l = 2$ and step $1$.

\subsection{Adverse Price}

With $T_{\overrightarrow{t}}$ established, we calculate the optimal adverseloss levels:

\begin{align}
    A_{\overrightarrow{t}} =
    \begin{cases}
        \displaystyle\min_{t_{E_t} \le \overline{t} \le \overrightarrow{t}_{T_{\overrightarrow{t}}}} [\min P_{\overline{t}}], & \text{for } E_t^{\text{buyside}} \\[12pt]
        \displaystyle\max_{t_{E_t} \le \overline{t} \le \overrightarrow{t}_{T_{\overrightarrow{t}}}} [\max P_{\overline{t}}], & \text{for } E_t^{\text{sellside}}
    \end{cases}
    \quad \text{\textcolor{red}{Adverseloss Price}}
\end{align}

\subsection{Q-Ratio or $A_{\overrightarrow{t}}:\Omega_{\overrightarrow{t}}$ Ratio}

The ratio of Adverse Price to Stoploss Price is:

\begin{align}
    Q_{\overrightarrow{t}} = 
    \begin{cases}
        \left|\displaystyle\frac{E_t - A_{\overrightarrow{t}}^{\text{buyside}}}{E_t - \Omega_t^{\text{buyside}}} \right|, & \text{for } E_t^{\text{buyside}} \\[12pt]
        \left| \displaystyle\frac{E_t - A_{\overrightarrow{t}}^{\text{sellside}}}{E_t - \Omega_t^{\text{sellside}}} \right|, & \text{for } E_t^{\text{sellside}}
    \end{cases}
    \quad \text{\textcolor{red}{$A_{\overrightarrow{t}}:\Omega_{\overrightarrow{t}}$ Ratio}}
\end{align}

\subsection{W-Ratio or $R_{\overrightarrow{t}}:T_{\overrightarrow{t}}$ Ratio}

The ratio of Recovery Price to Takeprofit Price is:

\begin{align}
    W_{\overrightarrow{t}} = 
    \begin{cases}
        \left| \displaystyle\frac{E_t - R_{\overrightarrow{t}}^{\text{buyside}}}{E_t - T_{\overrightarrow{t}}^{\text{buyside}}} \right|, & \text{for } E_t^{\text{buyside}} \\[12pt]
        \left| \displaystyle\frac{E_t - R_{\overrightarrow{t}}^{\text{sellside}}}{E_t - T_{\overrightarrow{t}}^{\text{sellside}}} \right|, & \text{for } E_t^{\text{sellside}}
    \end{cases}
    \quad \text{\textcolor{red}{$R_{\overrightarrow{t}}:T_{\overrightarrow{t}}$ Ratio}}
\end{align}

\subsection{Y-Ratio or $\Omega_{\overrightarrow{t}}:T_{\overrightarrow{t}}$ Ratio}

The ratio of Stoploss Price to Takeprofit Price is:

\begin{align}
    Y_{\overrightarrow{t}} = 
    \begin{cases}
        \left| \displaystyle\frac{E_t - \Omega_t^{\text{buyside}}}{E_t - T_{\overrightarrow{t}}^{\text{buyside}}} \right|, & \text{for } E_t^{\text{buyside}} \\[12pt]
        \left| \displaystyle\frac{E_t - \Omega_t^{\text{sellside}}}{E_t - T_{\overrightarrow{t}}^{\text{sellside}}} \right|, & \text{for } E_t^{\text{sellside}}
    \end{cases}
    \quad \text{\textcolor{red}{$\Omega_{\overrightarrow{t}}:T_{\overrightarrow{t}}$ Ratio}}
\end{align}

\section{Set of Values at Time-Index $t$}

We construct $V_t$, the set of all values from time-index $t$ and time-index lookahead $\overrightarrow{t}$:

\begin{align}
    V_t = \{E_t, \Omega_{\overrightarrow{t}}, T_{\overrightarrow{t}}, R_{\overrightarrow{t}}, A_{\overrightarrow{t}}, Q_{\overrightarrow{t}}, W_{\overrightarrow{t}}, Y_{\overrightarrow{t}}\}, \quad \text{\textcolor{red}{Set of all Values}}
\end{align}

Note that $V$ has a time-index of $t$, carrying all values from both $t$ and $\overrightarrow{t}$. In dataframe terms, $V_t$ represents all values written in the same row as \{datetime, open, high, low, close, tick volume\} CSV variables.

This methodology lags more than conventional indicators; therefore, it is best used as a new form of dataset rather than a trading signal. For example, a dataset consisting of optimal price levels for ordering at a given time can be used to engineer the reward function of a Reinforcement Learning model.

\section{The Valid $V_t$ at Time-Index $t$}

\subsection{Deviating from $E_t$}

We find the deviation of price-based elements $\{\Omega_{\overrightarrow{t}}, T_{\overrightarrow{t}}, R_{\overrightarrow{t}}, A_{\overrightarrow{t}}\}$ from $E_t$. For an element $v$ of $V_t$:

\begin{align}
    \text{Dev}(v) =
    \begin{cases}
        \left| E_t - \Omega_{\overrightarrow{t}} \right|, & \text{Stoploss Deviation} \\
        \left| E_t - T_{\overrightarrow{t}} \right|, & \text{Takeprofit Deviation} \\
        \left| E_t - R_{\overrightarrow{t}} \right|, & \text{Recovery Deviation} \\
        \left| E_t - A_{\overrightarrow{t}} \right|, & \text{Adverse Deviation}
    \end{cases}
\end{align}

\subsection{Simplifying the Elements of $V_t$}

Since all elements with index $\overrightarrow{t}$ are carried back to the same time-index as $E_t$ (which is $t$), we simplify:

\begin{align}
    V_t = \{E_t, \Omega_{\overrightarrow{t}}, T_{\overrightarrow{t}}, R_{\overrightarrow{t}}, A_{\overrightarrow{t}}, Q_{\overrightarrow{t}}, W_{\overrightarrow{t}}, Y_{\overrightarrow{t}}\}
    \implies
    V_t = \{E_t, \Omega_t, T_t, R_t, A_t, Q_t, W_t, Y_t\}
\end{align}

\subsection{Assigning Points}

At time-index $t$, there will be both buy and sell entries, each with corresponding elements to obtain their own $V_t$. We care only about one side (buyside $bs$ or sellside $ss$) that will have the Valid $V_t$.

\begin{align}
    \text{Point }(v^{bs},v^{ss}) =
    \begin{cases}
        (E_t^{bs} = E_t^{ss}) &\implies (1,1) \\
        (\Omega_t^{bs,\text{Dev}} > \Omega_t^{ss,\text{Dev}}) &\implies (0,1) \\
        (\Omega_t^{bs,\text{Dev}} < \Omega_t^{ss,\text{Dev}}) &\implies (1,0) \\
        (T_t^{bs,\text{Dev}} > T_t^{ss,\text{Dev}}) &\implies (1,0) \\
        (T_t^{bs,\text{Dev}} < T_t^{ss,\text{Dev}}) &\implies (0,1) \\
        (R_t^{bs,\text{Dev}} > R_t^{ss,\text{Dev}}) &\implies (1,0) \\
        (R_t^{bs,\text{Dev}} < R_t^{ss,\text{Dev}}) &\implies (0,1) \\
        (A_t^{bs,\text{Dev}} > A_t^{ss,\text{Dev}}) &\implies (0,1) \\
        (A_t^{bs,\text{Dev}} < A_t^{ss,\text{Dev}}) &\implies (1,0) \\
        (Q_t^{bs} > Q_t^{ss}) &\implies (0,1) \\
        (Q_t^{bs} < Q_t^{ss}) &\implies (1,0) \\
        (W_t^{bs} > W_t^{ss}) &\implies (1,0) \\
        (W_t^{bs} < W_t^{ss}) &\implies (0,1) \\
        (Y_t^{bs} > Y_t^{ss}) &\implies (1,0) \\
        (Y_t^{bs} < Y_t^{ss}) &\implies (0,1)
    \end{cases}
\end{align}

Where $v$ is an element of $V_t$. The rules are:
\begin{itemize}[label=$\rightarrow$]
    \item For Entry Price, both sides get 1 point (same open price)
    \item For Stoploss, the side with lesser deviation gets 1 point
    \item For Takeprofit, the side with greater deviation gets 1 point
    \item For Recovery, the side with greater deviation gets 1 point
    \item For Adverseloss, the side with lesser deviation gets 1 point
    \item For Q-Ratio, the side with lesser value gets 1 point
    \item For W-Ratio, the side with greater value gets 1 point
    \item For Y-Ratio, the side with greater value gets 1 point
\end{itemize}

\subsection{Score Calculator}

\subsubsection{Normal Scoring}

With points assigned, we calculate the score:

\begin{align}
    \text{Score}(V_t^{bs},V_t^{ss}) = \left( \sum_{\text{all Point}(v^{bs})} \text{Point}(v^{bs}),\; \sum_{\text{all Point}(v^{ss})} \text{Point}(v^{ss}) \right)
\end{align}

This sums all points of elements for each side. Normally, one side will have a greater or lesser total.

\subsubsection{Special Scoring}

If a trade has an invalid element (e.g., Takeprofit Deviation smaller than Stoploss Deviation), we invalidate it:

\begin{align}
    \text{Score}(V_t^{bs},V_t^{ss}) = (Y_t^{bs} < 1) \oplus (Y_t^{ss} < 1) \implies (0,0)
\end{align}

If $Y_t < 1$ for either side, that side is automatically invalid.

\subsection{Valid $V_t$}

With total scores determined, we decide which side remains at time-index $t$:

\begin{align}
    \text{Valid}(V_t^{bs},V_t^{ss}) =
    \begin{cases}
        (1,0), & \text{if } \text{Score}(V_t^{bs}) > \text{Score}(V_t^{ss}), \quad \text{favor the buyside} \\
        (0,1), & \text{otherwise}, \quad \text{favor the sellside}
    \end{cases}
\end{align}

\subsection{Null $V_t$}

\begin{align}
    \text{Null}(V_t^{bs},V_t^{ss}) =
    \begin{cases}
        (1,0), & \text{if } \text{Score}(V_t^{bs}) = 0 \\
        (0,1), & \text{if } \text{Score}(V_t^{ss}) = 0
    \end{cases}
\end{align}
    
\section{Organizing The Valid $V_t$'s}

\subsection{Valid and Null Trades $\mathcal{T}$}

The process includes both buy and sell entries at the same time-index $t$. Corresponding elements are calculated (lookahead calculations are performed and brought back to time-index $t$), then points are assigned to determine scores for validation. Only one side remains:

\begin{align}
    \mathcal{T}_t^{\text{valid}} = (\text{Valid }(V_t^{bs}) = 1) \oplus (\text{Valid }(V_t^{ss}) = 1)
\end{align}

And

\begin{align}
    \mathcal{T}_t^{\text{null}} = (\text{Null }(V_t^{bs}) = 1) \land (\text{Null }(V_t^{ss}) = 1)
\end{align}

\subsection{Scaling the Number of Trades}

Simulated trades are conducted for each time-index $t$ (parallel calculations are recommended due to computational intensity) and filtered by assigning whether $\mathcal{T}_t^{\text{valid}}$ (either buyside or sellside) or $\mathcal{T}_t^{\text{null}}$ (no side, no trade) is appropriate. The resulting time-series data appears as:

\begin{align}
    \{\mathcal{T}_t^{\text{valid}}, \mathcal{T}_t^{\text{null}}, \mathcal{T}_t^{\text{valid}}, \mathcal{T}_t^{\text{valid}}, \mathcal{T}_t^{\text{valid}}, \mathcal{T}_t^{\text{null}},\ldots,\mathcal{T}_t^{\text{?}}\}
\end{align}

Where $\mathcal{T}_t^{\text{valid}}$ corresponds to values and elements from either the buyside or sellside.

\section{Recommendations for Implementation}

\subsection{Representing the Elements of $V_t$ on Chart}

Representing these elements on a chart is complex. It is recommended to represent $\{E_t, \Omega_{\overrightarrow{t}}, T_{\overrightarrow{t}}, R_{\overrightarrow{t}}, A_{\overrightarrow{t}} \}$ as single dots in an overlayed line plot at time-index $t$, and $\{Q_{\overrightarrow{t}}, W_{\overrightarrow{t}}, Y_{\overrightarrow{t}}\}$ as bars in a separate barchart pane (as they cannot be represented as prices). The deviations $\{\Omega_t^{\text{Dev}}, T_t^{\text{Dev}}, R_t^{\text{Dev}}, A_t^{\text{Dev}} \}$ can also be plotted as bars in another separate pane.

\subsection{Dataset for Reinforcement Learning}

Individual rows of a dataframe from a CSV file may have a row of \{datetime, open, high, low, close, tick volume\} as raw data. The new dataset is organized in the same row as the raw data:

\[
\{\mathcal{T}_t^{\text{valid}}, \mathcal{T}_t^{\text{null}}, V_t^{bs}, V_t^{ss}, E_t, \Omega_t, T_t, R_t, A_t, Q_t, W_t, Y_t, \Omega_t^{\text{Dev}}, T_t^{\text{Dev}}, R_t^{\text{Dev}}, A_t^{\text{Dev}}\}
\]

We introduce timeout times as time indicators for the agent to force exit if targets are not reached in real environments:

\begin{align}
    J^T_{\overrightarrow{t}} &= 
    \begin{cases}
        \text{Count}(t_{0,E_t^{bs}}, t_1, \ldots, t_{j,T_{\overrightarrow{t}}^{bs}}), & \text{for buyside} \\
        \text{Count}(t_{0,E_t^{ss}}, t_1, \ldots, t_{j,T_{\overrightarrow{t}}^{ss}}), & \text{for sellside}
    \end{cases} \\[10pt]
    J^R_{\overrightarrow{t}} &= 
    \begin{cases}
        \text{Count}(t_{0,E_t^{bs}}, t_1, \ldots, t_{j,R_{\overrightarrow{t}}^{bs}}), & \text{for buyside} \\
        \text{Count}(t_{0,E_t^{ss}}, t_1, \ldots, t_{j,R_{\overrightarrow{t}}^{ss}}), & \text{for sellside}
    \end{cases}
\end{align}

Both $J^T$ and $J^R$ enable the agent to force exit if pending targets are not reached during real-time environments.

Once the timeout is reached, use the close price at that time to force-exit:

\begin{align}
    F^T_{\overrightarrow{t}} &= 
    \begin{cases}
        C_{\overrightarrow{t}}^{J^T,bs}, & \text{for buyside} \\
        C_{\overrightarrow{t}}^{J^T,ss}, & \text{for sellside}
    \end{cases} \\[10pt]
    F^R_{\overrightarrow{t}} &= 
    \begin{cases}
        C_{\overrightarrow{t}}^{J^R,bs}, & \text{for buyside} \\
        C_{\overrightarrow{t}}^{J^R,ss}, & \text{for sellside}
    \end{cases}
\end{align}

\subsubsection{Simplifying the Notation}

Bringing lookahead values $\overrightarrow{t}$ back to time-index $t$:

\begin{align}
    J^T_{\overrightarrow{t}} &\implies J^T_t \\
    J^R_{\overrightarrow{t}} &\implies J^R_t \\
    F^T_{\overrightarrow{t}} &\implies F^T_t \\
    F^R_{\overrightarrow{t}} &\implies F^R_t
\end{align}

\subsubsection{Final Form of the New Dataset}

The final dataset structure is:

\begin{center}
    \{$\mathcal{T}_t^{\text{valid}}$, $\mathcal{T}_t^{\text{null}}$, $V_t^{bs}$, $V_t^{ss}$, $E_t$, $\Omega_t$, $T_t$, $R_t$, $A_t$, $Q_t$, $W_t$, $Y_t$, $\Omega_t^{\text{Dev}}$, $T_t^{\text{Dev}}$, $R_t^{\text{Dev}}$, $A_t^{\text{Dev}}$, $J^T_t$, $J^R_t$, $F^T_t$, $F^R_t$\}
\end{center}

This is placed in the same row as the raw dataset for each time-index $t$:

\begin{center}
    \{datetime, open, high, low, close, tick volume, $\mathcal{T}_t^{\text{valid}}$, $\mathcal{T}_t^{\text{null}}$, $V_t^{bs}$, $V_t^{ss}$, $E_t$, $\Omega_t$, $T_t$, $R_t$, $A_t$, $Q_t$, $W_t$, $Y_t$, $\Omega_t^{\text{Dev}}$, $T_t^{\text{Dev}}$, $R_t^{\text{Dev}}$, $A_t^{\text{Dev}}$, $J^T_t$, $J^R_t$, $F^T_t$, $F^R_t$\}
\end{center}

\section{Conclusion}

This paper has presented a comprehensive framework for generating simulated trade signals through lookahead analysis. The methodology systematically calculates entry prices, stoploss levels, takeprofit targets, recovery prices, and adverse loss levels, along with their associated ratios. The scoring system effectively determines valid trades, and the resulting data structure is well-suited for reinforcement learning applications.

The framework provides several key contributions:
\begin{enumerate}
    \item A rigorous mathematical foundation for trade signal generation
    \item A novel dataset structure capturing optimal price levels and timing information
    \item A validation mechanism to ensure trade quality
    \item Practical implementation recommendations for charting and machine learning applications
\end{enumerate}

Future work may explore optimizing the parameter values ($K$, $m$, $d$, $l$) through systematic backtesting and incorporating additional market microstructure features to enhance signal quality.


\end{document}

