Check out my interview in Traders’ Magazine [Germany]

INTERVIEW WITH THE GERMANY BASED TRADERS´ Magazine 05.2024 (May 2024 Issue)

traders-mag.com

Note from George – Original text was written in German.  The text below is translated without modification.

George Pruitt was Director of Research at Futures Truth for 30 years.

During this time he checked the performance of more than 1000 trading strategies that were commercially available. He had contact with many prominent people in the algorithmic trading industry. He has also advised domestic and foreign customers and published a total of eight books. We talk to George Pruitt about his experiences during more than three decades of trading system development.

Traders’ media Gmbh – Eisenbahnstraße 53
97084 Würzbug

info@traders-mag.com

TRADERS´: YOU BEGAN WORKING FOR FUTURES TRUTH IN 1989, WHILE YOU WERE STUDENT. HOW DID THAT HAPPEN?

Pruitt: I was in my final year of college and looking for an internship. I saw an ad for Futures Truth in the newspaper. They were looking for a part-time programmer. After the interview with founder John Hill and programmer John Fisher, I got the job.

TRADERS´: FUTURES TRUTH HAS BEEN AN INSTITUTION IN THE INDUSTRY FOR A LONG TIME. WHAT DID THE PROVIDERS OF TRADING STRATEGIES THINK ABOUT THE PERFORMANCE OF THEIR APPROACHES BEING SUBJECT TO EXTERNAL VALIDATION AND THEREFORE MADE TRANSPARENT?

Pruitt: Many system providers used the results published in the magazine as a springboard to become leaders in the heyday of the trading systems industry.

Other providers were not so happy about their results being made available to the public. Particularly in the early days of system trading, only a few traders had the computing power, data or software to check the claims about the strategies made in the providers’ advertisements. Sometimes the results shown were not accurate at all. Futures Truth used a rigorous backtesting methodology, using tick data when necessary to create authentic track records. These sometimes contradicted the advertising material of the providers, who were of course not that enthusiastic about them.

TRADERS: WHAT SURPRISED YOU THE MOST WHILE TESTING ALL THESE STRATEGIES OVER THE YEARS?

Pruitt: I was surprised that some very expensive trading systems were not worth the price the customer paid for them. In fact, price had very little to do with success. One reason for this was that many strategy providers were not traders in the true sense, but rather engineers or scientists.

TRADERS’: IN THE 1990’S YOU TESTIFIED TO YOUR FEDERAL GOVERNMENT ON THE SUBJECT OF ALGORITHMIC TRADING. WHAT WAS IT ABOUT THEN?

Pruitt: In this particular case, I was asked to essentially answer the following question: “Can an algo that has low trading success have periods of success – and could it in the future-be more successful at all?” Of course, any trading system, good or bad, can have profit and loss margins. However, in my experience at the time, an algo with a negative expected value usually didn’t last long after a winning streak.

TRADERS: YOU SAID “ACCORDING TO MY EXPERIENCE AT THE TIME”. HAS YOUR OPINION LATER CHANGED?

Pruitt: Back then, markets were relatively inefficient. One might expect a solid backtest to be pretty indicative of future performance. In the meantime, however, the markets have evolved. Don’t get me wrong: all we can lean on is the backtest, and it will always stay that way. But I don’t think it’s as meaningful today as it was in the 1990s.

TRADERS: DO YOU REMEMBER A SUPERIOR SYSTEM THAT GOT INTO TROUBLE?

Pruitt: One example was Keith Fitschen and his “aberration” system. It was a breakout system based on Bollinger bands with a period length of 80 days and two standard deviations. The exit was at the moving average (middle band). In my opinion, it was one of the most successful trading systems of all time. From 2010 to 2020, however, the strategy went through a difficult phase. Keith believed that markets have become much more efficient. With his “Paradigm Shift” system, he basically turned the trading rules around, although not exactly. This resulted in it having a really poor performance in the backtest, but succeeding after that. But only temporarily. The success of the reverse approach did not last.

The graphic shows a comparison of Keith Fitschen’s original aberration system and his practically reversed paradigm shift strategy, each applied to crude oil. For a while, it seemed like the market had undergone a paradigm shift. But then the new strategy also disappointed.

This is what the capital curve of a typical trend-following strategy looks like across a portfolio of different futures contracts. There were big movements in 2008, 2010 and 2014. After that, it became more difficult

