File size: 23,027 Bytes
d09db33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342

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

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

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

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

\begin{document}
\maketitle

\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\}$, where $n$ is additive indexer, and $n \in \{0,1,2,\ldots,\infty\}$},  \\
  \overline{t} &= \text{be the any time-index in between $t$ and $\overrightarrow{t}$, 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 the values at $\overrightarrow{t}$ is being caried by $t$} \\
  P &\in \{H,O,C,L\} = \text{be the \textcolor{red}{Price} and \{High,Open,Close,Low\} repectively} \\
  \Omega_t &= \text{be the $\Omega_{\overrightarrow{t}}$ being brought back to time-index $t$ } \\
  T_t &= \text{be the $T_{\overrightarrow{t}}$ being brought back to time-index $t$ } \\
  R_t &= \text{be the $R_{\overrightarrow{t}}$ being brought back to time-index $t$ } \\
  A_t &= \text{be the $A_{\overrightarrow{t}}$ being brought back to time-index $t$ } \\
  Q_t &= \text{be the $Q_{\overrightarrow{t}}$ being brought back to time-index $t$ } \\
  W_t &= \text{be the $W_{\overrightarrow{t}}$ being brought back to time-index $t$ } \\
  Y_t &= \text{be the $Y_{\overrightarrow{t}}$ being brought back to time-index $t$ } \\
  V_t &= \{E_t, \Omega_t, T_t, R_t, A_t, Q_t, W_t, Y_t\} \text{ is the same as }\{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^{null} &= \text{be the null or invalid trade which represents as no trade at time-index $t$ was observed} \\
  \mathcal{T}_t^{valid} &= \text{be the valid trade which represents as a eligible trade (either buyside or sellside) at time-index $t$ was observed} \\
  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 of timeout time for Takeprofit target, from lookahead $\overrightarrow{t}$} \\
  F^R_{\overrightarrow{t}}  &= \text{be the Close Price of timeout time for Recovery target, from lookahead $\overrightarrow{t}$} \\
  J^T_t &= \text{be the $J^T_{\overrightarrow{t}}$ being brought back to time-index $t$} \\
  J^R_t &= \text{be the $J^R_{\overrightarrow{t}}$ being brought back to time-index $t$} \\
  F^T_t &= \text{be the $F^T_{\overrightarrow{t}}$ being brought back to time-index $t$} \\
  F^R_t &= \text{be the $F^R_{\overrightarrow{t}}$ being brought back to time-index $t$} \\
\end{align*}

\newpage

\section{Values at time-index $t$}
\subsection{Entry Price}
By default, we will use 3-minute timeframe. Supposed its always to Buy and Sell at $E_t$ (we sell buy and sell 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 start by calculating our \textcolor{red}{average of max imaginary adverse excursion}, which is formalized as:
\begin{align}
    \omega &= \frac{1}{K}\sum_{t=0}^{K-1} 
    \begin{cases}
        \text{if $O_{-t} < C_{-t}$}, \quad \max\left(O_{-t} - L_{-t},|O_{-t}-C_{{-t}-1}|,|L_{-t}-C_{{-t}-1}|\right)\\
        \text{if $O_{-t} > C_{-t}$}, \quad \max\left(|O_{-t} - H_{-t}|,|O_{-t}-C_{{-t}-1}|,|H_{-t}-C_{{-t}-1}|\right)
    \end{cases}
\end{align}
That captures the average of wick 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} 
        \text{for $E_t^{buyside}$ }, \quad O_t -(\omega_{t-1} \cdot s_t\cdot m) \\ 
        \text{for $E_t^{sellside}$ }, \quad O_t +(\omega_{t-1} \cdot s_t \cdot m) 
    \end{cases},\quad \text{\textcolor{red}{Stoploss Price}}
\end{align}

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



\section{Values at time-index lookahead $\overrightarrow{t}$}

\subsection{Recovery Price}
We start by calculating the $P^{\text{extreme}}_{\overline{t}}$ while the time moves forward.
\begin{align}
    P^{\text{extreme}}_{\overline{t}} =
    \begin{cases}
        \text{for } E_t^{\text{buyside}}, & \displaystyle\max_{t \le \overline{t} \le \overrightarrow{t}} [\max P_{\overline{t}}] \\
        \text{for } E_t^{\text{sellside}}, & \displaystyle\min_{t \le \overline{t} \le \overrightarrow{t}} [\min P_{\overline{t}}]
    \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}
        \text{for } E_t^{\text{buyside}}, & \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{sellside}}, & \left| \Omega_t - \displaystyle\min_{t \le \overline{t} \le \overrightarrow{t}} [\min P_{\overline{t}}] \right| \times d - \Omega_t \\
    \end{cases}, \quad \text{Stop Creterion}
