Global Variables In TS - EasyLanguage Programming | futures io social day trading
futures io futures trading

Global Variables In TS
Updated: Views / Replies:4,424 / 7
Created: by c12345 Attachments:1

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 100,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • 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.

-- Big Mike, Site Administrator

Thread Tools Search this Thread

Global Variables In TS

  #1 (permalink)
Trading for Fun
Futures Experience: None
Platform: eSignal / NinjaTrader
Posts: 81 since Sep 2009
Thanks: 4 given, 43 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
  #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.

  #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:
  #4 (permalink)
Trading for Fun
Futures Experience: None
Platform: eSignal / NinjaTrader
Posts: 81 since Sep 2009
Thanks: 4 given, 43 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
  #5 (permalink)
Trading for Fun
Futures Experience: None
Platform: eSignal / NinjaTrader
Posts: 81 since Sep 2009
Thanks: 4 given, 43 received

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 2 users say Thank You to c12345 for this post:
  #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, 48 views)
Reply With Quote
The following 3 users say Thank You to SPMC for this post:
  #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
  #8 (permalink)
Elite Member
Futures Experience: Intermediate
Platform: TradeStation
Favorite Futures: Forex
Posts: 1 since Mar 2012
Thanks: 0 given, 0 received

I have a problem and am wondering if the TypeZero Synch might be a workable solution, but I am not sure if it woud work. I am using TradeStation with a third party program to create strategies that I subsequently automate and day-trade using a server. I have programmed my own custom indicators for use with the third party program that creates the strategies from past data. What the third party program uses for the custom indicator values is the data output values seen on a chart of the symbol to which the custom indicator(s) has/have been applied. So in step (A) I chart @ES.D - 10 minute price bars beginning on 10/14/2007 with 5 custom indicators, all with different max bars back values (say they are 52 bars, 150 bars, 280 bars, 21 bars and 100 bars, respectively for custom indicators number 1 through 5)
Now the problem is that the final strategy created by the third party program may have a Max Bars Referenced value of say 280 bars, and use custom indicator numbers 1 and 3. In Step (B) , I use custom functions that I have created to actually implement the strategy code generated by the third party program. The custom functions would work properly to reproduce the indicator values from step (A), provided that the original max bars back for each individual indicator was the same as in step A. But now the max bars back values have changed (for example indicator #1 is now using max bars back of 280 bars instead of 52) and in some cases the indicator values are totally different, thus making the strategy useless.
I am thinking that if I created workspace number one with custom indicator number (1) and workspace number two with
custom indicator #3 and workspace number three with a real-time chart of the symbol in a TZS environment, that I could get the strategy code to work properly, despite the discrepancy in the max bars back values.
I need both a working back-test, showing that the strategy code is working on past data, and the ability to make the strategy run in real time going forward.

Does this make sense? Do you think it would work?

Reply With Quote


futures io > > > > > Global Variables In TS

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

September Journal Challenge (sponsored by TopstepTrader)


Battlestations! Win $947 in prizes for showing us your trading desk!


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 01:44 AM. (this page content is cached, log in for real-time version)

Copyright © 2018 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432,
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 2018-10-18 in 0.17 seconds with 15 queries on phoenix