|
本帖最後由 lingin1204 於 16-3-4 12:11 編輯
飲水思源,分享程式原始碼,請慢用
ps: 趨勢線定義因人而異,小弟的程式碼目前會產生最新的波段高點連線,並刪除舊的或已經突破的
-----------------------------------------------------------------------------------------------------
Input:leftStrength(3),rightStrength(3);
array:arrayH[300,4](0),arrayL[300,4](0),arrayDraw[2,4](0);
var:var0(0),var1(0),var2(0),var3(0),var4(0),highPrice(0),lowPrice(0),highBarNum(0)
,lowBarNum(0),arrayHNum(0),arrayLNum(0),highPrice2(0),tl_num(0),t1(0),t2(0),t3(0),t4(0),t5(0),t6(0);
cleardebug;
t1=Pivot(High,leftStrength+rightStrength,leftStrength,rightStrength,1,1,highPrice,highBarNum);
if highPrice<> -1 and highBarNum <> -1 then begin
arrayHNum = arrayHNum +1;
arrayH[arrayHNum,0] = highPrice;
arrayH[arrayHNum,1] = IntPortion(Date[highBarNum]);
arrayH[arrayHNum,2] = IntPortion(time_s[highBarNum]);
arrayH[arrayHNum,3] = 0; //for trend line number
end;
t2= Pivot(Low,leftStrength+rightStrength,leftStrength,rightStrength,1,-1,lowPrice,lowBarNum);
if lowPrice<> -1 and lowBarNum <> -1 then begin
arrayLNum +=1;
arrayL[arrayLNum,0] = lowPrice;
arrayL[arrayLNum,1] = IntPortion(Date[lowBarNum]);
arrayL[arrayLNum,2] = IntPortion(time_s[lowBarNum]);
arrayL[arrayLNum,3] = 0;
end;
if t1>0 then begin // Pivot success
tl_delete(arrayH[arrayHNum-1,3]);
end;
for var0 = arrayHNum downto 1 begin
if arrayH[arrayHNum ,0] < arrayH[var0,0] and arrayH[arrayHNum,0]<>0 and t1>0 then begin
arrayH[arrayHNum,3] = tl_new_self_s(arrayH[var0,1],arrayH[var0,2],arrayH[var0,0]
,arrayH[arrayHNum,1],arrayH[arrayHNum,2],arrayH[arrayHNum,0]);
tl_setextright(arrayH[arrayHNum,3],true);
var4 =tl_setalert(arrayH[arrayHNum,3],2);
if var4 >0 then begin
messagelog(" Alert trigger ");
PlaySound("C:\Windows\Media\notify.wav");
end;
arrayDraw[0,0]=arrayH[var0,0];
arrayDraw[0,1]=arrayH[var0,1];
arrayDraw[0,2]=arrayH[var0,2];
arrayDraw[1,0]=arrayH[arrayHNum,0];
arrayDraw[1,1]=arrayH[arrayHNum,1];
arrayDraw[1,2]=arrayH[arrayHNum,2];
var0 = 0;
end;
end;
if arrayHNum > 1 then begin
messagelog("arrayHNum: ",arrayHNum);
messagelog("arrayH[arrayHNum-1,3]: ",arrayH[arrayHNum-1,3]);
messagelog("arrayH[arrayHNum,3]: ",arrayH[arrayHNum,3]);
end;
|
|