TRADERS: YOU ARE AN EXPERT IN THE DEVELOPMENT OF TRADING SYSTEMS. WHAT ABOUT YOUR PERSONAL TRADING?

I was two years into working at Futures Truth. It took this long to complete the CompuTrac-M conversion. Futures Truth was started by John Hill who also owned Hill Financial Group and Commodity Research. At this time the managed futures business was booming and I was asked to sit for the Series 3 exam and to help start trading Fisher and Hills algorithms. John Hill, in my opinion, was the greatest market technician of his time. He had several books on bar patterns and he exposed me to discretionary trading. I couldn’t see the same things he did on a chart. However, Fisher had canned many of John’s concepts and programmed them into Fortran. I am a programmer and a computer scientist first and foremost and could see how the ideas, expressed by code, could work and they did for many years. I am an algorithmic trader and will always be one. I never traded futures for my personal accounts due to the conflict of interests. I spend most of my time trading stocks and working on my first love – programming.

TRADERS: WHAT WAS IT LIKE BACK THEN? YOUR APPROACH TO STOCK TRADING?

Pruitt: It was the dot-com era. We simply bought everything and sold it again a little later, which had a certain dynamism. In doing so, we also saw the signs of the times and held back a lot before the end of the bubble.

Shown is the capital curve of a short-term mean reversion strategy on the Nasdaq E-mini future. It buys pullbacks and trades in the direction of the long-term moving average. However, the drawdowns can be significant. For example, there was a 30 percent setback from trade 98 to 107.

TRADERS: YOU LED THE BACK-OFFICE TEAM OF A $180 MILLION HEDGE FUND IN THE 1990S AND DEVELOPED THE CORE ALGORITHMS OF ANOTHER HEDGE FUND IN THE 2000S. HOW DID YOU MANAGE THE GREAT SUCCESS AND LATER DISILLUSIONMENT WITH TREND-FOLLOWING STRATEGIES?

Pruitt: In the early 2000s, trend-following strategies became more and more popular. Back then, the managers of funds of funds didn’t even look at you if you were trading discretionarily, with options or anything else to follow trends. I, too, had included trend following in our programs and had some success with it. But at some point the zenith was passed. After the last major movements in raw materials and the stock market in the early 2010s, many hedge funds and commodity trading advisors (CTAs) had to give up. A two-percent fixed fee and a 20 percent performance fee are great when you’re making money, but it’s very hard when you’re not. The High Watermark became an obstacle that was difficult to overcome. At the same time, small hedge funds and CTAs in particular had to spend far too much money in relative terms to comply with the now stricter regulations.

TRADERS: NEVERTHELESS, TREND FOLLOWING IS STILL ONE OF THE MOST WELL-KNOWN TRADING STRATEGIES TODAY. WHY IS THAT?

Pruitt: For one thing, timing isn’t that important. And on the other hand, you do what the commandments of trading tell us: be selective when you enter, let the profits run, give the market room to its noise, and limit the losses. Most markets lend themselves well to trend following. And many of these systems have few parameters, so that over-optimization is hardly possible. This is also important.

TRADERS: WHAT DOES YOUR OWN TRADING APPROACH LOOK LIKE TODAY?

Pruitt: I trade a small portfolio of stocks on the daily chart. In doing so, I rely on both breakouts and mean reversion. I overlay levels on a 5-minute chart using Camarilla pivot points, for example, in order to systematically find entry levels. I derive the corresponding levels from the daily chart. The decisive factors here are indications that speak for a breakout or even a countercyclical trade. In these places, the risk can also be kept low. I also rely on the pyramiding of positions. However, my portfolio only contains stocks that I know and that I would hold for the long term.

TRADERS: IT IS SAID THAT AMONG DISCRETIONARY TRADERS ARE BOTH THE BEST AND THE WORST OF ALL. HOW MANY SUCCESSFUL DISCRETIONARY TRADERS THERE ARE IN THEIR EXPERIENCE?

Pruitt: Discretionary traders make a lot of money – but also lose it. For me, that’s not the way to go. I’ve met a lot of discretionary traders. But not many have been successful in the long run. Most eventually turn to algorithms – either as complete trading systems or as tools.

TRADERS: IT IS ALSO SAID THAT DISCRETIONARY TRADERS ALSO FOLLOW A SYSTEM. THE ONLY DIFFERENCE IS THAT THEY HAVE NOT YET SUFFICIENTLY SPECIFIED THEIR (UNCONSCIOUS) RULES. WOULD YOU AGREE WITH THAT?

