Forex Tester Forum (Professional Training Software for Traders) Forum Index Forex Tester Forum (Professional Training Software for Traders)

Back to main site   Risk disclosure
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

"Can not install..." new strategy

 
Post new topic   Reply to topic    Forex Tester Forum (Professional Training Software for Traders) Forum Index -> FT API
View previous topic :: View next topic  
Author Message
SquareMeal



Joined: 15 Sep 2010
Posts: 40

PostPosted: Sun Sep 19, 2010 5:02 pm    Post subject: "Can not install..." new strategy Reply with quote

I'm using lazarus in a Delphi syntax mode. After days of self-teaching an old dog new programming tricks, I've completed my first clean compile of a strategy (woof!!) and tried to install the resulting .dll file into ForexTester2.

The error message I got was "Can not install..."

I looked this up in this forum and found that your previously suggested a review of the 4 required parts of the strategy source code. I looked at example strategies regarding those 4 major sections and mine looks identical... as best I can tell.

I also read the information on accessing indicators within strategies and was therefore careful to execute the CreateIndicator procedure within the Reset section.

I don't know what else to look for -- so I would appreciate your help at this point.

Regards,
SquareMeal

-------------My source code follows-----------:

library onyx;

uses
SysUtils, Classes, StrategyInterfaceUnit, IndicatorInterfaceUnit;

var
// External parameters
Currency: PChar = nil;
TimeFrame: integer;
LotSize: double;

// custom variables
OrderHandle: integer;
OrderStyle: TTradePositionType;
OpenTime: TDateTime;

IndMo: integer;
IndEMA: integer;

Midline, HighTZ, LowTZ, TZPeriod: double;
MoPrevious, MoCurrent, MoChange, MinMo: double;

{-----Init strategy---------------------------------------------------------}
procedure InitStrategy; stdcall;
begin
StrategyShortName('Onyx');
StrategyDescription('Test Trading Engine');

// 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('Minimum Momentum %Chg', ot_Double, MinMO);
SetOptionRange('Minimum Momentum %Chg', 0, 0.50);
MinMO := 0.02;

RegOption('TradeZone Period', ot_Integer, TZPeriod);
SetOptionRange('TradeZone Period', 5, 15);
TZPeriod := 10;
end;

{-----Done strategy---------------------------------------------------------}
procedure DoneStrategy; stdcall;
begin
FreeMem(Currency);
end;

{-----Reset strategy--------------------------------------------------------}
procedure ResetStrategy; stdcall;
begin
OrderHandle := -1;

// Create the Momentum Indicator
IndMo := CreateIndicator('EURUSD', 30, 'Momentum', '5;Close');

{ SetIndicatorBuffStyle(IndMo, 0, 'psSolid', 1, clBlue); }

// Create the 3 EMA Indicators (1 indicator, 3 buffers)
IndEMA := CreateIndicator('EURUSD', 30, 'MovingAverage',
format ('%d;0;0;Exponential (EMA);High + Low + Close)/3',
[TZPeriod]));
IndEMA := CreateIndicator('EURUSD', 30, 'MovingAverage',
format ('%d;0;0;Exponential (EMA);High', [TZPeriod]));
IndEMA := CreateIndicator('EURUSD', 30, 'MovingAverage',
format ('%d;0;0;Exponential (EMA);Low', [TZPeriod]));

{ SetIndicatorBuffStyle(IndEMA, 0, 'psDot', 1, clYellow);
SetIndicatorBuffStyle(IndEMA, 1, 'psSolid', 1, clYellow);
SetIndicatorBuffStyle(IndEMA, 2, 'psSolid', 1, clYellow); }

end;

{-----Process single tick---------------------------------------------------}
procedure GetSingleTick; stdcall;

begin
// check our currency
if Symbol <> string(Currency) then exit;

// set currency and timeframe
SetCurrencyAndTimeframe(Symbol, TimeFrame);

// check number of bars and TZ period
if Bars < TZPeriod then exit;

// get the Momentum numbers

MoCurrent := GetIndicatorValue (IndMo, 0, 1);
MoPrevious := GetIndicatorValue (IndMo, 1, 1);
MOChange := MoCurrent / MoPrevious - 1;

// get the TradeZone (EMA) numbers

Midline := GetIndicatorValue (IndEMA, 0, 0);
HighTZ := GetIndicatorValue (IndEMA, 0, 1);
LowTZ := GetIndicatorValue (IndEMA, 0, 2);


// if Buy order exists and Close crosses Midline from beneath
// then close order
if (OrderHandle <> -1) and (OrderStyle = tp_Buy) and
(OpenTime <> Time(0)) and (Close(0) > Midline) then
begin
CloseOrder(OrderHandle);
OrderHandle := -1;
end;

// if SELL order exists and Close crosses Midline from above
// then close order
if (OrderHandle <> -1) and (OrderStyle = tp_Sell) and
(OpenTime <> Time(0)) and (Close(0) < Midline) then
begin
CloseOrder(OrderHandle);
OrderHandle := -1;
end;

// if there is no order and Body above TZ and good MO change
// then open SELL order
if (OrderHandle = -1) and (Open(0) > HighTZ) and (Close(0) > HighTZ)
and (MOChange < (MinMO * -1)) then
begin
SendInstantOrder(Symbol, op_Sell, LotSize, 0, 0, '', 0, OrderHandle);
OrderStyle := tp_Sell;
OpenTime := Time(0);
end;

// if there is no order and Body below TZ and good MO change
// then open BUY order
if (OrderHandle = -1) and (Open(0) < LowTZ) and (Close(0) < LowTZ)
and (MOChange > MinMO) 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.

_________________
creativity + willful purpose
Back to top
View user's profile Send private message
SquareMeal



Joined: 15 Sep 2010
Posts: 40

PostPosted: Sun Sep 19, 2010 11:55 pm    Post subject: Additional info on the problem Reply with quote

Just to make sure I am doing everything correctly in Lazarus / compiling, etc... I brought the sample SMAStrategy into Lazarus, compiled it to a .dll file and installed it into ForexTester2. It worked (recognizing there was one there by that name already and did I want to overwrite?) I answered 'Yes' and the file was installed.

So, I conclude there must be something wrong with my CODE (above) vs. my OPERATIONAL METHODS.

Thanks again for any help,

SquareMeal

_________________
creativity + willful purpose
Back to top
View user's profile Send private message
FT Support



Joined: 11 Jul 2009
Posts: 901

PostPosted: Mon Sep 20, 2010 8:52 am    Post subject: Reply with quote

Hello,

Probably this is the reason of the error:

you have the following code:

Code:
RegOption('TradeZone Period', ot_Integer, TZPeriod);

but note that "TZPeriod" variable is declired as double:
Code:
TZPeriod: double;

so you probably need to declare TZPeriod as integer or change option type to ot_Double

_________________
Check our other products here:
www.fx-metropolis.com
www.forexcopier.com
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Forex Tester Forum (Professional Training Software for Traders) Forum Index -> FT API All times are GMT
Page 1 of 1

 
Jump to:  
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