I just started trying to learn how to program yesterday, but I'm having a really difficult go at it.
I was attempting to divide the volume output by seconds per bar for use with Tick, Range and Renko type charts, but I really have no idea what I'm doing. I've been working on it and watching videos and reading the help menu for hours and hours, but I'm getting pretty stuck now. I have looked at other indicators and taken a few ideas from a few, but it's just not working. Would anyone be willing to help me out with this? I would really appreciate it. My retarded code is attached. I'm sure it's laughable, at best.
You have not declared the variable totalseconds, which would be of type double. Also there is a useless DataSeries volpersec, which has not been initialized and not be used so far. Just delete it.
Further your indicator will not display correctly for the first bar of each session and the first bar after a technical break, because your way of calculating the bar duration includes the session breaks and technical breaks.
Otherwise your indicator should work as expected.
The following 2 users say Thank You to Fat Tails for this post:
I added "private double totalseconds; under variables. Did I at least get that right? Probably not. Please forgive my ignorance.
Re: "your indicator will not display correctly for the first bar of each session..." I deleted the "If current bar < 1 return..." lines under OnBarUpdate. Was that what I should have done to address this problem? I suppose it's obvious I have no idea what I'm doing here, and that's fine. I just have to keep working at it and asking for help if I'm going to learn how to do this.
Also, under properties, is that all I need in that section?
Thank you so very much for your help; I really appreciate it
Just a couple of questions left now: Bertrand used int instead of double. What are your thoughts on that? And how do I make it display correctly for the first bar of each session and for the first bar after a technical break? I don't really understand what I could possibly do here.
timer.TotalSeconds returns a double value. There is no need to convert it to int, because you will use it as divisor for Volume, which itself contains a double value.
first bar of session:
Check for Bars.FirstBarOfSession with every bar. In case that you have a first bar of the session, you do not calculate timer = Time - Time, but timer = Time - sessionBegin. You can find out the sessionBegin via Bars.Session.GetNextBeginEnd(Bars, 0, out sessionBegin, out sessionEnd), where sessionBegin and sessionEnd are DateTime objects.
The following 3 users say Thank You to Fat Tails for this post: