Old TS Script  [SOLVED]

Questions about MultiCharts and user contributed studies.
derek.wai
Posts: 2
Joined: 28 Aug 2017

Old TS Script

Postby derek.wai » 28 Aug 2017

I used to use this old script on TS, but i have recently started using Multicharts and would like to migrate that here.

But i keep getting this error message:

Message: Error in study xxxxx:
Trying to access future data. Bar reference value : -2

I'm personally not great at coding and has been trying to learn. If anyone can help or point me in the right direction, that'll be great! Thanks!

Code: Select all

Inputs: Length1 (13), Offset1(8),
Length2 (8), Offset2 (5),
Length3 (5), Offset3 (3);

if Length1 > 0 then begin
if @CurrentBar = 1 then
begin
Value1 = @Average(((HIGH+LOW) / 2), Length1);
Value2 = @Average(((HIGH+LOW) / 2), Length2);
Value3 = @Average(((HIGH+LOW) / 2), Length3);
end
else
begin
Value1 = ((Value1 * (Length1-1) )+( (HIGH+LOW) / 2)) / Length1;
Value2 = ((Value2 * (Length2-1) )+( (HIGH+LOW) / 2)) / Length2;
Value3 = ((Value3 * (Length3-1) )+( (HIGH+LOW) / 2)) / Length3;
end;
end;

if (Value1[Offset1] > 0 and Value2[Offset2] > 0 and Value3[offset3] >0) then
begin
Plot1 (Value1[Offset1], "Blue 13/8");
Plot1[-1] (Value1[Offset1-1], "Blue 13/8");
Plot1[-2] (Value1[Offset1-2], "Blue 13/8");
Plot1[-3] (Value1[Offset1-3], "Blue 13/8");
Plot1[-4] (Value1[Offset1-4], "Blue 13/8");
Plot1[-5] (Value1[Offset1-5], "Blue 13/8");
Plot1[-6] (Value1[Offset1-6], "Blue 13/8");
Plot1[-7] (Value1[Offset1-7], "Blue 13/8");
Plot1[-8] (Value1[Offset1-8], "Blue 13/8");

Plot2 (Value2[Offset2], "Red 8/5");
Plot2[-1] (Value2[Offset2-1], "Red 8/5");
Plot2[-2] (Value2[Offset2-2], "Red 8/5");
Plot2[-3] (Value2[Offset2-3], "Red 8/5");
Plot2[-4] (Value2[Offset2-4], "Red 8/5");
Plot2[-5] (Value2[Offset2-5], "Red 8/5");

Plot3 (Value3[Offset3], "Green 5/3");
Plot3[-1] (Value3[Offset3-1], "Green 5/3");
Plot3[-2] (Value3[Offset3-2], "Green 5/3");
Plot3[-3] (Value3[Offset3-3], "Green 5/3");
end;

User avatar
rrams
Posts: 128
Joined: 10 Feb 2011
Location: USA
Has thanked: 7 times
Been thanked: 70 times
Contact:

Re: Old TS Script

Postby rrams » 29 Aug 2017

Because you are using a negative offset in the plot function, it is trying to move the plot forward to future bars.
Which is okay, but you have to make sure the chart has free space to the right.
No code change is needed just choose Format Window, X - Time Scale on the chart and set Chart Shift to at least 8 bars.
(Then add comments in the code explaining this. :) )

derek.wai
Posts: 2
Joined: 28 Aug 2017

Re: Old TS Script  [SOLVED]

Postby derek.wai » 29 Aug 2017

Ah, that's right, totally missed that. Thanks for the help!


Return to “MultiCharts”