matalb 图中画出买卖信号

xdata=1:1:100;
ydata=rand(100,1);
% 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];
set(hDatatip, 'Position', [position(2,1) position(2,2)]);

你可能感兴趣的:(matalb 图中画出买卖信号)