想請教各位大大,
我想寫一個程式碼,
買入條件是:
1.) 30mins: macd > signal
2.) 5mins: macd cross signal
賣出條件是:
1.) 5mins: signal cross macd
我試寫了下面兩個公式 (Test A and Test B)
Test A:
TimeFrameSet( 6* in5Minute);
HIST30 = MACD( 12, 26 ) - Signal( 12, 26, 9 ) ;
TimeFrameRestore();
TimeFrameSet( in5Minute);
m5 = Cross ( MACD( 12, 26 ) , Signal( 12, 26, 9 ));
S5 = Cross ( Signal( 12, 26, 9 ) , MACD( 12, 26 ));
TimeFrameRestore();
Buy = hist30 >0 AND M5;
Sell = S5;
Test B:
TimeFrameSet(in1Minute * 5);
M5 = MACD( 12 , 26);
S5 = Signal( 12 , 26 ,9 );
TimeFrameRestore();
MM5 = TimeFrameExpand(M5, in1Minute * 5);
SS5 = TimeFrameExpand(s5, in1Minute * 5);
Hi5 =Cross (MM5 ,SS5);
Lo5 =Cross (SS5, MM5);
TimeFrameSet(in1Minute * 30);
M30 = MACD( 12 , 26);
S30 = Signal( 12 , 26, 9 );
TimeFrameRestore();
MM30 = TimeFrameExpand(M30, in1Minute * 30);
SS30 = TimeFrameExpand(S30, in1Minute * 30);
Hi30 = MM30 > SS30;
Buy = Hi5 AND Hi30;
Sell = Lo5;
請問為什麼兩者(A and B)會出現不一樣結果?
測試 Test A 時發現如果SETTING 中 periodicity 選擇不一樣 (如選1min or 5min) 會得出不一樣的結果
請問有大大可以指出我的問題所在嗎?
謝謝!
|