Exporting Strategy Performance XML files that use 15 years of 5-minute bars can be cumbersome. Using Maestro can be cumbersome too. I know there are great programs out there that will quickly analyze the XML files and do what we are about to do plus a bunch more. But if you want to do it yourself, try working with 224,377 KB files.
If you want to do a quick merge of equity curves of different markets or systems use this simple method. That is if you have Python, MatPlotLib and Pandas installed on your computer. Installing these are really simple and everybody is doing it. I created this script with the help of a paid version of ChatGPT.
Using Python et al. to plot combined equity curve.
Steps:
1,) Create a folder on you C drive: C:\Data
2.) Put this code into your strategy code. Make sure you change the output file name for each market/system combo that the strategy is applied to.
if t = sessionEndtime(0,1) then begin print(file("C:\Data\Sysname-NQ.csv"),d+19000000:8:0,",",netProfit + Openpositionprofit); end;
3.) Copy and paste the following code into your favorite Python IDE or IDLE.
import tkinter as tk from tkinter import filedialog import pandas as pd import matplotlib.pyplot as plt import os
def extract_market_name(filename): """Extracts the market name from the filename formatted as 'system-market.csv'.""" return os.path.splitext(filename)[0].split('-')[-1]
def load_equity_data(files): """Loads and aligns equity data from multiple CSV files.""" data_dict = {}
def calculate_metrics(equity_curve): """Calculates total profit and maximum drawdown from the equity curve.""" total_profit = equity_curve.iloc[-1] - equity_curve.iloc[0] peak = equity_curve.cummax() drawdown = peak - equity_curve max_drawdown = drawdown.max() return total_profit, max_drawdown, drawdown
def calculate_correlation(df): """Calculates and prints the correlation matrix of equity curves.""" correlation_matrix = df.corr() print("\n--- Correlation Matrix ---") print(correlation_matrix.to_string()) print("\n--------------------------")
def plot_equity_and_drawdown(df, drawdown): """Plots the combined equity curve and drawdown as separate subplots.""" fig, ax = plt.subplots(2, 1, figsize=(12, 8), sharex=True)
4.) Run it and multi-select all the system/market .csv files
5.) Examine the results:
Combined equity, maximum draw down, and correlation matrix
How did I get ChatGPT to code this for me.
I pay $20 a month for Chat and it learns from my workflows. The more I work with it, the more it knows my end goals to the scripts I am asking it to create.
Here are the prompts I provided Chat:
I want the user to be able to use tkinter to select multiple files that contain two columns: 1-date in yyyymmdd format and 2 – the equity value for that date. The filename consists of the system name and the market name and follows the following patterm: system name”-“market name”.csv”. I need you to extract the market from the filename. If the filename is “Gatts-GC.csv”, the market name is “GC.” Once all the files are opened, I need you to align the dates and create a combined equity curve. We can do this in matplotlib if you like. I need you to calculate the total profit and the maximum drawdown among the combined equity curves.
[SCRIPT FAILED]
My data does not included headers. The first column is the date in yyyymmdd with no separators and the second column is a float value. I think your pandas are having a hard time interpreting this
[SCRIPT WORKED]
That is perfect. Can we had a correlation analysis to the equity curves and print that out too.
[SCRIPT WORKED]
Can we plot the draw down on the same canvas as the equity curves?
[SCRIPT WORKED]
Could we put the draw down in a subplot instead of in the profit plot?
[FINAL SCRIPT] Look above
Am I Worried About Being Replaced by Chat GPT?
With Python and its data visualization libraries and EasyLanguage you can overcome some of the limitations of TradeStation. And of course, ChatGPT. I have been programming in Python for nine years now and I am very good at base Python. However, Pandas are still a mystery to me and interfacing with MatPlotLib is not super simple. Does it frustrate me that I don’t know exactly what ChatGPT is coding? Yes, it did at first. But now I use it as a tool. I may not be coding the Python, but I am managing ChatGPT through my well thought out prompts and my feedback. Does my knowledge of Python help streamline this process? – I think it does. And I have trained ChatGPT during the process. I am becoming a manager-programmer and ChatGPT is my assistant.
Backtesting with [Trade Station,Python,AmiBroker, Excel]. Intended for informational and educational purposes only!
Get All Five Books in the Easing Into EasyLanguage Series - The Trend Following Edition is now Available!
Announcement – A Trend Following edition has been added to my Easing into EasyLanguage Series! This edition will be the fifth and final installment and will utilize concepts discussed in the Foundation editions. I will pay respect to the legends of Trend Following by replicating the essence of their algorithms. Learn about the most prominent form of algorithmic trading. But get geared up for it by reading the first four editions in the series now. Get your favorite QUANT the books they need!
The Foundation Edition. The first in the series.
This series includes five editions that covers the full spectrum of the EasyLanguage programming language. Fully compliant with TradeStation and mostly compliant with MultiCharts. Start out with the Foundation Edition. It is designed for the new user of EasyLanguage or for those you would like to have a refresher course. There are 13 tutorials ranging from creating Strategies to PaintBars. Learn how to create your own functions or apply stops and profit objectives. Ever wanted to know how to find an inside day that is also a Narrow Range 7 (NR7?) Now you can, and the best part is you get over 4 HOURS OF VIDEO INSTRUCTION – one for each tutorial.
Hi-Res Edition Cover
This book is ideal for those who have completed the Foundation Edition or have some experience with EasyLanguage, especially if you’re ready to take your programming skills to the next level. The Hi-Res Edition is designed for programmers who want to build intraday trading systems, incorporating trade management techniques like profit targets and stop losses. This edition bridges the gap between daily and intraday bar programming, making it easier to handle challenges like tracking the sequence of high and low prices within the trading day. Plus, enjoy 5 hours of video instruction to guide you through each tutorial.
Advanced Topics Cover
The Advanced Topics Edition delves into essential programming concepts within EasyLanguage, offering a focused approach to complex topics. This book covers arrays and fixed-length buffers, including methods for element management, extraction, and sorting. Explore finite state machines using the switch-case construct, text graphic manipulation to retrieve precise X and Y coordinates, and gain insights into seasonality with the Ruggiero/Barna Universal Seasonal and Sheldon Knight Seasonal methods. Additionally, learn to build EasyLanguage projects, integrate fundamental data like Commitment of Traders, and create multi-timeframe indicators for comprehensive analysis.
Get Day Trading Edition Today!
The Day Trading Edition complements the other books in the series, diving into the popular approach of day trading, where overnight risk is avoided (though daytime risk still applies!). Programming on high-resolution data, such as five- or one-minute bars, can be challenging, and this book provides guidance without claiming to be a “Holy Grail.” It’s not for ultra-high-frequency trading but rather for those interested in techniques like volatility-based breakouts, pyramiding, scaling out, and zone-based trading. Ideal for readers of the Foundation and Hi-Res editions or those with EasyLanguage experience, this book offers insights into algorithms that shaped the day trading industry.
Trend Following Cover.
For thirty-one years as the Director of Research at Futures Truth Magazine, I had the privilege of collaborating with renowned experts in technical analysis, including Fitschen, Stuckey, Ruggiero, Fox, and Waite. I gained invaluable insights as I watched their trend-following methods reach impressive peaks, face sharp declines, and ultimately rebound. From late 2014 to early 2020, I witnessed a dramatic downturn across the trend-following industry. Iconic systems like Aberration, CatScan, Andromeda, and Super Turtle—once thriving on robust trends of the 1990s through early 2010s—began to falter long before the pandemic. Since 2020 we have seen the familiar trends return. Get six hours of video instruction with this edition.
Pick up your copies today – e-Book or paperback format – at Amazon.com