COCO研究院

 找回密碼
 註冊
搜索
查看: 3640|回復: 4

請教當沖交易日盤及夜盤設定,謝謝!!

[複製鏈接]
發表於 19-1-9 11:30 | 顯示全部樓層 |閱讀模式
當沖交時間設定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[1] 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[1] 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[1] 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;
發表於 19-1-9 16:10 | 顯示全部樓層
本帖最後由 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[1] then begin
  if date < 0450 then begin  // 應該是time < 0450
    if time =0450 then begin

還有該縮排要縮排...




回復 支持 2 反對 0

使用道具 舉報

發表於 19-1-10 16:06 | 顯示全部樓層
程式碼有很多問題,還有邏輯上跟語法上問題...
你應該先花點時間去爬文別人的code,慢慢再建立出來,不然會很挫折的 ....
編譯的問題是在,你一個begin 要對一個end; 少了很多end; 如果真的找不到問題,就一一區 {} 起來,就可以找出那裡少了..
回復 支持 1 反對 0

使用道具 舉報

 樓主| 發表於 19-1-9 21:01 | 顯示全部樓層
感謝 jason680 大大指點,請問是改成這樣嗎??
可是還是沒辦法編譯,還有哪裡沒改到,謝謝!!

if date = date[1] 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[1] 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;
 樓主| 發表於 19-1-10 18:21 | 顯示全部樓層
謝謝 chengmou 大大的說明,我再試試看!!
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

手機版|Archiver|站長信箱|廣告洽詢|COCO研究院

GMT+8, 24-4-25 16:15

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回復 返回頂部 返回列表
理財討論網站 | AI繪圖AI超擬真美女AI beauty AI Stable DiffusionAI正妹AI Lookbook