# Grid Trading System Robot (GTSbot): A Novel Mathematical Algorithm for Trading FX Market
## 3 GTSbot: The Proposed Pipeline
### GTShot: Grid System Manager Block
Therefore, in the hypothesis that was in the example shown in Figure 6, the maximum number of operations had not been reached, the GSM block would confirm and execute the opening of the second long order proposal, characterized by the blue circle in detail in Figure 6. In this way, the GSM block would be able to open such trades in grid schemes and operations appropriately spaced from each other in order to average any wrong trades open against the real trend. The heuristically defined x-thresholds and y-thresholds allowed the prevention of several wrong trades very close to each other being opened by the GSM block. To confirm what has been said, we had tried the proposed approach disabling the checks performed by means of the mentioned x-thresholds and y-thresholds. Specifically, we had tried the grid trading system robot (GTSbot) system without the x-threshold based check. The so modified algorithm had performed lower with respect to the same with the x-threshold check enabled. More in detail, we noticed a considerable increase in the drawdown (on average +25%) accompanied by a reduction in profit (-10% of daily profit in average). Similarly, with the y-threshold control disabled, we found a considerable increase in the drawdown (+18.3%) along with a reduction in daily profit (-11.25%). The above tests (performed in the scenarios reported in Tables 1 and 2) confirmed the key role played by the x-thresholds and y-thresholds based checks in the proposed system. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Experiment [11]** & **FX Currency Cross** & **ROI** & **MD** & **ROI (Proposed)** & **MD (Proposed)** \\ \hline Nr. 01 & EUR/USD & 60.77 & 21 & **94.11** & **11.25** \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Trading Performance Comparison. \begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Experiment [11]** & **FX Currency Cross** & **ROI** & **MD** & **ROI (Proposed)** & **MD (Proposed)** \\ \hline Nr.01(10 Lots) & EUR/USD & **607.75** & 64.86 & 350.62 & **38.75** \\ Nr.01(10 Lots) & EUR/USD & **607.75** & **64.86** & 500.73 & 65.11 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Trading Performance Comparison. Figure 6: The GSM block: An instance of workflow (long trades). This approach provides a simple and effective method to compensate any drawdown drifts due to wrong opened trades. We performed several tests in order to select a robust values of x-threshold and y-threshold as well as the maximum number of allowed operations with an intraday investment perspective. According to our experimental results, we decided to use the following values:  
* x-threshold = 15 (candlestick, i.e., 15 min in a 1 min timeframe);
* y-threshold = 0.00020 (two pips according to FX 5-digits quotations);
* Maximum number of operations = 13. The x-threshold set to 15 indicated that the GSM block did not open any operation if we have at least 15 samples (or candlesticks) of distance between each opened operation and new ones. Similarly, GSM block did not open any operations (long or short) if the FX cross quotation value at which we want to open a new trade was greater or lower (according to the type of operation if it was long or short, respectively) than the y-threshold with respect to all the prices at which previous trades (in the same directions) had been opened. The used distance metric was the absolute distance. The FX cross quotation value was measured in pips, which was the standard unit for FX markets. The maximum number of allowed operations had been defined as an odd number because we want to avoid a perfect hedging condition in which we had a number of long trades exactly equal to short ones as the trading system became market neutral. Formerly, the GSM block would proceed opening a trade if (in the hypothesis of the defined trend detected by TCB):  
Long trade:  
\[ \begin{array}{c}c_{real}^{Open}(k_{1}):k_{1}>k+x_{h};\\ c_{real}^{Open}(k_{1}):c_{real}^{Open}(k_{0})<c_{real}^{Open}(k_{0}^{i})+y_{h };\\ N_{tracks}<M_{0}\end{array}