缠论分笔分段dll源码–处理K线顶底的源代码(作者:悟多)
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 |
function kxian(pData:pTagCALCINFO):integer;stdcall;export; const quekou:single=0.005; var i,j,k,m,n:integer; h,h1,h2,h3,h4,h5,h6,h7:single; tj1,tj2,tj3,tj4:boolean; begin if (@pData.m_pfParam1 <> nil) and (@pData.m_pfParam2 <> nil) then begin adjustkline(pdata); //处理包含关系; firstduan:=true; prtype:=pdata^.m_dataType; case prtype of MIN1_DATA: //1 biquekou:=quekou; MIN5_DATA: //5 biquekou:=quekou*3; MIN15_DATA: //15 biquekou:=Quekou*6 ; MIN30_DATA: //30 biquekou:=quekou*9; MIN60_DATA:// 60 biquekou:=quekou*18; DAY_DATA: //day biquekou:=quekou*30; WEEK_DATA: //周线 biquekou:=quekou*90; MONTH_DATA: biquekou:=quekou*250; YEAR_DATA: biquekou:=quekou*1000; MULTIday_DATA: biquekou:=quekou*500; MULTmin_DATA: biquekou:=quekou*20; else biquekou:=quekou*500; end; //标出顶和底 pr[0].flag:=0; pr[prnum-1].flag:=0; for i:=1 to prnum-2 do begin h:=pr.hprice; j:=i-1; h1:=pr[j].hprice; while (h=h1) and (j>0) do//取前一个不同的高值 begin j:=j-1; h1:=pr[j].hprice; end; m:=j; if j>0 then j:=j-1; h2:=pr[j].hprice; while (h1=h2) and (j>0) do//最前2个不同的值 begin j:=j-1; h2:=pr[j].hprice; end; if j>0 then j:=j-1; h3:=pr[j].hprice; while (h2=h3) and (j>0) do//取前3个不同的值 begin j:=j-1; h3:=pr[j].hprice; end; k:=i+1; h4:=pr[k].hprice; while (h=h4) and (k<prnum-1) do //后一个不同高值 begin k:=k+1; h4:=pr[k].hprice; end; n:=k; if (k<prnum-1) then k:=k+1; h5:=pr[k].hprice; while (h4=h5) and (k<prnum-1) do //后2个不同高值 begin k:=k+1; h5:=pr[k].hprice; end; if (k<prnum-1) then k:=k+1; h6:=pr[k].hprice; while (h5=h6) and (k<prnum-1) do //后3个不同高值 begin k:=k+1; h6:=pr[k].hprice; end; if (k>=prnum) or (n+3>=prnum) then break; tj1:=false;tj2:=false; tj3:=false;tj4:=false; if (h>=h1) and (h>=h2) and (h>=h3) and (h>=h4) and (h>=h5) and (h>=h6) then //判断顶底 tj1:=true; if m>=3 then h7:=pr[m-3].hprice else h7:=pr[0].hprice; if (h>=h1) and (h>=h2) and (h>=h3) and (h>=h7) and (h>=pr[n].hprice) and (h>=pr[n+1].hprice) and (h>=pr[n+2].hprice) and (h>=pr[n+3].hprice) then tj2:=true; if not (tj1 and tj2) then begin h:=pr.lprice; j:=i-1; h1:=pr[j].lprice; while (h=h1) and (j>0) do//取前一个不同的低值 begin j:=j-1; h1:=pr[j].lprice; end; m:=j; if j>0 then j:=j-1; h2:=pr[j].lprice; while (h1=h2) and (j>0) do//最前2个不同的值 begin j:=j-1; h2:=pr[j].lprice; end; if j>0 then j:=j-1; h3:=pr[j].lprice; while (h2=h3) and (j>0) do//取前3个不同的值 begin j:=j-1; h3:=pr[j].lprice; end; k:=i+1; h4:=pr[k].lprice; while (h=h4) and (k<prnum-1) do //后1个不同低值 begin k:=k+1; h4:=pr[k].lprice; end; n:=k; if (k<prnum-1) then k:=k+1; h5:=pr[k].lprice; while (h4=h5) and (k<prnum-1) do //后2个不同高值 begin k:=k+1; h5:=pr[k].lprice; end; if (k<prnum-1) then k:=k+1; h6:=pr[k].lprice; while (h5=h6) and (k<prnum-1) do //后3个不同高值 begin k:=k+1; h6:=pr[k].lprice; end; if (k>=prnum) or (n+3>=prnum) then break; if (h<=h1) and (h<=h2) and (h<=h3) and (h<=h4) and (h<=h5) and (h<=h6) then //判断底 tj3:=true; if m>=3 then h7:=pr[m-3].lprice else h7:=pr[0].lprice; if (h<=h1) and (h<=h2) and (h<=h3) and (h<=h7) and (h<=pr[n].lprice) and (h<=pr[n+1].lprice) and (h<=pr[n+2].lprice) and (h<=pr[n+3].lprice) then tj4:=true; end; if tj1 and tj2 then pr.flag:=1 else if tj3 and tj4 then pr.flag:=-1 else pr.flag:=0; end;//end for for i:=1 to prnum-2 do //检查几个包含后重复的。 begin m:=pr.flag; if m= 1 then begin if pdata^.m_pData.m_fHigh=pr.hprice then begin pr.flag:=1; j:=i+1; //如果前面的相同,只标最后一个 h:=pr[j].hprice; while (h=pr.hprice) and (j<prnum-1) do begin j:=j+1; h:=pr[j].hprice; end; for k:=i+1 to (j-1) do begin pr[k].flag:=0; end; end else pr.flag:=0; end; if m= -1 then begin if pdata^.m_pData.m_fLow=pr.lprice then begin pr.flag:=-1; j:=i+1; //如果前面的相同,只标最后一个 h:=pr[j].lprice; while (h=pr.lprice) and (j<prnum-1) do begin j:=j+1; h:=pr[j].lprice; end; for k:=i+1 to (j-1) do begin pr[k].flag:=0; end; end else pr.flag:=0; end; end;//end 检查重复的 adjustdd(1,prnum-2); checkhl(); for i:=0 to prnum-1 do pdata^.m_pResultBuf:=pr.flag; result:=1; end // end if NULL else result:=0; end; |
转自:http://blog.sina.com.cn/s/blog_4e82df240100dbc3.html