|
Open the 4XSystem.DLL solution using Visual Studio
4XSystem.DLL Project files:
4XSystem.DLL.cs: contains the Trading Systems class, the trading systems are declared to the DLL here ANN.cs: contains an artificial neural network implementation, needs configuration files to work. CandlePatterns.cs: source code for a candle pattern recognizer fs_StochRSISystem.cs: IMPORTANT FILE, contains a strategy based on the Stochastics RSI indicator. fs_UnitTests.cs: contains a ForexObject that performs unit tests on several modules of the program Indicators.cs: IMPORTANT FILE, contains the indicators implemented in the program. The important files are marked in Bold, those are the files you will be modifying or using when writing new trading systems.
4XSystem.DLL.cs:
In here you will register your trading systems with the program. You will do so by adding an instance of your object to the collection in the TradingSystems class
ForexObjects.Add( new fStochRSISystem()); ForexObjects.Add(new fUnitTester()); ForexObjects.Add(new fStubSystem());
Adding a new instance of your object here will list it in the Process dropdown menu. The order in which they are added to the collection will determine their order in the pulldown menu.
The ForexObject class is also defined here, this class inherits from the CandleListener class, defined in the RateServers.cs file. This inheritance allows a trading system which inherits from ForexObject to register themselves with the cCandleBuilder class and be notified of when a new candle is available.
The CandleListener class defines the ReceiveCandle virtual method, the use of polymorphism here allows the cCandleBuilder class to send candles to object which inherit from the ForexObject class. The CandleListener class itself inherits from the TickListener class, which implements a similar ReceiveTick virtual method. The ReceiveTick method allows an object registered with the cTickServer class to receive tick data.
Thus, trading systems register with CandleBuilders to receive candles, and optionally can register with TickServer to receive ticks. CandleBuilders must be registered with TickServer to receive ticks. This registration mechanism ensures your class will be called to analyze candle data.
Inherited ForexObject class methods (lets use fs_CandleSystem.cs):
fs_CandleSystem: Constructor, only perform very basic initialization of variables here. Defer the actual processing to the Init method, which will be called shortly. This method will be called twice, once when an instance of the object is added to the ForexObject collection, and once when the SystemTester class instantiates a copy of the object selected for execution. For this reason, the only action recommended for this method is to flag a first run variable if your algorithm so needs. See the fStochRSISystem class for an example of this technique.
InitializeParameters: Receives ProcessParameters and DefaultParameters. This method is responsible for initializing the various ParameterParser objects, and merging the DefaultParameters with the ProcessParameters received by the object.
Init: Receives ProcessParameters. Called by the SystemTester class before a new run is initiated. In here you must perform all the initialization steps the class requires to work properly. The Init method is responsible for calling the InitializeParameters method, instantiate the desired indicators and candlebuilders, and register the candlebuilders with TickServer to receive ticks. See the fStochRSISystem class for an example.
ReceiveTick: If the class registered, this method will get called by the TickServer. In here you can perform analysis based on ticks, analyze the current spread, or take buying/selling decisions based on the current price action.
ReceiveCandle: This method will get called by CandleBuilders when a new candle is ready. This method receives a candle as well as variables specifying its time period, and the name of the candlebuilder that sent us this candle. In here, we must decide which indicators will be sent what values.
|