New API programmer
-
- Posts: 4
- Joined: Sun Dec 23, 2007 1:43 am
New API programmer
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!
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!
- Tantalus
- Posts: 302
- Joined: Fri Mar 23, 2007 3:51 pm
- Contact:
-
- Posts: 4
- Joined: Sun Dec 23, 2007 1:43 am
SMA strategy for C++
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!
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!
- Tantalus
- Posts: 302
- Joined: Fri Mar 23, 2007 3:51 pm
- Contact:
-
- Posts: 72
- Joined: Wed Apr 23, 2008 12:24 pm
- Terranin
- Site Admin
- Posts: 833
- Joined: Sat Oct 21, 2006 4:39 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??
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
Mike
-
- Posts: 72
- Joined: Wed Apr 23, 2008 12:24 pm
thanks
would like to implement an idea
example
Not displayed in Strategy list
what have I done wrong?
...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?
- Attachments
-
- StrategyWithForm.rar
- SMAStrategy.dll
- (163.32 KiB) Downloaded 867 times
- Terranin
- Site Admin
- Posts: 833
- Joined: Sat Oct 21, 2006 4:39 pm
- Terranin
- Site Admin
- Posts: 833
- Joined: Sat Oct 21, 2006 4:39 pm
FinGeR wrote:sorry
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
Mike
-
- Posts: 72
- Joined: Wed Apr 23, 2008 12:24 pm
-
- Posts: 72
- Joined: Wed Apr 23, 2008 12:24 pm
-
- Posts: 72
- Joined: Wed Apr 23, 2008 12:24 pm
request
hello,
how do I get the SWAP of open positions?
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;
- Terranin
- Site Admin
- Posts: 833
- Joined: Sat Oct 21, 2006 4:39 pm
Re: request
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
Mike
-
- Posts: 72
- Joined: Wed Apr 23, 2008 12:24 pm
-
- Posts: 72
- Joined: Wed Apr 23, 2008 12:24 pm
- Terranin
- Site Admin
- Posts: 833
- Joined: Sat Oct 21, 2006 4:39 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
Mike
Who is online
Users browsing this forum: No registered users and 13 guests