How to Build a Strategy + an Example.

If you want to create a robust strategy, the algorithm can be as follows:

I. Basic rules

1) Parameter tuning. Don’t tune 2 or more parameters simultaneously. Optimize only one parameter at the same time. Otherwise, you can’t get a good result because every 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 that it will be successful.

II. Preparatory stage

1) Try to formulate your idea and choose a 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. If the elements are irrelevant to the basic idea, then they should be considered/added separately, 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 value), commissions, and trading costs! Because in this stage, they can prevent you from seeing the real picture – whether your basic idea works or not. If you don’t do this, you can miss an excellent strategy or idea at the very beginning stage of development.

4) Disable complex exit rules like trailing stop, etc. Leave only SL and TP values and most importantly, set a value of the time-stop (see ‘StopBar‘ parameter). Its initial value is set equal to the max. period used in your trading model. The initial values of the SL and TP need to be set according to the type of your strategy. The SL/TP values should not be too small or too large; the values must correspond to the working TF and trading logic of your basic idea. If you want to create an MR strategy, then the SL value should be several times larger than the TP value. For a momentum or a breakout strategy, the SL value should be equal or several times less than the TP value.
For example, for a momentum strategy, set the initial TP value to 1.0 (ATR), SL to 0.5 (ATR).

5) Secondary parameters, like the ATR period (used for normalization) or offset parameters (PCh_OffsetPip, HL/2_OffsetPip) for the PCh model, are analyzed/optimized in the last stage. For now, set the ATR period to 5, set the offsets to 0.

6) Do not use the TDS2 software or any 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 try to create a momentum strategy. 
Basic idea: After 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 daily ATR), StopLoss=0.5, TakeProfit=1, 
TimeStop=1 (because in my idea, 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,, Number of trades=2061, Total profit=587, 
spread=0.2pips, no slippage, 'open prices only' method, from 2005 to 2018

Belkaglazer, How to create a trading strategy

Belkaglazer, How to create a trading strategy

As we can see, the main idea works))), but the average trade is small. 
If I did not turn off the spread, I might think that the idea does not work.

III. Analysis of model parameters

Now it is time to analyze the model parameters. Try to optimize and analyze them, one by one.

A robust parameter of a model can behave in 3 ways:

1) It can work in 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 is selected based on the main logic of a strategy. Don’t try to select the highest value (a 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, then 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.

Filter parameter

3) It can work like this:

Model parameter

In this case, it’s necessary to choose the value at which your strategy shows 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 for optimization, I have only one parameter  - 'PA_Size%ATR'.
Let's analyze it from 1 to 60 step 1:

Belkaglazer, How to create a trading strategy

Belkaglazer, How to create a trading strategy

Belkaglazer, How to create a trading strategy
Thus, the parameter 'PA_Size%ATR' behaves like a filter (see p. 2 III Analysis of model parameters). 
It's good news, there is a high probability it is a robust parameter.

I set PA_Size%ATR to 36

IV. Time-stop, SL, TP

1) The mathematical (statistical) 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 after a certain number of bars. Increasing the time-stop value increases the performance of a strategy. After a certain point, the performance does not change or falls slightly. So this point is the best value for a time-stop. But don’t forget, the longer the holding time, the higher the trading risk.


2) Optimize SL/TP values, one by one. Do not select too small or big values, be guided by common sense and take into account the logic of your basic idea. In a good strategy, the SL/TP values have little effect on performance

Let's optimize 'StopBar' from 1 to 100 step 1:

Belkaglazer, How to create a trading strategy

So, the time-stop works well, and it makes no sense to hold trades longer than ~ 43 bars.
I set it to 40.

'StopLoss' from 0.05 to 1 step 0.05:

Belkaglazer, How to create a trading strategy

The values 0.2....0.4 are good. I set it to 0.30

'TakeProfit' from 0.1 to 2 step 0.1:
Belkaglazer, How to create a trading strategy
I set 'TakeProfit' to 1.5

Now the strategy looks better:

Belkaglazer, How to create a trading strategy

PF=1.49,, 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. Only range. Do not remove certain hours, minutes so you can prevent overfitting. As a rule, a momentum strategy is traded during active hours, MR strategies are used during hours of the calm market.

2) Try to add other filters (trend, volatility). A robust filter can behave like this:

Filter parameter

The difference between a model parameter and a filter parameter is that if you exclude a filter, then a strategy will show less performance, but it will still work. If you exclude a model parameter, then the strategy will stop working, and the equity curve will turn into a random walk.
The specific value should not be selected based on the beauty of the growth chart. It is necessary to proceed from the fact that the avg. trade must be high enough to cover all trading costs and give a profit. A trend filter may behave differently, it can work in a wide range, but if you turn the filter off, then a strategy will not fail, it will still work, worse but will work (it is the difference between a model and a filter).

3) In this stage, you can try to optimize/analyze the ATR period.

In my strategy, I set 'OrderHourStart' = 1, and 'OrderHourStop'=23. I am going to trade momentum, 
so I don't want to trade it during low liquidity time.

DayOfWeek tuning:

Belkaglazer, How to create a trading strategy

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 reach 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

Belkaglazer, How to create a trading strategy

The filter works correctly. For my momentum 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:

Belkaglazer, How to create a trading strategy

PF=1.93,, 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, there is nothing to filter)))

VI. Finishing touches

1) Enable commissions, trading costs, set real spreads, slippages. Conduct tests using TDS2 software with tick data and variable spreads (if your strategy requires good execution).

2) If it is needed then add complicated exit rules.

3) If you are using PCh model then try to optimize ‘PCh_OffsetPip’, ‘HL/2_OffsetPip’ parameters.

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

Belkaglazer, How to create a trading strategy

PF=1.92,, Number of trades=520, Total profit=748, 
99.9% quality, Dukascopy data from 2005 to 2018

The End.