Hi,
I am having hard time to install my strategy onto FT2.
This is what I did.
I change Strategy Description in the default file, SMA Strategy.
Saved and Build on razarus.
Came back to FT2, and did "Install New Strategy".
Then, I got th following error.
After asking me for the overwriting and I clicked Yes, the error comes back by saying "Can not install strategy, file will be deleted"
Then the SMA Strategy is not in the Strategy list any more.
You know, All I did was just changing Strategy Description.
Did I do something wrong?
Is there any work around for this?
Any different way of installing the strategy?
I remember it used to be OK to move the dll file directly into Strategy folder on FT2.
Please help me out.
Strategy Install Error
-
- Posts: 14
- Joined: Tue Sep 21, 2010 2:19 pm
Strategy Install Error
- Attachments
-
- Untitled.png (131.64 KiB) Viewed 17628 times
-
- Posts: 905
- Joined: Sat Jul 11, 2009 10:54 am
Is it correct that your strategy is written in C++?
if yes then please check that you have .def file in your project and it has the following text:
if yes then please check that you have .def file in your project and it has the following text:
Code: Select all
LIBRARY MYSTRATEGY
EXPORTS InitStrategy
DoneStrategy
ReplaceStr
ResetStrategy
GetSingleTick
IntrfProcsRec
Check our other product here:
http://www.forexcopier.com
http://www.forexcopier.com
-
- Posts: 14
- Joined: Tue Sep 21, 2010 2:19 pm
Hi,
It is delphi.
I got this from the /examples/Strategies/Delphi folder.
As you see below, I only changed "StrategyDescription"
//-------------------------------------------------------------------------
// Example of strategy based on 2 crossing SMA (c) Koshelev M.A.
//-------------------------------------------------------------------------
library SMAStrategy;
uses
SysUtils, Classes, StrategyInterfaceUnit;
var
// External parameters
Currency: PChar = nil;
TimeFrame: integer;
LotSize: double;
period1: integer;
period2: integer;
// custom variables
OrderHandle: integer;
OrderStyle: TTradePositionType;
OpenTime: TDateTime;
{-----Init strategy---------------------------------------------------------}
procedure InitStrategy; stdcall;
begin
StrategyShortName('SimpleSMA');
StrategyDescription('Trend Analysis');
// Register external parameters
RegOption('Currency', ot_Currency, Currency);
ReplaceStr(Currency, 'EURUSD');
RegOption('Timeframe', ot_Timeframe, TimeFrame);
TimeFrame := PERIOD_H1;
RegOption('LotSize', ot_Double, LotSize);
SetOptionDigits('LotSize', 1);
lotSize := 0.1;
RegOption('SMA1 period', ot_Integer, period1);
SetOptionRange('SMA1 period', 2, MaxInt);
period1 := 16;
RegOption('SMA2 period', ot_Integer, period2);
SetOptionRange('SMA2 period', 2, MaxInt);
period2 := 32;
end;
{-----Done strategy---------------------------------------------------------}
procedure DoneStrategy; stdcall;
begin
FreeMem(Currency);
end;
{-----Reset strategy--------------------------------------------------------}
procedure ResetStrategy; stdcall;
begin
OrderHandle := -1;
end;
{-----Calculate SMA---------------------------------------------------------}
function GetSMA(period: integer): double;
var
i: integer;
sum: double;
begin
sum := 0;
for i:=0 to period - 1 do
sum := sum + Close(i);
result := sum/period;
end;
{-----Process single tick---------------------------------------------------}
procedure GetSingleTick; stdcall;
var
sma1, sma2: double;
begin
// check our currency
if Symbol <> string(Currency) then exit;
// set currency and timeframe
SetCurrencyAndTimeframe(Symbol, TimeFrame);
// check number of bars and SMA period
if (Bars < period1) or (Bars < period2) then exit;
// calculate SMA
sma1 := GetSMA(period1);
sma2 := GetSMA(period2);
// if BUY order exists and fast SMA crosses slow SMA from top
// then close order
if (OrderHandle <> -1) and (OrderStyle = tp_Buy) and
(OpenTime <> Time(0)) and (sma1 < sma2) then
begin
CloseOrder(OrderHandle);
OrderHandle := -1;
end;
// if SELL order exists and fast SMA crosses slow SMA from bottom
// then close order
if (OrderHandle <> -1) and (OrderStyle = tp_Sell) and
(OpenTime <> Time(0)) and (sma1 > sma2) then
begin
CloseOrder(OrderHandle);
OrderHandle := -1;
end;
// if there is no order and fast SMA crosses slow SMA from top
// then open SELL order
if (OrderHandle = -1) and (sma1 < sma2) then
begin
SendInstantOrder(Symbol, op_Sell, LotSize, 0, 0, '', 0, OrderHandle);
OrderStyle := tp_Sell;
OpenTime := Time(0);
end;
// if there is no order and fast SMA crosses slow SMA from bottom
// then open BUY order
if (OrderHandle = -1) and (sma1 > sma2) then
begin
SendInstantOrder(Symbol, op_Buy, LotSize, 0, 0, '', 0, OrderHandle);
OrderStyle := tp_Buy;
OpenTime := Time(0);
end;
end;
exports
InitStrategy,
DoneStrategy,
ResetStrategy,
GetSingleTick;
end.
It is delphi.
I got this from the /examples/Strategies/Delphi folder.
As you see below, I only changed "StrategyDescription"
//-------------------------------------------------------------------------
// Example of strategy based on 2 crossing SMA (c) Koshelev M.A.
//-------------------------------------------------------------------------
library SMAStrategy;
uses
SysUtils, Classes, StrategyInterfaceUnit;
var
// External parameters
Currency: PChar = nil;
TimeFrame: integer;
LotSize: double;
period1: integer;
period2: integer;
// custom variables
OrderHandle: integer;
OrderStyle: TTradePositionType;
OpenTime: TDateTime;
{-----Init strategy---------------------------------------------------------}
procedure InitStrategy; stdcall;
begin
StrategyShortName('SimpleSMA');
StrategyDescription('Trend Analysis');
// Register external parameters
RegOption('Currency', ot_Currency, Currency);
ReplaceStr(Currency, 'EURUSD');
RegOption('Timeframe', ot_Timeframe, TimeFrame);
TimeFrame := PERIOD_H1;
RegOption('LotSize', ot_Double, LotSize);
SetOptionDigits('LotSize', 1);
lotSize := 0.1;
RegOption('SMA1 period', ot_Integer, period1);
SetOptionRange('SMA1 period', 2, MaxInt);
period1 := 16;
RegOption('SMA2 period', ot_Integer, period2);
SetOptionRange('SMA2 period', 2, MaxInt);
period2 := 32;
end;
{-----Done strategy---------------------------------------------------------}
procedure DoneStrategy; stdcall;
begin
FreeMem(Currency);
end;
{-----Reset strategy--------------------------------------------------------}
procedure ResetStrategy; stdcall;
begin
OrderHandle := -1;
end;
{-----Calculate SMA---------------------------------------------------------}
function GetSMA(period: integer): double;
var
i: integer;
sum: double;
begin
sum := 0;
for i:=0 to period - 1 do
sum := sum + Close(i);
result := sum/period;
end;
{-----Process single tick---------------------------------------------------}
procedure GetSingleTick; stdcall;
var
sma1, sma2: double;
begin
// check our currency
if Symbol <> string(Currency) then exit;
// set currency and timeframe
SetCurrencyAndTimeframe(Symbol, TimeFrame);
// check number of bars and SMA period
if (Bars < period1) or (Bars < period2) then exit;
// calculate SMA
sma1 := GetSMA(period1);
sma2 := GetSMA(period2);
// if BUY order exists and fast SMA crosses slow SMA from top
// then close order
if (OrderHandle <> -1) and (OrderStyle = tp_Buy) and
(OpenTime <> Time(0)) and (sma1 < sma2) then
begin
CloseOrder(OrderHandle);
OrderHandle := -1;
end;
// if SELL order exists and fast SMA crosses slow SMA from bottom
// then close order
if (OrderHandle <> -1) and (OrderStyle = tp_Sell) and
(OpenTime <> Time(0)) and (sma1 > sma2) then
begin
CloseOrder(OrderHandle);
OrderHandle := -1;
end;
// if there is no order and fast SMA crosses slow SMA from top
// then open SELL order
if (OrderHandle = -1) and (sma1 < sma2) then
begin
SendInstantOrder(Symbol, op_Sell, LotSize, 0, 0, '', 0, OrderHandle);
OrderStyle := tp_Sell;
OpenTime := Time(0);
end;
// if there is no order and fast SMA crosses slow SMA from bottom
// then open BUY order
if (OrderHandle = -1) and (sma1 > sma2) then
begin
SendInstantOrder(Symbol, op_Buy, LotSize, 0, 0, '', 0, OrderHandle);
OrderStyle := tp_Buy;
OpenTime := Time(0);
end;
end;
exports
InitStrategy,
DoneStrategy,
ResetStrategy,
GetSingleTick;
end.
-
- Posts: 905
- Joined: Sat Jul 11, 2009 10:54 am
-
- Posts: 14
- Joined: Tue Sep 21, 2010 2:19 pm
-
- Posts: 905
- Joined: Sat Jul 11, 2009 10:54 am
-
- Posts: 14
- Joined: Tue Sep 21, 2010 2:19 pm
-
- Posts: 905
- Joined: Sat Jul 11, 2009 10:54 am
-
- Posts: 14
- Joined: Tue Sep 21, 2010 2:19 pm
Hi,
I tried something different from what you suggested.
What I did was I installed the same version of Lazarus into my other Windows PC.
Then, I replicated the same problem in the other PC.
That means it does not matter if my PC is 32bit or 64bit.
So, I came to realize that this must be coming from the way I compile and install the strategy.
Can you please tell me how you compile and install the strategy in every single details?
(Please remember I am fine with the strategy installation for the first time, but never been successful from second time.)
BTW, this is what I do once it has been compiled and installed into FT2.
- Go back to Lazarus
- Change and modify "SMAStrategy.dpr" on Source Editor. (This file is already opened under "SMAStrategy.lpi" project file.)
- Press Save all button
- Run >> Build from Menu bar
- On Messages window, 'Project "SMAStrategy" successfully built. '
- Launch FT2
- File >> Install New Strategy
or
- Go back to Lazarus
- Change and modify "SMAStrategy.dpr" on Source Editor. (This file is already opened under "SMAStrategy.lpi" project file.)
- Press Save all button
- Run >> Build from Menu bar
- On Messages window, 'Project "SMAStrategy" successfully built. '
- Take SMAStrategy.dll from Lazarus folder to ForexTester2\Strategies
- Launch FT2
I tried something different from what you suggested.
What I did was I installed the same version of Lazarus into my other Windows PC.
Then, I replicated the same problem in the other PC.
That means it does not matter if my PC is 32bit or 64bit.
So, I came to realize that this must be coming from the way I compile and install the strategy.
Can you please tell me how you compile and install the strategy in every single details?
(Please remember I am fine with the strategy installation for the first time, but never been successful from second time.)
BTW, this is what I do once it has been compiled and installed into FT2.
- Go back to Lazarus
- Change and modify "SMAStrategy.dpr" on Source Editor. (This file is already opened under "SMAStrategy.lpi" project file.)
- Press Save all button
- Run >> Build from Menu bar
- On Messages window, 'Project "SMAStrategy" successfully built. '
- Launch FT2
- File >> Install New Strategy
or
- Go back to Lazarus
- Change and modify "SMAStrategy.dpr" on Source Editor. (This file is already opened under "SMAStrategy.lpi" project file.)
- Press Save all button
- Run >> Build from Menu bar
- On Messages window, 'Project "SMAStrategy" successfully built. '
- Take SMAStrategy.dll from Lazarus folder to ForexTester2\Strategies
- Launch FT2
-
- Posts: 905
- Joined: Sat Jul 11, 2009 10:54 am
Ok, please try to do the following:
1) replace your StrategyInterfaceUnit with attached one
2) add ReplaceStr and IntrfProcsRec functions into "exports" section on your strategy, so it will look like this:
Let me know if it does not help
1) replace your StrategyInterfaceUnit with attached one
2) add ReplaceStr and IntrfProcsRec functions into "exports" section on your strategy, so it will look like this:
Code: Select all
exports
InitStrategy,
DoneStrategy,
ResetStrategy,
GetSingleTick,
ReplaceStr,
IntrfProcsRec;
Let me know if it does not help
- Attachments
-
- StrategyInterfaceUnit.zip
- (8.87 KiB) Downloaded 651 times
Check our other product here:
http://www.forexcopier.com
http://www.forexcopier.com
-
- Posts: 40
- Joined: Wed Sep 15, 2010 6:52 am
worked for me
I have been watching this thread because I have had the same problem.
I use Lazarus with Windows Vista.
I have only been able to install a strategy after the first compile.
If I made any change and recompiled, it would not install.
I would have to do: Project / New... paste in the source code, add LCL, etc. (all of the steps on the video), then do a "Save As" with a new name and compile... THEN I could install the .dll into Forex Tester.
Of course this was too much work to be productive with changes.
Thank you for your suggested solution...
I started using the new StrategyInterfaceUnit and included the additional lines as Exports (suggested above) and it works fine now!!!
I use Lazarus with Windows Vista.
I have only been able to install a strategy after the first compile.
If I made any change and recompiled, it would not install.
I would have to do: Project / New... paste in the source code, add LCL, etc. (all of the steps on the video), then do a "Save As" with a new name and compile... THEN I could install the .dll into Forex Tester.
Of course this was too much work to be productive with changes.
Thank you for your suggested solution...
I started using the new StrategyInterfaceUnit and included the additional lines as Exports (suggested above) and it works fine now!!!
creativity + willful purpose
Who is online
Users browsing this forum: No registered users and 11 guests