Pruitt: Absolutely. We have a pattern in our head that we follow. You can’t just trade based on a gut feeling and be successful with it.

TRADERS: SYSTEMATIC TRADING HAS, BUT THERE ARE ALSO DOWNSIDES. WHAT ARE THEY?

Pruitt: It’s very challenging in a number of ways. Of course, if you’re winning non-stop with a system, it’s great. But what if ten losses occur in a row? At this point, at the latest, you start to doubt. To a certain extent, you have to enter the market with a blunt instrument and hope that your diligence in system development will pay off in the end. Remember, no matter what type of trader you are, your worst drawdown is yet to come. That’s why I believe that a multi-strategy approach works best. The hope, of course, is that diversification will improve earnings. In the end we were trading five different systems on almost the same portfolio.

TRADERS: THE MARKETS ARE CONSTANTLY CHANGING. IN 2001 YOU WROTE ABOUT IT, WHICH, FROM THEIR POINT OF VIEW, ARE THE BEST SYSTEMS FOR SHORT-TERM TRADING. HOW HAS THIS DEVELOPED OVER THE LAST TWO DECADES?

Pruitt: The best short-term swing systems in 2001 were based on breaking out of the opening range. The traders made a lot of money with this very simple approach. Toby Crabel wrote one of the best books about it. With the disappearance of the pits, the opening range was diluted. That said, I believe it still works for stocks and stock indices. Together with system developer Murray Ruggiero, we developed the Dynamic Open approach. The opening of the trading day is not based on time, but on a constant increase in volume. This also worked for a while, but unfortunately not permanently. Currently, the best short-term systems are based on mean reversion approaches.

TRADERS: CAN YOU GIVE US AN EXAMPLE?

Pruitt: You can use short-term Bollinger Bands, the Relative Strength Index, or anything else that shows a move away from the average. Buying pullbacks can be difficult because you don’t know where to end up in the downcycle.

 

TRADERS: SPEAKING OF MARKETS THAT CHANGE OVER TIME, HOW LONG DO YOU THINK IS THE IDEAL PERIOD FOR BACKTESTING?

Pruitt: The markets have undergone a change in strategy. It used to be that the more data, the better. But now I think that old data is affecting the validity of the results. A test period of ten to 15 years is more than sufficient these days.

TRADERS: ONE OF THE CHALLENGES OF BACKTESTING IS TO HAVE ENOUGH HIGH-QUALITY DATA IN THE FIRST PLACE. WHAT DO YOU WORK WITH? IS IT POSSIBLE TO ACHIEVE GOOD RESULTS EVEN WITH FREE DATA?

TO ACHIEVE THE BEST POSSIBLE RESULTS?

Pruitt: You can work with free data. This means that a positive expected value can be derived from it. But I would never trade it. Yahoo Finance and Quandl offer some free data, and good daily data is also relatively cheap. I’m using Pinnacle Data for commodities. They are very reasonably priced and very good. The same goes for CSI Data. I also test with Trade Station and their data. The integration of data, testing and trading in one package like TradeStation or MultiCharts is the main reason why I wrote my book series on EasyLanguage. Despite its limitations, it is probably the best programming language for beginners.

This capital curve looks too good to be true. That’s why caution is advised when it comes to data mining. However, it can also be the birth of a trading idea – used consciously – by optimizing all possible entry points and holding periods. Every once in a while, you’ll find something that works and can withstand rigorous testing.

TRADERS ́: WHAT ABOUT THE OLD IDEA OF DEVELOPING THE WORST POSSIBLE TRADING STRATEGY AND THEN JUST TRADING THE OPPOSITE?

Pruitt: That can work. You need to keep an eye on the average trade metric. If it’s high (big avgerage loss), why not? Often, bad systems are the ones that can’t cover their trading costs, and that’s a function of trade frequency. So a bad system that trades too much will always be a bad system.

TRADERS ́: WHAT INDICATORS WERE YOUR FAVORITES OVER THE YEARS?

Pruitt: I like Bollinger Bands, Keltner Channels, Moving Averages, and the MACD. Through Murray Ruggiero, I was introduced to John Ehlers’ indicators such as the Laguerre RSI and the Dominant Cycle. RSI and stochastic are good for the entry point, but not necessarily for making the entry decision.

