New API programmer

How to create strategies and indicators
Message
Author
jorge
Posts: 4
Joined: Sun Dec 23, 2007 1:43 am

New API programmer

#1 Postby jorge » Sun Dec 23, 2007 4:34 am

Hi:

I would like to learn how to program the strategy API and would like to study the code for the included strategy in FT: SimpleSMA. Does anybody know if the code is available for download?

Thank you!

---
Pour gagner... il faut avoir faim.
Si se puede!

User avatar
Tantalus
Posts: 302
Joined: Fri Mar 23, 2007 3:51 pm
Contact:

#2 Postby Tantalus » Sun Dec 23, 2007 1:44 pm

If you have FT then you already have that code... Look in:

\ForexTester\Examples\Strategies\...

There are examples for both Delphi and C++

:)

jorge
Posts: 4
Joined: Sun Dec 23, 2007 1:43 am

SMA strategy for C++

#3 Postby jorge » Sun Dec 23, 2007 4:57 pm

Thank you, Tantalus.

I looked in the examples/strategies/C++ folder, but could not find the SMA strategy. I did find it in the Delphi folder. Does anyone have it in C++ or should I try to learn Delphi?


---
Pour gagner il faut avoir faim.
Si se puede!

User avatar
Tantalus
Posts: 302
Joined: Fri Mar 23, 2007 3:51 pm
Contact:

#4 Postby Tantalus » Sun Dec 23, 2007 8:02 pm

Oops, my bad...

I don't do C++ so I have never looked in there. Why don't you PM Terranin and ask if he has code for other examples in C++?

jorge
Posts: 4
Joined: Sun Dec 23, 2007 1:43 am

thanks

#5 Postby jorge » Sun Dec 23, 2007 8:22 pm

thank you Tantalus:

I will e-mail Terrain. In the meantime, I downloaded Delphi from Borland, installed it, and I'm learning the language.

:)

---
Pour gagner... il faut avoir faim.
Si se puede!

FinGeR
Posts: 72
Joined: Wed Apr 23, 2008 12:24 pm

#6 Postby FinGeR » Wed Aug 06, 2008 9:36 am

hello,

Delphi or C++

indicators with Windows Form Dialog on FT like Screenshot

is possible ?
Attachments
capture076.jpg
capture076.jpg (100.94 KiB) Viewed 23491 times

FinGeR
Posts: 72
Joined: Wed Apr 23, 2008 12:24 pm

#7 Postby FinGeR » Wed Aug 06, 2008 4:20 pm

not possible ?

TForm on FT

sample with Delphi
Attachments
capture077.jpg
capture077.jpg (89.06 KiB) Viewed 23482 times

User avatar
Terranin
Site Admin
Posts: 833
Joined: Sat Oct 21, 2006 4:39 pm

#8 Postby Terranin » Wed Aug 06, 2008 6:19 pm

It should not be done like this. Form must be created manually, so delete it from the list of forms that are created automatically in project.

You should create form in InitStrategy:

Form1 := TForm1.create(nil);

And release it in DoneStrategy:

Form1.free;

To call it in GetSingleTick use:

Pause;
if Form1.ShowModal = mrOk then ... // do some things
Resume;

This example is for strategies. You should not use forms in indicators, for what purpose do you want to use them there??
Hasta la vista
Mike

FinGeR
Posts: 72
Joined: Wed Apr 23, 2008 12:24 pm

#9 Postby FinGeR » Thu Aug 07, 2008 12:34 am

thanks

...for what purpose do you want to use them there??

would like to implement an idea

..This example is for strategies.

example
Not displayed in Strategy list
what have I done wrong? :oops:
Attachments
StrategyWithForm.rar
SMAStrategy.dll
(163.32 KiB) Downloaded 867 times

User avatar
Terranin
Site Admin
Posts: 833
Joined: Sat Oct 21, 2006 4:39 pm

#10 Postby Terranin » Thu Aug 07, 2008 8:17 am

FinGeR wrote:thanks

...for what purpose do you want to use them there??

would like to implement an idea

..This example is for strategies.

example
Not displayed in Strategy list
what have I done wrong? :oops:


You did not attach the source file, so I can not say anything.
Hasta la vista

Mike

FinGeR
Posts: 72
Joined: Wed Apr 23, 2008 12:24 pm

