Max number of bars study will reference; annoying

Questions about MultiCharts and user contributed studies.
janus
Posts: 747
Joined: 25 May 2009
Has thanked: 41 times
Been thanked: 83 times

Max number of bars study will reference; annoying

Postby janus » 29 Aug 2009

I'm getting more annoyed with the "Max number of bars study will reference" feature. There must be a way to turn this off. If I wanted to look back say 20 bars I would do so only on bar 21 and beyond. That's how I always write my code. My studies often vary the number of bars they look back. As a consequence of this feature, the study re-runs a number of times, which in itself is annoying as I have code to read data from a file. So, it re-reads it a number of times, which is wasteful and time consuming. It's very hard to set the number of bars the study will reference manually as I don't know what it is. As I said the study can be dynamic so the number of bars it will reference is indeterminate. We must have an option to disable this feature. I realize it's useful for most people, but for me at least it's extremely annoying. PLEASE!

In the simple example above, I might only need to look back more than 20 if I'm on bar 5000. If on bar 5000 I decide to look back say 100., the study decides to re-run itself from scratch. Yet, it didn't have to since I never look back more than say 20 until after bar 21 and before bar 5000. It's so silly really.

OK, if I make a mistake and try to reference a bar too far back I should simply get an run time error, just like if I referenced an array out of bounds. Simple really. Making an application fool proof is a good idea. But here we are talking about a software development tool. A programmer such as myself should have as much control as possible, mistakes and all. In my books this feature is totally useless and causes no end of trouble. So, a simple option to disable it would be a good step forward.

bowlesj3
Posts: 2013
Joined: 21 Jul 2007
Has thanked: 169 times
Been thanked: 402 times

Postby bowlesj3 » 29 Aug 2009

I have a similar study (bunch of them). I have the max bars back set at 1000 and I have the symbol total bars to read from the database set at 100,000. I don't get this error any more. There is a register entry for increasing your max bars back maximum size.

janus
Posts: 747
Joined: 25 May 2009
Has thanked: 41 times
Been thanked: 83 times

Postby janus » 29 Aug 2009

Yes, but I don't want to skip past the first 1000 bars. I want to use all the data that's available. Imagine using daily data and you had to load up an extra 1000 days worth of data just to skip past it. It's silly.

bowlesj3
Posts: 2013
Joined: 21 Jul 2007
Has thanked: 169 times
Been thanked: 402 times

Postby bowlesj3 » 29 Aug 2009

yah, I guess it works for me because 1/ my system works really well (or at least as well as I need it to work for my goals) and I don't need to back test because of this plus 2/ I trade a much smaller wave level (about 1 level or 2 levels above scalping) so I don't use the daily bars all that much.

MC is setting aside memory so it can use those built in tables which have the square bracket offset. I don't think it can do anything else. So when you exceed that maxbarsback it has to allocate more memory for these tables then restart the study. I did tests and it does this a few times until it thinks it has it right. There is a thread on it. I think this is the one. The code is in there. It is in one of the next two.
http://forum.tssupport.com/viewtopic.ph ... axbarsback
http://forum.tssupport.com/viewtopic.ph ... axbarsback

this is kind of interesting too and somewhat related. It can sting you.
http://forum.tssupport.com/viewtopic.ph ... axbarsback

I think this problem mentioned in this thread may have been because of the resetting of the maxbarsback but I did not realize it at that time. So I decided I would put in code to check to see if MC did the reset of MaxBarsBack size so if My studies got screwed up as you describe I would be notified in my database program with a popup.
http://forum.tssupport.com/viewtopic.ph ... axbarsback

I am not sure what MC will do if you have the maxbarsback size hard coded and it gets exceeded. I never checked for this. I think it still does the reset actually.

janus
Posts: 747
Joined: 25 May 2009
Has thanked: 41 times
Been thanked: 83 times

Postby janus » 29 Aug 2009

Thanks for the links. I've studied them and find my own solution is still the best. I store price and volume data in dynamic arrays. Then I reference them using arrays rather than data series nomenclature. This means I can set the max bars to 1. The only downside is it increases memory consumption but so far it hasn't been a problem for me. I haven't converted all my studies to use arrays this way but I will as it solves the problem very well. It's unfortunate that I have to duplicate the data just to get around the max bars "feature". It does give me one advantage. It allows me to pre-filter the data. For example, I sometimes need to set the open equal to the previous close unless it's the start of a new session. Sometimes this does confuse me as the chart no longer reflects precisely what the study is using, but that's a small sacrifice compared to the major bonus of getting around the max bars feature. I could get around that as well by using plotpaintbar to plot the adjusted vales, but that introduces other issues, which I don't want to bring up here.

Is it really that hard for MC to change the code to give us the option to disable "max bars" or is it just a matter of too many other things for them to do to treat this seriously enough? Oh well, at least I have a workaround.

I just make one general comment. Any serious programmer would prefer to use a development tool that give them complete flexibility. I did consider writing my own ATS. In fact I have written a charting package in two different languages; FreeBasic and VB.Net. I decided not to add the extra code to interface with IB as I thought it would be just re-inventing the wheel too much (I hate databases :-). So, I decided to go with MC. I did look at other packages, some would be better for a developer like me. However, I chose MC because I think it has a better front-end for the user. It's multi-charting capabilities are superb. What would be really nice is if MC could be interfaced easily to any other language so all one uses MC for is the plotting. I've written my own dll's so I could see that approach may work. I could use Eclipse for the development environment to boot. I like MC very much and hope to stay with it. I'll probably look at other alternatives again to see if something better comes along. That's competition, which is good.

