BarNumber[X] CurrentBar[X] questions. An Observation too.

Questions about MultiCharts and user contributed studies.
bowlesj3
Posts: 2088
Joined: 21 Jul 2007
Has thanked: 197 times
Been thanked: 416 times

BarNumber[X] CurrentBar[X] questions. An Observation too.

Postby bowlesj3 » 19 Jan 2009

I have two questions. They are related to the test results shown below and the code to create these test results is shown first. There is also an interesting observation found during the test.

Q1/ Why does BarNumber and CurrentBar not make use of the [X] offset? It compiles with them but does not use them. You can see this in the test results. Note that Time[X] does work.
Q2/ Why was the function “BarNumber” written when there is a reserve word called “CurrentBar” that does the same thing?

Notes:
1/ that the MaxBarsBack Setting is shown in each test run at the start.
2/ The first bar I can see on the chart has a time “0200”.

Observation.
I changed the maxbarsback value in three of the 4 tests. The first is automatic and it becomes 6 which matches the number of loops in the for loop. In the 3rd one I set the maxbarsback to 10 and the report matches. However in the 2nd one I set the maxbarsback to value 2 and it shows in the report as 8 (which may be as a result of a 6 + 2 calculation). Thinking this, I did a test #4 with a manual maxbarsback setting of 3 and it shows in the report as 9 (which is 6 + 3 of course). So it appears that if the user sets maxbarsback too a value below the automatic value MC adds this value to the automatic value.

Code: Select all


variables:
   X(0);

if currentbar = 1 then
   Begin
   Print( File("C:\Access\ALog_Test_BarNumber_CurrentBar.txt"),
                          " StartOfTest", " " ,
                          " MaxBarsBack=", " " ,
                         MaxBarsBack, " " ,
                          " Time=", " " ,
                         Time, " " ,
                     " ");
   end;

Print( File("C:\Access\ALog_Test_BarNumber_CurrentBar.txt"),
                       " Processing New Bar", " " ,

                       " BarNumber=", " " ,
                      BarNumber, " " ,

                       " CurrentBar=", " " ,
                      CurrentBar, " " ,
   
                       " Time=", " " ,
                      Time, " " ,
                      
                  " ");

for X = 0 to 5
   begin
   Print( File("C:\Access\ALog_Test_BarNumber_CurrentBar.txt"),
                          " X=", " " ,
                         X, " " ,

                          " BarNumber[X]=", " " ,
                         BarNumber[X], " " ,

                          " CurrentBar[X]=", " " ,
                         CurrentBar[X], " " ,
   
                          " Time[X]=", " " ,
                         Time[X], " " ,
                         
                     " ");


   end;




Test1:
In this case MaxBarsBack is set to automatic.

StartOfTest MaxBarsBack= 6.00 Time= 206.00
Processing New Bar BarNumber= 1.00 CurrentBar= 1.00 Time= 206.00
X= 0.00 BarNumber[X]= 1.00 CurrentBar[X]= 1.00 Time[X]= 206.00
X= 1.00 BarNumber[X]= 1.00 CurrentBar[X]= 1.00 Time[X]= 205.00
X= 2.00 BarNumber[X]= 1.00 CurrentBar[X]= 1.00 Time[X]= 204.00
X= 3.00 BarNumber[X]= 1.00 CurrentBar[X]= 1.00 Time[X]= 203.00
X= 4.00 BarNumber[X]= 1.00 CurrentBar[X]= 1.00 Time[X]= 202.00
X= 5.00 BarNumber[X]= 1.00 CurrentBar[X]= 1.00 Time[X]= 201.00
Processing New Bar BarNumber= 2.00 CurrentBar= 2.00 Time= 207.00
X= 0.00 BarNumber[X]= 2.00 CurrentBar[X]= 2.00 Time[X]= 207.00
X= 1.00 BarNumber[X]= 2.00 CurrentBar[X]= 2.00 Time[X]= 206.00
X= 2.00 BarNumber[X]= 2.00 CurrentBar[X]= 2.00 Time[X]= 205.00
X= 3.00 BarNumber[X]= 2.00 CurrentBar[X]= 2.00 Time[X]= 204.00
X= 4.00 BarNumber[X]= 2.00 CurrentBar[X]= 2.00 Time[X]= 203.00
X= 5.00 BarNumber[X]= 2.00 CurrentBar[X]= 2.00 Time[X]= 202.00






Test2:
This is interesting. I set the maxbarsback to a value 2 yet the report shows 8. Why????

