Global Variables In TS - EasyLanguage Programming | futures trading

Go Back

> Futures Trading, News, Charts and Platforms > Platforms and Indicators > TradeStation > EasyLanguage Programming

Global Variables In TS
Started:January 11th, 2012 (01:55 PM) by c12345 Views / Replies:2,408 / 6
Last Reply:July 23rd, 2012 (04:48 AM) Attachments:1

Welcome to

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community. It's free and simple, and we will never resell your private information.

-- Big Mike

Thread Tools Search this Thread

Global Variables In TS

Old January 11th, 2012, 01:55 PM   #1 (permalink)
Trading for Fun
Futures Experience: None
Platform: eSignal / NinjaTrader
Posts: 81 since Sep 2009
Thanks: 4 given, 42 received

Global Variables In TS

Hello fellow traders,

I am reading and trying to make an indicator for trade management to plot information from a higher volume chart on a lower volume frame chart, not sure if I quite "get it" so I am asking for some assistance with this with those that know the ways...

I am trying to use a Global Variable to do this,

So for instance on my Higher Volume frame chart, I have the following to GET the information to the lower frame.

(this is setting the Global Variables)
SetRtn1 = GVSetFloat( 1, SMA10 ) ;
SetRtn2 = GVSetFloat( 2, SMA10[1] ) ;

If SMA10 > SMA10[ 1] then PLOT1(SMA10, "SetRtn1")
PLOT2(Var10, "SetRtn1");

So I've excluded the SMA code, but its a faster SMA, (hull)

the issue/problem that I am having is I would like to pass this into a lower volume frame chart, and plot these on the bottom of a chart, (for trade management reasons) So if the MA from the higher frame chart, changes colors say from green to red, then I want the lower volume frame chart, to also change from green to red, real time...

On the indicator on the lower frame chart to get the data is:

MA1 = GVGetFloat( 1 ) ; { Get global float variable 1 }
MA2 = GVGetFloat( 2 ) ; { Get global float variable 2 }

If MA1 > 1MA2[1] then Plot2(MidLevel,"MidLevel",Green) else Plot2(MidLevel,"MidLevel",Red)

But what is happening, is the indicator is compiling properly/plotting but its not plotting the historic data, not sure if I need the
if LastBarOnChart then

this works, but it doesn't contain any historic data, which is useful for backtesting...

If the Global Variable method doesn't do this, then perhaps the ADE is the tools to use.

Just checking with everyone on this...


Reply With Quote

Old January 11th, 2012, 01:55 PM   #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.


Old January 13th, 2012, 06:19 AM   #3 (permalink)
Elite Member
Futures Experience: Advanced
Platform: MC
Favorite Futures: ES
Posts: 144 since May 2011
Thanks: 11 given, 211 received

You are right, GV doesnt plot past values. You need to use ADE Save OHLCV for sending and ADU Mov Avg Line for receiving.

Reply With Quote
The following user says Thank You to SPMC for this post:

Old January 14th, 2012, 06:45 AM   #4 (permalink)
Trading for Fun
Futures Experience: None
Platform: eSignal / NinjaTrader
Posts: 81 since Sep 2009
Thanks: 4 given, 42 received

What is needed for volume charts, Type Zero Sync which is some additional functions, that will allow this to happen. I've read about them extensively, and now its to the point where I think I understand how to program this... Its a bit tricky, as there isn't a great deal of documentation about this, and also the fact that TS doesn't support this..

Oh, well something new isn't always easy.

If anyone has any expertise with Type Zero Sync, with higher frame volume charts, let me know, about your success with this..

Reply With Quote

Old January 14th, 2012, 06:50 AM   #5 (permalink)
Trading for Fun
Futures Experience: None
Platform: eSignal / NinjaTrader
Posts: 81 since Sep 2009
Thanks: 4 given, 42 received

Futures Edge on FIO

What happens to the S&P 500 when a new President takes office?

Here is information about Type Zero for TS:

TypeZero Library

The "TypeZero Sync" framework (TZS) allows you to synchronize data between tick or volume charts with the same symbol and bar type but a different bar interval. For example, you can synchronize a 100 tick chart and a 300 tick chart, or you can synchronize a 1000 share chart and a 5000 share chart. It's even possible to syncrhonize charts where one bar interval is not a direct multiple of the other. Currently the framework only supports a chart with a lower interval retrieving data for a higher interval. This seems to be the typical setup that people want to use.

