Re: [請益] 有K棒製作程式嗎?已回收

看板Stock (股票)作者 ( )時間13年前 (2013/05/27 12:30), 編輯推噓13(1413)
留言18則, 16人參與, 最新討論串2/3 (看更多)
※ 引述《dichotomyptt ((  ̄ c ̄)y▂ξ)》之銘言: : 如題 : 我想要請問一下 有沒有K棒製作程式 : 可以 自由填入X軸 Y軸 : 跟下面的成交量 有均線更佳 : 謝謝^^ 很久以前找到的程式碼,原作好像不是java,我改成寫成java,並加上註解 import java.awt.*; import java.awt.event.*; public class stock extends Frame { char [] dashline=new char [200]; int span=6; //寬的間距 int height=500; //圖高 int start=120; //X座標起點 int width=8; //長方形寬 int end=750; //X座標終點 int height_span=50; //高的間距 int max; //最大值 int min; //最小值 int scale=0; int ss; int es; int hs; int ls; int xL; int totspan; int stock_data[][]= { //開盤, 收盤, 當天最高, 當天最低 {313 ,331 ,333 ,311 }, {324 ,330 ,335 ,323 }, {335 ,329 ,337 ,328 }, {329 ,341 ,342 ,327 }, {341 ,328 ,343 ,328 }, {328 ,318 ,330 ,315 }, {320 ,321 ,326 ,320 }, {319 ,321 ,327 ,315 }, {325 ,335 ,335 ,323 }, {344 ,335 ,348 ,335 }, {338 ,358 ,358 ,333 }, {360 ,351 ,365 ,350 }, {355 ,346 ,356 ,345 }, {347 ,356 ,360 ,346 }, {356 ,353 ,362 ,352 }, {357 ,345 ,360 ,342 }, {344 ,338 ,348 ,338 }, {333 ,324 ,336 ,318 }, {332 ,321 ,334 ,321 }, {316 ,326 ,328 ,315 }, {328 ,318 ,332 ,318 }, {324 ,330 ,330 ,318 }, {332 ,329 ,333 ,327 }, {334 ,326 ,336 ,326 }, {324 ,318 ,324 ,318 }, {317 ,321 ,323 ,316 }, {326 ,326 ,329 ,324 }, {338 ,328 ,340 ,328 }, {333 ,333 ,337 ,330 }, {335 ,334 ,335 ,330 }, {334 ,331 ,338 ,330 }, {331 ,322 ,332 ,321 }, {323 ,325 ,327 ,316 }, {324 ,318 ,324 ,317 }, {318 ,310 ,322 ,310 }, {313 ,296 ,317 ,293 }, {295 ,302 ,302 ,291 }, {288 ,286 ,290 ,283 } }; public stock() { super("股票行情"); setSize(800,600); setResizable(false); //不可改變大小 addWindowListener(new WindowAdapter() //匿名的視窗事件調適器 { public void windowClosing(WindowEvent e) //視窗關閉事件 { dispose(); // 釋放視窗所佔用的資源, 並關閉視窗 } }); for(int i=0;i<200;i++) dashline[i]='-'; } public void paint (Graphics g) { int i,j,k; max = 0; for(j=0;j<stock_data.length;j++) { if (stock_data[j][2]>max) //求最大值 max = stock_data[j][2]; } min = max; for(j=0;j<stock_data.length;j++) { if (stock_data[j][3]<min) //求最小值 min = stock_data[j][3]; } scale=height/(max-min); g.drawString("max=" + max,110,60); // 寫出最大值 g.drawString("min=" + min,110,80); // 寫出最小值 g.drawString("height/max-min=" + scale,110,120); //寫出刻度 for( k=0;k<10;k++) // 分10個橫線 { int number=min+(scale*k); g.drawChars(dashline,0,200, 0,height-(k*height_span)); // 畫出橫的虛線 g.drawString(k + "->" + number , start - 70, height-((height_span*k)+5)); //橫線代表的數值 } for(i=0;i<stock_data.length;i++) { ss = stock_data[i][0]; // 開盤 es = stock_data[i][1]; // 收盤 hs = stock_data[i][2]; // 當天最高 ls = stock_data[i][3]; // 當天最低 xL= start+(width*i); totspan = span*(i-1); if(es>ss) //收盤大於開盤 { g.setColor(Color.red); g.fillRect(xL+totspan, height-((es-min)*scale), width, (es-ss)*scale); g.setColor(Color.black); g.drawLine((xL*2+totspan+(span*i))/2, height-((hs-min)*scale), (xL*2+totspan+(span*i))/2, height-((es-min)*scale)); g.drawLine((xL*2+totspan+(span*i))/2, height-((ls-min)*scale), (xL*2+totspan+(span*i))/2, height-((ss-min)*scale)); } else if(ss>es) //開盤大於收盤 { g.setColor(Color.green); g.fillRect(xL+totspan, height-((ss-min)*scale), width, (ss-es)*scale); g.setColor(Color.black); g.drawLine((xL*2+totspan+(span*i))/2, height-((hs-min)*scale), (xL*2+totspan+(span*i))/2, height-((ss-min)*scale)); g.drawLine((xL*2+totspan+(span*i))/2, height-((ls-min)*scale), (xL*2+totspan+(span*i))/2, height-((es-min)*scale)); } else //開盤等於收盤 { g.setColor(Color.black); g.fillRect(xL+totspan, height-((ss-min)*scale), width, 1); g.drawLine((xL*2+totspan+(span*i))/2, height-((hs-min)*scale), (xL*2+totspan+(span*i))/2, height-((ss-min)*scale)); g.drawLine((xL*2+totspan+(span*i))/2, height-((ls-min)*scale), (xL*2+totspan+(span*i))/2, height-((es-min)*scale)); } } } } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 112.104.47.10

05/27 12:33, , 1F
excel都不會了,這個看得懂嗎??
05/27 12:33, 1F

05/27 12:34, , 2F
VB咩 我懂!
05/27 12:34, 2F

05/27 12:34, , 3F
大感謝!!! 馬上import
05/27 12:34, 3F

05/27 12:35, , 4F
有code有推
05/27 12:35, 4F

05/27 12:36, , 5F
他要買車結果你教他做引擎 XDDDD
05/27 12:36, 5F

05/27 12:38, , 6F
我去問我朋友看看T_T 先謝謝你
05/27 12:38, 6F

05/27 12:49, , 7F
這是java applet??
05/27 12:49, 7F

05/27 12:53, , 8F
唸商科的看不懂啦!!!
05/27 12:53, 8F

05/27 13:03, , 9F
先推XD
05/27 13:03, 9F

05/27 13:21, , 10F
靠,你有看得懂的朋友,會教你更簡單的方式,廢文
05/27 13:21, 10F

05/27 14:04, , 11F
那也要他會啊 他只會簡單的EXCEL而以
05/27 14:04, 11F

05/27 14:08, , 12F
哇~~~這是VB還是C語言阿?
05/27 14:08, 12F

05/27 14:38, , 13F
看不懂啦!怒吃便當
05/27 14:38, 13F

05/27 15:03, , 14F
滿滿的宣告...~ 這應該也可以用C#
05/27 15:03, 14F

05/27 17:46, , 15F
JAVA好用推
05/27 17:46, 15F

05/27 19:28, , 16F
........
05/27 19:28, 16F

05/27 22:36, , 17F
python
05/27 22:36, 17F

05/27 22:36, , 18F
也很好用
05/27 22:36, 18F
文章代碼(AID): #1Hek5_Yt (Stock)
文章代碼(AID): #1Hek5_Yt (Stock)