TRADERS: DAY TRADING STRATEGIES ARE VERY POPULAR. HOWEVER, MANY PEOPLE UNDERESTIMATE HOW DIFFICULT IT IS TO EARN MONEY IN THE LONG RUN. WHAT ARE THE BIGGEST CHALLENGES?

Pruitt: Day trading can be successful, but you can’t trade too many times a day, and you can’t trade every day. The algorithms need appropriate filter rules. However, it’s hard for many traders to skip a day if they’re day traders. You have to wait for a setup. Waiting is perhaps the hardest part.

TRADERS: DO YOU HAVE ANY TIPS FOR DAY TRADERS THAT CAN BE USED TO IMPROVE RESULTS?

Pruitt: Identify support and resistance levels and trade around those levels. Be selective about which trades you make and don’t trade more than three times a day. In addition, filters should be developed to avoid bad trades in the first place.

TRADERS: WHAT ARE THE ANOMALIES IN RETURNS? THAT STILL EXIST TODAY?

Pruitt: There are still patterns in the market. They are a reflection of human nature. And there are persistent anomalies that can be detected with data mining tools. One example is the turn-of-the-month strategy. For day traders, there are specific times on the trading day that are suitable for long or short trades.

And the aforementioned open range breakout, which I still believe in, as well as the trade in the opposite direction in case the initial setup fails.

TRADERS: NO STRATEGY ALWAYS YIELDS PROFITS. THAT’S WHY SYSTEMATIC TRADERS NEED DIFFERENT APPROACHES THAT COMPLEMENT EACH OTHER. CAN YOU SHOW US A COMBINATION TO START WITH?

Pruitt: I would combine a trend-following approach with mean reversion and day trading. The trend-following portfolio should be the largest.

Mean Reversion only works in a handful of markets, and you should test this to see which markets are in this mode. When day trading, you should stick to markets with high volume and high volatility. As a rule, these are stocks and stock indices.

TRADERS: ONE CONTROVERSIAL ELEMENT OF STRATEGY DEVELOPMENT IS OPTIMIZATION. HOW MUCH DO YOU THINK SHOULD BE OPTIMIZED?

AND WITH WHAT APPROACH?

Pruitt: At the end of the day, all system developers are optimizing. A common question is whether you should use different parameters for different markets. When I was still working with managed futures, we didn’t allow for different parameters for different markets. We programmed concepts that were functions of the market, such as the Average True Range (ATR).

However, I believe that different parameters can work as long as you don’t overdo it, for example by optimizing individual parameters over too large a space. Data mining using genetic optimization can also be useful. On the other hand, I don’t believe in walk-forward optimization. This means that you are always behind the curve.

TRADERS: ONE METHOD OF OPTIMIZATION IS TO FILTER OUT THE LESS ATTRACTIVE SIGNALS WITHOUT COMPROMISING THE GOOD ONES. IS IT POSSIBLE TO IMPLEMENT THIS CONSCIENTIOUSLY?

Pruitt: Often, losing signals go hand in hand with a certain type of market behavior. In this case, filtering is the best approach to improve.

Let’s take a day trading system that trades every day but makes a loss overall. If you add that it only trades after days with a tight trading range, the performance of the system often increases.

TRADERS: YOU HAVE EXTENSIVE PROGRAMMING SKILLS IN DIFFERENT LANGUAGES. WHICH OF THEM ARE FOR YOU TODAY

MOST USEFUL?

Pruitt: Definitely Python and EasyLanguage. The latter is more or less identical to PowerLanguage from MultiCharts. Most trading strategies can be programmed in EasyLanguage to test and generate signals. Python allows you to test ideas outside of EasyLanguage, mainly because of the data limitations and access to academic libraries.

TRADERS: TODAY, ARTIFICIAL INTELLIGENCE (AI) IS ON EVERYONE’S LIPS. YOU HAVE ALREADY DEALT WITH SIMILAR IDEAS A FEW YEARS AGO.

IN WHICH AREAS CAN AI HELP?

Pruitt: We were already working with AI in the 1990s. She can help the trader develop the code and explain the huge library of indicators. Genetic optimization is helpful to some extent. As far as machine learning goes, I haven’t had any personal experience, but I’ve seen some disappointing results.

