Here is a possible algorithm for creating a robust strategy using Belkaglazer
I. Basic Rules
1) Parameter tuning. Don’t tune 2 or more parameters at once. It is better to optimize only one parameter at the same time because each parameter has own meaning, logic, and features.
2) Use the Occam’s razor principle at every stage: ‘The simpler one is usually better.’ ‘More things should not be used than are necessary.’
The simpler your strategy, the more likely it will be successful in live trading.
II. Preparatory Stage
1) Try to formulate your idea and choose the trading model. Also, you can use any of my strategies as a template.
2) Disable all filters (time, volatility, trend-based), set them to 0. The filters are optional elements of a strategy they are irrelevant to the basic idea and should be considered and added in the last stages.
After turning filters off, the performance (PF, average trade) of a strategy significantly decreases, with the number of trades increasing. Therefore->
3) -> you need to disable spread (set it to a minimum possible value), commissions, and trading costs! Because in this stage, the spread might prevent you from seeing reality – whether your basic idea works or not. If you don’t do this, you may throw out an excellent strategy or idea at the very beginning stage of development.
4) Disable complex exit rules like trailing stop, etc. Set initial values of SL, TP, and time-stop (see ‘StopBar‘ parameter). The initial value of the time-stop is necessary to set equal to the maximum period used in your trading model. The initial values of SL and TP must be set according to the type of strategy. They should not be too small or too large; the values must correspond to the working timeframe and trading logic of the basic idea. If you create an MR strategy, then the SL value should be several times bigger than the TP value. For a momentum or breakout strategy, the SL value should be equal or several times smaller than the TP value.
For example, in a momentum strategy, I recommend to set the initial TP to 1.0 (ATR), SL to 0.5 (ATR).
5) Secondary parameters, like the ATR period (used for normalization) or offset parameters in the PCh model (PCh_OffsetPip, HL/2_OffsetPip), should be analyzed/optimized in the last stage. For now, set the ATR period to 5, set the offset values to 0.
6) Do not use software like TDS2 or slow and accurate testing methods in the first stages. It is enough to use the fast ‘Open prices only‘ method. This rule will save you a lot of time.
An example. I will create a momentum strategy. Basic idea: After a significant price movement in one direction, the market will continue to move in the same direction. The significant price movement is expressed as the last closed bar larger than X of daily ATR. TF is M30. I plan to enter a trade with a market order. So I switch off everything. I set DailyATR_Period=5, Model type=PriceAction, ExecutionType=MarketOrder, PA_InitialHour=-1 (I don't use time binding, I use every last closed bar), PA_Bars=0 (I use the last bar only), PA_Size%ATR=30 (is an initial value =0.3 of the daily ATR), StopLoss=0.5, TakeProfit=1, TimeStop=1 (because I use only 1 last bar to generate a signal) So, at this stage, my strategy looks like this (a lot of trades, low performance): PF=1.39, Avg.trade=2.8pips, Number of trades=2061, Total profit=587, spread=0.2pips, no slippage, 'open prices only' method, from 2005 to 2018 As you can see, the main idea works, but the average trade is too small. If I had turned on the spread, I would not have seen that the strategy works.
III. Model Parameter Analysis
It is time to analyze the parameters of the model. Try to optimize and analyze them one by one.
In general, a robust parameter of a model can behave in 3 different ways:
1) It can work on a wide range of values, without a significant effect on performance. But if you turn it off, then a strategy will fail.
In this case, the optimal value should be selected based on the logic of the strategy. Don’t try to select the highest value (the global maximum point), it doesn’t make sense.
2) It can work as a filter: the more you tighten it, the higher the PF, average trade and the less the number of trades. But if you turn it off your strategy will fail.
In this case, you should select values based on the performance. On the one hand, you need a high average trade and PF, but on the other – you need a high total profit and a sufficient number of trades.
3) It can work like this:
In this case, choose a value that gives your strategy max. performance (PF, average trade).
In my momentum model, I have only two parameters: 'PA_Bars' and 'PA_Size%ATR'. There is no point to optimize the first one because I want to use only the last closed bar. So I have only one parameter to optimize - 'PA_Size%ATR'. Let's analyze it from 1 to 60 step 1:
Thus, 'PA_Size%ATR' behaves like a filter (see p. 2 III Model Parameter Analysis). It's good news, it is most likely a robust parameter. I set PA_Size%ATR to 36
IV. Time-stop, SL, TP
1) The math (stat) advantage of entry points and trades decreases with the position holding time. Therefore, it is necessary to use a time-stop (see parameters ‘StopBar‘ and ‘StopHour‘). The time-stop is a time-based stop loss that automatically closes trades at a specified time or after a certain number of bars has expired. Increasing the time-stop value increases performance. After a certain point, the performance does not increase or falls slightly. This point is the best value for a time-stop. But remember, the longer the holding time, the higher the trading risk.
2) Optimize SL/TP values one by one. Do not select too small or large values, follow the logic of your idea. The SL/TP values have little effect on performance for a good strategy.
Let's optimize 'StopBar' from 1 to 100 step 1: So, the time-stop works well, and no point to hold trades longer than ~ 43 bars. I set it to 40. 'StopLoss' from 0.05 to 1 step 0.05: The values 0.2....0.4 are good. I set it to 0.30 'TakeProfit' from 0.1 to 2 step 0.1: I set 'TakeProfit' to 1.5 Now the strategy looks better: PF=1.49, Avg.trade=8.1pips, Number of trades=1112, Total profit=906, spread=0.2pips, no slippage, 'open prices only' method, Alpari data from 2005 to 2018
V. Adding Filters
1) First, add a time filter. I recommend only filtering by range. Don’t remove certain hours, minutes. So you can prevent overfitting. As a rule, a momentum strategy is traded during active hours. MR strategies are usually used during hours of the calm market.
2) Try to add other filters (trend-based, volatility-based). A robust filter can behave like this:
The difference between the model parameter and filter is that if you exclude the filter, a strategy will show less performance, but it will work. If you exclude the model parameter, the strategy will fail, and the equity curve will turn into a random walk. You should not choose a value depending on the beauty of the growth chart. You must proceed from the fact that the avg. trade should be high enough to cover all trading costs (spread, commission) and give a profit. A trend-based filter can behave differently, it can work in a wide range, but if you turn the filter off, the strategy will not fail, it will work worse, but it will still work (that’s the difference between the model and filter).
3) In this stage, you may try to optimize/analyze the ATR period.
In my strategy, I set 'OrderHourStart' = 1, and 'OrderHourStop'=23. I'm going to trade momentum, so I don't want to trade it during low liquidity time. DayOfWeek tuning: So, the best days for trading are Tuesday, Wednesday, and Thursday. Monday is a low volatility day, so momentum does not work well. Friday is teeming with high impact news, thus the price reaches my short SL. I set 'OrderDayOfWeek' to 234 Trying to add a trend filter. Tuning 'EMA_Period' from -32 to 32 step 2, TF = Daily The filter works correctly. For my strategy, trading with the trend is more profitable than trading against the trend. I set 'EMA_Period' to 10. Now my strategy looks like this: PF=1.93, Avg.trade=14.5pips, Number of trades=518, Total profit=749, spread=0.2pips, no slippage, 'open prices only' method, Alpari data from 2005 to 2018 There are 518 trades left, nothing to filter anymore.
VI. Finishing Touches
1) Enable commissions, trading costs, set real spreads, slippages. Conduct tests using TDS2 software on the tick data with variable spreads (if your strategy requires good execution).
2) If it is needed add complicated exit rules.
3) If you are using PCh model then try to optimize ‘PCh_OffsetPip’, ‘HL/2_OffsetPip’ parameters.
It's a TDS2 test of my strategy, variable spreads, delay of 200-300ms, slippages, live execution (simulation), commission: $7 per one standard lot, round trip. Set-file of the strategy PF=1.92, Avg.trade=14.4pips, Number of trades=520, Total profit=748, 99.9% quality, Dukascopy data from 2005 to 2018