Improving strategy development

Share your ideas how the software could be improved
Message
Author
philBell
Posts: 24
Joined: Thu Jul 23, 2009 7:20 am
Location: Brighton, UK

Improving strategy development

#1 Postby philBell » Thu Aug 13, 2009 1:37 pm

In the absence of the ability to use the Delphi debugger on a strategy (stepping through code and watching variables change would be a huge productivity boost) I spend days going round a "change print()'s, re-build, re-install, reselect the strategy, test, possibly transfer log to Excel" loop. This would be helped :

a) if re-installing the selected strategy left it selected, rather than needing me to go back to the strategy list and manually re-select it every time.

b) allow the system's own "Order #nnn" messages to the log to be disabled, so that I don't have to search for my own print() output embedded in a stream of other messages

c) have the toolbar button that clears the log in the program also clear the log file, to make it easier to select just the data from the last test run. This might need to be an option if someone is already using the log file to accumulate multiple runs?

Phil Bell

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

Re: Improving strategy development

#2 Postby Terranin » Thu Aug 13, 2009 8:29 pm

philBell wrote:In the absence of the ability to use the Delphi debugger on a strategy (stepping through code and watching variables change would be a huge productivity boost) I spend days going round a "change print()'s, re-build, re-install, reselect the strategy, test, possibly transfer log to Excel" loop. This would be helped :

a) if re-installing the selected strategy left it selected, rather than needing me to go back to the strategy list and manually re-select it every time.

b) allow the system's own "Order #nnn" messages to the log to be disabled, so that I don't have to search for my own print() output embedded in a stream of other messages

c) have the toolbar button that clears the log in the program also clear the log file, to make it easier to select just the data from the last test run. This might need to be an option if someone is already using the log file to accumulate multiple runs?

Phil Bell


It is possible to use debugger, see this topic: http://forextester.com/forum/viewtopic.php?t=1065&highlight=debug
Hasta la vista
Mike

philBell
Posts: 24
Joined: Thu Jul 23, 2009 7:20 am
Location: Brighton, UK

#3 Postby philBell » Fri Aug 14, 2009 8:34 am

I read the post, but the steps don't work for me; I PM'd Plasmapelz about it, and he was using ForexTester 1.x at that time but concluded "Since version 2.x I don't use it any more".

I'm using ForexTester 2.2 and the free Turbo Delphi referred to on the Forum, under Vista Home Premium. I do my normal work (including Delphi & ForexTester) in a username that does not have administrator privileges, as a protection against malware; there is a separate user ID for installations. The PC is not networked, other than being connected to a hub sharing a broadband modem between three PCs. There's no sign of a "Local group policy" in Control Panel, as referred to in the Delphi Debugging Help. To record my attempts :

1. In the Examples\Strategies\Delphi folder from the ForexTester installation, open SMAStrategy.dpr in Turbo Delphi. Correct the syntax error by adding a "begin" before the final "end.", and Build to create SMAStrategy.dll.

2. In ForexTester, select Install from the File menu, choose the SMAStrategy.dll from the Delphi Examples folder & click Install

3. Select the just-installed strategy from the Strategies list.

4. Put ForexTester into Testing Mode.

