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
Error: Trying access at data to future. Bars reference value
- Marina Pashkova
- Posts: 2758
- Joined: 27 Jul 2007
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" ) ;
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" ) ;
- Marina Pashkova
- Posts: 2758
- Joined: 27 Jul 2007
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.
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 149 times
qpax's original code works in TS2ki
qpax's original code works in TS2ki.Function test:
inputs:
PriceValue( numericseries ),
Len(NumericSimple);
test = PriceValue[Len];
Indicator:
Plot1( test(close,-1) ) ;
Can MC also make it work as it is?
- Marina Pashkova
- Posts: 2758
- Joined: 27 Jul 2007