Error: Trying access at data to future. Bars reference value

Questions about MultiCharts and user contributed studies.
qpax
Posts: 3
Joined: 07 Apr 2008

Error: Trying access at data to future. Bars reference value

Postby qpax » 13 Apr 2008

Hi,

I try to reference to future data and get the error message: "Trying access at data to future. Bars reference value. -1". Actually it is good feature to avoid this kind of acces but is there a way to deactivate this feature.

Thanks

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 14 Apr 2008

Hi qpax,

Could you please send us the indicator? We need to have a look at it to help you.

Thank you.

qpax
Posts: 3
Joined: 07 Apr 2008

Postby qpax » 14 Apr 2008

Hi Marina,

enclosed is a variation of the Extremes Function. When I try to call the function in the indicator with a negativ Len (forward looking) I get the error message. My intention is to get the Highs and Lows x days in the future instead of the past.

Thanks



Function:

inputs:
PriceValue( numericseries ),
Len( numericsimple ),
HiLo( numericsimple ),
oExtremeVal( numericref ),
oExtremeBar( numericref ) ;

variable:
var0( 0 ),
var1( 0 ) ;

var0 = PriceValue ;
var1 = 0 ;

if Len < 0 then begin

for Value1 = Len+1 to 1 begin
condition1 = ( HiLo = 1 and var0[Value1] > var0 )
or ( HiLo = -1 and var0[Value1] < var0 ) ;
if condition1 then begin
var0 = var0[Value1] ;
var1 = Value1 ;
end ;
end ;
end
else begin

for Value1 = 1 to Len - 1 begin
condition1 = ( HiLo = 1 and PriceValue[Value1] > var0 )
or ( HiLo = -1 and PriceValue[Value1] < var0 ) ;
if condition1 then begin
var0 = PriceValue[Value1] ;
var1 = Value1 ;
end ;
end ;
end;

oExtremeVal = var0 ;
oExtremeBar = var1 + ExecOffset ;

Extremes_Forward = 1 ;

Indicator:

inputs: PriceValue( Close ), Len( 10 ),HiLo(1), Displace(0) ;
variables: var0( 0 ),var1( 0 ) ;

Value1 = Extremes_Forward( PriceValue,Len,1, var0, var1 ) ;

Plot3[Displace]( var0, "High" ) ;

qpax
Posts: 3
Joined: 07 Apr 2008

Postby qpax » 15 Apr 2008

Hi,
this is an even easier example. It doesn't work with negative Len Input.

Function test:

inputs:
PriceValue( numericseries ),
Len(NumericSimple);

test = PriceValue[Len];

Indicator:

Plot1( test(close,-1) ) ;

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 17 Apr 2008

Hi qpax,

I sent you an e-mail but I'm also posting the answer here.

We have created a sample code that you could use to create the type of the chart that you need. Please see the attachment. If it doesn't work for you please let me know.
Attachments
example.zip
(1.12 KiB) Downloaded 144 times

2haerim
Posts: 502
Joined: 01 Sep 2006
Been thanked: 2 times

qpax's original code works in TS2ki

Postby 2haerim » 17 Apr 2008

Function test:

inputs:
PriceValue( numericseries ),
Len(NumericSimple);

test = PriceValue[Len];

Indicator:

Plot1( test(close,-1) ) ;
qpax's original code works in TS2ki.

Can MC also make it work as it is?

User avatar
Marina Pashkova
Posts: 2758
Joined: 27 Jul 2007

Postby Marina Pashkova » 18 Apr 2008

HaeRim,

This code is not supposed to work. If you try to use it in TS 8 it won't work - just like it doesn't work in MultiCharts.


Return to “MultiCharts”