About Ensign

Owner of Ensign Software, Inc.

ESPL: AlertEvent( eSave )

Q:  Is there a way to differentiate between the 3 different events that fire the AlertEvent(eSave) processing?

The 3 possible events are:

a) the user closes the chart.
b) the Timeframe button is used to change the chart but the chart form is the same.
c) the data for the chart is refreshed.

In the first two cases, I want to perform my CloseChart processing, i.e. save the chart data to file and close the MainForm instance.   In the second case, a new MainForm instance will be created by the subsequent eLoad event.

In the third case, it is possible that new bars have been added before the barend. In this case, the appropriate action is to reinitialize so that processing begins from the start but I don’t want to save the data to file and close the instance.

A:   Ensign 10 ESPL splits out all the places the AlertEvent(eSave) is called and identifies the procedure in the IT variable’s string.   The possible places for saving chart datafile are many. The IT text will have the time, then Save and a word for the procedure, and then the symbol. You can use

if pos('Save Close',IT)>0 then begin 
  {this is case a) for chart close} 

Other choices for xxx in ‘Save xxx’ are:   Roll, Build, Objects, Open, Close, Rebuild, Template, Property, Timer, Load, Refresh, ESPL 1, ESPL 2, ESPL 3, Update, and Time.

The 3 events you asked about would be: 

a) Save Close
b) Save Time
c) Save Refresh

Of course, put in some logging of the IT value to the output window and verify the content of IT for the various actions you take and the program exercises and skip those that do not affect your system design.   

Example test code:

  if ESPL=0 then AlertEvent(eSave, 600);
  if ESPL=600 then writeln( IT );

Dollar Delta Marker

Q:  I was testing the dollar delta feature in Ensign 10 on some commodities that are not priced with decimals – specifically soybeans. When I use the dollar delta feature on bean contracts it does not display the dollar amount clearly.

A:  The answer is right. Just need to know how to interpret it.  Dollar Delta will show the price change points multiplied by the leverage to give the change in dollars.

In this example, the 2 end points of the line are 10 cents apart, and at $50 per cent, the answer is $500.

The scale format for these grains is 8ths, meaning the last digit of the price is the fraction cent. So the last digit of 2 is 2/8th, and 4 is 4/8ths. The answer from the delta dollar is in the same price format, meaning the last digit is the fractional part. 5000 is 500 and 0/8ths, ie $500.00

ESPL: Print Message on a Chart

This article shows various ways to print a message on a chart using ESPL.

1) The following sample code will print bar values on a chart.

  bar_1, bar_2: integer;
  if ESPL = 1 then begin
    bar_1 := 5;
    bar_2 := 10;

2) The following sample code uses ADDNOTE to place a note on a chart.

  if ESPL = 1 then begin
    FindWindow(eChart);  // Find the chart with focus
    AddNote( 'Buy the Market', 4, -10, -10, 0 );

3) The following example, adds a note to a chart, then changes the Note text after 5 seconds.  Keep track of the HANDLE of the note, in order to change it later.  The ESPL documentation for SetStudy shows that the NOTE text is stored in SELECT value 30.

  if ESPL = 1 then begin
    FindWindow(eChart);  // Find the chart with focus
    iNoteHandle := AddNote( 'Buy the Market', 4, -10, -10, 0 );
    SetStudy(iNoteHandle,30,'Sell the Market');

Chart Scanner on Bollinger Bands

Q:  I want the scanner to tell me which symbols on the quote list has price above/below the first band in a 20 day BB study (above +1 Std , below -1 Std).

A:  This example will walk you through the steps.

1)  Create a quote page of symbols to scan.   In this example the vendor’s symbol list is used, but a custom list could have been used.  Here is the vendor list and quote page.

2) Open a daily chart for each symbol to verify the chart is complete. Refreshed the chart if needed. Charts can then be closed.

3) On one chart, put on a Bollinger band and configure it for a 20 Average and 1 multiplier. Now add a DYO configured this way to test for Close exceeding either upper or lower bands.

Variable [8] has the upper band value, [9] has the lower band value, and [3] is the flag that is True when close exceeds either band.  These 2 studies are then saved as a template named BollingerTest.

4) Open Setup | Chart Scanner, and configure the form like this.

Name this setup Bollinger and use the Save button to remember these settings after filling in the form. That way it can be retrieved.

The box to use the Vendor quote page for eSignal is checked. Load each chart with the BollingerTest template. Chart time frame is Daily.

