Study Transfer

Plotting Studies from Another Chart

Global Variables can be used to transfer study values from one chart to another chart.   Write Global Variables for a study on one chart, and then plot the Global Variables on the 2nd chart.

In this example, a 3x5ATR study is plotted on both charts.   The 3x5ATR is plotted as a red channel on the 500-Volume chart, and plotted as a blue channel on the 34-Tick chart.   The red channel from the 500-Volume chart is also being transferred to the 34-Tick chart and plotted as a red channel.   This is how it is done.

The property form for the study on the 500-Volume chart is storing its study values in Global Variables [10] and [11].   This is the property form for the DYO.

Note that the study value on Line C is being written to GV[10], and the study value on Line E is being written to GV[11].

Then the DYO on the 34-Tick chart not only plots its own 3x5ATR study, but it also plots GV values for [10] and [11].  This is the DYO property form on the 34-Tick chart.

Lines A through Line E are the implementation for its own 3x5ATR study.    Line G and Line H are the two lines that plot in red the study values from the other chart.

It is important to understand that the two charts open and calculate independently of each other.  Note that the study lines on the 34-Tick chart are flat lines ahead of  13:33.   This is the time when the two charts were opened.   The 500-Volume chart calculated and wrote final values to GV[10] and [11].   Then the 34-Tick chart opened, calculated, found constant values in GV[10] and [11] and plotted these as the flat red lines on the left side of the Start arrow.  

Live data updated the chart on the right side of the Start arrow.  As new ticks arrived, both charts updated tick by tick and recalculated their studies tick by tick.   The Red lines on the 34-Tick chart are plotting the study values from the 500-Volume study.

Information From Other Charts

There is popular interest in writing study and alert values from one chart to Global Variables, so they can be used as part of the signal logic on another chart.   Possibly the charts are different symbols, or the same symbol but different time frames.   Global Variables make it easy to pass study and alert data among charts.

However, there is the following characteristic that needs to be understood and tolerated.  While the information can be shared during real-time operation, there is a problem in trying to show previous results or Alert graphics when a chart is reopened or a workspace is redisplayed.   The issue is that each chart does its calculation independently of other charts.   Chart A might need study data from Chart B that Chart B stores in Global Variables.    When Chart A opens and calculates across all of its bars, it will use whatever values are present in the Global Variables.  These GV values intended to be set by Chart B will be constant while Chart A calculates across all its bars.   Chart B might not even be open yet.

So, the clever interaction between Chart A and Chart B will work fine in real-time where each chart gets a chance to calculate tick by tick.  But it will not show correctly what happened in the past when either chart does a full recalculate across all bars.  

The second issue to be aware of is that the Windows operating system has a Z-order list for the child windows.  When a chart receives focus, it moves to the top of the Z-order list.   Execution for calculation will be according to the Z-order list, from top to bottom.  Thus, you may intend for Chart B to calculate before Chart A so the values being passed are updated in the Global Variables before they are needed.  However, you cannot control the way the charts will change positions on the Z-order list.   At times, Chart A will calculate ahead of Chart B and at other times Chart B will calculate first.   Hopefully this will not be much of a problem for the signals and systems you design, but it is a fact about what is really happening.


Copyright © 2008 by Ensign Software, Inc.