After all these steps we will only work with text inside the main window, so I will post here only listings. First step, let's delete all unnecessary strings from text:
Code: Select all
library DemoStrategy;
uses
SysUtils;
begin
end.
After installation of ForexTester you can find API files for strategies in folder <FT>\Examples\Strategies\Delphi\ . There are 2 files StrategyInterfaceUnit.pas and TechnicalFunctions.pas. Copy these files to the same folder where you saved your project. And add their names to uses section of your code:
Code: Select all
library DemoStrategy;
uses
SysUtils, StrategyInterfaceUnit, TechnicalFunctions;
begin
end.
Now you can use all functions from these two files, and we can create simple strategy. To make ForexTester recognize our dll as a strategy that can be executed, our module should contain at least 4 procedures:
-
InitStrategy - this procedure is called only once, when strategy is initialized after it was loaded by ForexTester when it starts.
-
DoneStrategy - this procedure is called only once, when you close ForexTester to release some resources that you possible allocated in InitStrategy.
-
ResetStrategy - this procedure is called every time when you start new testing. I will explain it later in details.
-
GetSingleTick - this procedure is called every time when price changes during testing. It does not matter what currency changes, strategy can work with every currency and receives every changes from all currencies.
Code: Select all
library DemoStrategy;
uses
SysUtils, StrategyInterfaceUnit, TechnicalFunctions;
procedure InitStrategy; stdcall;
begin
StrategyShortName('DemoStrategy');
StrategyDescription('Demo strategy that does nothing');
end;
procedure DoneStrategy; stdcall;
begin
end;
procedure ResetStrategy; stdcall;
begin
end;
procedure GetSingleTick; stdcall;
begin
end;
exports
InitStrategy,
DoneStrategy,
ResetStrategy,
GetSingleTick;
end.
As you can see, I added 2 string in InitStrategy procedure. First string defines short name of strategy and second defines some longer description. You will be able to see these string in "Strategies list" dialog in ForexTester.
Press Ctrl+F9 and compile our project.
You will have DemoStrategy.dll file at the same folder where you saved the project. Now we need to import this file into ForexTester. All you need to do - just close ForexTester (if it was started), copy DemoStrategy.dll to <ForexTester>\Strategies\ folder, and start ForexTester again. If everything was correct you will see our strategy in Strategies List (menu Tools -> Strategies List).
Congratulations! You created your first strategy for ForexTester. It does nothing though and has no options

but it is only first step.