#11 Postby FinGeR » Thu Aug 07, 2008 8:30 am

sorry

:oops:
Attachments
test.rar
(8.1 KiB) Downloaded 919 times

User avatar
Terranin
Site Admin
Posts: 833
Joined: Sat Oct 21, 2006 4:39 pm

#12 Postby Terranin » Thu Aug 07, 2008 9:39 am

FinGeR wrote:sorry

:oops:


You should add this form as a separate unit with delphi. Just add new form to the project like this (File -> New -> Form):

Code: Select all

library DemoStrategy2;

uses
  StrategyInterfaceUnit,
  TechnicalFunctions,
  forms,
  controls,
  Unit1 in 'Unit1.pas' {Form1};

procedure InitStrategy; stdcall;
begin
  StrategyShortName('DemoStrategy2');
  StrategyDescription('Strategy with Form');

  form1 := TForm1.Create(nil);
end;

procedure DoneStrategy; stdcall;
begin
  form1.Free;
end;

procedure ResetStrategy; stdcall;
begin

end;

procedure GetSingleTick; stdcall;
begin
  Pause;
  if form1.ShowModal = mrOk then
    begin

    end;
  Resume;
end;

exports
  InitStrategy,
  DoneStrategy,
  ResetStrategy,
  GetSingleTick;

begin

end.


form:

Code: Select all

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;

type
  TForm1 = class(TForm)
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

end.


And you will be able to edit this form with Delphi visual tools. Delphi also creates *.dfm file, maybe this is the reason why form was not created.
Hasta la vista

Mike

FinGeR
Posts: 72
Joined: Wed Apr 23, 2008 12:24 pm

#13 Postby FinGeR » Thu Aug 07, 2008 11:21 am

great
I understand
thanks you

FinGeR
Posts: 72
Joined: Wed Apr 23, 2008 12:24 pm

#14 Postby FinGeR » Fri Aug 08, 2008 3:18 pm

i love Delphi much easier than C++ Great Software
and FT :D

FinGeR
Posts: 72
Joined: Wed Apr 23, 2008 12:24 pm

request

#15 Postby FinGeR » Sat Aug 23, 2008 10:30 am

hello,

how do I get the SWAP of open positions?

Code: Select all

 for i:=OrdersTotal - 1 downto 0 do
  if OrderSelect(i, SELECT_BY_POS, MODE_TRADES) then
      begin
      Print(Floattostr(TTradePositionType(swap)));
     end;

User avatar
Terranin
Site Admin
Posts: 833
Joined: Sat Oct 21, 2006 4:39 pm

Re: request

#16 Postby Terranin » Sat Aug 23, 2008 11:12 am

FinGeR wrote:hello,

how do I get the SWAP of open positions?



If you mean how to separate open positions from pending orders then:

Code: Select all

for i:=OrdersTotal - 1 downto 0 do
  if OrderSelect(i, SELECT_BY_POS, MODE_TRADES) then
    if OrderType in [tp_Buy, tp_Sell) then
      begin
        Print(Floattostr(TTradePositionType(swap)));
     end;
Hasta la vista

Mike

FinGeR
Posts: 72
Joined: Wed Apr 23, 2008 12:24 pm

#17 Postby FinGeR » Sat Aug 23, 2008 2:46 pm

thanks

FinGeR
Posts: 72
Joined: Wed Apr 23, 2008 12:24 pm

#18 Postby FinGeR » Sat Aug 23, 2008 3:30 pm

problem

use swap function by System.pas

look image
Attachments
Unbenannt.jpg
Unbenannt.jpg (18.03 KiB) Viewed 17805 times

User avatar
Terranin
Site Admin
Posts: 833
Joined: Sat Oct 21, 2006 4:39 pm

#19 Postby Terranin » Sat Aug 23, 2008 3:55 pm

FinGeR wrote:problem

use swap function by System.pas

look image


I see,

Code: Select all

var
  info: TTradePosition;

for i:=OrdersTotal - 1 downto 0 do
  if OrderSelect(i, SELECT_BY_POS, MODE_TRADES) then
    if OrderType in [tp_Buy, tp_Sell) then
      begin
        GetOrderInfo(OrderHandle, info);
        Print(format('Swap = %.4f', [info.swap]));
     end;
Hasta la vista

Mike


Return to “FT API”

Who is online

Users browsing this forum: No registered users and 21 guests