I continue investiaging another area of knowledge of humankind, which is FXCM trading Station.
So, if you need to write strategy, you'll need following methods to be defined in your strategy:
- AsyncOperationFinished(cookie, successful, message, message1, message2)
Now little bit details:
The Init() function of the strategy is called once, when the host application has just loaded the strategy into the memory. In this function the strategy must create profile. Profile is the information which is required for creation of the strategy: strategy name and description and parameters.
When the function is being executed, there is a global variable called strategy. You must use the table kept in this variable to provide all necessary information.
Note: Values of any global variables, which are defined in the Init() function will not be available in the other strategies functions. Because the user can apply multiple instance of the same strategy at the same time, the new instance of the strategy is created every time when the user applies the strategy.
Prepare function is called every time when the user applies the strategy. At this moment, a copy of the strategy code is created. This copy is called strategy instance. At one moment, there can be as many strategy instances as many times the strategy is applied.
In this function you must:
- Prepare all common data for further work of the strategy logic.
When the function is being executed, there is a global variable called instance. You must use this to access to the instrument and parameters data.
nameOnly indicates whether this function was called just for creating instance's name.
Important: strategy instance is always created in a new context. The
Init() function is not called for an instance, so there is no way to pass data from the
Init() function to the
Update is a most important function in the strategy. The update function is called every time when a new bid or ask price appears on the instrument to which the strategy is attached.
terminal table to get access to the trading application functions.
Release function is optional, you can omit it in your strategy.
In case this function exists, it is called before the strategy instance is destroyed. You can use this function to dispose objects created in the
Other functions will be described in another post