Hi,
I have not yet found a way to make Forextester2 call the DoneStrategy function.
How do I make Forextester2 call that function?
When is DoneStrategy called?
-
- Posts: 905
- Joined: Sat Jul 11, 2009 10:54 am
-
- Posts: 94
- Joined: Tue Jan 31, 2012 5:14 am
- Contact:
FT Support wrote:This function is called only once at the moment when Forex Tester finalizes and frees the strategy library.
Hi
Are you sure of that ?
I have generate tick until 31-03-2008 and when FT stopped after last tick, my DoneStategy procedure isn't fire ! In debug mode, Delphi don't stop in it and the code that have to write some file on disk doesn't run.
Even after pressing Stop/Start buttun.
what's the problem ?
Could it be the place of this procedure in the code ? Or it's name ?
May be we have to use OnTestCompleted but how to do this ?
Philippe
Code: Select all
procedure DoneStrategy; stdcall;
var
FichierDe , FichierA : string;
begin
if WriteTradeAnalyseToFile=0 then
begin
WriteDDmax;
WriteTrade;
WriteTradeModeSortie;
WriteTradeAttenteSortie;
WriteTradeDD;
WriteGainMaxPips;
TimeSeparator := '_';
DateSeparator := '_';
// save Trade.txt
FichierDe := RepertoireTemp+'\Trade.txt';
FichierA := RepertoireTemp+'\Trade_'+DateTimeToStr(Now)+'.txt';
CopyFile(Pchar(FichierDe),Pchar(FichierA),true);
//save RepertoireTemp+'\TradeDrawDown.txt'
FichierDe := RepertoireTemp+'\TradeDrawDown.txt';
FichierA := RepertoireTemp+'\TradeDrawDown_'+DateTimeToStr(Now)+'.txt';
CopyFile(Pchar(FichierDe),Pchar(FichierA),true);
//save RepertoireTemp+'\TradeModeSortie.txt'
FichierDe := RepertoireTemp+'\TradeModeSortie.txt';
FichierA := RepertoireTemp+'\TradeModeSortie_'+DateTimeToStr(Now)+'.txt';
CopyFile(Pchar(FichierDe),Pchar(FichierA),true);
//save RepertoireTemp+'\TradeAttenteSortie.txt'
FichierDe := RepertoireTemp+'\TradeAttenteSortie.txt';
FichierA := RepertoireTemp+'\TradeAttenteSortie_'+DateTimeToStr(Now)+'.txt';
CopyFile(Pchar(FichierDe),Pchar(FichierA),true);
//save RepertoireTemp+'\TradeGainMaxPips.txt'
FichierDe := RepertoireTemp+'\TradeGainMaxPips.txt';
FichierA := RepertoireTemp+'\TradeGainMaxPips_'+DateTimeToStr(Now)+'.txt';
CopyFile(Pchar(FichierDe),Pchar(FichierA),true);
end;
end;
my live account - 8 based pairs with optimized parameters : +188%
http://www.myfxbook.com/members/Philipp ... jpg/519044
TradeSlide : http://bit.ly/14R9Nf6
to be informed about Windev/MT4 services : a04486-tradingsignal@yahoo.fr
http://www.myfxbook.com/members/Philipp ... jpg/519044
TradeSlide : http://bit.ly/14R9Nf6
to be informed about Windev/MT4 services : a04486-tradingsignal@yahoo.fr
-
- Posts: 26
- Joined: Thu Jun 21, 2012 12:03 am
Robopip wrote:A Function like "OnTestCompleted" is what I'm searching for also.
ie a way to find out when my strategy have received the last tick of all generated ticks.
Ok, I found a solution.
By reading the *.dat files in data\ticks folder, we can find max(time).
When we get TimeCurrent()=max(time) in our GetSingleTick() function, we know it is the last tick.
Here is example and code:
EXPORT void __stdcall GetSingleTick()
{
if (isLastTick(TimeCurrent()))
{
Print("This is the last tick. Do whatever you have to do.");
}
}
int isLastTick(double test)
{
static double lastTick = 0.0;
static int num = 0;
static int count = 0;
if (lastTick == 0.0)
{
WIN32_FIND_DATA ffd;
HANDLE hFind = INVALID_HANDLE_VALUE;
FILE *stream;
unsigned long numTicks;
double tick;
fpos_t pos;
wchar_t path[256], criteria[256], filename[256];
wcscpy_s(path, TEXT("C:\\ForexTester2\\data\\Ticks"));
swprintf_s(criteria, TEXT("%s\\*.dat"), path);
hFind = FindFirstFile(criteria, &ffd);
do
{
if (hFind != INVALID_HANDLE_VALUE)
{
swprintf_s(filename, TEXT("%s\\%s"), path, ffd.cFileName);
if (stream = _wfsopen(filename, TEXT("rb"), _SH_DENYNO))
{
fread(&numTicks, sizeof(unsigned long), 1, stream);
pos = sizeof(unsigned long) + ((numTicks - 2) * sizeof(double) * 2);
fsetpos(stream, &pos);
fread(&tick, sizeof(double), 1, stream);
if (tick > lastTick)
{
lastTick = tick;
num = 1;
}
else if (tick == lastTick)
{
num++;
}
fclose(stream);
}
else
{
Print("could not open file");
}
}
}
while (FindNextFile(hFind, &ffd) != 0);
FindClose(hFind);
}
if ((lastTick - test) <= 0.00)
{
count++;
if (count == num)
{
count = 0;
return (1);
}
}
return (0);
}
Have fun!
-
- Posts: 94
- Joined: Tue Jan 31, 2012 5:14 am
- Contact:
Good job ! I hope support will explain OnTestCompleted for Delphi users !
Robopip wrote:Robopip wrote:A Function like "OnTestCompleted" is what I'm searching for also.
ie a way to find out when my strategy have received the last tick of all generated ticks.
Ok, I found a solution.
By reading the *.dat files in data\ticks folder, we can find max(time).
When we get TimeCurrent()=max(time) in our GetSingleTick() function, we know it is the last tick.
Here is example and code:
EXPORT void __stdcall GetSingleTick()
{
if (isLastTick(TimeCurrent()))
{
Print("This is the last tick. Do whatever you have to do.");
}
}
int isLastTick(double test)
{
static double lastTick = 0.0;
static int num = 0;
static int count = 0;
if (lastTick == 0.0)
{
WIN32_FIND_DATA ffd;
HANDLE hFind = INVALID_HANDLE_VALUE;
FILE *stream;
unsigned long numTicks;
double tick;
fpos_t pos;
wchar_t path[256], criteria[256], filename[256];
wcscpy_s(path, TEXT("C:\\ForexTester2\\data\\Ticks"));
swprintf_s(criteria, TEXT("%s\\*.dat"), path);
hFind = FindFirstFile(criteria, &ffd);
do
{
if (hFind != INVALID_HANDLE_VALUE)
{
swprintf_s(filename, TEXT("%s\\%s"), path, ffd.cFileName);
if (stream = _wfsopen(filename, TEXT("rb"), _SH_DENYNO))
{
fread(&numTicks, sizeof(unsigned long), 1, stream);
pos = sizeof(unsigned long) + ((numTicks - 2) * sizeof(double) * 2);
fsetpos(stream, &pos);
fread(&tick, sizeof(double), 1, stream);
if (tick > lastTick)
{
lastTick = tick;
num = 1;
}
else if (tick == lastTick)
{
num++;
}
fclose(stream);
}
else
{
Print("could not open file");
}
}
}
while (FindNextFile(hFind, &ffd) != 0);
FindClose(hFind);
}
if ((lastTick - test) <= 0.00)
{
count++;
if (count == num)
{
count = 0;
return (1);
}
}
return (0);
}
Have fun!
my live account - 8 based pairs with optimized parameters : +188%
http://www.myfxbook.com/members/Philipp ... jpg/519044
TradeSlide : http://bit.ly/14R9Nf6
to be informed about Windev/MT4 services : a04486-tradingsignal@yahoo.fr
http://www.myfxbook.com/members/Philipp ... jpg/519044
TradeSlide : http://bit.ly/14R9Nf6
to be informed about Windev/MT4 services : a04486-tradingsignal@yahoo.fr
-
- Posts: 905
- Joined: Sat Jul 11, 2009 10:54 am
Sorry for the delay.
OnTestCompleted function is called after every test run in strategy optimizer, I'm not sure that it will work outside of optimizer.
you can use OnTestCompleted function this way
OnTestCompleted function is called after every test run in strategy optimizer, I'm not sure that it will work outside of optimizer.
you can use OnTestCompleted function this way
Code: Select all
procedure OnTestCompleted; stdcall;
begin
...
end;
exports
..., OnTestCompleted, ...;
Check our other product here:
http://www.forexcopier.com
http://www.forexcopier.com
-
- Posts: 94
- Joined: Tue Jan 31, 2012 5:14 am
- Contact:
Hi
It's OK in normal Tester and also OK for OnPause procedure! Thks
It's OK in normal Tester and also OK for OnPause procedure! Thks
FT Support wrote:Sorry for the delay.
OnTestCompleted function is called after every test run in strategy optimizer, I'm not sure that it will work outside of optimizer.
you can use OnTestCompleted function this wayCode: Select all
procedure OnTestCompleted; stdcall;
begin
...
end;
exports
..., OnTestCompleted, ...;
my live account - 8 based pairs with optimized parameters : +188%
http://www.myfxbook.com/members/Philipp ... jpg/519044
TradeSlide : http://bit.ly/14R9Nf6
to be informed about Windev/MT4 services : a04486-tradingsignal@yahoo.fr
http://www.myfxbook.com/members/Philipp ... jpg/519044
TradeSlide : http://bit.ly/14R9Nf6
to be informed about Windev/MT4 services : a04486-tradingsignal@yahoo.fr
Who is online
Users browsing this forum: No registered users and 6 guests