NexusFi: Find Your Edge


Home Menu

 





Global Variables In TS


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one c12345 with 3 posts (2 thanks)
    2. looks_two SPMC with 2 posts (4 thanks)
    3. looks_3 jojojo with 1 posts (0 thanks)
    4. looks_4 Quick Summary with 1 posts (0 thanks)
    1. trending_up 9,101 views
    2. thumb_up 6 thanks given
    3. group 4 followers
    1. forum 8 posts
    2. attach_file 1 attachments




 
Search this Thread

Global Variables In TS

  #1 (permalink)
c12345
PA
 
Posts: 81 since Sep 2009
Thanks Given: 4
Thanks Received: 47

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")
else
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
begin

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...

thanks

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
MC PL editor upgrade
MultiCharts
How to apply profiles
Traders Hideout
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
What broker to use for trading palladium futures
Commodities
 
  #3 (permalink)
 SPMC 
GER
 
Experience: Advanced
Platform: MC
Trading: ES
Posts: 144 since May 2011
Thanks Given: 11
Thanks Received: 213


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
Thanked by:
  #4 (permalink)
c12345
PA
 
Posts: 81 since Sep 2009
Thanks Given: 4
Thanks Received: 47

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)
c12345
PA
 
Posts: 81 since Sep 2009
Thanks Given: 4
Thanks Received: 47

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
TZU Plot OHLCV
TZU Save OHLCV

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 c.zip 68887 bytes
https://www.tradestation.com:443/Discussi...peZeroSync.zip


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
Thanked by:
  #6 (permalink)
 SPMC 
GER
 
Experience: Advanced
Platform: MC
Trading: ES
Posts: 144 since May 2011
Thanks Given: 11
Thanks Received: 213

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
Elite Membership required to download: SP SEND RECEIVE.pla
Reply With Quote
Thanked by:
  #7 (permalink)
 Gillou 
Bordeaux, FRANCE
 
Experience: Advanced
Platform: MULTICHARTS
Broker: IB
Trading: Eurex
Posts: 8 since Oct 2010
Thanks Given: 2
Thanks Received: 0

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)
 TraderDoc2 
Plainview
 
Experience: Intermediate
Platform: TradeStation
Broker: TradeStation
Trading: Futures
Posts: 34 since Mar 2012
Thanks Given: 1
Thanks Received: 21

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?

Follow me on Twitter Reply With Quote
  #9 (permalink)
 jojojo 
FrankfurtGermany
 
Experience: Beginner
Platform: Tradestation
Posts: 41 since Oct 2010
Thanks Given: 4
Thanks Received: 7

Unfortunately "load global data" function is missing

Reply With Quote




Last Updated on November 14, 2023


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts