You are on page 1of 18

http://www.matlabsky.com/thread-28489-1-1.

html

alpha

f(ts,para) = equity
f ts para
equity f f

equity

Matlab
Matlab Matlab
MCTBMT4 Matlab 7
Matlab

Matlab C

Matlab

2.- Matlab
http://www.matlabsky.com/thread-28490-1-1.html

FRBFarutos Range Breaker

1
IFCU
1
2012 6 1 1.5 IF
0.35%% 0.35%%*1.5=0.525%%
IF 1.5 slip 1 slip
IF 1.5

IFCU
1

IF

3. BackTesting - Matlab
http://www.matlabsky.com/thread-28573-1-1.html
<- Matlab > FRB IFCUAL
FRB IFCUAL
FRB
BackTesting

ABCD T
Ti *
K ABCD Tk Tk
Tk K * K

1-2slip

5-7 BP
PS

1.5-3

Bar(k) Tick Bar Bar Bar(k1).Close Bar Bar Bar(k).Open



Bar
Bar Bar

Bar Bar

Robust Statistics

NB

4.K Matlab - Matlab


http://www.matlabsky.com/thread-28811-1-1.html
Demo IF 20120104 -1

K matlab candle K
matlab candle K K

1. %% K Matlab Demo
2. % by LiYang/faruto
3. % Email:farutoliyang@gmail.com
4. % 2012/8/4
5. scrsz = get(0,'ScreenSize');
6. figure('Position',[1 1 scrsz(3)*4/5 scrsz(4)]);
7.
8. subplot(3,1,[1 2]);
9. OHLC = F(:,3:6);
10. cndlV2(OHLC,0,'r','b','k');
11. xlim([1,length( OHLC )]);
12.
13.

% % Tick Label Set

14.

XTick = [];

15.

XTickLabel = [];

16.
17.

XTick = [XTick; 1];

18.

str = [num2str(F(1,1)),'-',num2str(F(1,2))];

19.

XTickLabel{numel(XTickLabel)+1, 1} = str;

20.
21.

ind = find(F(:,2) == 1000, 1);

22.

if ~isempty(ind)

23.

XTick = [XTick; ind ];

24.

str = [num2str(F(ind, 1)),'-',num2str(F(ind, 2))];

25.

XTickLabel{numel(XTickLabel)+1, 1} = str;

26.

end

27.
28.

ind = find(F(:,2) == 1130, 1);

29.

if ~isempty(ind)

30.

XTick = [XTick; ind ];

31.

str = [num2str(F(ind, 1)),'-',num2str(F(ind, 2))];

32.

XTickLabel{numel(XTickLabel)+1, 1} = str;

33.

end

34.
35.

ind = find(F(:,2) == 1400, 1);

36.

if ~isempty(ind)

37.

XTick = [XTick; ind ];

38.

str = [num2str(F(ind, 1)),'-',num2str(F(ind, 2))];

39.

XTickLabel{numel(XTickLabel)+1, 1} = str;

40.

end

41.
42.

ind = length(F(:,1));

43.

XTick = [XTick; ind ];

44.

str = [num2str(F(ind, 1)),'-',num2str(F(ind, 2))];

45.

XTickLabel{numel(XTickLabel)+1, 1} = str;

46.
47.

set(gca,'XTick', XTick);

48.

set(gca,'XTickLabel', XTickLabel);

49.

TickLabelRotate(gca, 'x', 30, 'right');

50.
51. title('K Matlab Demo', 'FontWeight','Bold', 'FontSize', 15);
52.
53. subplot(313);
54. bar( F(:,7) );
55. xlim([1,length( OHLC )]);

56. title('', 'FontWeight','Bold', 'FontSize', 15);


57.
58.

set(gca,'XTick', XTick);

59.

set(gca,'XTickLabel', XTickLabel);

60.

TickLabelRotate(gca, 'x', 30, 'right');

K K

1. function cndlV2(varargin)
2. % See if we have [OHLC] or seperate vectors and retrieve our
3. % required variables (Feel free to make this code more pretty ;-)
4. isMat = size(varargin{1},2);
5. indexShift = 0;
6. useDate = 0;
7.
8. if isMat == 4,
9.