The Criteria for adding to the report is when Variable [3] is True.  [3] was set by the DYO.

The report will have 4 columns with labels Symbol, Close, Upper, Lower. The format is caption = value.  [$S] is the token for showing the chart symbol. [$C] is the token for the Close price.  [8] and [9] are variables populated by the DYO for the upper and lower Bollinger bands.

5)  Now, click the Run Scanner button and get a report of results like this.

Of the symbols on the quote list, 7 triggered the criteria. AAPL Close is 587.45 which exceeded the Upper Bollinger band.   Here is the AAPL chart as confirmation.

The price has moved a few cents from when the scan was run and the chart image captured for this example.

IB Gateway Feed

Ensign 10 and Ensign Windows can receive the Interactive Broker feed through the IB Gateway or through the IB Trader Workstation.   The advantage of the IB Gateway is it does not have the overhead of showing a quote page or trade platform.   Also, the IB Gateway is not required to be shut down each day whereas TWS does shut down.

Get the IB Gateway from the IB web site using this link.  It installs with the TWS.


Gateway can be found in the Start menu, All Programs | Interactive Brokers folder.  Drag the Gateway icon to the desktop so there is a desktop link named IB Gateway.

For Ensign Windows, run Gateway and manually connect.   Ensign Windows will find Gateway running and connect to it to receive the feed from Interactive Brokers.

For Ensign 10, check the box Use IB Gateway instead of TWS found on the Setup | Feeds form.  Ensign 10 can run IB Gateway and accomplish the login process.

 IB Gateway uses the same Username and Password as is used by TWS.   Note in the above example that the Reconnect time has been blanked out which is appropriate since Gateway remains running and does not need to be rerun by Ensign each day.

To log in to IB Gateway the 1st time, you need to change the bullet selection to IB API.  Then enter your Username and Password.

You must change the port setting that Gateway listens on for Ensign to connect to it.   In Gateway, click menu Configure | Settings | API | Settings and change the port to 7496.  And create the entry in Trusted IP Addresses for  as shown here.

Study Values in Sections

Q:  How can I have a DYO display study values at the bottom of the chart?  Basically what I want to do is instead of having the show values window appear on the left side of the chart I would like the values to be displayed in the DYO field sections of their respective DYO’s to save screen real estate.

A:   This DYO will show current study values in sections at the bottom of the chart. These are current values that will update tick by tick. They are not study values aligned for where the mouse is.

A – Read a study value and show the label with a blue background and white font. The label has |1| to indicate the location is the 1st section.

B – Read another study value and show with a brown background. The label has |2| to locate the text in the 2nd section.   [B.2] is the value from Row B formatted to show 2 decimals.

A DYO like this can show values in 7 different sections that exist at the bottom of a chart. Use the section tags |1| through |7|.

Import Ticker Symbols

Q:  How can I transfer a list of ticker symbols to Ensign 10.

A:  If you want a list of ticker symbols to be a list your data feed follows, save the ASCII file with the name Symbol1.dat in the /Feeds/vendor folder. Here is the example for the eSignal vendor and its folder is ES under /Feeds. 

Then the program will watch this list of symbols and populate the ESignal quote page with live updates.

If you want a custom quote page, then the ascii text file with the symbols is like this example.  The folder is Quofile and the text file has a .dat suffix. The list of symbols have a single character prefix for the vendor, and they are in the same list order as the Feeds on Setup Feeds. The list starts with A for FXCM vendor and B for Interactive Broker vendor feed, etc.

A Spreadsheet cannot import your ticker list. However you could use ESPL to read your file and then poke the cells on the spread sheet with the strings of your ticker list.

Code example would be something like this.

  sList.LoadFromFile(sPath + 'yourfilename.dat');
  for row := 1 to pred(sList.count) do
    SetCell(2, row, sList[row], clWhite); {1st param is column}

Day Session Range

Q:   I need to view the ES on an all-sessions chart.  But I would like to have a DYO start at 9:30 and end at 16:15.  I would like it to find the high and low during that time which would allow me to display the range on the message text.

A:  Use a Daily Price Lines tool to find the day session only high and low, and a DYO to calculate and show the range in the message text.

The DPL will find the Today High and Today Low, but have the Day Session box checked so these values are found using only the 9:30 to 16:15 data.  Their values are saved in the GVs as shown so the DYO can calculate and show the range.

Two Lessons from History