\end{align}
Where $\textcolor{blue}{d}$ is the divisor, and the default value is $d = 0.50$ with a step of $0.10$. The $S_{\overline{t}}$ is used as creteria, and if the price deeps beyond the boundary then we register that time as:

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

\subsection{Takeprofit Price}
Now that we have our $R_{\overrightarrow{t}}$, whe can now calculate for the best takeprofit levels, formalized as:

\begin{align}
    T_{\overrightarrow{t}} =
    \begin{cases}
        \text{for $E_t^{buyside}$ }, & \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^{sellside}$ }, & \displaystyle\left(\min_{t_{E_t} \le \overline{t} \le \overrightarrow{t}_{R_{\overrightarrow{t}}}} [\min P_{\overline{t}}] \right) + (s_t \times l) 
    \end{cases}, \quad \text{\textcolor{red}{Takeprofit Price}}
\end{align}
Where $l$ is multiplier and the default value is $l = 2$, with a step of 1.

\subsection{Adverse Price}
Now that we have our $T_{\overline{t}}$, we can now calculate for the best adverseloss levels, formalized as:

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

\subsection{Q-Ratio or $A_{\overrightarrow{t}}:\Omega_{\overrightarrow{t}}$ Ratio}
And the ratio of Adverse Price relative to Stoploss Price is formalized as:

\begin{align}
    Q_{\overrightarrow{t}} = 
    \begin{cases}
        \text{for $E_t^{buyside}$ }, \quad \left|\displaystyle\frac{E_t - A_{\overrightarrow{t}}^{buyside}}{E_t - \Omega_t^{buyside}} \right| \\
        \text{for $E_t^{sellside}$ }, \quad \left| \displaystyle\frac{E_t - A_{\overrightarrow{t}}^{sellside}}{E_t - \Omega_t^{sellside}} \right|
    \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}
And the ratio of Revovery Price relative to the Takeprofit Price is formalized as:

\begin{align}
    W_{\overrightarrow{t}} = 
    \begin{cases}
        \text{for $E_t^{buyside}$ }, \quad \left| \displaystyle\frac{E_t - R_{\overrightarrow{t}}^{buyside}}{E_t - T_{\overrightarrow{t}}^{buyside}} \right| \\
        \text{for $E_t^{sellside}$ }, \quad \left| \displaystyle\frac{E_t - R_{\overrightarrow{t}}^{sellside}}{E_t - T_{\overrightarrow{t}}^{sellside}} \right|
    \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}
And the ratio of Stoploss Price relative to the Takeprofit Price is formalized as:

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

\section{Set of Values at time-index $t$}
Therefore we can now contruct our $V_t$ which is a set of all values from time-index $t$ and time-index lookahed $\overrightarrow{t}$, amd we formalize it as:
\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}
Notice that $V$ has a time-index of $t$. therefore it carries all values from both $t$ and $\overrightarrow{t}$. In addition, by using a dataframe-related terms, the $V_t$ is a set of all values written in the same row as \{datetime,open,high,low,close,tick volume\} csv variables. The same row. The same bar. 

Moving on, this methodology lags far more than a conventional indicators. Therefore it is best use as a new form of dataset rather than a trading signal. Like for example, a dataset which consists of best prices to order at that time, for engineering the Reward Function of a Reinforecement Learning Model.

\section{The Valid $V_t$ at time-index $t$}

\subsection{Deviating from $E_t$}
First, we need to find the deviation values of Price-based elements such as $\{\Omega_{\overrightarrow{t}}, T_{\overrightarrow{t}}, R_{\overrightarrow{t}}, A_{\overrightarrow{t}}\}$ which are deviated from the $E_t$. Let $v$ be the element of $V_t$. Therefore we formalize it as:

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

\subsection{Simplifiying the Elements of $V_t$}
Since all Elelements of $V_t$ with an index of $\overrightarrow{t}$ is being carried back to the same time-index as the $E_t$ which is $t$, therefore we could simplify is as:
\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}
Becauase all elements are simplified. Then the process goes like this: at time-index $t$, there will be both buy and sell entry, and each will calculated its corresponding elements to get their own $V_t$. But we care only one side (buyside $bs$ or sellside $ss$) which will have the Valid $V_t$. 