TRADERS: WITH YOUR KNOWLEDGE OF MORE THAN 1000 DIFFERENT ALGORITHMS, YOUR PROGRAMMING SKILLS AND ALL THE DATA AT YOUR DISPOSAL, DO YOU HAVE THE HOLY GRAIL FOUND?

Pruitt: In quantum circles, I was known as a “bubble brusher.” Often, developers and traders tested with table calculations and didn’t realize that they were cheating by unconsciously using future information. It’s easy to do. For example, you make the decision to trade at the open, but you accidentally use the daily close in your calculations for the signal. Most test platforms nowadays prevent such leaks, in the case of EasyLanguage, for example, through the “next bar” paradigm. However, if you have multiple signals that can be triggered on the same day, it is difficult to determine which one actually took place from a back testing perspective. In other words, during the back test if you need to know which long position was initiated from the various potential trade signals, the next bar paradigm makes it difficult to ascertain this.

TRADERS’: BASED ON YOUR DECADES OF EXPERIENCE, WHAT DO YOU RECOMMEND THAT ASPIRING TRADERS SHOULD START WITH?

Pruitt: John Hill’s most famous saying was, “Trading is the hardest way to make easy money!” Those of us who were able to act in the 1980s, 1990s, and a few years after were gifted. Arbitrage opportunities abounded at the time. John often said that trading bonds in those days was as easy as shooting fish in an aquarium. Today, on the other hand, it is very difficult to trade successfully. We have better instruments, but the market is more efficient. Countless market participants, access to data and fast computers have robbed us of easy profit opportunities. I would definitely recommend using an algorithm, and not trading too frequently. Don’t worry about every little movement in the market. Sooner or later, a bigger one will inevitably come. And be prepared to change your preconceived notions. Don’t try to force anything.

Infobox: Toby Crabel

Toby Crabel is a successful tennis player, US futures trader and fund manager at the hedge fund Crabel Capital Management, which he founded. In 1990, he published the book "Day Trading With Short Term Price Patterns and Opening Range Breakout", which is now considered a collector's item. On Amazon, more than 500 euros are called up, on the US site even over 1000 US dollars.

Source: Wikipedia

Infobox: Pivot-Punk Clique

Camarilla pivot points are a modified version of the classic pivot points. Introduced in 1989 by Nick Scott, a successful bond trader, they indicate potential intraday support and resistance levels. Similar to classic pivot points, they use the previous day's high, low, and close. However, Fibonacci numbers are used in the calculation of levels.

What: https://www.babypips.com

Multi-Agents and the Power of the Series Function

Jeff Swanson wrote a great post on multi-agent trading a few years ago.

Jeff created a simple mean reversion system and then created two derivatives that culminated in three systems (or three agents.)  Using Murray Ruggiero’s Equity Curve Feedback, he was able to poll which system was doing the best, synthetically, and execute the strategy that showed the best performance.   If memory serves, picking the highflyer turned out to be the way to go.  Jeff had just touched the surface of Murray’s tool. but it definitely did the job.  Murray contracted me to fix some problems with the ECF tool and I did, but the tool is just way too cumbersome, resource hungry and requires a somewhat higher level of EasyLanguage knowledge to be universally applicable.  I was doing similar research in the area of polling multiple strategies and picking the best, just like Jeff did, and just executing that one system, when I thought about this post.  Traders do this all the time.  They have multiple strategies in the pipeline and monitor the performance and if one is head and shoulders better than what they are currently trading, they will switch systems.  This was one of the side benefits of the ECF tool.

What is an agent

An agent is any trading system that produces a positive expectancy.  Using multiple agents in a polling process allows a trader to go with the strategy that is currently performing the best.  This sounds reasonable, but there are pitfalls.  You could always be behind the curve – picking the best system right before it has its draw down.  Agents can be similar, or they can be totally different types of systems.  I am going to follow in Jeff’s footsteps and create three agents with the same DNA.  Here is what I call the AgentSpawner strategy.

inputs: movAvgLen(200),numDownDays(3),numDaysInTrade(2),stopLoss(5000);


value1 = countIf(c < c[1],numDownDays);
if c > average(c,movAvgLen) and value1 = numDownDays then
buy next bar at open;
if barsSinceEntry = numDaysInTrade then
sell next bar at open;
if marketPosition = 1 then sell next bar at entryPrice - stopLoss/bigPointValue stop;
Use this template and optimize inputs to spawn new agents

