[原創(chuàng)]自動(dòng)開關(guān)金字塔軟件、自動(dòng)開啟交易等技巧 [金字塔]
- 咨詢內(nèi)容:
整個(gè)流程為:
8:40 自動(dòng)開啟金字塔軟件,軟件登錄馬上加載交易圖表(Frame1)
30秒后自動(dòng)啟動(dòng)圖表交易(整個(gè)過程需要一兩分鐘)
17:30 自動(dòng)執(zhí)行收盤作業(yè)(請(qǐng)先設(shè)置好收盤作業(yè)的市場(chǎng),和需要保存的K線周期)
19:00 自動(dòng)關(guān)閉金字塔軟件
20:40 自動(dòng)開啟金字塔軟件,軟件登錄馬上加載夜盤交易圖表(Frame2)
30秒后自動(dòng)啟動(dòng)圖表交易(整個(gè)過程需要一兩分鐘)
06:00 自動(dòng)關(guān)閉金字塔軟件
軟件分為兩部分,VC++部分用途為每天兩次自動(dòng)開啟金字塔軟件并自動(dòng)點(diǎn)擊“登錄”按鈕。程序在附件中,只有兩個(gè)文件(testTraderApi.exe和thostmduserapi.dll),該程序自動(dòng)連接某期貨公司的ctp行情服務(wù)器,取得交易日日期,從而自動(dòng)判斷當(dāng)天是否交易,不交易不開啟金字塔軟件。請(qǐng)將testTraderApi.exe設(shè)置為隨Windows自動(dòng)啟動(dòng)即可(放個(gè)快捷方式到“開始菜單》程序》啟動(dòng)”)。軟件下載:
下載信息 [文件大小: 下載次數(shù): ]點(diǎn)擊瀏覽該文件:自動(dòng)開啟金字塔.zip
為防止網(wǎng)友懷疑我在exe中加入盜號(hào)、盜策略等木馬程序,特附上該exe文件的源代碼供下載,大家也可以下載后自行編譯,并且還可以修改開啟金字塔的時(shí)間,源代碼下載: 下載信息 [文件大小: 下載次數(shù): ]點(diǎn)擊瀏覽該文件:金字塔開機(jī)軟件.zip
- 金字塔客服:
第二部分為金字塔VBA代碼,可復(fù)制并放入金字塔的任何一個(gè)VBA模塊中:
dim StartTime
dim StartTrade
dim HasDoCloseSub APPLICATION_Start()
'''''''自動(dòng)啟動(dòng)相應(yīng)的框架(分日盤、夜盤調(diào)出相應(yīng)圖表,請(qǐng)自行疊加相應(yīng)策略公式)
if cdate(time)>cdate("06:00:00") and cdate(time)<cdate("18:00:00") then
'''''''日盤交易,打開框架名“Frame1”
application.ActivateFrame "Frame1"
else
'''''''夜盤交易,打開框架名“Frame2”
application.ActivateFrame "Frame2"
end if
call application.Settimer(100,30000) '30秒時(shí)鐘循環(huán)
StartTime = cdate(time)
StartTrade = 0
HasDoClose = 0
End SubSub APPLICATION_Timer(ID)
if ID=100 then
if StartTrade=0 then
''''''''''''''啟動(dòng)圖表交易
Set Wrap = CreateObject("DynamicWrapper")
Wrap.Register "user32.dll","FindWindowA","i=ss","f=s", "r=l"
Wrap.Register "user32.dll","FindWindowExA","i=llss","f=s", "r=l"
Wrap.Register "user32.dll","SendMessageA","i=lull","f=s", "r=l"
WM_LBUTTONDOWN=513
WM_LBUTTONUP=514
h = Wrap.FindWindowA("#32770","圖表程式化交易 - 日盤框架 - 交易中") '框架名稱請(qǐng)自行定義,下同
if h=0 then h = Wrap.FindWindowA("#32770","圖表程式化交易 - 夜盤框架 - 交易中")
if h<>0 then
Wrap.PostMessageA h,WM_CLOSE,0,0
StartTrade=1
else
h = Wrap.FindWindowA("#32770","金字塔")
if h<>0 then
h2 = Wrap.FindWindowExA(h,0,"Button","是(&Y)")
if h2<>0 then
Wrap.SendMessageA h2,WM_LBUTTONDOWN,0,0
Wrap.SendMessageA h2,WM_LBUTTONUP,0,0
end if
else
h = Wrap.FindWindowA("#32770","圖表程式化交易 - 日盤框架 - 已停止")
if h=0 then h = Wrap.FindWindowA("#32770","圖表程式化交易 - 夜盤框架 - 已停止")
if h<>0 then
h2 = Wrap.FindWindowExA(h,0,"Button","啟動(dòng)交易")
if h2<>0 then
Wrap.SendMessageA h2,WM_LBUTTONDOWN,0,0
Wrap.SendMessageA h2,WM_LBUTTONUP,0,0
end if
else
application.PostMessage(33873)
end if
end if
end if
elseif HasDoClose=0 and cdate(time)>cdate("17:30:00") and cdate(time)<cdate("18:00:00") then
''''''''17:30~18:00啟動(dòng)收盤
HasDoClose=1
call application.Settimer(5,2000)
application.PostMessage(454)'收盤
elseif (StartTime<cdate("16:00:00") and cdate(time)>cdate("19:00:00") and cdate(time)<cdate("19:30:00")) or ((StartTime<cdate("2:30:00") or StartTime>cdate("6:30:00")) and cdate(time)>cdate("06:00:00") and cdate(time)<cdate("06:30:00")) then
'''''''''''''關(guān)閉金字塔程序(早上2:30前或前一日6:30后開啟的凌晨6點(diǎn)關(guān)閉,下午16點(diǎn)前開啟的19點(diǎn)關(guān)閉)
Set Wrap = CreateObject("DynamicWrapper")
Wrap.Register "user32.dll","FindWindowA","i=ss","f=s", "r=l"
Wrap.Register "user32.dll","FindWindowExA","i=llss","f=s", "r=l"
Wrap.Register "user32.dll","SendMessageA","i=lull","f=s", "r=l"
WM_LBUTTONDOWN=513
WM_LBUTTONUP=514
h = Wrap.FindWindowA("#32770","金字塔")
if h<>0 then
h2 = Wrap.FindWindowExA(h,0,"Button","是(&Y)")
if h2<>0 then
Wrap.SendMessageA h2,WM_LBUTTONDOWN,0,0
Wrap.SendMessageA h2,WM_LBUTTONUP,0,0
end if
else
application.PostMessage(57665)
end if
end if
elseif ID=5 then
'''''''''''開始收盤
call application.killtimer(5)
Set Wrap = CreateObject("DynamicWrapper")
Wrap.Register "user32.dll","FindWindowA","i=ss","f=s", "r=l"
Wrap.Register "user32.dll","FindWindowExA","i=llss","f=s", "r=l"
Wrap.Register "user32.dll","PostMessageA","i=lull","f=s", "r=l"
WM_CLOSE=16
call application.Settimer(7,600000)'10分鐘后關(guān)閉收盤窗口
h = Wrap.FindWindowA("#32770","數(shù)據(jù)管理器")
tab=Wrap.FindWindowExA(h,0,"SysTabControl32","Tab1")
BM_CLICK=245
h1=Wrap.FindWindowExA(tab,0,"#32770","")
do while h1<>0
bt=Wrap.FindWindowExA(h1,0,"Button","執(zhí)行收盤(&X)")
if bt<>0 then
Wrap.PostMessageA bt,BM_CLICK,0,0
h1=0
else
h1=Wrap.FindWindowExA(tab,h1,"#32770","")
end if
loop
call application.Settimer(6,2000)
elseif ID=6 then
call application.killtimer(6)
BM_CLICK=245
Set Wrap = CreateObject("DynamicWrapper")
Wrap.Register "user32.dll","FindWindowA","i=ss","f=s", "r=l"
Wrap.Register "user32.dll","FindWindowExA","i=llss","f=s", "r=l"
Wrap.Register "user32.dll","PostMessageA","i=lull","f=s", "r=l"
h = Wrap.FindWindowA("#32770","金字塔")
bt=Wrap.FindWindowExA(h,0,"Button","是(&Y)")
Wrap.PostMessageA bt,BM_CLICK,0,0
elseif ID=7 then
'''''''結(jié)束收盤
Set Wrap = CreateObject("DynamicWrapper")
Wrap.Register "user32.dll","FindWindowA","i=ss","f=s", "r=l"
Wrap.Register "user32.dll","FindWindowExA","i=llss","f=s", "r=l"
Wrap.Register "user32.dll","PostMessageA","i=lull","f=s", "r=l"
WM_CLOSE=16
BM_CLICK=245
h = Wrap.FindWindowA("#32770","金字塔")
bt = 0
bt = Wrap.FindWindowExA(h,0,"Button","確定")
st = 0
st = Wrap.FindWindowExA(h,0,"Static","收盤作業(yè)結(jié)束。")
if bt<>0 and st<>0 then
Wrap.PostMessageA h,WM_CLOSE,0,0
h = Wrap.FindWindowA("#32770","數(shù)據(jù)管理器")
Wrap.PostMessageA h,WM_CLOSE,0,0
call application.killtimer(7)
'SendMail "收盤作業(yè)完成","收盤作業(yè)完成" ''''發(fā)信息通知收盤完成,是否需要個(gè)人決定
end if
end if
end sub - 用戶回復(fù):
感謝klc無私提供的幫助
- 網(wǎng)友回復(fù):
VBA部分,以往有不少網(wǎng)友不知道怎么用,上面僅用到兩個(gè)VBA事件:Sub APPLICATION_Start和Sub APPLICATION_Timer(ID),都是系統(tǒng)內(nèi)置的,用金字塔菜單》工具》宏》V...B...工程就可以打開看到幾個(gè)模塊,任選一個(gè)模塊,把上面代碼添加即可。
需要注意的是兩點(diǎn):
1、必須先停止VBA才能編輯模塊中的代碼
2、APPLICATION_Start和APPLICATION_Timer,在整個(gè)金字塔中都必須各只有一個(gè),如果原來已經(jīng)有了,不要直接覆蓋,而是修改原來的代碼,加到Sub內(nèi)部。
另外,我原來寫過提高圖表交易程序效率的帖子,也寫過自動(dòng)檢查金字塔運(yùn)行狀態(tài)的帖子,都可以和本帖子的內(nèi)容結(jié)合起來,結(jié)合的時(shí)候,注意同名函數(shù)的問題就行。同時(shí),我原來還寫過盤后自動(dòng)進(jìn)行數(shù)據(jù)補(bǔ)充,可以結(jié)合起來,我自己的做法是,盤后先自動(dòng)下載一次當(dāng)天的分筆數(shù)據(jù),下載完成后,進(jìn)行一次當(dāng)天數(shù)據(jù)K線檢查,檢查如果沒有發(fā)現(xiàn)問題,才啟動(dòng)收盤,如果有問題,不收盤,短信通知。這個(gè)需要大家通過我?guī)讉€(gè)帖子結(jié)合起來,自行修改了。
最后補(bǔ)充一個(gè)問題:exe可改名,dll不可改名
[此貼子已經(jīng)被作者于2013/10/23 13:45:12編輯過] - 網(wǎng)友回復(fù): 感謝klc無私提供的幫助
有思路,想編寫各種指標(biāo)公式,程序化交易模型,選股公式,預(yù)警公式的朋友
可聯(lián)系技術(shù)人員 QQ: 1145508240 進(jìn)行 有償 編寫!(不貴!點(diǎn)擊查看價(jià)格!)
相關(guān)文章
-
沒有相關(guān)內(nèi)容