TradeStation

Using AI to Code TradeStation EasyLanguage: A Breakthrough for Traders

image of Barry Taylor from Emini-Watch.com

Barry Taylor

image of tradestation easylanguage and ai

TradeStation’s EasyLanguage is a powerful but sometimes challenging coding language. What if artificial intelligence could simplify the process of learning and writing code for indicators and systems?

The EasyLanguage Challenge

TradeStation’s proprietary EasyLanguage has been around for over 25 years. When it first appeared, it was revolutionary, allowing retail traders to code their own indicators and trading systems without extensive programming knowledge. Since then, similar languages have emerged – MultiCharts’ variation, NinjaTrader’s NinjaScript, and TradingView’s PineScript – but EasyLanguage remains relevant and valuable.

The challenge? Despite its name, EasyLanguage still has a learning curve that can be intimidating for non-programmers. This is where AI might offer a solution.

Testing AI Models for EasyLanguage Coding

Over the past year, several AI models have been tested for their ability to generate functional EasyLanguage code:

Each model was evaluated both “out of the box” and with their deep research/thinking options. Some tests included uploading EasyLanguage documentation like reference guides and example code to improve results.

The common problem? Most models generated hybrid code – a mixture of EasyLanguage and Python or other languages – making the code difficult to implement without significant editing.

The Breakthrough: Claude 3.7 Sonnet

About a month ago, Claude 3.7 Sonnet arrived and changed the game. Without any specific EasyLanguage documentation or deep research mode, this model demonstrated an exceptional ability to generate functional EasyLanguage code.

While not perfect, Claude 3.7 Sonnet produces code that’s extremely close to working immediately and can even help troubleshoot verification errors when they occur.

Five Ways AI Can Help with EasyLanguage

  1. Explaining code line by line: AI excels at breaking down existing code into understandable chunks, explaining each step in progressively simpler terms until you grasp the concepts.
  2. Debugging, improving, or commenting code: AI can identify errors, suggest improvements, and add explanatory comments to make code more readable and shareable.
  3. Converting other code to EasyLanguage: Though less tested, AI shows promise in converting indicators from different languages like PineScript to EasyLanguage and vice versa.
  4. Customizing existing code: For ‘Better’ indicator subscribers with access to open the code, AI can help modify and customize the existing indicators without requiring deep programming knowledge.
  5. Generating fresh code for indicators or systems: Perhaps most impressive, AI can create new indicators based on conceptual descriptions.

A Real-World Example: Hourly Volume Indicator

To test Claude’s capabilities, we requested an indicator that would calculate the average volume traded for each hour of the trading day, from the first bar to the current one, displayed as a histogram.

image of AI prompt example using Claude to generate a volume by hour TradeStation EasyLanguage indicator
AI Prompt Example Using Claude to Generate a Volume-by-Hour Indicator

Claude generated the initial code quickly, though it required a few iterations to perfect:

  • First, the code needed to be modified to handle 24-hour markets
  • A small array declaration error needed fixing
  • The plotting method needed simplification

After approximately 20 minutes of back-and-forth refinement, the result was an elegant, functioning indicator that efficiently used arrays to calculate and display hourly volume averages. Here is the EasyLanguage code:

{*
  Hourly Average Volume Indicator
  Purpose: Calculates the average volume traded for each hour of the trading day.
  Plots a single value for the current hour as a histogram.
  Suitable for continuous instruments like crude futures that trade day and night sessions.
*}

{ Array declarations }
Array: hourlyTotalVolume[24](0), hourlyBarCount[24](0), hourlyAvgVolume[24](0);

[IntrabarOrderGeneration = false]

Variables:
    hourIndex(0),           { Index for current hour }
    i(0),                            { Loop counter }
    barTime(0),              { Time of current bar }
    barHour(0),              { Hour of current bar }
    currentBar(0);          { Current bar number in calculation }

{ Increment the bar counter }
currentBar = currentBar + 1;

{ Get the time and hour of the current bar }
barTime = Time;
barHour = Floor(barTime / 100);
hourIndex = barHour; { Map hour (0-23) to array index }

{ Accumulate volume data for this hour }
hourlyTotalVolume[hourIndex] = hourlyTotalVolume[hourIndex] + Volume;
hourlyBarCount[hourIndex] = hourlyBarCount[hourIndex] + 1;

{ Calculate average volume for the current hour }
If hourlyBarCount[hourIndex] > 0 Then
    hourlyAvgVolume[hourIndex] = hourlyTotalVolume[hourIndex] / hourlyBarCount[hourIndex]
Else
    hourlyAvgVolume[hourIndex] = 0;

{ Plot only the current hour's average volume }
Plot1(hourlyAvgVolume[hourIndex], "Avg_Volume_Hour_" , Cyan);

Practical Applications

image of TradeStation EasyLanguage indicator generated by Claude AI showing average trading volume by hour

The finished indicator is shown above on the 15 largest futures markets. The indicator revealed interesting insights about trading volume patterns across these 15 different futures markets:

  • E-mini futures: Most active during first 3 hours (8:30 AM – 11:30 AM Chicago time)
  • Forex markets: More active during London trading hours, before US markets open
  • Crude oil and Natural gas: Consistent activity throughout the trading day
  • Bitcoin: Relatively level activity across all hours

A variation of this indicator calculates the average range (high to low) during each hour of trading. Combining the volume activity and price (or range) activity gives valuable information for traders in different time zones looking to focus on the most active markets during their trading hours. See: What Are the Best Markets to Trade?

Key Takeaways for Traders

AI assistance, particularly from Claude 3.7 Sonnet, has fundamentally changed the accessibility of EasyLanguage coding. Tasks that once required significant programming knowledge can now be accomplished through conversational requests and iterative refinement.

AI presents a powerful alternative that dramatically reduces the time and expertise required for traders looking to create custom indicators or systems. Whether explaining, debugging, converting, customizing, or generating EasyLanguage code from scratch, AI has NOW become an invaluable partner for TradeStation users looking to gain an edge in the markets.

About the Author

Barry Taylor is a full-time trader, owner of Emini-Watch.com and developer of the ‘Better’ Trading Indicators. The ‘Better’ Indicators are a unique set of 3 non-correlated indicators that will give you an edge, whether you’re a day trader, swing trader or investor. With over 14 years of full-time trading and traveling, Barry splits his time between Byron Bay, Biarritz and Kauai.

image of tradestation for mace users

TradeStation for Mac Users: A Step-by-Step Guide for 2024

If you’re looking to run TradeStation on a Mac, you’ve come to the right place. I’ve been using TradeStation on a Mac since 2010 – the best tech decision I ever made! But it hasn’t all been plain sailing – Apple hardware isn’t perfect, their ‘Retina’ displays require special settings, ...

image of trading backup plan

Trading Backup Plan: My 7 Step Plan for Hardware Failure

You need a trading backup plan because your hardware is going to fail, period. I’ve been emphasizing this for years, ever since the original version of this article appeared in 2010. Yet, after my own series of catastrophic failures in 2018, I realized I needed to update my approach. In ...

image of tradestation charts

TradeStation Charts: 20 Tips, Tricks & FAQs Answered

I’ve been using TradeStation charts for nearly 20 years, and before that, I used SuperCharts – the predecessor to the TradeStation platform. With over 25 years of TradeStation experience, I’ve compiled my top tips for getting the most out of TradeStation. From backing up your charts and files to optimizing ...