The TZS framework uses my All-Data-Everywhere library, version 1.07 or later. You must install ELCollections 1.03 and ADE 1.07 before you install TypeZero Sync.

Note that if you want to work with ADE and TypeZero bars (tick and volume bars), you almost certainly need to install the TypeZero Sync library as well, since it will allow you to correctly synchronize data between different charts.

Here are the instructions for using the TZS framework. Please read and follow them carefully, since you must set things up correctly in order for the framework to work properly.

1. Set up each chart that you want to synchronize so that the first bar on the chart is at the start of a session. This just means that the range should be set with Days/Months/Years Back or with First Date, rather than with Bars Back. Don't ever use the Bars Back range setting with the TypeZero Sync framework!!!

2. Apply the "! TZS Setup Sync" indicator to each chart involved in synchronization (both sender and receiver). Check the "Prompt for Format" box and make sure that the Interval input is set correctly -- e.g. it should be ADE.TickBarV(BarInterval) for tick bars using trade volume, and ADE.VolBarV(BarInterval) for volume bars using trade volume. The indicator is named with a ! at the start to ensure that it comes first in the indicator list. Indicators that use TypeZero Sync should always be named so that they come after the "! TZS Setup Sync" indicator.

3. Apply the indicator that saves data to the higher-interval chart. To save OHLCV data, use the "TZU Save OHLCV" indicator. Again, make sure the Interval input contains the appropriate TypeZero interval function for the chart.

4. Apply the indicator that consumes the higher-interval data to the lower-interval chart. Check the "Prompt for Format" box and enter the appropriate function calls for ThisInterval and ThatInterval. ThisInterval refers to the interval for the current chart, and ThatInterval refers to the higher interval. You can always pass BarInterval to the function used for ThisInterval (e.g. ADE.VolBarV(BarInterval)) , but you will need to specify the correct interval for the higher interval (e.g. ADE.VolBarV(5000)).

That's it!

When you write an indicator that uses the TypeZero Sync framework, you should call the TZS.SyncBarID function to get the correct BarID for the higher interval. Pass the function the ThisInterval and ThatInterval inputs that have been specified for the indicator. See the "TZU Bollinger Bands" indicator for an example of how to use this function.

Do not call the ADE.OnNextBar function when using the TypeZero Sync framework. Instead, save the previous BarID into PrevBarID before calling TZS.SyncBarID. After the call, check whether the BarID has changed (BarID <> PrevBarID) and only perform your higher interval logic if it has. Again, the "TZU Bollinger Bands" indicator provides an example of this.

I've provided a couple example workspaces that show the framework in action. The "TZU Plot OHLCV Demo" workspace provides a visual demo of bar synchronization. The "TZU Bollinger Bands Demo" workspace shows how to plot Bollinger Bands from a higher bar interval. Note that the "! TZS Setup Sync" and "TZU Save OHLCV" indicators in these workspaces could be hidden to reduce clutter, but I've left them visible so you can easily see how the charts are set up.

In my testing I've found that the framework works best in real time if the sending and receiving charts are in different workspaces (with the senders first). In fact, it *must* be done this way if the receiver is a strategy, since strategies will calculate before indicators in the same workspace. Thus, I recommend using different workspaces for senders and receivers. I've included senders and receivers in the same workspace for the demos because it makes it easier to compare the two charts.

You may wonder why you need to apply the "! TZS Setup Sync" indicator rather than just calling a function in your own indicator. There's actually a very important reason for this. In order for the sync setup to work correctly, the MaxBarsBack *must* be zero, so that it picks up session activity (volume or ticks) from the very first bar of the session. The only way to guarantee this is to specify a MaxBarsBack of zero for the indicator. Since many if not most indicators and strategies will employ a lookback, using a separate indicator for the sync setup seemed like the best solution. (Even if your indicator doesn't employ a lookback, if you let TS determine MaxBarsBack automatically, it will skip the first bar on the chart. Did you know that? You have to manually specify zero for MaxBarsBack if you want to get the first bar on the chart.) Because the sync setup is performed by a separate indicator, you can employ a lookback in your own indicators and strategies if you need to.

The TypeZero Sync library provides the following indicators for you to use and study:

TZU Bollinger Bands
TZU Exp Mov Avg
TZU Keltner Channel
TZU Linear Reg Curve
TZU Mov Avg Line

Note: The demo workspaces use the @ES.D symbol, so they'll require a real-time data subscription for the CME e-minis.

