Categories
Uncategorized

Systems Selector! My new tools to find and select your best trading systems!

Well well well well, today I want to introduce you to my 3 tool, essential if like me you have more than 200 trading systems and every month you never know which one to choose!

Welcome to this new article, I am an algorithmic trader and today I will introduce you to my new tool!

Let’s start from the beginning, I had just started with algorithmic trading but I already had a few systems and therefore every month I found myself having to choose among my systems which ones to put live.

For a while I relied on a proprietary program, it wasn’t very performing but it had everything needed to compare systems and above all to be able to upload reports and immediately have the metrics of each system available. Over time I realized that this program didn’t measure some performances very well and there were quite a few discrepancies! So I began my online search for better software that was more accurate and offered me viable alternatives. I have not found it.

( you can find the link to the tool at the bottom of the article ) 

I didn’t understand how many automatic/algorithmic/systematic traders could choose between their strategies without comparing them 2 at a time, I still ask myself this question, I created my own answer and now I make it available to all of you.

I have been using this program for months now and every time I added new things and comparison metrics, now we are at a definitive version.

The tool allows you to load as many systems as you want, otherwise it will do everything on its own.

The first part you will see will be the filtering of your strategy reports, you will be able to choose which data to take from the report and measure each metric on the chosen data, you will have three possibilities:

  • Last 5% of trades made
  • Last 2 months
  • Entire report

This system will allow you to compare all the systems based on the chosen filtering and consider different points of view, personally I first use the last 5% of the trades made to evaluate the systems, and finally I move on to the last 2 months.

Having chosen the criterion that most interests you, let’s get to the important point. You will see a table like this:

This is the list of systems that I have uploaded, as an index you will have the name of the systems uploaded and then a series of metrics, the dataframe is interactive, so you can sort the columns as you like, I prefer the initial configuration which sorts according to the Net Profit

( you can find the link to the tool at the bottom of the article )

Let’s take a closer look at these metrics!

The first 5 columns therefore: Net Profit, Average Trade, % Profit and Profit Factor we know them very well, they need no explanation, they are based on the filtering criterion chosen above so if you choose the last 5% of the trades we will have the Net Profit of the last 5% of the trades for each system, if you choose “Last 2 Months” you will have the Net Profit of the last 2 months.

2 Months Positive is a metric I always look at, if the box is checked it means that the system has made profits in the last two months (excluding the current one).

New Highs last but not least, this simple box reports what it says, i.e. whether the system is making new highs!

Num Trade reports the number of trades made based on the filtering system previously chosen

Finally, Last Trading Day will tell you the date of the last open trade.

Now let’s see the graphics…

Below the table you will see these four graphs:

Naturally they are all interactive, so you can zoom them in and go into more detail, let’s see them one at a time..

Profitability Chart: Profit Factor / % Profit

This chart will show you the systems that have a higher Profit Factor based on % Profit, very useful indeed.

Profitability Chart: Net Profit / Num Trade

No less useful than the previous one we have this graph that will show you the systems that have achieved a higher Net Profit with fewer Trades, very useful for comparing the effectiveness between the various systems.

Max Drawdown / Systems

Here you will have all the Systems sorted by Drawdown, from the one that took the least losses to the one that made the most.

Net Profit / Systems

Last chart, you will get list of all systems in order of Net Profit.

I hope you like this tool and above all it will be useful to you, I created it out of necessity, I adapted it to the values I thought were most appropriate to evaluate automatic trading systems and compare them with each other, if you have any requests or suggestions do not hesitate to contact me, I will do my best to meet your requests!

The completely free tool can be found at this link.

Goodbye and see you in the next article!


Buy my 👉 Trading Systems

Join the 👉 Telegram group

Follow me on 👉 LinkedIn

If you want discounts for the platform I use contact me privately or buy via this 👉 MultiCharts

Categories
Uncategorized

Using the Herrick Payoff Index and Channel Breakout on Close Indicator for Trading Opportunities

The Herrick Payoff Index (HPI) is a complex formula that evaluates changes in price, volume, and open interest. HPI measures the flow of money into and out of a market.

Because its calculation includes open interest, HPI can only be used for futures and not for stocks. Another restriction of the HPI is that it can only be applied to daily data because there is no such thing as intraday or weekly open interest.

HPI can be used to confirm price action. When HPI rallies to a new high along with a new price high, volume (the number of contracts that change hands during a specified time period) and

open interest are confirming the bullish price action, and when HPI falls to a new low along with a new low in price, volume and open interest are confirming the bearish price action.

( I remind you that if you want to download the entire strategy you can find it at the bottom of the article, just join the Telegram channel )

However, when a new price high is accompanied by the failure of HPI to also make a new high, the price action is not confirmed by volume and open interest. A bearish divergence exists between the higher price high and the lower HPI high. Similarly, when a new price low is not matched by a new HPI low, the price action is unconfirmed by volume and open interest, and a condition of bullish divergence exists.

Bullish and bearish divergences are early warning signs of a possible change in trend. HPI confirmation of new price highs and new price lows suggests that the current trend is more likely to continue than to reverse.

