Example:
Code: Select all
if LastBarOnChart then
begin
FileDelete(filepath);
FileAppend( filepath , NumToStr(currentbar,0) + "," + NumToStr(Date,0) + "," + NumToStr(time_s,0) );
end;
Code: Select all
if LastBarOnChart then
begin
FileDelete(filepath);
FileAppend( filepath , NumToStr(currentbar,0) + "," + NumToStr(Date,0) + "," + NumToStr(time_s,0) );
end;
What is your MultiCharts version?Currentbar on my custom chalkin osc indicator doesn't match currentbar on series. Why don't these numbers match?
Example:So, when I check the currentbar from the file then it is about 20 bars behind the series bar when I mouse over it on the chart. Why are these values different and how do I get the currentbar from the series when coding an indicator.Code: Select all
if LastBarOnChart then
begin
FileDelete(filepath);
FileAppend( filepath , NumToStr(currentbar,0) + "," + NumToStr(Date,0) + "," + NumToStr(time_s,0) );
end;
did you reload the chart or re-apply an indicator (any indicator)?When you move your mouse over a bar on a chart you will see information about that bar. The barnumber is one of those pieces of information. It should match what was output to the file in my code example. The barnumber in the file is about 20 bars behind the chart, but I expect them to be equal.
I am not sure if I understand what you are looking for.Yeah, the plot on the indicator starts 21 bars after the data series. Is there a way to tell the indicator to get the current bar of a specific series or indicator?
The CurrentBar PowerLanguage reserved word used in an indicator or signal starts counting after the MaxBarsBack amount of bars have passed. In other words, if you have the MaxBarsBack set to 20, the indicator starts calculating on chart bar number 21, but this will be the first bar for the indicator (so CurrentBar = 1).When you move your mouse over a bar on a chart you will see information about that bar. The barnumber is one of those pieces of information. It should match what was output to the file in my code example. The barnumber in the file is about 20 bars behind the chart, but I expect them to be equal.
Code: Select all
Bar number of chart = MaxBarsBack + CurrentBar - 1
Version 7.4 has this problem, too. This makes the code and the chart not to match each other and makes debugging much harder. I hope this can be taken as a bug.If I recall correctly:Code: Select all
Bar number of chart = MaxBarsBack + CurrentBar - 1
That is not a bug, that is expected behavior. Please see JoshM above post for explanation.Version 7.4 has this problem, too. This makes the code and the chart not to match each other and makes debugging much harder. I hope this can be taken as a bug.
Well, this might be an expected behavior with the description, but it is certainly not intuitive and not user friendly. Why can't MaxBarsBack be figured in currentbar in the code so that currentbar indicates the REAL currentbar on the chart where the mouse is, thereafter a lot of user confusions can be reduced and all the unnecessary explanations can be saved?That is not a bug, that is expected behavior. Please see JoshM above post for explanation.
These is a Symbol_CurrentBar reserved word for that.Why can't MaxBarsBack be figured in currentbar in the code so that currentbar indicates the REAL currentbar on the chart where the mouse is