bowlesj3
Posts: 2013
Joined: 21 Jul 2007
Has thanked: 169 times
Been thanked: 402 times

Postby bowlesj3 » 30 Aug 2009

It is cool to see a real programmer (and a very advanced one) do what you have done. When I first started using TS this offset thing really took some getting use to since I did not even know it exsisted for a while. I was thinking I would have to do what you are doing and I did not like the offset thing much because it kept screwing up variables as I knew them to work.

janus
Posts: 747
Joined: 25 May 2009
Has thanked: 41 times
Been thanked: 83 times

Postby janus » 30 Aug 2009

I played around some more with dll's by using dynamic arrays in FreeBasic. I thought at first it would be slower but it turns out to be much faster to store my values in the dll dynamic arrays compared to using dynamic arrays in PL. I'm now tempted to write all my computations in dll's, and just use PL to plot and trade. I could then develop fancier windows front ends for the user to input and display data. Also, display pop-up alarms and notifications at will. On the other hand I might not. I want to focus on trading, not developing applications. Time will tell though.

User avatar
TJ
Posts: 6550
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 965 times
Been thanked: 1892 times

Postby TJ » 30 Aug 2009

wow... sounds like you guys are having fun.

I might look into PowerBasic... heard many people use it to write DLL for TS and MultiCharts.

I haven't used FreeBasic... I should give it a try.
Last edited by TJ on 30 Aug 2009, edited 1 time in total.

janus
Posts: 747
Joined: 25 May 2009
Has thanked: 41 times
Been thanked: 83 times

Postby janus » 30 Aug 2009

Yes, indeed I'm having fun. Now I can share all the data in one chart across all other studies running on other charts. Beats using global variables. I know others have done this (eg, pushpop). It's nice to have such freedom once again. I need to control myself and focus on trading :-(

bowlesj3
Posts: 2013
Joined: 21 Jul 2007
Has thanked: 169 times
Been thanked: 402 times

Postby bowlesj3 » 30 Aug 2009

I need to control myself and focus on trading


I know this feeling all too well! After I got MC, It took me over 2 years to complete my programming and my various programming projects (some of which I totally dumped as my strategy improved and I narrowed down my market criteria to only the really important stuff).

I am in an interesting situation in that I was a fairly good programmer who learned trading without a program like MC to play with (I had qcharts when I learned and all it does is chart). I started in a trading house. My trading approach was basically complete before I got MC and that was done without any backtesting at all and the only stuff that is new with MC is the 10 second bars which were not available on Qcharts. So all I have done since I got MC is refine my methods and organize them better so I can keep up with the market (all that done without any backtesting at all). I am really glad I did not have MC for about 7 years because the mind is very good at pattern recognition and you don't really need to do backtesting to find a good strategy (the really good ones will stand out like a sore thumb and there is no need to get all fussed about numbers to know you have a good approach). Don't get me wrong. I love MC. Without it there is no chance for making a living using my strategy since MC does so much work for me making it manageable now. That is why I made the switch. I had to. With QC I knew I had found the approach I had been looking for all these years and I knew I needed TS or MC to do it. Only now have I finally nailed that strategy and refined it such that I don't need to do any more programming at all. Programming projects can take a lot longer than we think they will. But it was worth it. You rarely see me on this forum now (normally only on weekends and never during the trading day) and that is because I am 100% focused on trading now FINALLY!

Patience and persistence is needed.

janus
Posts: 747
Joined: 25 May 2009
Has thanked: 41 times
Been thanked: 83 times

Postby janus » 30 Aug 2009

Thanks for you very helpful and insightful comments. For the similar reasons you mentioned I decided to use MC rather than continue developing my own ATS. I had many stressful days trying to make a decision - should I or shouldn't ?. I know I could have written one with all the features I need that are lacking from MC (eg, drawing indicators vertically and with gaps - in fact I already did with my plotting programs). It even had a playback feature, which I found pivotal in my strategy development. However, it would take me probably 6 months to develop a complete ATS with all the other necessary components such as a data collector and manager, and I was more interested in trading anyway. Hence MC.

janus
Posts: 747
Joined: 25 May 2009
Has thanked: 41 times
Been thanked: 83 times

Re: Max number of bars study will reference; annoying

Postby janus » 05 Sep 2009

OK, if nothing is going to be done about this, is there a way I can detect when a study is repeated? If not, I'll have to resort to using a global variable or a dll to keep track of things.

bowlesj3
Posts: 2013
Joined: 21 Jul 2007
Has thanked: 169 times
Been thanked: 402 times

Postby bowlesj3 » 06 Sep 2009

I agree.

That was my request in one of the posts above. To have an error message when a study's maxbarsback is exceeded so I don't go off thinking my study is working when it is not and don't go off on a long winded debugging session once I finally come to realize that the study is not working (hopefully not with losses too boot). It took way longer than it should have to figure out that MC was adjusting the maxbarsback and restarting the studies on me without any notification at all. MC should tell the user for sure.

Actually if it was a simple popup warning it would be handy if the user had an option to go back and review them for the day (current session) since they may miss them.


Return to “MultiCharts”