Develop a 200-Day SMA Trading Strategy Using DecisionRules and Polygon—No Coding Required
For those interested in automated trading strategies, building a 200-day Simple Moving Average (SMA) system can now be done without any programming expertise. Leveraging the new Workflow engine from DecisionRules alongside real-time financial data from Polygon, you can seamlessly create, automate, and optimize your trading strategy. This approach empowers users to track market trends and implement responsive strategies through an intuitive, no-code interface, enhancing both efficiency and accessibility. Discover how to simplify complex trading strategies and elevate your investment approach with cutting-edge, code-free solutions.
This is where DecisionRules.io comes in as a no-code platform that allows you to visually design, test, and implement trading strategies using real-time market data. By integrating with APIs like Polygon.io, DecisionRules.io enables you to automate stock analysis and decision-making based on simple financial logic, without needing to know how to code.
In this post, we'll walk through how you can leverage DecisionRules.io to build a trading strategy that uses the 200-day moving average to determine when to buy or sell stocks - all without the need for coding.
Polygon.io is a powerful data platform that provides real-time and historical market data, enabling developers and businesses to access comprehensive stock, forex, and cryptocurrency information. Known for its speed, reliability, and extensive data coverage, Polygon.io is an essential tool for building and automating financial applications. Its robust API allows users to fetch detailed market data, analyze trends, and make informed decisions—making it an ideal choice for integrating with DecisionRules.io to enhance automated trading strategies.
In this guide, we will walk you through the steps required to build a trading strategy that uses the 200-day moving average to determine when to buy or sell stocks - all without the need for coding.
DecisionRules allows you to create workflows and decision tables that can be used to automate various business logic, including trading strategies.
Polygon.io provides real-time and historical market data, which we’ll use to fetch stock prices for our strategy.
Before building the workflow, you'll need to define the input and output models. These models will structure the data you feed into and get from your trading strategy.
The input model defines the data you’ll provide for the workflow. In this case, you need to specify the following values:
The output model will structure the decision made by your trading strategy:
To implement the strategy in DecisionRules.io using Polygon.io, you will need a few specific nodes to structure the logic and API interactions. Here's a breakdown of the necessary nodes:
This node will store your API key and any additional variables (like ticker symbol, etc.) needed throughout the workflow.
This allows you to manage these values centrally without hardcoding them in multiple places.
This REST API node will call the Polygon API to fetch the current or previous day’s price of the stock.
Expected Response: The API will return a JSON object with the stock’s closing price.
More info in polygon documentation HERE
This node will fetch the 200-day historical price data to calculate the 200-day simple moving average.
Expected Response: A JSON object with the historical closing prices for the last 200 days.
More info in polygon documentation HERE
This node is responsible for parsing and extracting the needed values from the responses of both REST API nodes.
In the Assign Node, you can directly use DecisionRules functions to extract and manipulate the API response data efficiently. Here’s how to implement the extraction and calculation:
This node will decide whether the current price is above or below the 200-day moving average.
After the Switch node decides whether the stock’s price is above or below the 200-day moving average, you’ll need to assign specific outcomes for each decision. This is where the Assign nodes come in, which will map the trading position (Buy/Sell) to the output model.
Let’s review the final output of the workflow. Using the 200-day moving average, the system evaluates the stock’s current price and has determined that a bull order is the best course of action with the last closed price 16% above the moving average value. This output reflects the automated decision-making that can be achieved through the no-code workflow. You can download the full rule here:
This tutorial shows you how to create a fully functional trading strategy without writing a single line of code. DecisionRules.io provides a user-friendly, visual interface where the logic is handled through nodes, and integration with external APIs (like Polygon.io) enables you to automate stock trading decisions based on real-time and historical data. This workflow design helps you build, test, and adjust trading strategies quickly and efficiently, even if you're unfamiliar with programming. This example demonstrates a simple use of the workflow, but you can extend it to create much more complex strategies as needed.