缠论分笔分段dll源码–处理笔关系源代码(作者:悟多)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
function bi(pData:pTagCALCINFO):integer;stdcall;export; var i,j,k,l,m,n:integer; p1,p2,s:single; ctfg,bictfg:boolean; buf:array[0..9] of single; begin //adjustdd(1,prnum-2); //合并多顶连续 //找和后面不构成一笔的情况 //去掉后面一个,然后再同取高值或低值 i:=1; while i<(prnum-1) do begin k:=pr[i].flag; if k<>0 then begin j:=i+1; l:=pr[j].flag; while (l=0) and (j<prnum-1) do //找到下一个不为0的 begin j:=j+1; l:=pr[j].flag; end;//找到两个值; if l=0 then break; //判断包含后的距离 fillchar(buf,36,0); m:=0; for k:=i to j do begin s:=pr[k].hprice; ctfg:=false; for l:=0 to 5 do //查找是否在队列中 begin if s=buf[l] then begin ctfg:=true; break; end; end; if not ctfg then //如果不在队列中 begin for l:=0 to 5 do if buf[l]=0 then begin buf[l]:=s; m:=m+1; break; end; end; if m >= 4 then break; end;//end for bictfg:=false; //缺口处理过程 begin s:=0; if pr[i].flag=-1 then//向上 begin for k:=i to j-1 do begin p1:=pdata^.m_pdata[k].m_fHigh; p2:=pdata^.m_pdata[k+1].m_fLow; // p1:=pr[k].hprice; // p2:=pr[k+1].lprice; if p2>p1 then s:=(p2/p1 -1)+s; end; end else//向下 begin for k:=i to j-1 do begin // p1:=pr[k].lprice; // p2:=pr[k+1].hprice; p1:=pdata^.m_pdata[k].m_flow; p2:=pdata^.m_pdata[k+1].m_fhigh; if p1>p2 then s:=abs(p2/p1 -1)+s; end; end; if s>=biQUEKOU then bictfg:=true; end; if m>=4 then//包含后大于4根,再次判断 begin if j-i >=4 then //不包含,至少5根 begin if prtype<>MIN5_DATA then //5分钟分笔幅度太小的,舍掉 bictfg:=True else begin if pr[j].flag=1 then begin s:=(pr[j].hprice-pr[i].lprice)/pr[i].lprice; if (j-i>=6) or (s>=0.008) then bictfg:=true; end; if pr[j].flag=-1 then begin s:=(pr[i].hprice-pr[j].lprice)/pr[i].hprice; if (j-i>=6) or (s>=0.008) then bictfg:=true; end; end; end; end;// end m>=4 if not bictfg then //如果不是一笔,进行下面的处理 begin k:=i; l:=pr[k].flag; k:=k+1; while (l<>pr[k].flag) and (k<prnum-1) do //取下相同的顶或底 k:=k+1; if l=1 then//如果是顶 begin p1:=pr[i].hprice; p2:=pr[k].hprice; if p1>=p2 then //前顶比后顶高; begin pr[j].flag:=0; pr[k].flag:=0; end else//前顶比后顶矮 begin pr[i].flag:=0; //先把自己去掉 n:=j; m:=pr[n].flag; n:=n-1; while (m<>pr[n].flag) and (n>0) do n:=n-1; p1:=pr[n].lprice; p2:=pr[j].lprice; if p1<p2 then begin pr[j].flag:=0; end else pr[n].flag:=0; end;//end else i:=i-1; end; if l=-1 then begin p1:=pr[i].lprice; p2:=pr[k].lprice; if p1<=p2 then //前底比后底矮 begin pr[j].flag:=0; pr[k].flag:=0; end else//前底比后底高 begin pr[i].flag:=0; n:=j; m:=pr[n].flag; n:=n-1; while (m<>pr[n].flag) and (n>0) do n:=n-1; p1:=pr[n].hprice; p2:=pr[j].hprice; if p1>p2 then pr[j].flag:=0 else pr[n].flag:=0; end; i:=i-1; end; end; end;// end if k<>0; i:=i+1; end; // end while; { //检查第一笔 i:=0; while (i<prnum-1) and (pr[i].flag=0) do i:=i+1; if pr[i].flag=-1 then begin k:=0; s:=pr[0].lprice; for j:=0 to i do if pr[j].lprice<s then begin k:=j; s:=pr[j].lprice; end; pr[i].flag:=0; pr[k].flag:=-1; end; if pr[i].flag=1 then begin k:=0; s:=pr[0].hprice; for j:=0 to i do if pr[j].hprice>s then begin k:=j; s:=pr[j].hprice; end; pr[i].flag:=0; pr[k].flag:=1; end; } checkhl(); //检查最后一笔的高低点 i:=prnum-1; while (pr[i].flag=0) and (i>0) do i:=i-1; if pr[i].flag=1 then begin for j:=i+1 to prnum-1 do begin if pr[j].hprice>pr[i].hprice then begin pr[i].flag:=0; Break; end; end; end; if pr[i].flag=-1 then begin for j:=i+1 to prnum-1 do if pr[j].lprice<pr[i].lprice then begin pr[i].flag:=0; break; end; end; for i:=0 to prnum-1 do begin pdata^.m_pResultBuf[i]:=pr[i].flag; end; result:=1; end; |
转自:http://blog.sina.com.cn/s/blog_4e82df240100dbc5.html