ADE and receiving data from Range Bars

Questions about MultiCharts and user contributed studies.
SP
Posts: 444
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 280 times

ADE and receiving data from Range Bars

Postby SP » 28 Sep 2010

I use some ADE indicators that send data from lower timeframes to another chart. It works fine with tick/volumecharts.
Is there a way to send ADE data from a range chart to another range or tick chart
or is the only solution using Global Variables ?

User avatar
Anastassia
Posts: 179
Joined: 18 Jan 2010
Been thanked: 4 times

Re: ADE and receiving data from Range Bars

Postby Anastassia » 29 Sep 2010

Hi SP,

If you use "ADE.BarInterval" function in your scripts, then:

Code: Select all

[LegacyColorValue = TRUE];

// For intraday charts, this function returns the normal BarInterval.
// Otherwise, it returns 0 for daily, -1 for weekly, and -2 for monthly.

if BarType = 1 then
   ADE.BarInterval = BarInterval
else if BarType >= 2 and BarType <= 4 then
   ADE.BarInterval = 2 - BarType
else if BarType = 0 then begin
   ADE.BarInterval = 0;
   Value1 = ADE.RaiseError("ADE.BarInterval can't be used on tick/volume charts. " +
      "Use ADE.TypeZeroInterval instead.");
end
else begin
   ADE.BarInterval = 0;
   Value1 = ADE.RaiseError("ADE cannot store data for this chart type.");
end;


The function is meant for the following BarType values:
1 – Intra-Day (Seconds, Minutes, & Hours)
2 – Days
3 – Weeks
4 – Months, Quarters, & Years
If you change 4 to 5 in the "else if BarType >= 2 and BarType <= 4 then" line, then function will also get calculated for Points (point resolution=range resolution)

Thank you
These users thanked the author Anastassia for the post:
Rick Webber

Rick Webber
Posts: 47
Joined: 04 Jan 2008
Has thanked: 21 times
Been thanked: 3 times

Re: ADE and receiving data from Range Bars

Postby Rick Webber » 20 Apr 2013

When I follow your instructions I get an ADE error: "Unsupported ADE interval code: 3". Any solutions to this? Thanks.

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: ADE and receiving data from Range Bars

Postby TJ » 20 Apr 2013

Rick Webber wrote:When I follow your instructions I get an ADE error: "Unsupported ADE interval code: 3". Any solutions to this? Thanks.

Have you installed the TypeZero Library?

You can get it here:
http://www.tradersxchange.com/viewtopic.php?f=49&t=4
These users thanked the author TJ for the post:
Rick Webber

Rick Webber
Posts: 47
Joined: 04 Jan 2008
Has thanked: 21 times
Been thanked: 3 times

Re: ADE and receiving data from Range Bars

Postby Rick Webber » 21 Apr 2013

Thanks for reply TJ. TypeZero library was installed. I also created a VirtBarTypes.cfg file named "201,Point" to let ADE know of this bar to use for Interval function as per Virtual Bar Type instructions and got this error: " Interval not supported: -201".

User avatar
Dave Masalov
Posts: 1712
Joined: 16 Apr 2010
Has thanked: 51 times
Been thanked: 485 times

Re: ADE and receiving data from Range Bars

Postby Dave Masalov » 25 Apr 2013

Rick Webber wrote:Thanks for reply TJ. TypeZero library was installed. I also created a VirtBarTypes.cfg file named "201,Point" to let ADE know of this bar to use for Interval function as per Virtual Bar Type instructions and got this error: " Interval not supported: -201".


Hello Rick,

The post above by Anastassia provides the right direction, but scripts should be manually adjusted.

It is easier to create custom functions to read and write to avoid using functions like ADE.BarInterval that have certain resolution limitations. Here is the read function:

Code: Select all

inputs:
   Sym(stringsimple),
   Interval(numericsimple),
   BarID(numericsimple),
   DataName(stringsimple),
   vLoadData(numericref);

vars:
   _last_sym(""),
   _last_interval(-1),
   _index(0),

   _data_map(0),
   _bar_list(0),
   _data_name_list(0);


if Sym <> _last_sym or Interval <> _last_interval then begin
   _last_sym = Sym;
   _last_interval = Interval;

   _data_map = ADE.GetRequiredMap("GData" + DataName, Sym, Interval);
   _bar_list = MapSC.Get(_data_map, ":Bar");

   _data_name_list = MapSC.Get(_data_map, DataName);
end;

if ListN.IsSorted(_bar_list) = false then
   Value1 = ADE.SortDataMap(_data_map);

if ListN.Lookup(_bar_list, BarID, _index) = false then
   _index = _index - 1;

if _index <> 0 then
   vLoadData = ListN.Get(_data_name_list, _index);

load_global_data = _index;


I.e. if we write on a ESH3 - 5 point chart:

Code: Select all

variables: var0(0);
var0 = close + open / 2;
save_global_data(symbolname, barinterval, date+time_s/1000000, "MyVar", var0);


Then it can be read the following way:

Code: Select all

variables: var0(0);
load_global_data("ESM3", 5, date+time_s/1000000, "MyVar", var0);


Similar functions can be created to save/get string values.

Rick Webber
Posts: 47
Joined: 04 Jan 2008
Has thanked: 21 times
Been thanked: 3 times

Re: ADE and receiving data from Range Bars

Postby Rick Webber » 12 May 2013

Thanks for the detailed instructions Dave. I have yet to dig into this but seems to be the solution to a problem I've had for a long time. Should be helpful to many.


Return to “MultiCharts”