StartOfTest MaxBarsBack= 8.00 Time= 208.00
Processing New Bar BarNumber= 1.00 CurrentBar= 1.00 Time= 208.00
X= 0.00 BarNumber[X]= 1.00 CurrentBar[X]= 1.00 Time[X]= 208.00
X= 1.00 BarNumber[X]= 1.00 CurrentBar[X]= 1.00 Time[X]= 207.00
X= 2.00 BarNumber[X]= 1.00 CurrentBar[X]= 1.00 Time[X]= 206.00
X= 3.00 BarNumber[X]= 1.00 CurrentBar[X]= 1.00 Time[X]= 205.00
X= 4.00 BarNumber[X]= 1.00 CurrentBar[X]= 1.00 Time[X]= 204.00
X= 5.00 BarNumber[X]= 1.00 CurrentBar[X]= 1.00 Time[X]= 203.00
Processing New Bar BarNumber= 2.00 CurrentBar= 2.00 Time= 209.00
X= 0.00 BarNumber[X]= 2.00 CurrentBar[X]= 2.00 Time[X]= 209.00
X= 1.00 BarNumber[X]= 2.00 CurrentBar[X]= 2.00 Time[X]= 208.00
X= 2.00 BarNumber[X]= 2.00 CurrentBar[X]= 2.00 Time[X]= 207.00
X= 3.00 BarNumber[X]= 2.00 CurrentBar[X]= 2.00 Time[X]= 206.00
X= 4.00 BarNumber[X]= 2.00 CurrentBar[X]= 2.00 Time[X]= 205.00
X= 5.00 BarNumber[X]= 2.00 CurrentBar[X]= 2.00 Time[X]= 204.00




Test#3:
In this case I set the Maxbarsback to 10 and it appears correct in the report.

StartOfTest MaxBarsBack= 10.00 Time= 210.00
Processing New Bar BarNumber= 1.00 CurrentBar= 1.00 Time= 210.00
X= 0.00 BarNumber[X]= 1.00 CurrentBar[X]= 1.00 Time[X]= 210.00
X= 1.00 BarNumber[X]= 1.00 CurrentBar[X]= 1.00 Time[X]= 209.00
X= 2.00 BarNumber[X]= 1.00 CurrentBar[X]= 1.00 Time[X]= 208.00
X= 3.00 BarNumber[X]= 1.00 CurrentBar[X]= 1.00 Time[X]= 207.00
X= 4.00 BarNumber[X]= 1.00 CurrentBar[X]= 1.00 Time[X]= 206.00
X= 5.00 BarNumber[X]= 1.00 CurrentBar[X]= 1.00 Time[X]= 205.00
Processing New Bar BarNumber= 2.00 CurrentBar= 2.00 Time= 211.00
X= 0.00 BarNumber[X]= 2.00 CurrentBar[X]= 2.00 Time[X]= 211.00
X= 1.00 BarNumber[X]= 2.00 CurrentBar[X]= 2.00 Time[X]= 210.00
X= 2.00 BarNumber[X]= 2.00 CurrentBar[X]= 2.00 Time[X]= 209.00
X= 3.00 BarNumber[X]= 2.00 CurrentBar[X]= 2.00 Time[X]= 208.00
X= 4.00 BarNumber[X]= 2.00 CurrentBar[X]= 2.00 Time[X]= 207.00
X= 5.00 BarNumber[X]= 2.00 CurrentBar[X]= 2.00 Time[X]= 206.00




Test#4:
In this case I set the Maxbarsback to 3 and it appears in the report as 9 (which is 6 + 3 of course).

StartOfTest MaxBarsBack= 9.00 Time= 209.00
Processing New Bar BarNumber= 1.00 CurrentBar= 1.00 Time= 209.00
X= 0.00 BarNumber[X]= 1.00 CurrentBar[X]= 1.00 Time[X]= 209.00
X= 1.00 BarNumber[X]= 1.00 CurrentBar[X]= 1.00 Time[X]= 208.00
X= 2.00 BarNumber[X]= 1.00 CurrentBar[X]= 1.00 Time[X]= 207.00
X= 3.00 BarNumber[X]= 1.00 CurrentBar[X]= 1.00 Time[X]= 206.00
X= 4.00 BarNumber[X]= 1.00 CurrentBar[X]= 1.00 Time[X]= 205.00
X= 5.00 BarNumber[X]= 1.00 CurrentBar[X]= 1.00 Time[X]= 204.00
Processing New Bar BarNumber= 2.00 CurrentBar= 2.00 Time= 210.00
X= 0.00 BarNumber[X]= 2.00 CurrentBar[X]= 2.00 Time[X]= 210.00
X= 1.00 BarNumber[X]= 2.00 CurrentBar[X]= 2.00 Time[X]= 209.00
X= 2.00 BarNumber[X]= 2.00 CurrentBar[X]= 2.00 Time[X]= 208.00
X= 3.00 BarNumber[X]= 2.00 CurrentBar[X]= 2.00 Time[X]= 207.00
X= 4.00 BarNumber[X]= 2.00 CurrentBar[X]= 2.00 Time[X]= 206.00
X= 5.00 BarNumber[X]= 2.00 CurrentBar[X]= 2.00 Time[X]= 205.00

Return to “MultiCharts”