Enter/Edit Program
Previous  Top  Next

Backup First

Before editing the study library, you should make backup copies of the existing files (\UA\studylib with various file extensions, depending upon language). This will allow you to return to the original file in case of problems with your changes. Save your backups in a separate folder or under different filenames.

Whenever you upgrade to a new version of UA, a new studylib file may be included. To avoid overwriting your previous changes, UA will automatically save your old studylib file in a folder called \ua\Oldlibs. Changes you have made to your studylib file (which would then be found in ua\oldlibs) can be cut and pasted into your current studylib file, which is always found in the \ua folder. Please contact CSI Technical Support if you need assistance with backing up files or cutting and pasting text.

The study library is shared between Unfair Advantage's basic charting module and MarketScanner. The editing function is handled through the same "Code Editor" screen used to select and run an existing study. See the introduction to the first several topics of this chapter for instructions on reaching this point.

Programmers may edit or add new studies to the Interpreted Studies library by simply entering code into the existing file. Follow the steps shown here:

1) Select Language
2) Select Study
3) Start programming!

This part of the process is the creative, open-ended part. You can see by the examples and in the provided libraries that there are many ways to get the job done.

As in any programming job, be sure to use the conventions required by your chosen language, including the necessary terms to start and end your analysis routines. For example, each study in VBScript or AnyLanguage must begin with "Function" and end with "end function." We recommend the "For Dummies" series of books for VBasic or Perl. They can save you hours of frustration.

Tip: Examining the existing studies is often the quickest and easiest way to answer your programming questions.

See the Study Concepts and Syntax topics for more information on programming your study. The ua\studylib.* files contain many useful examples of how to write indicators. Hopefully, these examples will help you get started using UA and MarketScanner for writing custom indicators. Three full examples are also included in this manual:

Example 1 - A one-function version of the A/D Oscillator
Example 2 - A/D Oscillator using the ExpMovingAverageOfData
Example 3 - A/D Oscillator using the ExpMovingAverageOfFunc

The Code Editor form:


codeedit1


Placement of New Code: Although we see no reason to avoid adding to the end of the file, you may insert a new study anywhere in the file, as long as it is not within an existing study. Regardless of actual code placement, your new study will appear in alphabetical order on the Interpreted Studies menu. Use the scroll arrows at right and click your mouse within the window to place your cursor.

Locating a Study to Edit: If you wish to change a study, select it through the "Select Indicator From List" menu at the top of your screen. The code will be displayed in the lower box.

Line Numbers: Click the box in the scroll bar at right to display the line number for the top line visible on your screen as shown. (Note that the line number shown does not correspond to the placement of the mouse.)

linenum


Changing Views:

less   To hide the window showing the programming code, click the [<< Less] Button.

more   


To display programming code that has been hidden, click the [More>>] button.

Pre-Programmed Statements: The sample code provided includes many helper subroutines which you may call in your own programs. These include functions to find a symbol to report, the number of days to report, the current date to report price data, etc... A current list can be found in the Study Input topic (helpers excluded). Please review the file for a full listing.

Search, Replace and GoTo: To simplify the job of searching for statements and replacing code, the Search menu offers a typical set of options as shown:

searchmen


Pull down the Search menu and click "Find" or "Find Next" to bring up the extensive list of search options:

searchtex


Choose your desired options, direction and "Match within" specifications and then type the search field. Click [OK] to begin your search.

Pull down the Search menu and click "Goto Line" to enter a specific desired line number.

Save File

UA will automatically save your file when you run the program, but you may want to save or cancel your changes at other times. If you do not save your file and your system freezes for any reason, your work will be lost. To save or cancel your changes, pull down the "File" menu and choose from:

·Save (to make your changes permanently effective)  
·Save and Close (to make your changes permanently effective and exit the editor)  
·Close without Saving (to cancel your changes and exit the editor)  

Printing the File


You can save a hardcopy (printed) version of the file by pulling down the "File" menu and clicking "Print." A normal print dialog will display.

Select Study

When your new or edited code is complete, you must select it from the menu to run the program. Click the "Indicator From List" menu for a revised list of available studies, which should now include your latest addition. Click the desired study and UA will display the necessary expression for executing the file in the top text box.

You must now enter all necessary parameters in the expression statement.

Run the Program

run   Click the [Run] button at the bottom of the screen to execute the selected study (in MarketScanner). Depending upon the complexity of your study and the language selected, it may take a few moments to complete. If you are programming your study through UA's charting module, click the [OK] button. This will add the study to your Study Toolbar, where you may [Apply] it to your chart.

View Results

After successful completion:

If the analysis completes successfully, the "Choosing Studies" screen re-displays showing your study as the selected option. Click [OK] to display the study.

After unsuccessful completion:

If your analysis does not complete properly, an error message will display. Click [OK] to close the message box and then click [Cancel].

Common Error Messages:

·Getbool from undefined myvarient - This error message indicates an undefined parameter in the expression. Check your input and make sure you complete the parameter entries properly.  

·Divide By Zero Error, Syntax Error, etc.. - These errors and others indicate flaws in your program.  

·Inconsistent # of Returns - A programming error indicating that all fields are not reported consistently throughout the study.  

Many different error messages are possible. If your program fails to run, return to the Code Editor and try to correct the problem. We recommend you use the AnyLanguage language so you'll be able to check your program line by line using the debug mode.

When entering and/or editing a program, you'll benefit from understanding some basic Study Concepts.