O = varargin{1}(:,1);

10.

H = varargin{1}(:,2);

11.

L = varargin{1}(:,3);

12.

C = varargin{1}(:,4);

13. else
14.

O = varargin{1};

15.

H = varargin{2};

16.

L = varargin{3};

17.

C = varargin{4};

18.

indexShift = 3;

19. end
20. if nargin+isMat < 7,
21.

colorDown = 'k';

22.

colorUp = 'w';

23.

colorLine = 'k';

24. else
25.

colorUp = varargin{3+indexShift};

26.

colorDown = varargin{4+indexShift};

27.

colorLine = varargin{5+indexShift};

28. end
29. if nargin+isMat < 6,
30.

date = (1:length(O))';

31. else
32.

if varargin{2+indexShift} ~= 0

33.

date = varargin{2+indexShift};

34.

useDate = 1;

35.

else

36.

date = (1:length(O))';

37.

end

38. end
39.
40. % w = Width of body, change multiplier to draw body thicker or thinner
41. % the 'min' ensures no errors on weekends ('time gap Fri. Mon.' > wanted
42. % spacing)
43. w=.3*min([(date(2)-date(1)) (date(3)-date(2))]);
44. %%%%%%%%%%%Find up and down days%%%%%%%%%%%%%%%%%%%
45. d=C-O;
46. l=length(d);
47. hold on
48. %%%%%%%%draw line from Low to High%%%%%%%%%%%%%%%%%
49. for i=1:l
50.

line([date(i) date(i)],[L(i) H(i)],'Color',colorLine)

51. end
52. %%%%%%%%%%draw white (or user defined) body (down day)%%%%%%%%%%%%%%%%%
53. n=find(d<0);
54. for i=1:length(n)
55.

x=[date(n(i))-w date(n(i))-w date(n(i))+w date(n(i))+w date(n(i))-w];

56.

y=[O(n(i)) C(n(i)) C(n(i)) O(n(i)) O(n(i))];

57.

fill(x,y,colorDown)

58. end
59. %%%%%%%%%%draw black (or user defined) body(up day)%%%%%%%%%%%%%%%%%%%
60. n=find(d>=0);
61. for i=1:length(n)
62.

x=[date(n(i))-w date(n(i))-w date(n(i))+w date(n(i))+w date(n(i))-w];

63.

y=[O(n(i)) C(n(i)) C(n(i)) O(n(i)) O(n(i))];

64.

fill(x,y,colorUp)

65. end
66.
67. if (nargin+isMat > 5) && useDate,
68. %
69.

tlabel('x');
dynamicDateTicks

70. end
71.
72. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73. hold off

1MA
2MACD
MACD

1S L EMA1EMA2
2 DIF=EMA1-EMA2
3 DIF N DEA
4 MACD=2*(DIF-DEA)
3DMA
DMA
1S L MA1MA2
2 DMA=MA1-MA2
3 DMA M AMA
4TRIX
TRIX
1 N EMA
2 EMA N TR
3 TRIX=(TR- TR)/ TR*100
4 TRIX M MATRIX

Demo

1. %% Matlab
2. % by LiYang/faruto

3. % Email:farutoliyang@gmail.com
4. % 2012/8/4
5. %% MA
6. S = 5;
7. L = 20;
8. [SMA, LMA] = movavg(Data, S, L);
9. SMA(1:S-1) = NaN;
10. LMA(1:L-1) = NaN;
11.
12. scrsz = get(0,'ScreenSize');
13. figure('Position',[1 1 scrsz(3)*4/5 scrsz(4)]);
14.
15. subplot(221);
16. OHLC = F(:,3:6);
17. cndlV2(OHLC,0,'r','b','k');
18. xlim([1,length( OHLC )]);
19.

set(gca,'XTick', XTick);

20.

set(gca,'XTickLabel', XTickLabel);

21.

TickLabelRotate(gca, 'x', 30, 'right');