5. In Delphi, choose Attach Process from the Run menu (Plasmapelz's post says "Start menu")

6. Select ForexTester.exe from the list, with the Pause after Attach checkbox checked & the Remote machine textbox blank, and click Attach.

7. Delphi switches to the CPU tab of the debugger.

8. Switch to the SMAStrategy source tab and create a breakpoint on the first executable line of GetSingleTick, "if Symbol <> string(Currency) then exit;". Line is highlighted, but the red breakpoint icon has a white cross on it (rather than the yellow cross the Delphi Help shows as an "Invalid breakpoint").

(image1.png)

9. Click the green Run button in the Delphi debugger; a "Source has been modified, Rebuild?" dialog appears.

If I click the No button, the sequence is :

A. Nothing happens, presumably because ForexTester is waiting for a command. Switch to ForexTester & click the Clear Log button; the log clears OK.

B. Click the Fast Test button, set a start date in the dialog, and click Execute.

C. The test runs, trades are shown on the price chart and messages are written to the log, but the Delphi breakpoint isn't hit

If I click the Yes button, the sequence is :

A. A "Cannot run project unless a host application is defined. Use the Run|Parameters... dialog box" dialog appears.

B. Click OK to clear the dialog

C. Select Parameters from the Run menu, and choose C:\ForexTester2\ForexTester2.exe

D. Click the green Run button in Delphi, and a Protection error dialog "Debugger detected - please close down and restart" appears. Clicking OK clears the dialog, terminates ForexTester, and the red breakpoint icon in Delphi loses its white cross

The same sequences of events occur if I give the user ID administrator privileges.

It is entirely possible that there's an option that needs to be set somewhere within Delphi, which an expert knows about but which I haven't stumbled across it in the help.

Phil Bell
Attachments
Image1.png
Image1.png (38.7 KiB) Viewed 11834 times

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

#4 Postby Terranin » Fri Aug 14, 2009 12:30 pm

Ok, I checked this situation and it works fine for me.

Here it is steps how to use Delphi debugger with strategy in Forex Tester:

1. You need to copy all your strategy files (strategy *.dpr and StrategyInterfaceUnit.pas, TechnicalFunctions.pas) to the <ForexTester>\Strategies\ folder.

2. Compile your strategy before you start ForexTester in this folder. Enable all debug options in Project -> Options -> Compiler. (do not install strategy via File menu, you need to compile it exactly in this folder).

3. Start ForexTester.

4. In Delphi go to menu Run -> Attach to process and select there ForexTester.exe. (you will need to press Run few times probably, because it will show CPU window and pause).

5. Now you can set breakpoints, go step by step, and see variables. Works fine for me.
Attachments
1.png
1.png (51.64 KiB) Viewed 11825 times
2.png
2.png (23.62 KiB) Viewed 11825 times
3.png
3.png (14.09 KiB) Viewed 11825 times
4.png
4.png (52.39 KiB) Viewed 11825 times
5.png
5.png (51.65 KiB) Viewed 11825 times
Hasta la vista

Mike

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

#5 Postby Tantalus » Fri Aug 14, 2009 5:44 pm

Can a similar method be used to debug indicators? Would the setup be the same?

B-
Tantalus Research - Developing 21st Century Trading Systems.

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

#6 Postby Terranin » Fri Aug 14, 2009 6:46 pm

Tantalus wrote:Can a similar method be used to debug indicators? Would the setup be the same?

B-


The problem is that when you put indicator on the chart FT copies original indicator from Indicators folder to the currency folder and timeframe, and changes its name to something like 0F32034802.dll. If you manage to replace this dll with yours you will be able to debug it.
Hasta la vista

Mike

philBell
Posts: 24
Joined: Thu Jul 23, 2009 7:20 am
Location: Brighton, UK

#7 Postby philBell » Sat Aug 15, 2009 5:22 am

Many, many thanks for your efforts - that's going to be a HUGE help.

Would it be sensible to move this post chain to FT API from here, so that its easier for other people to find in the future?

What is necessary after you've made a change to the project and re-built; will ForexTester pick up the new version, will it be necessary to re-install via the File menu, or will it be necessary to terminate and restart FT to pick up the changes?

Thanks again.

Phil Bell

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

#8 Postby Terranin » Sat Aug 15, 2009 9:27 am

philBell wrote:Many, many thanks for your efforts - that's going to be a HUGE help.

Would it be sensible to move this post chain to FT API from here, so that its easier for other people to find in the future?

What is necessary after you've made a change to the project and re-built; will ForexTester pick up the new version, will it be necessary to re-install via the File menu, or will it be necessary to terminate and restart FT to pick up the changes?

Thanks again.

Phil Bell


I copied this post to Programming Lessons too.

If you want to rebuild code - you need to close Forex Tester, rebuild it and then start ForexTester again. You can not rebuild it while ForexTester is running, because dll file will be locked by FT.
Hasta la vista

Mike


Return to “New Feature Suggestions”

Who is online

Users browsing this forum: No registered users and 33 guests