| View previous topic :: View next topic |
| Author |
Message |
Gen
Joined: 21 Sep 2010 Posts: 14
|
Posted: Tue Sep 21, 2010 7:44 pm Post subject: Strategy Install Error |
|
|
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.
| Description: |
|
| Filesize: |
131.64 KB |
| Viewed: |
3277 Time(s) |

|
|
|
| Back to top |
|
 |
FT Support
Joined: 11 Jul 2009 Posts: 902
|
Posted: Tue Sep 21, 2010 8:12 pm Post subject: |
|
|
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:
| Code: | LIBRARY MYSTRATEGY
EXPORTS InitStrategy
DoneStrategy
ReplaceStr
ResetStrategy
GetSingleTick
IntrfProcsRec |
_________________ Check our other products here:
www.fx-metropolis.com
www.forexcopier.com |
|
| Back to top |
|
 |
Gen
Joined: 21 Sep 2010 Posts: 14
|
Posted: Wed Sep 22, 2010 6:46 am Post subject: |
|
|
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.
|
|
| Back to top |
|
 |
FT Support
Joined: 11 Jul 2009 Posts: 902
|
Posted: Wed Sep 22, 2010 11:11 am Post subject: |
|
|
Hello, this is quite strange...
I've just tried to build your strategy and install it into Forex Tester, it worked fine.
Btw, what compiler did you use to build it?
Where was the file located when you chose it from "Install Strategy" dialog?
_________________ Check our other products here:
www.fx-metropolis.com
www.forexcopier.com |
|
| Back to top |
|
 |
Gen
Joined: 21 Sep 2010 Posts: 14
|
Posted: Wed Sep 22, 2010 7:37 pm Post subject: |
|
|
Hi,
I used razrus for the compiler.
I followed exactly what the video explained for ruzarus setup and for compiling.
The strategy dll file is located at razarus/strategy.
So, I am getting it directly from folder under razarus.
Do I need to move dll file to FT/Strategies folder first?
|
|
| Back to top |
|
 |
FT Support
Joined: 11 Jul 2009 Posts: 902
|
Posted: Wed Sep 22, 2010 8:36 pm Post subject: |
|
|
What Lazarus version do you use?
Did you set "Win XX" as a "Target OS" in Project -> "Compiler Options" -> "Code"?
_________________ Check our other products here:
www.fx-metropolis.com
www.forexcopier.com |
|
| Back to top |
|
 |
Gen
Joined: 21 Sep 2010 Posts: 14
|
Posted: Thu Sep 23, 2010 7:21 pm Post subject: |
|
|
Hi,
I attached the razarus version information.
And yes, I set the target OS in Project to Win32.
My PC is Windows7 64bit.
It should be working 32bit application as well in the compatibility mode.[/img]
| Description: |
|
| Filesize: |
94.34 KB |
| Viewed: |
3239 Time(s) |

|
|
|
| Back to top |
|
 |
FT Support
Joined: 11 Jul 2009 Posts: 902
|
|
| Back to top |
|
 |
Gen
Joined: 21 Sep 2010 Posts: 14
|
Posted: Mon Sep 27, 2010 6:41 am Post subject: |
|
|
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
|
|
| Back to top |
|
 |
FT Support
Joined: 11 Jul 2009 Posts: 902
|
Posted: Mon Sep 27, 2010 7:16 pm Post subject: |
|
|
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:
| Code: | exports
InitStrategy,
DoneStrategy,
ResetStrategy,
GetSingleTick,
ReplaceStr,
IntrfProcsRec;
|
Let me know if it does not help
| Description: |
|
 Download |
| Filename: |
StrategyInterfaceUnit.zip |
| Filesize: |
8.87 KB |
| Downloaded: |
329 Time(s) |
_________________ Check our other products here:
www.fx-metropolis.com
www.forexcopier.com |
|
| Back to top |
|
 |
SquareMeal
Joined: 15 Sep 2010 Posts: 40
|
Posted: Tue Sep 28, 2010 4:25 am Post subject: 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!!!
_________________ creativity + willful purpose |
|
| Back to top |
|
 |
Gen
Joined: 21 Sep 2010 Posts: 14
|
Posted: Tue Sep 28, 2010 4:56 am Post subject: |
|
|
It finally worked.
Thanks for your support.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|