股票自动交易脚本(配合Excel使用)

更新时间:2023-10-12 11:30:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

股票自动交易脚本(配合Excel使用)

适合没时间看盘但倾向超短线操作股友,也适合那些经常因涨时贪跌时怕而被庄家诱多或诱空的股友,该脚本除能判别条件执行买入或卖出外,最大特点在于能实现拐点买入(分时图中的某个波谷,但不能保证是一天的最小值)或卖出(分时图上的某个波峰,但不能保证是一天的最大值),示例券商为东方财富证券,如用其他券商需调制一次参数,有意使用者可与我沟通. 以下是源代码:Delay 100

If ZBJD < 1 Then ' Excel坐标校对一次

Hwnd = Plugin.Window.Find(0, 'Microsoft Excel(产品激活失败) - Daily')

Call Plugin.Window.Restore(Hwnd) Call Plugin.Window.Active(Hwnd) Call Plugin.Window.Move(Hwnd, 0, 257) ZBJD = 1 End If Delay 20

If Yesterday < 1 Then '录入昨收价,可运行且仅一次 If Hour(now()) minute(now()) / 60 < 8.75 or Hour(now()) minute(now()) / 60 > 15.5 Then '8:45前或15:30后可录入昨

收价

Recordable = 1 Else Recordable = 0 End If

If Recordable > 0 Then Delay 10

MoveTo 135, 473'Excel定位于[B2]单元格 Delay 10 LeftDown 1 Delay 300 LeftUp 1 Delay 300

QX = 316'待卖股昨收价起点坐标 QY = 169 Call SZSB() Delay 10

If QTJ > 0 Then '防止昨日横盘,收盘价白色无法识别,这时需手动事前输入,程序将不会改动它 SayString QTJ End If KeyPress 39, 2

Delay 10

QY = 191'可买股一昨收价起点坐标 Call SZSB() Delay 10

If QTJ > 0 Then SayString QTJ End If KeyPress 39, 2 Delay 10 QY = 213'第二只 Call SZSB() Delay 10

If QTJ > 0 Then SayString QTJ End If KeyPress 39, 2 Delay 10 QY = 235'第三只 Call SZSB() Delay 10

If QTJ > 0 Then SayString QTJ

End If KeyPress 40, 2 Delay 10 KeyPress 39, 9

QX = 300 '录入大盘昨收指数 Call DPZS() Delay 10

If ZXJ > 0 Then SayString ZXJ End If MoveR 0,50

Yesterday = 1'已录入,除非程序重启,以后将不会运行此模块 End If End If Delay 50

If CommenceDealing < 0.5 then '等待到指定时间开始交易 Timer = hour(now()) * 3600 minute(now()) * 60 second(now()) WaitTime = Form1.inputbox2.text*3600

Form1.inputbox3.text*60 Form1.inputbox4.text-Timer If WaitTime <= 0 Then

WaitTime = 0.5 '指定交易时间前启动脚本将等待到指定

时间才能继续运行,超过指定时间直接运行一次 End If

Delay WaitTime * 1000 ' 延时指定时间与脚本运行时间差,只运行一次

CommenceDealing = 1 '开始盘中交易

End If//委比条件竞价成交,当推测卖股开盘不冲就是最高价,买股不跌开盘即最低价时启用

If Form1.Checkbox2.Value * 1 = 1 and hour(now) = 9 and minute(now) = 24 Then QX = 1106 : QY = 169 Call ZDF YMGWB = ZXJ Delay 10

QX = 382 : QY = 169 Call ZDF YMGZF = ZXJ Delay 10

QX = 1106 : QY = 191 Call ZDF KMG1WB = ZXJ Delay 10 QX = 382 : QY = 191

Call ZDF KMG1ZF = ZXJ Delay 10

QX = 1106 : QY = 213 Call ZDF KMG2WB = ZXJ Delay 10

QX = 382 : QY = 213 Call ZDF KMG2ZF = ZXJ Delay 10

QX = 1106 : QY = 235 Call ZDF KMG3WB = ZXJ Delay 10

QX = 382 : QY = 235 Call ZDF KMG3ZF = ZXJ

Delay 10 If YMGWB < Form1.InputBox8.Text*1 and Form1.Checkbox1.value * 1 = 1 and YMGZF > Form1.InputBox10.Text * 1 Then MoveTo 225, 173

Delay 300 LeftDown 1 Delay 100 LeftUp 1 Delay 100 KeyPress 13, 1 Delay 500 Call OpenSell End If

If KMG1WB > Form1.InputBox9.Text*1 and Form1.Checkbox1.Value * 1 = 0 and KMG1ZF < Form1.InputBox11.Text * 1 Then MoveTo 225, 195 Delay 300 LeftDown 1 Delay 100 LeftUp 1 Delay 100 KeyPress 13, 1 Delay 500 Call OpenBuy End If

If KMG2WB > Form1.InputBox9.Text*1 and Form1.Checkbox1.Value * 1 = 0 and KMG2ZF < Form1.InputBox11.Text * 1 and CGMR < 1 Then MoveTo 225, 217 Delay 300 LeftDown 1 Delay 100 LeftUp 1 Delay 100 KeyPress 13, 1 Delay 500 Call OpenBuy End If

If KMG3WB > Form1.InputBox9.Text*1 and Form1.Checkbox1.Value * 1 = 0 and KMG3ZF < Form1.InputBox11.Text * 1 and CGMR < 1 Then MoveTo 225, 239 Delay 300 LeftDown 1 Delay 100 LeftUp 1 Delay 100

KeyPress 13, 1 Delay 500 Call OpenBuy End If Delay 60000

End If//检查Excel是否丢失焦点及找回Excel焦点 Delay 20

KeyPress 37, 19 '此为防止因丢失焦点导致的东方财富显示界面发生的右偏移 Delay 200 Call JDXZ() Delay 500

//点击Excel更新与识别按钮确认选中A6单元格,或当焦点丢失后选中A列最后一行单元格,防止出错 MoveTo 452, 526 Delay 100 LeftDown 1 Delay 300 LeftUp 1 Delay 500

//有没有要卖的股,打钩为有,不打勾为无,自己每个交易日手动确认默认无误或更改

YMG = Form1.Checkbox1.Value * 1

//GXPL(最高价、最低价、均价、内外比等数据更新频率),随着交易时间的延长其值越来越大,9:30起始 If Hour(now()) Minute(now()) / 60 > 9.5 Then GXPLCS = Hour(now()) Minute(now()) / 60 - 9.5 Else GXPLCS = 0 End If

GXPL = 5 Int(GXPLCS * Form1.inputbox5.text * 1) GXPLn = 0 For GXPL

GXPLn = GXPLn 1

//输入需卖股最新价(唯一)起点坐标 QX = 382 QY = 169 Call ZDF() Delay 20 SayString ZXJ Delay 20 KeyPress 39, 2 Delay 20

//输入第一只可买股起点坐标

本文来源:https://www.bwwdw.com/article/ikqf.html

Top