22.
23. hold on;
24. H1 = plot(SMA,'g','LineWidth',1.5);
25. H2 = plot(LMA,'r','LineWidth',1.5);
26. title(' SMA()Matlab Demo',
'FontWeight','Bold', 'FontSize', 15);
27. M = {'MA5';'MA20'};
28. legend([H1,H2],M);
29.
30. %% MACD
31. S = 12;

32. L = 26;
33. EMA1 = EMA(Data, S);
34. EMA2 = EMA(Data, L);
35. DIFF = EMA1-EMA2;
36. M = 10;
37. DEA = EMA(DIFF, M);
38. MACD = 2*(DIFF-DEA);
39.
40. subplot(222);
41. MACD_p = MACD;
42. MACD_n = MACD;
43. MACD_p(MACD_p<0) = 0;
44. MACD_n(MACD_n>0) = 0;
45. bar(MACD_p,'r','EdgeColor','r');
46. hold on;
47. bar(MACD_n,'b','EdgeColor','b');
48. plot(DIFF,'k','LineWidth',1.5);
49.
50. plot(DEA,'g','LineWidth',1.5);
51.
52. xlim([1,length( OHLC )]);
53.

set(gca,'XTick', XTick);

54.

set(gca,'XTickLabel', XTickLabel);

55.

TickLabelRotate(gca, 'x', 30, 'right');

56. title(' MACD()Matlab Demo',


'FontWeight','Bold', 'FontSize', 15);
57.
58. %% DMA
59. S = 5;
60. L = 20;

61. [MA1, MA2] = movavg(Data, S, L);


62. MA1(1:S-1) = NaN;
63. MA2(1:L-1) = NaN;
64. DMA = MA1-MA2;
65. M = 5;
66. AMA = movavg(DMA, M, M);
67. AMA(1:M-1) = NaN;
68.
69. subplot(223);
70.
71. hold on;
72. plot(DMA,'k','LineWidth',1.5);
73. plot(AMA,'r','LineWidth',1.5);
74. title(' DMA()Matlab Demo', 'FontWeight','Bold',
'FontSize', 15);
75. legend('DMA','AMA');
76. xlim([1,length( OHLC )]);
77.

set(gca,'XTick', XTick);

78.

set(gca,'XTickLabel', XTickLabel);

79.

TickLabelRotate(gca, 'x', 30, 'right');

80. %% TRIX
81. N = 2;
82. ema = EMA(Data, N);
83. M = 20;
84. TR = EMA( EMA(ema,N) , N);
85. TRIX = ( TR(2:end)-TR(1:end-1) )./TR(1:end-1)*100;
86. TRIX = [NaN; TRIX];
87. MATRIX = movavg(TRIX, M, M);
88.
89. subplot(224);

90.
91. hold on;
92. plot(TRIX,'k','LineWidth',1.5);
93. plot(MATRIX,'r','LineWidth',1.5);
94. title(' TRIX()Matlab Demo',
'FontWeight','Bold', 'FontSize', 15);
95. legend('TRIX','MATRIX');
96. xlim([1,length( OHLC )]);
97.

set(gca,'XTick', XTick);

98.

set(gca,'XTickLabel', XTickLabel);

99.

TickLabelRotate(gca, 'x', 30, 'right');

5.MATLAB MatlabTraderGUI V1.0Beta


http://www.matlabsky.com/thread-22239-1-1.html

MatlabTrader.m

MatlabTrader.fig
======================================================
MatlabTraderGUI
V1.0
Beta
by

LiYang

2011/12/30

Email:farutoliyang@gmail.com
MATLAB

MatlabTraderGUI

V1.0

Beta

1. Yahoo Finance
2.

3.


4. callback
5.

MACD

6.Mcode
faruto 2011

6.- Matlab
http://www.matlabsky.com/thread-33832-1-1.html
Tick
1MIN3MIN5MIN15MIN30MIN1hour
Tick 4MIN7MIN9MIN

7.- Matlab
http://www.matlabsky.com/thread-33833-1-1.html
## ## 12
34
34

FPRFarutos Pattern Recognition

IF
1

2012 6 1 1.5 IF
0.35%% 0.35%%*1.5=0.525%%
IF 1.5 slip 1 slip
IF 1.5

You might also like