Attachment: DATA/20050302173356TypeZeroSyn 68887 bytes

An issue was discovered with reading TypeZero data from ADE data files (in the ADE\Data directory). This issue could cause duplicate bars to be stored in memory and then saved back to the data files.

Note that this issue applies only to TypeZero bars, not time-based bars. Also, it only occurs if you have set the UseFile input to true for one of the TypeZero indicators (e.g. TZU Save OHLCV, ! TZS Setup Sync). The UseFile input for these indicators is false by default (even if ADE.UseFile is true). If you have not saved TypeZero data to data files, then you will not have been affected by this issue.

The problem was the result of a very subtle difference in the results of BarID calculations in EasyLanguage and C++. Almost all of the ADE code is written in EasyLanguage, but there are a few helper functions in the ELCollections DLL which are used to improve the performance of reading and writing data files. This is where the problem occurred. Again, this was only happening with TypeZero bars, not time-based bars.

I have corrected the problem and posted a new version of ELCollections (1.04). Only the DLL is different from the previous version. Please download the new version and put the updated DLL in your TradeStation Program directory.

You do not need to update your ADE code to fix this problem; only the DLL needs to be updated.

Important: If you have saved any TypeZero data files in your ADE\Data directory, you should delete them and create them again after installing the new DLL.

Reply With Quote
The following user says Thank You to c12345 for this post:

Old January 14th, 2012, 08:05 AM   #6 (permalink)
Elite Member
Futures Experience: Advanced
Platform: MC
Favorite Futures: ES
Posts: 144 since May 2011
Thanks: 11 given, 211 received

Put the Send Indicator on an higher or lower Volume Chart and the Receive Indicator on a second Volume Chart with a different interval. Put in the interval of the first chart under the input "IntervalSize" at the Receive Indicator and you are done.

If you want to use it with Tick Charts you need to change the input TypeCode on both indicators to

// TypeCodes for standard Tradestation TypeZero bars
// -------------------------------------------------
// 11 = Tick bars with TradeVolume for Volume
// 12 = Tick bars with TickCount for Volume
// 21 = Volume bars with TradeVolume for Volume
// 22 = Volume bars with TickCount for Volume

Attached Files
Register to download File Type: pla SP SEND RECEIVE.pla (83.2 KB, 37 views)
Reply With Quote
The following 3 users say Thank You to SPMC for this post:

Old July 23rd, 2012, 04:48 AM   #7 (permalink)
Elite Member
Bordeaux, FRANCE
Futures Experience: Advanced
Broker/Data: IB
Favorite Futures: Eurex
Posts: 7 since Oct 2010
Thanks: 2 given, 0 received

Very good post ! now, i need all tools to use TZU framwork.

but i need latest ELcollection,ADE, and TZU framwork ...I can't acces to tradestation forum , somebody can share ?

Many Thanks for your help.

Reply With Quote

Reply > Futures Trading, News, Charts and Platforms > Platforms and Indicators > TradeStation > EasyLanguage Programming > Global Variables In TS

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Upcoming Webinars and Events (4:30PM ET unless noted)

An Afternoon with FIO trader bobwest

Elite only

NinjaTrader 8: Programming Profitable Trading Edges w/Scott Hodson

Elite only

Anthony Drager: Executing on Intermarket Correlations & Order Flow, Part 2

Elite only

Adam Grimes: Five critically important keys to professional trading

Elite only

Machine Learning Concepts w/FIO member NJAMC

Elite only

MarketDelta Cloud Platform: Announcing new mobile features

Dec 1

NinjaTrader 8: Features and Enhancements

Dec 6

Similar Threads
Thread Thread Starter Forum Replies Last Post
Global Variables (GV) in EasyLanguage for TradeStation/MultiCharts Big Mike EasyLanguage Programming 19 October 29th, 2013 03:07 PM
Global variables for sharing data between Charts ECI Ed NinjaTrader Programming 5 March 6th, 2012 09:02 AM
global variables: anyone got a complete NT7 example? elbone NinjaTrader Programming 2 July 19th, 2011 09:13 AM
Exposing variables kaywai NinjaTrader Programming 4 April 14th, 2011 11:58 AM
Global Variables and Strategies in Ninja 6.5 TonyA NinjaTrader Programming 3 November 6th, 2010 07:50 AM

All times are GMT -4. The time now is 10:11 AM.

Copyright © 2016 by All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts

Page generated 2016-10-25 in 0.14 seconds with 20 queries on phoenix via your IP