這個需求怎么實現? [MC]
-
MC用戶求助:
”節假日及周末前“,這個節假日及周末的日期需要您手動輸入,然后在代碼中實時的與當前的日期時間進行比較判斷,下面分別提供螺紋和滬金的例子,僅供參考:
//rb
input: endtime(2300);
var: tt(""),t1(""), t_date(0);
tt=txt_read("F:\test25.txt");??
{這里使用了從外部讀取信息,因為這樣可以在程序運行過程中,對外部讀取的文件進行人工更改,而不需要停止自動交易然后再重新輸入參數或者更改代碼了;輸入節假日的第一天的日期即可}
t1=midstr(tt,1,7);//見附件內容,只是一個簡單的模板,更復雜的數據需要清洗
t_date=strtonum(t1);??//將字符轉化為數值
condition1=juliantodate(datetojulian(t_date)-1)=date and time>=minutestotime(timetominutes(endtime)-5);
{juliantodate(datetojulian(t_date)-1)=date這個條件判斷當天是否為節假日前的第一天; time>=minutestotime(timetominutes(endtime)-5)這個條件判斷當根bar是否處在收盤前的5分鐘內}
if condition1 and marketposition<>0 then begin
? ? ? ? sell next bar at market;
? ? ? ? buytocover next bar at market;
end;
//au
input: endtime(230);
var: tt(""),t1(""), t_date(0);
tt=txt_read("F:\test25.txt");
t1=midstr(tt,1,7);
t_date=strtonum(t1);
condition1=juliantodate(datetojulian(t_date))=date and time>=minutestotime(timetominutes(endtime)-5) and time<900;
if condition1 and marketposition<>0 then begin
? ? ? ? sell next bar at market;
? ? ? ? buytocover next bar at market;
end;代碼見鏈接:
http://dl.icetech.com.cn/download/forums/test25.txt
?
-
MC回復討論一:
”節假日及周末前“,這個節假日及周末的日期需要您手動輸入,然后在代碼中實時的與當前的日期時間進行比較判斷,下面分別提供螺紋和滬金的例子,僅供參考:
//rb
input: endtime(2300);
var: tt(""),t1(""), t_date(0);
tt=txt_read("F:\test25.txt");??
{這里使用了從外部讀取信息,因為這樣可以在程序運行過程中,對外部讀取的文件進行人工更改,而不需要停止自動交易然后再重新輸入參數或者更改代碼了;輸入節假日的第一天的日期即可}
t1=midstr(tt,1,7);//見附件內容,只是一個簡單的模板,更復雜的數據需要清洗
t_date=strtonum(t1);??//將字符轉化為數值
condition1=juliantodate(datetojulian(t_date)-1)=date and time>=minutestotime(timetominutes(endtime)-5);
{juliantodate(datetojulian(t_date)-1)=date這個條件判斷當天是否為節假日前的第一天; time>=minutestotime(timetominutes(endtime)-5)這個條件判斷當根bar是否處在收盤前的5分鐘內}
if condition1 and marketposition<>0 then begin
? ? ? ? sell next bar at market;
? ? ? ? buytocover next bar at market;
end;
//au
input: endtime(230);
var: tt(""),t1(""), t_date(0);
tt=txt_read("F:\test25.txt");
t1=midstr(tt,1,7);
t_date=strtonum(t1);
condition1=juliantodate(datetojulian(t_date))=date and time>=minutestotime(timetominutes(endtime)-5) and time<900;
if condition1 and marketposition<>0 then begin
? ? ? ? sell next bar at market;
? ? ? ? buytocover next bar at market;
end;代碼見鏈接:
http://dl.icetech.com.cn/download/forums/test25.txt
有思路,想編寫各種指標公式,程序化交易模型,選股公式,預警公式的朋友
可聯系技術人員 QQ: 511411198 進行 有償 編寫!(不貴!點擊查看價格!)
相關文章
-
沒有相關內容