Selecting levelsStopLoss and TakeProfit can have a very strong impact on the overall performance of trading. In addition to the obvious parameters of the trade transaction-the size of the possible win or possible loss-the levelsStopLoss and TakeProfit also affect the expected duration of the trade, and the profitability of the trade in general.
If you have already determined the optimal transaction durations using the “AIS-ODT” script, then you can start determining the parameters associated with the levelsStopLoss and TakeProfit.
To do this, we will proceed as follows. First, we will determine all possible price deviations in one direction or the other, and calculate the probabilities of their achievement within a certain time. After that, you can calculate the most optimal levelsStopLoss and TakeProfit, given their size, probability, and mathematical expectation of profit.
To do this, run the script on the chart of the currency pair of interest and the desired timeframe. In the properties window, use the ILB parameter to set the desired trading position duration, expressed in the number of bars. During the operation of the utility, data is analyzed for the entire history, and the most optimal values are selected. At the end of the script, two files are formed – “Buy. csv” and “Sell.csv“, containing tables with the results obtained-Figure 1.
[spoiler title=”Read More…”]
The first column of the table shows the possible size of the TakeProfit, and the second column shows the best size.StopLoss. The third column shows the probability of winning with these parameters as a percentage, the fourth indicates the mathematical expectation of profit in the transaction, expressed in points. The fifth column of the table contains an integral performance indicator, which should be used when selecting levels.StopLoss and TakeProfit – the bigger it is, the better.
As you can see in Figure 2, there is always an optimal ratio, adhering to which you can hope to get the best results in trading.