Hi 小幫手您好:
參考了討論區的文章,我有寫了一個關於台指日盤的CDP繪圖指標,日盤經過測試後沒有太大問題,於是想把這個指標延伸到台指夜盤上面使用。
但是如果用在夜盤,夜盤的CDP運算數值會產生錯誤,與走勢圖內的CDP相去甚遠。
請教一下是否有機會把日盤與夜盤整合在一起,還是建議日盤與夜盤分開呢?
程式碼如下:
settotalbar(2000);
var:CDP(0),AH(0),AL(0),NH(0),NL(0);
if barfreq <> "Min" then raiseruntimeerror("請運行在分鐘頻率上 (最好是1分鐘)");
value1=xfMin_GetValue("5",high,0);
value2=xfMin_GetValue("5",low,0);
value3=xfMin_GetValue("5",closeD(1),0);
value4=xfMin_GetValue("5",open,0);
//均價線
Value5 = GetField("AvgPrice");
CDP = (getfield("High", "D")[1] + getfield("Low", "D")[1] + getfield("Close", "D")[1] * 2) / 4;
AH = CDP + (getfield("High", "D")[1] - getfield("Low", "D")[1]);
AL = CDP - (getfield("High", "D")[1] - getfield("Low", "D")[1]);
NH = 2 * CDP - getfield("Low", "D")[1];
NL = 2 * CDP - getfield("High", "D")[1];
Plot1(AH,"AH");
Plot2(NH,"NH");
Plot3(CDP,"CDP");
Plot4(NH,"NH");
Plot5(NL,"NL");
Plot6(Value5,"均價線");
//====== 日盤 ==========================
if time>=084500 and time<=084959 then
value11=simplehighest(value1,1);
if time>=084500 and time<=084959 then
value12=SimpleLowest(value2,1);
if time>=084500 and time<=134459 then
value13=SimpleLowest(value3,1);
if time>=084500 and time<=084959 then
value14=value4;
if time>=084500 and time<134059 then
plot11(value11,"日開高") else noplot(1);
if time>=084500 and time<134059 then
plot12(value12,"日開低") else noplot(1);
if time>=084500 and time<134059 then
plot13(value13,"日盤昨收") else noplot(1);
if time>=084500 and time<134059 then
plot14(value14,"日開盤") else noplot(1);
//====== 夜盤 ==========================
if time>=150000 and time<=150459 then
value21=simplehighest(value1,1);
if time>=150000 and time<=150459 then
value22=SimpleLowest(value2,1);
if time>=150000 and time<=045959 then
value23=SimpleLowest(value3,1);
if time>=150000 and time<=150459 then
value24=value4;
if time>=150000 and time<045959 then
plot21(value21,"夜開高") else noplot(1);
if time>=150000 and time<045959 then
plot22(value22,"夜開低") else noplot(1);
if time>=150000 and time<045959 then
plot23(value23,"夜盤收") else noplot(1);
if time>=150000 and time<045959 then
plot24(value24,"夜開盤") else noplot(1);
4 評論