\begin{align}
    \text{Point }(v^{bs},v^{ss}) =
    \begin{cases}
        (E_t^{bs} \gtreqless E_t^{ss}) &\implies (1,1) \\
        (\Omega_t^{{bs},{Dev}} > \Omega_t^{{ss},{Dev}}) &\implies (0,1) \\
        (\Omega_t^{{bs},{Dev}} < \Omega_t^{{ss},{Dev}}) &\implies (1,0) \\
        (T_t^{{bs},{Dev}} > T_t^{{ss},{Dev}}) &\implies (1,0) \\
        (T_t^{{bs},{Dev}} < T_t^{{ss},{Dev}}) &\implies (0,1) \\
        (R_t^{{bs},{Dev}} > R_t^{{ss},{Dev}}) &\implies (1,0) \\
        (R_t^{{bs},{Dev}} < R_t^{{ss},{Dev}}) &\implies (0,1) \\
        (A_t^{{bs},{Dev}} > A_t^{{ss},{Dev}}) &\implies (0,1) \\
        (A_t^{{bs},{Dev}} < A_t^{{ss},{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 element of $V_t$. For Entry Price $v$ is clearly the same since we are entering at the same open price, therefore both gets 1 point. The Stoploss Price $v^{?}$ gets 1 point who ever is the lesser Stoploss Deviation. The Takeprofit Price $v^{?}$ gets 1 point who ever is the greater Takeprofit Deviation. The Recovery Price $v^{?}$ gets 1 point who ever is the greater Recovery Deviation. The Adverseloss Price $v^{?}$ gets 1 point who ever is the lesser Adverseloss Deviation. Moving on, the Q-Ratio $v^{?}$ gets 1 point who ever is the lesser. The W-Ratio $v^{?}$ gets 1 point who ever is the greater. The Y-Ratio $v^{?}$ gets 1 point who ever is the greater.

\subsection{Score Calculator}
\subsubsection{Normal Scoring}
Since we now have a Points, we can now calculate for the Scoring calculator, which is formalized as:
\begin{align}
    \text{Score}(V_t^{bs},V_t^{ss}) = \displaystyle\sum_{\text{all Point}(v^{bs})}(\text{Point}(v^{bs})), \sum_{\text{all Point}(v^{ss})}{\text{all}}(\text{Point}(v^{ss}))
\end{align}
In context, that will sum all the points of elements of each side (the buyside and sellside). Normally, one side will end up greater or lesser than the other.
\subsubsection{Special Scoring}
But here is the catch, some cases that the a trade have a not so ideal or invalid element, (say) an trade Entry with a Takeprofit Deviation is smaller that its Stoploss Deviation. Therefore we formalize the invalidity as automatically scores 0:
\begin{align}
    \text{Score}(V_t^{bs},V_t^{ss}) = (Y_t^{bs} < 1) \oplus (Y_t^{ss} < 1) \implies (0,0)
\end{align}
Simply speaking, if the $Y_t$ of $V_t$ is less than one, then its automatically invalid.


\subsection{Valid $V_t$}
Since we now have the Scores in total. We can now decide what side to remain at time-index $t$, since we can only remain one side per time-index $t$. And we formalize that as:
\begin{align}
    \text{Valid}(V_t^{bs},V_t^{ss}) =
    \begin{cases}
        (1,0), & \text{if } \left(\text{Score}(V_t^{bs}) > \text{Score}(V_t^{ss})\right), \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}$}
As recall, the process includes both buy and sell entry at the same time-index $t$ which corresponding elements are calculated (lookahead calculations was performed and brought it back to the time-index $t$), then points are calculated to give the corresponding scores to validate, and therefore only one side remains (either the buyside or the sellside). That gives us another formalization:
\begin{align}
    \mathcal{T}_t^{valid} = (\text{Valid }(V_t^{bs}) = 1) \oplus (\text{Valid }(V_t^{ss}) = 1)
\end{align}
And
\begin{align}
    \mathcal{T}_t^{null} = (\text{Null }(V_t^{bs}) = 1) \land (\text{Null }(V_t^{ss}) = 1)
\end{align}

\subsection{Scaling the Number of Trades, Moving from one time-index $t$ to another $t$}
Naturally, simulated trades are being conducted for each time-index $t$ (I recomend a parallel calculations for this becuase its heavy) and being filtered by assigning whether it is $\mathcal{T}_t^{valid}$ (which could be the buyside or the sellside) or $\mathcal{T}_t^{null}$ (which there is no side, no trade/s) is appropriate for each time-index $t$. Therefore our row data or time-series data will look like this; as example:
\begin{align}
    \{\mathcal{T}_t^{valid}, \mathcal{T}_t^{null}, \mathcal{T}_t^{valid}, \mathcal{T}_t^{valid}, \mathcal{T}_t^{valid}, \mathcal{T}_t^{null},\ldots,\mathcal{T}_t^{?}\}
\end{align}
Which ${\mathcal{T}_t^{valid}}$ corresponding values and elements will either from buyside or sellside.

\section{Recomendations Upon Implimentations}
\subsection{Representing the Elements of $V_t$ on Chart}
Representing these elements of $V_t$ on chart is confusing. At best, its recomended to represent $\{E_t, \Omega_{\overrightarrow{t}}, T_{\overrightarrow{t}}, R_{\overrightarrow{t}}, A_{\overrightarrow{t}} \}$ as a single dot for overlayed lineplot at time-index $t$. And $\{Q_{\overrightarrow{t}}, W_{\overrightarrow{t}}, Y_{\overrightarrow{t}}\}$ as a bar at time-index $t$ for barchart at separate pane because this cant be represented through prices. In addition, the $\{\Omega_{\overrightarrow{t}}^{Dev}, T_{\overrightarrow{t}}^{Dev}, R_{\overrightarrow{t}}^{Dev}, A_{\overrightarrow{t}}^{Dev} \}$ could be ploted using bar for barchart in another separate pane.

\subsection{Dataset for Reinforecement Learning}

Individual rows of a datafram from csv file may have a ow of \{datetime, open, high, low, close, tick volume\} as raw data. Therefore the new dataset may appear and will be organized like this, as the same row as the raw data:
\{$\mathcal{T}_t^{valid}$, $\mathcal{T}_t^{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^{Dev}, T_t^{Dev}$, $R_t^{Dev}$, $A_t^{Dev}$ \}

With that being said, lets introduc another element, which are the timeout time where we could use as a time indicator which the agent will conduct force out if the timeout time it reached, this in useful in out-of-sample-training or the agent is exposed in real-live environments where the targets have not reached like the Takeprofit target. And we formalized that as:
\begin{align}
    J^T_{\overrightarrow{t}} &= 
    \begin{cases}
    \text{Count}(t_{{0},{E_t^{bs}}},t_1,\ldots,t_{{j},{T_{\overrightarrow{t}}^{bs}}}), \quad \text{for buyside} \\
    \text{Count}(t_{{0},{E_t^{ss}}},t_1,\ldots,t_{{j},{T_{\overrightarrow{t}}^{ss}}}), \quad \text{for sellside}
    \end{cases}, \quad \text{where we count the time it takes until the $Takeprofit$ target} \\
    J^R_{\overrightarrow{t}} &= 
    \begin{cases}
    \text{Count}(t_{{0},{E_t^{bs}}},t_1,\ldots,t_{{j},{R_{\overrightarrow{t}}^{bs}}}), \quad \text{for buyside} \\
    \text{Count}(t_{{0},{E_t^{ss}}},t_1,\ldots,t_{{j},{R_{\overrightarrow{t}}^{ss}}}), \quad \text{for sellside}
    \end{cases}, \quad \text{where we count the time it takes until the $Recovery$ target}
\end{align}
Which both $J^T$ and $J^R$ is used to make the agent have a force timeout time to take out the trade if the pending targets arent reached during real-live environments.

Ideally, once the timeout time is reached, use the close price of that timeout time to get out or force-exit the trade. Formalized as:

\begin{align}
    F^T_{\overrightarrow{t}} &= 
    \begin{cases}
        C_{\overrightarrow{t}}^{{J^T},{bs}}, \quad \text{for buyside} \\
        C_{\overrightarrow{t}}^{{J^T},{ss}}, \quad \text{for sellside} 
    \end{cases}, \quad \text{where we use the close price at timeout time $J^T_{\overrightarrow{t}}$} \\
    F^R_{\overrightarrow{t}} &= 
    \begin{cases}
        C_{\overrightarrow{t}}^{{J^R},{bs}}, \quad \text{for buyside} \\
        C_{\overrightarrow{t}}^{{J^R},{ss}}, \quad \text{for sellside} 
    \end{cases}, \quad \text{where we use the close price at timeout time $J^R_{\overrightarrow{t}}$}
\end{align} 

\subsubsection{Simplifying the Notation}
Because we are brigging the lookahead values $\overrightarrow{t}$ back to the time-index $t$, then we could simplify:
\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}
Therefore, our final form of dataset is:
\begin{center}
    \{$\mathcal{T}_t^{valid}$, $\mathcal{T}_t^{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^{Dev}, T_t^{Dev}$, $R_t^{Dev}$, $A_t^{Dev}$, , $J^T_t$, $J^R_t$, $F^T_t$, $F^R_t$\}
\end{center}
Which is placed at the same row of the raw dataset whenever the trade is valid or null for that time-index $t$. Finally, we present it as:
\begin{center}
    \{datetime, open, high, low, close, tick volume, , $\mathcal{T}_t^{valid}$, $\mathcal{T}_t^{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^{Dev}, T_t^{Dev}$, $R_t^{Dev}$, $A_t^{Dev}$, , $J^T_t$, $J^R_t$, $F^T_t$, $F^R_t$\}
\end{center}

\end{document}