Strategy testing system
Test before you invest


 

 
  Home Downloads Licensing Contact

 

Creating a Trading Strategy

In this exercise a trading strategy is built based on the indicators created in the Using DS Functions tutorial.  The Velocity and Acceleration data series should be in the current view before proceeding.  The strategy implements the following rules.

            Rule A:  IF Velocity IS Positive OR Acceleration IS High THEN Buy

            Rule B:  IF Velocity IS Negative OR Acceleration IS Low THEN Sell

 

Step 1 - Characterize the data series with fuzzy sets.

Select the Velocity data series.  Then create a new fuzzy set by navigating File / New / Fuzzy Set on the main menu and naming the new set "Velocity Fuzzifier".  This opens the Fuzzy Set Editor showing the normal distribution of the selected data series but with the function editing control empty.  From the menu select Insert / Full Set ... / 2-Function.  This inserts two fuzzy functions into the editing control.  In this case the functions are already have Positive and Negative predicates needed to evaluate the  Velocity portion of the rule.  Use the sliders on the bottom of the editor control to adjust membership grades.  Repeat this procedure for the Acceleration data series but in this case name the membership functions "High" and "Low".

      

 

Step 2 - Open a new strategy

From the menu select File / New / Strategy.  This creates a new strategy and opens a new Petri net in the FlowView control with the Start Place, End Place and Begin transition already inserted.  All Petri nets must have a single start place and a single end place to function correctly.  Position objects with drag-and-drop methods.

 

 

Step 3 - Insert data series

Click on the Velocity data series in the Explorer pane and then drag it onto the FlowView control.  TekView inserts a transition with the a data series reference embedded in it along with an input place (which receives tokens representing the look up period in the data series and an output place that receives the value for the period.  The input place is automatically linked to the Begin transition.  Repeat the procedure for the Acceleration data series.  The Petri net will look something like the following at this point.

 

Step 4 - Insert fuzzifiers

On the Petri chart select the output place for the Velocity data series (as shown in the above picture) and then select and drag the Velocity fuzzy set created in step 1 onto the chart (i.e. the "Velocity Fuzzifier").  This links the fuzzifier to the selected place and creates output places for each of the membership functions in the set.  Repeat for the Acceleration data series.

Step 5 - Add fuzzy operators

Next select the Negative and Low nodes as shown above and drag the Fuzzy OR operator onto the chart.  Do the same thing for the Positive and High nodes resulting in the following:

Step 6 - Add defuzzifier

The final step in the fuzzy inference process is to convert the fuzzy values expressed by the logic of the unions and intersections back to a "crisp" value (see Fuzzy Logic Fundamentals).  This is done by creating another fuzzy set having one membership function called Buy and another called Sell.  Also, set the fuzzzy set's properties as shown.

       

Drag the Buy/Sell Defuzzifier on to the chart.  Since defuzzification is the last transition performed TekView knows to connect it to the net's end place.

Step 7 - Connect the antecedents with their consequence

In the parlance of set theory, where an inference has the form IF x THEN y, the x part is known as the the antecedent and the y part as the consequence.  To complete the logic given at the start of the exercise we just have to link antecedents to the consequences as shown below. Complete the links by right-clicking one of the Fuzzy OR transitions, selecting Insert Arc from the pop-up menu and then clicking on the appropriate Buy or Sell place.   

The strategy is now ready to be saved and tested.

 

Back