Super User is a question and answer site for computer enthusiasts and power users. 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

In my trading software I write myself logs like this:

634782126998342815 q 0.0156327559515302
634782126998966816 q 0.0156323845819952
634782126999122816 q 0.0156323423136646
634782126999278816 q 0.0156323634478013
634782126999434817 q 0.0156321895228581
634782126999434817 q 0.015632316326057
634782126999434817 q 0.0156320680833289
634782126999434817 q 0.0156319412841572
634782126999434817 q 0.0156320680833289
634782126999434817 q 0.0156321541605791
634782126999902817 b 0.0156321229489328
634782126999902817 q 0.0156319988296541
634782126999902817 q 0.0156318739862979
634782126999902817 q 0.0156319488920723
  • First column is time (it's so big because this is number of ticks elapsed from 1970 where one tick = 100 nanoseconds, just don't worry about that)
  • Second column is operation. Either q for quote b for buy and s for sell.
  • Third column is price.

Lines with the same time should form a vertical candle. Also I need to add annotations on the graph to show where I buy and sell stocks.

Without annotations I think this task is trivial for Matlab, but can I add annotations in Matlab? i.e. I want to have something like this:

(Click image to enlarge)

When I buy stock I want to display a green arrow and when I sell stock I want to display a red arrow. It's OK to use other symbols until they are clear and distinguishable.

share|improve this question
up vote 0 down vote accepted

It is possible to do so. The following code creates a circle (o) at data position 5. Additionally it adds a tooltip. (source: )

% First plot the data
hLine = plot(xdata, ydata);

% First get the figure's data-cursor mode, activate it, and set some of its properties
cursorMode = datacursormode(gcf);
set(cursorMode, 'enable','on');

% Note: the following code was adapted from %matlabroot%\toolbox\matlab\graphics\datacursormode.m
% Create a new data tip
hTarget = handle(hLine);
hDatatip = cursorMode.createDatatip(hTarget);

% Update the datatip marker appearance
set(hDatatip, 'MarkerSize',5, 'MarkerFaceColor','none', ...
          'MarkerEdgeColor','k', 'Marker','o', 'HitTest','off');

% Move the datatip to the right-most data vertex point
position = [xdata(5),ydata(5),1; xdata(end),ydata(end),-1];
update(hDatatip, position);

enter image description here

Secondly my own idea, which a little bit easier:

sells = [10,15,25]
buys = [5 12 20]

hold on
for i=buys

for i=sells

enter image description here

share|improve this answer
thanks, I will learn your response today-tomorrow! – javapowered Jul 19 '12 at 17:11

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.