Another component of this system is the channel breakout on close. When a market closes above the highest high of a specified number of bars, price action is bullish, and when a market closes below the lowest low of a specified number of bars, the market is bearish.

A system combining the Channel Breakout on Close Indicator and the Herrick Payoff Index should alert us to good trading opportunities. After a bullish setup, we’ll enter long at the high of the setup bar plus one point, and after a bearish setup, we’ll enter short at the low of the setup bar minus one point. The setup remains in effect for five days after the setup bar.

Our initial stop and trailing stop when long will be at the four-day low, and our initial stop and trailing stop when short will be at the four-day high. We’ll exit long positions on the close when HPI crosses below zero and exit short positions on the close when HPI crosses above zero.

Defining your Trading Rules

In this system, we defined both long entries and short entries as well as exit orders. We also did some setup work to calculate the Channel Breakout on Close Indicator and the Herrick Payoff Index, as well as their to compare them. The setup, entries and exits are described next.

Setup

Calculate the HPI values.

Look for confirmation of bearish price action by consistency between the closing price and the HPI. The closing price will be lower than the lowest low of the last 10 bars and the HPI will be lower than the lowest HPI of the last 10 bars. This is our sell setup.

Look for confirmation of bullish price action by consistency between the closing price and the HPI. The closing price will be higher than the highest high of the last 10 bars and the HPI will be higher than the highest HPI of the last 10 bars. This is our buy setup.

Long Entries

After a bullish or buy setup, we’ll enter long at the high of the setup bar plus one point.This setup will remain in effect for five days after the setup bar.

Short Entries

After a bearish or sell setup, we’ll enter short at the low of the setup bar minus one point. This setup will remain in effect for five days after the setup bar.

Exit Orders

Our initial stop and trailing stop when long will be at the 4-day low, and our initial stop and trailing stop when short will be at the 4-day high.

We’ll also exit long positions on the close when HPI crosses below zero and exit short positions on the close when HPI crosses above zero.

Designing & Formatting

This section presents the EasyLanguage instructions and formatting for the system, with the EasyLanguage instructions broken down and explained line by line.

( I remind you that if you want to download the entire strategy you can find it at the bottom of the article, just join the Telegram channel )

Inputs

Following is the list of all the inputs we used in this system:

In addition to these inputs, we define the following variables (notice that our variables CountL

and CountS are initialized to 5):

Vars: HPIVal(0), CountL(5), CountS(5);

Setup

We begin by calculating the HPI value using the HPI function and a contract value of 100 and a smoothing factor of .1. We store the resulting value in the variable HPIVal.

HPIVal = HPI(Mult, Factor);

Then we perform four comparisons and store the results in four different variables, Condition1 through Condition4. First, we check to see if the close of the current bar is greater than the highest high of the last 10 bars. We store the result in Condition1. Then we check to make sure the value in HPIVal is greater than the highest HPIVal value for the last 10 bars and make sure HPIVal is greater than zero. The result is stored in Condition2.

Next we check to see if the close of the current bar is less than the lowest low of the last 10 bars. We store the result in Condition3. And finally, we check to see if HPIVal is less than the lowest HPIVal value for the last 10 bars and make sure HPIVal is less than zero. The result is stored in Condition4.

Condition1 = Close > Highest(High, Length)[1];

Condition2 = HPIVal > Highest(HPIVal, Length)[1] AND HPIVal > 0;

Condition3 = Close < Lowest(Low, Length)[1];

Condition4 = HPIVal < Lowest(HPIVal, Length)[1) AND HPIVal < 0;

We use two counters, CountL and CountS. We increment these with each bar and reset them to 1 each time a buy setup or sell setup occurs, respectively. This way, we can keep a count and use them to keep buy and sell orders active for 5 bars:

CountL = CountL + 1; CountS = CountS + 1;

If the criteria specified in the conditional statements above, as appropriate, are true and the variables CountL or CountS is greater than 5, then CountL or CountS is reset to one. Since the buy or sell setup criteria is true, we want to place buy or sell orders, respectively, therefore, we need to set the counters to 1 so the next set of instructions are carried out.

If Condition1 AND Condition2 AND CountL > 5 thenCountL = 1;

If Condition3 AND Condition4 AND CountS > 5 thenCountS = 1;

Long & Short Entries

If the CountL variable is less than or equal to 5, a buy stop order is generated at the high of the setup bar plus 1 point. If the CountS variable is less than or equal to 5, a sell stop order is generated at the low of the setup bar minus 1 point.

If CountL <= 5 then Buy Next Bar at High[CountL] + 1 Point Stop;

If CountS <= 5 then Sellshort Next Bar at Low[CountS] — 1 Point Stop;

Long & Short Exits

A trailing stop for long positions will be placed at the lowest low of the last four bars. Conversely, we will place a trailing stop to cover our short positions at the highest high of the last four bars.

Sell Next Bar at Lowest(Low, 4) Stop;

Buytocover Next Bar at Highest(High, 4) Stop;

Additionally, the system will generate a long exit on the close of the current bar if the HPI value falls below zero. A short exit on the close of the current bar will be generated if the HPI value rises above zero.

