|
Foreword:
Implementing this trading system should be a nice warm up for you. This trading system utilizes three different kind of indicators, the MACD (a combination of moving averages), the EMA (an exponential moving average), and the Derivatives indicator (gives a feeling of that a line is doing : up,down, or sideways)
You can look into the files fs_ForexObject.cs for an example class, as well as the mechanism to register your class with the 4XLab.NET program. The fs_StochRSISystem.cs file will give you an example of a fully functional trading system. The source code for the indicators can be found in the Indicators.cs file.
Assignment:
Observe the figure linked here:
http://www.4xmadeeasy.com/PRODUCT/images/trading_popup.jpg
Inputs:
See the green/red line: You can calculate those using the MACD indicator. A good set of parameters is (12,26,9), you can feed the indicator the closing price. The red line is the MACD value, the green line is the Signal value.
See the green up and red down arrows: Those can be calculated using the Slope, or Derivatives indicator when fed with different length EMA values (try 5,10, and 15 simultaneously) of the closing price.
Your trading system will have so far 7 inputs. MINUTES: 5; used to build your candles, MACDFAST: 12; MACDSLOW:26; MACDSIGNAL:9; are used to instantiate the MACD indicator, EMASHORT:5; EMAMEDIUM:10; EMALONG:15; are used to provide the green/red signals for the different time periods.
Instantiate a candlebuilder using MINUTES as a parameter. Register your trading system as a candlelistener with the candlebuilder. Register the candlebuilder as a ticklistener with the tickserver.
Instantiate a MACD and three EMA indicators, those will be your basic input indicators.
Instantiate two Derivatives indicators for the MACD outputs. One derivative indicator will be fed the MACD value, the other the Signal value.
Instantiate three more Derivatives indicators for the EMA outputs. Each one will receive the value of a different EMA indicator.
Strategy:
-----
Opening Conditions:
Buying to Open Condition (going long): Buy when the MACD is above the signal, and their first derivatives are positives. The first derivative of the three EMA indicators must also be positive.
Selling to Open Condition (going short): Sell when the MACD is below the signal, and their first derivatives are negatives. The first derivatives of the three EMA indicators must also be negative.
-----
Closing Conditions:
If Buying, sell to close when:
1) MACD is below the signal
or
2) The slope (first derivative) of the MACD is zero or negative.
Add a parameter to select betwen exit criteria 1 or 2: for example EXIT:1;
If Selling, buy to close when:
1) MACD is above the signal
or
2) The slope (first derivative) of the MACD is zero or positive.
-----
Thus, your system parameters might look like this:
MINUTES:5; MACDFAST:12; MACDSLOW:26; MACDSIGNAL:9; EMASHORT:5; EMAMEDIUM:10; EMALONG:15; EXIT:2;
Tasks:
1) Implement this system and report its results.
2) What parameters could you optimize here?
|