Hi
I just stated to test forex tester and test some strategies with it ,
I wrote this code in Delphi 2010
procedure GetSingleTick; stdcall;
begin
SendInstantOrder('AUDCAD', op_Sell, 0.1, 0, 0, '', 0, OrderHandle);
end;
but I get this error when trying to test the strategy "
Can not place instant order (A,sell,lot:0.1,price:0,sl:0,tp:0)
I so changed 'AUDCAD' to 'USDJPY' and then the error was changed to
Can not place instant order (U,sell,lot:0.1,price:0,sl:0,tp:0)
I think there is a problem in using delphi 2010 strings because it just gets the first letter of strings ,
SendInstantorder Symbol does not work in delphi 2010
-
- Posts: 4
- Joined: Thu Dec 09, 2010 4:32 am
- Contact:
-
- Posts: 905
- Joined: Sat Jul 11, 2009 10:54 am
Hello,
This problem appears because in new delphi version "string" means unicode string but in old delphi version "string" was equal to "AnsiString".
Forex Tester requires all strings in AnsiString format, so please do the following to fix this issue:
1) use attached API libraries. these libraries are included in Forex Tester 2.6. and above
2) change type for all "string" variables to "AnsiString" in your strategy
This problem appears because in new delphi version "string" means unicode string but in old delphi version "string" was equal to "AnsiString".
Forex Tester requires all strings in AnsiString format, so please do the following to fix this issue:
1) use attached API libraries. these libraries are included in Forex Tester 2.6. and above
2) change type for all "string" variables to "AnsiString" in your strategy
- Attachments
-
- StrategiesAPI_Delphi2010.zip
- (10.46 KiB) Downloaded 627 times
Check our other product here:
http://www.forexcopier.com
http://www.forexcopier.com
-
- Posts: 4
- Joined: Thu Dec 09, 2010 4:32 am
- Contact:
Hello
really tnx
I did what you told me and it works fine now ,
but I have another problem ,
Could you please tell me how I can use ordercomment() , ordersymbol() and also Symbol ? whenever I try to get them and print , I just see something like Chinese alphabets , and the other question is about defining extern variables of string type , I did almost everything but I was not successful in getting input string values ,replceStr also does not work with strings ,
thanks again
really tnx
I did what you told me and it works fine now ,
but I have another problem ,
Could you please tell me how I can use ordercomment() , ordersymbol() and also Symbol ? whenever I try to get them and print , I just see something like Chinese alphabets , and the other question is about defining extern variables of string type , I did almost everything but I was not successful in getting input string values ,replceStr also does not work with strings ,
thanks again
-
- Posts: 905
- Joined: Sat Jul 11, 2009 10:54 am
-
- Posts: 4
- Joined: Thu Dec 09, 2010 4:32 am
- Contact:
Hello
thanks for your attention
here is the code which just sends 2 orders and then tries to print their comment .
a shot of journal and orderinformation window is attached .
and with a simple change in this code I encounter another problem about not setting strings extern values
this codes in initstrategy and resetstrategy
thanks for your attention
here is the code which just sends 2 orders and then tries to print their comment .
a shot of journal and orderinformation window is attached .
Code: Select all
library Simple;
uses
Windows,
Messages,
SysUtils,
Variants,
Classes,
Graphics,
Controls,
Forms,
Dialogs,
StrategyInterfaceUnit in 'StrategyInterfaceUnit.pas';
var
OrderHandle: integer;
StartLot:double;
Symbols:array [1..100] of ansistring;
procedure InitStrategy; stdcall;
begin
StrategyShortName('Simple');
StrategyDescription('TheSimplStrategy');
RegOption('StartLot', ot_double, StartLot);
StartLot:=0.1;
end;
procedure DoneStrategy; stdcall;
var
i:integer;
begin
end;
procedure ResetStrategy; stdcall;
var
I: Integer;
Comment:ansistring;
begin
OrderHandle := -1;
symbols[1]:='USDJPY';
symbols[2]:='EURUSD';
for I := 1 to 2 do begin
Comment:=(inttostr(i))+'|Simple';
sendinstantorder(Symbols[i],op_Sell,StartLot,0,0,Comment,0,OrderHandle);
end;
end;
procedure GetSingleTick; stdcall;
var
I: Integer;
begin
for I := 0 to orderstotal()-1 do begin
if orderselect(i,select_by_pos,mode_trades) then print( ordercomment());
end;
end;
exports
InitStrategy,
DoneStrategy,
ResetStrategy,
GetSingleTick;
end.
and with a simple change in this code I encounter another problem about not setting strings extern values
this codes in initstrategy and resetstrategy
Code: Select all
procedure InitStrategy; stdcall;
begin
StrategyShortName('Simple');
StrategyDescription('TheSimplStrategy');
RegOption('StartLot', ot_double, StartLot);
RegOption('Symbol1', ot_string, symbols[1]);
StartLot:=0.1;
end;
procedure DoneStrategy; stdcall;
var
i:integer;
begin
end;
procedure ResetStrategy; stdcall;
var
I: Integer;
Comment:ansistring;
begin
OrderHandle := -1;
symbols[2]:='EURUSD';
showmessage(symbol[1]);
for I := 1 to 2 do begin
Comment:=(inttostr(i))+'|Simple';
sendinstantorder(Symbols[i],op_Sell,StartLot,0,0,Comment,0,OrderHandle);
end;
end;
- Attachments
-
- Orderinfo
- ftester-OrderInfo.png (27.82 KiB) Viewed 18108 times
-
- jurnal
- ftester-jurnal.png (6.39 KiB) Viewed 18108 times
-
- Posts: 905
- Joined: Sat Jul 11, 2009 10:54 am
Hmm, that is strange, i tried your code and it worked fine for me.
btw please do not call operations with orders in "ResetStrategy" procedure, do it only in GetSingleTick procedure.
so I've made some changes in your code (result is attached).
if you still get ???? in journal then please try to install my compiled dll, does it work fine on your computer? if not then something is wrong with localization or system settings on your computer.
btw please do not call operations with orders in "ResetStrategy" procedure, do it only in GetSingleTick procedure.
so I've made some changes in your code (result is attached).
if you still get ???? in journal then please try to install my compiled dll, does it work fine on your computer? if not then something is wrong with localization or system settings on your computer.
- Attachments
-
- Simple.zip
- (48.27 KiB) Downloaded 601 times
-
- FTLog.png (13.12 KiB) Viewed 18095 times
Check our other product here:
http://www.forexcopier.com
http://www.forexcopier.com
-
- Posts: 4
- Joined: Thu Dec 09, 2010 4:32 am
- Contact:
Delphi2010
Hello
Thanks
I used your Dll and it worked fine , but when I recompiled your code (with delphi 2010 ) the problem appeared again,
Thanks
I used your Dll and it worked fine , but when I recompiled your code (with delphi 2010 ) the problem appeared again,
- Attachments
-
- Simple.rar
- (129.91 KiB) Downloaded 601 times
-
- Posts: 905
- Joined: Sat Jul 11, 2009 10:54 am
Who is online
Users browsing this forum: No registered users and 21 guests