PowerBasic Debugger

Many of our NeuroShell Trader users have started to write their own custom indicators using a programming language called PowerBasic. PowerBasic is a good programming tool which allows easy dynamic-link library (DLL) writing and compilation. It is so easy that even people with very little programming experience can use it. There is one problem, however. The PowerBasic DLL Editor does not allow you to debug the DLL source code while the DLL is being called from the Trader.

We have come up with a way to work around of this problem. The solution is to use the PowerBasic DLL Editor and build a small console application (not the DLL), which would emulate the Trader while calling your custom indicator.

The basic steps are:

1.In the beginning of your existing DLL source code module put the #COMPILE EXE statement and remark the #COMPILE DLL if there is one.

2.Add the PBMAIN() function in the end of the module.

3.In the PBMAIN() function, declare the input and output arrays and fill the input array(s) with some data emulating stock market time series data.

4.Put a call statement in the PBMAIN function to call your custom indicator passing the input/output arrays and other necessary parameters.

5.Make sure the module compiles with no visible errors.

6.Start the Debugger.

7.Use the Debug menu commands to navigate across your source code.

8.Place breakpoints (by pressing F9) on the lines of code you need to interrupt the program execution and check the variable values.

9.Use the “Watch Variable” and “Evaluate” commands to test the value of program variables.

10. Continue program execution by pressing F8 (single step), F5 (run), or other Debug menu commands.

We have built a PowerBasic console application example called DEBUG.BAS, which demonstrates the process described above. We used the Moving Average indicator and built a console application around it. To run and debug the example, start the PowerBasic DLL Editor and load the DEBUG.BAS. Then follow steps 5-10 above. You may want to use the example as a template and modify it in order to debug your own custom indicators written with PowerBasic.

Click here to download the self-extracting archive file containing the DEBUG.BAS example.

Was this article helpful?

Related Articles