請教當沖交易日盤及夜盤設定,謝謝!!
當沖交時間設定0845-1329及1500-隔日0450,若與前盤收盤價落差50點以上時,延後30分鐘交易,以MACD為例沒辦法編譯?不知道哪裡有問題,請各位高手幫忙解惑,謝謝!!
inputs: FastLength( 12 ), SlowLength( 26 ), MACDLength( 9 ) ;
variables: var0( 0 ), var1( 0 ), var2( 0 ) ;
var0 = MACD( Close, FastLength, SlowLength ) ;
var1 = XAverage( var0, MACDLength ) ;
var2 = var0 - var1 ;
If var0 cross over var1 then buy this bar on close;
If var0 cross under var1 then sellshort this bar on close;
if date = date then begin
if time > 0850 and time < 1329 and time > 1500 then begin
if time =1329 then begin
if marketposition = 1 then sell this bar on close;
if marketposition = -1 then buytocover this bar on close;
end;
if date <> date then begin
if date < 0450 then begin
if time =0450 then begin
if marketposition = 1 then sell this bar on close;
if marketposition = -1 then buytocover this bar on close;
end;
if date <> date and opend(0) - closed(0) < 50 then begin
end else if time = 0915 then begin
end;
if time = 1345 then value1=close;
if time = 1500 and (open - close < 50 or close - open < 50) then begin
end else if time = 1530 then begin
end; 本帖最後由 jason680 於 19-1-9 16:16 編輯
先看這兩個問題...
改了再看有沒有其他問題
if time > 0850 and time < 1329 and time > 1500 then begin不同時間區塊要用or,不是and
if time > 0850 and time < 1329 or time > 1500 then begin
一般這樣寫 簡單易懂
if 0850 < time and time < 1329 or 1500 < time then begin
或者分兩行
if 0850 < time and time < 1329
or 1500 < time then begin
感覺這怪怪的,看不懂要做什麼...
if date <> date then begin
if date < 0450 then begin// 應該是time < 0450
if time =0450 then begin
還有該縮排要縮排...
程式碼有很多問題,還有邏輯上跟語法上問題...
你應該先花點時間去爬文別人的code,慢慢再建立出來,不然會很挫折的 ....
編譯的問題是在,你一個begin 要對一個end; 少了很多end; 如果真的找不到問題,就一一區 {} 起來,就可以找出那裡少了..
感謝 jason680 大大指點,請問是改成這樣嗎??
可是還是沒辦法編譯,還有哪裡沒改到,謝謝!!
if date = date then begin
if 0850 < time and time < 1329 or 1500 < time then begin
if time =1329 then begin
if marketposition = 1 then sell this bar on close;
if marketposition = -1 then buytocover this bar on close;
end;
if date <> date then begin
if time < 0450 then begin
if time =0450 then begin
if marketposition = 1 then sell this bar on close;
if marketposition = -1 then buytocover this bar on close;
end;
謝謝 chengmou 大大的說明,我再試試看!!
頁:
[1]