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 

Please explain the TTypes used..

 
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
Tantalus



Joined: 23 Mar 2007
Posts: 300

PostPosted: Sat Nov 10, 2007 7:50 pm    Post subject: Please explain the TTypes used.. Reply with quote

Hi, Mike..

I'm starting to run into some serious difficulties in using the APIs because of the Type structures you've created. I'm not familiar with this aspect of Delphi and the values returned are not usable in the way I need to use them.

The short question is: After I select an order, how do I print the order type to the journal? The Print() function needs a string, but the value returned by OrderType is of the type TTradeOrderType. Looking into the API file, it seems that TTradeOrderType values are integer enums, but if I try to convert the value using IntToStr(OrderType), the compiler gives an error.

There doesn't seem to be a TTradeOrderTypeToStr() function available, so what must I do in order to print the value of OrderType to the Journal?

The long question is how the heck can I understand how all these custom data structures work? I don't want to seem like a complainer, but you really should consider creating a more comprehensive help file for these APIs. It's very frustrating trying to learn how to program them with only the very sketchy info in the current help file.

It would also be quite nice if you could provide a variety of strategy examples - if there were 5 or 6 different example files that show how the various functions and types are actually used it would be a lot easier to figure this stuff out.

Anyway, I hope you can help me.. I really need to know what OrderType is being returned so I can see why my strategy is ignoring me...

Thx.

_________________
Tantalus Research - Developing 21st Century Trading Systems.


Last edited by Tantalus on Tue Jun 09, 2009 10:04 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Terranin
Site Admin


Joined: 21 Oct 2006
Posts: 831

PostPosted: Sat Nov 10, 2007 8:51 pm    Post subject: Re: Please explain the TTypes used.. Reply with quote

Tantalus wrote:
Hi, Mike..

I'm starting to run into some serious difficulties in using the APIs because of the Type structures you've created. I'm not familiar with this aspect of Delphi and the values returned are not usable in the way I need to use them.

The short question is: After I select an order, how do I print the order type to the journal? The Print() function needs a string, but the value returned by OrderType is of the type TTradeOrderType. Looking into the API file, it seems that TTradeOrderType values are integer enums, but if I try to convert the value using IntToStr(OrderType), the compiler gives an error.

There doesn't seem to be a TTradeOrderTypeToStr() function available, so what must I do in order to print the value of OrderType to the Journal?

The long question is how the heck can I understand how all these custom data structures work? I don't want to seem like a complainer, but you really should consider creating a more comprehensive help file for these APIs. It's very frustrating trying to learn how to program them with only the very sketchy info in the current help file.

It would also be quite nice if you could provide a variety of strategy examples - if there were 5 or 6 different example files that show how the various functions and types are actually used it would be a lot easier to figure this stuff out.

Anyway, I hope you can help me.. I really need to know what OrderType is being returned so I can see why my strategy is ignoring me...

Thx.


It is not very difficult, we have:
Code:
TTradePositionType =
    (tp_Buy       = 0,
     tp_Sell      = 1,
     tp_BuyLimit  = 2,
     tp_SellLimit = 3,
     tp_BuyStop   = 4,
     tp_SellStop  = 5,
     tp_Balance   = 6,
     tp_Credit    = 7);


it is just simple enumeration. So if you want to convert it to integer, do this

Code:
var
  pt: TTradePositionType;

Print(IntToStr(integer(pt)));


if you want to have a string here it is simple function

Code:
function GetStrPosType(pt: TTradePosType): string;
begin
  case integer(pt) of
    0: result := 'Buy';
    1: result := 'Sell';
    3: result := 'Buy limit';
    4: result := 'Sell limit';
    5: result := 'Buy stop';
    6: result := 'Sell stop';
    else result := 'Unknown';
  end;
end;


Structures works very simpe, for example you got TTradePosition structure as a result of function - it is just a set of different variables combined together. To get any variable from the structure type its name after point like this:

Code:
var
  tp: TTradePosition;

if tp.ticket <> ... then ...

if (tp.StopLoss = 0) or (tp.TakeProfit = 0) then ...

Print(tp.comments);

_________________
Hasta la vista
Mike
Back to top
View user's profile Send private message
drader



Joined: 28 Mar 2009
Posts: 3

PostPosted: Sat Mar 28, 2009 12:11 am    Post subject: Re: Please explain the TTypes used.. Reply with quote

Hi Tantalus

Tantalus wrote:


There doesn't seem to be a TTradeOrderTypeToStr() function available, so what must I do in order to print the value of OrderType to the Journal?



you can use this little trik:

include the unit TypInfo
uses the function

GetEnumName(TypeInfo(TTradeOrderTypeToStr), Integer(tp_Buy))

Rgds Dario
Back to top
View user's profile Send private message
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