Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to write my own indicators to use with functions like TradingChart. From the context, it's clear that one needs to write a function whose parameters provide access to the underlying list of "OHLC" bars. Also, I don't know whether these indicator funtions are called after every bar is seen or just once. If the latter, then the list is sufficient but if the former, then there has to be another parameter that lets you know where you are.

share|improve this question
Did you see this example? Looks like all the data for a single element is passed in one call per element. Easy. – Sjoerd C. de Vries Oct 21 '13 at 19:29
I assume you're talking about the ChartElementFunction. I don't quite see how that helps. For example, suppose one wants to look at the last 50 values (relative to the current value) to perform an operation. How do you know where you are and how do you get at the previous values? – David Jameson Oct 25 '13 at 15:47
I'm afraid I fail to understand your problem. The function you pass gets all the information you need automatically passed through its arguments. You use these to draw an indicator in the place where it needs to be and the chart function places it there and proceeds to call your custom function for the next indicator. No need to "know where you are". – Sjoerd C. de Vries Oct 25 '13 at 17:28
I appreciate your patience. Can you give me an example of the signature of such a function so that I can see exactly how I would reference all the existing data. It is not clear to me what constitutes a single element? For example, if I have 365 days worth of data (one per day) to handle, do I get a single callback with the entire 365 days of data or do I get a callback for each day of data? If the former, then what do you do if you want to update your charts (or indicators) in real time as data arrives from an external source? – David Jameson Oct 28 '13 at 3:15
Your function gets called for each indicator separately. If new data arrives you redraw the entire plot with a new call to the plotting function with the new data. – Sjoerd C. de Vries Oct 28 '13 at 6:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.