number of bars on a chart. (now a new question)

Questions about MultiCharts and user contributed studies.
bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

number of bars on a chart. (now a new question)

Postby bowlesj3 » 10 Feb 2010

Is there a command that can give me the number of bars on a chart?
Last edited by bowlesj3 on 11 Feb 2010, edited 1 time in total.

User avatar
Bruce DeVault
Posts: 438
Joined: 19 Jan 2010
Location: Washington DC
Been thanked: 2 times
Contact:

Re: number of bars on a chart.

Postby Bruce DeVault » 11 Feb 2010

Is there a command that can give me the number of bars on a chart?
The number of bars on the chart so far (for a single data series) would be a function of MaxBarsBack and BarNumber. By adding those two together, you should be able to determine how many bars there have been.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Postby bowlesj3 » 11 Feb 2010

Thanks Bruce,

I tried these commands last night but something was not working. Maybe after working from 4:30 am to 10pm I was just too tired. BarNumber and CurrentBar were giving me 372 when I had over 10000 bars on the chart. I was compiling a lot without bringing MC down. Sometimes that can screw things up if you do it too often. MC needs a reset at times with a complete restart. Code below gives a quick visual.

Now the question is. Can I change the MaxBarsBack setting and do a recalculate with that new setting after grabbing this number to see just how large I can make the MaxBarsBack.

John.

Code: Select all


{
Put bar numbers on the chart - both BarNumber and CurrentBar
}
inputs:
Spacing(1) {Distance the text appears above the bar or below the bar}
;

variables:
TextID(0),
IntraBarPersist Cnt2(0),
IntraBarPersist Cnt(0);

If BarStatus = 2 then
begin
Cnt = Cnt + 1;
Cnt2 = Cnt2 + 1;
if cnt2 = 1 then
begin
cnt = 0;
TextID = Text_New(date,time,High + Spacing,NumToStr(BarNumber + MaxBarsBack,0));
TextID = Text_New(date,time,Low - Spacing,NumToStr(CurrentBar + MaxBarsBack,0));
end;
if Cnt = 100 then
begin
cnt = 0;
TextID = Text_New(date,time,High + Spacing,NumToStr(BarNumber + MaxBarsBack,0));
TextID = Text_New(date,time,Low - Spacing,NumToStr(CurrentBar + MaxBarsBack,0));
end;
end;

If LastBarOnChart then
begin
TextID = Text_New(date,time,High + Spacing,NumToStr(BarNumber + MaxBarsBack,0));
TextID = Text_New(date,time,Low - Spacing,NumToStr(CurrentBar + MaxBarsBack,0));
end

User avatar
Bruce DeVault
Posts: 438
Joined: 19 Jan 2010
Location: Washington DC
Been thanked: 2 times
Contact:

Postby Bruce DeVault » 11 Feb 2010

Rather than trying to debug something complex where you could have made any number of mistakes, try simply making an indicator that has one line "plot1(maxbarsback + currentbar - 1, "barnumber");" and apply this one line indicator separately from what you have done. Once you see how that works, you can track down your mistake and correct the other code.

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Postby bowlesj3 » 11 Feb 2010

Actually there was no mistake in the code above. I just whipped that together just now. Last night I simply did a print of these too commands after lastbaronchart was hit. Like I said, based upon the fact that today they are giving more appropriate numbers I figure MC needed a restart and I guess after that long day I was more interested in going to bed than continuing with it to figure out why I was getting 382 or whatever it was.
Last edited by bowlesj3 on 11 Feb 2010, edited 1 time in total.

User avatar
Bruce DeVault
Posts: 438
Joined: 19 Jan 2010
Location: Washington DC
Been thanked: 2 times
Contact:

Postby Bruce DeVault » 11 Feb 2010

If you run out of memory, any 32 bit application can become unstable. Check to make sure that the sum of all loaded 32 bit applications does not approach 2GB (if you are running a 32 bit OS) or that no one application approaches 2GB (if you are running a 64 bit OS).

bowlesj3
Posts: 2180
Joined: 21 Jul 2007
Has thanked: 227 times
Been thanked: 429 times

Postby bowlesj3 » 11 Feb 2010

Actually your right Bruce. I have been getting a fair number of memory errors with MC 6.0 beta2. Thanks.

Still curious about setting MaxBarsBack however. Nop! The compiler does not like the command MaxBarsBack = 10;
Last edited by bowlesj3 on 11 Feb 2010, edited 1 time in total.

SUPER
Posts: 646
Joined: 03 Mar 2007
Has thanked: 106 times
Been thanked: 84 times

Postby SUPER » 11 Feb 2010

If you run out of memory, any 32 bit application can become unstable. Check to make sure that the sum of all loaded 32 bit applications does not approach 2GB (if you are running a 32 bit OS) or that no one application approaches 2GB (if you are running a 64 bit OS).
Bruce,

Many thanks for your guidance on memory usage. I need some clarification please, my resource monitor shows in use 2266 MB and I have 4096 MB installed memory on a windows-7 32 bit applicaton would you call that overloading.

Thanks & regards
Super

User avatar
Bruce DeVault
Posts: 438
Joined: 19 Jan 2010
Location: Washington DC
Been thanked: 2 times
Contact:

Postby Bruce DeVault » 11 Feb 2010

"In use" is a complex statistic that takes in several things, including disk caching, the operating system, etc. It's not at all uncommon to see that number at about 50% of physical RAM in part because Windows does some complicated things to try to balance this. What I would suggest is on Resource Monitor to look at the column "Working Set". Does that number approach 2GB for any application? (Or, if on 32 bit Windows, for any combination of applications?) That's the question I would suggest to start with.

SUPER
Posts: 646
Joined: 03 Mar 2007
Has thanked: 106 times
Been thanked: 84 times

Postby SUPER » 11 Feb 2010

Bruce,

Many thanks for your precise explanation.

Regards
Super


Return to “MultiCharts”