Using Python in Build Alpha [Creating Custom Signals]

Build Alpha and Python

As 2017 comes to an end, I want to introduce one more upgrade to BuildAlpha in its first year. As you know Build Alpha allows users to create, stress test, and even generate tradable code without ANY programming at all.

It also allows traders to use a custom drag and drop signal builder to create unique rules and signals to test alongside the pre-built Build Alpha signal library of nearly 5,000 signals – and growing (below is a picture of the drag and drop custom signal builder).

However, I have now added a python environment to give traders even more freedom. Traders now have the ability to code their own signals in python and test these signals in the Build Alpha strategy creation engine.

Again, you do NOT need ANY programming skills to use Build Alpha but if you WANT to you can now use python to create signals, but you do NOT have to as Build Alpha will work without. This is just an upgrade for the more sophisticated traders out there.

Python Example in Build Alpha

Below is a simple, 5-step walkthrough of how to create a signal using python and test it with other pre-built signals in Build Alpha. From the file menu, create a new custom signal which will open the window below. Set the type to ‘Python’.

Build Alpha then produces a simple to use template and we just need to set the variable file_name_base to the file we wish to do analysis on. Build Alpha will change this to whatever symbol(s) you have selected from the main interface at runtime. I have used the built-in Build Alpha data in the example below.

*Note* You can find the file path by right-clicking on your data file, selecting properties, and copy/pasting the path inside two quotes.

The only requirement is that we return a Signal list with the same length as data rows in our input file. This ensures there is a signal for every bar. Then simply save and access your custom signal from the main interface.

This new feature opens the door for what is possible in Build Alpha. Traders can leverage the power of python as well as BuildAlpha in extremely easy to use ways.

Moving Average Trading Strategy Python

Build Alpha’s python environment is a full python environment which means we can import external libraries. Let’s import the famous technical analysis library, talib, to create a moving average trading strategy with python.

Create a new indicator and add `import talib` at the top of the python file.

Python Import talib for SMA strategy

Install Python Library for Technical Analysis Indicators

If you do not have talib installed, then open a command terminal and navigate to your python directory. You can type ‘cmd’ into the start menu of most Windows devices. If you used the Build Alpha installer then talib is included. However, you can navigate to your python directory like this: 

Command Prompt for Python Install

Then install talib using the following prompt. Notice the hyphen in ta-lib.

Command Prompt for Python talib install

Next let’s calculate an 8-period moving average and create a signal that is true when the close price is below the 8-period SMA. Both code and screenshot are below.

def GetCustomSignal():


## Write signal calculation here


        global df1

        df1['SMA'] = talib.SMA(df1['Close'].values,8)

        Signal = [1 if c < sma else 0 for c,sma in zip(df1['Close'],df1['SMA'])]

`Moving Average Calculation Python Code talib

Then you can access this signal in the Custom list of the main Strategy Builder screen.

Custom Signals Build Alpha Interface

You can then combine it with any other Build Alpha signal or feature as if it were a built-in signal. This one of course is a built-in signal but made for a simple talib example.

Algorithmic Trading Python

Python is the fastest growing and most versatile programming language making it extremely attractive for quantitative traders and developers. Many algo traders prefer python due to its easy-to-read code and simple syntax. Python does not require code block brackets or semi-colons to end statements, but still is object oriented providing a great mix of ease and flexibility.

Python for algorithmic trading is growing every day with new libraries and popular libraries being updated. TALIB is the most popular library, but many more advanced libraries continue to pop up. Algo trading with python has never been easier.

However, connecting to exchanges, handling live price data, and coming up with trading ideas can be a daunting task. The best part about coding is coming up with new signals. Build Alpha takes care of the heavy lifting enabling python traders to simply do the fun part: signal creation.


Build Alpha now supports the ability to import custom signals via python. This is additional functionality for programmers that want to leverage the speed and ease of Build Alpha. Reminder that this is extra and NO programming is needed to use Build Alpha’s built-in signals or drag and drop custom signal builder.

It has been one heck of a year for Build Alpha’s development and there is still so much to do in 2018! Thanks for all those that support the software; I am looking forward to next year.


David Bergstrom Author Photo Trading Edge

David Bergstrom – the guy behind Build Alpha. I have spent a decade-plus in the professional trading world working as a market maker and quantitative strategy developer at a high frequency trading firm with a Chicago Mercantile Exchange (CME) seat, consulting for Hedge Funds, Commodity Trading Advisors (CTAs), Family Offices and Registered Investment Advisors (RIAs). I am a self-taught programmer utilizing C++, C# and python with a statistics background specializing in data science, machine learning and trading strategy development. I have been featured on,,, Quantocracy,,, Benzinga, TradeStation, NinjaTrader and more. Most of my experience has led me to a series of repeatable processes to find, create, test and implement algorithmic trading ideas in a robust manner. Build Alpha is the culmination of this process from start to finish. Please reach out to me directly at any time.

1 thought on “Using Python in Build Alpha [Creating Custom Signals]

Leave a Reply

Your email address will not be published.