Developing a MIN/MAX indicator.

1 回表示 (過去 30 日間)
Seth
Seth 2012 年 9 月 9 日
Okay, so I'm attempting to make a min/max indicator.It shows the min & max value over certain periods.
i.e. (Obviously this example is offset slightly. Ignore that.)
So far this is what I've come up with(focusing just on the max):
importfile('BundDaily.xls')
period = 14;
maxp = floor(length(High) / period);
startscale = 1;
endscale = 14;
fp = max(High(startscale:endscale,:));
for i=startscale:endscale:maxp
B(i) = fp;
startscale = (startscale + period);
endscale = (endscale + period);
plot(B, 'r') , hold on
end
This is the result:
Methinks the problem is either:
  • How I'm using the max function.
  • Problem with the for loop.
  • Perhaps I need to somehow use a movavg?
  • All of the above!? haha
I'm new to Matlab(clearly) so any help would be much appreciated. Thank-you in advance!
  3 件のコメント
Seth
Seth 2012 年 9 月 9 日
I have five sets of data relating to the price of the Bund (German bond future, it is sampled daily)
  • Open
  • High
  • Low
  • Close
  • Date
They are all 879x1
Oleg Komarov
Oleg Komarov 2012 年 9 月 9 日
I added the missing line of code: importfile('BundDaily.xls').

サインインしてコメントする。

採用された回答

Oleg Komarov
Oleg Komarov 2012 年 9 月 9 日
Plotting on Close with window size 14.
importfile('BundDaily.xls')
period = 14;
n = numel(Close);
% Run moving max
mClose = NaN(n,1);
for ii = 1:length(Close)-period
mClose(period+ii) = max(Close(ii:ii+period-1));
end
% Zoom the graph to see the candles
candle(High,Low,Close,Open)
hold on
plot(mClose,'r')
  1 件のコメント
Seth
Seth 2012 年 9 月 9 日
Awesome, thank-you very much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeFinancial Toolbox についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by