Trading Systems Coding: System Design
| Sponsor: At last, an easy way to predict stock trends – get your FREE copy of 5 Chart Patterns You Need to Know. |
The first step when coding any application is the design phase. Whether coding a software application or a trading system, careful design and planning will help you finish in a shorter amount of time with fewer errors. We will be using a simple three-step process to design our trading system.
Step 1: Create Your Trading System Rules
The first step when designing a trading system is simply coming up with the rules by which your system will operate. There should be four core rules to every trading system:
- Buy - Identify when you want to buy a position.
- Sell - Identify when you want to sell a position.
- Stop - Identify when you want to cut your losses.
- Target - Identify when you want to book a gain.
- Buy - When the 30-day moving average (MA) crosses above the 60-day MA
- Sell - When the 30-day MA crosses below the 60-day MA
- Stop - Maximum loss of 10 units
- Target - Target of 10 units
Step 2: Identify the Components of Each Rule
Now that we have our rules down, we need to identify the components involved in each rule. Each component should contain two elements:
- The indicator or study used
- The settings for the indicator or study
Let's take a look at a few examples:
- MA(25) - 25-day moving average
- RSI(25) - 25-day relative strength index
- MACD(Close(0),5,5) - Moving average convergence divergence set based on today's close, with a five-day fast length and a five-day slow length
|
So, for the example mentioned in step one, we would use:
- MA(30) - Meaning 30-day moving average
- MA(60) - Meaning 60-day moving average
Now we will add actions to our rules. Each action adheres to the following basic format:
IF Condition [WHILE Condition] THEN Action
Typically, the condition will consist of the components and parameters you created above, while the action will consist of buy or sell. Conditions may also consist of simple English if no component is present. Note that the "while" component is optional.
Here are a few examples to help illustrate this point:
- IF MA(30) Crosses Above MA(60) THEN Buy
- IF MA(30) Crosses Below MA(60) WHILE Volume(20,000) THEN Sell
- IF EMA(25) Is Greater Than MA(5) THEN Sell
- IF RSI(20) Is Equal To 50 THEN Buy
- IF MA(30) Crosses Above MA(60) THEN Buy
- IF MA(30) Crosses Below MA(60) THEN Sell
- IF our trade has 10 units of profit THEN Sell
- IF our trade has 10 units of loss THEN Sell
Next, we'll take a look at converting these rules into a code that your computer can understand!
Next: Trading Systems Coding: The Coding Stage »
Table of Contents
comments powered by Disqus

Free Annual Reports