SendInstantorder Symbol does not work in delphi 2010

Bug reports and errors in the program
Message
Author
DrSobhani
Posts: 4
Joined: Thu Dec 09, 2010 4:32 am
Contact:

SendInstantorder Symbol does not work in delphi 2010

#1 Postby DrSobhani » Thu Dec 09, 2010 4:37 am

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 ,

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#2 Postby FT Support » Fri Dec 10, 2010 2:22 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
Attachments
StrategiesAPI_Delphi2010.zip
(10.46 KiB) Downloaded 627 times
Check our other product here:
http://www.forexcopier.com

DrSobhani
Posts: 4
Joined: Thu Dec 09, 2010 4:32 am
Contact:

#3 Postby DrSobhani » Sun Dec 12, 2010 11:53 am

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

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#4 Postby FT Support » Mon Dec 13, 2010 2:28 am

Hello,

Can you please post a very simple strategy with these problems here?
Check our other product here:
http://www.forexcopier.com

DrSobhani
Posts: 4
Joined: Thu Dec 09, 2010 4:32 am
Contact:

#5 Postby DrSobhani » Mon Dec 13, 2010 4:05 am

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 .

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
ftester-OrderInfo.png
Orderinfo
ftester-OrderInfo.png (27.82 KiB) Viewed 18102 times
ftester-jurnal.png
jurnal
ftester-jurnal.png (6.39 KiB) Viewed 18102 times

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#6 Postby FT Support » Mon Dec 13, 2010 8:18 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.
Attachments
Simple.zip
(48.27 KiB) Downloaded 601 times
FTLog.png
FTLog.png (13.12 KiB) Viewed 18089 times
Check our other product here:
http://www.forexcopier.com

DrSobhani
Posts: 4
Joined: Thu Dec 09, 2010 4:32 am
Contact:

Delphi2010

#7 Postby DrSobhani » Mon Dec 13, 2010 1:36 pm

Hello
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

FT Support
Posts: 905
Joined: Sat Jul 11, 2009 10:54 am

#8 Postby FT Support » Fri Feb 01, 2013 4:53 am

Hello hadriya9091,

What functions are you talking about? please give more info, what do you mean by "will they be making it into 2.6?"
Check our other product here:
http://www.forexcopier.com


Return to “Bug reports”

Who is online

Users browsing this forum: No registered users and 18 guests