This code trades in the direction of the longer-term moving average and waits for a pull back on N consecutive down closes.  I am using the neat function countIF. This function counts the number of times the conditional test occurs in the last N bars.  If I want to know the number of times I have had a down close in the last 3 days, I can use this function like this.

Value1 = countIF(c<c[1],3);

// this is what the function doues
// 1.) todays close < yesterdays close + 1
// 2.) yesterdays close < prior days close + 2
// 3.) day before yesterdays close < prior cays close + 3

// If value3 = 3 then I know I had three conscecutive down
// closes. If value3 is less than three then I did not.

If the close is greater than the longer-term moving average and I have N consecutive down closings, then I buy the next bar at the open.  I use a wide protective stop and get out after X bars since entry.  Remember EasyLanguage does not count the day of entry in its barsSinceEntry calculation.  I am not using the built-in setStopLoss as I don’t want to get stopped out on the day of entry.  In real trading, you may want to do this, but for testing purposes my tracking algorithm was not this sophisticated.  I spawned three agents with the following properties.

	Case 1: //Agent 1
movAvgLen = 200;
numDownDays = 2;
numDaysInTrade = 15;
stopLoss = 7500;
Case 2: //Agent 2
movAvgLen = 140;
numDownDays = 3;
numDaysInTrade = 9;
stopLoss = 2500;
Case 3: //Agent 3
movAvgLen = 160;
numDownDays = 3;
numDaysInTrade = 15;
stopLoss = 2500;

System Tracking Algorithm

This is why I love copy-paste programming.  This can be difficult if you don’t know your EasyLanguage or how TradeStation processes the bars of data.  Get educated by checking my books out at amazon.com – that is if you have not already.  This code is a very simplistic approach for keeping track of a system’s trades and its equity.

value4 = countIf(c<c[1],4);
value3 = countIf(c<c[1],3);
value2 = countIf(c<c[1],2);
//Agent #1 tracking algorithm
if sys1Signal<> 1 and c[1] > average(c[1],160) and value2[1] = 2 then
begin
sys1Signal = 1;
sys1BarCount = -1;
sys1TradePrice = open;
sys1LExit = open - 7500/bigPointValue;
end;
if sys1Signal = 1 then
begin
sys1BarCount+=1;
if low < sys1LExit and sys1BarCount > 0 then
begin
sys1TradePrice = sys1LExit;
sys1Signal = 0;
end;
if sys1BarCount = 16 and sys1Signal = 1 then
begin
sys1TradePrice = open;
sys1Signal = 0;
end;
end;
Yes, this looks a little hairy, but it really is simple stuff

I am pretending to be TradeStation here.  First, I need to test to see if Agent#1 entered into a long position.  If the close of yesterday is greater than the moving average, inclusive of yesterdays close, and there has been two consecutive down closes, then I know a trade should have been entered on todays open.  EasyLanguage’s next bar paardigm cannot be utilized here.  Remember I am not generating signals, I am just seeing if today’s (not tomorrows or the next bars) trading action triggered a signal and if so, I need to determine the entry/exit price.  I am gathering this information so I can feed it into a series function.  If a trade is triggered, I set four variables:

  1. sys1Signal – 1 for long, -1 for short, and 0 for flat.
  2. sys1BarCount – set to a -1 because I immediately increment.
  3. sys1TradePrice – at what price did I enter or exit
  4. sys1LExit – set this to our stop loss level

If I am theoretically long, remember we are just tracking here, then I need to test, starting with the following day, if the low of the day is below our stop loss level and if it is I need to reset two variables:

  1. sys1TradePrice – where did I get out
  2. sys1Signal – set to 0 for a flat position

If not stopped out, then I start counting the number of bars sys1Signal is equal to 1.  If sys1BarCount = 16, then I get out at the open by resetting the following variables:

  1. sys1TradePrice = open
  2. sys1Signal = 0

If you look back at the properties for Agent#1 you will see I get out after 15 days, not 16.  Here is where the next bar paradigm can make it confusing.  The AgentSpawner strategy says to sell next bar at open when barsSinceEntry = 15.  The next bar after 15 is 16, so we store the open of the 16th bar as our trade price.

Now copy and paste the code into a nice editor such as NotePad++ or NotePad and replace the string sys1 with sys2.  Copy the code from NotePad++ into your EasyLanguage editor.  Now back to NotePad++ and replace sys2 with sys3.  Copy that code into the EL edition too.  Now all you need to do is change the different properties for each agent and you will have three tracking modules.