Larry Pesavento: ‘Bernard Baruch, the famous speculator from the 1920’s had several investment rules that he relied on throughout his career that are now famous quotes and basic tenets for thousands of investors today. These three charts exemplify some of the most noted of these rules. The first chart shows the Greek Markit manufacturing index in a very steep downtrend.

Since rates on Treasuries have reached essentially zero, it is unlikely this divergence can continue and either Treasuries or equities (and quite possibly both) could be headed for a potential collapse. Either way, this illustrates another rule: do not be concerned on the return ON your money, be concerned with the return OF your money.

This week, the stock market has reached the three-year anniversary of the major low dating back from March of 2009. Incredibly, nothing in the underlying economy has really changed since. More importantly, all of the AB=CD patterns that I have been looking at on a worldwide basis still remain intact. While I know this may sound like a broken record each week, the record is still playing and has not changed its tune. My bearishness remains intact, and I am awaiting a suitable entrance into the expected reversal.’

Where Files are Saved

Q:  There needs to be a better explanation about how to save charts, save layouts, and using the backup folder.

A:  Although the answer and examples will use Ensign 10 folders and paths, the information is applicable to Ensign Windows.

Charts:  When a chart is opened from the charts form or from a quote page, the process reads the chart’s property file (if one exits), loads the chart’s data file and brings the bars on the chart current by extracting from database files, and then dresses the chart with study and draw tool objects.   If a chart is being opened for the first time, it will not have a property file, and so the default C:/Ensign10/Inifile/Chart.ini file is read.  Chart property files are located in the C:/Ensign10/Property folder using the chart symbol in the filename.

Studies and Draw Tools that belong to the chart are located in the C:/Ensign10/Study folder and use the chart symbol in the filename.

Layouts:  When a layout is opened, the layout script contains information about which forms to open, where to position them, and how to dress the charts with studies and tools.  The layout file possesses the chart properties, and the chart objects.  Thus, a chart opened by a layout does not read from the C:/Ensign10/Property folder nor from the C:/Ensign10/Study folder.   Layout files are located in the C:/Ensign10/Layout folder with a sub-folder for each of the eight layout form tabs.

The layout file is saved when you use the Save or Save As buttons on the layout form.  You should resave layouts using different names when you are evolving your layout content so that you have an earlier version of the layout if you experience a difficulty.

The pop-up menu for Save Layout (hot key CTRL+W) executes the same code as the Save button on the Layout form.

Templates:  Templates are a collection of studies and draw tool objects that are stored as a file so the collection can be applied to a chart.  Template files are located in the C:/Ensign10/Templates folder with a sub-folder for each of the eight template form tabs. 

Template files are saved when you use the Save or Save As buttons on the template form.  You should resave templates using different names when you are evolving your template content so that you have an earlier version of the template if you experience a difficulty and want to return to an earlier version.

Backups:  You are encouraged to have the Setup | System option checked to Backup Templates on Exit.  This backup feature will backup several important folders, including layouts.  Upon program exit, important files will be copied to the folder C:/Ensign10/AutoBackup which has sub-folders for each day of the week.  Thus, there could be a useful image of your files from Monday if they need to be restored on Wednesday.

Another backup and restore feature is found on the Setup | System | Maintenance form.  Perform task #14 to create an extensive backup to folder C:/Ensign10Backup.  And performing task #15 would restore this backup from the same folder.  This manual backup image is more extensive and is independent of the backup made on program exit.

The backups are accomplished by copying files.  Thus any file could be restored by using Windows Explorer to copy the file from the backup location to its appropriate folder under the C:/Ensign10 folder.

Undelete:  The chart objects form has an Undelete button which when clicked will restore the last deleted chart object.   The undelete is accomplished by reloading a template of the chart objects that was saved in a C:/Ensign10/Backup folder prior to the deletion.   Though this was intended for use by Ensign 10 behind the scene, this folder might have a useful copy of how a chart was dressed with studies and draw tools if a template file is accidentally deleted or corrupted in the C:/Ensign10/Templates folder.

Personal Backups:  Trading is a serious endeavor, and should be treated as such.  You should make your own backups to devices which are separate from the computer’s hard disk.   I recommend a free program called EZBackitup and use it on a daily basis to back up important files and folders to an external hard disk or to jump drives.  It is easy to create a backup script by dragging files or folders from a navigation tree to the backup list.  Jump drives are inexpensive, so I backup to a different one each day of the week.