Why the currentbar reset again when I used the reserve word "date"? The issue only happen for once, is it a bug?  [SOLVED]

Questions about MultiCharts and user contributed studies.
~Zola~
Posts: 22
Joined: 28 Nov 2016
Has thanked: 5 times
Been thanked: 1 time

Why the currentbar reset again when I used the reserve word "date"? The issue only happen for once, is it a bug?

Postby ~Zola~ » 31 May 2019

Code: Select all

variables: tvAverage(0), vAverage(0), vBar(0), MeaningfulVolume(91), mDay(1);

for value1 = 1 to 3
begin
if currentbar = value1 then
begin
value2 = Ticks + value2;
print("Ticks: ", Ticks, ", Total volume: ", value2, ", Time: ", Time);
end;
end;

if currentbar > 20 then
begin
if month(date) <> month(date[1]) then
begin
//vmAverage[0] = 0;
tvAverage = 0;
mDay = 0;
end;
end;
Please find the output as below:
Ticks: 71.00, Total volume: 71.00, Time: 946.00
Ticks: 69.00, Total volume: 140.00, Time: 947.00
Ticks: 76.00, Total volume: 216.00, Time: 948.00
Ticks: 13.00, Total volume: 13.00, Time: 952.00
Ticks: 36.00, Total volume: 49.00, Time: 953.00
Ticks: 40.00, Total volume: 89.00, Time: 954.00

I only request to write the current bar from no.1 to no.3, but 6 output were found. I noted that after I used the statement "if month(date) <> month(date[1])", the current bar will be reset and started from the seventh bar. How can I resolved this problem?

Code: Select all

for value1 = 1 to 3
begin
if currentbar = value1 then
begin
value2 = Ticks + value2;
print("Ticks: ", Ticks, ", Total volume: ", value2, ", Time: ", Time);
end;
end;
Please find the output as below and this is what I expected:
Ticks: 71.00, Total volume: 71.00, Time: 946.00
Ticks: 69.00, Total volume: 140.00, Time: 947.00
Ticks: 76.00, Total volume: 216.00, Time: 948.00

~Zola~
Posts: 22
Joined: 28 Nov 2016
Has thanked: 5 times
Been thanked: 1 time

Re: Why the currentbar reset again when I used the reserve word "date"? The issue only happen for once, is it a bug?

Postby ~Zola~ » 02 Jun 2019

Inputs: pBars(2), VolumeRatio(1.26785563);
variables: tvAverage(0), vAverage(0), vBar(0), MeaningfulVolume(91), mDay(1);

for value1 = 1 to 3
begin
if currentbar = value1 then
begin
value2 = Ticks + value2;
print("Ticks: ", Ticks, ", Total volume: ", value2, ", Time: ", Time, ", currentbar: ", currentbar);
end;
end;

if currentbar > 20 then
begin
if month(date) <> month(date[1]) then
begin
//vmAverage[0] = 0;
tvAverage = 0;
mDay = 0;
end;
end;
I show the output more clear as below:
Ticks: 71.00, Total volume: 71.00, Time: 946.00, currentbar: 1.00
Ticks: 69.00, Total volume: 140.00, Time: 947.00, currentbar: 2.00
Ticks: 76.00, Total volume: 216.00, Time: 948.00, currentbar: 3.00
Ticks: 13.00, Total volume: 13.00, Time: 952.00, currentbar: 1.00
Ticks: 36.00, Total volume: 49.00, Time: 953.00, currentbar: 2.00
Ticks: 40.00, Total volume: 89.00, Time: 954.00, currentbar: 3.00

~Zola~
Posts: 22
Joined: 28 Nov 2016
Has thanked: 5 times
Been thanked: 1 time

Re: Why the currentbar reset again when I used the reserve word "date"? The issue only happen for once, is it a bug?

Postby ~Zola~ » 03 Jun 2019

I have investigated the issue again and confirmed the issue was caused by "date[1]".

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Why the currentbar reset again when I used the reserve word "date"? The issue only happen for once, is it a bug?  [SOLVED]

Postby TJ » 04 Jun 2019

MaxBarsBack caused the recalc.

~Zola~
Posts: 22
Joined: 28 Nov 2016
Has thanked: 5 times
Been thanked: 1 time

Re: Why the currentbar reset again when I used the reserve word "date"? The issue only happen for once, is it a bug?

Postby ~Zola~ » 04 Jun 2019

MaxBarsBack caused the recalc.
Thanks TJ. I have checked this part and set the parameter "1" to [Max number of bars] User Specified. The currentbar does not recalc, but counted second bar as "currentbar = 1" instead of first bar from the 1 min chart.

~Zola~
Posts: 22
Joined: 28 Nov 2016
Has thanked: 5 times
Been thanked: 1 time

Re: Why the currentbar reset again when I used the reserve word "date"? The issue only happen for once, is it a bug?

Postby ~Zola~ » 04 Jun 2019

MaxBarsBack caused the recalc.
I can use the volume[1] or high[1], etc to resolve this issue. Thank you for your reply again.


Return to “MultiCharts”