The Power of the EasyLanguage Series Function

The vanilla version of EasyLanguage has object-oriented nuances that you may not see right off the bat.  In my opinion, a series function is like a class.  Before I get started, let me explain what I mean by series.  All EasyLanguage function are of three types.

  1. simple – like a Bollinger band calculation
  2. series – like we are talking about here
  3. auto-detect – the interpreter/compiler decides

The series function has a memory for the variables that are used within the function.  Take a look at this.

input: funcID(string),seed(numericSimple);

vars: count(0);
if barNumber = 1 then // on first bar seed count
count = seed;
count = count+1;
print(d," ",funcID," ", count);
SeriesFunctionTest = count;
Count is class-like member

On the first bar of the function call – remember it will be called on each bar in the chart, the function variable count is assigned seed. Seed will be ignored on subsequent bars.   What makes this magical is that no matter how many times you call the function on the same bar it remembers the internal variables on somewhat of a hierarchical basis (each call remembers its own stuff.)  It like a class in that it gets instantiated on the very first call.  Meaning if you call it three times on the first bar of the data, you will have three distinct internal variable memories.  Take a look at my sandbox function driver and its output.

result = SeriesFunctionTest("Call #1",50);
result = SeriesFunctionTest("Call #2",5);
result = SeriesFunctionTest("Call #3",100);

//outPut

1170407.00 Call #1 51.00 //first bar 51 = seed + count + 1
1170407.00 Call #2 6.00 //first bar 6 = seed + count + 1
1170407.00 Call #3 101.00 //first bar 101 = seed + count + 1

1170410.00 Call #1 52.00 // second bar it remembered count was 51
1170410.00 Call #2 7.00 // second bar it remembered count was 6
1170410.00 Call #3 102.00 // second bar it remembered count was 101

1170411.00 Call #1 53.00 // you have a unique function values that
1170411.00 Call #2 8.00 // were instantiated on the first bar
1170411.00 Call #3 103.00 // of the test.

1170412.00 Call #1 54.00
1170412.00 Call #2 9.00
1170412.00 Call #3 104.00
Series functions rock - but they are resource hungry

Why is this important?

I have created a PLSimulator function that keeps track of the three agent’s performance.  I need the profit or loss to stick with each function and then also add or subtract from it.  This is a neat function.  Remember if you like this stuff buy my books at Amazon.com.

//ProfitLoss Simulator
Inputs: signal(numericseries),tradePrice(numericSimple),orderType(numericSimple),useOte(Truefalse);
Vars:dmode(0),LEPrice(-99999),LXPrice(-99999),SEPrice(-99999),SXPrice(-99999);
vars: GProfit(0),OpenProfit(0);
vars: modTradePrice(0);

vars: printOutTrades(True);

modTradePrice = tradePrice;

if orderType = 1 then // stop order
begin
if signal = 1 or (signal = 0 and signal[1] = - 1) then
modTradePrice = maxList(open,modTradePrice);
if signal = -1 or (signal = 0 and signal[1] = 1) then
modTradePrice = minList(open,modTradePrice);
end;

if orderType = 2 then // limit order
begin
if signal = 1 or (signal = 0 and signal[1] = - 1) then
modTradePrice = minList(open,modTradePrice);
if signal = -1 or (signal = 0 and signal[1] = 1) then
modTradePrice = maxList(open,modTradePrice);
end;
if orderType = 3 then // market order
begin
modTradePrice = open;
end;