If HPIVal < 0 then Sell this bar on Close;

If HPIVal > 0 then Buytocover this bar on Close;

Testing & Improving

Below I will show you the performance on some underlyings, of course the parameters have been optimized but they are not finished strategies, you will find the whole strategy on my Telegram channel so you can download it for free!

Now it’s your turn! I’ll leave you the complete strategy, let me know what you can do!


Buy my 👉 Trading Systems

Join the 👉 Telegram group

Follow me on 👉 LinkedIn

If you want discounts for the platform I use contact me privately or buy via this 👉 MultiCharts

Categories
Uncategorized

How to choose the parameters to optimize an automatic trading system

If you are also a trader and you develop automatic trading strategies, you absolutely have to ask yourself this question: What parameters do I choose during an optimization?

This question is by no means obvious and if you don’t answer it right it will have catastrophic effects on your systems and especially on your personal account.

In this article we will see how to optimize a trading system with one variable and with two variables.

In this article I use Tradestation, for those unfamiliar with it it is a trading platform that allows you to do automatic trading in a simple and safe way, the same goes for those who use Multicharts, I remind you that the concepts I explain are the same for whatever platform you are using.

Let’s start right away…

OPTIMIZATION WITH 1 PARAMETER

Suppose we have a system with tm Daily that enters long on the S&P 500 when the price exceeds a moving average of variable length and we exit the market after 6 bars (6 days), here is the system in its entirety:

Now we don’t know what length of the moving average to use for better performance, so we’re going to optimize the length of the average.

Well after a good optimization we find this system:

With a net profit of $139,000, an average trade of $335 and a drawdown of $37,000, you’ll say perfect, I’ve created a system, I’ll add a filter to lower the drawdown and that’s it!

Unfortunately this is not the case, let’s take a better look at what our optimization has done…

I optimized my moving average from 5 to 200 bars with steps of 5 and the Tradestation automatically chose the best result that I showed you above, but let’s see all the results:

Let’s zoom in on the part chosen by the optimization and with better parameters:

What you notice? I’m telling you this is called OVERFITTING, meaning too much adapting your system and metrics based on the past!

Do you know what happens if a system is OVERFITTED? YOU WILL LOSE YOUR MONEY

How to understand it? Well the answer is simple when you optimize just 1 parameter: LOOK AROUND

We see that in our case moving 10 bars in length from the selected result something very interesting: The net profit drops drastically and the drawdown increases!

Do you think it is a sign of stability? Well I would say NO!

But let’s see in more detail…

This is a simple chart showing NetProfit in relation to the length of the bars..

Notice the difference in just 10 bars? Moving the indicator 10 bars would have resulted in a $30,000 lower NetProfit and an almost doubled drawdown!

So guys be careful what parameters you select and always look at the surroundings!

OPTIMIZATION WITH 2 PARAMETERS

Let’s continue with the previous system, this time I don’t want to optimize only the length of the moving average but also the duration of the trade (i.e. the exit after tot bars), and therefore I put a new element in input: lenBar, I will optimize it to understand which parameter is the best.

So this time I proceed to optimize the length of the moving average from 5 to 200 with steps of 5 and the length of bars for the exit from 0 to 6 with steps of 1 (I don’t want to stay on the market for more than 6 days)

Let’s see the results and we notice that Tradestation offers us the same inputs I had before, therefore average length 80 and output after 6 bars!

Fine, but now that we have one more input how do we figure out which one is the best and the most stable? If optimizing 1 parameter we used a 2D graph, we just have to use a 3D graph to show 3 parameters! In this case we will have the optimized inputs in X and Y and in Z we will have the NetProfit, unfortunately Tradestation unlike Multicharts does not give us the possibility to do this, so we should do it ourselves.

For a while I used excel, but it was a tedious and graphically unappealing operation, so in the end I decided to write a small python tool and share it with all of you!

Well, by saving the report you can upload it to my site and the tool will do everything automatically.

Let’s see the results of my optimization:

What do you think? I’ll tell you, this system is not stable, the returns of the strategy after a few inputs vary considerably, this means that the system will not withstand long market variations or adverse conditions that arise after its creation, in this case if we choose the values we like the most like these:

But we will have an OVERFITTED system that at the first signs of change or even without signs of change the system will no longer perform and you WILL LOSE MONEY.

SO HOW TO AVOID BUILDING AN OVERFITTED SYSTEM?

The explanation with 1 and 2 parameters is very simple, look at the surroundings, they must be stable and above all the Net Profit must not fluctuate much. Of course there is one thing to say, optimizing a moving average on a daily tm is different from optimizing it on a 5-minute tm, so choose also and above all the optimization steps with criteria, as a too narrow step does not allow it will give a complete but too fragmented vision, while a large step will give us an overall vision but not detailed enough, the secret lies in the middle.

I hope this article has been useful and can help you in building your systems, if you have any questions do not hesitate to write me, I leave you the link to my site again to upload your 2 parameter reports

See you soon!


Join the 👉 Telegram group

Follow me on 👉 LinkedIn

If you want discounts for the platform I use contact me privately or buy via this 👉 MultiCharts