The system discussed in the previous post can be easily tested using the simulation method of its operation. The input record format will be an Open-High-Low-Close, and I plan to implement the engine of the system using C++ compiler together with the R environment. But first I would like to briefly write down the formulas necessary to program rules of position reversals and the resulting profits.
The basic premise of the system, perhaps not very intuitive and difficult to accept, is to determine the levels of reverse position relative to the initial quotation, namely Open. Expanding on this thought: if your position is short, the level set to be reversed at a fixed distance above the opening price. There will be the potential closure by Stop Loss and opening a new one by Buy Stop. On the other hand, taking a long position reversal level is set at a fixed distance below the opening. There will accordingly be expected Stop Loss and Sell Stop.
In essence this means that the user only requires a decision to determine this distance, denoted hereinafter by the letter "t". The appropriate level of reversal knows the market. Motivation to use this kind of strategy, as well as discussions on all the pros and cons would occupy many pages yet, so we will return to them in the future. But now I would like to introduce models as soon as possible, allowing examine its properties in practice.
We'll start with the simplest problem, which is to write formulas for the transition between positions. This requires the appropriate symbols. Long positions will be determined as +1, and short -1. There are perhaps quite natural signs, which - consistently applied - also will be useful in implementations and simulations. What is needed is a variable that stores the current position. I suggest the symbol "s" as the value of the position at the end of the interval of the appropriate index. "t" is also necessary here, since this value will depend on the previous position, and the distance "t" which determines the level of the reversal.
And here is the formula for the reversal of the position included in a conditional expression. The letters O, H, L, C, along with the BID and ASK indices denote the corresponding quotations within the interval.
These formulas allow you to set sequences of positions occupied by a player on the basis of records OHLC quotes for different cases of the parameter "t". However, what interests us most is the study of the effectiveness of the strategy through profit and risk indicators. To do this, you will need formulas determining gains and losses as a function of the relevant data and parameters. It will be presented in the next post.