If Signal[0]=1 And (Signal[1]=-1 Or Signal[1]=0) Then
begin
LEPrice=modTradePrice;
SXPrice = -999999;
condition1 = false;
If Signal[1]=-1 Then
begin
SXPrice=modTradePrice;
GProfit=(SEPrice-SXPrice)+GProfit;
condition1 = True;
End;
if not(condition1) then
if printOutTrades then Print(d," L:Entry ",LEPrice)
else
if printOutTrades then Print(d," L:Entry ",LEPrice," ",(SEPrice-SXPrice)*bigPointValue:8:2," ",GProfit*bigPointValue:9:2);
End;
{('***********************************************}
If Signal[0]=-1 And (Signal[1]=1 Or Signal[1]=0) Then
begin
SEPrice=modTradePrice;
LXPrice = 999999;
condition1 = false;
If Signal[1]=1 Then
begin
condition1 = True;
LXPrice=modTradePrice;
GProfit=(LXPrice-LEPrice)+GProfit;
End;
if not(condition1) then
if printOutTrades then Print(d," S:Entry ",SEPrice)
else
if printOutTrades then Print(d," L:Exit ",LXPrice," ",(LXPrice-LEPrice)*bigPointValue:8:2," ",GProfit*bigPointValue:9:2);

End;
If Signal[0]=0 And Signal[1]=-1 Then
begin
SXPrice = modTradePrice;
GProfit=(SEPrice-SXPrice)+GProfit;
if printOutTrades then Print(d," S:Exit ",SXPrice," ",(SEPrice-SXPrice)*bigPointValue:8:2," ",GProfit*bigPointValue:9:2);

end;
If Signal[0]=0 And Signal[1]=1 Then
begin
LXPrice = modTradePrice;
GProfit=(LXPrice-LEPrice)+GProfit;
if printOutTrades then Print(d," L:Exit ",LXPrice," ",(LXPrice-LEPrice)*bigPointValue:8:2," ",GProfit*bigPointValue:9:2);

end;

If Signal[1]=1 And useOte=True Then
begin
OpenProfit=(Close[1]-LEPrice);
End;
If Signal[1]=-1 and useOte=True Then
begin
OpenProfit=(SEPrice-Close[1]);
End;
If Signal[1]=0 Or useOte=False Then
begin
OpenProfit=0;
End;

PLSimulator=(GProfit+OpenProfit)*bigpointvalue;
Simulate profit and loss and more importantly keep track of it

Feed tracker algorithm data into the function

Your information must be properly assigned to get this to work.  First, I show how to get the information into the function.  The function does all the work and returns the equity.  I then determine the best agent by looking at the ROC over the past thirty days of equity for each agent and pick the very best.  I then trade the very best.  This is a very quick application of the function.  I will have a more sophisticated function, something akin to Murray’s ECF but with much less overhead and more strategy templates.

sys1Equity = PLSimulator(sys1Signal,sys1TradePrice,1,True);
sys2Equity = PLSimulator(sys2Signal,sys2TradePrice,1,True);
sys3Equity = PLSimulator(sys3Signal,sys3TradePrice,1,True);


vars: multiAgent(0);

value1 = maxList(sys1Equity-sys1Equity[30],sys2Equity-sys2Equity[30],sys3Equity-sys3Equity[30]);
multiAgent = 1;
if sys2Equity-sys2Equity[30] = value1 then multiAgent = 2;
if sys3Equity-sys3Equity[30] = value1 then multiAgent = 3;


{print(d," ",sys1Equity-sys1Equity[30]," ",sys1Equity);
print(d," ",sys2Equity-sys2Equity[30]," ",sys2Equity);
print(d," ",sys3Equity-sys3Equity[30]," ",sys2Equity);}
print(d," MultiAgent ",multiAgent);

//system parameters
vars: movAvgLen(200),numDownDays(3),numDaysInTrade(2),stopLoss(5000);
Switch ( multiAgent )
Begin
Case 1:
movAvgLen = 200;
numDownDays = 2;
numDaysInTrade = 15;
stopLoss = 7500;
Case 2:
movAvgLen = 140;
numDownDays = 3;
numDaysInTrade = 9;
stopLoss = 2500;
Case 3:
movAvgLen = 160;
numDownDays = 3;
numDaysInTrade = 15;
stopLoss = 2500;
End;
// Actual system execution
value1 = countIf(c < c[1],numDownDays);

if multiAgent <> multiAgent[1] then print(d," ---->multiagent trans ");

if c > average(c,movAvgLen) and value1 = numDownDays then
begin
if multiAgent = 1 then buy("Sys1") next bar at open;
if multiAgent = 2 then buy("Sys2") next bar at open;
if multiAgent = 3 then buy("Sys3") next bar at open;
end;
if barsSinceEntry >= numDaysInTrade then
sell next bar at open;
if marketPosition = 1 then sell next bar at entryPrice - stopLoss/bigPointValue stop;
Cool usage of a switch-case and agent determination

If this seems over your head…

Get one of my books are check out Jeff Swanson’s course.  EasyLanguage has so many little nuggets that can help you define your algorithm into an actionable strategy.  You will never know how your strategy will work until your program it (properly) and back test it.  And then potentially improve it with optimization.

Multi-Agent Results