diff --git a/uft_robot/bin/(20100812)GTJAQH-CFZJYJK-0000_3rd.dat b/uft_robot/bin/(20100812)GTJAQH-CFZJYJK-0000_3rd.dat
new file mode 100644
index 00000000..9eeeef05
Binary files /dev/null and b/uft_robot/bin/(20100812)GTJAQH-CFZJYJK-0000_3rd.dat differ
diff --git a/uft_robot/bin/HsFutuSDK.dll b/uft_robot/bin/HsFutuSDK.dll
new file mode 100644
index 00000000..a1e80049
Binary files /dev/null and b/uft_robot/bin/HsFutuSDK.dll differ
diff --git a/uft_robot/bin/flyingfish.dll b/uft_robot/bin/flyingfish.dll
new file mode 100644
index 00000000..404c2ef3
Binary files /dev/null and b/uft_robot/bin/flyingfish.dll differ
diff --git a/uft_robot/bin/fz_3rd.dat b/uft_robot/bin/fz_3rd.dat
new file mode 100644
index 00000000..9eeeef05
Binary files /dev/null and b/uft_robot/bin/fz_3rd.dat differ
diff --git a/uft_robot/bin/sh600328.day b/uft_robot/bin/sh600328.day
new file mode 100644
index 00000000..0d7b3426
Binary files /dev/null and b/uft_robot/bin/sh600328.day differ
diff --git a/uft_robot/bin/sjx_3rd.dat b/uft_robot/bin/sjx_3rd.dat
new file mode 100644
index 00000000..3363197a
Binary files /dev/null and b/uft_robot/bin/sjx_3rd.dat differ
diff --git a/uft_robot/bin/t2sdk.dll b/uft_robot/bin/t2sdk.dll
new file mode 100644
index 00000000..6142df2c
Binary files /dev/null and b/uft_robot/bin/t2sdk.dll differ
diff --git a/uft_robot/conf/ff_BB_100.ini b/uft_robot/conf/ff_BB_100.ini
new file mode 100644
index 00000000..0af1aa7f
--- /dev/null
+++ b/uft_robot/conf/ff_BB_100.ini
@@ -0,0 +1,27 @@
+[BB_100]
+ACT=100
+A_min=1800
+B_min=2600
+C_min=1200
+
+AB_max=5
+BC_max=5
+IA_min=8
+IA_max=18
+
+CUT=12.0
+STOP=18.0
+ADD=6.0
+
+#action
+F=1
+S=1
+T=1
+
+A=8
+
+BOX_Y=3800
+BOX_X=5
+
+
+#End Line£»Make This Line Is Last Line£»Do Not Delete This Line!
\ No newline at end of file
diff --git a/uft_robot/conf/ff_conf_file.ini b/uft_robot/conf/ff_conf_file.ini
new file mode 100644
index 00000000..cb39eb99
--- /dev/null
+++ b/uft_robot/conf/ff_conf_file.ini
@@ -0,0 +1,38 @@
+[0]
+#section name must from 0 .. N
+filename=../conf/ff_main.ini
+
+[1]
+#section name must from 0 .. N
+filename=../conf/ff_local.ini
+
+[2]
+#section name must from 0 .. N
+filename=../conf/ff_rsi.ini
+
+[3]
+#section name must from 0 .. N
+filename=../conf/ff_ma_bb.ini
+
+[4]
+#section name must from 0 .. N
+filename=../conf/ff_bb_100.ini
+
+[5]
+#section name must from 0 .. N
+filename=../conf/ff_m30_short.ini
+
+[6]
+#section name must from 0 .. N
+filename=../conf/ff_m30_long.ini
+
+[7]
+#section name must from 0 .. N
+filename=../conf/ff_short_1.ini
+
+
+
+
+
+
+#End Line£»Make This Line Is Last Line£»Do Not Delete This Line!
\ No newline at end of file
diff --git a/uft_robot/conf/ff_local.ini b/uft_robot/conf/ff_local.ini
new file mode 100644
index 00000000..247770c9
--- /dev/null
+++ b/uft_robot/conf/ff_local.ini
@@ -0,0 +1,34 @@
+[Main]
+FC=
+FCPWD=
+
+[FC]
+FC.0=
+VOL.0=1
+NAME.0=888
+VOL.0=1
+LONG_MAX.0=18
+SHORT_MAX.0=18
+
+
+[What]
+CODE=IF1305
+KONLY=0
+LS_CTRL=0
+MBM_ONLY=1
+
+NO_AUTOTRADE=1
+
+LONG_ONLY=1
+SHORT_ONLY=0
+
+LONG_NO_CUT=1
+SHORT_NO_CUT=0
+
+LONG_STOP_PRICE=8.88
+SHORT_STOP_PRICE=8.88
+
+
+#
+#End Line£»Make This Line Is Last Line£»Do Not Delete This Line!
+#
\ No newline at end of file
diff --git a/uft_robot/conf/ff_m30_long.ini b/uft_robot/conf/ff_m30_long.ini
new file mode 100644
index 00000000..f87adf87
--- /dev/null
+++ b/uft_robot/conf/ff_m30_long.ini
@@ -0,0 +1,26 @@
+[M30]
+A_min=1800
+B_min=2600
+C_min=1200
+
+AB_max=5
+BC_max=5
+IA_min=8
+IA_max=18
+
+CUT=12.0
+STOP=18.0
+ADD=6.0
+
+#action
+F=1
+S=0
+T=0
+
+A=8
+
+BOX_Y=800
+BOX_X=8
+
+
+#End Line£»Make This Line Is Last Line£»Do Not Delete This Line!
\ No newline at end of file
diff --git a/uft_robot/conf/ff_m30_short.ini b/uft_robot/conf/ff_m30_short.ini
new file mode 100644
index 00000000..a4af60b7
--- /dev/null
+++ b/uft_robot/conf/ff_m30_short.ini
@@ -0,0 +1,26 @@
+[M30]
+A_min=1800
+B_min=2600
+C_min=1200
+
+AB_max=5
+BC_max=5
+IA_min=8
+IA_max=18
+
+CUT=12.0
+STOP=18.0
+ADD=6.0
+
+#action
+F=1
+S=0
+T=0
+
+A=8
+
+BOX_Y=2800
+BOX_X=6
+
+
+#End Line£»Make This Line Is Last Line£»Do Not Delete This Line!
\ No newline at end of file
diff --git a/uft_robot/conf/ff_ma_bb.ini b/uft_robot/conf/ff_ma_bb.ini
new file mode 100644
index 00000000..74310484
--- /dev/null
+++ b/uft_robot/conf/ff_ma_bb.ini
@@ -0,0 +1,27 @@
+[M120BB]
+ACT=100
+A_min=1800
+B_min=2600
+C_min=1200
+
+AB_max=5
+BC_max=5
+IA_min=8
+IA_max=18
+
+CUT=12.0
+STOP=18.0
+ADD=6.0
+
+#action
+F=1
+S=1
+T=1
+
+A=8
+
+BOX_Y=1200
+BOX_X=7
+
+
+#End Line£»Make This Line Is Last Line£»Do Not Delete This Line!
\ No newline at end of file
diff --git a/uft_robot/conf/ff_main.ini b/uft_robot/conf/ff_main.ini
new file mode 100644
index 00000000..4083af20
--- /dev/null
+++ b/uft_robot/conf/ff_main.ini
@@ -0,0 +1,38 @@
+[Sever]
+#
+IP=10.100.202.5:2900
+
+IP=222.66.166.146:2900
+
+IP=10.100.202.5:2900
+#IP=10.100.202.5:2800
+
+
+#biz_license_str
+BLS=31332263F984F45D4B07689CB2371284
+#comm_license_file
+CLF=sjx_3rd.dat
+#entrust_type
+ENT=L
+
+[Kline]
+MA.0=5
+MA.1=10
+MA.2=20
+MA.3=30
+MA.4=50
+MA.5=60
+MA.6=120
+MA.7=200
+MA.8=250
+
+
+RSI.0=6
+RSI.1=12
+RSI.2=24
+RSI.3=9
+RSI.4=18
+RSI.5=36
+
+
+#End Line£»Make This Line Is Last Line£»Do Not Delete This Line!
\ No newline at end of file
diff --git a/uft_robot/conf/ff_rsi.ini b/uft_robot/conf/ff_rsi.ini
new file mode 100644
index 00000000..b00aacc4
--- /dev/null
+++ b/uft_robot/conf/ff_rsi.ini
@@ -0,0 +1,36 @@
+[W20]
+ACT=10
+A_min=1800
+B_min=2600
+C_min=1200
+
+AB_max=5
+BC_max=5
+IA_min=2
+IA_max=4
+
+CUT=32.0
+# for 0.6% index
+STOP=128.0
+# for 1%--10% index
+ADD=16.0
+# for 0.5% index
+
+# not use
+ADD_FLOSS_MAX=12
+
+
+#action
+F=1
+S=1
+T=0
+
+A=1
+
+BOX_Y=800
+
+M30=0
+M120=0
+
+
+#End Line£»Make This Line Is Last Line£»Do Not Delete This Line!
\ No newline at end of file
diff --git a/uft_robot/conf/ff_short_1.ini b/uft_robot/conf/ff_short_1.ini
new file mode 100644
index 00000000..4a27622c
--- /dev/null
+++ b/uft_robot/conf/ff_short_1.ini
@@ -0,0 +1,30 @@
+[Main]
+ACT=100
+A_min=1800
+B_min=2600
+C_min=1200
+
+AB_max=5
+BC_max=5
+IA_min=7
+IA_max=18
+
+CUT=12.0
+STOP=6.0
+ADD=6.0
+
+#action
+F=1
+S=1
+T=1
+
+A=8
+
+BOX_Y=800
+BOX_X=8
+
+M30=28
+M120=0
+
+
+#End Line£»Make This Line Is Last Line£»Do Not Delete This Line!
\ No newline at end of file
diff --git a/uft_robot/robot/bin/(20100812)GTJAQH-CFZJYJK-0000_3rd.dat b/uft_robot/robot/bin/(20100812)GTJAQH-CFZJYJK-0000_3rd.dat
new file mode 100644
index 00000000..9eeeef05
Binary files /dev/null and b/uft_robot/robot/bin/(20100812)GTJAQH-CFZJYJK-0000_3rd.dat differ
diff --git a/uft_robot/robot/bin/FF_300M.exe b/uft_robot/robot/bin/FF_300M.exe
new file mode 100644
index 00000000..ee9658f1
Binary files /dev/null and b/uft_robot/robot/bin/FF_300M.exe differ
diff --git a/uft_robot/robot/bin/HsFutuSDK.dll b/uft_robot/robot/bin/HsFutuSDK.dll
new file mode 100644
index 00000000..a1e80049
Binary files /dev/null and b/uft_robot/robot/bin/HsFutuSDK.dll differ
diff --git a/uft_robot/robot/bin/flyingfish.dll b/uft_robot/robot/bin/flyingfish.dll
new file mode 100644
index 00000000..404c2ef3
Binary files /dev/null and b/uft_robot/robot/bin/flyingfish.dll differ
diff --git a/uft_robot/robot/bin/fz_3rd.dat b/uft_robot/robot/bin/fz_3rd.dat
new file mode 100644
index 00000000..9eeeef05
Binary files /dev/null and b/uft_robot/robot/bin/fz_3rd.dat differ
diff --git a/uft_robot/robot/bin/sh600328.day b/uft_robot/robot/bin/sh600328.day
new file mode 100644
index 00000000..0d7b3426
Binary files /dev/null and b/uft_robot/robot/bin/sh600328.day differ
diff --git a/uft_robot/robot/bin/sjx_3rd.dat b/uft_robot/robot/bin/sjx_3rd.dat
new file mode 100644
index 00000000..3363197a
Binary files /dev/null and b/uft_robot/robot/bin/sjx_3rd.dat differ
diff --git a/uft_robot/robot/bin/t2sdk.dll b/uft_robot/robot/bin/t2sdk.dll
new file mode 100644
index 00000000..6142df2c
Binary files /dev/null and b/uft_robot/robot/bin/t2sdk.dll differ
diff --git a/uft_robot/robot/conf/ff_BB_100.ini b/uft_robot/robot/conf/ff_BB_100.ini
new file mode 100644
index 00000000..0af1aa7f
--- /dev/null
+++ b/uft_robot/robot/conf/ff_BB_100.ini
@@ -0,0 +1,27 @@
+[BB_100]
+ACT=100
+A_min=1800
+B_min=2600
+C_min=1200
+
+AB_max=5
+BC_max=5
+IA_min=8
+IA_max=18
+
+CUT=12.0
+STOP=18.0
+ADD=6.0
+
+#action
+F=1
+S=1
+T=1
+
+A=8
+
+BOX_Y=3800
+BOX_X=5
+
+
+#End Line£»Make This Line Is Last Line£»Do Not Delete This Line!
\ No newline at end of file
diff --git a/uft_robot/robot/conf/ff_conf_file.ini b/uft_robot/robot/conf/ff_conf_file.ini
new file mode 100644
index 00000000..cb39eb99
--- /dev/null
+++ b/uft_robot/robot/conf/ff_conf_file.ini
@@ -0,0 +1,38 @@
+[0]
+#section name must from 0 .. N
+filename=../conf/ff_main.ini
+
+[1]
+#section name must from 0 .. N
+filename=../conf/ff_local.ini
+
+[2]
+#section name must from 0 .. N
+filename=../conf/ff_rsi.ini
+
+[3]
+#section name must from 0 .. N
+filename=../conf/ff_ma_bb.ini
+
+[4]
+#section name must from 0 .. N
+filename=../conf/ff_bb_100.ini
+
+[5]
+#section name must from 0 .. N
+filename=../conf/ff_m30_short.ini
+
+[6]
+#section name must from 0 .. N
+filename=../conf/ff_m30_long.ini
+
+[7]
+#section name must from 0 .. N
+filename=../conf/ff_short_1.ini
+
+
+
+
+
+
+#End Line£»Make This Line Is Last Line£»Do Not Delete This Line!
\ No newline at end of file
diff --git a/uft_robot/robot/conf/ff_local.ini b/uft_robot/robot/conf/ff_local.ini
new file mode 100644
index 00000000..63e729b0
--- /dev/null
+++ b/uft_robot/robot/conf/ff_local.ini
@@ -0,0 +1,34 @@
+[Main]
+FC=XXXXXXXX
+FCPWD=XXXXXXXX
+
+[FC]
+FC.0=XXXXXXXX
+VOL.0=1
+NAME.0=888
+VOL.0=1
+LONG_MAX.0=18
+SHORT_MAX.0=18
+
+
+[What]
+CODE=IF1305
+KONLY=0
+LS_CTRL=0
+MBM_ONLY=1
+
+NO_AUTOTRADE=1
+
+LONG_ONLY=1
+SHORT_ONLY=0
+
+LONG_NO_CUT=1
+SHORT_NO_CUT=0
+
+LONG_STOP_PRICE=8.88
+SHORT_STOP_PRICE=8.88
+
+
+#
+#End Line£»Make This Line Is Last Line£»Do Not Delete This Line!
+#
\ No newline at end of file
diff --git a/uft_robot/robot/conf/ff_m30_long.ini b/uft_robot/robot/conf/ff_m30_long.ini
new file mode 100644
index 00000000..f87adf87
--- /dev/null
+++ b/uft_robot/robot/conf/ff_m30_long.ini
@@ -0,0 +1,26 @@
+[M30]
+A_min=1800
+B_min=2600
+C_min=1200
+
+AB_max=5
+BC_max=5
+IA_min=8
+IA_max=18
+
+CUT=12.0
+STOP=18.0
+ADD=6.0
+
+#action
+F=1
+S=0
+T=0
+
+A=8
+
+BOX_Y=800
+BOX_X=8
+
+
+#End Line£»Make This Line Is Last Line£»Do Not Delete This Line!
\ No newline at end of file
diff --git a/uft_robot/robot/conf/ff_m30_short.ini b/uft_robot/robot/conf/ff_m30_short.ini
new file mode 100644
index 00000000..a4af60b7
--- /dev/null
+++ b/uft_robot/robot/conf/ff_m30_short.ini
@@ -0,0 +1,26 @@
+[M30]
+A_min=1800
+B_min=2600
+C_min=1200
+
+AB_max=5
+BC_max=5
+IA_min=8
+IA_max=18
+
+CUT=12.0
+STOP=18.0
+ADD=6.0
+
+#action
+F=1
+S=0
+T=0
+
+A=8
+
+BOX_Y=2800
+BOX_X=6
+
+
+#End Line£»Make This Line Is Last Line£»Do Not Delete This Line!
\ No newline at end of file
diff --git a/uft_robot/robot/conf/ff_ma_bb.ini b/uft_robot/robot/conf/ff_ma_bb.ini
new file mode 100644
index 00000000..74310484
--- /dev/null
+++ b/uft_robot/robot/conf/ff_ma_bb.ini
@@ -0,0 +1,27 @@
+[M120BB]
+ACT=100
+A_min=1800
+B_min=2600
+C_min=1200
+
+AB_max=5
+BC_max=5
+IA_min=8
+IA_max=18
+
+CUT=12.0
+STOP=18.0
+ADD=6.0
+
+#action
+F=1
+S=1
+T=1
+
+A=8
+
+BOX_Y=1200
+BOX_X=7
+
+
+#End Line£»Make This Line Is Last Line£»Do Not Delete This Line!
\ No newline at end of file
diff --git a/uft_robot/robot/conf/ff_main.ini b/uft_robot/robot/conf/ff_main.ini
new file mode 100644
index 00000000..4083af20
--- /dev/null
+++ b/uft_robot/robot/conf/ff_main.ini
@@ -0,0 +1,38 @@
+[Sever]
+#
+IP=10.100.202.5:2900
+
+IP=222.66.166.146:2900
+
+IP=10.100.202.5:2900
+#IP=10.100.202.5:2800
+
+
+#biz_license_str
+BLS=31332263F984F45D4B07689CB2371284
+#comm_license_file
+CLF=sjx_3rd.dat
+#entrust_type
+ENT=L
+
+[Kline]
+MA.0=5
+MA.1=10
+MA.2=20
+MA.3=30
+MA.4=50
+MA.5=60
+MA.6=120
+MA.7=200
+MA.8=250
+
+
+RSI.0=6
+RSI.1=12
+RSI.2=24
+RSI.3=9
+RSI.4=18
+RSI.5=36
+
+
+#End Line£»Make This Line Is Last Line£»Do Not Delete This Line!
\ No newline at end of file
diff --git a/uft_robot/robot/conf/ff_rsi.ini b/uft_robot/robot/conf/ff_rsi.ini
new file mode 100644
index 00000000..b00aacc4
--- /dev/null
+++ b/uft_robot/robot/conf/ff_rsi.ini
@@ -0,0 +1,36 @@
+[W20]
+ACT=10
+A_min=1800
+B_min=2600
+C_min=1200
+
+AB_max=5
+BC_max=5
+IA_min=2
+IA_max=4
+
+CUT=32.0
+# for 0.6% index
+STOP=128.0
+# for 1%--10% index
+ADD=16.0
+# for 0.5% index
+
+# not use
+ADD_FLOSS_MAX=12
+
+
+#action
+F=1
+S=1
+T=0
+
+A=1
+
+BOX_Y=800
+
+M30=0
+M120=0
+
+
+#End Line£»Make This Line Is Last Line£»Do Not Delete This Line!
\ No newline at end of file
diff --git a/uft_robot/robot/conf/ff_short_1.ini b/uft_robot/robot/conf/ff_short_1.ini
new file mode 100644
index 00000000..4a27622c
--- /dev/null
+++ b/uft_robot/robot/conf/ff_short_1.ini
@@ -0,0 +1,30 @@
+[Main]
+ACT=100
+A_min=1800
+B_min=2600
+C_min=1200
+
+AB_max=5
+BC_max=5
+IA_min=7
+IA_max=18
+
+CUT=12.0
+STOP=6.0
+ADD=6.0
+
+#action
+F=1
+S=1
+T=1
+
+A=8
+
+BOX_Y=800
+BOX_X=8
+
+M30=28
+M120=0
+
+
+#End Line£»Make This Line Is Last Line£»Do Not Delete This Line!
\ No newline at end of file
diff --git a/uft_robot/robot/src/FF_300M.bdsproj b/uft_robot/robot/src/FF_300M.bdsproj
new file mode 100644
index 00000000..c15fb491
--- /dev/null
+++ b/uft_robot/robot/src/FF_300M.bdsproj
@@ -0,0 +1,187 @@
+
+
+
+
+
+
+
+
+
+
+
+ FF_300M.dpr
+
+
+ 7.0
+
+
+ 8
+ 0
+ 1
+ 1
+ 0
+ 0
+ 1
+ 1
+ 1
+ 0
+ 0
+ 1
+ 0
+ 1
+ 1
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 1
+ 1
+ 1
+ True
+ True
+ WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
+
+ False
+
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ False
+ False
+ False
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+
+
+
+ 0
+ 0
+ False
+ 1
+ False
+ False
+ False
+ 16384
+ 1048576
+ 4194304
+
+
+
+ F:\slog\FF300W_9113\bin_1
+
+
+
+
+
+
+
+ False
+
+
+
+
+
+ False
+
+
+ True
+ False
+
+
+ False
+
+
+ False
+ False
+ 1
+ 0
+ 0
+ 0
+ False
+ False
+ False
+ False
+ False
+ 2052
+ 936
+
+
+
+
+ 1.0.0.0
+
+
+
+
+
+ 1.0.0.0
+
+
+
+ Microsoft Office 2000 Sample Automation Server Wrapper Components
+ Microsoft Office XP Sample Automation Server Wrapper Components
+
+
+
+
diff --git a/uft_robot/robot/src/FF_300M.cfg b/uft_robot/robot/src/FF_300M.cfg
new file mode 100644
index 00000000..3ed94d45
--- /dev/null
+++ b/uft_robot/robot/src/FF_300M.cfg
@@ -0,0 +1,39 @@
+-$A8
+-$B-
+-$C+
+-$D+
+-$E-
+-$F-
+-$G+
+-$H+
+-$I+
+-$J-
+-$K-
+-$L+
+-$M-
+-$N+
+-$O+
+-$P+
+-$Q-
+-$R-
+-$S-
+-$T-
+-$U-
+-$V+
+-$W-
+-$X+
+-$YD
+-$Z1
+-cg
+-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
+-H+
+-W+
+-M
+-$M16384,1048576
+-K$00400000
+-E"C:\may\robot\bin"
+-LE"c:\program files\borland\delphi7\Projects\Bpl"
+-LN"c:\program files\borland\delphi7\Projects\Bpl"
+-w-UNSAFE_TYPE
+-w-UNSAFE_CODE
+-w-UNSAFE_CAST
diff --git a/uft_robot/robot/src/FF_300M.dof b/uft_robot/robot/src/FF_300M.dof
new file mode 100644
index 00000000..90ad758e
--- /dev/null
+++ b/uft_robot/robot/src/FF_300M.dof
@@ -0,0 +1,143 @@
+[FileVersion]
+Version=7.0
+[Compiler]
+A=8
+B=0
+C=1
+D=1
+E=0
+F=0
+G=1
+H=1
+I=1
+J=0
+K=0
+L=1
+M=0
+N=1
+O=1
+P=1
+Q=0
+R=0
+S=0
+T=0
+U=0
+V=1
+W=0
+X=1
+Y=1
+Z=1
+ShowHints=1
+ShowWarnings=1
+UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
+NamespacePrefix=
+SymbolDeprecated=1
+SymbolLibrary=1
+SymbolPlatform=1
+UnitLibrary=1
+UnitPlatform=1
+UnitDeprecated=1
+HResultCompat=1
+HidingMember=1
+HiddenVirtual=1
+Garbage=1
+BoundsError=1
+ZeroNilCompat=1
+StringConstTruncated=1
+ForLoopVarVarPar=1
+TypedConstVarPar=1
+AsgToTypedConst=1
+CaseLabelRange=1
+ForVariable=1
+ConstructingAbstract=1
+ComparisonFalse=1
+ComparisonTrue=1
+ComparingSignedUnsigned=1
+CombiningSignedUnsigned=1
+UnsupportedConstruct=1
+FileOpen=1
+FileOpenUnitSrc=1
+BadGlobalSymbol=1
+DuplicateConstructorDestructor=1
+InvalidDirective=1
+PackageNoLink=1
+PackageThreadVar=1
+ImplicitImport=1
+HPPEMITIgnored=1
+NoRetVal=1
+UseBeforeDef=1
+ForLoopVarUndef=1
+UnitNameMismatch=1
+NoCFGFileFound=1
+MessageDirective=1
+ImplicitVariants=1
+UnicodeToLocale=1
+LocaleToUnicode=1
+ImagebaseMultiple=1
+SuspiciousTypecast=1
+PrivatePropAccessor=1
+UnsafeType=0
+UnsafeCode=0
+UnsafeCast=0
+[Linker]
+MapFile=0
+OutputObjs=0
+ConsoleApp=1
+DebugInfo=0
+RemoteSymbols=0
+MinStackSize=16384
+MaxStackSize=1048576
+ImageBase=4194304
+ExeDescription=
+[Directories]
+OutputDir=C:\may\robot\bin
+UnitOutputDir=
+PackageDLLOutputDir=
+PackageDCPOutputDir=
+SearchPath=
+Packages=vcl;rtl;vclx;indy;inet;xmlrtl;vclie;inetdbbde;inetdbxpress;dbrtl;dsnap;dsnapcon;vcldb;soaprtl;VclSmp;dbexpress;dbxcds;inetdb;bdertl;vcldbx;webdsnap;websnap;adortl;ibxpress;teeui;teedb;tee;dss;visualclx;visualdbclx;vclactnband;vclshlctrls;IntrawebDB_50_70;Intraweb_50_70;Rave50CLX;Rave50VCL;dclOfficeXP
+Conditionals=
+DebugSourceDirs=
+UsePackages=0
+[Parameters]
+RunParams=
+HostApplication=
+Launcher=
+UseLauncher=0
+DebugCWD=
+[Language]
+ActiveLang=
+ProjectLang=
+RootDir=
+[Version Info]
+IncludeVerInfo=0
+AutoIncBuild=0
+MajorVer=1
+MinorVer=0
+Release=0
+Build=0
+Debug=0
+PreRelease=0
+Special=0
+Private=0
+DLL=0
+Locale=2052
+CodePage=936
+[Version Info Keys]
+CompanyName=
+FileDescription=
+FileVersion=1.0.0.0
+InternalName=
+LegalCopyright=
+LegalTrademarks=
+OriginalFilename=
+ProductName=
+ProductVersion=1.0.0.0
+Comments=
+[HistoryLists\hlUnitAliases]
+Count=1
+Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
+[HistoryLists\hlOutputDirectorry]
+Count=2
+Item0=C:\may\robot\bin
+Item1=C:\may\ff_300m_ex_wk\bin_1
diff --git a/uft_robot/robot/src/FF_300M.dpr b/uft_robot/robot/src/FF_300M.dpr
new file mode 100644
index 00000000..265ef954
--- /dev/null
+++ b/uft_robot/robot/src/FF_300M.dpr
@@ -0,0 +1,23 @@
+program FF_300M;
+
+uses
+ Forms,
+ fm_main in 'fm_main.pas' {MAINFORM},
+ do_beep_thread in 'do_beep_thread.pas',
+ ff_hs_base in 'ff_hs_base.pas',
+ s_lib_pas_unit in 's_lib_pas_unit.pas',
+ uFutuDataTypes in 'uFutuDataTypes.pas',
+ uFutuMessageInterface in 'uFutuMessageInterface.pas',
+ uFutuSdkInterface in 'uFutuSdkInterface.pas',
+ ff_dm in 'ff_dm.pas' {DM: TDataModule};
+
+{$R *.res}
+
+begin
+ Application.Initialize;
+ //Application.MainFormOnTaskbar := True;
+ Application.CreateForm(TMAINFORM, MAINFORM);
+ Application.CreateForm(TDM, DM);
+ Application.Run;
+end.
+
diff --git a/uft_robot/robot/src/FF_300M.dproj b/uft_robot/robot/src/FF_300M.dproj
new file mode 100644
index 00000000..0c9eb00f
--- /dev/null
+++ b/uft_robot/robot/src/FF_300M.dproj
@@ -0,0 +1,56 @@
+
+
+
+ {71aa6909-7e37-4b70-8ae1-1a082991afc4}
+ FF_300M.dpr
+ Debug
+ AnyCPU
+ DCC32
+ ..\..\FZ_FF300M_EX\bin_1\FF_300M.exe
+
+
+ 7.0
+ False
+ False
+ 0
+ F:\slog\FF300W_9113\bin_1
+ RELEASE
+
+
+ 7.0
+ DEBUG
+ F:\slog\FZ_FF300M_EX\bin_1
+
+
+ Delphi.Personality
+
+
+FalseTrueFalseFalseFalse1000FalseFalseFalseFalseFalse20529361.0.0.01.0.0.0
+
+
+
+
+ Microsoft Office 2000 Sample Automation Server Wrapper Components
+ Microsoft Office XP Sample Automation Server Wrapper Components
+ FF_300M.dprFalse
+
+
+
+
+ MainSource
+
+
+
+
+ TDataModule
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/uft_robot/robot/src/FF_300M.identcache b/uft_robot/robot/src/FF_300M.identcache
new file mode 100644
index 00000000..13dfcddf
Binary files /dev/null and b/uft_robot/robot/src/FF_300M.identcache differ
diff --git a/uft_robot/robot/src/FF_300M.res b/uft_robot/robot/src/FF_300M.res
new file mode 100644
index 00000000..e877da3f
Binary files /dev/null and b/uft_robot/robot/src/FF_300M.res differ
diff --git a/uft_robot/robot/src/do_beep_thread.dcu b/uft_robot/robot/src/do_beep_thread.dcu
new file mode 100644
index 00000000..cf31d5b0
Binary files /dev/null and b/uft_robot/robot/src/do_beep_thread.dcu differ
diff --git a/uft_robot/robot/src/do_beep_thread.pas b/uft_robot/robot/src/do_beep_thread.pas
new file mode 100644
index 00000000..d1778799
--- /dev/null
+++ b/uft_robot/robot/src/do_beep_thread.pas
@@ -0,0 +1,161 @@
+unit do_beep_thread;
+
+interface
+
+uses
+ Windows, Messages, SysUtils, Classes, s_lib_pas_unit;
+
+type
+ Tth_beep = class(TThread)
+ i_do_main_loop_mark: Integer;
+ private
+ { Private declarations }
+ protected
+ procedure Execute; override;
+ end;
+
+implementation
+uses ff_hs_base;
+
+procedure Tth_beep.Execute;
+var
+ iRet, i_loop_count: Integer;
+ s_tmp_log: string;
+begin
+ { Place thread code here }
+ //1.check time,loop,wait
+ //2.main loop
+
+ try
+
+ i_loop_count := 888;
+
+ Sleep(5000);
+
+ //frmMain2.GRID_S001.Cells[0,0]:=pc_what_wk;
+
+ if (i_comm_ok = 0) then
+ begin
+ //frmMain2.GRID_S006.Cells[0,0]:='¶Ï¿ª';
+ s_caption_3 := '¶Ï¿ª';
+ Exit;
+ end
+ else
+ begin
+ //frmMain2.GRID_S006.Cells[0,0]:='Áª»ú';
+ s_caption_3 := 'Áª»ú';
+ end;
+
+ //Sleep(15000);
+
+ while not Terminated do
+ begin
+ //Beep();
+ //s_sleep_us(2000000);
+
+ if i_do_main_loop_mark = 0 then
+ begin
+
+ iRet := 888;
+
+ if (not g_bStop) then
+ begin
+ if (WAIT_OBJECT_0 = WaitForSingleObject(g_hEvent, INFINITE)) then
+ //if(WAIT_OBJECT_0 = WaitForSingleObject(g_hEvent,1000) ) then
+ begin
+
+ if (i_comm_ok = 0) then
+ begin
+ //frmMain2.GRID_S006.Cells[0,0]:='¶Ï¿ª';
+ s_caption_3 := '¶Ï¿ª';
+ Exit;
+ end
+ else
+ begin
+ //frmMain2.GRID_S006.Cells[0,0]:='Áª»ú';
+ s_caption_3 := 'Áª»ú';
+ end;
+
+ //Í˳ö
+ if g_bStop then
+ begin
+ Exit;
+ end;
+
+ while (iRet <> 0) do
+ begin
+ try
+ W_Log('Call Start', 8, 999, 'check lpComm_Start here!');
+ //Sleep(1000);
+
+ //for tasks restart
+ ExitProcess(9);
+
+ iRet := m_lpComm.Start(g_iType);
+ if (iRet = 0) then
+ begin
+ i_comm_ok := 888;
+ ResetEvent(g_hEvent);
+ break;
+ end;
+ Sleep(1000);
+
+ except
+ W_Log('try_except', 9, 999, 'lpComm_Start exception');
+ end;
+ end;
+
+ end;
+ end;
+ end
+ else
+ begin
+ //s_sleep_us(300000);
+ s_sleep_us(200000);
+
+ try
+
+ if (i_loop_count mod 100 = 0) then ff_get_qty();
+
+ if (i_ff_get_qty_88 > 0) then
+ begin
+ i_ff_get_qty_88 := i_ff_get_qty_88 - 2;
+ ff_get_qty();
+ end;
+
+ except
+ on E: Exception do
+ begin
+ //Assert(false,s_tmp_log);
+ //W_Log('ff_get_qty',19,999,PChar(s_tmp_log));
+ W_Log('ff_get_qty', 19, 999, PChar(E.Message));
+ ExitProcess(999);
+ end;
+ end;
+
+ try
+ ff_main_wk_loop();
+ except
+ on E: Exception do
+ begin
+ //Assert(false,s_tmp_log);
+ //W_Log('ff_main_wk_loop',i_line_no_001,999,PChar(s_tmp_log));
+ W_Log('ff_main_wk_loop', i_line_no_001, 999, PChar(E.Message));
+ ExitProcess(999);
+ end;
+ end;
+
+ //if( i_loop_count mod 18 =0 ) then ff_get_qty();
+ //if( i_loop_count mod 2 =0 ) then ff_main_wk_loop();
+ i_loop_count := i_loop_count + 1;
+ if (i_loop_count > 88888888) then i_loop_count := 0;
+ end;
+ end;
+
+ finally
+ ExitProcess(999);
+ end;
+
+end;
+
+end.
diff --git a/uft_robot/robot/src/ff_dm.dcu b/uft_robot/robot/src/ff_dm.dcu
new file mode 100644
index 00000000..16f1c9d3
Binary files /dev/null and b/uft_robot/robot/src/ff_dm.dcu differ
diff --git a/uft_robot/robot/src/ff_dm.dfm b/uft_robot/robot/src/ff_dm.dfm
new file mode 100644
index 00000000..6c8290b7
--- /dev/null
+++ b/uft_robot/robot/src/ff_dm.dfm
@@ -0,0 +1,5 @@
+object DM: TDM
+ OldCreateOrder = False
+ Height = 381
+ Width = 581
+end
diff --git a/uft_robot/robot/src/ff_dm.pas b/uft_robot/robot/src/ff_dm.pas
new file mode 100644
index 00000000..952a5802
--- /dev/null
+++ b/uft_robot/robot/src/ff_dm.pas
@@ -0,0 +1,23 @@
+unit ff_dm;
+
+interface
+
+uses
+ SysUtils, Classes;
+
+type
+ TDM = class(TDataModule)
+ private
+ { Private declarations }
+ public
+ { Public declarations }
+ end;
+
+var
+ DM: TDM;
+
+implementation
+
+{$R *.dfm}
+
+end.
diff --git a/uft_robot/robot/src/ff_hs_base.dcu b/uft_robot/robot/src/ff_hs_base.dcu
new file mode 100644
index 00000000..5b25e78b
Binary files /dev/null and b/uft_robot/robot/src/ff_hs_base.dcu differ
diff --git a/uft_robot/robot/src/ff_hs_base.pas b/uft_robot/robot/src/ff_hs_base.pas
new file mode 100644
index 00000000..11b75f69
--- /dev/null
+++ b/uft_robot/robot/src/ff_hs_base.pas
@@ -0,0 +1,6028 @@
+unit ff_hs_base;
+
+{
+//ff_300m_ex for ¶àÕË»§Ò»¼üϵ¥
+
+//
+}
+interface
+uses
+ Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, DateUtils,
+ Dialogs, uFutuDataTypes, uFutuMessageInterface, uFutuSdkInterface, fm_main, s_lib_pas_unit,
+ do_beep_thread;
+
+const
+ HSFUSDKDLL = 'HsFutuSDK.DLL';
+
+
+type
+ ////////////////////////¼Ì³Ð»Øµ÷½Ó¿Ú//////////////////////////////////
+ TMyFuCallBack = class(IFuCallBack)
+ public
+ //²éѯ
+ function QueryInterface(const iid: PChar; ppv: Pointer): Integer; override; stdcall;
+
+ //ÒýÓýӿڣ¬ÒýÓüÆÊý¼ÓÒ»
+ function AddRef(): Integer; override; stdcall;
+
+ //ÊͷŽӿڣ¬ÒýÓüÆÊý¼õÒ»£¬¼ÆÊýΪ0ʱÊͷŽӿڵÄʵÏÖ¶ÔÏó
+ function Release(): Integer; override; stdcall;
+
+ //Á¬½Ó״̬µÄ¸Ä±ä
+ procedure OnConnStateNotify(lpInst: Pointer; iType: Integer; iRet: Integer;
+ const szNotifyTime: PChar;
+ const szMsg: PChar); override; stdcall;
+
+ //µÇ½Ӧ´ðÏûÏ¢
+ procedure OnRspLogin(lpInst: Pointer; lpMsg: IFuMessage); override; stdcall;
+
+ //µÇ³ö·´À¡
+ procedure OnRspLogout(lpInst: Pointer; lpMsg: IFuMessage); override; stdcall;
+
+ //¶©ÔÄ\Í˶©ÐÐÇé»òÕ߻ر¨µÄ½á¹û
+ procedure OnRspSubResult(lpInst: Pointer; sType: REGType;
+ aAction: REGAction; iResult: Integer;
+ const lpParam: PChar; const szMsg: PChar); override; stdcall;
+
+ //ÒµÎñ½ÓÊÕµ½ÒµÎñÓ¦´ðÏûÏ¢
+ procedure OnReceivedBiz(lpInst: Pointer; lpAnsData: IFuMessage; iRet: Integer; iKeyID: Integer); override; stdcall;
+
+ //½ÓÊÕµ½µ¥ÍÈÊг¡ÐÐÇé
+ procedure OnRspMarketInfo(lpInst: Pointer; const lpData: LPCMarketInfo; rAction: REGAction); override; stdcall;
+
+ //½ÓÊÕµ½×éºÏÊг¡ÐÐÇé
+ procedure OnRspArgMaketInfo(lpInst: Pointer; const lpData: LPCArgMarketInfo; rAction: REGAction); override; stdcall;
+
+ //½ÓÊÕµ½Î¯Íз´À¡ÏûÏ¢
+ procedure OnRecvOrderInfo(lpInst: Pointer; const lpInfo: LPCOrderRspInfo); override; stdcall;
+
+ //½ÓÊÕµ½¶©µ¥³É½»·´À¡
+ procedure OnRecvOrderRealInfo(lpInst: Pointer; const lpInfo: LPCRealRspInfo); override; stdcall;
+
+ //ÔÚÏ߸öÈËÏûÏ¢
+ procedure OnRspOnlineMsg(lpInst: Pointer; szUsrID: PChar; szMessage: PChar); override; stdcall;
+ end;
+ /////////////////////////////////////////////////////////////////////
+
+ /////////////////////////////////////////SDKµ¼³ö½Ó¿Ú////////////////////////////////////////
+ { /**
+ * ²úÉúÒ»ÌõеÄÏûÏ¢
+ *@param iMsgType ÏûÏ¢ÀàÐÍ,Çë²Î¿¼ÓÐЧµÄÏûÏ¢ÀàÐͶ¨Òå
+ *return ·ÇNULL±íʾһÌõÓÐЧµÄÏûÏ¢,NULL±íʾ·ÖÅäÄÚ´æʧ°Ü
+ [Ḭ̈߳²È«]
+ */}
+function NewFuMessage(iMsgType: Integer = -1; iMsgMode: Integer = -1): IFuMessage; stdcall; external HSFUSDKDLL;
+
+ {/**
+ * ´´½¨ÐµÄϵͳÁ¬½Ó¶ÔÏó
+ *@param lpReserved ±£Áô²ÎÊý,V1°æ±¾±ØÐëÖÃΪNULL
+ *@return ¶ÔÏó½Ó¿Ú¶ÔÏóÖ¸Õë(¿ÉÒÔµ÷ÓÃÆäÄڵĺ¯ÊýʵÏÖ)
+ [Ḭ̈߳²È«]
+ */}
+function NewFuCommObj(lpReserved: Pointer = nil): Pointer; stdcall;
+external HSFUSDKDLL name 'NewFuCommObj';
+
+ {/**
+ * »ñÈ¡°æ±¾ºÅ
+ @return °æ±¾ºÅ,Ê®Áù½øÖÆÊý¾Ý,ÀýÈç0x10000000,±íʾ°æ±¾Îª1.0.0.0
+ [Ḭ̈߳²È«]
+ */}
+function GetSDKVersion(): Integer; stdcall; external HSFUSDKDLL;
+ /////////////////////////////////////////SDKµ¼³ö½Ó¿Ú////////////////////////////////////////
+
+const
+ m_ma_max_index = 11; //for 12 :0..11
+
+type
+ //Ϊ¼æÈÝÐÔͳһÒÔ4×Ö½Ú¶ÔÆë,·ñÔòÓÐÊý¾Ý¶ÔÆëµÄÎÊÌâ
+{$A4}
+ // µ¥ÍÈÐÐÇé
+ LP_s_k_line_data = ^s_k_line_data;
+ s_k_line_data = record
+ i_date: Cardinal;
+ i_open: Cardinal;
+ i_high: Cardinal;
+ i_low: Cardinal;
+ i_close: Cardinal;
+ f_amount: Single;
+ i_vol: Cardinal;
+ i_pre_close: Cardinal;
+ end;
+
+ LP_s_k_line_ma_rsi = ^s_k_line_ma_rsi;
+ s_k_line_ma_rsi = record
+ ai_ma: array[0..m_ma_max_index] of Cardinal;
+ ai_rsi: array[0..5] of Cardinal;
+ end;
+
+
+ LP_s_fc_data = ^s_fc_data;
+
+ s_fc_data = record
+ pc_username: PChar;
+ pc_xxx_name: PChar;
+ pc_fcpwd: PChar;
+
+ i_VOL: Integer;
+ i_long_max: Integer;
+ i_short_max: Integer;
+
+ i_got_it_mark: Integer;
+ i_short_mark: Integer;
+ i_rights_balance: Integer;
+
+ f_rights_balance: Single;
+ f_short_price: Single;
+ f_business_price: Single;
+
+ end;
+
+ LP_s_vol_data = ^s_vol_data;
+
+ s_vol_data = record
+ tm_0: TDateTime;
+ i_business_amount: Integer;
+ i_VOL: Integer;
+ end;
+
+const
+ m_i_max_chg_kline_in_mem = 18888;
+
+ //for F9
+ m_bsk_ask_long = 1;
+ //for F10
+ m_bsk_bid_long = 2;
+ //for F11
+ m_bsk_bid_short = 3;
+ //for F12
+ m_bsk_ask_short = 4;
+
+ m_bsk_clear_long = 5;
+ m_bsk_clear_short = 6;
+
+ m_mairu = '1';
+ m_maichu = '2';
+ m_kaicang = '1';
+ m_pingcang = '2';
+ m_jiaoge = '3';
+ m_pingjin = '4';
+
+ m_i_long = 1;
+ m_i_short = 2;
+
+ m_k_line_file_name = 'sh600328.day';
+ m_USER_NAME = 'XXXXXXX';
+ m_USER_PWD = 'XXXXXXX';
+
+ m_ff_main_ini = '../conf/ff_main.ini';
+ m_ff_rsi_ini = '../conf/ff_rsi.ini';
+ m_ff_local_ini = '../conf/ff_local.ini';
+ m_ff_ma120_ini = '../conf/ff_ma_bb.ini';
+ m_ff_bb100_ini = '../conf/ff_bb_100.ini';
+ m_ff_m30_short_ini = '../conf/ff_m30_short.ini';
+ m_ff_m30_long_ini = '../conf/ff_m30_long.ini';
+ m_ff_short_1_ini = '../conf/ff_short_1.ini';
+ m_ff_action_ini = '../conf/ff_action.ini';
+
+var
+ i_show_string_grid: Integer = 0;
+ i_do_ff_qty_loop: Integer = 0;
+
+ i_open_price: Integer = 0;
+ i_open_vol: Integer = 0;
+ i_open_vol_wk: Integer = 0;
+
+ c_open_price: array[0..88] of Char;
+ c_open_price_0: array[0..88] of Char;
+ c_open_price_1: array[0..88] of Char;
+
+ //for vol ,up power
+ i_chk_power_vol_set: Integer = 5000;
+
+ i_chk_power_vol_wk: Integer = 5000;
+
+ i_up_count_ex: Integer = 0;
+ i_down_count_ex: Integer = 0;
+ i_up_vol_sum: Integer = 0;
+ i_down_vol_sum: Integer = 0;
+
+
+ //for vol display
+ i_vol_start: Integer = 0;
+ i_vol_reset: Integer = 0;
+ i_vol_stop: Integer = 0;
+
+ i_vol_0: Integer = 0;
+
+ tdt_vol_0: TDateTime;
+ i_vol_1: Integer = 0;
+
+ tdt_vol_1: TDateTime;
+
+
+ as_vol_data: array[0..88] of s_vol_data;
+
+ i_clr_long_1_mark: Integer = 0;
+ i_clr_short_1_mark: Integer = 0;
+
+ i_clr_long_to_001_mark: Integer = 0;
+ i_clr_short_to_001_mark: Integer = 0;
+
+ //for stop
+ i_stp_long: Integer = 0;
+ i_stp_short: Integer = 0;
+
+ i_act_stp_long: Integer = 0;
+ i_act_stp_short: Integer = 0;
+
+ i_set_stp_long: Integer = 0;
+ i_set_stp_short: Integer = 0;
+
+ i_set_stp_long_wk: Integer = 0;
+ i_set_stp_short_wk: Integer = 0;
+
+ i_act_stp_long_mark: Integer = 0;
+ i_act_stp_short_mark: Integer = 0;
+
+ i_stp_delta: Integer = 3;
+
+
+
+
+ i_lock_long: Integer = 0;
+ i_lock_short: Integer = 0;
+
+ i_cut_lock_long: Integer = 0;
+ i_cut_lock_short: Integer = 0;
+
+ i_set_lock_long: Integer = 0;
+ i_set_lock_short: Integer = 0;
+
+ i_set_lock_long_wk: Integer = 0;
+ i_set_lock_short_wk: Integer = 0;
+
+ i_cut_lock_long_mark: Integer = 0;
+ i_cut_lock_short_mark: Integer = 0;
+
+ i_delta: Integer = 12;
+
+ i_open_delta: Integer = 12;
+ i_close_delta: Integer = 12;
+
+
+ i_only_1: Integer = 0;
+ i_fc_count: Integer = 0;
+ i_fc_wk_index: Integer = 0;
+ i_fc_wk_index_bak: Integer = 88;
+ as_fc_data: array[0..88] of s_fc_data;
+
+ c_error_no: array[0..88] of Char;
+ c_error_info: array[0..888] of Char;
+
+ pc_open_long_time: PChar = nil;
+ pc_open_short_time: PChar = nil;
+ pc_close_long_time: PChar = nil;
+ pc_close_short_time: PChar = nil;
+
+ //<0 for disable
+ //=0 for enable ,just wait to do it
+ //>0 for had did
+ i_open_long_timer: Integer = -8;
+ i_open_short_timer: Integer = -8;
+ i_close_long_timer: Integer = -8;
+ i_close_short_timer: Integer = -8;
+
+var
+ i_lock_for_main_loop: Integer = 0;
+
+ s_edit_text_1: string = ' ';
+ s_edit_text_2: string = ' ';
+
+ s_caption_1: string = ' ';
+ s_caption_2: string = ' ';
+ s_caption_3: string = ' ';
+ s_caption_4: string = ' ';
+ s_caption_5: string = ' ';
+ s_caption_6: string = ' ';
+ s_caption_7: string = ' ';
+ s_caption_8: string = ' ';
+ s_caption_9: string = ' ';
+ s_caption_10: string = ' ';
+ s_caption_11: string = ' ';
+ s_caption_12: string = ' ';
+ s_caption_13: string = ' ';
+ s_caption_14: string = ' ';
+ s_caption_15: string = ' ';
+ s_caption_16: string = ' ';
+
+ s_caption_vol: string = ' ';
+ s_caption_long_stp: string = ' ';
+ s_caption_short_stp: string = ' ';
+ s_caption_status: string = ' ';
+
+var
+ i_line_no_001: Integer;
+ i_line_no_002: Integer;
+ i_line_no_003: Integer;
+ i_line_no_004: Integer;
+ i_line_no_005: Integer;
+ i_line_no_006: Integer;
+ i_line_no_007: Integer;
+ i_line_no_008: Integer;
+
+ i_loop_count_001: Integer = 0;
+
+
+var
+ ai_ma_set: array[0..11] of Integer = (5, 10, 20, 30, 50, 60, 120, 200, 250, 600, 1200, 2400);
+ ai_rsi_set: array[0..5] of Integer = (6, 12, 24, 9, 18, 36);
+
+ m_lpComm: IHsFutuComm;
+ m_lpCallBack: TMyFuCallBack;
+
+ i_comm_ok: Integer = 0;
+
+ i_ff_get_qty_88: Integer = 0;
+ i_ff_get_qty_flag: Integer = 0;
+
+ th_beep: Tth_beep;
+ th_main_loop: Tth_beep;
+ i_beeping: Integer = 0;
+
+ g_hEvent: THANDLE;
+ g_iType: Integer = 0;
+ g_bStop: Boolean = False;
+
+ tm_0: TDateTime;
+ tm_1: TDateTime;
+ tm_2: TDateTime;
+
+ i_as_k_chg_init_flag: Integer = 0;
+ i_s_k_chg_index_wk: Integer = 0;
+ i_s_k_chg_index_wk_bak: Integer = 0;
+ i_s_k_chg_index_load: Integer = 0;
+ i_as_k_base_init_flag: Integer = 0;
+
+ as_k_chg: array[0..m_i_max_chg_kline_in_mem] of s_k_line_data;
+ as_k_chg_ma_rsi: array[0..m_i_max_chg_kline_in_mem] of s_k_line_ma_rsi;
+ i_get_price_count: Integer = 0;
+
+ iFileHandle: Integer;
+
+ i_will_close_market: Integer = 0;
+
+var
+ i_no_trade: Integer = 0;
+
+ i_only_short: Integer = 0;
+
+ i_only_long: Integer = 0;
+ i_mbm_only: Integer = 0;
+
+ i_short_stop_index: Integer = 0;
+ i_long_stop_index: Integer = 0;
+
+ i_sum_short_mbm_count: Integer = 0;
+ i_sum_long_mbm_count: Integer = 0;
+
+ i_sum_4ma_short_mbm_count: Integer = 0;
+ i_sum_4ma_long_mbm_count: Integer = 0;
+
+ //for Big Money
+ i_mbm_long: Integer = 888;
+ i_mbm_short: Integer = 888;
+
+ i_4ma_mbm_long: Integer = 888;
+ i_4ma_mbm_short: Integer = 888;
+
+ i_short_mbm_mark: Integer = 0;
+ i_long_mbm_mark: Integer = 0;
+
+ i_4ma_short_mbm_mark: Integer = 0;
+ i_4ma_long_mbm_mark: Integer = 0;
+
+ i_short_mbm_count: Integer = 0;
+ i_long_mbm_count: Integer = 0;
+
+ i_4ma_short_mbm_count: Integer = 0;
+ i_4ma_long_mbm_count: Integer = 0;
+
+ i_long_mbm_count_action_1: Integer = 0;
+ i_short_mbm_count_action_1: Integer = 0;
+
+ i_short_mbm_count_bak: Integer = 0;
+ i_long_mbm_count_bak: Integer = 0;
+
+ i_4ma_short_mbm_count_bak: Integer = 0;
+ i_4ma_long_mbm_count_bak: Integer = 0;
+
+ i_short_mbm_index: Integer = 0;
+ i_long_mbm_index: Integer = 0;
+
+ i_short_mbm_index_1: Integer = 0;
+ i_long_mbm_index_1: Integer = 0;
+
+ i_last_120ma250eq_index: Integer = 0;
+
+ f_mbm_cut_long: Single = 0.0;
+ f_mbm_stop_long: Single = 0.0;
+
+ f_mbm_cut_short: Single = 0.0;
+ f_mbm_stop_short: Single = 0.0;
+
+ i_short_long_01: Integer = 888;
+ i_short_long_date: Integer = 0;
+ i_short_long_index: Integer = 888;
+
+ i_wk_log: Integer = 8;
+ i_debug_log: Integer = 0;
+ i_tmp_log: Integer = -1;
+ i_mbm_log: Integer = 28;
+
+ i_make_log_ex: Integer = -1;
+
+ i_make_ex_test: Integer = 0;
+ i_make_k_only: Integer = 0;
+
+ i_long_short_ctrl: Integer = 0;
+
+ i_make_long_mark: Integer = 0;
+ i_got_it_mark: Integer = 0;
+
+ i_long_act_flag: Integer = -1;
+ i_short_act_flag: Integer = -1;
+
+ i_make_short_mark: Integer = 0;
+
+ i_short_mark: Integer = 0;
+ f_short_price: Single;
+ f_business_price: Single;
+
+ i_got_it_mark_ex: Integer = 0;
+ i_short_mark_ex: Integer = 0;
+ f_short_price_ex: Single;
+ f_business_price_ex: Single;
+
+
+ f_last_price_wk: Single = 0.0;
+ f_last_price_1: Single = 0.0;
+ f_price_A: Single = 0.0;
+
+ f_buy_1: Single = 0.0;
+ f_sale_1: Single = 0.0;
+
+ i_BSK: Integer = 0;
+
+ i_stop_check_count: Integer = 0;
+ i_stop_short_count: Integer = 0;
+
+ c_entrust_no: array[0..88] of Char;
+ c_batch_no: array[0..88] of Char;
+
+ c_rights_balance: array[0..88] of Char;
+ i_rights_balance: Integer = 0;
+ f_rights_balance: Single = 0.0;
+
+ i_entrust_no_mark: Integer = 0;
+
+var
+ pc_username: PChar;
+ pc_user_pwd: PChar;
+
+ pc_what_wk: PChar;
+
+ pc_IP: PChar;
+ pc_BLS: PChar;
+ pc_CLF: Pchar;
+ pc_ENT: Pchar;
+
+ i_rsi_A: Integer = 1800;
+ i_rsi_B: Integer = 2800;
+ i_rsi_C: Integer = 1800;
+
+ i_rsi_AB: Integer = 6;
+ i_rsi_BC: Integer = 6;
+ i_rsi_IA_min: Integer = 8;
+ i_rsi_IA_max: Integer = 18;
+
+ f_rsi_stop: Single = 18.0;
+ f_rsi_cut: Single = 12.0;
+
+ f_rsi_stop_long: Single = 18.0;
+ f_rsi_stop_short: Single = 18.0;
+
+ f_rsi_cut_long: Single = 0.0;
+ f_rsi_cut_short: Single = 0.0;
+
+ f_rsi_add: Single = 8.0;
+ i_F: Integer = 1;
+ i_S: Integer = 1;
+ i_T: Integer = 1;
+ i_A: Integer = 1;
+
+ i_M30: Integer = 30;
+ i_M30_stop: Integer = 0;
+
+ i_M120: Integer = 0;
+ i_M120_stop: Integer = 0;
+
+ i_BOX_Y: Integer = 8;
+
+ i_get_S_mark: Integer = 0;
+ i_get_T_mark: Integer = 0;
+ i_short_S_mark: Integer = 0;
+ i_short_T_mark: Integer = 0;
+
+ i_w20_mark: Integer = 0;
+ i_w20_A_index: Integer = 0;
+ i_w20_B_index: Integer = 0;
+ i_w20_C_index: Integer = 0;
+
+ i_MA120_BB_mark: Integer = 0;
+ i_MA120_BB_n: Integer = 0;
+ i_MA120_BB_c: Integer = 0;
+ i_MA120_BB_i: Integer = 0;
+
+ i_BB_BOX_X: Integer = 8;
+ i_BB_BOX_Y: Integer = 800;
+
+ i_M30_short_mark: Integer = 0;
+ i_M30_short_n: Integer = 0;
+ i_M30_short_c: Integer = 0;
+ i_M30_short_i: Integer = 0;
+
+ i_M30_short_BOX_X: Integer = 8;
+ i_M30_short_BOX_Y: Integer = 2800;
+
+
+
+var
+ i_BB_100_BOX_X: Integer = 8;
+ i_BB_100_BOX_Y: Integer = 3800;
+ i_BB_100_mark: Integer = 0;
+ i_BB_100_n: Integer = 0;
+ i_BB_100_c: Integer = 0;
+ i_BB_100_i: Integer = 0;
+
+ i_MA120_120_chg: Integer = 0;
+ i_make_long: integer = 0;
+ i_make_short: Integer = 0;
+
+ i_short_1_mark: Integer = 0;
+ i_short_250_mark: Integer = 0;
+ i_short_30_mark: Integer = 0;
+ i_short_120_mark: Integer = 0;
+
+ i_pass3_short_120_mark: Integer = 0;
+
+ i_pass_3_mark: Integer = 0;
+ i_pass_3_mark_ex: Integer = 0;
+
+ i_act_rsi: Integer = 10;
+ i_act_m120: Integer = 10;
+ i_act_bb_100: Integer = 10;
+ i_act_short: Integer = 10;
+
+ i_B_S_Flag: Integer = 0;
+ i_B_S_Flag_10: Integer = 0;
+ i_B_S_Flag_18: Integer = 0;
+
+ i_B_Flag: Integer = 0;
+ i_S_Flag: Integer = 0;
+
+ i_short_pass3_mark: Integer = 0;
+
+ i_ADD_FLOSS_MAX: Integer = 0;
+ i_long_FLOSS_MAX: Integer = 0;
+ i_short_FLOSS_MAX: Integer = 0;
+
+var
+ MAINFORM: TMAINFORM;
+
+function ff_chk_power_vol(i: Integer): Integer;
+
+function ff_set_caption(): Integer;
+
+function ff_load_k_base(): Integer;
+
+function ff_rsi_w20_init(): Boolean;
+
+function FF_creat_comm_obj(): Boolean;
+function FF_release_comm_obj(): Boolean;
+function FF_comm_obj_init(): Boolean;
+function FF_do_logout(pc_fund_account: PChar): Boolean;
+
+function ff_make_ma_rsi_ex(ii: Integer): Integer;
+function ff_make_ma_rsi(): Integer;
+function ff_get_ma(i: Integer; j: Integer): Integer;
+function ff_get_rsi(ii: Integer; jj: Integer): Integer;
+function ff_get_max_ij_high(i: Integer; j: Integer): Integer;
+function ff_get_min_ij_low(i: Integer; j: Integer): Integer;
+function ff_get_max_ij_index(i: Integer; j: Integer): Integer;
+function ff_get_min_ij_index(i: Integer; j: Integer): Integer;
+
+function ff_check_rsi_w20(i: Integer): Integer;
+function ff_check_rsi_w20_ex(i: Integer): Integer;
+function ff_check_MA120_BB(i: Integer; i_ma_index: Integer): Integer;
+function ff_check_MA120_BB_ex(i: Integer): Integer;
+
+function ff_check_BB_100(i: Integer; i_ma_index: Integer): Integer;
+function ff_check_BB_100_ex(i: Integer): Integer;
+
+function ff_get_S_L_Mark(i: Integer): Integer;
+function ff_get_BS_Mark(i: Integer): Integer;
+function ff_get_long_mark_8(i: Integer): Integer;
+function ff_get_ma600_mark(i: Integer): Integer;
+function ff_get_ma600_mark_long(i: Integer): Integer;
+
+function ff_check_M30_short(i: Integer): Integer;
+function ff_check_M30_short_ex(i: Integer): Integer;
+
+
+
+function ff_check_short_1(i: Integer): Integer;
+function ff_check_short_1_ex(i: Integer): Integer;
+
+function ff_check_short_250(i: Integer): Integer;
+function ff_check_short_30(i: Integer): Integer;
+function ff_check_short_120(i: Integer): Integer;
+function ff_check_long_pass_3(i: Integer): Integer;
+function ff_long_pass_3_ex(i: Integer): Integer;
+
+function ff_make_long_MA30(i: Integer): Integer;
+function ff_make_long_MA60(i: Integer): Integer;
+function ff_make_long_MA250(i: Integer): Integer;
+
+function ff_short_pass3_mark(i: Integer): Integer;
+//function ff_pass3_short_250(i:Integer):Integer;
+function ff_pass3_short_120(i: Integer): Integer;
+
+
+function ff_make_mbm_long(i: Integer): Integer;
+function ff_make_mbm_short(i: Integer): Integer;
+
+function ff_4ma_make_mbm_long(i: Integer): Integer;
+function ff_4ma_make_mbm_short(i: Integer): Integer;
+
+function ff_main_wk_loop(): Integer;
+function ff_get_qty(): Integer;
+function ff_get_qty_ex(): Integer;
+
+function ff_get_profit(): Integer;
+
+function ff_cancel_entrust_no(): Integer;
+function ff_entrust_no(pc_contract_code: PChar): Integer;
+function ff_order_ex(
+ pc_contract_code: PChar;
+ pc_entrust_price: PChar;
+ pc_entrust_amount: PChar;
+ pc_entrust_bs: PChar;
+ pc_direction: PChar): Integer;
+
+function ff_passwd_chg(
+ pc_account: PChar;
+ pc_password_type: PChar;
+ pc_old_password: PChar;
+ pc_new_password: PChar): Integer;
+
+
+function do_beep(): Boolean;
+function ff_stop_do_beep(): Boolean;
+
+function ff_do_main_loop(): Integer;
+
+
+implementation
+
+//³õʼ»¯Í¨ÐŶÔÏó
+
+function FF_creat_comm_obj(): Boolean;
+var
+ i, j, i_count, j_count, k_count: Integer;
+ i_tmp, j_tmp, k_tmp: Integer;
+ i_index, j_index, k_index: Integer;
+
+
+ i_count_1, j_count_1, k_count_1: Integer;
+ i_tmp_1, j_tmp_1, k_tmp_1: Integer;
+ i_index_1, j_index_1, k_index_1: Integer;
+ s_tmp_log: string;
+
+begin
+ Result := False;
+
+ FF_load_allconf();
+ ff_rsi_w20_init();
+ ff_load_k_base();
+
+
+ //only for test
+ i_make_ex_test := 0;
+ i_count := 0;
+ j_count := 0;
+ k_count := 0;
+
+ i_count_1 := 0;
+ j_count_1 := 0;
+ k_count_1 := 0;
+
+ //Assert(false,s_tmp_log);
+
+ if i_make_ex_test > 0 then for j := 80 to i_s_k_chg_index_wk - 2 do
+ begin
+
+ f_last_price_wk := as_k_chg[j].i_close / 100;
+
+ if (Round(as_k_chg[j].i_date / 10000) > Round(as_k_chg[j - 1].i_date / 10000)) then
+ begin
+ W_Log('MBM long sum', as_k_chg[j].i_date, i_mbm_log + 6, PChar('4MA OK! Count:' + IntToStr(i_sum_long_mbm_count) +
+ ' short: ' + IntToStr(i_sum_short_mbm_count) +
+ ' long-short: ' + IntToStr(i_sum_long_mbm_count - i_sum_short_mbm_count) +
+ ' S-L: ' + IntToStr(i_sum_short_mbm_count - i_sum_long_mbm_count)
+
+ ));
+ W_Log('MBM long 4ma sum', as_k_chg[j].i_date, i_mbm_log + 7, PChar('4MA OK! Count:' + IntToStr(i_sum_4ma_long_mbm_count) +
+ ' short 4ma: ' + IntToStr(i_sum_4ma_short_mbm_count) +
+ ' 4ma L-S: ' + IntToStr(i_sum_4ma_long_mbm_count - i_sum_4ma_short_mbm_count)));
+ end;
+
+
+ ff_get_BS_Mark(j);
+
+ ff_4ma_make_mbm_long(j);
+ ff_4ma_make_mbm_short(j);
+
+ i_tmp_1 := ff_make_mbm_long(j);
+
+ if (i_tmp_1 = 0) then
+ begin
+ i_tmp_1 := as_k_chg[j].i_close;
+ j_tmp_1 := ff_get_max_ij_high(j, j + 240);
+ k_tmp_1 := ff_get_min_ij_low(j, j + 240);
+ j_index_1 := ff_get_max_ij_index(j, j + 240);
+ k_index_1 := ff_get_min_ij_index(j, j + 240);
+
+ if (i_tmp_1 - k_tmp_1 > 1600) or (j_tmp_1 - i_tmp_1 < 1000) then
+ begin
+ i_count_1 := i_count_1 + 1;
+ W_Log('MBM long', as_k_chg[j].i_date, i_mbm_log + 1,
+ PChar('Buy:' + IntToStr(i_tmp_1) + '-BAD-' + 'Cut Cut:' + IntToStr(k_tmp_1) + ' i:' + IntToStr(j_index_1 - k_index_1) + ' j:' + IntToStr(j_index_1 - j) + ' k:' + IntToStr(k_index_1 - j)));
+ end
+ else
+ begin
+ j_count_1 := j_count_1 + 1;
+ W_Log('MBM long', as_k_chg[j].i_date, i_mbm_log + 1,
+ PChar('Buy:' + IntToStr(i_tmp_1) + '-GOOD-' + 'Stop Stop:' + IntToStr(j_tmp_1) + ' i:' + IntToStr(j_index_1 - k_index_1) + ' j:' + IntToStr(j_index_1 - j) + ' k:' + IntToStr(k_index_1 - j)));
+ end;
+
+ end;
+
+ i_tmp := ff_make_mbm_short(j);
+
+ if (i_tmp = 0) then
+ begin
+ i_tmp := as_k_chg[j].i_close;
+ j_tmp := ff_get_max_ij_high(j, j + 240);
+ k_tmp := ff_get_min_ij_low(j, j + 240);
+ j_index := ff_get_max_ij_index(j, j + 240);
+ k_index := ff_get_min_ij_index(j, j + 240);
+
+ if (j_tmp - i_tmp > 1600) or (i_tmp - k_tmp < 1000) then
+ //if(i_tmp-k_tmp >1600 ) or (j_tmp-i_tmp<1000) then
+ begin
+ i_count := i_count + 1;
+ W_Log('MBM short', as_k_chg[j].i_date, i_mbm_log,
+ PChar('Buy:' + IntToStr(i_tmp) + '-BAD-' + 'Cut Cut:' + IntToStr(j_tmp) + ' i:' + IntToStr(j_index - k_index) + ' j:' + IntToStr(j_index - j) + ' k:' + IntToStr(k_index - j)));
+ end
+ else
+ begin
+ j_count := j_count + 1;
+ W_Log('MBM short', as_k_chg[j].i_date, i_mbm_log,
+ PChar('Buy:' + IntToStr(i_tmp) + '-GOOD-' + 'Stop Stop:' + IntToStr(k_tmp) + ' i:' + IntToStr(j_index - k_index) + ' j:' + IntToStr(j_index - j) + ' k:' + IntToStr(k_index - j)));
+ end;
+
+ end;
+
+
+ //ff_short_pass3_mark(j);
+ //ff_pass3_short_120(j);
+ //ff_make_mbm_long(j);
+ //ff_make_mbm_short(j);
+
+ //ff_get_BS_Mark(j);
+ //ff_make_long_MA30(j);
+ //ff_make_long_MA250(j);
+
+ //ff_check_short_1(j);
+ //ff_check_short_1_ex(j);
+ //ff_check_short_30(j);
+ //ff_check_short_250(j);
+ //ff_check_short_120(j);
+
+ //ff_long_pass_3_ex(j);
+ //ff_check_long_pass_3(j);
+
+ if as_k_chg[j].i_date = 1131314 then
+ begin
+ //ff_make_mbm_short(j);
+ //ff_short_pass3_mark(j);
+ //ff_pass3_short_120(j);
+
+ //ff_make_long_MA30(j);
+
+ //ff_check_long_pass_3(j);
+ //ff_check_short_250(j);
+ //ff_check_long_pass_3(j);
+ //ff_check_short_1(j);
+ //ff_check_short_1_ex(j);
+ end;
+ //ff_check_M30_short(j);
+ //ff_check_M30_short_ex(j);
+
+ //ff_check_rsi_w20(j);
+ //ff_check_rsi_w20_ex(j);
+
+ //ff_check_MA120_BB(j,3);
+ //ff_check_MA120_BB_ex(j);
+ //ff_check_BB_100(j,3);
+ //ff_check_BB_100_ex(j);
+ end;
+
+ if i_make_ex_test > 0 then W_Log('MBM long', 88888, i_mbm_log + 1, PChar('Stop:' + IntToStr(j_count_1) + '----------' + 'Cut:' + IntToStr(i_count_1)));
+ if i_make_ex_test > 0 then W_Log('MBM short', 888, i_mbm_log, PChar('Stop:' + IntToStr(j_count) + '----------' + 'Cut:' + IntToStr(i_count)));
+
+ //for test
+ if i_make_ex_test > 0 then ExitProcess(888);
+ //only for test End
+
+ for j := 888 to i_s_k_chg_index_wk - 2 do
+ begin
+ //for short long lamp
+ ff_get_BS_Mark(j);
+
+ ff_4ma_make_mbm_long(j);
+ ff_4ma_make_mbm_short(j);
+
+ ff_make_mbm_long(j);
+ ff_make_mbm_short(j);
+ end;
+
+
+ //ºÜÖØÒª:¼ì²éһϰ汾ÊÇ·ñ·ûºÏ
+ if HSFUSDK_VERSION <> GetSDKVersion() then
+ begin
+ //MessageBox(Self.Handle,'Í·Îļþ°æ±¾Óë¿âÎļþ°æ±¾²»Æ¥Åä,½«¿ÉÄܵ¼Ö¼æÈÝÐÔÎÊÌâ!','°æ±¾¾¯¸æ',MB_OK or MB_ICONWARNING);
+ Exit;
+ end;
+
+ //µÚÒ»²½ ´´½¨Ò»¸öͨÐŶÔÏó
+ m_lpComm := NewFuCommObj(nil);
+ if nil = m_lpComm then
+ begin
+ //Form1.AddLog('´´½¨Í¨ÐŶÔÏóʧ°Ü');
+ Exit;
+ end;
+ //Form1.AddLog('´´½¨Í¨ÐŶÔÏóOK');
+ //´´½¨»Øµ÷¶ÔÏó
+ m_lpCallBack := TMyFuCallBack.Create;
+
+ FF_comm_obj_init();
+
+ //
+ if (i_comm_ok > 0) then
+ begin
+ W_Log('create_thread', i_wk_log, i_wk_log, 'call do_beep!');
+ do_beep();
+ end;
+end;
+
+//ÊÍ·ÅͨÐŶÔÏó
+
+function FF_release_comm_obj(): Boolean;
+begin
+ Result := False;
+ if Assigned(m_lpComm) then
+ begin
+ //FileClose(iFileHandle);
+ if i_beeping > 0 then ff_stop_do_beep();
+
+ m_lpComm.SubscribeRequest(UnKnownType, CxlAll, 'ALLWWW');
+ m_lpComm.DoLogout(pc_username);
+ //¹Ø±Õ×Ô¶¯ÖØÁ¬Ïß³Ì
+ g_bStop := true;
+ SetEvent(g_hEvent);
+ Sleep(2000);
+ WaitForSingleObject(th_beep.Handle, 10000);
+ CloseHandle(th_beep.Handle);
+ WaitForSingleObject(th_main_loop.Handle, 10000);
+ CloseHandle(th_main_loop.Handle);
+
+ //¹Ø±ÕͨÐÅÁ¬½Ó
+ m_lpComm.Stop();
+ m_lpComm.Release();
+ m_lpComm := nil;
+ m_lpCallBack.Destroy;
+ end;
+end;
+
+function FF_comm_obj_init(): Boolean;
+var
+ i_loop, iRet: Integer;
+ //szServer:string;
+ sLog: string;
+begin
+ Result := False;
+
+ //ºÜÖØÒª:¼ì²éһϰ汾ÊÇ·ñ·ûºÏ
+ if HSFUSDK_VERSION <> GetSDKVersion() then
+ begin
+ //MessageBox(Self.Handle,'Í·Îļþ°æ±¾Óë¿âÎļþ°æ±¾²»Æ¥Åä,½«¿ÉÄܵ¼Ö¼æÈÝÐÔÎÊÌâ!','°æ±¾¾¯¸æ',MB_OK or MB_ICONWARNING);
+ Exit;
+ end;
+
+ //szServer := '222.66.166.146:2800';
+ pc_IP := FF_ffconf(m_ff_main_ini, 'Sever', 'IP');
+ pc_BLS := FF_ffconf(m_ff_main_ini, 'Sever', 'BLS');
+ pc_CLF := FF_ffconf(m_ff_main_ini, 'Sever', 'CLF');
+ pc_ENT := FF_ffconf(m_ff_main_ini, 'Sever', 'ENT');
+
+ pc_username := FF_ffconf(m_ff_local_ini, 'Main', 'FC');
+ pc_user_pwd := FF_ffconf(m_ff_local_ini, 'Main', 'FCPWD');
+
+ //sBiz:=
+ //sDatF:=
+ //sL:=
+ //ÉèÖÃÅäÖòÎÊý
+ m_lpComm.SetConfig('futu', 'server', pc_IP); //t2·þÎñÆ÷µØÖ·
+ //m_lpComm.SetConfig('futu','biz_license_str','31332263F984F45D4B07689AB3352E19'); //ÊÚȨҵÎñÖ¤Êé´®
+ //m_lpComm.SetConfig('futu','comm_license_file','fz_3rd.dat');//t2ͨÐÅÖ¤Êé
+ //m_lpComm.SetConfig('futu','entrust_type','L');//ίÍз½Ê½
+
+ m_lpComm.SetConfig('futu', 'biz_license_str', pc_BLS); //ÊÚȨҵÎñÖ¤Êé´®
+ m_lpComm.SetConfig('futu', 'comm_license_file', pc_CLF); //t2ͨÐÅÖ¤Êé
+
+ m_lpComm.SetConfig('futu', 'entrust_type', pc_ENT); //ίÍз½Ê½
+
+ //µÚ¶þ²½ ³õʼ»¯½Ó¿Ú¶ÔÏó
+ iRet := m_lpComm.Init(m_lpCallBack);
+ if 0 <> iRet then
+ begin
+ //sLog := '½Ó¿Ú³õʼ»¯Ê§°Ü:'+m_lpComm.GetErrorMsg(iRet);
+ Exit;
+ end;
+
+ //³õʼ»¯³É¹¦
+ sLog := '½Ó¿Ú³õʼ»¯³É¹¦!';
+
+ iRet := m_lpComm.Start(SERVICE_TYPE_TRADE);
+ if 0 <> iRet then
+ begin
+ sLog := 'Æô¶¯½»Ò×Á¬½Óʧ°Ü:' + m_lpComm.GetErrorMsg(iRet);
+ W_Log('m_lpComm.Start', i_wk_log, i_wk_log, PChar(sLog));
+ Exit;
+ end;
+ //Form1.AddLog('´´½¨Í¨ÐŶÔÏóOK 999');
+ //½¨Á¢Í¨ÐÅÁ¬½Ó
+ iRet := m_lpComm.Start(SERVICE_TYPE_QUOTE);
+ if 0 <> iRet then
+ begin
+ sLog := 'Æô¶¯ÐÐÇéÁ¬½Óʧ°Ü:' + m_lpComm.GetErrorMsg(iRet);
+ W_Log('m_lpComm.Start', i_wk_log, i_wk_log, PChar(sLog));
+ Exit;
+ end;
+ //Form1.AddLog('´´½¨Í¨ÐŶÔÏóOK 1000');
+ //µÚÈý²½ Ò»ÇвÙ×÷´ÓµÇ½¿ªÊ¼
+
+ for i_loop := 0 to i_fc_count - 1 do
+ begin
+ if (as_fc_data[i_loop].pc_fcpwd = nil) then as_fc_data[i_loop].pc_fcpwd := pc_user_pwd;
+
+ iRet := m_lpComm.DoLogin(as_fc_data[i_loop].pc_username, as_fc_data[i_loop].pc_fcpwd, 1);
+ if iRet <> 0 then
+ begin
+ sLog := 'µÇ½ʧ°Ü:' + IntToStr(iRet) + ':' + m_lpComm.GetErrorMsg(iRet);
+ W_Log('DoLogin', i_wk_log, i_wk_log, PChar(sLog));
+ ExitProcess(199);
+ end;
+ //Form1.AddLog('´´½¨Í¨ÐŶÔÏóOK 1888');
+ end;
+
+ pc_username := as_fc_data[i_fc_wk_index].pc_username;
+
+ s_caption_12 := pc_what_wk;
+
+ //¶©ÔÄÐÐÇé
+ m_lpComm.SubscribeRequest(SingleCode, Subscription, pc_what_wk);
+ m_lpComm.SubscribeRequest(RspReport, Subscription, pc_username);
+
+
+ //for password chg
+ //ff_passwd_chg(pc_username,'0',pc_user_pwd,'138688');
+
+ i_comm_ok := 888;
+
+ if (i_comm_ok = 0) then
+ begin
+ s_caption_3 := '¶Ï¿ª';
+ end
+ else
+ begin
+ s_caption_3 := 'Áª»ú';
+ end;
+
+
+end;
+
+
+
+function FF_do_logout(pc_fund_account: PChar): Boolean;
+var
+ iRet: Integer;
+begin
+ //µÇ³ö
+ if Assigned(m_lpComm) then
+ begin
+ iRet := m_lpComm.DoLogout(pc_fund_account);
+ if 0 <> iRet then
+ begin
+ //Form1.AddLog('µÇ³öʧ°Ü:'+m_lpComm.GetErrorMsg(iRet));
+ end;
+ end;
+
+ Result := True;
+
+end;
+
+
+
+
+{ TMyFuCallBack }
+ ////////////////////////////////////ÏûÏ¢»Øµ÷º¯ÊýʵÏÖ///////////////////////////////////////////////////
+
+function TMyFuCallBack.QueryInterface(const iid: PChar; ppv: Pointer): Integer;
+begin
+ Result := 0;
+end;
+
+function TMyFuCallBack.AddRef(): Integer;
+begin
+ Result := 0;
+end;
+
+function TMyFuCallBack.Release(): Integer;
+begin
+ Result := 0;
+end;
+
+procedure TMyFuCallBack.OnConnStateNotify(lpInst: Pointer; iType: Integer; iRet: Integer; const szNotifyTime, szMsg: PChar);
+begin
+ //Form1.Addlog('Á¬½Ó״̬±ä»¯:'+szNotifyTime+'-> '+szMsg+':'+IntToStr(iType));
+ if iRet = 0 then //Á¬½Ó¶Ï¿ªÁË
+ begin
+ i_comm_ok := 0;
+ g_iType := iType;
+ SetEvent(g_hEvent);
+ end;
+end;
+
+procedure TMyFuCallBack.OnReceivedBiz(lpInst: Pointer; lpAnsData: IFuMessage; iRet: Integer; iKeyID: Integer);
+begin
+ //Form1.AddLog('ÊÕµ½Òì²½Ó¦´ðÏûÏ¢:type'+IntToStr(lpAnsData.GetMsgType()));
+ //Form1.ShowFuMessage(lpAnsData);
+end;
+
+procedure TMyFuCallBack.OnRecvOrderInfo(lpInst: Pointer; const lpInfo: LPCOrderRspInfo);
+begin
+ //Form1.AddLog('ÊÕµ½Î¯Íз´À¡ÏûÏ¢:type'+IntToStr(lpInfo.fund_account));
+end;
+
+procedure TMyFuCallBack.OnRecvOrderRealInfo(lpInst: Pointer; const lpInfo: LPCRealRspInfo);
+var
+ c_log: array[0..88] of char;
+ s_tmp: string;
+begin
+ //Form1.AddLog('ÊÕµ½³É½»·´À¡ÏûÏ¢:type'+IntToStr(lpInfo.fund_account));
+ //entrust_bs: array[0..8] of Char; //5 ÂòÂô±êʶ
+ //entrust_direction: array[0..8] of Char;//6 ¿ªÆ½±êʶ
+ //business_price: Double; //7 ³É½»¼Û¸ñ
+ //business_amount: Double; //8 ³É½»ÊýÁ¿
+
+ //for i_got_it_mark,i_short_mark ,etc ,gobal var error
+ Exit;
+
+ FillChar(c_log, SizeOf(c_log), 0);
+
+ StrCopy(c_log, lpInfo.entrust_bs);
+
+ if c_log[0] = '2' then
+ begin
+ FillChar(c_log, SizeOf(c_log), 0);
+ StrCopy(c_log, lpInfo.entrust_direction);
+
+ //kaicang
+ if c_log[0] = '1' then
+ begin
+ f_short_price := lpInfo.business_price;
+ s_tmp := FloatToStrF(lpInfo.business_price, ffFixed, 8, 2);
+ i_short_mark := i_short_mark + Round(lpInfo.business_amount);
+
+ s_caption_9 := '¿Õ ' + Trim(s_tmp);
+ s_caption_11 := IntToStr(i_short_mark);
+
+ //MAINFORM.Label9.Caption :='¿Õ '+Trim(s_tmp);
+ //MAINFORM.Label11.Caption :=IntToStr(i_short_mark);
+
+ if (i_short_mark > (i_F + i_S - 1)) then i_short_S_mark := 888 else i_short_S_mark := 0;
+ if (i_short_mark > (i_F + i_S + i_T - 1)) then i_short_T_mark := 888 else i_short_T_mark := 0;
+ end;
+
+ //pingcang
+ if c_log[0] = '2' then
+ begin
+ f_short_price := lpInfo.business_price;
+ s_tmp := FloatToStrF(lpInfo.business_price, ffFixed, 8, 2);
+ i_got_it_mark := i_got_it_mark - Round(lpInfo.business_amount);
+
+ s_caption_8 := '¶à ' + Trim(s_tmp);
+ s_caption_10 := IntToStr(i_got_it_mark);
+ //MAINFORM.Label8.Caption :='¶à '+Trim(s_tmp);
+ //MAINFORM.Label10.Caption:=IntToStr(i_got_it_mark);
+
+ if (i_got_it_mark > (i_F + i_S - 1)) then i_get_S_mark := 888 else i_get_S_mark := 0;
+ if (i_got_it_mark > (i_F + i_S + i_T - 1)) then i_get_T_mark := 888 else i_get_T_mark := 0;
+ end;
+
+ end
+ else if c_log[0] = '1' then
+ begin
+ FillChar(c_log, SizeOf(c_log), 0);
+ StrCopy(c_log, lpInfo.entrust_direction);
+
+ //kaicang
+ if c_log[0] = '1' then
+ begin
+ f_business_price := lpInfo.business_price;
+ s_tmp := FloatToStrF(lpInfo.business_price, ffFixed, 8, 2);
+ i_got_it_mark := i_got_it_mark + Round(lpInfo.business_amount);
+
+ s_caption_8 := '¶à ' + Trim(s_tmp);
+ s_caption_10 := IntToStr(i_got_it_mark);
+
+ //MAINFORM.Label8.Caption :='¶à '+Trim(s_tmp);
+ //MAINFORM.Label10.Caption:=IntToStr(i_got_it_mark);
+
+ if (i_got_it_mark > (i_F + i_S - 1)) then i_get_S_mark := 888 else i_get_S_mark := 0;
+ if (i_got_it_mark > (i_F + i_S + i_T - 1)) then i_get_T_mark := 888 else i_get_T_mark := 0;
+ end;
+
+ //pingcang
+ if c_log[0] = '2' then
+ begin
+
+ f_short_price := lpInfo.business_price;
+ s_tmp := FloatToStrF(lpInfo.business_price, ffFixed, 8, 2);
+ i_short_mark := i_short_mark - Round(lpInfo.business_amount);
+
+ s_caption_9 := '¿Õ ' + Trim(s_tmp);
+ s_caption_11 := IntToStr(i_short_mark);
+
+ //MAINFORM.Label9.Caption :='¿Õ '+Trim(s_tmp);
+ //MAINFORM.Label11.Caption :=IntToStr(i_short_mark);
+
+ if (i_short_mark > (i_F + i_S - 1)) then i_short_S_mark := 888 else i_short_S_mark := 0;
+ if (i_short_mark > (i_F + i_S + i_T - 1)) then i_short_T_mark := 888 else i_short_T_mark := 0;
+ end;
+
+ end;
+
+ //frmMain2.CalcAll;
+ //frmMain2.GRID.Repaint;
+
+end;
+
+procedure TMyFuCallBack.OnRspArgMaketInfo(lpInst: Pointer; const lpData: LPCArgMarketInfo; rAction: REGAction);
+begin
+ //Form1.AddLog('ÊÕµ½×éºÏÐÐÇéÏûÏ¢.×éºÏ´úÂë:'+lpData.arbicontract_id);
+end;
+
+procedure TMyFuCallBack.OnRspLogin(lpInst: Pointer; lpMsg: IFuMessage);
+begin
+ //Form1.AddLog('Òì²½ÊÕµ½µÇ½Ӧ´ð:');
+ //Form1.ShowFuMessage(lpMsg);
+end;
+
+procedure TMyFuCallBack.OnRspLogout(lpInst: Pointer; lpMsg: IFuMessage);
+begin
+ //Form1.AddLog('Òì²½ÊÕµ½µÇ³öÓ¦´ð:');
+ //Form1.ShowFuMessage(lpMsg);
+end;
+
+procedure TMyFuCallBack.OnRspMarketInfo(lpInst: Pointer; const lpData: LPCMarketInfo; rAction: REGAction);
+var
+ //iFileHandle : Integer;
+ s_tmp: string;
+ i_loop: Integer;
+ i_tmp: Integer;
+begin
+ //cout<<"µ¥ÍÈÐÐÇé:("<futu_exch_type<<":"<contract_code<<")"<futu_last_price<<"\t"<sale_low_price<<"\t";
+ //cout<0) Then Exit;
+
+ s_tmp := FloatToStrF(lpData.futu_last_price, ffFixed, 8, 2) + ' MA30' +
+
+ IntToStr(as_k_chg_ma_rsi[i_s_k_chg_index_wk].ai_ma[3]) + ' MA60' +
+ IntToStr(as_k_chg_ma_rsi[i_s_k_chg_index_wk].ai_ma[5]) + ' RSI6' +
+ IntToStr(as_k_chg_ma_rsi[i_s_k_chg_index_wk - 1].ai_rsi[0]) + ' ' +
+ IntToStr(as_k_chg_ma_rsi[i_s_k_chg_index_wk].ai_rsi[0]);
+ tm_1 := Now;
+
+ if (lpData.futu_last_price < 10) then Exit;
+
+ f_last_price_wk := lpData.futu_last_price;
+
+ //20120622 add
+ if (i_got_it_mark = 0) then i_long_FLOSS_MAX := 0;
+ if (i_got_it_mark > 0) and
+ (f_last_price_wk - f_business_price < -3) then
+ begin
+ if i_long_FLOSS_MAX < Round(f_business_price - f_last_price_wk) then
+ i_long_FLOSS_MAX := Round(f_business_price - f_last_price_wk);
+ end;
+
+ if (i_short_mark = 0) then i_short_FLOSS_MAX := 0;
+ if (i_short_mark > 0) and
+ (f_last_price_wk - f_business_price > 3) then
+ begin
+ if i_short_FLOSS_MAX < Round(f_last_price_wk - f_business_price) then
+ i_short_FLOSS_MAX := Round(f_last_price_wk - f_business_price);
+ end;
+ //20120622 add end
+
+ if i_s_k_chg_index_wk > 8 then f_last_price_1 := as_k_chg[i_s_k_chg_index_wk - 1].i_close / 100
+ else f_last_price_1 := f_last_price_wk;
+
+ if (i_get_price_count < 1) or (i_get_price_count > m_i_max_chg_kline_in_mem - 8) then
+ begin
+ i_get_price_count := 0;
+ end;
+
+ if i_get_price_count = 0 then
+ begin
+ s_tmp := FormatDateTime('mmddhhnn', Now);
+ as_k_chg[i_s_k_chg_index_wk].i_date := StrToInt(s_tmp);
+
+ as_k_chg[i_s_k_chg_index_wk].i_open := Round(lpData.futu_last_price * 100);
+ as_k_chg[i_s_k_chg_index_wk].i_close := Round(lpData.futu_last_price * 100);
+ as_k_chg[i_s_k_chg_index_wk].i_high := Round(lpData.futu_last_price * 100);
+ as_k_chg[i_s_k_chg_index_wk].i_low := Round(lpData.futu_last_price * 100);
+
+ tm_0 := Now;
+
+ FillChar(as_vol_data, sizeof(as_vol_data), 0);
+
+ for i_loop := 0 to 19 do
+ begin
+ as_vol_data[i_loop].tm_0 := Now;
+ as_vol_data[i_loop].i_business_amount := Round(lpData.business_amount);
+ end;
+
+ end;
+
+ //for vol display
+ tm_2 := Now;
+
+ if (i_vol_start = 888) and (i_vol_reset = 0) then
+ begin
+ i_vol_0 := Round(lpData.business_amount);
+ i_vol_start := 999;
+ tdt_vol_0 := Now;
+ end;
+
+ if (i_vol_start = 999) and (i_vol_reset = 0) then
+ begin
+ i_vol_1 := Round(lpData.business_amount) - i_vol_0;
+ i_tmp := SecondsBetween(tdt_vol_0, tm_2);
+ if (i_tmp < 59) then
+ begin
+ s_caption_vol := IntToStr(i_tmp) + ' : ' + IntToStr(Round((60 / (i_tmp + 1)) * i_vol_1));
+ end
+ else
+ begin
+ i_vol_0 := Round(lpData.business_amount);
+ i_vol_start := 999;
+ tdt_vol_0 := Now;
+ end;
+ end;
+
+ for i_loop := 0 to 19 do
+ begin
+ if (SecondsBetween(as_vol_data[i_loop].tm_0, tm_2) > ((i_loop + 1) * 3 - 1)) then
+ begin
+ as_vol_data[i_loop].tm_0 := tm_2;
+ as_vol_data[i_loop].i_vol := Round(lpData.business_amount) - as_vol_data[i_loop].i_business_amount;
+ as_vol_data[i_loop].i_business_amount := Round(lpData.business_amount);
+ end;
+ end;
+
+ if (i_vol_start = 0) and (i_vol_reset = 0) then
+ begin
+ s_caption_vol := IntToStr(as_vol_data[7].i_vol + as_vol_data[2].i_vol * 2 + as_vol_data[1].i_vol * 2 + as_vol_data[0].i_vol * 2);
+ end;
+
+ if i_as_k_chg_init_flag = 0 then
+ begin
+ FillChar(as_k_chg, SizeOf(as_k_chg), 0);
+ FillChar(as_k_chg_ma_rsi, sizeof(as_k_chg_ma_rsi), 0);
+ i_as_k_chg_init_flag := 888;
+ i_s_k_chg_index_wk := 0;
+
+ s_tmp := FormatDateTime('mmddhhnn', Now);
+
+ as_k_chg[i_s_k_chg_index_wk].i_date := StrToInt(s_tmp);
+ as_k_chg[i_s_k_chg_index_wk].i_open := Round(lpData.futu_last_price * 100);
+ as_k_chg[i_s_k_chg_index_wk].i_close := Round(lpData.futu_last_price * 100);
+ as_k_chg[i_s_k_chg_index_wk].i_high := Round(lpData.futu_last_price * 100);
+ as_k_chg[i_s_k_chg_index_wk].i_low := Round(lpData.futu_last_price * 100);
+
+ tm_0 := Now;
+ end;
+
+ s_tmp := FormatDateTime('hhnn', Now);
+
+ if (SecondsBetween(tm_0, tm_1) > 59) or
+ ((SecondsBetween(tm_0, tm_1) > 50) and (i_will_close_market = 888)) then
+ begin
+ {
+ Form1.AddLog('ÊÕµ½µ¥ÍÈÐÐÇéÊý¾Ý:'+lpData.contract_code +' ' +
+ FloatToStrF(lpData.futu_last_price,ffFixed,8,2) + ' MA30' +
+ IntToStr(as_k_chg_ma_rsi[i_s_k_chg_index_wk].ai_ma[3]) + ' MA60' +
+ IntToStr(as_k_chg_ma_rsi[i_s_k_chg_index_wk].ai_ma[5]) + ' RSI6' +
+ IntToStr(as_k_chg_ma_rsi[i_s_k_chg_index_wk-1].ai_rsi[0]) + ' ' +
+ IntToStr(as_k_chg_ma_rsi[i_s_k_chg_index_wk].ai_rsi[0]) +' ' +
+ IntTostr(i_got_it_mark) + ' ' +
+ FloatToStrF(f_business_price,ffFixed,8,2) );
+ }
+
+ as_k_chg[i_s_k_chg_index_wk].i_close := Round(lpData.futu_last_price * 100);
+ as_k_chg[i_s_k_chg_index_wk].i_pre_close := Round(lpData.business_amount);
+
+ if as_k_chg[i_s_k_chg_index_wk].i_close > as_k_chg[i_s_k_chg_index_wk].i_high then
+ as_k_chg[i_s_k_chg_index_wk].i_high := as_k_chg[i_s_k_chg_index_wk].i_close;
+ if as_k_chg[i_s_k_chg_index_wk].i_close < as_k_chg[i_s_k_chg_index_wk].i_low then
+ as_k_chg[i_s_k_chg_index_wk].i_low := as_k_chg[i_s_k_chg_index_wk].i_close;
+
+ if i_s_k_chg_index_wk > i_s_k_chg_index_load then
+ as_k_chg[i_s_k_chg_index_wk].i_vol := as_k_chg[i_s_k_chg_index_wk].i_pre_close - as_k_chg[i_s_k_chg_index_wk - 1].i_pre_close;
+
+ s_tmp := FormatDateTime('mmddhhnn', Now);
+ as_k_chg[i_s_k_chg_index_wk].i_date := StrToInt(s_tmp);
+
+ s_tmp := FormatDateTime('hhnn', Now);
+ if (s_tmp = '1514') then i_will_close_market := 888;
+
+ s_tmp := FormatDateTime('nn', Now);
+
+ tm_0 := Now;
+ tm_1 := Now;
+
+ iFileHandle := FileOpen(m_k_line_file_name, fmOpenWrite);
+ if iFileHandle > 0 then
+ begin
+
+ if (as_k_chg[i_s_k_chg_index_wk].i_vol = 0) and (s_tmp = '15') then
+ as_k_chg[i_s_k_chg_index_wk].i_vol := Round(lpData.business_amount);
+
+ FileSeek(iFileHandle, 0, 2);
+ if (as_k_chg[i_s_k_chg_index_wk].i_close < 100) or
+ (as_k_chg[i_s_k_chg_index_wk].i_high < 100) or
+ (as_k_chg[i_s_k_chg_index_wk].i_low < 100) or
+ (as_k_chg[i_s_k_chg_index_wk].i_vol = 0) or
+ (as_k_chg[i_s_k_chg_index_wk].i_open < 100) then
+ begin
+ FileClose(iFileHandle);
+ end
+ else
+ begin
+ FileWrite(iFileHandle, as_k_chg[i_s_k_chg_index_wk], SizeOf(s_k_line_data));
+ FileClose(iFileHandle);
+ //for FF_300k
+ //try
+
+ //frmMain2.StkDataFile.writeStkDataToM(1,@as_k_chg[i_s_k_chg_index_wk]);
+ //except
+ // W_Log('try_except_0',1119,999,'StkDataFile.writeStkDataToM exception');
+ //end;
+ end;
+ end;
+
+
+
+ ff_make_ma_rsi_ex(i_s_k_chg_index_wk);
+
+ i_s_k_chg_index_wk_bak := i_s_k_chg_index_wk;
+
+ s_tmp := FormatDateTime('mmddhhnn', Now);
+ as_k_chg[i_s_k_chg_index_wk + 1].i_date := StrToInt(s_tmp);
+
+ if i_s_k_chg_index_wk > m_i_max_chg_kline_in_mem - 8 then
+ begin
+ FillChar(as_k_chg, SizeOf(as_k_chg), 0);
+ FillChar(as_k_chg_ma_rsi, sizeof(as_k_chg_ma_rsi), 0);
+ i_as_k_chg_init_flag := 888;
+ i_s_k_chg_index_wk := 0;
+ end;
+
+ as_k_chg[i_s_k_chg_index_wk + 1].i_open := Round(lpData.futu_last_price * 100);
+ as_k_chg[i_s_k_chg_index_wk + 1].i_close := Round(lpData.futu_last_price * 100);
+ as_k_chg[i_s_k_chg_index_wk + 1].i_high := Round(lpData.futu_last_price * 100);
+ as_k_chg[i_s_k_chg_index_wk + 1].i_low := Round(lpData.futu_last_price * 100);
+ //try
+ //frmMain2.StkDataFile.writeStkDataToM(0,@as_k_chg[i_s_k_chg_index_wk]);
+ //except
+ // W_Log('try_except_1',11119,999,'StkDataFile.writeStkDataToM exception');
+ //end;
+ //frmMain2.CalcAll;
+ //frmMain2.GRID.Repaint;
+
+ i_s_k_chg_index_wk := i_s_k_chg_index_wk + 1;
+ ff_make_ma_rsi_ex(i_s_k_chg_index_wk);
+ end
+ else
+ begin
+ as_k_chg[i_s_k_chg_index_wk].i_close := Round(lpData.futu_last_price * 100);
+ ff_make_ma_rsi_ex(i_s_k_chg_index_wk);
+
+ if as_k_chg[i_s_k_chg_index_wk].i_close > as_k_chg[i_s_k_chg_index_wk].i_high then
+ as_k_chg[i_s_k_chg_index_wk].i_high := as_k_chg[i_s_k_chg_index_wk].i_close;
+ if as_k_chg[i_s_k_chg_index_wk].i_close < as_k_chg[i_s_k_chg_index_wk].i_low then
+ as_k_chg[i_s_k_chg_index_wk].i_low := as_k_chg[i_s_k_chg_index_wk].i_close;
+
+ //if i_s_k_chg_index_wk > i_s_k_chg_index_load then
+ // as_k_chg[i_s_k_chg_index_wk].i_vol:= as_k_chg[i_s_k_chg_index_wk].i_pre_close-as_k_chg[i_s_k_chg_index_wk-1].i_pre_close;
+
+ //try
+ // frmMain2.StkDataFile.writeStkDataToM(1,@as_k_chg[i_s_k_chg_index_wk]);
+ //except
+ // W_Log('try_except_2',1119,999,'StkDataFile.writeStkDataToM exception');
+ //end;
+
+
+ end;
+
+ if (i_long_mbm_count > 0) then
+ begin
+ //frmMain2.GRID_S002.Cells[0,0]:='L5 ' + IntToStr(i_long_mbm_count);
+ //frmMain2.GRID_S002.Cells[1,0]:='L4 ' + IntToStr(i_4ma_long_mbm_count);
+ end;
+
+ if (i_short_mbm_count > 0) then
+ begin
+ //frmMain2.GRID_S002.Cells[0,0]:='S5 ' + IntToStr(i_short_mbm_count);
+ //frmMain2.GRID_S002.Cells[1,0]:='S4 ' + IntToStr(i_4ma_short_mbm_count);
+ end;
+
+
+ //frmMain2.GRID_S002.Cells[0,1]:='RSI';
+ //frmMain2.GRID_S002.Cells[1,1]:=FloatToStrF(as_k_chg_ma_rsi[i_s_k_chg_index_wk].ai_rsi[0]/100,ffFixed,7,2);
+
+ //MAINFORM.Label1.Caption:='Âô '+FloatToStrF(lpData.sale_low_price,ffFixed,7,2);
+ //MAINFORM.Label2.Caption:=IntToStr(lpData.sale_low_amount);
+
+ //MAINFORM.Label5.Caption:='Âò '+FloatToStrF(lpData.buy_high_price,ffFixed,7,2);
+ //MAINFORM.Label6.Caption:=IntToStr(lpData.buy_high_amount);
+
+ //MAINFORM.Label7.Caption:=pc_username;
+
+ s_caption_1 := 'Âô ' + FloatToStrF(lpData.sale_low_price, ffFixed, 7, 2);
+ s_caption_2 := IntToStr(lpData.sale_low_amount);
+
+ s_caption_5 := 'Âò ' + FloatToStrF(lpData.buy_high_price, ffFixed, 7, 2);
+ s_caption_6 := IntToStr(lpData.buy_high_amount);
+
+ s_caption_7 := pc_username;
+
+ f_buy_1 := lpData.buy_high_price;
+ f_sale_1 := lpData.sale_low_price;
+
+ //for
+ if ((i_get_price_count mod 18) = 0) then
+ begin
+ //frmMain2.CalcAll;
+ //frmMain2.GRID.Repaint;
+ //frmMain2.GridSxxxRePaint;
+ end;
+
+ i_get_price_count := i_get_price_count + 1;
+
+end;
+
+procedure TMyFuCallBack.OnRspOnlineMsg(lpInst: Pointer; szUsrID, szMessage: PChar);
+begin
+ //Form1.AddLog('ÊÕµ½ÔÚÏßÏûÏ¢.');
+end;
+
+procedure TMyFuCallBack.OnRspSubResult(lpInst: Pointer; sType: REGType; aAction: REGAction; iResult: Integer; const lpParam, szMsg: PChar);
+begin
+ //Form1.AddLog('ÊÕµ½¶©ÔĽá¹ûÓ¦´ð.');
+end;
+
+
+
+
+//from cpp
+
+function ff_get_rsi(ii: Integer; jj: Integer): Integer;
+var
+ n: Integer;
+ i: Integer;
+ j: Integer;
+ sum1: Single;
+ sum2: Single;
+ AX1: Double;
+ BX1: Double;
+begin
+ n := ai_rsi_set[jj];
+
+ for i := 0 to ii do
+ begin
+
+ if (i < n + 8) then
+ begin
+ as_k_chg_ma_rsi[i].ai_rsi[jj] := 5000;
+ Continue;
+ end;
+
+ sum1 := 0.0;
+ sum2 := 0.0;
+
+ for j := 0 to n - 1 do
+ begin
+ if (as_k_chg[i - j].i_close > as_k_chg[(i - j) - 1].i_close) then
+ sum1 := sum1 + as_k_chg[i - j].i_close / 100 - as_k_chg[(i - j) - 1].i_close / 100
+ else
+ if (as_k_chg[i - j].i_close < as_k_chg[(i - j) - 1].i_close) then
+ sum2 := sum2 + as_k_chg[(i - j) - 1].i_close / 100 - as_k_chg[i - j].i_close / 100;
+
+ end;
+
+ AX1 := sum1 / n;
+ BX1 := sum2 / n;
+
+ if (sum1 < 0.001) and (sum2 < 0.001) then
+ begin
+ Result := 0;
+ as_k_chg_ma_rsi[i].ai_rsi[jj] := as_k_chg_ma_rsi[i - 1].ai_rsi[jj];
+ Exit;
+ end;
+
+ BX1 := 10000.0 * 2 * (AX1 / (AX1 + BX1) / 3.0);
+
+ as_k_chg_ma_rsi[i].ai_rsi[jj] := Round(as_k_chg_ma_rsi[i - 1].ai_rsi[jj] / 3) + Round(BX1);
+ //as_k_chg_ma_rsi[i].ai_rsi[jj] :=Round(BX1);
+
+ end;
+
+ Result := 0;
+end;
+
+
+
+function ff_get_ma(i: Integer; j: Integer): Integer;
+var
+ k: Integer;
+ f_tmp: Single;
+begin
+ f_tmp := 0.0;
+ for k := i - ai_ma_set[j] + 1 to i do f_tmp := f_tmp + as_k_chg[k].i_close;
+ as_k_chg_ma_rsi[i].ai_ma[j] := Round(f_tmp / ai_ma_set[j]);
+ Result := 0;
+end;
+
+
+//from cpp
+
+function ff_get_rsi_ex(i: Integer; jj: Integer): Integer;
+var
+ n: Integer;
+ j: Integer;
+ sum1: Single;
+ sum2: Single;
+ AX1: Double;
+ BX1: Double;
+begin
+ n := ai_rsi_set[jj];
+ Result := 0;
+
+ if (i < 88) then
+ begin
+ as_k_chg_ma_rsi[i].ai_rsi[jj] := 5000;
+ Exit;
+ end;
+
+ sum1 := 0.0;
+ sum2 := 0.0;
+
+ for j := 0 to n - 1 do
+ begin
+ if (as_k_chg[i - j].i_close > as_k_chg[(i - j) - 1].i_close) then
+ sum1 := sum1 + as_k_chg[i - j].i_close / 100 - as_k_chg[(i - j) - 1].i_close / 100
+ else
+ if (as_k_chg[i - j].i_close < as_k_chg[(i - j) - 1].i_close) then
+ sum2 := sum2 + as_k_chg[(i - j) - 1].i_close / 100 - as_k_chg[i - j].i_close / 100;
+
+ end;
+
+ AX1 := sum1 / n;
+ BX1 := sum2 / n;
+
+ if (sum1 < 0.001) and (sum2 < 0.001) then
+ begin
+ Result := 0;
+ as_k_chg_ma_rsi[i].ai_rsi[jj] := as_k_chg_ma_rsi[i - 1].ai_rsi[jj];
+ Exit;
+ end;
+
+
+ BX1 := 10000.0 * 2 * (AX1 / (AX1 + BX1) / 3.0);
+
+ as_k_chg_ma_rsi[i].ai_rsi[jj] := Round(as_k_chg_ma_rsi[i - 1].ai_rsi[jj] / 3) + Round(BX1);
+
+ Result := 0;
+end;
+
+
+
+function ff_get_max_ij_high(i: Integer; j: Integer): Integer;
+var
+ k: Integer;
+ i_m: Integer;
+begin
+ i_m := as_k_chg[i].i_high;
+ for k := i to j do if Integer(as_k_chg[k].i_high) > i_m then i_m := as_k_chg[k].i_high;
+ Result := i_m;
+end;
+
+function ff_get_max_ij_index(i: Integer; j: Integer): Integer;
+var
+ k: Integer;
+ i_m: Integer;
+ i_index: Integer;
+begin
+ i_m := as_k_chg[i].i_high;
+ i_index := i;
+ for k := i to j do if Integer(as_k_chg[k].i_high) > i_m then
+ begin
+ i_m := as_k_chg[k].i_high;
+ i_index := k;
+ end;
+ Result := i_index;
+end;
+
+function ff_get_min_ij_low(i: Integer; j: Integer): Integer;
+var
+ k: Integer;
+ i_m: Integer;
+begin
+ i_m := as_k_chg[i].i_low;
+ for k := i to j do if Integer(as_k_chg[k].i_low) < i_m then i_m := as_k_chg[k].i_low;
+ Result := i_m;
+end;
+
+function ff_get_min_ij_index(i: Integer; j: Integer): Integer;
+var
+ k: Integer;
+ i_m: Integer;
+ i_index: Integer;
+begin
+ i_index := i;
+ i_m := as_k_chg[i].i_low;
+ for k := i to j do if Integer(as_k_chg[k].i_low) < i_m then
+ begin
+ i_m := as_k_chg[k].i_low;
+ i_index := k;
+ end;
+ Result := i_index;
+end;
+
+function ff_make_ma_rsi_ex(ii: Integer): Integer;
+var
+ j: Integer;
+begin
+ for j := 0 to m_ma_max_index do if (ii > ai_ma_set[j] - 1) then ff_get_ma(ii, j);
+ for j := 0 to 5 do ff_get_rsi_ex(ii, j);
+ Result := 0;
+end;
+
+
+function ff_make_ma_rsi(): Integer;
+var
+ i: Integer;
+ j: Integer;
+begin
+
+ for i := 0 to i_s_k_chg_index_wk do
+ begin
+ for j := 0 to m_ma_max_index do if (i > ai_ma_set[j] - 1) then ff_get_ma(i, j);
+ end;
+
+ i := i_s_k_chg_index_wk;
+
+ for j := 0 to 5 do ff_get_rsi(i, j);
+
+ Result := 0;
+end;
+
+function ff_check_rsi_w20(i: Integer): Integer;
+var
+ j: Integer;
+ k: Integer;
+begin
+
+ Result := -1;
+ if (i < 88) then Exit;
+
+ if (i_act_rsi = 0) then Exit;
+
+ if (i_w20_mark = 888) then Exit;
+
+ if (as_k_chg_ma_rsi[i].ai_rsi[0] > 6000) or (as_k_chg_ma_rsi[i].ai_rsi[0] < 2100) then Exit;
+
+ if (as_k_chg_ma_rsi[i - 1].ai_rsi[0] < Cardinal(i_rsi_A)) or
+ (as_k_chg_ma_rsi[i - 2].ai_rsi[0] < Cardinal(i_rsi_A)) or
+ (as_k_chg_ma_rsi[i - 3].ai_rsi[0] < Cardinal(i_rsi_A)) then
+ begin
+ for j := 0 to i_rsi_AB do
+ if as_k_chg_ma_rsi[i - j - 2].ai_rsi[0] > Cardinal(i_rsi_B) then
+ begin
+ for k := 0 to i_rsi_BC do
+ if as_k_chg_ma_rsi[i - j - k - 2].ai_rsi[0] < Cardinal(i_rsi_C) then
+ begin
+
+ W_Log('W20', as_k_chg[i].i_date, i_wk_log, 'RSI W20!');
+
+ Result := -2;
+ i_w20_mark := 888;
+ i_w20_C_index := i - j - k - 2;
+ i_w20_B_index := i - j - 2;
+ i_w20_A_index := i - 1;
+ Exit;
+ end;
+ end;
+ end;
+
+ Result := -1;
+
+end;
+
+function ff_check_MA120_BB(i: Integer; i_ma_index: Integer): Integer;
+var
+ j: Integer;
+ n: Integer;
+ a: Integer;
+ b: Integer;
+ c: Integer;
+begin
+
+ Result := -1;
+
+ if (i_act_m120 = 0) then exit;
+
+ if (i < 888) then Exit;
+
+ if (i - i_MA120_BB_mark > i_BB_BOX_X * 3) then i_MA120_BB_mark := 0;
+
+ if (i_MA120_BB_mark > 888) then Exit;
+
+ //ai_ma[6] for MA120
+ if (as_k_chg[i].i_close < as_k_chg_ma_rsi[i - 1].ai_ma[6] - 100) then Exit;
+
+ if (as_k_chg[i].i_close > as_k_chg_ma_rsi[i - 1].ai_ma[6] + 800) then Exit;
+
+ if (as_k_chg_ma_rsi[i].ai_ma[i_ma_index] < (as_k_chg_ma_rsi[i].ai_ma[6])) then Exit;
+
+ n := ff_get_min_ij_index(i - i_BB_BOX_X - 2, i);
+
+ c := ff_get_max_ij_index(i - 5 * i_BB_BOX_X, n);
+
+ b := ff_get_min_ij_index(c - 8 * i_BB_BOX_X, c);
+
+ a := ff_get_max_ij_index(b - 8 * i_BB_BOX_X, b);
+
+ if (Integer(as_k_chg[a].i_high + 800) < ff_get_max_ij_high(a, n)) then Exit;
+
+ //MA30 < MA120
+ for j := a - i_BB_BOX_X * 2 to n - i_BB_BOX_X do
+ begin
+ if as_k_chg_ma_rsi[j].ai_ma[i_ma_index] > as_k_chg_ma_rsi[j].ai_ma[6] then Exit;
+ end;
+
+ if (c > (n - i_BB_BOX_X + 2)) then Exit;
+
+ if as_k_chg[c].i_high > (as_k_chg[n].i_close + 1600) then Exit;
+
+ if (as_k_chg[a].i_high > (as_k_chg[c].i_high + 600)) then Exit;
+
+ if (as_k_chg[c].i_high > (as_k_chg[a].i_high + 600)) then Exit;
+
+ if (as_k_chg[n].i_low < as_k_chg[b].i_low) then Exit;
+
+ if (as_k_chg[n].i_close - as_k_chg[b].i_low) < Round((as_k_chg[c].i_high - as_k_chg[b].i_low) / 3) then Exit;
+ if (as_k_chg[n].i_close - as_k_chg[b].i_low) < Round((as_k_chg[a].i_high - as_k_chg[b].i_low) / 3) then Exit;
+
+ if (b - a < i_BB_BOX_X * 2) then Exit;
+ if (c - b < i_BB_BOX_X) then Exit;
+ if (i - n < 2) then Exit;
+
+ i_MA120_BB_c := c;
+ i_MA120_BB_n := n;
+ i_MA120_BB_i := i;
+ i_MA120_BB_mark := i;
+
+ W_Log('M120 BB', i_tmp_log, i_make_log_ex, 'n !!!');
+ W_Log('M120 BB', i_tmp_log, i_make_log_ex, 'c !!!');
+ W_Log('M120 BB', i_tmp_log, i_make_log_ex, 'b !!!');
+ W_Log('M120 BB', i_tmp_log, i_make_log_ex, 'a !!!');
+
+ Result := -1;
+
+end;
+
+function ff_check_MA120_BB_ex(i: Integer): Integer;
+begin
+ Result := -1;
+ if (i < 888) then Exit;
+
+ if (i - i_MA120_BB_mark > i_BB_BOX_X * 2) then i_MA120_BB_mark := 0;
+
+ if (i_MA120_BB_mark = 0) then Exit;
+
+ W_Log('M120_BB_EX', i_tmp_log, i_make_log_ex, '1 888!!!');
+
+ if (f_last_price_wk < ff_get_min_ij_low(i_MA120_BB_n, i_MA120_BB_i) / 100 - 2.0) then
+ begin
+ W_Log('M120_BB_EX', i_tmp_log, i_make_log_ex, '2 888!!!');
+
+ i_MA120_BB_mark := 0;
+ end;
+
+ if (f_last_price_wk > (as_k_chg[i_MA120_BB_c].i_high / 100 + 5.0)) then
+ begin
+ W_Log('M120_BB_EX', i_tmp_log, i_make_log_ex, '2.5 f_last_price_wk 888!!!');
+
+ W_Log('M120_BB_EX', i_tmp_log, i_make_log_ex, '3 888!!!');
+ i_MA120_BB_mark := 0;
+ end;
+
+ W_Log('M120_BB_EX', i_tmp_log, i_make_log_ex, '4 888!!!');
+
+ if (i_MA120_BB_mark = 0) then Exit;
+
+ W_Log('M120_BB_EX', i_tmp_log, i_make_log_ex, '5 f_last_price_wk 888!!!');
+ W_Log('M120_BB_EX', i_tmp_log, i_make_log_ex, '6 max high!!');
+
+ if (f_last_price_wk > ff_get_max_ij_high(i_MA120_BB_n, i_MA120_BB_i) / 100) and
+ (f_last_price_wk < (ff_get_max_ij_high(i_MA120_BB_n, i_MA120_BB_i) / 100 + 5)) then
+ begin
+ W_Log('M120_BB_EX', as_k_chg[i].i_date, i_wk_log, '88888888!!!');
+ Result := 0;
+ i_MA120_BB_mark := 0;
+ Exit;
+ end;
+ Result := -1;
+
+end;
+
+
+
+function ff_check_rsi_w20_ex(i: Integer): Integer;
+begin
+
+ Result := -1;
+ if (i < 88) then Exit;
+
+ if (i_w20_mark = 0) then Exit;
+
+ if i_w20_A_index > i - i_rsi_IA_min then Exit;
+
+ //if i - i_w20_A_index > i_rsi_IA_max Then i_w20_mark :=0;
+
+ if (f_last_price_wk < (ff_get_min_ij_low(i_w20_A_index, i - i_rsi_IA_min) / 100 - 1.0)) then
+ begin
+ i_w20_mark := 0;
+ end;
+
+ if (f_last_price_wk > (ff_get_max_ij_high(i_w20_A_index, i - i_rsi_IA_max) / 100 + 5.0)) then
+ begin
+ i_w20_mark := 0;
+ end;
+
+ if (i_w20_mark = 0) then Exit;
+
+ if (ff_get_max_ij_high(i_w20_A_index, i - 2) - ff_get_min_ij_low(i_w20_A_index, i - 2) < i_BOX_Y) then
+ begin
+ if (f_last_price_wk > (ff_get_max_ij_high(i_w20_A_index, i_w20_A_index + i_rsi_IA_min) / 100 + 1.0)) and
+ (f_last_price_wk < (ff_get_max_ij_high(i_w20_A_index, i_w20_A_index + i_rsi_IA_min) / 100 + 5.0)) then
+ begin
+ W_Log('W20_EX', as_k_chg[i].i_date, i_wk_log, '888888 !!!');
+ Result := 0;
+ i_w20_mark := 0;
+ Exit;
+ end;
+ end
+ else
+ begin
+ i_w20_mark := 0;
+ end;
+
+ Result := -1;
+
+end;
+
+
+function ff_check_BB_100(i: Integer; i_ma_index: Integer): Integer;
+var
+ j: Integer;
+ n: Integer;
+ a: Integer;
+ b: Integer;
+ c: Integer;
+begin
+
+ Result := -1;
+
+ if (i_act_bb_100 = 0) then exit;
+
+ if (i < 888) then Exit;
+
+ if (i - i_BB_100_mark > i_BB_100_BOX_X * 5) then i_BB_100_mark := 0;
+
+ if (i_BB_100_mark > 888) then Exit;
+
+ //ai_ma[6] for MA120
+ if (as_k_chg[i].i_close < as_k_chg_ma_rsi[i - 1].ai_ma[6] - 100) then Exit;
+ if (as_k_chg[i].i_close > as_k_chg_ma_rsi[i - 1].ai_ma[6] + 1200) then Exit;
+
+ if (as_k_chg_ma_rsi[i].ai_ma[3] < (as_k_chg_ma_rsi[i].ai_ma[6])) then Exit;
+ if (as_k_chg_ma_rsi[i].ai_ma[5] < (as_k_chg_ma_rsi[i].ai_ma[6])) then Exit;
+
+ n := ff_get_min_ij_index(i - i_BB_100_BOX_X - 2, i);
+
+ c := ff_get_max_ij_index(i - 5 * i_BB_100_BOX_X, n);
+
+ b := ff_get_min_ij_index(c - 12 * i_BB_100_BOX_X, c);
+
+ a := ff_get_max_ij_index(b - 12 * i_BB_100_BOX_X, b);
+
+ if (Integer(as_k_chg[a].i_high + 800) < ff_get_max_ij_high(a, n)) then Exit;
+
+ if (Integer(as_k_chg[a].i_high - as_k_chg[b].i_low) > Round((Integer(as_k_chg[a].i_high) - ff_get_min_ij_low(a - 12 * i_BB_100_BOX_X, a)) / 2)) then Exit;
+
+
+ //MA30 < MA120
+ for j := a - i_BB_100_BOX_X * 2 to n - i_BB_100_BOX_X do
+ begin
+ if as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[6] then Exit;
+ if as_k_chg_ma_rsi[j].ai_ma[5] < (as_k_chg_ma_rsi[j].ai_ma[6] - 200) then Exit;
+ if (as_k_chg[j].i_close < as_k_chg_ma_rsi[j - 1].ai_ma[6] - 100) then Exit;
+ end;
+
+ if (c > (n - i_BB_100_BOX_X + 2)) then Exit;
+
+ if as_k_chg[c].i_high > (as_k_chg[n].i_close + 2800) then Exit;
+
+ if (as_k_chg[a].i_high > (as_k_chg[c].i_high + 1200)) then Exit;
+
+ if (as_k_chg[c].i_high > (as_k_chg[a].i_high + 1200)) then Exit;
+
+ if (as_k_chg[n].i_low < as_k_chg[b].i_low) then Exit;
+
+ if (as_k_chg[n].i_close - as_k_chg[b].i_low) < Round((as_k_chg[c].i_high - as_k_chg[b].i_low) / 3) then Exit;
+ if (as_k_chg[n].i_close - as_k_chg[b].i_low) < Round((as_k_chg[a].i_high - as_k_chg[b].i_low) / 3) then Exit;
+
+ if (b - a < i_BB_100_BOX_X * 2) then Exit;
+ if (c - b < i_BB_100_BOX_X) then Exit;
+ if (i - n < 2) then Exit;
+
+ i_BB_100_c := c;
+ i_BB_100_n := n;
+ i_BB_100_i := i;
+ i_BB_100_mark := i;
+
+ W_Log('BB_100', i_tmp_log, i_make_log_ex, 'n !!!');
+ W_Log('BB_100', i_tmp_log, i_make_log_ex, 'c !!!');
+ W_Log('BB_100', i_tmp_log, i_make_log_ex, 'b !!!');
+ W_Log('BB_100', i_tmp_log, i_make_log_ex, 'a !!!');
+
+ Result := -1;
+
+end;
+
+
+function ff_check_BB_100_ex(i: Integer): Integer;
+begin
+ Result := -1;
+ if (i < 888) then Exit;
+
+ if (i_BB_100_mark = 0) then Exit;
+
+ //W_Log('BB_100_EX',as_k_chg[i].i_date,8,'1 888!!!');
+
+ if (f_last_price_wk < ff_get_min_ij_low(i_BB_100_n, i_BB_100_i) / 100 - 2.0) then
+ begin
+ //W_Log('BB_100_EX',as_k_chg[i].i_date,8,'2 888!!!');
+ i_BB_100_mark := 0;
+ end;
+
+ if (f_last_price_wk > (as_k_chg[i_BB_100_c].i_high / 100 + 5.0)) then
+ begin
+ //W_Log('BB_100_EX',as_k_chg[i].i_high,8,'2.5 f_last_price_wk 888!!!');
+ //W_Log('BB_100_EX',as_k_chg[i].i_date,8,'3 888!!!');
+ i_BB_100_mark := 0;
+ end;
+
+ //W_Log('BB_100_EX',as_k_chg[i].i_date,8,'4 888!!!');
+
+ if (i_BB_100_mark = 0) then Exit;
+
+ //W_Log('BB_100_EX',as_k_chg[i].i_high,8,'5 f_last_price_wk 888!!!');
+ //W_Log('BB_100_EX',ff_get_max_ij_high(i_BB_100_n,i_BB_100_i),8,'6 max high!!');
+
+ if (f_last_price_wk > ff_get_max_ij_high(i_BB_100_n, i_BB_100_i) / 100) and
+ (f_last_price_wk < (ff_get_max_ij_high(i_BB_100_n, i_BB_100_i) / 100 + 5)) then
+ begin
+ W_Log('BB_100_EX', as_k_chg[i].i_date, i_wk_log, '88888888!!!');
+ Result := 0;
+ i_BB_100_mark := 0;
+ Exit;
+ end;
+ Result := -1;
+
+end;
+
+
+function ff_get_S_L_Mark(i: Integer): Integer;
+begin
+ Result := -1;
+
+ if (i < 888) then Exit;
+
+ i_MA120_120_chg := as_k_chg_ma_rsi[i].ai_ma[6] - as_k_chg_ma_rsi[i - 120].ai_ma[6];
+
+ if (i_MA120_120_chg > 1600) then
+ begin
+ f_rsi_stop_long := f_rsi_stop * 2;
+ i_make_long := 888
+ end
+ else
+ begin
+ i_make_long := 0;
+ f_rsi_stop_long := f_rsi_stop;
+ end;
+
+ if (i_MA120_120_chg < -1600) then
+ begin
+ f_rsi_stop_short := f_rsi_stop * 2;
+ i_make_short := 888
+ end
+ else
+ begin
+ f_rsi_stop_short := f_rsi_stop;
+ i_make_short := 0;
+ end;
+
+ if (f_mbm_stop_short > 1.0) then
+ f_rsi_stop_short := f_mbm_stop_short;
+
+ if (f_mbm_stop_long > 1.0) then
+ f_rsi_stop_long := f_mbm_stop_long;
+
+ if (f_mbm_cut_short > 1.0) then
+ f_rsi_cut_short := f_mbm_cut_short
+ else
+ f_rsi_cut_short := f_rsi_cut;
+
+ if (f_mbm_stop_long > 1.0) then
+ f_rsi_cut_long := f_mbm_cut_long
+ else
+ f_rsi_cut_long := f_rsi_cut;
+
+end;
+
+
+
+
+
+
+
+function ff_check_M30_short(i: Integer): Integer;
+var
+ j: Integer;
+ n: Integer;
+ a: Integer;
+ b: Integer;
+ c: Integer;
+begin
+
+ Result := -1;
+
+ if (i < 288) then Exit;
+
+ if (i - i_M30_short_mark > i_M30_short_BOX_X * 2) then i_M30_short_mark := 0;
+
+ if (i_M30_short_mark > 288) then Exit;
+
+ //ai_ma[6] for MA120
+ if (as_k_chg[i].i_close > as_k_chg_ma_rsi[i - 1].ai_ma[5] - 100) then Exit;
+
+ if (as_k_chg[i].i_close < as_k_chg_ma_rsi[i - 1].ai_ma[5] - 1200) then Exit;
+
+ if (as_k_chg_ma_rsi[i].ai_ma[3] < (as_k_chg_ma_rsi[i].ai_ma[6])) then Exit;
+ if (as_k_chg_ma_rsi[i].ai_ma[5] < (as_k_chg_ma_rsi[i].ai_ma[6])) then Exit;
+
+ n := ff_get_max_ij_index(i - i_M30_short_BOX_X - 2, i);
+
+ c := ff_get_min_ij_index(i - 5 * i_M30_short_BOX_X, n);
+
+ b := ff_get_max_ij_index(c - 8 * i_M30_short_BOX_X, c);
+
+ a := ff_get_min_ij_index(b - 8 * i_M30_short_BOX_X, b);
+
+ if (Integer(as_k_chg[a].i_low + 800) < ff_get_min_ij_low(a, n)) then Exit;
+
+ //MA30 < MA120
+ for j := a to n - i_M30_short_BOX_X do
+ begin
+ if as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[6] then Exit;
+ end;
+
+ if (c > (n - i_M30_short_BOX_X + 2)) then Exit;
+
+ //if ((as_k_chg[c].i_low +1600) < as_k_chg[n].i_close) Then Exit;
+
+ //if (as_k_chg[a].i_low > (as_k_chg[c].i_low + 800) ) Then Exit;
+
+ //if (as_k_chg[c].i_low > (as_k_chg[a].i_low + 800) ) Then Exit;
+
+ if (as_k_chg[n].i_high > as_k_chg[b].i_high) then Exit;
+
+ if (b - a < i_M30_short_BOX_X * 2) then Exit;
+ if (c - b < i_M30_short_BOX_X) then Exit;
+ if (i - n < 2) then Exit;
+
+ i_M30_short_c := c;
+ i_M30_short_n := n;
+ i_M30_short_i := i;
+ i_M30_short_mark := i;
+
+ //W_Log('M30_short',as_k_chg[n].i_date,8,'n !!!');
+ //W_Log('M30_short',as_k_chg[c].i_date,8,'c !!!');
+ //W_Log('M30_short',as_k_chg[b].i_date,8,'b !!!');
+ //W_Log('M30_short',as_k_chg[a].i_date,8,'a !!!');
+
+ Result := -1;
+
+end;
+
+function ff_check_M30_short_ex(i: Integer): Integer;
+begin
+ Result := -1;
+ if (i < 288) then Exit;
+
+ if (i_M30_short_mark = 0) then Exit;
+
+ //W_Log('M30_short_EX',as_k_chg[i].i_date,8,'1 888!!!');
+
+ if (f_last_price_wk > ff_get_max_ij_high(i_M30_short_n, i_M30_short_i) / 100 - 2.0) then
+ begin
+ //W_Log('M30_short_EX',as_k_chg[i].i_date,8,'2 888!!!');
+ i_M30_short_mark := 0;
+ end;
+
+ if (f_last_price_wk < (as_k_chg[i_M30_short_c].i_low / 100 - 15.0)) then
+ begin
+ //W_Log('M30_short_EX',as_k_chg[i].i_high,8,'2.5 f_last_price_wk 888!!!');
+
+ //W_Log('M30_short_EX',as_k_chg[i].i_date,8,'3 888!!!');
+ i_M30_short_mark := 0;
+ end;
+
+ //W_Log('M120_BB_EX',as_k_chg[i].i_date,8,'4 888!!!');
+
+ if (i_M30_short_mark = 0) then Exit;
+
+ //W_Log('M30_short_EX',as_k_chg[i].i_low,8,'5 f_last_price_wk 888!!!');
+ //W_Log('M30_short_EX',ff_get_min_ij_low(i_M30_short_n,i_M30_short_i),8,'6 min low!!');
+
+ if (f_last_price_wk > as_k_chg_ma_rsi[i - 1].ai_ma[6] / 100) then Exit;
+
+ if (f_last_price_wk < ff_get_min_ij_low(i_M30_short_n, i_M30_short_i) / 100) and
+ (f_last_price_wk > (ff_get_min_ij_low(i_M30_short_n, i_M30_short_i) / 100 - 15)) then
+ begin
+ W_Log('M30_short_EX', as_k_chg[i].i_date, i_wk_log, '88888888!!');
+ Result := 0;
+ i_M30_short_mark := 0;
+ Exit;
+ end;
+ Result := -1;
+
+end;
+
+function ff_check_short_1(i: Integer): Integer;
+var
+ j: Integer;
+ a: Integer;
+ b: Integer;
+ k: Integer;
+ m: Cardinal;
+begin
+
+ Result := -1;
+
+ if (i_act_short = 0) then Exit;
+
+ if (i < 888) then Exit;
+
+ if (i - i_short_1_mark > i_BB_BOX_X * 3) then i_short_1_mark := 0;
+
+ if (i_short_1_mark > 888) then Exit;
+
+ //ai_ma[6] for MA120
+ if (as_k_chg[i].i_close > as_k_chg_ma_rsi[i - 1].ai_ma[6]) then Exit;
+ if (as_k_chg[i].i_close > as_k_chg_ma_rsi[i - 1].ai_ma[5]) then Exit;
+ if (as_k_chg[i].i_close > as_k_chg_ma_rsi[i - 1].ai_ma[3]) then Exit;
+ if (as_k_chg[i].i_close > as_k_chg_ma_rsi[i - 1].ai_ma[8]) then Exit;
+
+ if (as_k_chg_ma_rsi[i].ai_ma[6] > as_k_chg_ma_rsi[i].ai_ma[8] + 30) then Exit;
+ m := 400;
+ a := 0;
+ k := i;
+ for j := k downto k - i_BB_BOX_X * 8 do
+ begin
+ if ((as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[3] + m) and
+ (as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[6] + m) and
+ (as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[8] + m) and
+ (as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[6] + m) and
+ (as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[8] + m) and
+ (as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[3] + m) and
+ (as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[5] + m) and
+ (as_k_chg_ma_rsi[j].ai_ma[5] < as_k_chg_ma_rsi[j].ai_ma[6] + m) and
+ (as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[5] + m) and
+ (as_k_chg_ma_rsi[j].ai_ma[5] < as_k_chg_ma_rsi[j].ai_ma[8] + m) and
+ (as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[5] + m) and
+ (as_k_chg_ma_rsi[j].ai_ma[5] < as_k_chg_ma_rsi[j].ai_ma[3] + m)) then
+ begin
+ a := j;
+ Break;
+ end;
+ end;
+
+ if (a = 0) then Exit;
+
+ if (ff_get_max_ij_high(i - i_BB_BOX_X * 8, i) < integer(as_k_chg_ma_rsi[a].ai_ma[6])) then Exit;
+
+ if (ff_get_max_ij_high(i - 3, i) < integer(as_k_chg_ma_rsi[i].ai_ma[3])) then Exit;
+
+
+ b := 0;
+ k := i;
+ for j := k downto k - i_BB_BOX_X * 8 do
+ begin
+ if ((as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[8] + 20) and
+ (as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[6] + 20)) then
+ begin
+ b := j;
+ Break;
+ end;
+ end;
+
+ if ((b = 0) or (b < a - i_BB_BOX_X * 2)) then Exit;
+
+ if (as_k_chg[b].i_high + 1200 < as_k_chg_ma_rsi[b].ai_ma[6]) then exit;
+
+ if (as_k_chg_ma_rsi[i - 1].ai_ma[3] > as_k_chg_ma_rsi[i - 1].ai_ma[5]) then Exit;
+ if (as_k_chg_ma_rsi[i - 1].ai_ma[5] > as_k_chg_ma_rsi[i - 1].ai_ma[6]) then Exit;
+ if (as_k_chg_ma_rsi[i - 1].ai_ma[6] > as_k_chg_ma_rsi[i - 1].ai_ma[8]) then Exit;
+
+ if (as_k_chg_ma_rsi[i - 1].ai_ma[3] > as_k_chg_ma_rsi[a].ai_ma[3]) then Exit;
+ if (as_k_chg_ma_rsi[i - 1].ai_ma[5] > as_k_chg_ma_rsi[a].ai_ma[5]) then Exit;
+ if (as_k_chg_ma_rsi[i - 1].ai_ma[6] > as_k_chg_ma_rsi[a].ai_ma[6]) then Exit;
+ if (as_k_chg_ma_rsi[i - 1].ai_ma[8] > as_k_chg_ma_rsi[a].ai_ma[8]) then Exit;
+
+ if (ff_get_max_ij_high(i - 3, i) > integer(as_k_chg_ma_rsi[i].ai_ma[6])) and
+ (as_k_chg[i].i_close > as_k_chg_ma_rsi[i].ai_ma[5]) and
+ (as_k_chg[i].i_close > as_k_chg_ma_rsi[i].ai_ma[3]) and
+ (as_k_chg[i].i_close < as_k_chg_ma_rsi[i - 1].ai_ma[6]) then
+ begin
+ i_short_1_mark := i;
+ W_Log('short_1', as_k_chg[i].i_date, i_wk_log, 'Down Under M120, SET i_short_1_mark');
+ Result := 0;
+ Exit;
+ end;
+
+
+ if (as_k_chg[i].i_close < as_k_chg_ma_rsi[i - 1].ai_ma[3]) then
+ begin
+ i_short_1_mark := i;
+ W_Log('Short_1', as_k_chg[i].i_date, i_wk_log, 'SET i_short_1_mark!');
+ Result := 0;
+ Exit;
+ end;
+
+ Result := -1;
+
+end;
+
+
+function ff_check_short_1_ex(i: Integer): Integer;
+begin
+ Result := -1;
+ if (i < 288) then Exit;
+
+ if (i_short_1_mark = 0) then Exit;
+
+ if (f_last_price_wk > ff_get_max_ij_high(i - 5, i - 1) / 100 + 2.0) then
+ begin
+ i_short_1_mark := 0;
+ end;
+
+ if (f_last_price_wk < (ff_get_min_ij_low(i - i_BB_BOX_X * 2, i - 1) / 100 - 3.0)) then
+ begin
+ i_short_1_mark := 0;
+ end;
+
+ if (i_short_1_mark = 0) then Exit;
+
+ if (f_last_price_wk < as_k_chg_ma_rsi[i - 1].ai_ma[3] / 100) and
+ (f_last_price_wk > (as_k_chg_ma_rsi[i - 1].ai_ma[3] / 100 - 5)) then
+ begin
+ W_Log('Short_1', as_k_chg[i].i_date, i_wk_log, '88888888!!');
+ i_short_1_mark := 0;
+ Result := 0;
+ Exit;
+ end;
+ Result := -1;
+end;
+
+
+function ff_get_BS_Mark(i: Integer): Integer;
+begin
+ Result := -1;
+
+ if (i < 888) then Exit;
+
+ i_B_S_Flag_10 := as_k_chg_ma_rsi[i - 10].ai_ma[6] - as_k_chg_ma_rsi[i - 10].ai_ma[8];
+ i_B_S_Flag_18 := as_k_chg_ma_rsi[i - 18].ai_ma[6] - as_k_chg_ma_rsi[i - 18].ai_ma[8];
+
+ i_B_S_Flag := as_k_chg_ma_rsi[i].ai_ma[6] - as_k_chg_ma_rsi[i].ai_ma[8];
+
+ if i_B_S_Flag > 0 then
+ begin
+ //i_act_rsi:=10;
+ //i_act_m120:=10;
+ //i_act_bb_100:=10;
+ //i_act_short:=0;
+ end
+ else
+ begin
+ //i_act_short:=10;
+ //i_act_rsi:=0;
+ //i_act_m120:=0;
+ //i_act_bb_100:=0;
+ end;
+
+ if (Integer(as_k_chg_ma_rsi[i].ai_ma[8] - as_k_chg_ma_rsi[i].ai_ma[3]) > 700) and
+ (i_short_long_01 = 888) then
+ begin
+ if (as_k_chg_ma_rsi[i].ai_ma[8] > as_k_chg_ma_rsi[i].ai_ma[6] + 100) and
+ (as_k_chg_ma_rsi[i].ai_ma[6] > as_k_chg_ma_rsi[i].ai_ma[5] + 50) and
+ (as_k_chg_ma_rsi[i].ai_ma[5] > as_k_chg_ma_rsi[i].ai_ma[3] + 100) then
+ begin
+ //for short
+ i_short_long_01 := 0;
+ i_short_long_date := as_k_chg[i].i_date mod 10000;
+ i_short_long_index := i;
+ W_Log(PChar(IntToStr(as_k_chg[i].i_date)), i_wk_log, i_wk_log, 'DO SHORT ONLY!');
+ end;
+ end;
+
+ if (Integer(as_k_chg_ma_rsi[i].ai_ma[8]) < as_k_chg[i].i_high) and
+ (i_short_long_01 = 0) then
+ begin
+ i_short_long_01 := 888;
+ W_Log(PChar(IntToStr(as_k_chg[i].i_date)), i_wk_log, i_wk_log, 'DO SHORT END!');
+ end;
+
+
+ if (Integer(as_k_chg_ma_rsi[i].ai_ma[3] - as_k_chg_ma_rsi[i].ai_ma[8]) > 700) and
+ (i_short_long_01 = 888) then
+ begin
+ if (as_k_chg_ma_rsi[i].ai_ma[3] > as_k_chg_ma_rsi[i].ai_ma[5] + 100) and
+ (as_k_chg_ma_rsi[i].ai_ma[5] > as_k_chg_ma_rsi[i].ai_ma[6] + 50) and
+ (as_k_chg_ma_rsi[i].ai_ma[6] > as_k_chg_ma_rsi[i].ai_ma[8] + 100) then
+ begin
+ //for short
+ i_short_long_01 := 1;
+ i_short_long_index := i;
+ i_short_long_date := as_k_chg[i].i_date mod 10000;
+ W_Log(PChar(IntToStr(as_k_chg[i].i_date)), i_wk_log, i_wk_log, 'DO LONG ONLY!');
+ end;
+ end;
+
+ if (Integer(as_k_chg_ma_rsi[i].ai_ma[8]) > as_k_chg[i].i_low) and
+ (i_short_long_01 = 1) then
+ begin
+ i_short_long_01 := 888;
+ W_Log(PChar(IntToStr(as_k_chg[i].i_date)), i_wk_log, i_wk_log, 'DO LONG END!');
+ end;
+
+ if (i_short_long_01 = 0) then
+ begin
+ //frmMain2.GRID_S008.Cells[0,0]:='SHORT';
+ //frmMain2.Header.Cells[12,0] := IntToStr(i_short_long_date);
+ //frmMain2.Header.Cells[13,0] := 'SHORT!';
+ end
+ else if (i_short_long_01 = 1) then
+ begin
+ //frmMain2.GRID_S008.Cells[0,0]:='LONG';
+ //frmMain2.Header.Cells[12,0] := IntToStr(i_short_long_date);
+ //frmMain2.Header.Cells[13,0] := 'LONG!';
+ end
+ else
+ begin
+ //frmMain2.GRID_S008.Cells[0,0]:='NOTRADE';
+ //frmMain2.Header.Cells[12,0] := ' ';
+ //frmMain2.Header.Cells[13,0] := 'NO TRADE!';
+ end;
+
+end;
+
+function ff_get_long_mark_8(i: Integer): Integer;
+var
+ i_B_S_Flag_tmp: Integer;
+ i_B_S_Flag_10_tmp: Integer;
+ i_B_S_Flag_18_tmp: Integer;
+begin
+ Result := -1;
+
+ if (i < 888) then Exit;
+
+ i_B_S_Flag_10_tmp := as_k_chg_ma_rsi[i - 10].ai_ma[6] - as_k_chg_ma_rsi[i - 10].ai_ma[8];
+ i_B_S_Flag_18_tmp := as_k_chg_ma_rsi[i - 18].ai_ma[6] - as_k_chg_ma_rsi[i - 18].ai_ma[8];
+ i_B_S_Flag_tmp := as_k_chg_ma_rsi[i].ai_ma[6] - as_k_chg_ma_rsi[i].ai_ma[8];
+
+ //if( i_B_S_Flag_18_tmp>0 ) and ( i_B_S_Flag_10_tmp>0 ) Then
+ //if (i_B_S_Flag_tmp < 0 ) Then
+ //begin
+ // Result :=i;
+ //end;
+
+ if (i_B_S_Flag_18_tmp < 0) and (i_B_S_Flag_10_tmp < 0) then
+ if (i_B_S_Flag_tmp > 0) then
+ begin
+ Result := i;
+ end;
+
+end;
+
+function ff_get_ma600_mark(i: Integer): Integer;
+var
+ i_low_600: Integer;
+ i_high_600: Integer;
+ i_check_count: Integer;
+begin
+ Result := -1;
+
+ if (i < 888) then Exit;
+
+ i_check_count := 38;
+
+ i_low_600 := ff_get_min_ij_low(i - i_check_count, i);
+ i_high_600 := ff_get_max_ij_high(i - i_check_count, i);
+
+ if (i_low_600 < as_k_chg_ma_rsi[i - i_check_count].ai_ma[9]) and
+ (i_low_600 < as_k_chg_ma_rsi[i].ai_ma[9]) and
+ (as_k_chg_ma_rsi[i].ai_ma[0] > as_k_chg_ma_rsi[i - i_check_count].ai_ma[9] - 1000) and
+ (as_k_chg_ma_rsi[i].ai_ma[0] > as_k_chg_ma_rsi[i].ai_ma[9] - 1000) and
+ (i_low_600 > as_k_chg_ma_rsi[i - i_check_count].ai_ma[9] - 1200) and
+ (i_low_600 > as_k_chg_ma_rsi[i].ai_ma[9] - 1200) and
+
+ //( as_k_chg_ma_rsi[i-300].ai_ma[9] < as_k_chg_ma_rsi[i].ai_ma[9] ) and
+
+ (as_k_chg_ma_rsi[i].ai_ma[6] < as_k_chg_ma_rsi[i].ai_ma[9]) and
+
+ (i_high_600 < as_k_chg_ma_rsi[i - i_check_count].ai_ma[9]) and
+ (i_high_600 < as_k_chg_ma_rsi[i].ai_ma[9])
+ //( i_high_600 > as_k_chg_ma_rsi[i-10].ai_ma[9] - 500 ) and
+ //( i_high_600 > as_k_chg_ma_rsi[i].ai_ma[9] -500 )
+ then
+ begin
+
+ if ((as_k_chg_ma_rsi[i - 1].ai_ma[8] > as_k_chg_ma_rsi[i - 1].ai_ma[6]) and
+ (as_k_chg_ma_rsi[i - 1].ai_ma[6] > as_k_chg_ma_rsi[i - 1].ai_ma[5]) and
+ (as_k_chg_ma_rsi[i - 1].ai_ma[5] > as_k_chg_ma_rsi[i - 1].ai_ma[4]) and
+
+ (as_k_chg_ma_rsi[i - 1].ai_ma[3] < as_k_chg_ma_rsi[i - 5].ai_ma[3]) and
+ (as_k_chg_ma_rsi[i - 1].ai_ma[4] < as_k_chg_ma_rsi[i - 5].ai_ma[4]) and
+ (as_k_chg_ma_rsi[i - 1].ai_ma[5] < as_k_chg_ma_rsi[i - 5].ai_ma[5]) and
+
+ (as_k_chg_ma_rsi[i - 1].ai_ma[4] > as_k_chg_ma_rsi[i - 1].ai_ma[3])) then
+
+ Result := i;
+
+ end;
+
+end;
+
+function ff_get_ma600_mark_long(i: Integer): Integer;
+var
+ i_low_600: Integer;
+ i_high_600: Integer;
+ i_check_count: Integer;
+begin
+ Result := -1;
+
+ if (i < 888) then Exit;
+
+ i_check_count := 28;
+
+ i_low_600 := ff_get_min_ij_low(i - i_check_count, i);
+ i_high_600 := ff_get_max_ij_high(i - i_check_count, i);
+
+ if (i_low_600 > as_k_chg_ma_rsi[i - i_check_count].ai_ma[9]) and
+ (i_low_600 > as_k_chg_ma_rsi[i].ai_ma[9]) and
+ (as_k_chg_ma_rsi[i].ai_ma[1] < as_k_chg_ma_rsi[i - i_check_count].ai_ma[9] + 1000) and
+ (as_k_chg_ma_rsi[i].ai_ma[1] < as_k_chg_ma_rsi[i].ai_ma[9] + 1000) and
+ (i_high_600 < as_k_chg_ma_rsi[i - i_check_count].ai_ma[9] + 1200) and
+ (i_high_600 < as_k_chg_ma_rsi[i].ai_ma[9] + 1200) and
+
+ (as_k_chg_ma_rsi[i - 300].ai_ma[9] > as_k_chg_ma_rsi[i].ai_ma[9]) and
+
+ //( as_k_chg_ma_rsi[i].ai_ma[5] > as_k_chg_ma_rsi[i].ai_ma[9] ) and
+
+ (i_high_600 > as_k_chg_ma_rsi[i - i_check_count].ai_ma[9]) and
+ (i_high_600 > as_k_chg_ma_rsi[i].ai_ma[9])
+ then
+ begin
+
+ if ((as_k_chg_ma_rsi[i - 1].ai_ma[8] < as_k_chg_ma_rsi[i - 1].ai_ma[6]) and
+ (as_k_chg_ma_rsi[i - 1].ai_ma[6] < as_k_chg_ma_rsi[i - 1].ai_ma[5]) and
+ (as_k_chg_ma_rsi[i - 1].ai_ma[5] < as_k_chg_ma_rsi[i - 1].ai_ma[4]) and
+
+ (as_k_chg_ma_rsi[i - 1].ai_ma[3] > as_k_chg_ma_rsi[i - 5].ai_ma[3]) and
+ (as_k_chg_ma_rsi[i - 1].ai_ma[4] > as_k_chg_ma_rsi[i - 5].ai_ma[4]) and
+ (as_k_chg_ma_rsi[i - 1].ai_ma[5] > as_k_chg_ma_rsi[i - 5].ai_ma[5]) and
+
+ (as_k_chg_ma_rsi[i - 1].ai_ma[4] < as_k_chg_ma_rsi[i - 1].ai_ma[3])) then
+
+ Result := i;
+
+ end;
+
+end;
+
+
+
+
+
+function ff_check_short_250(i: Integer): Integer;
+var
+ j: Integer;
+ b: Integer;
+ k: Integer;
+ i_high: Integer;
+ i_low: Integer;
+
+begin
+
+ Result := -1;
+
+ if (i_act_short = 0) then Exit;
+
+ if (i < 888) then Exit;
+
+ if (i - i_short_250_mark > i_BB_BOX_X) then i_short_250_mark := 0;
+
+ if (i_short_250_mark > 888) then Exit;
+
+ if (as_k_chg[i].i_close < as_k_chg_ma_rsi[i - 1].ai_ma[6]) then Exit;
+
+ b := 0;
+ k := i;
+ for j := k - 120 to i - i_BB_BOX_X do
+ begin
+ if (as_k_chg[j].i_high > as_k_chg_ma_rsi[j].ai_ma[8] + 20) then
+ begin
+ Exit;
+ end;
+ end;
+
+
+ b := 0;
+ k := i;
+ for j := k downto 888 do
+ begin
+ if ((as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[8] + 20) and
+ (as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[6] + 20)) then
+ begin
+ b := j;
+ Break;
+ end;
+ end;
+
+ if b = 0 then Exit;
+
+ i_high := ff_get_max_ij_high(b, i);
+ i_low := ff_get_min_ij_low(b, i);
+
+ if (i_high < integer(as_k_chg[i].i_close)) then Exit;
+
+ if (i_low > integer(as_k_chg[i].i_low - 800)) then Exit;
+
+ if ((i_high - i_low) > integer(3 * (integer(as_k_chg[i].i_high) - i_low))) then Exit;
+
+ if ((100 * (i_high - i_low) / (i_high + 100)) < 1) then Exit;
+
+ if (as_k_chg[b].i_close < as_k_chg[i].i_close + 800) then Exit;
+
+ if (as_k_chg_ma_rsi[i - 1].ai_ma[6] > as_k_chg_ma_rsi[b].ai_ma[6]) then Exit;
+ if (as_k_chg_ma_rsi[i - 1].ai_ma[8] > as_k_chg_ma_rsi[b].ai_ma[8]) then Exit;
+
+ if (as_k_chg_ma_rsi[i].ai_ma[3] > as_k_chg_ma_rsi[i].ai_ma[8]) then Exit;
+ if (as_k_chg_ma_rsi[i].ai_ma[5] > as_k_chg_ma_rsi[i].ai_ma[8]) then Exit;
+ if (as_k_chg_ma_rsi[i].ai_ma[6] > as_k_chg_ma_rsi[i].ai_ma[8]) then Exit;
+
+ if (ff_get_max_ij_high(i - 3, i) > integer(as_k_chg_ma_rsi[i].ai_ma[8])) and
+ (as_k_chg[i].i_close > as_k_chg_ma_rsi[i].ai_ma[6]) and
+ (as_k_chg[i].i_close > as_k_chg_ma_rsi[i].ai_ma[3]) and
+ (as_k_chg[i].i_close < as_k_chg_ma_rsi[i - 1].ai_ma[8]) then
+ begin
+ i_short_250_mark := i;
+ W_Log('Short_1', as_k_chg[i].i_date, i_wk_log, 'SET i_short_250_mark!');
+ Result := 0;
+ Exit;
+ end;
+
+ Result := -1;
+
+end;
+
+
+
+
+
+function ff_check_short_30(i: Integer): Integer;
+var
+ j: Integer;
+ b: Integer;
+ k: Integer;
+ i_high: Integer;
+begin
+
+ Result := -1;
+
+ if (i_act_short = 0) then Exit;
+
+ if (i < 888) then Exit;
+
+ if (i - i_short_30_mark > i_BB_BOX_X) then i_short_30_mark := 0;
+
+ if (i_short_30_mark > 888) then Exit;
+
+ if (as_k_chg[i].i_close > as_k_chg_ma_rsi[i - 1].ai_ma[5]) then Exit;
+ if (as_k_chg[i].i_close > as_k_chg_ma_rsi[i - 1].ai_ma[6]) then Exit;
+ if (as_k_chg[i].i_close > as_k_chg_ma_rsi[i - 1].ai_ma[8]) then Exit;
+
+ k := i;
+ for j := k - 5 downto k - i_BB_BOX_X - 5 do
+ begin
+ if (as_k_chg[j].i_high > as_k_chg_ma_rsi[j].ai_ma[3]) then Exit;
+ end;
+
+ b := 0;
+ k := i;
+ for j := k downto 888 do
+ begin
+ if ((as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[8] + 20) and
+ (as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[6] + 20)) then
+ begin
+ b := j;
+ Break;
+ end;
+ end;
+
+ if b = 0 then Exit;
+
+ //for 1.5 hour
+ if ((i - b) > 58) then Exit;
+
+ i_high := ff_get_max_ij_high(b, i);
+
+ if (i_high < integer(as_k_chg[i].i_close)) then Exit;
+ if (as_k_chg[b].i_close < as_k_chg[i].i_close + 800) then Exit;
+
+ if (as_k_chg_ma_rsi[i - 1].ai_ma[6] > as_k_chg_ma_rsi[b].ai_ma[6] + 100) then Exit;
+ if (as_k_chg_ma_rsi[i - 1].ai_ma[8] > as_k_chg_ma_rsi[b].ai_ma[8] + 100) then Exit;
+
+ if (ff_get_max_ij_high(i - 6, i) > integer(as_k_chg_ma_rsi[i].ai_ma[3])) and
+ (as_k_chg[i - 1].i_close < as_k_chg_ma_rsi[i - 1].ai_ma[3]) and
+ (as_k_chg[i].i_close < as_k_chg[i - 1].i_close) and
+ ((as_k_chg[i - 2].i_high > as_k_chg_ma_rsi[i - 2].ai_ma[3]) or
+ (as_k_chg[i - 3].i_high > as_k_chg_ma_rsi[i - 3].ai_ma[3]) or
+ (as_k_chg[i - 4].i_high > as_k_chg_ma_rsi[i - 4].ai_ma[3]) or
+ (as_k_chg[i - 1].i_high > as_k_chg_ma_rsi[i - 1].ai_ma[3]) or
+ (as_k_chg[i - 6].i_high > as_k_chg_ma_rsi[i - 6].ai_ma[3]) or
+ (as_k_chg[i - 5].i_high > as_k_chg_ma_rsi[i - 5].ai_ma[3])) then
+ begin
+ i_short_30_mark := i;
+ W_Log('short_30', as_k_chg[i].i_date, i_wk_log, 'short 30!!!');
+ Result := 0;
+ Exit;
+ end;
+
+ Result := -1;
+
+end;
+
+function ff_check_short_120(i: Integer): Integer;
+var
+ j: Integer;
+ k: Integer;
+ i_high: Integer;
+ i_low: Integer;
+begin
+
+ Result := -1;
+
+ if (i_act_short = 0) then Exit;
+
+ if (i < 888) then Exit;
+
+ if (i - i_short_120_mark > i_BB_BOX_X) then i_short_120_mark := 0;
+
+
+ if (i_short_120_mark > 888) then Exit;
+
+ if (as_k_chg_ma_rsi[i].ai_ma[6] > as_k_chg_ma_rsi[i].ai_ma[8]) then Exit;
+ if (as_k_chg[i].i_close > as_k_chg_ma_rsi[i - 1].ai_ma[6]) then Exit;
+
+ k := i;
+ for j := k - 5 downto k - 128 do
+ begin
+ if (as_k_chg[j].i_high > as_k_chg_ma_rsi[j].ai_ma[6]) then Exit;
+ end;
+
+ i_low := ff_get_min_ij_low(i - i_BB_BOX_X * 8, i);
+
+ if (i_low > integer(as_k_chg[i].i_close)) then Exit;
+
+ i_high := ff_get_max_ij_high(i - i_BB_BOX_X * 3, i - 5);
+ if (i_high > integer(as_k_chg_ma_rsi[i].ai_ma[6])) then Exit;
+
+ if (ff_get_max_ij_high(i - 3, i) > integer(as_k_chg_ma_rsi[i].ai_ma[6])) and
+ (as_k_chg[i].i_close > as_k_chg_ma_rsi[i].ai_ma[3]) and
+ (as_k_chg[i].i_close > as_k_chg_ma_rsi[i].ai_ma[5]) and
+ (as_k_chg[i].i_close < as_k_chg_ma_rsi[i].ai_ma[6]) then
+ begin
+ i_short_120_mark := i;
+ W_Log('short_120', as_k_chg[i].i_date, 8, 'short 120!!!');
+ Result := 0;
+ Exit;
+ end;
+
+ Result := -1;
+
+end;
+
+
+function ff_short_pass3_mark(i: Integer): Integer;
+var
+ j: Integer;
+ c: Integer;
+ b: Integer;
+ a: Integer;
+ k: Integer;
+begin
+
+ Result := -1;
+
+ if (i < 888) then Exit;
+
+ if (i - i_short_pass3_mark > 58) then i_short_pass3_mark := 0;
+
+ if (i_short_pass3_mark > 888) then Exit;
+
+ if (as_k_chg[i].i_close > as_k_chg_ma_rsi[i - 1].ai_ma[8]) then Exit;
+ if (as_k_chg[i].i_close > as_k_chg_ma_rsi[i - 1].ai_ma[5]) then Exit;
+ if (as_k_chg[i].i_close > as_k_chg_ma_rsi[i - 1].ai_ma[6]) then Exit;
+
+ k := i;
+ for j := k - 8 downto k - 38 do
+ begin
+ // if( as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[6] ) Then Exit;
+ end;
+
+ k := i;
+ c := 0;
+ for j := k - 1 downto k - i_BB_BOX_X * 6 do
+ begin
+ if ((as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[3] + 20) and
+ (as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[8] + 20)) then
+ begin
+ c := j;
+ Break;
+ end;
+ end;
+
+ if (c = 0) then Exit;
+
+ k := i;
+ b := 0;
+ for j := k - 1 downto k - i_BB_BOX_X * 6 do
+ begin
+ if ((as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[3] + 20) and
+ (as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[6] + 20)) then
+ begin
+ b := j;
+ Break;
+ end;
+ end;
+
+ if (b = 0) then Exit;
+
+ a := 0;
+ k := i;
+ for j := k - 1 downto k - i_BB_BOX_X * 6 do
+ begin
+ if ((as_k_chg_ma_rsi[j].ai_ma[5] < as_k_chg_ma_rsi[j].ai_ma[3] + 20) and
+ (as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[5] + 20)) then
+ begin
+ a := j;
+ Break;
+ end;
+ end;
+
+ if (a = 0) then Exit;
+
+ if ((i - a) > i_BB_BOX_X) and ((i - b) > i_BB_BOX_X) and ((i - c) > i_BB_BOX_X) then Exit;
+
+
+ for j := a - 2 downto a - i_BB_BOX_X do
+ begin
+ if (as_k_chg_ma_rsi[j].ai_ma[5] > as_k_chg_ma_rsi[j].ai_ma[3]) then Exit;
+ end;
+
+ for j := b - 2 downto b - i_BB_BOX_X do
+ begin
+ if (as_k_chg_ma_rsi[j].ai_ma[6] > as_k_chg_ma_rsi[j].ai_ma[3]) then Exit;
+ end;
+
+ for j := c - 2 downto c - i_BB_BOX_X do
+ begin
+ if (as_k_chg_ma_rsi[j].ai_ma[8] > as_k_chg_ma_rsi[j].ai_ma[3]) then Exit;
+ end;
+
+ i_short_pass3_mark := i;
+ W_Log('short_pass3_mark', as_k_chg[i].i_date, i_wk_log, 'SET short pass3_mark!!!');
+
+ Result := 0;
+
+end;
+
+
+
+function ff_pass3_short_120(i: Integer): Integer;
+var
+ j: Integer;
+ k: Integer;
+ i_high: Integer;
+ i_low: Integer;
+begin
+
+ Result := -1;
+
+ if (i_act_short = 0) then Exit;
+
+ if (i_short_pass3_mark = 0) then Exit;
+
+ if (i - i_pass3_short_120_mark > i_BB_BOX_X) then i_pass3_short_120_mark := 0;
+
+ if (i_pass3_short_120_mark > 888) then Exit;
+
+ if (i < 888) then Exit;
+
+ if (as_k_chg_ma_rsi[i].ai_ma[6] > as_k_chg_ma_rsi[i].ai_ma[8]) then Exit;
+ if (as_k_chg_ma_rsi[i].ai_ma[5] > as_k_chg_ma_rsi[i].ai_ma[8]) then Exit;
+
+ if (as_k_chg[i].i_close > as_k_chg_ma_rsi[i - 1].ai_ma[6]) then Exit;
+
+ if (ff_get_max_ij_high(i - 3, i) > integer(as_k_chg_ma_rsi[i].ai_ma[6])) and
+ (as_k_chg[i].i_close > as_k_chg_ma_rsi[i].ai_ma[3]) and
+ (as_k_chg[i].i_close < as_k_chg_ma_rsi[i].ai_ma[6]) then
+ begin
+ i_pass3_short_120_mark := i;
+ W_Log('pass3_short120', as_k_chg[i].i_date, i_wk_log, 'pass3_short120!!!');
+ Result := 0;
+ Exit;
+ end;
+
+ Result := -1;
+
+end;
+
+
+
+
+function ff_check_long_pass_3(i: Integer): Integer;
+var
+ j: Integer;
+ b: Integer;
+ a: Integer;
+ k: Integer;
+begin
+
+ Result := -1;
+
+ if (i < 888) then Exit;
+
+ if (i - i_pass_3_mark > i_BB_BOX_X) then i_pass_3_mark := 0;
+
+ if (i_pass_3_mark > 888) then Exit;
+
+ if (as_k_chg[i].i_close < as_k_chg_ma_rsi[i - 1].ai_ma[8]) then Exit;
+ if (as_k_chg[i].i_close < as_k_chg_ma_rsi[i - 1].ai_ma[5]) then Exit;
+ if (as_k_chg[i].i_close < as_k_chg_ma_rsi[i - 1].ai_ma[6]) then Exit;
+
+ k := i;
+ for j := k - 8 downto k - 188 do
+ begin
+ if (as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[6]) then Exit;
+ if (as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[5]) then Exit;
+ end;
+
+ k := i;
+ b := 0;
+ for j := k - 1 downto k - i_BB_BOX_X * 6 do
+ begin
+ if (as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[3]) then Exit;
+
+ if ((as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[3] + 30) and
+ (as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[6] + 30)) then
+ begin
+ b := j;
+ Break;
+ end;
+ end;
+
+ if (b = 0) then Exit;
+
+ a := 0;
+ k := i;
+ for j := b - 2 downto k - i_BB_BOX_X * 5 do
+ begin
+ if (as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[3]) then Exit;
+ if (as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[3]) then Exit;
+
+ if ((as_k_chg_ma_rsi[j].ai_ma[5] < as_k_chg_ma_rsi[j].ai_ma[3] + 30) and
+ (as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[5] + 30)) then
+ begin
+ a := j;
+ Break;
+ end;
+ end;
+
+ if (a = 0) then Exit;
+
+ for j := a - 2 downto a - i_BB_BOX_X do
+ begin
+ if (as_k_chg_ma_rsi[j].ai_ma[5] < as_k_chg_ma_rsi[j].ai_ma[3]) then Exit;
+ end;
+
+ if (as_k_chg_ma_rsi[i].ai_ma[8] > as_k_chg_ma_rsi[i].ai_ma[3]) then Exit;
+ if (as_k_chg_ma_rsi[i].ai_ma[6] > as_k_chg_ma_rsi[i].ai_ma[3]) then Exit;
+ if (as_k_chg_ma_rsi[i].ai_ma[5] > as_k_chg_ma_rsi[i].ai_ma[3]) then Exit;
+
+ i_pass_3_mark := i;
+ W_Log('pass_3', as_k_chg[i].i_date, 8, 'long pass_3!!!');
+
+ Result := 0;
+
+end;
+
+
+function ff_long_pass_3_ex(i: Integer): Integer;
+var
+ j: Integer;
+ c: Integer;
+ b: Integer;
+ a: Integer;
+ k: Integer;
+begin
+
+ Result := -1;
+
+ if (i < 888) then Exit;
+
+ if (i - i_pass_3_mark_ex > i_BB_BOX_X) then i_pass_3_mark_ex := 0;
+
+ if (i_pass_3_mark_ex > 888) then Exit;
+
+ if (as_k_chg[i].i_close < as_k_chg_ma_rsi[i - 1].ai_ma[8]) then Exit;
+ if (as_k_chg[i].i_close < as_k_chg_ma_rsi[i - 1].ai_ma[5]) then Exit;
+ if (as_k_chg[i].i_close < as_k_chg_ma_rsi[i - 1].ai_ma[6]) then Exit;
+
+ if (as_k_chg_ma_rsi[i].ai_ma[8] > as_k_chg_ma_rsi[i].ai_ma[6] + 50) then Exit;
+
+ if (as_k_chg_ma_rsi[i].ai_ma[6] < as_k_chg_ma_rsi[i - 20].ai_ma[6] + 50) then Exit;
+ if (as_k_chg_ma_rsi[i].ai_ma[8] + 100 < as_k_chg_ma_rsi[i - 20].ai_ma[8]) then Exit;
+
+ k := i;
+ c := 0;
+ for j := k - 1 downto k - i_BB_BOX_X * 6 do
+ begin
+ if ((as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[3] + 20) and
+ (as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[8] + 20)) then
+ begin
+ c := j;
+ Break;
+ end;
+ end;
+
+ if (c = 0) then Exit;
+
+ k := i;
+ b := 0;
+ for j := k - 1 downto k - i_BB_BOX_X * 6 do
+ begin
+ if ((as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[3] + 20) and
+ (as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[6] + 20)) then
+ begin
+ b := j;
+ Break;
+ end;
+ end;
+
+ if (b = 0) then Exit;
+
+ a := 0;
+ k := i;
+ for j := k - 1 downto k - i_BB_BOX_X * 6 do
+ begin
+ if ((as_k_chg_ma_rsi[j].ai_ma[5] < as_k_chg_ma_rsi[j].ai_ma[3] + 20) and
+ (as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[5] + 20)) then
+ begin
+ a := j;
+ Break;
+ end;
+ end;
+
+ if (a = 0) then Exit;
+
+ if ((i - a) > i_BB_BOX_X) and ((i - b) > i_BB_BOX_X) and ((i - c) > i_BB_BOX_X) then Exit;
+
+
+ if (as_k_chg_ma_rsi[i].ai_ma[8] > as_k_chg_ma_rsi[i].ai_ma[3]) then Exit;
+ if (as_k_chg_ma_rsi[i].ai_ma[6] > as_k_chg_ma_rsi[i].ai_ma[3]) then Exit;
+ if (as_k_chg_ma_rsi[i].ai_ma[5] > as_k_chg_ma_rsi[i].ai_ma[3]) then Exit;
+
+ i_pass_3_mark_ex := i;
+ W_Log('pass_3_ex', as_k_chg[i].i_date, i_wk_log, 'long pass_3_ex!!!');
+
+ Result := 0;
+
+end;
+
+function ff_short_pass_3_ex(i: Integer): Integer;
+var
+ j: Integer;
+ b: Integer;
+ a: Integer;
+ k: Integer;
+begin
+
+ Result := -1;
+
+ if (i < 888) then Exit;
+
+ if (i - i_pass_3_mark > i_BB_BOX_X) then i_pass_3_mark := 0;
+
+ if (i_pass_3_mark > 888) then Exit;
+
+ if (as_k_chg[i].i_close < as_k_chg_ma_rsi[i - 1].ai_ma[8]) then Exit;
+ if (as_k_chg[i].i_close < as_k_chg_ma_rsi[i - 1].ai_ma[5]) then Exit;
+ if (as_k_chg[i].i_close < as_k_chg_ma_rsi[i - 1].ai_ma[6]) then Exit;
+
+ k := i;
+ for j := k - 8 downto k - 188 do
+ begin
+ if (as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[6]) then Exit;
+ if (as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[5]) then Exit;
+ end;
+
+ k := i;
+ b := 0;
+ for j := k - 1 downto k - i_BB_BOX_X * 6 do
+ begin
+ if (as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[3]) then Exit;
+
+ if ((as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[3] + 30) and
+ (as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[6] + 30)) then
+ begin
+ b := j;
+ Break;
+ end;
+ end;
+
+ if (b = 0) then Exit;
+
+ a := 0;
+ k := i;
+ for j := b - 2 downto k - i_BB_BOX_X * 5 do
+ begin
+ if (as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[3]) then Exit;
+ if (as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[3]) then Exit;
+
+ if ((as_k_chg_ma_rsi[j].ai_ma[5] < as_k_chg_ma_rsi[j].ai_ma[3] + 30) and
+ (as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[5] + 30)) then
+ begin
+ a := j;
+ Break;
+ end;
+ end;
+
+ if (a = 0) then Exit;
+
+ for j := a - 2 downto a - i_BB_BOX_X do
+ begin
+ if (as_k_chg_ma_rsi[j].ai_ma[5] < as_k_chg_ma_rsi[j].ai_ma[3]) then Exit;
+ end;
+
+ if (as_k_chg_ma_rsi[i].ai_ma[8] > as_k_chg_ma_rsi[i].ai_ma[3]) then Exit;
+ if (as_k_chg_ma_rsi[i].ai_ma[6] > as_k_chg_ma_rsi[i].ai_ma[3]) then Exit;
+ if (as_k_chg_ma_rsi[i].ai_ma[5] > as_k_chg_ma_rsi[i].ai_ma[3]) then Exit;
+
+ i_pass_3_mark := i;
+ W_Log('pass_3', as_k_chg[i].i_date, 8, 'long pass_3!!!');
+
+ Result := 0;
+
+end;
+
+
+
+function ff_make_long_MA30(i: Integer): Integer;
+var
+ j: Integer;
+ b: Integer;
+ a: Integer;
+ k: Integer;
+begin
+
+ Result := -1;
+
+ if (i < 888) then Exit;
+
+ if (i_short_long_01 <> 1) then Exit;
+ if (i > i_short_long_index + 38) then Exit;
+
+ if (as_k_chg_ma_rsi[i - 1].ai_ma[6] < as_k_chg_ma_rsi[i - 8].ai_ma[6]) then Exit;
+
+ if (as_k_chg[i].i_close < as_k_chg_ma_rsi[i - 1].ai_ma[8]) then Exit;
+ if (as_k_chg[i].i_close < as_k_chg_ma_rsi[i - 1].ai_ma[6]) then Exit;
+
+ if (as_k_chg_ma_rsi[i - 1].ai_ma[3] < as_k_chg_ma_rsi[i - 1].ai_ma[5]) then Exit;
+
+ k := i;
+ b := 0;
+ for j := k - 1 downto k - i_BB_BOX_X * 2 do
+ begin
+ if (as_k_chg[j].i_low > as_k_chg_ma_rsi[j].ai_ma[3]) then
+ begin
+ b := j;
+ Break;
+ end;
+ end;
+
+ if (b = 0) then Exit;
+
+ if (ff_get_min_ij_low(b, i) < as_k_chg_ma_rsi[i].ai_ma[3]) and
+ (ff_get_min_ij_low(b, i) > as_k_chg_ma_rsi[i].ai_ma[5]) and
+ (as_k_chg_ma_rsi[i].ai_ma[3] > as_k_chg_ma_rsi[b].ai_ma[3]) and
+ (as_k_chg[i].i_close > ff_get_max_ij_high(i - 3, i - 1)) and
+ (as_k_chg[i].i_close > as_k_chg_ma_rsi[i].ai_ma[3]) then
+ begin
+ W_Log('LONY_MA30', as_k_chg[i].i_date, i_tmp_log, 'MAKE LONG_MA30!!!');
+ Result := 0;
+ end;
+
+end;
+
+
+function ff_make_long_MA60(i: Integer): Integer;
+var
+ j: Integer;
+ b: Integer;
+ a: Integer;
+ k: Integer;
+begin
+
+ Result := -1;
+
+ if (i < 888) then Exit;
+
+ if (i_short_long_01 <> 1) then Exit;
+ if (i > i_short_long_index + 38) then Exit;
+
+ if (as_k_chg_ma_rsi[i - 1].ai_ma[8] < as_k_chg_ma_rsi[i - 8].ai_ma[8]) then Exit;
+ if (as_k_chg_ma_rsi[i - 1].ai_ma[6] < as_k_chg_ma_rsi[i - 8].ai_ma[6]) then Exit;
+
+ if (as_k_chg[i].i_close < as_k_chg_ma_rsi[i - 1].ai_ma[8]) then Exit;
+ if (as_k_chg[i].i_close < as_k_chg_ma_rsi[i - 1].ai_ma[6]) then Exit;
+
+ if (as_k_chg_ma_rsi[i - 1].ai_ma[3] < as_k_chg_ma_rsi[i - 1].ai_ma[5]) then Exit;
+
+ k := i;
+ b := 0;
+ for j := k - 1 downto k - i_BB_BOX_X * 2 do
+ begin
+ if (as_k_chg[j].i_low > as_k_chg_ma_rsi[j].ai_ma[5]) then
+ begin
+ b := j;
+ Break;
+ end;
+ end;
+
+ if (b = 0) then Exit;
+
+ if (ff_get_min_ij_low(b, i) < as_k_chg_ma_rsi[i].ai_ma[5]) and
+ (ff_get_min_ij_low(b, i) > as_k_chg_ma_rsi[i].ai_ma[6]) and
+ (as_k_chg_ma_rsi[i].ai_ma[5] > as_k_chg_ma_rsi[b].ai_ma[5]) and
+
+ (as_k_chg[i].i_close > ff_get_max_ij_high(i - 3, i - 1)) and
+
+ (as_k_chg[i].i_close > as_k_chg_ma_rsi[i].ai_ma[5]) then
+ begin
+ W_Log('LONY_MA60', as_k_chg[i].i_date, i_tmp_log, 'MAKE LONG_MA60!!!');
+ Result := 0;
+ end;
+
+end;
+
+function ff_make_long_MA250(i: Integer): Integer;
+var
+ j: Integer;
+ b: Integer;
+ a: Integer;
+ k: Integer;
+begin
+
+ Result := -1;
+
+ if (i < 888) then Exit;
+
+ //if ( i_short_long_01 <> 1 ) Then Exit;
+ //if ( i > i_short_long_index +38) Then Exit;
+
+ if (as_k_chg_ma_rsi[i - 1].ai_ma[8] < as_k_chg_ma_rsi[i - 8].ai_ma[8]) then Exit;
+
+ b := 0;
+ k := i;
+ for j := k downto k - 288 do
+ begin
+ if ((as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[8] + 20) and
+ (as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[6] + 20)) then
+ begin
+ b := j;
+ Break;
+ end;
+ end;
+
+ if (b = 0) then Exit;
+
+ if (as_k_chg_ma_rsi[i - 1].ai_ma[8] < as_k_chg_ma_rsi[b].ai_ma[8]) then Exit;
+
+ if (i - b < 58) then Exit;
+
+ for j := b + 8 to b + 58 do
+ begin
+ if (as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[8]) then Exit;
+ if (as_k_chg[j].i_close < as_k_chg_ma_rsi[j].ai_ma[8]) then Exit;
+ end;
+
+ if (as_k_chg[i].i_close > ff_get_max_ij_high(i - 8, i - 2)) and
+ (ff_get_max_ij_high(i - 8, i - 2) < as_k_chg_ma_rsi[i].ai_ma[8]) and
+ (as_k_chg[i].i_close > as_k_chg_ma_rsi[i].ai_ma[8]) then
+ begin
+ W_Log('LONY_MA250', as_k_chg[i].i_date, i_tmp_log, 'MAKE LONG_MA250!!!');
+ Result := 0;
+ end;
+
+end;
+
+
+function ff_chk_power_vol(i: Integer): Integer;
+var
+ j: Integer;
+ k: Integer;
+ i_tmp: Integer;
+ i_tmp_1: Integer;
+ i_up_count_wk: Integer;
+ i_down_count_wk: Integer;
+ i_up_sum_wk: Integer;
+ i_down_sum_wk: Integer;
+
+begin
+
+ Result := -1;
+
+ k := i - 1;
+
+ i_up_count_wk := 0;
+ i_down_count_wk := 0;
+
+ i_up_sum_wk := 0;
+ i_down_sum_wk := 0;
+
+ for j := k downto 8 do
+ begin
+ i_tmp := Round(as_k_chg[j].i_date / 10000);
+ i_tmp_1 := Round(as_k_chg[j - 1].i_date / 10000);
+
+
+ if (i_tmp <> i_tmp_1) then
+ begin
+ Break;
+ end;
+
+ if (as_k_chg[j].i_open < as_k_chg[j].i_close) and (as_k_chg[j].i_vol > i_chk_power_vol_wk) then
+ begin
+ i_up_count_wk := i_up_count_wk + 1;
+ i_up_sum_wk := i_up_sum_wk + as_k_chg[j].i_vol;
+ end;
+
+ if (as_k_chg[j].i_open > as_k_chg[j].i_close) and (as_k_chg[j].i_vol > i_chk_power_vol_wk) then
+ begin
+ i_down_count_wk := i_down_count_wk + 1;
+ i_down_sum_wk := i_down_sum_wk + as_k_chg[j].i_vol;
+ end;
+
+ end;
+
+ i_up_count_ex := i_up_count_wk;
+ i_down_count_ex := i_down_count_wk;
+ i_up_vol_sum := i_up_sum_wk;
+ i_down_vol_sum := i_down_sum_wk;
+
+end;
+
+
+
+//start for big money
+
+function ff_4ma_make_mbm_long(i: Integer): Integer;
+var
+ j: Integer;
+ b: Integer;
+ k: Integer;
+begin
+
+ Result := -1;
+
+ if (i < 888) then Exit;
+
+ if (
+ (as_k_chg_ma_rsi[i - 1].ai_ma[6] < as_k_chg_ma_rsi[i - 1].ai_ma[5]) and
+ (as_k_chg_ma_rsi[i - 1].ai_ma[5] < as_k_chg_ma_rsi[i - 1].ai_ma[4]) and
+
+ (as_k_chg_ma_rsi[i - 1].ai_ma[3] > as_k_chg_ma_rsi[i - 3].ai_ma[3]) and
+ (as_k_chg_ma_rsi[i - 1].ai_ma[4] > as_k_chg_ma_rsi[i - 3].ai_ma[4]) and
+ (as_k_chg_ma_rsi[i - 1].ai_ma[5] > as_k_chg_ma_rsi[i - 3].ai_ma[5]) and
+
+ (as_k_chg_ma_rsi[i - 1].ai_ma[4] < as_k_chg_ma_rsi[i - 1].ai_ma[3])) then
+ begin
+ if (i_4ma_mbm_long = 888) then
+ begin
+ //check how long
+ k := i;
+ b := 0;
+ for j := k - 888 to k do
+ begin
+ if (not (
+ (as_k_chg_ma_rsi[j - 1].ai_ma[6] > as_k_chg_ma_rsi[j - 1].ai_ma[5]) and
+ (as_k_chg_ma_rsi[j - 1].ai_ma[5] > as_k_chg_ma_rsi[j - 1].ai_ma[4]) and
+ (as_k_chg_ma_rsi[j - 1].ai_ma[4] > as_k_chg_ma_rsi[j - 1].ai_ma[3]))) then
+ begin
+ if (not (
+ (as_k_chg_ma_rsi[j - 1].ai_ma[6] < as_k_chg_ma_rsi[j - 1].ai_ma[5]) and
+ (as_k_chg_ma_rsi[j - 1].ai_ma[5] < as_k_chg_ma_rsi[j - 1].ai_ma[4]) and
+ (as_k_chg_ma_rsi[j - 1].ai_ma[4] < as_k_chg_ma_rsi[j - 1].ai_ma[3]))) then
+ begin
+ b := j;
+ Break;
+ end;
+ end;
+ end;
+
+ if (b = 0) then Exit;
+ if (i - b < 18) then Exit;
+
+ i_4ma_long_mbm_mark := i;
+
+ i_4ma_long_mbm_count_bak := i_4ma_long_mbm_count;
+ i_4ma_long_mbm_count := i_4ma_long_mbm_count + 1;
+
+ i_sum_4ma_long_mbm_count := i_sum_4ma_long_mbm_count + 1;
+
+ if (i_4ma_long_mbm_count < 0) then W_Log('MBM 4ma long', as_k_chg[i].i_date, i_mbm_log + 1, PChar('4MA OK! Count:' + IntToStr(i_4ma_long_mbm_count)));
+
+ if ((i_sum_4ma_long_mbm_count mod 5) = 0) then W_Log('MBM 4ma long sum', as_k_chg[i].i_date, i_mbm_log + 2, PChar('4MA OK! Count:' + IntToStr(i_sum_4ma_long_mbm_count) + ' vs 4ma short ' + IntToStr(i_sum_4ma_short_mbm_count)));
+
+ i_4ma_mbm_long := m_i_long;
+ end;
+
+ i_4ma_mbm_long := m_i_long;
+ i_4ma_short_mbm_count := 0;
+
+ i_4ma_short_mbm_mark := 0;
+ i_4ma_mbm_short := 888;
+
+ end
+ else
+ begin
+ i_4ma_long_mbm_mark := 0;
+ i_4ma_mbm_long := 888;
+ end;
+
+end;
+
+function ff_4ma_make_mbm_short(i: Integer): Integer;
+var
+ j: Integer;
+ b: Integer;
+ k: Integer;
+begin
+
+ Result := -1;
+
+ if (i < 888) then Exit;
+
+ if (
+ (as_k_chg_ma_rsi[i - 1].ai_ma[6] > as_k_chg_ma_rsi[i - 1].ai_ma[5]) and
+ (as_k_chg_ma_rsi[i - 1].ai_ma[5] > as_k_chg_ma_rsi[i - 1].ai_ma[4]) and
+
+ (as_k_chg_ma_rsi[i - 1].ai_ma[3] < as_k_chg_ma_rsi[i - 5].ai_ma[3]) and
+ (as_k_chg_ma_rsi[i - 1].ai_ma[4] < as_k_chg_ma_rsi[i - 5].ai_ma[4]) and
+ (as_k_chg_ma_rsi[i - 1].ai_ma[5] < as_k_chg_ma_rsi[i - 5].ai_ma[5]) and
+
+ (as_k_chg_ma_rsi[i - 1].ai_ma[4] > as_k_chg_ma_rsi[i - 1].ai_ma[3])) then
+ begin
+ if (i_4ma_mbm_short = 888) then
+ begin
+ //check how long
+ k := i;
+ b := 0;
+ for j := k - 888 to k do
+ begin
+ if (not (
+ (as_k_chg_ma_rsi[j - 1].ai_ma[6] < as_k_chg_ma_rsi[j - 1].ai_ma[5]) and
+ (as_k_chg_ma_rsi[j - 1].ai_ma[5] < as_k_chg_ma_rsi[j - 1].ai_ma[4]) and
+ (as_k_chg_ma_rsi[j - 1].ai_ma[4] < as_k_chg_ma_rsi[j - 1].ai_ma[3]))) then
+ begin
+ if (not (
+ (as_k_chg_ma_rsi[j - 1].ai_ma[6] > as_k_chg_ma_rsi[j - 1].ai_ma[5]) and
+ (as_k_chg_ma_rsi[j - 1].ai_ma[5] > as_k_chg_ma_rsi[j - 1].ai_ma[4]) and
+ (as_k_chg_ma_rsi[j - 1].ai_ma[4] > as_k_chg_ma_rsi[j - 1].ai_ma[3]))) then
+ begin
+ b := j;
+ Break;
+ end;
+ end;
+ end;
+
+ if (b = 0) then Exit;
+ if (i - b < 18) then Exit;
+
+
+
+ i_4ma_short_mbm_mark := i;
+
+ i_4ma_short_mbm_count_bak := i_4ma_short_mbm_count;
+
+ i_4ma_short_mbm_count := i_4ma_short_mbm_count + 1;
+
+ i_sum_4ma_short_mbm_count := i_sum_4ma_short_mbm_count + 1;
+
+ if (i_4ma_short_mbm_count < 0) then W_Log('MBM 4ma_short', as_k_chg[i].i_date, i_mbm_log, PChar('4MA OK! Count:' + IntToStr(i_4ma_short_mbm_count)));
+
+ if ((i_sum_4ma_short_mbm_count mod 5) = 0) then W_Log('MBM short 4ma sum', as_k_chg[i].i_date, i_mbm_log + 3, PChar('4MA OK! Count:' + IntToStr(i_sum_4ma_short_mbm_count) + ' vs 4ma long ' + IntToStr(i_sum_4ma_long_mbm_count)));
+
+ i_4ma_mbm_short := m_i_short;
+ end;
+
+ i_4ma_mbm_short := m_i_short;
+
+ i_4ma_long_mbm_count := 0;
+ i_4ma_long_mbm_mark := 0;
+ i_4ma_mbm_long := 888;
+
+ end
+ else
+ begin
+ i_4ma_short_mbm_mark := 0;
+ i_4ma_mbm_short := 888;
+ end;
+
+end;
+
+
+
+
+function ff_make_mbm_long(i: Integer): Integer;
+var
+ j: Integer;
+ b: Integer;
+ k: Integer;
+begin
+
+ Result := -1;
+
+ if ((as_k_chg_ma_rsi[i].ai_ma[8] < as_k_chg_ma_rsi[i].ai_ma[6] + 40) and
+ (as_k_chg_ma_rsi[i].ai_ma[6] < as_k_chg_ma_rsi[i].ai_ma[8] + 40)) then
+ begin
+ i_last_120ma250eq_index := i;
+ end;
+
+ if (i < 888) then Exit;
+
+ if ((as_k_chg_ma_rsi[i - 1].ai_ma[8] < as_k_chg_ma_rsi[i - 1].ai_ma[6]) and
+ (as_k_chg_ma_rsi[i - 1].ai_ma[6] < as_k_chg_ma_rsi[i - 1].ai_ma[5]) and
+ (as_k_chg_ma_rsi[i - 1].ai_ma[5] < as_k_chg_ma_rsi[i - 1].ai_ma[4]) and
+
+ (as_k_chg_ma_rsi[i - 1].ai_ma[3] > as_k_chg_ma_rsi[i - 5].ai_ma[3]) and
+ (as_k_chg_ma_rsi[i - 1].ai_ma[4] > as_k_chg_ma_rsi[i - 5].ai_ma[4]) and
+ (as_k_chg_ma_rsi[i - 1].ai_ma[5] > as_k_chg_ma_rsi[i - 5].ai_ma[5]) and
+
+ (as_k_chg_ma_rsi[i - 1].ai_ma[4] < as_k_chg_ma_rsi[i - 1].ai_ma[3])) then
+ begin
+ if (i_mbm_long = 888) then
+ begin
+ //check how long
+ k := i;
+ b := 0;
+ for j := k - 888 to k do
+ begin
+ if (not ((as_k_chg_ma_rsi[j - 1].ai_ma[8] > as_k_chg_ma_rsi[j - 1].ai_ma[6]) and
+ (as_k_chg_ma_rsi[j - 1].ai_ma[6] > as_k_chg_ma_rsi[j - 1].ai_ma[5]) and
+ (as_k_chg_ma_rsi[j - 1].ai_ma[5] > as_k_chg_ma_rsi[j - 1].ai_ma[4]) and
+ (as_k_chg_ma_rsi[j - 1].ai_ma[4] > as_k_chg_ma_rsi[j - 1].ai_ma[3]))) then
+ begin
+ if (not ((as_k_chg_ma_rsi[j - 1].ai_ma[8] < as_k_chg_ma_rsi[j - 1].ai_ma[6]) and
+ (as_k_chg_ma_rsi[j - 1].ai_ma[6] < as_k_chg_ma_rsi[j - 1].ai_ma[5]) and
+ (as_k_chg_ma_rsi[j - 1].ai_ma[5] < as_k_chg_ma_rsi[j - 1].ai_ma[4]) and
+ (as_k_chg_ma_rsi[j - 1].ai_ma[4] < as_k_chg_ma_rsi[j - 1].ai_ma[3]))) then
+ begin
+ b := j;
+ Break;
+ end;
+ end;
+ end;
+
+ if (b = 0) then Exit;
+ if (i - b < 58) then Exit;
+
+
+ if (i_long_mbm_count > 0) then
+ begin
+ if ((i - i_long_mbm_index) < 18) then Exit;
+ end;
+
+
+ i_long_mbm_mark := i;
+
+ i_long_mbm_count_bak := i_long_mbm_count;
+ i_long_mbm_count := i_long_mbm_count + 1;
+
+ i_sum_long_mbm_count := i_sum_long_mbm_count + 1;
+
+ if ((i_sum_long_mbm_count mod 5) = 0) then W_Log('MBM long sum', as_k_chg[i].i_date, i_mbm_log + 4, PChar('4MA OK! Count:' + IntToStr(i_sum_long_mbm_count) + ' vs short ' + IntToStr(i_sum_short_mbm_count)));
+
+ if (i_long_mbm_count = 1) then i_long_mbm_count_action_1 := 1 else i_long_mbm_count_action_1 := 0;
+
+ if (i_long_mbm_count < 3) and (i_long_mbm_count > 0) then
+ begin
+
+ Result := 0;
+
+ if (i_long_mbm_count = 2) then Result := 0 else Result := 1;
+
+ if (i_4ma_long_mbm_count > 4) and (i_long_mbm_count = 1) then Result := 0;
+
+ //if( i_4ma_long_mbm_count <3 ) and ( i_long_mbm_count=2 ) Then Result :=1;
+
+ //if( i_4ma_long_mbm_count >2 ) and ( i_long_mbm_count=3 ) Then Result :=0;
+
+ {
+ if(i_short_mbm_count >5) and ( i_long_mbm_count=1 ) Then Result :=1;
+ //20120918 for test //
+ if(i_short_mbm_count_bak >5) and ( i_long_mbm_count=2 ) Then Result :=1;
+
+ if(i_short_mbm_count_bak >5) Then Result :=1;
+
+ if(i_long_mbm_count_bak >5) and ( i_long_mbm_count=1 ) Then Result :=1;
+ if(i_long_mbm_count_bak >5) and ( i_long_mbm_count=2 ) Then Result :=1;
+
+ if(Result =0) Then W_Log('MBM long',as_k_chg[i].i_date,i_wk_log,PChar('MA OK! Count:'+IntToStr(i_long_mbm_count)) );
+ }
+ i_long_mbm_index := i;
+
+ end;
+
+ if (i_long_mbm_count < 88) then W_Log('MBM long', as_k_chg[i].i_date, i_mbm_log + 1, PChar('MA OK! Count:' + IntToStr(i_long_mbm_count)));
+
+ i_mbm_long := m_i_long;
+ end;
+
+ i_mbm_long := m_i_long;
+ f_mbm_cut_long := f_rsi_cut * 1.5;
+ f_mbm_stop_long := f_rsi_stop * 2;
+
+ i_long_mbm_index_1 := i;
+
+ i_short_mbm_count := 0;
+
+ i_short_mbm_mark := 0;
+ i_mbm_short := 888;
+ f_mbm_cut_short := 0.0;
+ f_mbm_stop_short := 0.0;
+
+ end
+ else
+ begin
+ i_long_mbm_mark := 0;
+ i_mbm_long := 888;
+ f_mbm_cut_long := 0.0;
+ f_mbm_stop_long := 0.0;
+ end;
+
+ if (i_mbm_long = m_i_long) and (as_k_chg[i].i_close < as_k_chg_ma_rsi[i].ai_ma[4]) then
+ begin
+ f_mbm_cut_long := 0.0;
+ f_mbm_stop_long := 0.0;
+ end;
+
+ if (i_long_mbm_count_action_1 = 1) then
+ begin
+ //i_long_mbm_count_action_1:=0;
+ //i_long_mbm_index :=i;
+ //W_Log('MBM Action_1',as_k_chg[i].i_date,i_tmp_log,'MBM do long!!!' );
+ //Result :=0;
+ //Exit;
+ end;
+
+
+ if (i < i_short_mbm_index_1 + 168) then Exit;
+
+ if (i - i_long_mbm_index < i_BB_BOX_X * 2) then Exit;
+
+ if (i > i_long_mbm_mark + 58) then Exit;
+
+ //if (i < i_long_mbm_mark + 3 ) Then Exit;
+ //if (i > i_last_120ma250eq_index +78 ) Then Exit;
+
+ if (i_long_mbm_count > 3) then Exit;
+
+ if (i_mbm_long = m_i_long) and
+ //(as_k_chg[i].i_close > ff_get_max_ij_high(i-3,i-1) ) and
+ (as_k_chg[i].i_close > as_k_chg_ma_rsi[i].ai_ma[3]) then
+ begin
+ //i_long_mbm_index :=i;
+ //W_Log('MBM Action',as_k_chg[i].i_date,i_tmp_log,'Set MBM long lamp!!!' );
+ //Result :=0;
+ end;
+
+end;
+
+
+function ff_make_mbm_short(i: Integer): Integer;
+var
+ j: Integer;
+ b: Integer;
+ k: Integer;
+begin
+
+ Result := -1;
+
+ if ((as_k_chg_ma_rsi[i].ai_ma[8] < as_k_chg_ma_rsi[i].ai_ma[6] + 40) and
+ (as_k_chg_ma_rsi[i].ai_ma[6] < as_k_chg_ma_rsi[i].ai_ma[8] + 40)) then
+ begin
+ i_last_120ma250eq_index := i;
+ end;
+
+ if (i < 888) then Exit;
+
+ if ((as_k_chg_ma_rsi[i - 1].ai_ma[8] > as_k_chg_ma_rsi[i - 1].ai_ma[6]) and
+ (as_k_chg_ma_rsi[i - 1].ai_ma[6] > as_k_chg_ma_rsi[i - 1].ai_ma[5]) and
+ (as_k_chg_ma_rsi[i - 1].ai_ma[5] > as_k_chg_ma_rsi[i - 1].ai_ma[4]) and
+
+ (as_k_chg_ma_rsi[i - 1].ai_ma[3] < as_k_chg_ma_rsi[i - 5].ai_ma[3]) and
+ (as_k_chg_ma_rsi[i - 1].ai_ma[4] < as_k_chg_ma_rsi[i - 5].ai_ma[4]) and
+ (as_k_chg_ma_rsi[i - 1].ai_ma[5] < as_k_chg_ma_rsi[i - 5].ai_ma[5]) and
+
+ (as_k_chg_ma_rsi[i - 1].ai_ma[4] > as_k_chg_ma_rsi[i - 1].ai_ma[3])) then
+ begin
+ if (i_mbm_short = 888) then
+ begin
+ //check how long
+ k := i;
+ b := 0;
+ for j := k - 888 to k do
+ begin
+ if (not ((as_k_chg_ma_rsi[j - 1].ai_ma[8] < as_k_chg_ma_rsi[j - 1].ai_ma[6]) and
+ (as_k_chg_ma_rsi[j - 1].ai_ma[6] < as_k_chg_ma_rsi[j - 1].ai_ma[5]) and
+ (as_k_chg_ma_rsi[j - 1].ai_ma[5] < as_k_chg_ma_rsi[j - 1].ai_ma[4]) and
+ (as_k_chg_ma_rsi[j - 1].ai_ma[4] < as_k_chg_ma_rsi[j - 1].ai_ma[3]))) then
+ begin
+ if (not ((as_k_chg_ma_rsi[j - 1].ai_ma[8] > as_k_chg_ma_rsi[j - 1].ai_ma[6]) and
+ (as_k_chg_ma_rsi[j - 1].ai_ma[6] > as_k_chg_ma_rsi[j - 1].ai_ma[5]) and
+ (as_k_chg_ma_rsi[j - 1].ai_ma[5] > as_k_chg_ma_rsi[j - 1].ai_ma[4]) and
+ (as_k_chg_ma_rsi[j - 1].ai_ma[4] > as_k_chg_ma_rsi[j - 1].ai_ma[3]))) then
+ begin
+ b := j;
+ Break;
+ end;
+ end;
+ end;
+
+ if (b = 0) then Exit;
+ if (i - b < 58) then Exit;
+
+ if (i_short_mbm_count > 0) then
+ begin
+ if ((i - i_short_mbm_index) < 18) then Exit;
+ end;
+
+ i_short_mbm_mark := i;
+
+ i_short_mbm_count_bak := i_short_mbm_count;
+
+ i_short_mbm_count := i_short_mbm_count + 1;
+
+ i_sum_short_mbm_count := i_sum_short_mbm_count + 1;
+ if ((i_sum_short_mbm_count mod 5) = 0) then W_Log('MBM short sum', as_k_chg[i].i_date, i_mbm_log + 5, PChar('4MA OK! Count:' + IntToStr(i_sum_short_mbm_count) + ' vs 4ma long ' + IntToStr(i_sum_long_mbm_count)));
+
+ if (i_short_mbm_count = 1) then i_short_mbm_count_action_1 := 1 else i_short_mbm_count_action_1 := 0;
+
+ if (i_short_mbm_count < 3) and (i_short_mbm_count > 0) then
+ begin
+ Result := 0;
+
+ if (i_short_mbm_count = 2) then Result := 0 else Result := 1;
+ if (i_4ma_short_mbm_count > 4) and (i_short_mbm_count = 1) then Result := 0;
+ //if( i_4ma_short_mbm_count <3 ) and ( i_short_mbm_count=2 ) Then Result :=1;
+ //if( i_4ma_short_mbm_count >2 ) and ( i_short_mbm_count=3 ) Then Result :=0;
+
+ {
+ if(i_long_mbm_count >3) and ( i_short_mbm_count=1 ) Then Result :=1;
+ //20120918 for test //
+ if(i_long_mbm_count_bak >3) and ( i_short_mbm_count=2 ) Then Result :=1;
+ if(i_short_mbm_count_bak >3) and ( i_short_mbm_count=1 ) Then Result :=1;
+ if(i_short_mbm_count_bak >3) and ( i_short_mbm_count=2 ) Then Result :=1;
+ if(Result =0) Then W_Log('MBM short',as_k_chg[i].i_date,i_wk_log,PChar('MA OK! Count:'+IntToStr(i_short_mbm_count)) );
+ }
+ i_short_mbm_index := i;
+
+ end;
+
+
+ if (i_short_mbm_count < 88) then W_Log('MBM short', as_k_chg[i].i_date, i_mbm_log, PChar('MA OK! Count:' + IntToStr(i_short_mbm_count)));
+
+ i_mbm_short := m_i_short;
+ end;
+
+ i_mbm_short := m_i_short;
+ f_mbm_cut_short := f_rsi_cut * 1.5;
+ f_mbm_stop_short := f_rsi_stop * 2;
+
+ i_short_mbm_index_1 := i;
+
+
+ i_long_mbm_count := 0;
+ i_long_mbm_mark := 0;
+ i_mbm_long := 888;
+ f_mbm_cut_long := 0.0;
+ f_mbm_stop_long := 0.0;
+
+
+ end
+ else
+ begin
+ i_short_mbm_mark := 0;
+ i_mbm_short := 888;
+ f_mbm_cut_short := 0.0;
+ f_mbm_stop_short := 0.0;
+
+ end;
+
+ if (i_mbm_short = m_i_short) and (as_k_chg[i].i_close > as_k_chg_ma_rsi[i].ai_ma[4]) then
+ begin
+ f_mbm_cut_short := 0.0;
+ f_mbm_stop_short := 0.0;
+ end;
+
+ if (i_short_mbm_count_action_1 = 1) then
+ begin
+ //i_short_mbm_count_action_1:=0;
+ //i_short_mbm_index :=i;
+ //W_Log('MBM Action_1',as_k_chg[i].i_date,i_tmp_log,'MBM do short!' );
+ //Result :=0;
+ //Exit;
+ end;
+
+ if (i < i_long_mbm_index_1 + 168) then Exit;
+
+ if (i - i_short_mbm_index < i_BB_BOX_X * 2) then Exit;
+
+ if (i > i_short_mbm_mark + 58) then Exit;
+ //if (i < i_short_mbm_mark +3 ) Then Exit;
+
+ //if (i > i_last_120ma250eq_index +68 ) Then Exit;
+
+ if (i_short_mbm_count > 3) then Exit;
+
+
+ if (i_mbm_short = m_i_short) and
+ //(as_k_chg[i].i_close < ff_get_min_ij_low(i-3,i-1) ) and
+ (as_k_chg[i].i_close < as_k_chg_ma_rsi[i].ai_ma[3]) then
+ begin
+ //i_short_mbm_index :=i;
+ //W_Log('MBM Action',as_k_chg[i].i_date,i_tmp_log,'Set MBM short lamp!!!' );
+ //Result :=0;
+ end;
+
+end;
+
+
+//end for big money
+
+
+function ff_set_caption(): Integer;
+var
+ p, q: PChar;
+ i_loop_wk: Integer;
+begin
+ MAINFORM.Label1.Caption := s_caption_1;
+ MAINFORM.Label2.Caption := s_caption_2;
+ MAINFORM.Label3.Caption := s_caption_3;
+ MAINFORM.Label4.Caption := s_caption_4;
+ MAINFORM.Label5.Caption := s_caption_5;
+ MAINFORM.Label6.Caption := s_caption_6;
+ MAINFORM.Label7.Caption := s_caption_7;
+ MAINFORM.Label8.Caption := s_caption_8;
+ MAINFORM.Label9.Caption := s_caption_9;
+ MAINFORM.Label10.Caption := s_caption_10;
+ MAINFORM.Label11.Caption := s_caption_11;
+ MAINFORM.Label12.Caption := s_caption_12;
+ MAINFORM.Label13.Caption := s_caption_13;
+ MAINFORM.Label14.Caption := s_caption_14;
+ MAINFORM.Label15.Caption := s_caption_15;
+ MAINFORM.Label16.Caption := s_caption_16;
+ MAINFORM.Label_status.Caption := s_caption_status;
+
+ MAINFORM.Label_Vol.Caption := s_caption_vol;
+ MAINFORM.Label_long_stp.Caption := s_caption_long_stp;
+ MAINFORM.Label_short_stp.Caption := s_caption_short_stp;
+
+ if (i_lock_short = 0) then MAINFORM.N5.Checked := False;
+ if (i_lock_long = 0) then MAINFORM.N4.Checked := False;
+ if (i_lock_short > 0) then MAINFORM.N5.Checked := True;
+ if (i_lock_long > 0) then MAINFORM.N4.Checked := True;
+
+ if MAINFORM.N4.Checked = True then s_caption_15 := 'Ëø' else s_caption_15 := ' ';
+ if MAINFORM.N5.Checked = True then s_caption_16 := 'Ëø' else s_caption_16 := ' ';
+
+ if (i_stp_short = 0) then MAINFORM.Short_STP.Checked := False;
+ if (i_stp_long = 0) then MAINFORM.Long_STP.Checked := False;
+ if (i_stp_short > 0) then MAINFORM.Short_STP.Checked := True;
+ if (i_stp_long > 0) then MAINFORM.Long_STP.Checked := True;
+
+ if MAINFORM.Short_STP.Checked = True then s_caption_short_stp := '+' else s_caption_short_stp := ' ';
+ if MAINFORM.Long_STP.Checked = True then s_caption_long_stp := '+' else s_caption_long_stp := ' ';
+
+ if (StrLen(PChar(MAINFORM.Edit_vol_chk.Text)) > 2) then i_chk_power_vol_wk := StrToInt(MAINFORM.Edit_vol_chk.Text)
+ else i_chk_power_vol_wk := 1000;
+
+ MAINFORM.Label_up_power.Caption := '¶à·½Á¿ÄÜ ' + IntToStr(i_up_count_ex) + ' : ' + IntToStr(i_up_vol_sum);
+ MAINFORM.Label_down_power.Caption := '¿Õ·½Á¿ÄÜ ' + IntToStr(i_down_count_ex) + ' : ' + IntToStr(i_down_vol_sum);
+
+ if i_show_string_grid < 1 then
+ begin
+ MAINFORM.Height := 418;
+ end
+ else
+ begin
+ MAINFORM.ff_sg.Height := 558;
+ MAINFORM.Height := 988;
+ MAINFORM.Top := 1;
+ MAINFORM.Left := 1;
+
+ for i_loop_wk := 0 to i_fc_count - 1 do
+ begin
+ MAINFORM.ff_sg.Cells[0, i_loop_wk + 1] := as_fc_data[i_loop_wk].pc_username;
+ MAINFORM.ff_sg.Cells[1, i_loop_wk + 1] := as_fc_data[i_loop_wk].pc_xxx_name;
+ MAINFORM.ff_sg.Cells[2, i_loop_wk + 1] := IntToStr(as_fc_data[i_loop_wk].i_got_it_mark);
+
+ if (as_fc_data[i_loop_wk].i_got_it_mark > 0) then
+ begin
+ MAINFORM.ff_sg.Cells[2, i_loop_wk + 1] := FloatToStrF(as_fc_data[i_loop_wk].f_business_price, ffFixed, 8, 2);
+ MAINFORM.ff_sg.Cells[3, i_loop_wk + 1] := IntToStr(as_fc_data[i_loop_wk].i_got_it_mark);
+ end
+ else
+ begin
+ MAINFORM.ff_sg.Cells[2, i_loop_wk + 1] := ' ';
+ MAINFORM.ff_sg.Cells[3, i_loop_wk + 1] := ' ';
+ end;
+
+ if (as_fc_data[i_loop_wk].i_short_mark > 0) then
+ begin
+ MAINFORM.ff_sg.Cells[4, i_loop_wk + 1] := FloatToStrF(as_fc_data[i_loop_wk].f_short_price, ffFixed, 8, 2);
+ MAINFORM.ff_sg.Cells[5, i_loop_wk + 1] := IntToStr(as_fc_data[i_loop_wk].i_short_mark);
+ end
+ else
+ begin
+ MAINFORM.ff_sg.Cells[4, i_loop_wk + 1] := ' ';
+ MAINFORM.ff_sg.Cells[5, i_loop_wk + 1] := ' ';
+ end;
+ MAINFORM.ff_sg.Cells[6, i_loop_wk + 1] := FloatToStrF(as_fc_data[i_loop_wk].f_rights_balance, ffFixed, 11, 2);
+ end;
+ end;
+
+ if (StrLen(PChar(MAINFORM.Edit_open_price.Text)) > 3) then
+ begin
+ FillChar(c_open_price, SizeOf(c_open_price), 0);
+ StrCopy(c_open_price, PChar(MAINFORM.Edit_open_price.Text));
+ end;
+
+ if (StrLen(c_open_price) > 3) then
+ begin
+ i_open_vol := 0;
+ q := StrPos(c_open_price, ':');
+ if (q <> nil) then
+ begin
+ q[0] := #0;
+ p := @q[1];
+ i_open_price := StrToInt(c_open_price);
+ if (StrLen(p) > 0) then i_open_vol := StrToInt(p);
+ end
+ else
+ i_open_price := StrToInt(c_open_price)
+ end
+ else i_open_price := 0;
+
+end;
+
+
+
+function ff_load_k_base(): Integer;
+var
+ //iFileHandle : Integer;
+ iFileLength: Integer;
+ iBytesRead: Integer;
+ i: Integer;
+ k_line_file_name: string;
+ pc_Buffer: PChar;
+
+begin
+
+ Result := 0;
+
+ FillChar(as_k_chg, SizeOf(as_k_chg), 0);
+ FillChar(as_k_chg_ma_rsi, sizeof(as_k_chg_ma_rsi), 0);
+
+ pc_Buffer := @as_k_chg[0];
+
+ tm_0 := Now;
+ tm_1 := Now;
+
+ k_line_file_name := m_k_line_file_name;
+
+ if not FileExists(k_line_file_name) then
+ begin
+ iFileHandle := FileCreate(k_line_file_name);
+ FileClose(iFileHandle);
+ end;
+
+ iFileHandle := FileOpen(k_line_file_name, fmOpenRead);
+ if iFileHandle > -1 then
+ begin
+ iFileLength := FileSeek(iFileHandle, 0, 2);
+ FileSeek(iFileHandle, 0, 0);
+
+ if (iFileLength > (m_i_max_chg_kline_in_mem - 5888) * SizeOf(s_k_line_data)) then
+ FileSeek(iFileHandle,
+ iFileLength - (m_i_max_chg_kline_in_mem - 5888) * SizeOf(s_k_line_data), 0);
+
+ iBytesRead := FileRead(iFileHandle, pc_Buffer^, iFileLength);
+ FileClose(iFileHandle);
+ end
+ else Exit;
+
+ DeleteFile(k_line_file_name);
+ iFileHandle := FileCreate(k_line_file_name);
+
+
+ if iBytesRead > 0 then
+ begin
+
+ for i := 0 to Round(iBytesRead / SizeOf(s_k_line_data) - 1) do
+ begin
+ if (as_k_chg[i].i_open > 0) and (as_k_chg[i].i_low > 0) then
+ FileWrite(iFileHandle, as_k_chg[i], SizeOf(s_k_line_data));
+ end;
+ i_s_k_chg_index_wk := Round(iBytesRead / SizeOf(s_k_line_data)) - 1 + 1;
+ i_s_k_chg_index_load := Round(iBytesRead / SizeOf(s_k_line_data));
+ i_as_k_base_init_flag := 888;
+ i_as_k_chg_init_flag := 888;
+
+ as_k_chg[i_s_k_chg_index_wk].i_open := as_k_chg[i_s_k_chg_index_wk - 1].i_open;
+ as_k_chg[i_s_k_chg_index_wk].i_close := as_k_chg[i_s_k_chg_index_wk - 1].i_close;
+ as_k_chg[i_s_k_chg_index_wk].i_high := as_k_chg[i_s_k_chg_index_wk - 1].i_high;
+ as_k_chg[i_s_k_chg_index_wk].i_low := as_k_chg[i_s_k_chg_index_wk - 1].i_low;
+
+ for i := 0 to i_s_k_chg_index_wk do ff_make_ma_rsi_ex(i);
+
+ end
+ else i_s_k_chg_index_wk := 0;
+
+ FileClose(iFileHandle);
+
+end;
+
+function ff_passwd_chg(
+ pc_account: PChar;
+ pc_password_type: PChar;
+ pc_old_password: PChar;
+ pc_new_password: PChar): Integer;
+var
+ iRet: Integer;
+ lpReqMsg, lpAnsMsg: IFuMessage;
+ lpRecord, lpAnsRecord: IFuRecord;
+ c_log: array[0..88] of char;
+
+begin
+ Result := 0;
+
+ if not Assigned(m_lpComm) then Exit;
+ if (i_comm_ok = 0) then Exit;
+
+ //ÒµÎñ²Ù×÷ίÍÐϵ¥
+ lpReqMsg := NewFuMessage(MSG_TYPE_MODIFY_PASSWORD, Integer(MSG_MODE_REQUEST)); //¿Í»§ÐÞ¸ÄÃÜÂë
+ lpAnsMsg := NewFuMessage(MSG_TYPE_UNKNOWN, Integer(MSG_MODE_ANSWER)); //½ÓÊÕÏûÏ¢(ÎÞ¹ØÏûÏ¢ÀàÐÍ)
+
+ //´ò°üÇëÇó²ÎÊý(×Ö¶Î˳ÐòÎÞ¹Ø,Öظ´ÉèÖÃ×Ö¶ÎÔò¸²¸ÇÆäÖµ)
+ lpRecord := lpReqMsg.AddRecord();
+
+
+ lpRecord.SetString('fund_account', pc_account);
+ lpRecord.SetString('password_type', pc_password_type);
+ lpRecord.SetString('password', pc_old_password);
+ lpRecord.SetString('new_password', pc_new_password);
+
+ //ͬ²½½ÓÊÕÏûÏ¢
+ iRet := m_lpComm.SyncSendRecv(lpReqMsg, lpAnsMsg);
+ if iRet <> 0 then
+ begin
+ //cout<<"ͬ²½Î¯ÍÐʧ°Ü:iRet="<GetErrorMsg(iRet)< 0 then
+ begin
+ lpAnsRecord := lpAnsMsg.GetRecord(0);
+ FillChar(c_log, SizeOf(c_log), 0);
+ StrCopy(c_log, lpAnsRecord.GetString('result'));
+
+ W_Log(pc_new_password, i_tmp_log, i_wk_log, c_log);
+ end;
+
+ lpReqMsg.Release();
+ lpAnsMsg.Release();
+end;
+
+
+
+
+
+
+function ff_order_ex(
+ pc_contract_code: PChar;
+ pc_entrust_price: PChar;
+ pc_entrust_amount: PChar;
+ pc_entrust_bs: PChar;
+ pc_direction: PChar): Integer;
+var
+ iRet: Integer;
+ lpReqMsg, lpAnsMsg: IFuMessage;
+ lpRecord, lpAnsRecord: IFuRecord;
+begin
+ Result := 0;
+
+ if not Assigned(m_lpComm) then Exit;
+ if (i_comm_ok = 0) then Exit;
+
+ //ÒµÎñ²Ù×÷ίÍÐϵ¥
+ lpReqMsg := NewFuMessage(MSG_TYPE_NEW_SINGLE_ORDER, Integer(MSG_MODE_REQUEST)); //ίÍÐϵ¥
+ lpAnsMsg := NewFuMessage(MSG_TYPE_UNKNOWN, Integer(MSG_MODE_ANSWER)); //½ÓÊÕÏûÏ¢(ÎÞ¹ØÏûÏ¢ÀàÐÍ)
+
+ //´ò°üÇëÇó²ÎÊý(×Ö¶Î˳ÐòÎÞ¹Ø,Öظ´ÉèÖÃ×Ö¶ÎÔò¸²¸ÇÆäÖµ)
+ lpRecord := lpReqMsg.AddRecord();
+
+
+ lpRecord.SetString('fund_account', pc_username);
+ //lpRecord.SetString('password',pc_user_pwd);
+ lpRecord.SetString('futu_exch_type', 'F4');
+ lpRecord.SetString('futures_account', '');
+ lpRecord.SetString('contract_code', pc_contract_code);
+ //buy
+ lpRecord.SetString('entrust_bs', pc_entrust_bs);
+ //long,open
+ lpRecord.SetString('futures_direction', pc_direction);
+
+ lpRecord.SetString('hedge_type', '0');
+ lpRecord.SetString('futu_entrust_prop', '0');
+
+
+ lpRecord.SetString('futu_entrust_price', pc_entrust_price);
+
+ lpRecord.SetString('entrust_amount', pc_entrust_amount);
+
+ lpRecord.SetString('entrust_kind', '0');
+
+ //ͬ²½½ÓÊÕÏûÏ¢
+ iRet := m_lpComm.SyncSendRecv(lpReqMsg, lpAnsMsg);
+ if iRet <> 0 then
+ begin
+
+ if lpAnsMsg.GetCount() > 0 then
+ begin
+
+ lpAnsRecord := lpAnsMsg.GetRecord(0);
+ FillChar(c_error_no, SizeOf(c_error_no), 0);
+ FillChar(c_error_info, SizeOf(c_error_info), 0);
+
+ StrCopy(c_error_no, lpAnsRecord.GetString('error_no'));
+ StrCopy(c_error_info, lpAnsRecord.GetString('error_info'));
+
+ W_Log('order_ex_error', iRet, i_wk_log, c_error_no);
+ W_Log('order_ex_error', iRet, i_wk_log, c_error_info);
+
+ end;
+
+
+ //cout<<"ͬ²½Î¯ÍÐʧ°Ü:iRet="<GetErrorMsg(iRet)< 0 then
+ begin
+ lpAnsRecord := lpAnsMsg.GetRecord(0);
+ FillChar(c_batch_no, SizeOf(c_batch_no), 0);
+ FillChar(c_entrust_no, SizeOf(c_entrust_no), 0);
+
+ StrCopy(c_entrust_no, lpAnsRecord.GetString('entrust_no'));
+ StrCopy(c_entrust_no, lpAnsRecord.GetString('batch_no'));
+ end;
+
+ lpReqMsg.Release();
+ lpAnsMsg.Release();
+end;
+
+
+
+function ff_entrust_no(pc_contract_code: PChar): Integer;
+var
+ iRet: Integer;
+ lpReqMsg, lpAnsMsg: IFuMessage;
+ lpRecord, lpAnsRecord: IFuRecord;
+begin
+ Result := 0;
+
+ if not Assigned(m_lpComm) then Exit;
+ if (i_comm_ok = 0) then Exit;
+
+ FillChar(c_batch_no, SizeOf(c_batch_no), 0);
+ FillChar(c_entrust_no, SizeOf(c_entrust_no), 0);
+
+
+ //ÒµÎñ²Ù×÷ίÍÐϵ¥
+ lpReqMsg := NewFuMessage(MSG_TYPE_GET_ENTRUST_ORDERS, Integer(MSG_MODE_REQUEST)); //ίÍÐϵ¥
+ lpAnsMsg := NewFuMessage(MSG_TYPE_UNKNOWN, Integer(MSG_MODE_ANSWER)); //½ÓÊÕÏûÏ¢(ÎÞ¹ØÏûÏ¢ÀàÐÍ)
+
+ //´ò°üÇëÇó²ÎÊý(×Ö¶Î˳ÐòÎÞ¹Ø,Öظ´ÉèÖÃ×Ö¶ÎÔò¸²¸ÇÆäÖµ)
+ lpRecord := lpReqMsg.AddRecord();
+
+
+ lpRecord.SetString('fund_account', pc_username);
+ //lpRecord.SetString('password',pc_user_pwd);
+ lpRecord.SetString('futu_exch_type', 'F4');
+ lpRecord.SetString('futures_account', '');
+ lpRecord.SetString('contract_code', pc_contract_code);
+
+ lpRecord.SetString('en_entrust_status', '012347C');
+ lpRecord.SetString('query_direction', '0');
+
+ lpRecord.SetString('futu_entrust_type', '0');
+
+ //ͬ²½½ÓÊÕÏûÏ¢
+ iRet := m_lpComm.SyncSendRecv(lpReqMsg, lpAnsMsg);
+ if iRet <> 0 then
+ begin
+ //cout<<"ͬ²½Î¯ÍÐʧ°Ü:iRet="<GetErrorMsg(iRet)< 0 then
+ begin
+
+ lpAnsRecord := lpAnsMsg.GetRecord(0);
+ FillChar(c_batch_no, SizeOf(c_batch_no), 0);
+ FillChar(c_entrust_no, SizeOf(c_entrust_no), 0);
+
+ StrCopy(c_entrust_no, lpAnsRecord.GetString('entrust_no'));
+ StrCopy(c_entrust_no, lpAnsRecord.GetString('batch_no'));
+
+ i_entrust_no_mark := 888;
+
+ end;
+
+ lpReqMsg.Release();
+ lpAnsMsg.Release();
+
+end;
+
+
+function ff_cancel_entrust_no(): Integer;
+var
+ iRet: Integer;
+ lpReqMsg, lpAnsMsg: IFuMessage;
+ lpRecord: IFuRecord;
+ lpAnsRecord: IFuRecord;
+
+begin
+ Result := 0;
+
+ iRet := StrLen(c_entrust_no);
+ if (iRet = 0) then Exit;
+
+ if not Assigned(m_lpComm) then Exit;
+ if (i_comm_ok = 0) then Exit;
+
+ //ÒµÎñ²Ù×÷ίÍÐϵ¥
+ lpReqMsg := NewFuMessage(MSG_TYPE_CANCEL_ORDER, Integer(MSG_MODE_REQUEST));
+ lpAnsMsg := NewFuMessage(MSG_TYPE_UNKNOWN, Integer(MSG_MODE_ANSWER)); //½ÓÊÕÏûÏ¢(ÎÞ¹ØÏûÏ¢ÀàÐÍ)
+
+ //´ò°üÇëÇó²ÎÊý(×Ö¶Î˳ÐòÎÞ¹Ø,Öظ´ÉèÖÃ×Ö¶ÎÔò¸²¸ÇÆäÖµ)
+ lpRecord := lpReqMsg.AddRecord();
+
+ lpRecord.SetString('fund_account', pc_username);
+ //lpRecord.SetString('password',pc_user_pwd);
+ lpRecord.SetString('futu_exch_type', 'F4');
+ lpRecord.SetString('entrust_no', c_entrust_no); //ίÍкÅ
+
+ //ͬ²½½ÓÊÕÏûÏ¢
+ iRet := m_lpComm.SyncSendRecv(lpReqMsg, lpAnsMsg);
+ if iRet <> 0 then
+ begin
+
+ if lpAnsMsg.GetCount() > 0 then
+ begin
+
+ lpAnsRecord := lpAnsMsg.GetRecord(0);
+ FillChar(c_error_no, SizeOf(c_error_no), 0);
+ FillChar(c_error_info, SizeOf(c_error_info), 0);
+
+ StrCopy(c_error_no, lpAnsRecord.GetString('error_no'));
+ StrCopy(c_error_info, lpAnsRecord.GetString('error_info'));
+
+ W_Log('cancel_error', iRet, i_wk_log, c_error_no);
+ W_Log('cancel_error', iRet, i_wk_log, c_error_info);
+
+ end;
+
+
+ //cout<<"ͬ²½Î¯ÍÐʧ°Ü:iRet="<GetErrorMsg(iRet)< 0) then
+ begin
+ for I := 0 to i_get_count - 1 do
+ begin
+ lpAnsRecord := lpAnsMsg.GetRecord(I);
+ FillChar(c_log, SizeOf(c_log), 0);
+
+ StrCopy(c_log, lpAnsRecord.GetString('contract_code'));
+ s_tmp := c_log;
+ s_tmp1 := pc_what_wk;
+
+ FillChar(c_log, SizeOf(c_log), 0);
+
+ StrCopy(c_log, lpAnsRecord.GetString('entrust_bs'));
+ if c_log[0] = '2' then
+ begin
+ if (s_tmp = s_tmp1) then
+ begin
+
+ StrCopy(c_log, lpAnsRecord.GetString('futu_average_price'));
+ f_short_price := StrToFloat(c_log);
+
+
+ s_caption_9 := '¿Õ ' + Trim(c_log);
+
+ FillChar(c_log, SizeOf(c_log), 0);
+ StrCopy(c_log, lpAnsRecord.GetString('real_amount'));
+
+
+ i_short_mark := Round(StrToFloat(c_log));
+
+ s_caption_11 := Trim(c_log);
+
+ if (i_short_mark > (i_F + i_S - 1)) then i_short_S_mark := 888 else i_short_S_mark := 0;
+ if (i_short_mark > (i_F + i_S + i_T - 1)) then i_short_T_mark := 888 else i_short_T_mark := 0;
+ end
+ end
+ else if c_log[0] = '1' then
+ begin
+ if (s_tmp = s_tmp1) then
+ begin
+
+ StrCopy(c_log, lpAnsRecord.GetString('futu_average_price'));
+
+ f_business_price := StrToFloat(c_log);
+
+ s_caption_8 := '¶à ' + Trim(c_log);
+
+ FillChar(c_log, SizeOf(c_log), 0);
+
+ StrCopy(c_log, lpAnsRecord.GetString('real_amount'));
+
+ s_caption_10 := Trim(c_log);
+
+ i_got_it_mark := Round(StrToFloat(c_log));
+
+ if (i_got_it_mark > (i_F + i_S - 1)) then i_get_S_mark := 888 else i_get_S_mark := 0;
+ if (i_got_it_mark > (i_F + i_S + i_T - 1)) then i_get_T_mark := 888 else i_get_T_mark := 0;
+ end;
+ end;
+ end;
+ end
+ else
+ begin
+
+ i_got_it_mark := 0;
+ i_get_S_mark := 0;
+ i_get_T_mark := 0;
+ i_short_mark := 0;
+ i_short_S_mark := 0;
+ i_short_T_mark := 0;
+
+ //frmMain2.GRID_S001.Cells[0,0]:=pc_what_wk;
+
+ end;
+
+ lpReqMsg.Release();
+ lpAnsMsg.Release();
+
+ if (i_long_act_flag = -1) and (i_got_it_mark = 0) then i_long_act_flag := 1;
+ if (i_short_act_flag = -1) and (i_short_mark = 0) then i_short_act_flag := 1;
+
+end;
+
+
+function ff_get_qty_ex(): Integer;
+var
+ iRet: Integer;
+ lpReqMsg, lpAnsMsg: IFuMessage;
+ lpRecord, lpAnsRecord: IFuRecord;
+ c_log: array[0..88] of char;
+ s_tmp: string;
+ s_tmp1: string;
+
+ I, i_get_count: Integer;
+
+begin
+ Result := 0;
+
+ if not Assigned(m_lpComm) then Exit;
+
+ if (i_comm_ok = 0) then Exit;
+
+ //for
+ i_short_mark_ex := 0;
+ i_got_it_mark_ex := 0;
+ f_short_price_ex := 0.0;
+ f_business_price_ex := 0.0;
+
+ //ÒµÎñ²Ù×÷ίÍÐϵ¥
+ lpReqMsg := NewFuMessage(MSG_TYPE_GET_HOLDSINFO, Integer(MSG_MODE_REQUEST)); //ίÍÐϵ¥
+ lpAnsMsg := NewFuMessage(MSG_TYPE_UNKNOWN, Integer(MSG_MODE_ANSWER)); //½ÓÊÕÏûÏ¢(ÎÞ¹ØÏûÏ¢ÀàÐÍ)
+
+ //´ò°üÇëÇó²ÎÊý(×Ö¶Î˳ÐòÎÞ¹Ø,Öظ´ÉèÖÃ×Ö¶ÎÔò¸²¸ÇÆäÖµ)
+ lpRecord := lpReqMsg.AddRecord();
+
+
+ lpRecord.SetString('fund_account', pc_username);
+ //lpRecord.SetString('password',pc_user_pwd);
+ lpRecord.SetString('futu_exch_type', '');
+
+ lpRecord.SetString('futures_account', '');
+ lpRecord.SetString('contract_code', '');
+ lpRecord.SetString('entrust_bs', '');
+ lpRecord.SetString('query_direction', '0');
+ lpRecord.SetString('query_mode', '1');
+ lpRecord.SetString('request_num', '50');
+ lpRecord.SetString('action_in', '');
+ lpRecord.SetString('position_str', '0');
+ lpRecord.SetString('switch_type', '1');
+
+ iRet := m_lpComm.SyncSendRecv(lpReqMsg, lpAnsMsg);
+
+ //Form1.ShowFuMessage(lpAnsMsg);
+
+ i_get_count := 0;
+ if (iRet = 0) then i_get_count := lpAnsMsg.GetCount;
+
+ if (iRet = 0) and (i_get_count > 0) then
+ begin
+ for I := 0 to i_get_count - 1 do
+ begin
+ lpAnsRecord := lpAnsMsg.GetRecord(I);
+ FillChar(c_log, SizeOf(c_log), 0);
+
+ StrCopy(c_log, lpAnsRecord.GetString('contract_code'));
+ s_tmp := c_log;
+ s_tmp1 := pc_what_wk;
+
+ FillChar(c_log, SizeOf(c_log), 0);
+
+ StrCopy(c_log, lpAnsRecord.GetString('entrust_bs'));
+ if c_log[0] = '2' then
+ begin
+ if (s_tmp = s_tmp1) then
+ begin
+
+ StrCopy(c_log, lpAnsRecord.GetString('futu_average_price'));
+
+ f_short_price_ex := StrToFloat(c_log);
+
+ FillChar(c_log, SizeOf(c_log), 0);
+ StrCopy(c_log, lpAnsRecord.GetString('real_amount'));
+
+ i_short_mark_ex := Round(StrToFloat(c_log));
+ end
+ end
+ else if c_log[0] = '1' then
+ begin
+ if (s_tmp = s_tmp1) then
+ begin
+
+ StrCopy(c_log, lpAnsRecord.GetString('futu_average_price'));
+
+ f_business_price_ex := StrToFloat(c_log);
+
+ FillChar(c_log, SizeOf(c_log), 0);
+
+ StrCopy(c_log, lpAnsRecord.GetString('real_amount'));
+
+ i_got_it_mark_ex := Round(StrToFloat(c_log));
+ end;
+ end;
+ end;
+ end
+ else
+ begin
+ i_short_mark_ex := 0;
+ i_got_it_mark_ex := 0;
+ f_short_price_ex := 0.0;
+ f_business_price_ex := 0.0;
+ end;
+
+ lpReqMsg.Release();
+ lpAnsMsg.Release();
+end;
+
+
+//20130221
+
+function ff_get_profit(): Integer;
+var
+ iRet: Integer;
+ lpReqMsg, lpAnsMsg: IFuMessage;
+ lpRecord, lpAnsRecord: IFuRecord;
+begin
+ Result := 0;
+
+ if not Assigned(m_lpComm) then Exit;
+ if (i_comm_ok = 0) then Exit;
+
+ FillChar(c_batch_no, SizeOf(c_batch_no), 0);
+ FillChar(c_entrust_no, SizeOf(c_entrust_no), 0);
+
+
+ //ÒµÎñ²Ù×÷ίÍÐϵ¥
+ lpReqMsg := NewFuMessage(MSG_TYPE_GET_PROFIT, Integer(MSG_MODE_REQUEST)); //ίÍÐϵ¥
+ lpAnsMsg := NewFuMessage(MSG_TYPE_UNKNOWN, Integer(MSG_MODE_ANSWER)); //½ÓÊÕÏûÏ¢(ÎÞ¹ØÏûÏ¢ÀàÐÍ)
+
+ //´ò°üÇëÇó²ÎÊý(×Ö¶Î˳ÐòÎÞ¹Ø,Öظ´ÉèÖÃ×Ö¶ÎÔò¸²¸ÇÆäÖµ)
+ lpRecord := lpReqMsg.AddRecord();
+
+
+ lpRecord.SetString('fund_account', pc_username);
+ //lpRecord.SetString('password',pc_user_pwd);
+ lpRecord.SetString('money_type', '0');
+
+ //ͬ²½½ÓÊÕÏûÏ¢
+ iRet := m_lpComm.SyncSendRecv(lpReqMsg, lpAnsMsg);
+ if iRet <> 0 then
+ begin
+ //cout<<"ͬ²½Î¯ÍÐʧ°Ü:iRet="<GetErrorMsg(iRet)< 0 then
+ begin
+ lpAnsRecord := lpAnsMsg.GetRecord(0);
+ FillChar(c_rights_balance, SizeOf(c_rights_balance), 0);
+ StrCopy(c_rights_balance, lpAnsRecord.GetString('rights_balance'));
+ f_rights_balance := StrToFloat(c_rights_balance);
+ i_rights_balance := Round(StrToFloat(c_rights_balance) / 10000);
+ end;
+
+ lpReqMsg.Release();
+ lpAnsMsg.Release();
+
+
+end;
+
+//20130221 end
+
+
+
+function ff_main_wk_loop(): Integer;
+var
+ i_loop_wk, i_loop, i_tmp: Integer;
+ i_tmp_1: Integer;
+ i_tmp_2: Integer;
+ i_tmp_3: Integer;
+ i_tmp_4: Integer;
+ i_tmp_5: Integer;
+ i_tmp_6: Integer;
+ i_tmp_7: Integer;
+ i_tmp_8: Integer;
+ i_index_8: Integer;
+
+ i_tmp_9: Integer;
+
+ s_tmp, s_tmp1: string;
+
+ pc_username_bak: PChar;
+
+
+begin
+ Result := 0;
+
+ i_line_no_001 := 1;
+ i_line_no_001 := i_line_no_001 + 1;
+
+ if i_only_1 = 1 then s_caption_14 := 'µ¥·¢' else s_caption_14 := 'Ⱥ·¢';
+
+ if (i_comm_ok = 0) then
+ begin
+ //frmMain2.GRID_S006.Cells[0,0]:='¶Ï¿ª';
+ s_caption_3 := '¶Ï¿ª';
+ Exit;
+ end
+ else
+ begin
+ //frmMain2.GRID_S006.Cells[0,0]:='Áª»ú';
+ s_caption_3 := 'Áª»ú';
+ end;
+
+ if i_do_ff_qty_loop > 0 then
+ begin
+ i_do_ff_qty_loop := 0;
+ for i_loop_wk := 0 to i_fc_count - 1 do
+ begin
+ pc_username := as_fc_data[i_loop_wk].pc_username;
+ ff_get_qty_ex();
+ ff_get_profit();
+ as_fc_data[i_loop_wk].i_short_mark := i_short_mark_ex;
+ as_fc_data[i_loop_wk].i_got_it_mark := i_got_it_mark_ex;
+ as_fc_data[i_loop_wk].i_rights_balance := i_rights_balance;
+ as_fc_data[i_loop_wk].f_short_price := f_short_price_ex;
+ as_fc_data[i_loop_wk].f_business_price := f_business_price_ex;
+ as_fc_data[i_loop_wk].f_rights_balance := f_rights_balance;
+ end;
+ end;
+
+ pc_username := as_fc_data[i_fc_wk_index].pc_username;
+ s_caption_7 := pc_username;
+ s_caption_13 := as_fc_data[i_fc_wk_index].pc_xxx_name;
+
+ i_line_no_001 := i_line_no_001 + 1;
+
+ if (i_no_trade = 0) then
+ begin
+ //s_caption_4:='×Ô¶¯';
+ end
+ else
+ begin
+ //s_caption_4:='ÊÖ¶¯';
+ end;
+ i_line_no_001 := i_line_no_001 + 1;
+
+
+ if (i_long_mbm_count > 0) then
+ begin
+ //frmMain2.GRID_S002.Cells[0,0]:='L5 ' + IntToStr(i_long_mbm_count);
+ //frmMain2.GRID_S002.Cells[1,0]:='L4 ' + IntToStr(i_4ma_long_mbm_count);
+ end;
+ i_line_no_001 := i_line_no_001 + 1;
+
+ if (i_short_mbm_count > 0) then
+ begin
+ //frmMain2.GRID_S002.Cells[0,0]:='S5 ' + IntToStr(i_short_mbm_count);
+ //frmMain2.GRID_S002.Cells[1,0]:='S4 ' + IntToStr(i_4ma_short_mbm_count);
+ end;
+
+ i_line_no_001 := i_line_no_001 + 1;
+
+ //for i_sum_long_mbm_count ... ...
+ if (1 > 0) then
+ begin
+ //frmMain2.GRID_S003.Cells[0,0]:='SL5 ';
+ //frmMain2.GRID_S003.Cells[1,0]:=IntToStr(i_sum_long_mbm_count);
+ //frmMain2.GRID_S003.Cells[0,1]:='SS5 ';
+ //frmMain2.GRID_S003.Cells[1,1]:=IntToStr(i_sum_short_mbm_count);
+ //frmMain2.GRID_S003.Cells[0,2]:='SD5 ';
+ //frmMain2.GRID_S003.Cells[1,2]:=IntToStr(i_sum_long_mbm_count-i_sum_short_mbm_count);
+
+ //frmMain2.GRID_S003.Cells[0,3]:='SL4 ';
+ //frmMain2.GRID_S003.Cells[1,3]:=IntToStr(i_sum_4ma_long_mbm_count);
+ //frmMain2.GRID_S003.Cells[0,4]:='SS4 ';
+ //frmMain2.GRID_S003.Cells[1,4]:=IntToStr(i_sum_4ma_short_mbm_count);
+ //frmMain2.GRID_S003.Cells[0,5]:='SD4 ';
+ //frmMain2.GRID_S003.Cells[1,5]:=IntToStr(i_sum_4ma_long_mbm_count-i_sum_4ma_short_mbm_count);
+
+ end;
+
+ i_line_no_001 := i_line_no_001 + 1;
+
+
+ //frmMain2.GRID_S002.Cells[0,1]:='RSI';
+ //frmMain2.GRID_S002.Cells[1,1]:=FloatToStrF(as_k_chg_ma_rsi[i_s_k_chg_index_wk].ai_rsi[0]/100,ffFixed,7,2);
+ i_line_no_001 := i_line_no_001 + 1;
+
+ if not Assigned(m_lpComm) then Exit;
+ if (i_comm_ok = 0) then Exit;
+
+
+ ff_chk_power_vol(i_s_k_chg_index_wk);
+
+
+ i_line_no_001 := i_line_no_001 + 1;
+ //for get K line Only
+ if (i_make_k_only > 0) then Exit;
+ i_line_no_001 := i_line_no_001 + 1;
+
+
+ if i_do_ff_qty_loop > 0 then
+ begin
+ i_do_ff_qty_loop := 0;
+ for i_loop_wk := 0 to i_fc_count - 1 do
+ begin
+ ff_get_qty();
+ ff_get_profit();
+ as_fc_data[i_loop_wk].i_short_mark := i_short_mark;
+ as_fc_data[i_loop_wk].i_got_it_mark := i_got_it_mark;
+ as_fc_data[i_loop_wk].i_rights_balance := i_rights_balance;
+ end;
+ end;
+
+
+ if (i_fc_wk_index_bak <> i_fc_wk_index) then
+ begin
+ s_caption_8 := ' ';
+ s_caption_9 := ' ';
+ s_caption_10 := ' ';
+ s_caption_11 := ' ';
+
+ i_fc_wk_index_bak := i_fc_wk_index;
+ ff_get_qty();
+ ff_get_profit();
+ as_fc_data[i_fc_wk_index].i_rights_balance := i_rights_balance;
+ s_caption_4 := c_rights_balance;
+ end;
+
+ if (i_short_mark = 0) then i_lock_short := 0;
+ if (i_got_it_mark = 0) then i_lock_long := 0;
+
+ if (i_ff_get_qty_flag > 1) then
+ begin
+ i_ff_get_qty_flag := i_ff_get_qty_flag - 1;
+ ff_get_qty();
+ end;
+
+ //for ff_action.ini
+ s_tmp := FormatDateTime('yyyymmddhhnnss', Now);
+
+ if (i_open_long_timer = 0) and
+ (pc_open_long_time <> nil) and (StrLen(pc_open_long_time) = StrLen(PChar(s_tmp))) then
+ begin
+ s_tmp1 := pc_open_long_time;
+ if (s_tmp > s_tmp1) then
+ begin
+ i_BSK := 1;
+ i_open_long_timer := 888;
+ end;
+ end;
+
+ if (i_open_short_timer = 0) and
+ (pc_open_short_time <> nil) and (StrLen(pc_open_short_time) = StrLen(PChar(s_tmp))) then
+ begin
+ s_tmp1 := pc_open_short_time;
+ if (s_tmp > s_tmp1) then
+ begin
+ i_BSK := 3;
+ i_open_short_timer := 888;
+ end;
+ end;
+
+
+ if (i_close_long_timer = 0) and
+ (pc_close_long_time <> nil) and (StrLen(pc_close_long_time) = StrLen(PChar(s_tmp))) then
+ begin
+ s_tmp1 := pc_close_long_time;
+ if (s_tmp > s_tmp1) then
+ begin
+ i_BSK := 5;
+ i_close_long_timer := 888;
+ end;
+ end;
+
+
+ if (i_close_short_timer = 0) and
+ (pc_close_short_time <> nil) and (StrLen(pc_close_short_time) = StrLen(PChar(s_tmp))) then
+ begin
+ s_tmp1 := pc_close_short_time;
+ if (s_tmp > s_tmp1) then
+ begin
+ i_BSK := 6;
+ i_close_short_timer := 888;
+ end;
+ end;
+
+
+
+ if (i_BSK = 1) or (i_BSK = 2) and (f_last_price_wk > 8.0) then
+ begin
+
+ i_ff_get_qty_flag := 18;
+
+ //for loop add
+ for i_loop_wk := 0 to i_fc_count - 1 do
+ begin
+
+ if i_only_1 = 1 then i_loop := i_fc_wk_index else i_loop := i_loop_wk;
+
+ if as_fc_data[i_loop].pc_username = nil then Break;
+ pc_username := as_fc_data[i_loop].pc_username;
+
+ //ff_entrust_no(pc_what_wk);
+ //ff_cancel_entrust_no();
+ ff_get_qty();
+
+ if (i_BSK = 1) then s_tmp := FloatToStrF(f_sale_1 + i_open_delta, ffFixed, 8, 2);
+ if (i_BSK = 2) then s_tmp := FloatToStrF(f_buy_1 - 1.0, ffFixed, 8, 2);
+ if (i_BSK = 2) and (i_open_price > 0) then s_tmp := IntToStr(i_open_price);
+
+ i_BSK := 0;
+
+ if (i_got_it_mark > (as_fc_data[i_loop].i_long_max - 1)) then Continue;
+
+ //ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_F)),m_mairu,m_kaicang);
+ ff_order_ex(pc_what_wk, PChar(s_tmp), PChar(IntToStr(as_fc_data[i_loop].i_VOL)), m_mairu, m_kaicang);
+
+ W_Log('main_loop', as_k_chg[i_s_k_chg_index_wk].i_date, i_wk_log, 'BSK,make long position!');
+ //Sleep(2000);
+ //ff_get_qty();
+
+ if i_only_1 = 1 then Break;
+
+ end
+ end
+ else if (i_BSK = 1) or (i_BSK = 2) then i_BSK := 0;
+
+ if (i_BSK = 3) or (i_BSK = 4) and (f_last_price_wk > 8.0) then
+ begin
+
+ i_ff_get_qty_flag := 18;
+ //for loop add
+ for i_loop_wk := 0 to i_fc_count - 1 do
+ begin
+
+ if i_only_1 = 1 then i_loop := i_fc_wk_index else i_loop := i_loop_wk;
+
+ if as_fc_data[i_loop].pc_username = nil then Break;
+ pc_username := as_fc_data[i_loop].pc_username;
+
+ //ff_entrust_no(pc_what_wk);
+ //ff_cancel_entrust_no();
+ ff_get_qty();
+
+ if (i_BSK = 3) then s_tmp := FloatToStrF(f_buy_1 - i_open_delta, ffFixed, 8, 2);
+ if (i_BSK = 4) then s_tmp := FloatToStrF(f_sale_1 + 1.0, ffFixed, 8, 2);
+ if (i_BSK = 4) and (i_open_price > 0) then s_tmp := IntToStr(i_open_price);
+
+ i_BSK := 0;
+
+ if (i_short_mark > (as_fc_data[i_loop].i_short_max - 1)) then Continue;
+
+ //ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_F)),m_maichu,m_kaicang);
+
+ ff_order_ex(pc_what_wk, PChar(s_tmp), PChar(IntToStr(as_fc_data[i_loop].i_VOL)), m_maichu, m_kaicang);
+
+ W_Log('main_loop', as_k_chg[i_s_k_chg_index_wk].i_date, i_wk_log, 'BSK,make short position!');
+ //Sleep(2000);
+ //ff_get_qty();
+ //frmMain2.GRID_S002.Repaint;
+
+ if i_only_1 = 1 then Break;
+
+ end
+ end
+ else if (i_BSK = 3) or (i_BSK = 4) then i_BSK := 0;
+
+ //for stp, auto_trade
+
+ if (i_stp_long > 0) and (i_BSK = 0) and (i_act_stp_long_mark = 0) then
+ if (i_got_it_mark > -1) and (f_last_price_wk > 8.0) then
+ begin
+ //if( i_set_stp_long_wk =0 ) Then i_set_stp_long_wk := Round(f_business_price+0.49);
+ if (i_set_stp_long_wk > 0) and (i_set_stp_long_wk < Round(f_last_price_wk + 0.49)) then
+ begin
+ i_stp_long := 0;
+ i_act_stp_long_mark := 888;
+ i_ff_get_qty_flag := 18;
+ i_act_stp_long := 888;
+ i_BSK := m_bsk_ask_long;
+ W_Log('main_loop', as_k_chg[i_s_k_chg_index_wk].i_date, i_wk_log, 'Long STP!');
+ end;
+ end;
+
+ if (i_stp_short > 0) and (i_BSK = 0) and (i_act_stp_short_mark = 0) then
+ if (i_got_it_mark > -1) and (f_last_price_wk > 8.0) then
+ begin
+ //if( i_set_stp_short_wk =0 ) Then i_set_stp_short_wk := Round(f_business_price+0.49);
+ if (i_set_stp_short_wk > 0) and (i_set_stp_short_wk > Round(f_last_price_wk - 0.49)) then
+ begin
+ i_stp_short := 0;
+ i_act_stp_short_mark := 888;
+ i_ff_get_qty_flag := 18;
+ i_act_stp_short := 888;
+ i_BSK := m_bsk_bid_short;
+ W_Log('main_loop', as_k_chg[i_s_k_chg_index_wk].i_date, i_wk_log, 'Short STP!');
+ end;
+ end;
+ //end stp
+
+ //for locked, auto_clear
+
+ if (i_lock_long > 0) and (i_BSK = 0) and (i_cut_lock_long_mark = 0) then
+ //if(i_got_it_mark >0) and (f_last_price_wk >8.0) and (f_last_price_wk - f_business_price < 0.50 ) Then
+ if (i_got_it_mark > 0) and (f_last_price_wk > 8.0) then
+ begin
+ if (i_set_lock_long_wk = 0) then i_set_lock_long_wk := Round(f_business_price + 0.49);
+ if (i_set_lock_long_wk > 0) and (i_set_lock_long_wk > Round(f_last_price_wk - 0.49)) then
+ begin
+ i_lock_long := 0;
+ i_cut_lock_long_mark := 888;
+ i_ff_get_qty_flag := 18;
+ i_cut_lock_long := 888;
+ i_BSK := m_bsk_clear_long;
+ W_Log('main_loop', as_k_chg[i_s_k_chg_index_wk].i_date, i_wk_log, 'Locked Long Clear!');
+ end;
+ end;
+
+ if (i_lock_short > 0) and (i_BSK = 0) and (i_cut_lock_short_mark = 0) then
+ //if(i_short_mark >0) and (f_last_price_wk >8.0) and ( f_short_price - f_last_price_wk <0.50 ) Then
+ if (i_short_mark > 0) and (f_last_price_wk > 8.0) then
+ begin
+ if (i_set_lock_short_wk = 0) then i_set_lock_short_wk := Round(f_short_price - 0.49);
+ if (i_set_lock_short_wk > 0) and (i_set_lock_short_wk < Round(f_last_price_wk + 0.49)) then
+ begin
+ i_lock_short := 0;
+ i_cut_lock_short_mark := 888;
+ i_ff_get_qty_flag := 18;
+ i_cut_lock_short := 888;
+ i_BSK := m_bsk_clear_short;
+ W_Log('main_loop', as_k_chg[i_s_k_chg_index_wk].i_date, i_wk_log, 'Locked Short Clear!');
+ end;
+ end;
+
+ //for locked, auto_clear_end
+
+ i_line_no_001 := i_line_no_001 + 1;
+
+ //if (i_BSK = 5 ) and (i_got_it_mark >0) and (f_last_price_wk >8.0) Then
+ if (i_BSK = 5) and (f_last_price_wk > 8.0) then
+ begin
+ i_ff_get_qty_flag := 18;
+
+ i_BSK := 0;
+
+ if (i_lock_long > 0) and (i_cut_lock_long = 0) then
+ begin
+ s_caption_status := 'ÒÑËø¶à²Ö£¬²»µÃ½øÐг嶯µÄƽ¶à²Ù×÷£¡';
+ end
+ else
+ begin
+ //for loop add
+ for i_loop_wk := 0 to i_fc_count - 1 do
+ begin
+
+ //for reset
+ if (i_lock_long > 0) and (i_cut_lock_long > 0) then
+ begin
+ i_cut_lock_long := 0;
+ end;
+
+ if i_only_1 = 1 then i_loop := i_fc_wk_index else i_loop := i_loop_wk;
+
+ if as_fc_data[i_loop].pc_username = nil then Break;
+ pc_username := as_fc_data[i_loop].pc_username;
+
+ s_tmp := FloatToStrF(f_last_price_wk - i_close_delta, ffFixed, 8, 2);
+
+ //ff_entrust_no(pc_what_wk);
+ //ff_cancel_entrust_no();
+ ff_get_qty();
+
+ if (i_clr_long_1_mark > 0) then
+ //if (i_loop <> i_fc_wk_index ) Then
+ i_got_it_mark := as_fc_data[i_loop].i_VOL;
+
+ if (i_clr_long_to_001_mark > 0) then
+ begin
+ if (i_got_it_mark < 2) then
+ ff_order_ex(pc_what_wk, PChar(s_tmp), PChar(IntToStr(i_got_it_mark)), m_maichu, m_pingcang)
+ else
+ ff_order_ex(pc_what_wk, PChar(s_tmp), PChar(IntToStr(i_got_it_mark - 1)), m_maichu, m_pingcang);
+ end
+ else
+ ff_order_ex(pc_what_wk, PChar(s_tmp), PChar(IntToStr(i_got_it_mark)), m_maichu, m_pingcang);
+
+
+ W_Log('main_loop', as_k_chg[i_s_k_chg_index_wk].i_date, i_wk_log, '-12,BSK,long clear!');
+ //Sleep(2000);
+ //ff_get_qty();
+ //frmMain2.GRID_S002.Repaint;
+
+ if i_only_1 = 1 then Break;
+
+ end
+ end;
+
+ if (i_clr_long_1_mark > 0) then i_clr_long_1_mark := 0;
+ if (i_clr_long_to_001_mark > 0) then i_clr_long_to_001_mark := 0;
+
+ end
+ else if (i_BSK = 5) then i_BSK := 0;
+
+ i_line_no_001 := i_line_no_001 + 1;
+
+ if (i_BSK = 7) and (f_last_price_wk > 8.0) then
+ //if (i_BSK = 7 ) and (i_got_it_mark >0) and (f_last_price_wk >8.0) Then
+ begin
+ //i_ff_get_qty_flag := 18;
+
+ for i_loop_wk := 0 to i_fc_count - 1 do
+ begin
+
+ if i_only_1 = 1 then i_loop := i_fc_wk_index else i_loop := i_loop_wk;
+
+ if as_fc_data[i_loop].pc_username = nil then Break;
+ pc_username := as_fc_data[i_loop].pc_username;
+
+ i_got_it_mark := as_fc_data[i_loop].i_VOL;
+
+ //ff_entrust_no(pc_what_wk);
+ //ff_cancel_entrust_no();
+
+ ff_get_qty();
+
+ i_BSK := 0;
+ s_tmp := FloatToStrF(f_last_price_wk + 2.0, ffFixed, 8, 2);
+ if (i_open_price > 0) then s_tmp := IntToStr(i_open_price);
+
+ if (i_open_price > 0) and (i_open_vol > 0) then
+ ff_order_ex(pc_what_wk, PChar(s_tmp), PChar(IntToStr(i_open_vol)), m_maichu, m_pingcang)
+ else
+ //20120309 chg
+ //if(i_got_it_mark <2) Then
+ ff_order_ex(pc_what_wk, PChar(s_tmp), PChar(IntToStr(i_got_it_mark)), m_maichu, m_pingcang);
+ //else
+ // ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_got_it_mark-1)),m_maichu,m_pingcang);
+
+ W_Log('main_loop', as_k_chg[i_s_k_chg_index_wk].i_date, i_wk_log, '+2,BSK,long clear!');
+ //Sleep(2000);
+ //ff_get_qty();
+ //frmMain2.GRID_S002.Repaint;
+ if i_only_1 = 1 then Break;
+ end
+ end
+ else if (i_BSK = 7) then i_BSK := 0;
+
+
+ i_line_no_001 := i_line_no_001 + 1;
+
+
+ if (i_BSK = 6) and (i_short_mark > 0) and (f_last_price_wk > 8.0) then
+ begin
+ i_ff_get_qty_flag := 18;
+
+ i_BSK := 0;
+
+ if (i_lock_short > 0) and (i_cut_lock_short = 0) then
+ begin
+ s_caption_status := 'ÒÑËø¶à²Ö£¬²»µÃ½øÐг嶯µÄƽ¶à²Ù×÷£¡';
+ end
+ else
+ begin
+
+ for i_loop_wk := 0 to i_fc_count - 1 do
+ begin
+
+ if (i_lock_short > 0) and (i_cut_lock_short > 0) then
+ begin
+ i_cut_lock_short := 0;
+ end;
+
+ if i_only_1 = 1 then i_loop := i_fc_wk_index else i_loop := i_loop_wk;
+
+ if as_fc_data[i_loop].pc_username = nil then Break;
+ pc_username := as_fc_data[i_loop].pc_username;
+ i_short_mark := as_fc_data[i_loop].i_VOL;
+
+ //ff_entrust_no(pc_what_wk);
+ //ff_cancel_entrust_no();
+
+ ff_get_qty();
+
+ if (i_clr_short_1_mark > 0) then
+ i_short_mark := as_fc_data[i_loop].i_VOL;
+
+ s_tmp := FloatToStrF(f_last_price_wk + i_close_delta, ffFixed, 8, 2);
+
+ if (i_clr_short_to_001_mark > 0) then
+ begin
+ if (i_short_mark < 2) then
+ ff_order_ex(pc_what_wk, PChar(s_tmp), PChar(IntToStr(i_short_mark)), m_mairu, m_pingcang)
+ else
+ ff_order_ex(pc_what_wk, PChar(s_tmp), PChar(IntToStr(i_short_mark - 1)), m_mairu, m_pingcang);
+ end
+ else
+ //if(i_short_mark <2) Then
+ ff_order_ex(pc_what_wk, PChar(s_tmp), PChar(IntToStr(i_short_mark)), m_mairu, m_pingcang);
+ //else
+ // ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_short_mark-1)),m_mairu,m_pingcang);
+
+ W_Log('main_loop', as_k_chg[i_s_k_chg_index_wk].i_date, i_wk_log, '+12 BSK,short clear!');
+ //Sleep(2000);
+ //ff_get_qty();
+ //frmMain2.GRID_S002.Repaint;
+ if i_only_1 = 1 then Break;
+ end
+ end;
+
+ if (i_clr_short_1_mark > 0) then i_clr_short_1_mark := 0;
+ if (i_clr_short_to_001_mark > 0) then i_clr_short_to_001_mark := 0;
+
+ end
+ else if (i_BSK = 6) then i_BSK := 0;
+
+ i_line_no_001 := i_line_no_001 + 1;
+
+ if (i_BSK = 8) and (i_short_mark > 0) and (f_last_price_wk > 8.0) then
+ begin
+ //i_ff_get_qty_flag := 18;
+
+ i_BSK := 0;
+ for i_loop_wk := 0 to i_fc_count - 1 do
+ begin
+ if i_only_1 = 1 then i_loop := i_fc_wk_index else i_loop := i_loop_wk;
+
+ if as_fc_data[i_loop].pc_username = nil then Break;
+ pc_username := as_fc_data[i_loop].pc_username;
+ i_short_mark := as_fc_data[i_loop].i_VOL;
+
+ //ff_entrust_no(pc_what_wk);
+ //ff_cancel_entrust_no();
+
+ ff_get_qty();
+
+ s_tmp := FloatToStrF(f_last_price_wk - 2.0, ffFixed, 8, 2);
+ if (i_open_price > 0) then s_tmp := IntToStr(i_open_price);
+ //ff_entrust_no(pc_what_wk);
+ //ff_cancel_entrust_no();
+
+ //if(i_short_mark <2) Then
+ if (i_open_price > 0) and (i_open_vol > 0) then
+ ff_order_ex(pc_what_wk, PChar(s_tmp), PChar(IntToStr(i_open_vol)), m_mairu, m_pingcang)
+ else
+ ff_order_ex(pc_what_wk, PChar(s_tmp), PChar(IntToStr(i_short_mark)), m_mairu, m_pingcang);
+ //else
+ //ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_short_mark-1)),m_mairu,m_pingcang);
+
+ W_Log('main_loop', as_k_chg[i_s_k_chg_index_wk].i_date, i_wk_log, '-2,BSK,short clear!');
+ //Sleep(2000);
+ //ff_get_qty();
+ //frmMain2.GRID_S002.Repaint;
+ if i_only_1 = 1 then Break;
+ end
+ end
+ else if (i_BSK = 8) then i_BSK := 0;
+
+ if (i_BSK = 9) and (f_last_price_wk > 8.0) then
+ begin
+ i_BSK := 0;
+
+ for i_loop_wk := 0 to i_fc_count - 1 do
+ begin
+ if i_only_1 = 1 then i_loop := i_fc_wk_index else i_loop := i_loop_wk;
+
+ if as_fc_data[i_loop].pc_username = nil then Break;
+ pc_username := as_fc_data[i_loop].pc_username;
+
+ ff_entrust_no(pc_what_wk);
+ ff_cancel_entrust_no();
+
+ if i_only_1 = 1 then Break;
+ end
+ end
+ else if (i_BSK = 9) then i_BSK := 0;
+
+ //for ff_300m_ex : Exit Here!
+ Exit;
+
+
+ i_line_no_001 := i_line_no_001 + 1;
+
+ ff_short_pass3_mark(i_s_k_chg_index_wk - 1);
+
+ i_line_no_001 := i_line_no_001 + 1;
+
+ ff_get_BS_Mark(i_s_k_chg_index_wk - 1);
+
+ i_line_no_001 := i_line_no_001 + 1;
+
+ ff_get_S_L_Mark(i_s_k_chg_index_wk - 1);
+
+ i_line_no_001 := i_line_no_001 + 1;
+
+ if (f_last_price_wk < 1) then Exit;
+
+ i_line_no_001 := i_line_no_001 + 1;
+ //for auto_clear
+ i_tmp := i_B_S_Flag;
+ if (i_B_S_Flag_18 > 0) and (i_B_S_Flag_10 > 0) then
+ if (i_tmp < 0) and (i_got_it_mark > 0) and (f_last_price_wk > 8.0) then
+ begin
+ s_tmp := FloatToStrF(f_last_price_wk - 2.0, ffFixed, 8, 2);
+ ff_entrust_no(pc_what_wk);
+ ff_cancel_entrust_no();
+ ff_order_ex(pc_what_wk, PChar(s_tmp), PChar(IntToStr(i_got_it_mark)), m_maichu, m_pingcang);
+ W_Log('main_loop', as_k_chg[i_s_k_chg_index_wk].i_date, i_wk_log, 'Auto_Clear_Long!');
+ Sleep(2000);
+ ff_get_qty();
+ //frmMain2.GRID_S002.Repaint;
+ end;
+ i_line_no_001 := i_line_no_001 + 1;
+
+ i_tmp := i_B_S_Flag;
+ if (i_B_S_Flag_18 < 0) and (i_B_S_Flag_10 < 0) then
+ if (i_tmp > 0) and (i_short_mark > 0) and (f_last_price_wk > 8.0) then
+ begin
+ s_tmp := FloatToStrF(f_last_price_wk + 2.0, ffFixed, 8, 2);
+ ff_entrust_no(pc_what_wk);
+ ff_cancel_entrust_no();
+
+ ff_order_ex(pc_what_wk, PChar(s_tmp), PChar(IntToStr(i_short_mark)), m_mairu, m_pingcang);
+
+ W_Log('main_loop', as_k_chg[i_s_k_chg_index_wk].i_date, i_wk_log, 'auto_clear_short!');
+ Sleep(2000);
+ ff_get_qty();
+ //frmMain2.GRID_S002.Repaint;
+ end;
+
+ //for auto_clear_end
+ i_line_no_001 := i_line_no_001 + 1;
+
+ if (i_get_S_mark = 0) and (i_S > 0) and
+ (f_last_price_wk > f_last_price_1 + i_A) and
+ (i_got_it_mark > 0) and
+
+ //(i_ADD_FLOSS_MAX > i_long_FLOSS_MAX) and
+
+ (f_last_price_wk - f_business_price > f_rsi_add) and
+ (f_last_price_wk - f_business_price < f_rsi_add * 2) then
+ begin
+ if i_B_S_Flag > 0 then
+ begin
+ i_get_S_mark := 888;
+ s_tmp := FloatToStrF(f_last_price_wk + 1, ffFixed, 8, 2);
+ ff_order_ex(pc_what_wk, PChar(s_tmp), PChar(IntToStr(i_S)), '1', '1');
+
+ W_Log('main_loop', as_k_chg[i_s_k_chg_index_wk].i_date, i_wk_log, '8,add long position!');
+
+ Sleep(2000);
+ ff_get_qty();
+ end;
+
+ end;
+
+ i_line_no_001 := i_line_no_001 + 1;
+
+ if (i_short_S_mark = 0) and (i_S > 0) and
+ (f_last_price_wk < f_last_price_1 - i_A) and
+ (i_short_mark > 0) and
+
+ //(i_ADD_FLOSS_MAX > i_short_FLOSS_MAX) and
+
+ (f_short_price - f_last_price_wk > f_rsi_add) and
+ (f_short_price - f_last_price_wk < f_rsi_add * 2) then
+ begin
+ if i_B_S_Flag < 0 then
+ begin
+ i_short_S_mark := 888;
+ s_tmp := FloatToStrF(f_last_price_wk - 2.0, ffFixed, 8, 2);
+ ff_order_ex(pc_what_wk, PChar(s_tmp), PChar(IntToStr(i_S)), '2', '1');
+
+ W_Log('main_loop', as_k_chg[i_s_k_chg_index_wk].i_date, i_wk_log, '8,add short position!');
+
+ Sleep(2000);
+ ff_get_qty();
+ end;
+ end;
+
+ i_line_no_001 := i_line_no_001 + 1;
+
+ if (i_make_short_mark > 0) and
+ (i_s_k_chg_index_wk - i_make_short_mark > 0) then i_make_short_mark := 0;
+
+ i_tmp_1 := ff_check_short_250(i_s_k_chg_index_wk);
+
+ i_line_no_001 := i_line_no_001 + 1;
+
+
+ i_tmp_2 := ff_check_short_30(i_s_k_chg_index_wk);
+
+ i_line_no_001 := i_line_no_001 + 1;
+
+ i_tmp_3 := ff_check_short_120(i_s_k_chg_index_wk);
+
+ i_line_no_001 := i_line_no_001 + 1;
+
+ //for No MA120 Short
+ i_tmp_3 := 1;
+
+ i_tmp_4 := ff_pass3_short_120(i_s_k_chg_index_wk);
+
+ i_line_no_001 := i_line_no_001 + 1;
+
+ i_tmp_7 := ff_make_mbm_short(i_s_k_chg_index_wk);
+
+ i_line_no_001 := i_line_no_001 + 1;
+
+ ff_check_short_1(i_s_k_chg_index_wk - 1);
+
+ i_tmp := ff_check_short_1_ex(i_s_k_chg_index_wk - 1);
+
+ if i_mbm_only = 1 then
+ begin
+ i_tmp_1 := 1;
+ i_tmp_2 := 1;
+ i_tmp_3 := 1;
+ i_tmp_4 := 1;
+ i_tmp := 1;
+ i_tmp_7 := 1;
+ end;
+
+ i_tmp_9 := ff_get_ma600_mark(i_s_k_chg_index_wk - 1);
+ if (i_tmp_9 > 0) then
+ begin
+ if (i_short_act_flag > 0) then
+ begin
+ i_short_act_flag := i_short_act_flag - 1;
+ i_tmp_7 := 0;
+ W_Log('main_loop', as_k_chg[i_s_k_chg_index_wk].i_date, i_wk_log, 'i_tmp_9,make a short position!');
+ end;
+ end;
+
+ i_line_no_001 := i_line_no_001 + 1;
+
+ if ((i_tmp = 0) or (i_tmp_1 = 0) or (i_tmp_2 = 0) or (i_tmp_3 = 0) or (i_tmp_4 = 0) or
+ ((i_tmp_7 = 0) and (i_s_k_chg_index_wk - i_short_stop_index > 28))) then
+ begin
+ if (i_no_trade = 0) then if ((i_only_short = 1) or (i_long_short_ctrl = 0)) then
+ begin
+ if i_B_S_Flag < 0 then
+ begin
+ s_tmp := FloatToStrF(f_last_price_wk - 2.0, ffFixed, 8, 2);
+ if (i_short_mark = 0) and (i_make_short_mark = 0) then
+ begin
+ ff_order_ex(pc_what_wk, PChar(s_tmp), PChar(IntToStr(i_F)), '2', '1');
+
+ W_Log('main_loop', as_k_chg[i_s_k_chg_index_wk].i_date, i_wk_log, '8,make a short position!');
+
+ Sleep(2000);
+ ff_get_qty();
+ i_make_short_mark := i_s_k_chg_index_wk;
+ end;
+ end;
+ end;
+ end;
+
+ i_line_no_001 := i_line_no_001 + 1;
+ ff_4ma_make_mbm_short(i_s_k_chg_index_wk);
+ i_line_no_001 := i_line_no_001 + 1;
+ ff_4ma_make_mbm_long(i_s_k_chg_index_wk);
+ i_line_no_001 := i_line_no_001 + 1;
+
+ i_tmp_7 := ff_make_mbm_long(i_s_k_chg_index_wk);
+ i_line_no_001 := i_line_no_001 + 1;
+
+ i_tmp_6 := ff_long_pass_3_ex(i_s_k_chg_index_wk);
+ i_line_no_001 := i_line_no_001 + 1;
+
+ i_tmp_4 := ff_make_long_MA30(i_s_k_chg_index_wk);
+ i_line_no_001 := i_line_no_001 + 1;
+ i_tmp_4 := 1;
+
+ i_tmp_5 := ff_make_long_MA60(i_s_k_chg_index_wk);
+ i_line_no_001 := i_line_no_001 + 1;
+ i_tmp_5 := 1;
+ i_tmp_5 := ff_make_long_MA250(i_s_k_chg_index_wk);
+ i_line_no_001 := i_line_no_001 + 1;
+ //i_tmp_5 :=1;
+
+ i_tmp_3 := ff_check_long_pass_3(i_s_k_chg_index_wk);
+ i_line_no_001 := i_line_no_001 + 1;
+
+ ff_check_BB_100(i_s_k_chg_index_wk, 3);
+ i_line_no_001 := i_line_no_001 + 1;
+ i_tmp_2 := ff_check_BB_100_ex(i_s_k_chg_index_wk);
+ i_line_no_001 := i_line_no_001 + 1;
+
+ ff_check_MA120_BB(i_s_k_chg_index_wk, 3);
+ i_line_no_001 := i_line_no_001 + 1;
+ i_tmp_1 := ff_check_MA120_BB_ex(i_s_k_chg_index_wk);
+ i_line_no_001 := i_line_no_001 + 1;
+
+ if (i_make_long_mark > 0) and
+ (i_s_k_chg_index_wk - i_make_long_mark > 0) then i_make_long_mark := 0;
+
+ ff_check_rsi_w20(i_s_k_chg_index_wk - 1);
+ i_line_no_001 := i_line_no_001 + 1;
+ i_tmp := ff_check_rsi_w20_ex(i_s_k_chg_index_wk);
+ i_line_no_001 := i_line_no_001 + 1;
+
+ if i_mbm_only = 1 then
+ begin
+ i_tmp_1 := 1;
+ i_tmp_2 := 1;
+ i_tmp_3 := 1;
+ i_tmp_4 := 1;
+ i_tmp_5 := 1;
+ i_tmp_6 := 1;
+ i_tmp_7 := 1;
+ i_tmp := 1;
+ end;
+
+ i_tmp_9 := ff_get_ma600_mark_long(i_s_k_chg_index_wk - 1);
+ if (i_tmp_9 > 0) then
+ begin
+ if (i_long_act_flag > 0) then
+ begin
+ i_long_act_flag := i_long_act_flag - 1;
+ i_tmp_7 := 0;
+ W_Log('main_loop', as_k_chg[i_s_k_chg_index_wk].i_date, i_wk_log, 'i_tmp_9,make a long position!');
+ end
+ end;
+
+ i_line_no_001 := i_line_no_001 + 1;
+
+ if ((i_tmp = 0) or (i_tmp_1 = 0) or (i_tmp_2 = 0) or (i_tmp_3 = 0) or (i_tmp_4 = 0) or (i_tmp_5 = 0) or (i_tmp_6 = 0) or (i_tmp_7 = 0)) then
+ begin
+ if (i_no_trade = 0) then if ((i_only_long = 1) or (i_long_short_ctrl = 0)) then
+ begin
+ if (i_B_S_Flag > 0) or ((i_s_k_chg_index_wk - i_short_stop_index < 28) and (i_tmp = 0)) or
+ (i_tmp_3 = 0) or (i_tmp_4 = 0) or (i_tmp_5 = 0) or (i_tmp_6 = 0) or (i_tmp_2 = 0) or
+ (i_tmp_1 = 0) or (i_tmp_7 = 0) then
+ begin
+ s_tmp := FloatToStrF(f_last_price_wk + 1, ffFixed, 8, 2);
+ if (i_got_it_mark = 0) and (i_make_long_mark = 0) then
+ begin
+ ff_order_ex(pc_what_wk, PChar(s_tmp), PChar(IntToStr(i_F)), '1', '1');
+
+ W_Log('main_loop', as_k_chg[i_s_k_chg_index_wk].i_date, i_wk_log, '8,make a long position!');
+
+ Sleep(2000);
+ ff_get_qty();
+ i_make_long_mark := i_s_k_chg_index_wk;
+ end;
+ end;
+ end;
+ end;
+ i_line_no_001 := i_line_no_001 + 1;
+
+ //for short Stop
+ if (i_short_mark > 0) and (f_last_price_wk > (f_short_price + f_rsi_cut_short)) then
+ begin
+ i_stop_short_count := i_stop_short_count + 1;
+ if (i_stop_short_count > 1) then
+ begin
+ i_stop_short_count := 0;
+
+ //for OPEN, NO CUT!
+ s_tmp := FormatDateTime('hhnn', Now);
+ if ((s_tmp <> '0915') and (s_tmp <> '0916') and (s_tmp <> '0916') and (s_tmp <> '0916') and
+ (s_tmp <> '915') and (s_tmp <> '916') and (s_tmp <> '916') and (s_tmp <> '916')) then
+ begin
+
+ s_tmp := FloatToStrF(f_last_price_wk + 2.0, ffFixed, 8, 2);
+ ff_entrust_no(pc_what_wk);
+ ff_cancel_entrust_no();
+ ff_order_ex(pc_what_wk, PChar(s_tmp), PChar(IntToStr(i_short_mark)), m_mairu, m_pingcang);
+ i_stop_short_count := 0;
+
+ W_Log('main_loop', as_k_chg[i_s_k_chg_index_wk].i_date, i_wk_log, '99,Cut Short!');
+
+ //for make a long
+ ff_order_ex(pc_what_wk, PChar(s_tmp), PChar(IntToStr(i_short_mark)), m_mairu, m_pingcang);
+
+ if (as_k_chg[i_s_k_chg_index_wk].i_close > as_k_chg_ma_rsi[i_s_k_chg_index_wk - 1].ai_ma[6]) and
+ (as_k_chg[i_s_k_chg_index_wk].i_close > as_k_chg_ma_rsi[i_s_k_chg_index_wk - 1].ai_ma[3]) and
+ (as_k_chg[i_s_k_chg_index_wk].i_close < as_k_chg_ma_rsi[i_s_k_chg_index_wk - 1].ai_ma[8]) and
+ (as_k_chg[i_s_k_chg_index_wk].i_close > as_k_chg_ma_rsi[i_s_k_chg_index_wk - 1].ai_ma[5]) then
+ begin
+ ff_order_ex(pc_what_wk, PChar(s_tmp), PChar(IntToStr(i_short_mark)), m_mairu, m_kaicang);
+ W_Log('main_loop', as_k_chg[i_s_k_chg_index_wk].i_date, i_wk_log, '88,Make Long!');
+ end;
+
+ Sleep(2000);
+ ff_get_qty();
+
+ end;
+ end;
+ end
+ else if (i_short_mark > 0) and (f_short_price > f_last_price_wk + f_rsi_stop_short) then
+ begin
+ i_stop_short_count := i_stop_short_count + 1;
+
+ if (i_M120 > 0) and
+ ((Integer(as_k_chg_ma_rsi[i_s_k_chg_index_wk - 1].ai_ma[6]) + i_M120) <
+ (Integer(as_k_chg_ma_rsi[i_s_k_chg_index_wk - 2].ai_ma[6]))) then
+ begin
+ i_M120_stop := 888;
+ end
+ else if i_M120 > 0 then
+ begin
+ i_M120_stop := 8;
+ end
+ else i_M120_stop := 0;
+
+ if (i_M30 > 0) and
+ ((Integer(as_k_chg_ma_rsi[i_s_k_chg_index_wk - 1].ai_ma[3]) + i_M30) <
+ (Integer(as_k_chg_ma_rsi[i_s_k_chg_index_wk - 2].ai_ma[3]))) then
+ begin
+ i_M30_stop := 888;
+ end
+ else if i_M30 > 0 then
+ begin
+ i_M30_stop := 8;
+ end
+ else i_M30_stop := 0;
+
+ if (i_M120_stop = 888) or (i_M30_stop = 888) or
+ ((i_M30_stop = 0) and (i_M120_stop = 0)) then
+ begin
+
+ //M30 delta check
+ //if ( (Integer(as_k_chg_ma_rsi[ i_s_k_chg_index_wk-1 ].ai_ma[3]) + i_M30 ) >
+ // Integer(as_k_chg_ma_rsi[ i_s_k_chg_index_wk-2 ].ai_ma[3]) ) Then
+ //begin
+
+ if (i_stop_short_count > 1) then
+ begin
+ s_tmp := FloatToStrF(f_last_price_wk + 2.0, ffFixed, 8, 2);
+ ff_entrust_no(pc_what_wk);
+ ff_cancel_entrust_no();
+ ff_order_ex(pc_what_wk, PChar(s_tmp), PChar(IntToStr(i_short_mark)), m_mairu, m_pingcang);
+ W_Log('main_loop', as_k_chg[i_s_k_chg_index_wk].i_date, i_wk_log, '888,Stop Short Profit!');
+ i_stop_short_count := 0;
+
+ i_short_stop_index := i_s_k_chg_index_wk;
+
+ Sleep(2000);
+ ff_get_qty();
+ end;
+
+ end;
+ end;
+
+ i_line_no_001 := i_line_no_001 + 1;
+
+ //for Stop
+ if (i_got_it_mark > 0) and (f_last_price_wk - f_business_price > f_rsi_stop_long) then
+ begin
+
+ i_stop_check_count := i_stop_check_count + 1;
+
+ if (i_M120 > 0) and
+ (Integer(as_k_chg_ma_rsi[i_s_k_chg_index_wk - 1].ai_ma[6]) <
+ (Integer(as_k_chg_ma_rsi[i_s_k_chg_index_wk - 2].ai_ma[6]) + i_M120)) then
+ begin
+ i_M120_stop := 888;
+ end
+ else if i_M120 > 0 then
+ begin
+ i_M120_stop := 8;
+ end
+ else i_M120_stop := 0;
+
+ if (i_M30 > 0) and
+ (Integer(as_k_chg_ma_rsi[i_s_k_chg_index_wk - 1].ai_ma[3]) <
+ (Integer(as_k_chg_ma_rsi[i_s_k_chg_index_wk - 2].ai_ma[3]) + i_M30)) then
+ begin
+ i_M30_stop := 888;
+ end
+ else if i_M30 > 0 then
+ begin
+ i_M30_stop := 8;
+ end
+ else i_M30_stop := 0;
+
+ if (i_M120_stop = 888) or (i_M30_stop = 888) or
+ ((i_M30_stop = 0) and (i_M120_stop = 0)) then
+ begin
+
+ if (i_stop_check_count > 1) then
+ begin
+ s_tmp := FloatToStrF(f_last_price_wk - 1.0, ffFixed, 8, 2);
+ ff_entrust_no(pc_what_wk);
+ ff_cancel_entrust_no();
+ ff_order_ex(pc_what_wk, PChar(s_tmp), PChar(IntToStr(i_got_it_mark)), m_maichu, m_pingcang);
+ i_stop_check_count := 0;
+ W_Log('main_loop', as_k_chg[i_s_k_chg_index_wk].i_date, i_wk_log, '888,Stop Long Profit!');
+
+ i_long_stop_index := i_s_k_chg_index_wk;
+
+ Sleep(2000);
+ ff_get_qty();
+ end;
+
+ end;
+
+ end
+ else if (i_got_it_mark > 0) and (f_business_price - f_last_price_wk > f_rsi_cut_long) then
+ begin
+
+ s_tmp := FormatDateTime('hhnn', Now);
+ if ((s_tmp <> '0915') and (s_tmp <> '0916') and (s_tmp <> '0917') and (s_tmp <> '0918') and
+ (s_tmp <> '915') and (s_tmp <> '916') and (s_tmp <> '917') and (s_tmp <> '918')) then
+ begin
+
+ i_stop_check_count := i_stop_check_count + 1;
+ if (i_stop_check_count > 1) then
+ begin
+ i_stop_check_count := 0;
+ s_tmp := FloatToStrF(f_last_price_wk - 2.0, ffFixed, 8, 2);
+ ff_entrust_no(pc_what_wk);
+ ff_cancel_entrust_no();
+ ff_order_ex(pc_what_wk, PChar(s_tmp), PChar(IntToStr(i_got_it_mark)), m_maichu, m_pingcang);
+ W_Log('main_loop', as_k_chg[i_s_k_chg_index_wk].i_date, i_wk_log, '999,Cut loss!');
+ i_stop_check_count := 0;
+ Sleep(2000);
+ ff_get_qty();
+ end;
+
+ end;
+ end;
+
+end;
+
+function do_beep(): Boolean;
+begin
+ Result := False;
+ if i_beeping = 1 then Exit;
+ i_beeping := 1;
+ g_hEvent := CreateEvent(nil, TRUE, FALSE, nil);
+ //Application.ProcessMessages;
+ th_beep := Tth_beep.Create(false);
+ th_beep.i_do_main_loop_mark := 0;
+
+ th_main_loop := Tth_beep.Create(false);
+ th_main_loop.i_do_main_loop_mark := 888;
+
+ Result := True;
+end;
+
+function ff_stop_do_beep(): Boolean;
+begin
+ Result := True;
+ if i_beeping = 0 then Exit;
+ th_main_loop.Terminate;
+ th_beep.Terminate;
+ sleep(3000);
+ //for not need
+ //th_main_loop.Destroy;
+ //th_beep.Destroy;
+ i_beeping := 0;
+end;
+
+function ff_rsi_w20_init(): Boolean;
+var
+ pc_tmp: PChar;
+ s_tmp: string;
+ i_loop: Integer;
+ s_tmp1: string;
+
+begin
+
+ FillChar(as_fc_data, sizeof(as_fc_data), 0);
+
+ FillChar(c_batch_no, SizeOf(c_batch_no), 0);
+ FillChar(c_entrust_no, SizeOf(c_entrust_no), 0);
+
+ s_tmp := FormatDateTime('yyyymmddhhnnss', Now);
+
+ pc_tmp := FF_ffconf(m_ff_action_ini, 'LONG', 'OPEN_TIME');
+ if pc_tmp <> nil then pc_open_long_time := pc_tmp;
+
+ s_tmp1 := pc_open_long_time;
+ if (pc_open_long_time <> nil) and (StrLen(pc_open_long_time) = StrLen(PChar(s_tmp))) then
+ begin
+ if (s_tmp >= s_tmp1) then i_open_long_timer := -888 else i_open_long_timer := 0;
+ end;
+
+ pc_tmp := FF_ffconf(m_ff_action_ini, 'SHORT', 'OPEN_TIME');
+ if pc_tmp <> nil then pc_open_short_time := pc_tmp;
+
+ s_tmp1 := pc_open_short_time;
+ if (pc_open_short_time <> nil) and (StrLen(pc_open_short_time) = StrLen(PChar(s_tmp))) then
+ begin
+ if (s_tmp >= s_tmp1) then i_open_short_timer := -888 else i_open_short_timer := 0;
+ end;
+
+ pc_tmp := FF_ffconf(m_ff_action_ini, 'LONG', 'CLOSE_TIME');
+ if pc_tmp <> nil then pc_close_long_time := pc_tmp;
+
+ s_tmp1 := pc_close_long_time;
+ if (pc_close_long_time <> nil) and (StrLen(pc_close_long_time) = StrLen(PChar(s_tmp))) then
+ begin
+ if (s_tmp >= s_tmp1) then i_close_long_timer := -888 else i_close_long_timer := 0;
+ end;
+
+ pc_tmp := FF_ffconf(m_ff_action_ini, 'SHORT', 'CLOSE_TIME');
+ if pc_tmp <> nil then pc_close_short_time := pc_tmp;
+
+ s_tmp1 := pc_close_short_time;
+ if (pc_close_long_time <> nil) and (StrLen(pc_close_short_time) = StrLen(PChar(s_tmp))) then
+ begin
+ if (s_tmp >= s_tmp1) then i_close_short_timer := -888 else i_close_short_timer := 0;
+ end;
+
+ for i_loop := 0 to 78 do
+ begin
+ s_tmp := 'FC.' + IntToStr(i_loop);
+ pc_tmp := FF_ffconf(m_ff_local_ini, 'FC', PChar(s_tmp));
+ i_fc_count := i_loop;
+ if pc_tmp <> nil then as_fc_data[i_loop].pc_username := pc_tmp else Break;
+
+ s_tmp := 'FCPWD.' + IntToStr(i_loop);
+ pc_tmp := FF_ffconf(m_ff_local_ini, 'FC', PChar(s_tmp));
+ i_fc_count := i_loop;
+ if pc_tmp <> nil then as_fc_data[i_loop].pc_fcpwd := pc_tmp;
+
+ s_tmp := 'NAME.' + IntToStr(i_loop);
+ pc_tmp := FF_ffconf(m_ff_local_ini, 'FC', PChar(s_tmp));
+ i_fc_count := i_loop;
+ if pc_tmp <> nil then as_fc_data[i_loop].pc_xxx_name := pc_tmp else Break;
+
+ s_tmp := 'VOL.' + IntToStr(i_loop);
+ pc_tmp := FF_ffconf(m_ff_local_ini, 'FC', PChar(s_tmp));
+ i_fc_count := i_loop;
+ if pc_tmp <> nil then as_fc_data[i_loop].i_VOL := StrToInt(pc_tmp) else Break;
+
+ s_tmp := 'LONG_MAX.' + IntToStr(i_loop);
+ pc_tmp := FF_ffconf(m_ff_local_ini, 'FC', PChar(s_tmp));
+ i_fc_count := i_loop;
+ if pc_tmp <> nil then as_fc_data[i_loop].i_long_max := StrToInt(pc_tmp) else Break;
+
+ s_tmp := 'SHORT_MAX.' + IntToStr(i_loop);
+ pc_tmp := FF_ffconf(m_ff_local_ini, 'FC', PChar(s_tmp));
+ i_fc_count := i_loop;
+ if pc_tmp <> nil then as_fc_data[i_loop].i_short_max := StrToInt(pc_tmp) else Break;
+
+ end;
+
+ Result := True;
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini, 'W20', 'A_min');
+ if pc_tmp <> nil then i_rsi_A := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini, 'W20', 'B_min');
+ if pc_tmp <> nil then i_rsi_B := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini, 'W20', 'C_min');
+ if pc_tmp <> nil then i_rsi_C := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini, 'W20', 'AB_max');
+ if pc_tmp <> nil then i_rsi_AB := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini, 'W20', 'BC_max');
+ if pc_tmp <> nil then i_rsi_BC := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini, 'W20', 'IA_min');
+ if pc_tmp <> nil then i_rsi_IA_min := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini, 'W20', 'IA_max');
+ if pc_tmp <> nil then i_rsi_IA_max := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini, 'W20', 'CUT');
+ if pc_tmp <> nil then f_rsi_cut := StrToFloat(pc_tmp);
+
+ //f_mbm_cut_all :=f_rsi_cut*3;
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini, 'W20', 'STOP');
+ if pc_tmp <> nil then f_rsi_stop := StrToFloat(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini, 'W20', 'ADD');
+ if pc_tmp <> nil then f_rsi_add := StrToFloat(pc_tmp);
+
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini, 'W20', 'F');
+ if pc_tmp <> nil then i_F := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini, 'W20', 'S');
+ if pc_tmp <> nil then i_S := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini, 'W20', 'T');
+ if pc_tmp <> nil then i_T := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini, 'W20', 'A');
+ if pc_tmp <> nil then i_A := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini, 'W20', 'M30');
+ if pc_tmp <> nil then i_M30 := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini, 'W20', 'M120');
+ if pc_tmp <> nil then i_M120 := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini, 'W20', 'BOX_Y');
+ if pc_tmp <> nil then i_BOX_Y := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_local_ini, 'What', 'KONLY');
+ if pc_tmp <> nil then i_make_k_only := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_local_ini, 'What', 'LS_CTRL');
+ if pc_tmp <> nil then i_long_short_ctrl := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_local_ini, 'What', 'CODE');
+ if pc_tmp <> nil then pc_what_wk := pc_tmp;
+
+ pc_tmp := FF_ffconf(m_ff_local_ini, 'What', 'MBM_ONLY');
+ if pc_tmp <> nil then i_mbm_only := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_local_ini, 'What', 'LONG_ONLY');
+ if pc_tmp <> nil then i_only_long := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_local_ini, 'What', 'SHORT_ONLY');
+ if pc_tmp <> nil then i_only_short := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_ma120_ini, 'M120BB', 'BOX_Y');
+ if pc_tmp <> nil then i_BB_BOX_Y := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_ma120_ini, 'M120BB', 'BOX_X');
+ if pc_tmp <> nil then i_BB_BOX_X := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_bb100_ini, 'BB_100', 'BOX_X');
+ if pc_tmp <> nil then i_BB_100_BOX_X := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_bb100_ini, 'BB_100', 'BOX_Y');
+ if pc_tmp <> nil then i_BB_100_BOX_Y := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_m30_short_ini, 'M30', 'BOX_X');
+ if pc_tmp <> nil then i_M30_short_BOX_X := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_m30_short_ini, 'M30', 'BOX_Y');
+ if pc_tmp <> nil then i_M30_short_BOX_Y := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_short_1_ini, 'Main', 'ACT');
+ if pc_tmp <> nil then i_act_short := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini, 'W20', 'ACT');
+ if pc_tmp <> nil then i_act_rsi := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini, 'W20', 'ADD_FLOSS_MAX');
+ if pc_tmp <> nil then i_ADD_FLOSS_MAX := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_ma120_ini, 'M120BB', 'ACT');
+ if pc_tmp <> nil then i_act_m120 := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_bb100_ini, 'BB_100', 'ACT');
+ if pc_tmp <> nil then i_act_bb_100 := StrToInt(pc_tmp);
+
+ f_rsi_stop_long := f_rsi_stop;
+ f_rsi_stop_short := f_rsi_stop;
+
+ pc_tmp := FF_ffconf(m_ff_local_ini, 'What', 'OPEN_DELTA');
+ if pc_tmp <> nil then i_open_delta := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_local_ini, 'What', 'CLOSE_DELTA');
+ if pc_tmp <> nil then i_close_delta := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_local_ini, 'What', 'STP_DELTA');
+ if pc_tmp <> nil then i_stp_delta := StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_local_ini, 'What', 'CHK_POWER_VOL');
+ if pc_tmp <> nil then i_chk_power_vol_set := StrToInt(pc_tmp);
+
+end;
+
+function ff_do_main_loop(): Integer;
+var
+ s_tmp_log: string;
+begin
+
+ i_lock_for_main_loop := 1;
+
+ Result := 0;
+
+ i_loop_count_001 := i_loop_count_001 + 1;
+ if (i_loop_count_001 > 88888888) then i_loop_count_001 := 0;
+
+ try
+
+ if (i_loop_count_001 mod 100 = 0) then ff_get_qty();
+
+ if (i_ff_get_qty_88 > 0) then
+ begin
+ i_ff_get_qty_88 := i_ff_get_qty_88 - 2;
+ ff_get_qty();
+ end;
+
+ except
+ on E: Exception do
+ begin
+ //Assert(false,s_tmp_log);
+ //W_Log('ff_do_main_loop ff_get_qty',19,999,PChar(s_tmp_log));
+ W_Log('ff_do_main_loop ff_get_qty', 19, 999, PChar(E.Message));
+ ExitProcess(999);
+ end;
+ end;
+
+ try
+ ff_main_wk_loop();
+ except
+ on E: Exception do
+ begin
+ //Assert(false,s_tmp_log);
+ //W_Log('ff_do_main_loop ff_main_wk_loop',i_line_no_001,999,PChar(s_tmp_log));
+ W_Log('ff_do_main_loop ff_main_wk_loop', i_line_no_001, 999, PChar(E.Message));
+ ExitProcess(999);
+ end;
+ end;
+
+ i_lock_for_main_loop := 0;
+
+end;
+
+
+end.
diff --git a/uft_robot/robot/src/ff_qty.dfm b/uft_robot/robot/src/ff_qty.dfm
new file mode 100644
index 00000000..f8324299
--- /dev/null
+++ b/uft_robot/robot/src/ff_qty.dfm
@@ -0,0 +1,25 @@
+object fm_x: Tfm_x
+ Left = 0
+ Top = 0
+ ClientHeight = 300
+ ClientWidth = 635
+ Color = clBlack
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clWindowText
+ Font.Height = -11
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ OldCreateOrder = False
+ PixelsPerInch = 96
+ TextHeight = 13
+ object StringGrid1: TStringGrid
+ Left = 0
+ Top = 0
+ Width = 641
+ Height = 297
+ Color = clBlack
+ FixedCols = 0
+ FixedRows = 0
+ TabOrder = 0
+ end
+end
diff --git a/uft_robot/robot/src/ff_qty.pas b/uft_robot/robot/src/ff_qty.pas
new file mode 100644
index 00000000..c2554dcf
--- /dev/null
+++ b/uft_robot/robot/src/ff_qty.pas
@@ -0,0 +1,25 @@
+unit ff_qty;
+
+interface
+
+uses
+ Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+ Dialogs, Grids;
+
+type
+ Tfm_x = class(TForm)
+ StringGrid1: TStringGrid;
+ private
+ { Private declarations }
+ public
+ { Public declarations }
+ end;
+
+var
+ fm_x: Tfm_x;
+
+implementation
+
+{$R *.dfm}
+
+end.
diff --git a/uft_robot/robot/src/ff_x.dcu b/uft_robot/robot/src/ff_x.dcu
new file mode 100644
index 00000000..ac5e8303
Binary files /dev/null and b/uft_robot/robot/src/ff_x.dcu differ
diff --git a/uft_robot/robot/src/ff_x.dfm b/uft_robot/robot/src/ff_x.dfm
new file mode 100644
index 00000000..f8324299
--- /dev/null
+++ b/uft_robot/robot/src/ff_x.dfm
@@ -0,0 +1,25 @@
+object fm_x: Tfm_x
+ Left = 0
+ Top = 0
+ ClientHeight = 300
+ ClientWidth = 635
+ Color = clBlack
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clWindowText
+ Font.Height = -11
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ OldCreateOrder = False
+ PixelsPerInch = 96
+ TextHeight = 13
+ object StringGrid1: TStringGrid
+ Left = 0
+ Top = 0
+ Width = 641
+ Height = 297
+ Color = clBlack
+ FixedCols = 0
+ FixedRows = 0
+ TabOrder = 0
+ end
+end
diff --git a/uft_robot/robot/src/ff_x.pas b/uft_robot/robot/src/ff_x.pas
new file mode 100644
index 00000000..c0223134
--- /dev/null
+++ b/uft_robot/robot/src/ff_x.pas
@@ -0,0 +1,25 @@
+unit ff_x;
+
+interface
+
+uses
+ Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+ Dialogs, Grids;
+
+type
+ Tfm_x = class(TForm)
+ StringGrid1: TStringGrid;
+ private
+ { Private declarations }
+ public
+ { Public declarations }
+ end;
+
+var
+ fm_x: Tfm_x;
+
+implementation
+
+{$R *.dfm}
+
+end.
diff --git a/uft_robot/robot/src/fm_main.dcu b/uft_robot/robot/src/fm_main.dcu
new file mode 100644
index 00000000..0d0e0508
Binary files /dev/null and b/uft_robot/robot/src/fm_main.dcu differ
diff --git a/uft_robot/robot/src/fm_main.ddp b/uft_robot/robot/src/fm_main.ddp
new file mode 100644
index 00000000..4370276c
Binary files /dev/null and b/uft_robot/robot/src/fm_main.ddp differ
diff --git a/uft_robot/robot/src/fm_main.dfm b/uft_robot/robot/src/fm_main.dfm
new file mode 100644
index 00000000..264867f3
--- /dev/null
+++ b/uft_robot/robot/src/fm_main.dfm
@@ -0,0 +1,790 @@
+object MAINFORM: TMAINFORM
+ Left = 10
+ Top = 27
+ Width = 765
+ Height = 912
+ Caption = 'FF_300M'
+ Color = clBlack
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clLime
+ Font.Height = -21
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ Menu = MainMenu1
+ OldCreateOrder = False
+ OnCreate = FormCreate
+ OnDestroy = FormDestroy
+ PixelsPerInch = 96
+ TextHeight = 25
+ object Label1: TLabel
+ Left = 131
+ Top = 39
+ Width = 78
+ Height = 24
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clRed
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label2: TLabel
+ Left = 466
+ Top = 39
+ Width = 78
+ Height = 24
+ Alignment = taRightJustify
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clFuchsia
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label3: TLabel
+ Left = 424
+ Top = 323
+ Width = 78
+ Height = 24
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clFuchsia
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label4: TLabel
+ Left = 611
+ Top = 68
+ Width = 78
+ Height = 24
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clFuchsia
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label5: TLabel
+ Left = 131
+ Top = 69
+ Width = 78
+ Height = 24
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label6: TLabel
+ Left = 466
+ Top = 69
+ Width = 78
+ Height = 24
+ Alignment = taRightJustify
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label7: TLabel
+ Left = 136
+ Top = 323
+ Width = 78
+ Height = 24
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clFuchsia
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label8: TLabel
+ Left = 131
+ Top = 110
+ Width = 104
+ Height = 24
+ Caption = ' '
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clRed
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label9: TLabel
+ Left = 131
+ Top = 160
+ Width = 104
+ Height = 24
+ Caption = ' '
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label10: TLabel
+ Left = 461
+ Top = 110
+ Width = 78
+ Height = 24
+ Alignment = taRightJustify
+ Caption = ' '
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clFuchsia
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label11: TLabel
+ Left = 461
+ Top = 160
+ Width = 78
+ Height = 24
+ Alignment = taRightJustify
+ Caption = ' '
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label12: TLabel
+ Left = 3
+ Top = 68
+ Width = 78
+ Height = 24
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clFuchsia
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label13: TLabel
+ Left = 268
+ Top = 323
+ Width = 78
+ Height = 24
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clFuchsia
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label14: TLabel
+ Left = 520
+ Top = 323
+ Width = 78
+ Height = 24
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clFuchsia
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label15: TLabel
+ Left = 569
+ Top = 104
+ Width = 13
+ Height = 24
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label16: TLabel
+ Left = 569
+ Top = 160
+ Width = 13
+ Height = 24
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label_Vol: TLabel
+ Left = 388
+ Top = 8
+ Width = 13
+ Height = 24
+ Alignment = taRightJustify
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label_long_stp: TLabel
+ Left = 424
+ Top = 110
+ Width = 13
+ Height = 24
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label_short_stp: TLabel
+ Left = 424
+ Top = 160
+ Width = 13
+ Height = 24
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label_up_power: TLabel
+ Left = 126
+ Top = 221
+ Width = 78
+ Height = 24
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clRed
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label_down_power: TLabel
+ Left = 424
+ Top = 221
+ Width = 78
+ Height = 24
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label_status: TLabel
+ Left = 126
+ Top = 281
+ Width = 78
+ Height = 24
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ OnClick = Label_statusClick
+ end
+ object BitBtn1: TBitBtn
+ Left = 8
+ Top = 8
+ Width = 33
+ Height = 25
+ Caption = #24320#22810
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clRed
+ Font.Height = -19
+ Font.Name = #38582#20070
+ Font.Style = []
+ ParentFont = False
+ TabOrder = 1
+ OnClick = BitBtn1Click
+ end
+ object BitBtn2: TBitBtn
+ Left = 8
+ Top = 323
+ Width = 33
+ Height = 24
+ Caption = #28165'0'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clRed
+ Font.Height = -19
+ Font.Name = #38582#20070
+ Font.Style = [fsBold]
+ ParentFont = False
+ TabOrder = 2
+ OnClick = BitBtn2Click
+ end
+ object BitBtn3: TBitBtn
+ Left = 696
+ Top = 8
+ Width = 37
+ Height = 25
+ Caption = #24320#31354
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clBlue
+ Font.Height = -19
+ Font.Name = #38582#20070
+ Font.Style = []
+ ParentFont = False
+ TabOrder = 3
+ OnClick = BitBtn3Click
+ end
+ object BitBtn4: TBitBtn
+ Left = 696
+ Top = 323
+ Width = 37
+ Height = 24
+ Caption = #28165'0'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clBlue
+ Font.Height = -19
+ Font.Name = #38582#20070
+ Font.Style = []
+ ParentFont = False
+ TabOrder = 4
+ OnClick = BitBtn4Click
+ end
+ object F7FC: TBitBtn
+ Left = 368
+ Top = 317
+ Width = 33
+ Height = 30
+ Caption = 'F7'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clFuchsia
+ Font.Height = -29
+ Font.Name = #38582#20070
+ Font.Style = [fsBold]
+ ParentFont = False
+ TabOrder = 0
+ OnClick = NextFCClick
+ end
+ object Edit1: TEdit
+ Left = 611
+ Top = 98
+ Width = 117
+ Height = 37
+ Color = clWindowText
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ ParentFont = False
+ TabOrder = 5
+ OnKeyPress = Edit1KeyPress
+ end
+ object Edit2: TEdit
+ Left = 611
+ Top = 154
+ Width = 117
+ Height = 37
+ Color = clWindowText
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ ParentFont = False
+ TabOrder = 6
+ OnKeyPress = Edit2KeyPress
+ end
+ object BitBtn5: TBitBtn
+ Left = 616
+ Top = 11
+ Width = 42
+ Height = 23
+ Caption = #25764#21333
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clFuchsia
+ Font.Height = -29
+ Font.Name = #38582#20070
+ Font.Style = []
+ ParentFont = False
+ TabOrder = 7
+ OnClick = CancelOrderClick
+ end
+ object Edit_long_stp: TEdit
+ Left = 3
+ Top = 98
+ Width = 117
+ Height = 37
+ Color = clWindowText
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ ParentFont = False
+ TabOrder = 8
+ OnKeyPress = Edit_long_stpKeyPress
+ end
+ object Edit_short_stp: TEdit
+ Left = 3
+ Top = 154
+ Width = 117
+ Height = 37
+ Color = clWindowText
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ ParentFont = False
+ TabOrder = 9
+ OnKeyPress = Edit_short_stpKeyPress
+ end
+ object BitBtn6: TBitBtn
+ Left = 8
+ Top = 251
+ Width = 33
+ Height = 24
+ Caption = '-1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clRed
+ Font.Height = -19
+ Font.Name = #38582#20070
+ Font.Style = [fsBold]
+ ParentFont = False
+ TabOrder = 10
+ OnClick = BitBtn6Click
+ end
+ object BitBtn7: TBitBtn
+ Left = 696
+ Top = 251
+ Width = 37
+ Height = 24
+ Caption = '-1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clBlue
+ Font.Height = -19
+ Font.Name = #38582#20070
+ Font.Style = [fsBold]
+ ParentFont = False
+ TabOrder = 11
+ OnClick = BitBtn7Click
+ end
+ object BitBtn8: TBitBtn
+ Left = 616
+ Top = 323
+ Width = 37
+ Height = 24
+ Caption = #30041'1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clBlue
+ Font.Height = -19
+ Font.Name = #38582#20070
+ Font.Style = []
+ ParentFont = False
+ TabOrder = 12
+ OnClick = BitBtn8Click
+ end
+ object BitBtn9: TBitBtn
+ Left = 92
+ Top = 323
+ Width = 33
+ Height = 24
+ Caption = #30041'1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clRed
+ Font.Height = -19
+ Font.Name = #38582#20070
+ Font.Style = [fsBold]
+ ParentFont = False
+ TabOrder = 13
+ OnClick = BitBtn9Click
+ end
+ object BitBtn10: TBitBtn
+ Left = 92
+ Top = 251
+ Width = 33
+ Height = 24
+ Caption = '0 +'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clRed
+ Font.Height = -19
+ Font.Name = #38582#20070
+ Font.Style = [fsBold]
+ ParentFont = False
+ TabOrder = 14
+ OnClick = BitBtn10Click
+ end
+ object BitBtn11: TBitBtn
+ Left = 616
+ Top = 251
+ Width = 37
+ Height = 24
+ Caption = '0 +'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clBlue
+ Font.Height = -19
+ Font.Name = #38582#20070
+ Font.Style = [fsBold]
+ ParentFont = False
+ TabOrder = 15
+ OnClick = BitBtn11Click
+ end
+ object Edit_vol_chk: TEdit
+ Left = 3
+ Top = 208
+ Width = 117
+ Height = 37
+ Color = clWindowText
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ ParentFont = False
+ TabOrder = 16
+ OnKeyPress = Edit_vol_chkKeyPress
+ end
+ object BitBtn12: TBitBtn
+ Left = 92
+ Top = 8
+ Width = 33
+ Height = 25
+ Caption = 'C'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clRed
+ Font.Height = -19
+ Font.Name = #38582#20070
+ Font.Style = []
+ ParentFont = False
+ TabOrder = 17
+ OnClick = BitBtn12Click
+ end
+ object Edit_open_price: TEdit
+ Left = 616
+ Top = 280
+ Width = 117
+ Height = 37
+ Color = clWindowText
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ ParentFont = False
+ TabOrder = 18
+ Text = '0'
+ OnKeyPress = Edit_open_priceKeyPress
+ end
+ object ff_sg: TStringGrid
+ Left = 8
+ Top = 368
+ Width = 725
+ Height = 473
+ Color = clBlack
+ ColCount = 7
+ FixedCols = 0
+ FixedRows = 0
+ TabOrder = 19
+ OnDrawCell = ff_sgDrawCell
+ end
+ object BitBtn13: TBitBtn
+ Left = 368
+ Top = 244
+ Width = 33
+ Height = 30
+ Caption = 'V'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clFuchsia
+ Font.Height = -29
+ Font.Name = #38582#20070
+ Font.Style = [fsBold]
+ ParentFont = False
+ TabOrder = 20
+ OnClick = BitBtn13Click
+ end
+ object MainMenu1: TMainMenu
+ AutoHotkeys = maManual
+ Left = 667
+ Top = 40
+ object N3: TMenuItem
+ Caption = #25511#21046
+ object N16: TMenuItem
+ Caption = #27490#36194#21152#20493
+ end
+ object N17: TMenuItem
+ Caption = #27490#36194#20943#21322
+ end
+ object N20: TMenuItem
+ Caption = '--------'
+ end
+ object N18: TMenuItem
+ Caption = #27490#25439#21152#20493
+ end
+ object N19: TMenuItem
+ Caption = #27490#25439#20943#21322
+ end
+ object N14: TMenuItem
+ Caption = '--------'
+ end
+ object N15: TMenuItem
+ Caption = #25163#21160#20132#26131
+ OnClick = N15Click
+ end
+ object N27: TMenuItem
+ Caption = #33258#21160#20132#26131
+ OnClick = N27Click
+ end
+ object N33: TMenuItem
+ Caption = '--------'
+ end
+ object ShortOnly: TMenuItem
+ Caption = 'Short Only'
+ OnClick = ShortOnlyClick
+ end
+ object N35: TMenuItem
+ Caption = '--------'
+ end
+ object LongOnly: TMenuItem
+ Caption = 'Long Only'
+ OnClick = LongOnlyClick
+ end
+ object N34: TMenuItem
+ Caption = '--------'
+ end
+ object Konly: TMenuItem
+ Caption = 'K Only'
+ Checked = True
+ OnClick = KonlyClick
+ end
+ object N1: TMenuItem
+ Caption = '--------'
+ end
+ object Only1: TMenuItem
+ Caption = #21333#21457
+ OnClick = Only1Click
+ end
+ object NextFC: TMenuItem
+ Caption = 'Next FC'
+ ShortCut = 118
+ OnClick = NextFCClick
+ end
+ object N2: TMenuItem
+ Caption = '--------'
+ end
+ object N4: TMenuItem
+ Caption = #22810#21333#38145#20179
+ OnClick = N4Click
+ end
+ object N5: TMenuItem
+ Caption = #31354#21333#38145#20179
+ OnClick = N5Click
+ end
+ object N6: TMenuItem
+ Caption = '--------'
+ end
+ object Long_STP: TMenuItem
+ Caption = #22810#21333'STP'
+ OnClick = Long_STPClick
+ end
+ object Short_STP: TMenuItem
+ Caption = #31354#21333'STP'
+ OnClick = Short_STPClick
+ end
+ end
+ object N21: TMenuItem
+ Caption = #20132#26131
+ object N22: TMenuItem
+ Caption = #21334#20215#20316#22810
+ ShortCut = 120
+ OnClick = N22Click
+ end
+ object N23: TMenuItem
+ Caption = #20080#20215#20316#22810
+ ShortCut = 121
+ OnClick = N23Click
+ end
+ object N26: TMenuItem
+ Caption = '--------'
+ end
+ object N24: TMenuItem
+ Caption = #20080#20215#20316#31354
+ ShortCut = 122
+ OnClick = N24Click
+ end
+ object N25: TMenuItem
+ Caption = #21334#20215#20316#31354
+ ShortCut = 123
+ OnClick = N25Click
+ end
+ object N28: TMenuItem
+ Caption = '--------'
+ end
+ object N29: TMenuItem
+ Caption = #22810#22836#24179#20179
+ ShortCut = 114
+ OnClick = N29Click
+ end
+ object N30: TMenuItem
+ Caption = '--------'
+ end
+ object N31: TMenuItem
+ Caption = '--------'
+ end
+ object N32: TMenuItem
+ Caption = #31354#22836#24179#20179
+ ShortCut = 115
+ OnClick = N32Click
+ end
+ object N36: TMenuItem
+ Caption = '--------'
+ end
+ object N38: TMenuItem
+ Caption = '--------'
+ end
+ object N37: TMenuItem
+ Caption = 'ClearLong +1'
+ ShortCut = 116
+ OnClick = N37Click
+ end
+ object N39: TMenuItem
+ Caption = '--------'
+ end
+ object N40: TMenuItem
+ Caption = '--------'
+ end
+ object ClearShort11: TMenuItem
+ Caption = 'ClearShort -1'
+ ShortCut = 117
+ OnClick = ClearShort11Click
+ end
+ object N41: TMenuItem
+ Caption = '--------'
+ end
+ object CancelOrder: TMenuItem
+ Caption = 'CancelOrder'
+ ShortCut = 119
+ OnClick = CancelOrderClick
+ end
+ end
+ end
+ object Timer1: TTimer
+ Interval = 150
+ OnTimer = Timer1Timer
+ Left = 704
+ Top = 40
+ end
+end
diff --git a/uft_robot/robot/src/fm_main.pas b/uft_robot/robot/src/fm_main.pas
new file mode 100644
index 00000000..af1360b9
--- /dev/null
+++ b/uft_robot/robot/src/fm_main.pas
@@ -0,0 +1,701 @@
+unit fm_main;
+
+interface
+
+uses
+ Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+ Dialogs, Menus, StdCtrls, ExtCtrls, Buttons, Grids;
+
+type
+ TMAINFORM = class(TForm)
+ MainMenu1: TMainMenu;
+ N3: TMenuItem;
+ N16: TMenuItem;
+ N17: TMenuItem;
+ N20: TMenuItem;
+ N18: TMenuItem;
+ N19: TMenuItem;
+ N14: TMenuItem;
+ N15: TMenuItem;
+ N27: TMenuItem;
+ N33: TMenuItem;
+ ShortOnly: TMenuItem;
+ N35: TMenuItem;
+ LongOnly: TMenuItem;
+ N34: TMenuItem;
+ Konly: TMenuItem;
+ N21: TMenuItem;
+ N22: TMenuItem;
+ N23: TMenuItem;
+ N26: TMenuItem;
+ N24: TMenuItem;
+ N25: TMenuItem;
+ N28: TMenuItem;
+ N29: TMenuItem;
+ N30: TMenuItem;
+ N31: TMenuItem;
+ N32: TMenuItem;
+ N36: TMenuItem;
+ N38: TMenuItem;
+ N37: TMenuItem;
+ N39: TMenuItem;
+ N40: TMenuItem;
+ ClearShort11: TMenuItem;
+ N41: TMenuItem;
+ CancelOrder: TMenuItem;
+ Label1: TLabel;
+ Label2: TLabel;
+ Label3: TLabel;
+ Label4: TLabel;
+ Label5: TLabel;
+ Label6: TLabel;
+ Label7: TLabel;
+ Label8: TLabel;
+ Label9: TLabel;
+ Label10: TLabel;
+ Label11: TLabel;
+ Timer1: TTimer;
+ N1: TMenuItem;
+ NextFC: TMenuItem;
+ Only1: TMenuItem;
+ Label12: TLabel;
+ Label13: TLabel;
+ Label14: TLabel;
+ BitBtn1: TBitBtn;
+ BitBtn2: TBitBtn;
+ BitBtn3: TBitBtn;
+ BitBtn4: TBitBtn;
+ F7FC: TBitBtn;
+ Label15: TLabel;
+ Label16: TLabel;
+ N2: TMenuItem;
+ N4: TMenuItem;
+ N5: TMenuItem;
+ Edit1: TEdit;
+ Edit2: TEdit;
+ BitBtn5: TBitBtn;
+ Edit_long_stp: TEdit;
+ Edit_short_stp: TEdit;
+ Label_Vol: TLabel;
+ Label_long_stp: TLabel;
+ Label_short_stp: TLabel;
+ N6: TMenuItem;
+ Long_STP: TMenuItem;
+ Short_STP: TMenuItem;
+ BitBtn6: TBitBtn;
+ BitBtn7: TBitBtn;
+ BitBtn8: TBitBtn;
+ BitBtn9: TBitBtn;
+ BitBtn10: TBitBtn;
+ BitBtn11: TBitBtn;
+ Edit_vol_chk: TEdit;
+ Label_up_power: TLabel;
+ Label_down_power: TLabel;
+ BitBtn12: TBitBtn;
+ Edit_open_price: TEdit;
+ Label_status: TLabel;
+ ff_sg: TStringGrid;
+ BitBtn13: TBitBtn;
+ procedure FormCreate(Sender: TObject);
+ procedure FormDestroy(Sender: TObject);
+ procedure LongOnlyClick(Sender: TObject);
+ procedure ShortOnlyClick(Sender: TObject);
+ procedure KonlyClick(Sender: TObject);
+ procedure N15Click(Sender: TObject);
+ procedure N27Click(Sender: TObject);
+ procedure Timer1Timer(Sender: TObject);
+ procedure N22Click(Sender: TObject);
+ procedure N23Click(Sender: TObject);
+ procedure N24Click(Sender: TObject);
+ procedure N25Click(Sender: TObject);
+ procedure N29Click(Sender: TObject);
+ procedure N32Click(Sender: TObject);
+ procedure N37Click(Sender: TObject);
+ procedure ClearShort11Click(Sender: TObject);
+ procedure CancelOrderClick(Sender: TObject);
+ procedure NextFCClick(Sender: TObject);
+ procedure Only1Click(Sender: TObject);
+ procedure BitBtn1Click(Sender: TObject);
+ procedure BitBtn3Click(Sender: TObject);
+ procedure BitBtn2Click(Sender: TObject);
+ procedure BitBtn4Click(Sender: TObject);
+ procedure N4Click(Sender: TObject);
+ procedure N5Click(Sender: TObject);
+ procedure Edit1KeyPress(Sender: TObject; var Key: Char);
+ procedure Edit2KeyPress(Sender: TObject; var Key: Char);
+ procedure Long_STPClick(Sender: TObject);
+ procedure Short_STPClick(Sender: TObject);
+ procedure Edit_long_stpKeyPress(Sender: TObject; var Key: Char);
+ procedure Edit_short_stpKeyPress(Sender: TObject; var Key: Char);
+ procedure BitBtn6Click(Sender: TObject);
+ procedure BitBtn7Click(Sender: TObject);
+ procedure BitBtn8Click(Sender: TObject);
+ procedure BitBtn9Click(Sender: TObject);
+ procedure BitBtn10Click(Sender: TObject);
+ procedure BitBtn11Click(Sender: TObject);
+ procedure BitBtn12Click(Sender: TObject);
+ procedure Label_statusClick(Sender: TObject);
+ procedure Edit_open_priceKeyPress(Sender: TObject; var Key: Char);
+ procedure Edit_vol_chkKeyPress(Sender: TObject; var Key: Char);
+ procedure BitBtn13Click(Sender: TObject);
+ procedure ff_sgDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect;
+ State: TGridDrawState);
+ private
+ { Private declarations }
+ public
+ { Public declarations }
+ end;
+
+//var
+// MAINFORM: TMAINFORM;
+
+implementation
+
+{$R *.dfm}
+
+uses ff_hs_base, s_lib_pas_unit;
+
+procedure TMAINFORM.BitBtn10Click(Sender: TObject);
+begin
+ if f_buy_1 < 1.0 then Exit;
+
+ i_stp_long := 0;
+ Long_STP.Checked := False;
+
+ i_set_stp_long_wk := Round(f_last_price_wk - 0.49 + i_stp_delta);
+ Edit_long_stp.Text := IntToStr(i_set_stp_long_wk);
+
+ Long_STPClick(Sender);
+
+ i_BSK := m_bsk_clear_long;
+ s_caption_8 := ' ';
+ s_caption_9 := ' ';
+ s_caption_10 := ' ';
+ s_caption_11 := ' ';
+end;
+
+procedure TMAINFORM.BitBtn11Click(Sender: TObject);
+begin
+
+ if f_buy_1 < 1.0 then Exit;
+
+ i_stp_short := 0;
+ Short_STP.Checked := False;
+
+ i_set_stp_short_wk := Round(f_last_price_wk + 0.49 - i_stp_delta);
+ Edit_short_stp.Text := IntToStr(i_set_stp_short_wk);
+ Short_STPClick(Sender);
+
+ i_BSK := m_bsk_clear_short;
+ s_caption_8 := ' ';
+ s_caption_9 := ' ';
+ s_caption_10 := ' ';
+ s_caption_11 := ' ';
+
+end;
+
+procedure TMAINFORM.BitBtn12Click(Sender: TObject);
+begin
+ if (i_vol_start = 0) and (i_vol_reset = 0) then
+ begin
+ i_vol_start := 888;
+ i_vol_reset := 0;
+ tdt_vol_0 := Now;
+ end;
+
+ if (i_vol_start = 999) and (i_vol_reset = 0) then
+ begin
+ i_vol_start := 0;
+ i_vol_reset := 0;
+ tdt_vol_0 := Now;
+ end;
+
+end;
+
+procedure TMAINFORM.BitBtn13Click(Sender: TObject);
+begin
+ if i_show_string_grid < 1 then i_show_string_grid := 1 else i_show_string_grid := 0;
+ if i_do_ff_qty_loop = 0 then i_do_ff_qty_loop := 888;
+end;
+
+procedure TMAINFORM.BitBtn1Click(Sender: TObject);
+begin
+ if f_buy_1 < 1.0 then Exit;
+ i_BSK := m_bsk_ask_long;
+end;
+
+procedure TMAINFORM.BitBtn2Click(Sender: TObject);
+begin
+ if f_buy_1 < 1.0 then Exit;
+ i_BSK := m_bsk_clear_long;
+ s_caption_8 := ' ';
+ s_caption_9 := ' ';
+ s_caption_10 := ' ';
+ s_caption_11 := ' ';
+end;
+
+procedure TMAINFORM.BitBtn3Click(Sender: TObject);
+begin
+ if f_buy_1 < 1.0 then Exit;
+ i_BSK := m_bsk_bid_short;
+end;
+
+procedure TMAINFORM.BitBtn4Click(Sender: TObject);
+begin
+ if f_buy_1 < 1.0 then Exit;
+ i_BSK := m_bsk_clear_short;
+ s_caption_8 := ' ';
+ s_caption_9 := ' ';
+ s_caption_10 := ' ';
+ s_caption_11 := ' ';
+end;
+
+procedure TMAINFORM.BitBtn6Click(Sender: TObject);
+begin
+
+ if f_buy_1 < 1.0 then Exit;
+
+ i_clr_long_1_mark := 888;
+ i_BSK := m_bsk_clear_long;
+ s_caption_8 := ' ';
+ s_caption_9 := ' ';
+ s_caption_10 := ' ';
+ s_caption_11 := ' ';
+end;
+
+procedure TMAINFORM.BitBtn7Click(Sender: TObject);
+begin
+ if f_buy_1 < 1.0 then Exit;
+ i_BSK := m_bsk_clear_short;
+ s_caption_8 := ' ';
+ s_caption_9 := ' ';
+ s_caption_10 := ' ';
+ s_caption_11 := ' ';
+ i_clr_short_1_mark := 888;
+end;
+
+procedure TMAINFORM.BitBtn8Click(Sender: TObject);
+begin
+ if f_buy_1 < 1.0 then Exit;
+ i_BSK := m_bsk_clear_short;
+ s_caption_8 := ' ';
+ s_caption_9 := ' ';
+ s_caption_10 := ' ';
+ s_caption_11 := ' ';
+ i_clr_short_to_001_mark := 888;
+end;
+
+procedure TMAINFORM.BitBtn9Click(Sender: TObject);
+begin
+ if f_buy_1 < 1.0 then Exit;
+
+ i_clr_long_to_001_mark := 888;
+ i_BSK := m_bsk_clear_long;
+ s_caption_8 := ' ';
+ s_caption_9 := ' ';
+ s_caption_10 := ' ';
+ s_caption_11 := ' ';
+end;
+
+procedure TMAINFORM.CancelOrderClick(Sender: TObject);
+begin
+ //ClearOrder
+ i_BSK := 9;
+end;
+
+procedure TMAINFORM.ClearShort11Click(Sender: TObject);
+begin
+ //ClearShort -2
+ if f_buy_1 < 1.0 then Exit;
+ i_BSK := 8;
+ //i_ff_get_qty_88 := 188;
+
+end;
+
+procedure TMAINFORM.Edit1KeyPress(Sender: TObject; var Key: Char);
+begin
+ if Key in ['a'..'z'] + ['A'..'Z'] then Key := #0;
+ i_lock_long := 0;
+end;
+
+procedure TMAINFORM.Edit2KeyPress(Sender: TObject; var Key: Char);
+begin
+ if Key in ['a'..'z'] + ['A'..'Z'] then Key := #0;
+ i_lock_short := 0;
+end;
+
+procedure TMAINFORM.Edit_long_stpKeyPress(Sender: TObject; var Key: Char);
+begin
+ if Key in ['a'..'z'] + ['A'..'Z'] then Key := #0;
+ i_stp_long := 0;
+end;
+
+procedure TMAINFORM.Edit_open_priceKeyPress(Sender: TObject; var Key: Char);
+begin
+ if Key in ['a'..'z'] + ['A'..'Z'] then Key := #0;
+end;
+
+procedure TMAINFORM.Edit_short_stpKeyPress(Sender: TObject; var Key: Char);
+begin
+ if Key in ['a'..'z'] + ['A'..'Z'] then Key := #0;
+ i_stp_short := 0;
+end;
+
+procedure TMAINFORM.Edit_vol_chkKeyPress(Sender: TObject; var Key: Char);
+begin
+ if Key in ['a'..'z'] + ['A'..'Z'] then Key := #0;
+end;
+
+procedure TMAINFORM.ff_sgDrawCell(Sender: TObject; ACol, ARow: Integer;
+ Rect: TRect; State: TGridDrawState);
+var
+ iBackColor, iFrontColor: Integer;
+begin
+ case (ACol) of
+ 0: iFrontColor := clYellow;
+ 1: iFrontColor := $00FF00;
+ 2: iFrontColor := clRed;
+ 3: iFrontColor := $FF00FF;
+ 4: iFrontColor := $00FF00;
+ 5: iFrontColor := $FF00FF;
+ 6: iFrontColor := clYellow;
+ end;
+
+ with TStringGrid(Sender) do
+ begin
+ Canvas.Font.Color := iFrontColor;
+ Canvas.FillRect(Rect);
+ Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, Cells[ACol, ARow]);
+ end;
+
+end;
+
+procedure TMAINFORM.FormCreate(Sender: TObject);
+begin
+ FillChar(c_open_price, SizeOf(c_open_price), 0);
+
+ FF_creat_comm_obj();
+
+ //DoubleBuffered:=True;
+ if (i_make_k_only > 0) then
+ begin
+ Konly.Checked := True;
+ end
+ else
+ Konly.Checked := false;
+
+
+ if (i_only_long = 0) then
+ begin
+ LongOnly.Checked := False;
+ end
+ else if (i_only_long = 1) then
+ begin
+ LongOnly.Checked := True;
+ end;
+
+ if (i_only_short = 0) then
+ begin
+ ShortOnly.Checked := False;
+ end
+ else if (i_only_short = 1) then
+ begin
+ ShortOnly.Checked := True;
+ end;
+
+ if (i_only_long = 0) and (i_only_short = 0) then i_long_short_ctrl := 0;
+ if (i_only_long = 1) or (i_only_short = 1) then i_long_short_ctrl := 1;
+
+ Edit_vol_chk.Text := IntToStr(i_chk_power_vol_set);
+
+
+ //ff_sg.Options := Header.Options - [goVertLine, goHorzLine];
+ ff_sg.ColCount := 7;
+ ff_sg.RowCount := i_fc_count + 1;
+
+ ff_sg.Color := clBlack;
+ ff_sg.Cells[0, 0] := 'ÕË ºÅ';
+ ff_sg.Cells[1, 0] := 'Ãû ³Æ';
+ ff_sg.Cells[2, 0] := '¶à ³É ±¾';
+ ff_sg.Cells[3, 0] := '¶àÊýÁ¿';
+ ff_sg.Cells[4, 0] := '¿Õ ³É ±¾';
+ ff_sg.Cells[5, 0] := '¿ÕÊýÁ¿';
+ ff_sg.Cells[6, 0] := '×Ü ×Ê ²ú';
+
+ ff_sg.ColWidths[0] := 100;
+ ff_sg.ColWidths[1] := 100;
+ ff_sg.ColWidths[2] := 100;
+ ff_sg.ColWidths[3] := 70;
+ ff_sg.ColWidths[4] := 100;
+ ff_sg.ColWidths[5] := 70;
+ ff_sg.ColWidths[6] := 120;
+
+end;
+
+procedure TMAINFORM.FormDestroy(Sender: TObject);
+begin
+ FF_release_comm_obj();
+end;
+
+procedure TMAINFORM.KonlyClick(Sender: TObject);
+begin
+ if (i_make_k_only = 0) and (Konly.Checked = false) then
+ begin
+ Konly.Checked := True;
+ i_make_k_only := 128;
+ end
+ else if (i_make_k_only > 0) and (Konly.Checked = true) then
+ begin
+ Konly.Checked := false;
+ i_make_k_only := 0;
+ end;
+end;
+
+procedure TMAINFORM.Label_statusClick(Sender: TObject);
+begin
+ s_caption_status := ' ';
+end;
+
+procedure TMAINFORM.LongOnlyClick(Sender: TObject);
+begin
+ if (i_only_long = 0) and (LongOnly.Checked = false) then
+ begin
+ LongOnly.Checked := True;
+ i_only_long := 1;
+ i_only_short := 0;
+ end
+ else if (i_only_long = 1) and (LongOnly.Checked = true) then
+ begin
+ LongOnly.Checked := false;
+ i_only_long := 0;
+ end;
+
+ if (i_only_short = 0) then
+ begin
+ ShortOnly.Checked := False;
+ end
+ else if (i_only_short = 1) then
+ begin
+ ShortOnly.Checked := True;
+ end;
+
+ if (i_only_long = 0) and (i_only_short = 0) then i_long_short_ctrl := 0;
+ if (i_only_long = 1) or (i_only_short = 1) then i_long_short_ctrl := 1;
+
+end;
+
+procedure TMAINFORM.Long_STPClick(Sender: TObject);
+begin
+ if Long_STP.Checked = True then Long_STP.Checked := False else Long_STP.Checked := True;
+ if Long_STP.Checked = True then s_caption_long_stp := '+' else s_caption_long_stp := ' ';
+ if Long_STP.Checked = True then i_stp_long := 888 else i_stp_long := 0;
+ if Long_STP.Checked = True then i_act_stp_long_mark := 0;
+
+ if i_stp_long = 888 then Long_STP.Checked := True;
+
+ if (StrLen(PChar(Edit_long_stp.Text)) > 0) then i_set_stp_long := StrToInt(Edit_long_stp.Text)
+ else i_set_stp_long := 0;
+
+ if (i_set_stp_long > 9) then
+ begin
+ i_set_stp_long_wk := i_set_stp_long;
+ end
+ else i_set_stp_long_wk := 0;
+end;
+
+
+procedure TMAINFORM.N15Click(Sender: TObject);
+begin
+ i_no_trade := 888;
+
+end;
+
+procedure TMAINFORM.N22Click(Sender: TObject);
+begin
+ if f_sale_1 < 1.0 then Exit;
+ i_BSK := 1;
+ i_ff_get_qty_88 := 88;
+end;
+
+procedure TMAINFORM.N23Click(Sender: TObject);
+begin
+ if f_buy_1 < 1.0 then Exit;
+ i_BSK := 2;
+ i_ff_get_qty_88 := 88;
+end;
+
+procedure TMAINFORM.N24Click(Sender: TObject);
+begin
+ if f_buy_1 < 1.0 then Exit;
+ i_BSK := 3;
+ i_ff_get_qty_88 := 88;
+end;
+
+procedure TMAINFORM.N25Click(Sender: TObject);
+begin
+ if f_sale_1 < 1.0 then Exit;
+ i_BSK := 4;
+ i_ff_get_qty_88 := 88;
+
+end;
+
+procedure TMAINFORM.N27Click(Sender: TObject);
+begin
+ i_no_trade := 0;
+end;
+
+procedure TMAINFORM.N29Click(Sender: TObject);
+begin
+ if f_buy_1 < 1.0 then Exit;
+ i_BSK := 5;
+ s_caption_8 := ' ';
+ s_caption_9 := ' ';
+ s_caption_10 := ' ';
+ s_caption_11 := ' ';
+
+end;
+
+procedure TMAINFORM.N32Click(Sender: TObject);
+begin
+ if f_buy_1 < 1.0 then Exit;
+ i_BSK := 6;
+
+ s_caption_8 := ' ';
+ s_caption_9 := ' ';
+ s_caption_10 := ' ';
+ s_caption_11 := ' ';
+
+end;
+
+procedure TMAINFORM.N37Click(Sender: TObject);
+begin
+ //ClearLong +2
+ if f_buy_1 < 1.0 then Exit;
+ i_BSK := 7;
+ //i_ff_get_qty_88 := 188;
+
+end;
+
+procedure TMAINFORM.N4Click(Sender: TObject);
+begin
+ i_cut_lock_long := 0;
+
+ if N4.Checked = True then N4.Checked := False else N4.Checked := True;
+ if N4.Checked = True then s_caption_15 := 'Ëø' else s_caption_15 := ' ';
+ if N4.Checked = True then i_lock_long := 888 else i_lock_long := 0;
+ if N4.Checked = True then i_cut_lock_long_mark := 0;
+
+ if i_lock_long = 888 then N4.Checked := True;
+
+ if (StrLen(PChar(Edit1.Text)) > 0) then i_set_lock_long := StrToInt(Edit1.Text)
+ else i_set_lock_long := 0;
+
+ if (i_set_lock_long > 9) then
+ begin
+ i_set_lock_long_wk := i_set_lock_long;
+ end
+ else i_set_lock_long_wk := 0;
+
+end;
+
+procedure TMAINFORM.N5Click(Sender: TObject);
+begin
+ i_cut_lock_short := 0;
+
+ if N5.Checked = True then N5.Checked := False else N5.Checked := True;
+ if N5.Checked = True then s_caption_16 := 'Ëø' else s_caption_16 := ' ';
+ if N5.Checked = True then i_lock_short := 888 else i_lock_short := 0;
+ if N5.Checked = True then i_cut_lock_short_mark := 0;
+
+ if i_lock_short = 888 then N5.Checked := True;
+
+ if (StrLen(PChar(Edit2.Text)) > 0) then i_set_lock_short := StrToInt(Edit2.Text)
+ else i_set_lock_short := 0;
+
+ if (i_set_lock_short > 9) then
+ begin
+ i_set_lock_short_wk := i_set_lock_short;
+ end
+ else i_set_lock_short_wk := 0;
+
+end;
+
+procedure TMAINFORM.NextFCClick(Sender: TObject);
+begin
+
+ i_fc_wk_index := i_fc_wk_index + 1;
+ if (i_fc_wk_index > i_fc_count - 1) then i_fc_wk_index := 0;
+
+ s_caption_8 := ' ';
+ s_caption_9 := ' ';
+ s_caption_10 := ' ';
+ s_caption_11 := ' ';
+
+ i_got_it_mark := 0;
+ i_short_mark := 0;
+ i_ff_get_qty_88 := 8;
+end;
+
+procedure TMAINFORM.Only1Click(Sender: TObject);
+begin
+ if Only1.Checked = True then Only1.Checked := False else Only1.Checked := True;
+ if Only1.Checked = True then i_only_1 := 1 else i_only_1 := 0;
+
+ if Only1.Checked = True then s_caption_14 := 'µ¥·¢' else s_caption_14 := 'Ⱥ·¢';
+
+end;
+
+procedure TMAINFORM.ShortOnlyClick(Sender: TObject);
+begin
+ if (i_only_short = 0) and (ShortOnly.Checked = false) then
+ begin
+ ShortOnly.Checked := True;
+ i_only_short := 1;
+ i_only_long := 0;
+ end
+ else if (i_only_short = 1) and (ShortOnly.Checked = true) then
+ begin
+ ShortOnly.Checked := false;
+ i_only_short := 0;
+ end;
+
+ if (i_only_long = 0) then
+ begin
+ LongOnly.Checked := False;
+ end
+ else if (i_only_long = 1) then
+ begin
+ LongOnly.Checked := True;
+ end;
+
+ if (i_only_long = 0) and (i_only_short = 0) then i_long_short_ctrl := 0;
+ if (i_only_long = 1) or (i_only_short = 1) then i_long_short_ctrl := 1;
+
+end;
+
+procedure TMAINFORM.Short_STPClick(Sender: TObject);
+begin
+ if Short_STP.Checked = True then Short_STP.Checked := False else Short_STP.Checked := True;
+ if Short_STP.Checked = True then s_caption_short_stp := '+' else s_caption_short_stp := ' ';
+ if Short_STP.Checked = True then i_stp_short := 888 else i_stp_short := 0;
+ if Short_STP.Checked = True then i_act_stp_short_mark := 0;
+
+ if i_stp_short = 888 then Short_STP.Checked := True;
+
+ if (StrLen(PChar(Edit_short_stp.Text)) > 0) then i_set_stp_short := StrToInt(Edit_short_stp.Text)
+ else i_set_stp_short := 0;
+
+ if (i_set_stp_short > 9) then
+ begin
+ i_set_stp_short_wk := i_set_stp_short;
+ end
+ else i_set_stp_short_wk := 0;
+end;
+
+procedure TMAINFORM.Timer1Timer(Sender: TObject);
+begin
+ ff_set_caption();
+end;
+
+end.
+
diff --git a/uft_robot/robot/src/s_lib_pas_unit.dcu b/uft_robot/robot/src/s_lib_pas_unit.dcu
new file mode 100644
index 00000000..bbd282f8
Binary files /dev/null and b/uft_robot/robot/src/s_lib_pas_unit.dcu differ
diff --git a/uft_robot/robot/src/s_lib_pas_unit.pas b/uft_robot/robot/src/s_lib_pas_unit.pas
new file mode 100644
index 00000000..73b6369a
--- /dev/null
+++ b/uft_robot/robot/src/s_lib_pas_unit.pas
@@ -0,0 +1,145 @@
+unit s_lib_pas_unit;
+
+interface
+uses Windows;
+
+const
+ m_error_log = 0;
+ m_info_log = 1;
+
+
+ m_dead_lock_exit = 118;
+ m_exit_be_killed = 119;
+ m_error_exit = 117;
+ m_exit = 0;
+ FFdll = 'flyingfish.dll';
+ FF_NTSRTS_DLL = 'ff_ntsrts.dll';
+
+var
+ m_module_name: array[0..255] of Char;
+
+
+
+function W_Log(
+ pc_module: PChar;
+ i_lineno: Integer;
+ int: Integer;
+ pc_log: PChar
+ ): Integer; cdecl;
+external 'flyingfish.dll' name 'W_Log';
+
+
+function GetKeyValue(
+ inifilename: PChar;
+ section: PChar;
+ key: PChar;
+ datatype: PChar;
+ {
+ /* c for null end char */
+ /* s for short */
+ /* i for int */
+ /* l for long */
+ /* f for float */
+ /* d for double */
+ }
+ value: PChar
+ ): Integer; cdecl;
+external 'flyingfish.dll' name 'GetKeyValue';
+
+function WriteIni(
+ c_filename: PChar;
+ c_section: PChar;
+ c_key: PChar;
+ c_value: PChar
+ ): Integer; cdecl;
+external 'flyingfish.dll' name 'WriteIni';
+
+
+procedure s_sleep_us(l_us: Integer); cdecl;
+external 'flyingfish.dll' name 's_sleep_us';
+
+function FF_exit(i_exit: Integer): Integer; cdecl;
+external 'flyingfish.dll' name 'FF_exit';
+
+function FF_RtsMain(
+ p_cert_passwd: PChar
+ ): Integer; cdecl;
+external FF_NTSRTS_DLL name 'FF_RtsMain';
+
+function FF_NtsMain(
+ p_cert_passwd: PChar
+ ): Integer; cdecl;
+external FF_NTSRTS_DLL name 'FF_NtsMain';
+
+function FF_webMain(
+ p_cert_passwd: PChar
+ ): Integer; cdecl;
+external FF_NTSRTS_DLL name 'FF_webMain';
+
+function FF_CAMain(
+ p_cert_passwd: PChar
+ ): Integer; cdecl;
+external FF_NTSRTS_DLL name 'FF_CAMain';
+
+function FF_init(
+ p_cert_passwd: PChar
+ ): Integer; cdecl;
+external 'flyingfish.dll' name 'FF_init';
+
+
+function FF_get_thdinfo1(
+ p_v: Pointer
+ ): Integer; cdecl;
+external 'flyingfish.dll' name 'FF_get_thdinfo';
+
+function FF_get_thdinfo(
+ p_v: Pointer; pv_size: Integer
+ ): Integer; cdecl;
+external 'flyingfish.dll' name 'FF_get_thdinfo1';
+
+function CurDate(
+ buf: PChar
+ ): PChar; cdecl;
+external 'flyingfish.dll' name 'CurDate';
+function CurTime(
+ buf: PChar
+ ): PChar; cdecl;
+external 'flyingfish.dll' name 'CurTime';
+
+function FF_W_Info1(
+ pc_file_name: PChar;
+ pc_info: PChar; i_flag: Integer
+): PChar; cdecl;
+external 'flyingfish.dll' name 'FF_W_Info1';
+
+//int FF_cert_key_passwd(char *p_keyfile,char *p_oldpass,char *p_newpass)
+function FF_cert_key_passwd(
+ p_key_file: PChar;
+ p_oldpass: PChar;
+ p_newpass: PChar
+ ): Integer; cdecl;
+external 'flyingfish.dll' name 'FF_cert_key_passwd';
+//char *FF_ffconf(char *c_filename,char *c_section,char *c_name)
+function FF_ffconf(
+ c_filename: PChar;
+ c_section: PChar;
+ c_name: PChar
+ ): PChar; cdecl;
+external 'flyingfish.dll' name 'FF_ffconf';
+
+function FF_load_allconf(): PChar; cdecl;
+external 'flyingfish.dll' name 'FF_load_allconf';
+
+
+//int FF_key_passwd_check(char *p_keyfile,char *p_passwd)
+function FF_key_passwd_check(
+ p_keyfile: PChar;
+ p_passwd: PChar
+ ): Integer; cdecl;
+external FFdll name 'FF_key_passwd_check';
+
+
+
+implementation
+
+end.
diff --git a/uft_robot/robot/src/uFutuDataTypes.dcu b/uft_robot/robot/src/uFutuDataTypes.dcu
new file mode 100644
index 00000000..2d889d4a
Binary files /dev/null and b/uft_robot/robot/src/uFutuDataTypes.dcu differ
diff --git a/uft_robot/robot/src/uFutuDataTypes.pas b/uft_robot/robot/src/uFutuDataTypes.pas
new file mode 100644
index 00000000..016153c7
--- /dev/null
+++ b/uft_robot/robot/src/uFutuDataTypes.pas
@@ -0,0 +1,285 @@
+{/**********************************************************************
+* Ô´³ÌÐòÃû³Æ: futu_data_types.h
+* Èí¼þÖø×÷Ȩ: ºãÉúµç×ӹɷÝÓÐÏÞ¹«Ë¾
+* ϵͳÃû³Æ : 06°æ±¾ÆÚ»õϵͳ
+* Ä£¿éÃû³Æ : ºãÉúÆÚ»õÖܱ߽ӿÚ
+* ¹¦ÄÜ˵Ã÷ : Öܱ߽ӿڳ£ÓÃÊý¾ÝÀàÐͶ¨Òå
+* ×÷ Õß : xdx
+* ¿ª·¢ÈÕÆÚ : 20110315
+* ±¸ ×¢ : Êý¾ÝÀàÐͶ¨Òå
+* ÐÞ¸ÄÈËÔ± £º
+* ÐÞ¸ÄÈÕÆÚ £º
+* ÐÞ¸Ä˵Ã÷ £º20110315 ´´½¨
+20110701 luyj Ð޸ĵ¥ºÅ20110603001 °æ±¾Ôö¼Óµ½V1.0.0.1
+20110802 luyj Ð޸ĵ¥ºÅ20110802006 °æ±¾Ôö¼Óµ½V1.0.0.2
+20110809 luyj Ð޸ĵ¥ºÅ20110808022 °æ±¾Ôö¼Óµ½V1.0.0.3
+20110824 luyj Ð޸ĵ¥ºÅ20110819035 °æ±¾Ôö¼Óµ½V1.0.0.4
+20110913 luyj Ð޸ĵ¥ºÅ20110913002 °æ±¾Ôö¼Óµ½V1.0.0.5
+20111026 luyj Ð޸ĵ¥ºÅ20111026001 °æ±¾Ôö¼Óµ½V1.0.0.6
+20111027 luyj Ð޸ĵ¥ºÅ20111103023 °æ±¾Ôö¼Óµ½V1.0.0.7
+20111027 luyj Ð޸ĵ¥ºÅ20111124003 °æ±¾Ôö¼Óµ½V1.0.0.8
+20120207 luyj Ð޸ĵ¥ºÅ20120207003 °æ±¾Ôö¼Óµ½V1.0.0.9
+20120216 tangui Ð޸ĵ¥ºÅ20120214036 °æ±¾Ôö¼Óµ½V1.0.0.10
+20120216 tangui Ð޸ĵ¥ºÅ20120214036 °æ±¾Ôö¼Óµ½V1.0.0.11
+20120504 tangui Ð޸ĵ¥ºÅ20120412046 °æ±¾Ôö¼Óµ½V1.0.0.12
+20120512 tangui Ð޸ĵ¥ºÅ20120509021 °æ±¾Ôö¼Óµ½V1.0.0.13
+20120720 tanghui Ð޸ĵ¥ºÅ20120515030 °æ±¾Ôö¼Óµ½V1.0.0.14
+**********************************************************************/}
+unit uFutuDataTypes;
+
+interface
+
+const
+ //¶¨Òå°æ±¾ÐÅÏ¢
+ HSFUSDK_VERSION = $10000014;
+ HSFUSDK_VERSTRING = 'V1.0.0.14';
+
+ //¶¨ÒåÁ¬½Ó·þÎñÀàÐÍ
+ SERVICE_TYPE_TRADE = 1; //½»Ò×·þÎñ
+ SERVICE_TYPE_QUOTE = 2; //ÐÐÇé»Ø±¨·þÎñ
+
+ //¶¨ÒåÏûÏ¢ÀàÐÍ
+ MSG_TYPE_UNKNOWN = -1; //δ֪ÏûÏ¢ÀàÐÍ
+
+ MSG_TYPE_USER_LOGIN = 100; //Óû§µÇ¼
+ MSG_TYPE_USER_LOGOUT = 101; //UFT¿Í»§×¢Ïú
+ MSG_TYPE_CONFIRM_BILL = 102; //¿Í»§È·ÈÏÕ˵¥
+ MSG_TYPE_CHECK_CONTRACT_CODE = 103; //¼ì²éºÏÔ¼´úÂë(µ¥ÍÈ)
+ MSG_TYPE_CHECK_ENTRUST_PRICE = 104; //¼ì²éίÍм۸ñ
+ MSG_TYPE_NEW_SINGLE_ORDER = 105; //ίÍÐϵ¥
+ MSG_TYPE_CANCEL_ORDER = 106; //ίÍг·µ¥
+ MSG_TYPE_BANK_TRANSFER = 107; //ÒøÆÚתÕË
+ MSG_TYPE_MODIFY_PASSWORD = 108; //¿Í»§ÐÞ¸ÄÃÜÂë
+
+ //20110822 luyj Ôö¼Ó×éºÏίÍÐ Ð޸ĵ¥ºÅ:20110819035
+ MSG_TYPE_CHECK_COMBIN_CODE = 109; //¼ì²é×éºÏºÏÔ¼´úÂë
+ MSG_TYPE_NEW_COMBIN_ORDER = 110; //×éºÏίÍÐÈ·ÈÏ
+ //20110822 end
+
+ MSG_TYPE_GET_TRADING_CODE = 200; //½»Ò×±àÂë²éѯ
+ MSG_TYPE_GET_PROFIT = 201; //ÆÚ»õ¿Í»§×ʽðȨÒæ²éѯ
+ MSG_TYPE_GET_HOLDSINFO = 202; //³Ö²Ö²éѯ
+ MSG_TYPE_GET_ENTRUST_ORDERS = 203; //ίÍвéѯ
+ MSG_TYPE_GET_TRANS_DETAIL = 204; //³É½»Ã÷ϸ²éѯ
+ MSG_TYPE_GET_FUNDJOUR = 205; //ÀúÊ·×ʽðÁ÷Ë®²éѯ
+ MSG_TYPE_GET_FUND_HISTRANSJOUR = 206; //²éÀúʷתÕËÁ÷Ë®
+ MSG_TYPE_GET_BANK_ACCOUNT = 207; //ÒøÐÐÕ˺Ųéѯ
+ MSG_TYPE_GET_BANK_TRANSJOUR = 208; //ÒøÆÚתÕËÁ÷Ë®²éѯ
+ MSG_TYPE_GET_BANKBALA = 209; //ÒøÐÐÕË»§Óà¶î²éѯ
+ MSG_TYPE_GET_MARKET_DATA = 210; //ÆÚ»õÐÐÇé²éѯ
+ MSG_TYPE_GET_MARGIN = 211; //ºÏÔ¼±£Ö¤½ð²éѯ
+ MSG_TYPE_GET_FUTU_BANKINFO = 212; //ÆÚ»õµÇ¼ÇÒøÐÐÐÅÏ¢²éѯ
+ MSG_TYPE_GET_EXCH_TIME = 213; //½»Ò×Ëùʱ¼ä²î²éѯ
+ MSG_TYPE_GET_FMMC_PWD = 214; //¼à¿ØÖÐÐĽáË㵥ϵͳÃÜÂë²éѯ
+ MSG_TYPE_GET_BILL = 215; //½áËãµ¥²éѯ
+ MSG_TYPE_GET_HIS_ENTRUST = 216; //ÀúʷίÍвéѯ
+ MSG_TYPE_GET_HIS_BUSINESS = 217; //ÀúÊ·³É½»²éѯ
+ MSG_TYPE_GET_HIS_FUND = 218; //ÀúÊ·×ʽð²éѯ
+ MSG_TYPE_UFT_ORDERHSACK = 219; //ίÍз´À¡
+ MSG_TYPE_UFT_ORDEREXACK = 220; //³É½»·´À¡
+
+ //20110822 luyj Ôö¼Ó×éºÏίÍÐÏà¹Ø²éѯ(06) Ð޸ĵ¥ºÅ:20110819035
+ MSG_TYPE_GET_COMBIN_CODE = 221; //²éѯ×éºÏ´úÂë
+ MSG_TYPE_GET_COMBIN_QUOTE = 222; //²éѯ×éºÏÐÐÇé
+ MSG_TYPE_CHECK_PWD = 223; //УÑéÃÜÂë
+ //20110822 end
+
+ //20120426 tanghui Ôö¼Óµ¥¿Í»§²é·ÑÓÃÊôÐԺͱ£Ö¤½ðÊôÐÔ Ð޸ĵ¥:20120412046
+ MSG_TYPE_GET_FEE_PROPERTY = 224; //UFT¿Í»§²éѯ·ÑÓÃÊôÐÔ
+ MSG_TYPE_GET_MARGIN_PROPERTY = 225; //UFT¿Í»§²éѯ±£Ö¤½ðÊôÐÔ
+
+type
+ //¶¨ÒåIntegerÖ¸Õë
+ PInteger = ^Integer;
+ //¶©ÔÄÀàÐÍ
+ REGType =
+ (
+ UnKnownType = -1, // δ֪ÀàÐÍ
+ SingleCode = 0, // µ¥ÍÈÐÐÇé
+ RspReport = 1, // ίÍлر¨
+ CombinCode = 2, // ×éºÏÐÐÇé
+ OnlineMsg = 3 // ÔÚÏßÏûÏ¢
+ );
+
+ //¶©ÔĶ¯×÷
+ REGAction =
+ (
+ UnKnownAction = -1, // δ֪¶¯×÷
+ Subscription = 0, // ¶©ÔÄË¢ÐÂ(Ö÷ÒªÖ¸ÐÐÇé)»òÕßָʾ²»ÊÇÍ˶©
+ CxlAll = 1, // È¡ÏûÈ«²¿µÄ¶©ÔÄ
+ CxlFlag = 2, // ¸ù¾ÝÖƶ¨ÀàÐͶ©ÔÄ
+ Snapshot = 3 // ²éѯ¿ìÕÕ(Ö÷ÒªÖ¸ÐÐÇé)
+ );
+
+ //Á¬½ÓµÄ״̬
+ CONState =
+ (
+ Uninitialized = -1, // Á¬½Óδ³õʼ»¯
+ Disconnected = $0000, // δÁ¬½Ó
+ Connecting = $0001, // socketÕýÔÚÁ¬½Ó
+ Connected = $0002, // socketÒÑÁ¬½Ó
+ SafeConnecting = $0004, // ÕýÔÚ½¨Á¢°²È«Á¬½Ó
+ SafeConnected = $0008, // Òѽ¨Á¢°²È«Á¬½Ó
+ Registering = $0010, // Õý×¢²á
+ Registered = $0020, // ÒÑ×¢²á
+ Rejected = $0040 // ±»¾Ü¾ø,½«±»¹Ø±Õ
+ );
+
+ //¶¨ÒåÏûϢģʽ(FUTU_MSG_MODE¶¨Òå)
+ FUTU_MSG_MODE =
+ (
+ MSG_MODE_UNKNOWN = -1, //δ֪ÏûϢģʽ
+ MSG_MODE_REQUEST = 0, //±íʾÊÇÇëÇóÏûÏ¢
+ MSG_MODE_ANSWER = 1 //±íʾÊÇÓ¦´ðÏûÏ¢
+ );
+
+ //Ϊ¼æÈÝÐÔͳһÒÔ4×Ö½Ú¶ÔÆë,·ñÔòÓÐÊý¾Ý¶ÔÆëµÄÎÊÌâ
+{$A4}
+ // µ¥ÍÈÐÐÇé
+ LPCMarketInfo = ^CMarketInfo;
+ CMarketInfo = record
+ contract_code: array[0..12] of Char; //0 ºÏÔ¼´úÂë,
+ pre_square_price: Double; //1 ×òÈÕ½»¸î½áËã¼Û
+ futu_open_price: Double; //2 ¿ªÅ̼Û
+ futu_last_price: Double; //3 ×îм۸ñ
+ buy_high_price: Double; //4 ×î¸ßÂòÈë¼Û
+ buy_high_amount: Integer; //5 ×î¸ßÂòÈë¼ÛÂòÁ¿
+ buy_total_amount: Integer; //6 È«²¿ÂòÁ¿
+ sale_low_price: Double; //7 ×îµÍÂô¼Û¼Û¸ñ
+ sale_low_amount: Integer; //8 ×îµÍÂô¼ÛÂôÁ¿
+ sale_total_amount: Integer; //9 È«²¿ÂôÁ¿
+ futu_high_price: Double; //10 ×î¸ß¼Û
+ futu_low_price: Double; //11 ×îµÍ¼Û
+ average_price: Double; //12 ¾ù¼Û
+ change_direction: Double; //13 Ç÷ÊÆ
+ business_amount: Integer; //14 ³É½»Á¿
+ bear_amount: Integer; //15 ×ܳÖÁ¿
+ business_balance: Double; //16 ³É½»¶î
+ uplimited_price: Double; //17 ÕÇÍ£°å
+ downlimited_price: Double; //18 µøÍ£°å
+ futu_exch_type: array[0..2] of Char; //19 ½»Ò×Àà±ð
+ form_buy_price: Double; //20 ×éºÏÂòÈë¼Û¸ñ
+ form_sale_price: Double; //21 ×éºÏÂô³ö¼Û¸ñ
+ form_buy_amount: Integer; //22 ×éºÏÂòÈëÊýÁ¿
+ form_sale_amount: Integer; //23 ×éºÏÂô³öÊýÁ¿
+ pre_close_price: Double; //24 ×òÈÕÊÕÅ̼Û
+ pre_open_interest: Double; //25 ×òÈÕ¿ÕÅÌÁ¿
+ futu_close_price: Double; //26 ½ñÈÕÊÕÅ̼Û
+ square_price: Double; //27 ½áËã¼Û
+ pre_delta: Double; //28 ×òÈÕÐéʵ¶È
+ curr_delta: Double; //29 ½ñÈÕÐéʵ¶È
+ bid_price2: Double; //30 Âò¶þ¼Û
+ bid_volume2: Integer; //31 Âò¶þÁ¿
+ bid_price3: Double; //32 ÂòÈý¼Û
+ bid_volume3: Integer; //33 ÂòÈýÁ¿
+ bid_price4: Double; //34 ÂòËļÛ
+ bid_volume4: Integer; //35 ÂòËÄÁ¿
+ bid_price5: Double; //36 ÂòÎå¼Û
+ bid_volume5: Integer; //37 ÂòÎåÁ¿
+ ask_price2: Double; //38 Âô¶þ¼Û
+ ask_volume2: Integer; //39 Âô¶þÁ¿
+ ask_price3: Double; //40 ÂôÈý¼Û
+ ask_volume3: Integer; //41 ÂôÈýÁ¿
+ ask_price4: Double; //42 ÂôËļÛ
+ ask_volume4: Integer; //43 ÂôËÄÁ¿
+ ask_price5: Double; //44 ÂôÎå¼Û
+ ask_volume5: Integer; //45 ÂôÎåÁ¿
+ end;
+
+ // ×éºÏÐÐÇé
+ LPCArgMarketInfo = ^CArgMarketInfo;
+ CArgMarketInfo = record
+ arbicontract_id: array[0..30] of Char; //0 Ì×ÀûºÏÔ¼ºÅ
+ futu_exch_type: array[0..2] of Char; //1 ½»Ò×Àà±ð
+ first_code: array[0..12] of Char; //2 µÚÒ»ÍÈ
+ second_code: array[0..12] of Char; //3 µÚ¶þÍÈ
+ arbi_type: Char; //4 ×éºÏÀàÐÍ1-SPD, 2 -IPS
+ buy_price: Double; //5 ×î¸ßÂòÈë¼Û
+ buy_amount: Integer; //6 ×î¸ßÂòÈë¼ÛÂòÁ¿
+ buy_total_amount: Integer; //7 È«²¿ÂòÁ¿
+ sale_price: Double; //8 ×îµÍÂô¼Û¼Û¸ñ
+ sale_amount: Integer; //9 ×îµÍÂô¼ÛÂôÁ¿
+ sale_total_amount: Integer; //10 È«²¿ÂôÁ¿
+ futu_high_price: Double; //11 ×î¸ß¼Û
+ futu_low_price: Double; //12 ×îµÍ¼Û
+ uplimited_price: Double; //13 ÕÇÍ£°å¼Û¸ñ
+ downlimited_price: Double; //14 µøÍ£°å¼Û¸ñ
+ end;
+
+ //ίÍз´À¡ÐÅÏ¢
+ LPCOrderRspInfo = ^COrderRspInfo;
+ COrderRspInfo = record
+ entrust_no: Integer; //0 ίÍкÅ
+ futures_account: array[0..20] of Char; //1 ½»Ò×±àÂë
+ futu_exch_type: array[0..10] of Char; //2 ½»Ò×ËùÀà±ð
+ contract_code: array[0..12] of Char; //3 ºÏÔ¼´úÂë
+ entrust_bs: array[0..8] of Char; //4 ÂòÂô±êʶ
+ entrust_direction: array[0..8] of Char; //6 ¿ªÆ½±êʶ
+ hedge_type: array[0..8] of Char; //7 Ì×±£±êʶ
+ fund_account: Integer; //8 ×ʽðÕË»§
+ futu_report_no: array[0..20] of Char; //9 ±¾µØµ¥ºÅ
+ firm_no: array[0..8] of Char; //10 »áÔ±ºÅ
+ operator_no: array[0..8] of Char; //11 ²Ù×÷Ô±ºÅ
+ client_group: Integer; //12 ¿Í»§Àà±ð
+ entrust_amount: Integer; //13 ίÍÐÊýÁ¿
+ business_total_amount: Integer; //14 ³É½»×ÜÊýÁ¿
+ cacel_amount: Integer; //15 ³·µ¥ÊýÁ¿
+ entrust_price: Double; //16 ίÍм۸ñ
+ entrust_status: Char; //17 ίÍÐ״̬
+ branch_no: Integer; //18 ÓªÒµ²¿ºÅ
+ batch_no: Integer; //19 ίÍÐÅúºÅ
+ futu_entrust_type: Char; //20 ίÍÐÀàÐÍ
+ amount_per_hand: Integer; //21 ºÏÔ¼³ÆÊý
+ forceclose_reason: Char; //22 ǿƽÔÒò
+ init_date: Integer; //23 ½»Ò×ÈÕÆÚ
+ curr_time: Integer; //24 µ±Ç°Ê±¼ä
+ confirm_no: array[0..20] of Char; //25 Ö÷³¡µ¥ºÅ
+ weave_type: Integer; //26 ×éºÏίÍÐÀàÐÍ
+ arbitrage_code: array[0..20] of Char; //27 ×éºÏίÍÐÀàÐÍ
+ time_condition: Integer; //28 ÓÐЧÆÚÀàÐÍ
+ volume_condition: Integer; //29 ³É½»Á¿ÀàÐÍ
+ futu_entrust_prop: Integer; //30 ÆÚ»õίÍÐÊôÐÔ
+ frozen_fare: Double; //31 ¶³½á×Ü·ÑÓÃ
+ //20120428 tanghui ίÍз´À¡ºÍ³É½»·´À¡Ôö¼Ó´íÎóÐÅÏ¢×ֶΠÐ޸ĵ¥:20120412049
+ error_message: array[0..254] of Char; //32 ´íÎóÐÅÏ¢
+ end;
+
+ //³É½»·´À¡ÐÅÏ¢
+ LPCRealRspInfo = ^CRealRspInfo;
+ CRealRspInfo = record
+ entrust_no: Integer; //0 ίÍкÅ
+ futures_account: array[0..20] of Char; //1 ½»Ò×±àÂë
+ futu_exch_type: array[0..10] of Char; //2 ½»Ò×ËùÀà±ð
+ business_no: array[0..20] of Char; //3 ³É½»±àºÅ
+ contract_code: array[0..12] of Char; //4 ºÏÔ¼´úÂë
+ entrust_bs: array[0..8] of Char; //5 ÂòÂô±êʶ
+ entrust_direction: array[0..8] of Char; //6 ¿ªÆ½±êʶ
+ business_price: Double; //7 ³É½»¼Û¸ñ
+ business_amount: Double; //8 ³É½»ÊýÁ¿
+ hedge_type: array[0..8] of Char; //9 Ì×±£±êʶ
+ fund_account: Integer; //10 ×ʽðÕË»§
+ futu_report_no: array[0..20] of Char; //11 ±¾µØµ¥ºÅ
+ firm_no: array[0..8] of Char; //12 »áÔ±ºÅ
+ operator_no: array[0..8] of Char; //13 ²Ù×÷Ô±ºÅ
+ client_group: Integer; //14 ¿Í»§Àà±ð
+ entrust_amount: Integer; //15 ίÍÐÊýÁ¿
+ business_total_amount: Integer; //16 ³É½»×ÜÊýÁ¿
+ cacel_amount: Integer; //17 ³·µ¥ÊýÁ¿
+ entrust_price: Double; //18 ίÍм۸ñ
+ entrust_status: Char; //19 ίÍÐ״̬
+ branch_no: Integer; //20 ÓªÒµ²¿ºÅ
+ batch_no: Integer; //21 ίÍÐÅúºÅ
+ futu_entrust_type: Char; //22 ίÍÐÀàÐÍ
+ amount_per_hand: Integer; //23 ºÏÔ¼³ÆÊý
+ forceclose_reason: Char; //24 ǿƽÔÒò
+ init_date: Integer; //25 ½»Ò×ÈÕÆÚ
+ business_time: Integer; //26 ³É½»Ê±¼ä
+ confirm_no: array[0..20] of Char; //27 Ö÷³¡µ¥ºÅ
+ frozen_fare: Double; //28 ¶³½á×Ü·ÑÓÃ
+ //20120428 tanghui ίÍз´À¡ºÍ³É½»·´À¡Ôö¼Ó´íÎóÐÅÏ¢×ֶΠÐ޸ĵ¥:20120412049
+ error_message: array[0..254] of Char; //29 ´íÎóÐÅÏ¢
+ end;
+{$A8}
+implementation
+
+end.
diff --git a/uft_robot/robot/src/uFutuMessageInterface.dcu b/uft_robot/robot/src/uFutuMessageInterface.dcu
new file mode 100644
index 00000000..e7ee4f2e
Binary files /dev/null and b/uft_robot/robot/src/uFutuMessageInterface.dcu differ
diff --git a/uft_robot/robot/src/uFutuMessageInterface.pas b/uft_robot/robot/src/uFutuMessageInterface.pas
new file mode 100644
index 00000000..69cec276
--- /dev/null
+++ b/uft_robot/robot/src/uFutuMessageInterface.pas
@@ -0,0 +1,253 @@
+{/**********************************************************************
+* Ô´³ÌÐòÃû³Æ: futu_message_interface.h
+* Èí¼þÖø×÷Ȩ: ºãÉúµç×ӹɷÝÓÐÏÞ¹«Ë¾
+* ϵͳÃû³Æ : 06°æ±¾ÆÚ»õϵͳ
+* Ä£¿éÃû³Æ : ºãÉúÆÚ»õÖܱ߽ӿÚ
+* ¹¦ÄÜ˵Ã÷ : Öܱ߽ӿÚÊý¾Ý²Ù×÷¶¨Òå
+* ×÷ Õß : xdx
+* ¿ª·¢ÈÕÆÚ : 20110315
+* ±¸ ×¢ : Êý¾ÝÀàÐͶ¨Òå
+* ÐÞ¸ÄÈËÔ± £º
+* ÐÞ¸ÄÈÕÆÚ £º
+* ÐÞ¸Ä˵Ã÷ £º20110315 ´´½¨
+**********************************************************************/}
+
+unit uFutuMessageInterface;
+
+interface
+
+uses
+ Classes;
+
+type
+
+//¸÷Àà½Ó¿ÚͳһµÄ²éѯÓëÒýÓÃ½Ó¿Ú (²ÎÕÕCOM±ê×¼)
+ IHSKnown = class
+ public
+ {/**
+ * ²éѯÓ뵱ǰ½Ó¿ÚÏà¹ØµÄÆäËû½Ó¿Ú(±¾½Ó¿ÚÖÐÒ»°ã²»Ê¹ÓÃ)
+ *@param HS_SID iid ½Ó¿ÚÈ«¾ÖΨһ±êʶ
+ *@param IKnown **ppv ·µ»Øiid¶ÔÓ¦µÄ½Ó¿ÚÖ¸Õë
+ *@return R_OK ³É¹¦£¬R_FAIL δ²éµ½iid ÏàÓ¦½Ó¿Ú
+ */}
+ function QueryInterface(const iid: PChar; ppv: Pointer): Integer; virtual; stdcall; abstract;
+
+ {/**
+ * ÒýÓýӿڣ¬ÒýÓüÆÊý¼ÓÒ»
+ *@return µ±Ç°ÒýÓüÆÊý
+ */}
+ function AddRef(): Integer; virtual; stdcall; abstract;
+
+ {/**
+ * ÊͷŽӿڣ¬ÒýÓüÆÊý¼õÒ»£¬¼ÆÊýΪ0ʱÊͷŽӿڵÄʵÏÖ¶ÔÏó
+ *@param R_OK±íʾ³É¹¦,ÆäËû±íʾʧ°Ü
+ */}
+ function Release(): Integer; virtual; stdcall; abstract;
+ end;
+
+
+{/*
+ Ò»ÌõÏûÏ¢Êý¾Ý¼Ç¼,°üº¬Á˺ܶàµÄtag=value,ÆäÖÐtag²»Öظ´
+ Öظ´²åÈëÏàͬµÄtag,Ôò¸²¸ÇÉϴεÄÊý¾Ý
+ ΪÁËʹ½Ó¿Ú¿çÓïÑÔ,½öÖ§³ÖÒÔÏÂÊý¾ÝÀàÐÍ:
+ µ¥×Ö·ûÐÍ(char),Èç'A','1',
+ ÕûÐÍ(int),Èç123,-2343
+ ¸¡µãÐÍ(float),Èç23.50,-34.34
+ ×Ö·û´®ÐÍ(CÓïÑÔ·ç¸ñ'\0'½áβµÄ´®)(char*),Èç"Hello World"
+ ×¢ÒâÆä½Ó¿Ú·½·¨Ḭ̈߳²È«ÐÔ
+*/}
+ IFuRecord = class(IHSKnown)
+ public
+ ///Ìí¼ÓÊý¾ÝµÄ·½·¨,Èô´æÔÚfieldÔò¸²¸ÇÆäÖµ
+ {/**
+ * Ìí¼ÓÒ»¸ö×Ö·ûÐÍÖµ
+ *@param sField ×Ö¶ÎÃû³Æ
+ *@param cValue Ò»¸ö×Ö·ûÖµ
+ *@return R_OKÌí¼Ó³É¹¦,ÆäËû±íʾʧ°Ü
+ [·ÇḬ̈߳²È«]
+ */}
+ function SetChar(const sField: PChar; cValue: Char): Integer; virtual; stdcall; abstract;
+
+ {/**
+ * Ìí¼ÓÒ»¸öÕûÐÍÖµ
+ *@param sField ×Ö¶ÎÃû³Æ
+ *@param iValue Ò»¸öÕûÐÍÖµ
+ *@return R_OKÌí¼Ó³É¹¦,ÆäËû±íʾʧ°Ü
+ [·ÇḬ̈߳²È«]
+ */}
+ function SetInt(const sField: PChar; iValue: Integer): Integer; virtual; stdcall; abstract;
+
+ {/**
+ * Ìí¼ÓÒ»¸ö¸¡µãÖµ
+ *@param sField ×Ö¶ÎÃû³Æ
+ *@param cValue Ò»¸ö¸¡µãÖµ
+ *@return R_OKÌí¼Ó³É¹¦,ÆäËû±íʾʧ°Ü
+ [·ÇḬ̈߳²È«]
+ */}
+ function SetDouble(const sField: PChar; dValue: Double): Integer; virtual; stdcall; abstract;
+
+ {/**
+ * Ìí¼ÓÒ»¸ö×Ö·û´®(CÓïÑÔ¸ñʽ'\0'½áβµÄ×Ö·û´®)
+ *@param sField ×Ö¶ÎÃû³Æ
+ *@param cValue Ò»¸ö×Ö·û´®Öµ
+ *@return R_OKÌí¼Ó³É¹¦,ÆäËû±íʾʧ°Ü
+ [·ÇḬ̈߳²È«]
+ */}
+ function SetString(const sField: PChar; const strValue: PChar): Integer; virtual; stdcall; abstract;
+
+ ///¸ù¾Ý×ֶηÃÎÊÊý¾ÝµÄ·½·¨
+
+ {/**
+ * »ñÈ¡Ò»¸ö×Ö·ûÐÍÖµ
+ *@param sField ×Ö¶ÎÃû³Æ
+ *@return ÓÐЧ×Ö·ûÖµ;×ֶβ»´æÔÚÔòĬÈÏ'\0'
+ [Ḭ̈߳²È«]
+ */}
+ function GetChar(const sField: PChar): Char; virtual; stdcall; abstract;
+
+ {/**
+ * »ñÈ¡Ò»¸öÕûÐÍÖµ
+ *@param sField ×Ö¶ÎÃû³Æ
+ *@return ·µ»ØÒ»¸öÕûÐÍÖµ;×ֶβ»´æÔÚÔòĬÈÏ·µ»Ø0
+ [Ḭ̈߳²È«]
+ */}
+ function GetInt(const sField: PChar): Integer; virtual; stdcall; abstract;
+
+ {/**
+ * »ñµÃÒ»¸ö¸¡µãÖµ
+ *@param sField ×Ö¶ÎÃû³Æ
+ *@return ·µ»ØÒ»¸öÕûÐÍÖµ;×ֶβ»´æÔÚÔòĬÈÏ·µ»Ø0.0(×¢Ò⸡µãÐ͵ľ«¶ÈÎÊÌâ)
+ [Ḭ̈߳²È«]
+ */}
+ function GetDouble(const sField: PChar): Double; virtual; stdcall; abstract;
+
+ {/**
+ * »ñµÃÒ»¸ö×Ö·û´®
+ *@param sField ×Ö¶ÎÃû³Æ
+ *@return ·µ»ØÒ»¸ö×Ö·û´®,Èç²»´æÔÚ¸Ã×Ö¶ÎÔò·µ»ØNULL(0)
+ [Ḭ̈߳²È«]
+ */}
+ function GetString(const sField: Pchar): PChar; virtual; stdcall; abstract;
+
+ ///±éÀú·ÃÎÊ·½·¨,ͨ¹ý´Ë·ÃÎʿɱéÀúÕû¸öÌõ¼Ç¼
+ {/**
+ * Òƶ¯µ½¼Ç¼ͷ(µÚÒ»¸ötag=value)
+ *@return R_OK±íʾ³É¹¦,ÆäËû±íʾʧ°Ü
+ [·ÇḬ̈߳²È«]
+ */}
+ function MoveFirst(): Integer; virtual; stdcall; abstract;
+
+ {/**
+ * ÏÂÒ»Ìõ¼Ç¼
+ *@return R_OK±íʾ³É¹¦,ÆäËû±íʾʧ°Ü»òÒѾµ½¼Ç¼β
+ [·ÇḬ̈߳²È«]
+ */}
+ function MoveNext(): Integer; virtual; stdcall; abstract;
+
+ {/**
+ * ÅжÏÊÇ·ñÒƵ½Á˼Ǽβ
+ *@return 0±íʾδµ½¼Ç¼β,1±íʾÒѵ½¼Ç¼β
+ [·ÇḬ̈߳²È«]
+ */}
+ function IsEOF(): Integer; virtual; stdcall; abstract;
+
+ {/**
+ * »ñÈ¡µ±Ç°×Ö¶ÎÃû(ͨ¹ý¸ÃÃû¿ÉÒÔ·ÃÎʵ½Öµ)
+ *@return NULL±íʾÒѵ½½áβ»òÎÞÊý¾Ý,·ÇNULL±íʾ×Ö¶ÎÃû
+ [Ḭ̈߳²È«]
+ */}
+ function GetFieldName(): PChar; virtual; stdcall; abstract;
+
+ {/**
+ * ɾ³ýÒ»¸ö×Ö¶Î
+ *@param sField Ҫɾ³ýµÄ×Ö¶ÎÃû
+ *@return R_OK±íʾɾ³ý³É¹¦,ÆäËû±íʾʧ°Ü
+ [·ÇḬ̈߳²È«]
+ */}
+ function RemoveField(const sField: PChar): Integer; virtual; stdcall; abstract;
+
+ {/**
+ * ÊÇ·ñ´æÔÚijºÍ×Ö¶Î
+ *@param sField ×Ö¶ÎÃû
+ *@return 0±íʾ²»´æÔÚ,1±íʾ´æÔÚ
+ [·ÇḬ̈߳²È«]
+ */}
+ function IsExist(const sField: PChar): Integer; virtual; stdcall; abstract;
+
+ {/**
+ * ɾ³ýËùÓеÄ×Ö¶Î
+ *@return R_OK±íʾ³É¹¦,ÆäËû±íʾʧ°Ü
+ [·ÇḬ̈߳²È«]
+ */}
+ function Clear(): Integer; virtual; stdcall; abstract;
+
+ {/**
+ * »ñÈ¡¼Ç¼¸öÊý(Field=Value)
+ *@return ±íʾ¼Ç¼µÄÌõÊý
+ [Ḭ̈߳²È«]
+ */}
+ function GetCount(): Integer; virtual; stdcall; abstract;
+ end;
+
+
+///ÆÚ»õÏûÏ¢½Ó¿Ú,Ò»ÌõÏûÏ¢±íÃ÷ÁËÆäÏûÏ¢µÄÀàÐÍ,²¢ÓÉÒ»¸ö»ò¶àÕâ¸öIFuRecord×é³É
+ IFuMessage = class(IHSKnown)
+ public
+ {/**
+ * ÉèÖÃÏûÏ¢ÀàÐÍ
+ *@param iType ²Î¼ûFUTU_MSG_TYPEµÄ¶¨Òå
+ *@param iMode ±íʾ´ËÏûÏ¢ÊÇÇëÇó»¹ÊÇÓ¦´ð,0-ÇëÇó,1-Ó¦´ð
+ *@return R_OK±íʾ³É¹¦,ÆäËû±íʾÎÞЧ»ò²»Ö§³ÖµÄÏûÏ¢ÀàÐÍ
+ [·ÇḬ̈߳²È«]
+ */}
+ function SetMsgType(iType: Integer; iMode: Integer): Integer; virtual; stdcall; abstract;
+
+ {/**
+ * »ñÈ¡ÏûÏ¢ÀàÐÍ
+ *@param [int]ÏûÏ¢ÀàÐÍ.²Î¿¼FUTU_MSG_TYPEµÄ¶¨Òå
+ *@return ÏûϢģʽ.²Î¿¼FUTU_MSG_MODEµÄ¶¨Òå
+ [Ḭ̈߳²È«]
+ */}
+ function GetMsgType(iMsgMode: PInteger = nil): Integer; virtual; stdcall; abstract;
+
+ {/**
+ * »ñÈ¡¼Ç¼ÌõÊý
+ *@param >=0±íʾ¼Ç¼ÌõÊý,ÆäËû±íʾ´íÎó»òʧ°Ü
+ [Ḭ̈߳²È«]
+ */}
+ function GetCount(): Integer; virtual; stdcall; abstract;
+
+ {/**
+ * ÐÂÔöÒ»Ìõ¼Ç¼,²Ù×÷·µ»ØµÄÖ¸ÕëÒÔ²Ù×÷ÆäÖµ
+ *@return ·ÇNULL±íʾһÌõÓÐЧµÄ¼Ç¼,NULL±íʾ·ÖÅäÄÚ´æʧ°Ü
+ [·ÇḬ̈߳²È«]
+ */}
+ function AddRecord(): IFuRecord; virtual; stdcall; abstract;
+
+ {/**
+ * »ñÈ¡Ò»Ìõ¼Ç¼
+ *@param iIndex ¼Ç¼Ë÷ÒýλÖÃ,´Ó0¿ªÊ¼¼ÆÊý
+ *@return ·ÇNULL±íʾһÌõÓÐЧµÄ¼Ç¼,NULL±íʾË÷ÒýÔ½½ç
+ [·ÇḬ̈߳²È«]
+ */}
+ function GetRecord(iIndex: Integer = 0): IFuRecord; virtual; stdcall; abstract;
+
+ {/**
+ * ɾ³ýÒ»Ìõ¼Ç¼
+ *@param iIndex ¼Ç¼Ë÷ÒýλÖÃ,´Ó0¿ªÊ¼¼ÆÊý
+ *@return R_OK±íʾɾ³ý¹¦ÄÜ,·ñÔòʧ°Ü(¿ÉÄÜÊÇË÷ÒýÔ½½ç)
+ [·ÇḬ̈߳²È«]
+ */}
+ function DelRecord(iIndex: Integer = 0): Integer; virtual; stdcall; abstract;
+
+ {/**
+ * ɾ³ýËùÓеļǼ
+ *@return R_OK±íʾ³É¹¦,ÆäËû±íʾʧ°Ü
+ [·ÇḬ̈߳²È«]
+ */}
+ function Clear(): Integer; virtual; stdcall; abstract;
+ end;
+
+implementation
+
+end.
diff --git a/uft_robot/robot/src/uFutuSdkInterface.dcu b/uft_robot/robot/src/uFutuSdkInterface.dcu
new file mode 100644
index 00000000..9881825a
Binary files /dev/null and b/uft_robot/robot/src/uFutuSdkInterface.dcu differ
diff --git a/uft_robot/robot/src/uFutuSdkInterface.pas b/uft_robot/robot/src/uFutuSdkInterface.pas
new file mode 100644
index 00000000..ab61f2bc
--- /dev/null
+++ b/uft_robot/robot/src/uFutuSdkInterface.pas
@@ -0,0 +1,248 @@
+{/**********************************************************************
+* Ô´³ÌÐòÃû³Æ: futu_sdk_interface.h
+* Èí¼þÖø×÷Ȩ: ºãÉúµç×ӹɷÝÓÐÏÞ¹«Ë¾
+* ϵͳÃû³Æ : 06°æ±¾ÆÚ»õϵͳ
+* Ä£¿éÃû³Æ : ºãÉúÆÚ»õÖܱ߽ӿÚ
+* ¹¦ÄÜ˵Ã÷ : ÖܱßͨÐŽӿڶ¨Òå
+* ×÷ Õß : xdx
+* ¿ª·¢ÈÕÆÚ : 20110315
+* ±¸ ×¢ : ÖܱßͨÐŽӿڶ¨Òå
+* ÐÞ¸ÄÈËÔ± £º
+* ÐÞ¸ÄÈÕÆÚ £º
+* ÐÞ¸Ä˵Ã÷ £º20110315 ´´½¨
+**********************************************************************/}
+unit uFutuSdkInterface;
+
+interface
+
+uses
+ Classes, uFutuDataTypes, uFutuMessageInterface;
+
+type
+
+ //Ç°Ïò¶¨Òå
+ IFuCallBack = class;
+
+////////////////////////////////ÆÚ»õͨÐŶÔÏó½Ó¿Ú//////////////////////////////////////////
+ IHsFutuComm = class(IHSKnown)
+ public
+ {/**
+ * ÉèÖÃÅäÖòÎÊý
+ *@param szSection ½ÚµãÃû
+ *@param szName ÅäÖÃÏî
+ *@param szVal ÅäÖÃÖµ
+ *@return R_OK³É¹¦£¬ÆäËûʧ°Ü
+ [·ÇḬ̈߳²È«]
+ */}
+ function SetConfig(const szSection: PChar; const szName: PChar; const szVal: PChar): Integer; virtual; stdcall; abstract;
+
+ {/**
+ * ³õʼ»¯½Ó¿Ú,ʼ»¯¸÷ÖÖÊý¾Ý,²¢´ÓµÇ½·þÎñÆ÷ÉÏÈ¡µÃÏàÓ¦µÄÐÅÏ¢
+ *@param lpCallback Òì²½»Øµ÷¶ÔÏó,ÓÉÓû§¼Ì³Ð¶ÔÓ¦µÄ½Ó¿ÚʵÏÖÖ®,ΪNULLÔò±íʾ²»¹ØÐĻص÷ÐÅÏ¢
+ *@param iTimeOut ³¬Ê±Ê±¼ä,±íʾ³õʼ»¯³¬Ê±Ê±¼ä,µ¥Î»ºÁÃë,-1±íʾÎÞÏÞÆڵȴý.
+ *@return R_OK±íʾ³É¹¦,ÆäËû±íʾʧ°Ü
+ [Ḭ̈߳²È«]
+ */}
+ function Init(lpCallback: IFuCallBack; iTimeOut: Integer = 5000): Integer; virtual; stdcall; abstract;
+
+ {/**
+ * Æô¶¯·þÎñ,½¨Á¢¸÷ÖÖÓ¦ÓõÄͨÐÅÁ¬½Ó.µ±Í¨ÐÅÁ¬½Ó¶Ï¿ªÊ±,Ò²¿ÉÒÔµ÷Óô˺¯Êý½øÐÐÖØÐÂÁ¬½Ó
+ *@param iType ÒªÆô¶¯µÄ·þÎñÀàÐÍ.ÔÊÐíÈ¡Öµ(»òÁ½ÕßÏà¼Ó):SERVICE_TYPE_TRADE,SERVICE_TYPE_QUOTE
+ *@param iTimeout Æô¶¯·þÎñ³¬Ê±
+ [Ḭ̈߳²È«]
+ */}
+ function Start(iType: Integer; iTimeOut: Integer = 5000): Integer; virtual; stdcall; abstract;
+
+ {/**
+ * Óû§µÇ¼,ÔÚ×ö¾ßÌåµÄÒµÎñ֮ǰ,ÐèÒªÏȵǽÒÔÈ¡µÃÏà¹ØµÄÈÏÖ¤Éí·ÝÐÅÏ¢
+ *@param szUserID Óû§Ãû,Ò»°ãÖ¸×ʲúÕ˺Å
+ *@param szUserPass Óû§ÃÜÂë
+ *@param reportFlag Óû§ÊÇ·ñÐèÒªUFTÖ÷Íƻر¨£¬1ÐèÒª£¬0²»ÐèÒª
+ * *@param lpReserved ÆäËûÊý¾Ý,V1°æ±¾±ØÐëÉèÖÃΪNULL
+ *@return ERR_OK±íʾÇëÇó³É¹¦(µ«´Ëʱ²¢²»±íʾÒѾµÇ½³É¹¦,Ðè´ÓÒì²½»Øµ÷ÖÐÈ¡Ó¦´ðÏûÏ¢)
+ [Ḭ̈߳²È«]
+ */}
+ function DoLogin(const szUserID: PChar; const szUserPass: PChar; const reportFlag: Integer; const lpReserved: Pointer = nil): Integer; virtual; stdcall; abstract;
+
+ {/**luyj 20110701ÓÃÊäÈëµÄ²ÎÊýÀ´½ÓÊÜ»ØÀ¡ÐÅÏ¢¡£²»ÐèÒªÒì²½»Øµ÷¡£Ð޸ĵ¥20110623004
+ * Óû§µÇ¼,ÔÚ×ö¾ßÌåµÄÒµÎñ֮ǰ,ÐèÒªÏȵǽÒÔÈ¡µÃÏà¹ØµÄÈÏÖ¤Éí·ÝÐÅÏ¢
+ *@param szUserID Óû§Ãû,Ò»°ãÖ¸×ʲúÕ˺Å
+ *@param szUserPass Óû§ÃÜÂë
+ *@param lpReceivedMsg Óû§µÄ·µ»ØÐÅÏ¢
+ *@param reportFlag Óû§ÊÇ·ñÐèÒªUFTÖ÷Íƻر¨£¬1ÐèÒª£¬0²»ÐèÒª
+ *@param lpReserved ±£Áô²ÎÊý,±¾°æ±¾½Ó¿Ú±ØÐëÉèÖÃΪNULL
+ *@return ERR_OK±íʾÇëÇó³É¹¦(µ«´Ëʱ²¢²»±íʾÒѾµÇ½³É¹¦,Òª´ÓlpReceivedMsgÈ¡µÃÓ¦´ðÏûÏ¢)
+ [Ḭ̈߳²È«]
+ */}
+ function DoLoginEx(const szUserID: PChar; const szUserPass: PChar; lpReceivedMsg: IFuMessage; const reportFlag: Integer; const lpReserved: Pointer = nil): Integer; virtual; stdcall; abstract;
+
+ {/**
+ *·¢ËÍÒ»¸öÒµÎñÇëÇóÏûÏ¢(·´À¡½á¹ûÔÚÒì²½»Øµ÷ÖнÓÊÕ)
+ *@param lpMessage Ò»ÌõÒµÎñÇëÇóÏûÏ¢,ÓÉÓû§¸ºÔð¹ÜÀíÆäÉúÃüÆÚ
+ *@param iKeyID Ò»¸ö×Ô¶¨Òå±êʶ,Òì²½Ó¦´ð°üÖлá´ø´Ë±êʶ.-1±íʾ²»¹ØÐĴ˱êÖ¾(ÔòĬÈÏÒì²½Ó¦´ðÒÔ×ʽðÕ˺Å×÷Ϊkeyid)
+ *@return ERR_OK±íʾ·¢ËÍÇëÇó³É¹¦,ÐèÒªÔÙÒì²½»Øµ÷ÖÐÈ¡ÏàÓ¦µÄÓ¦´ðÏûÏ¢½á¹û
+ [·ÇḬ̈߳²È«]
+ */}
+ function AsyncSend(const lpReqMsg: IFuMessage; iKeyID: Integer = -1): Integer; virtual; stdcall; abstract;
+
+ {/** ͬ²½·¢ËÍÒ»¸öÒµÎñÇëÇóÏûÏ¢
+ *@param lpReqMsg ÇëÇóµÄÒµÎñÏûÏ¢ [in]
+ *@param lpAnsMsg ͬ²½Ó¦´ðÒµÎñÏûÏ¢[out]
+ *@param iTimeout ³¬Ê±Ê±¼ä,µ¥Î»ºÁÃë
+ *@return ERR_OK±íʾ³É¹¦,ÆäËû±íʾʧ°Ü
+ [·ÇḬ̈߳²È«]
+ */}
+ function SyncSendRecv(const lpReqMsg: IFuMessage; lpAnsMsg: IFuMessage; iTimeout: Integer = 3000): Integer; virtual; stdcall; abstract;
+
+ {/**
+ * ·¢ËͶ©ÔÄÇëÇó,ÒµÎñ½ÓÊÕ½á¹û
+ *@param rType ¶©ÔÄÀàÐÍ(²Î¼ûREGTypeµÄ¶¨Òå)
+ *@param rAction ¶©ÔÄ/Í˶©µÈ¶¯×÷(²Î¼ûREGActionµÄ¶¨Òå)
+ *@param szParam ¸ù¾Ý²»Í¬µÄrTypeÇø·Ö:
+ ÈôÊÇÐÐÇé:szParam±íʾ¶©ÔĵĺÏÔ¼Áбí,ÒÔ¶ººÅ·Ö¸î×Ö·û´®,ÀýÈçWS905,a0905,cu0905,IF0905
+ Èô¶©ÔÄÈ«Êг¡µÄÐÐÇé,¶©ÔÄ´úÂëΪALLWWW
+ ºÏÔ¼´®Ö»ÄÜÖ¸¶¨Ò»ÖÖÀàÐÍ(µ¥ÍÈ»òÕß×éºÏ)
+ ÈôÊǻر¨/¸öÈËÏûÏ¢:szParamÔò±íʾ´ý¶©ÔĵÄÓû§Õ˺Å,×¢ÒâÕâÀïµÄÕ˺Ŷ¼Êǵǽ¹ýµÄÕ˺Å
+ *@return ERR_OK±íʾÇëÇó³É¹¦(´ÓÒì²½Ó¦´ðÖÐÈ¡¶©ÔĽá¹û),ÆäËû±íʾÇëÇóʧ°Ü
+ [·ÇḬ̈߳²È«]
+ */}
+ function SubscribeRequest(rType: REGType; rAction: REGAction; const szParam: PChar): Integer; virtual; stdcall; abstract;
+
+ {/*
+ *Óû§µÇ³ö
+ *@param szUserID ´ýµÇ³öµÄÓû§Õ˺Å
+ *@param lpReserved ±£ÁôÖ®ÓÃ,V1°æ±¾±ØÐëÉèÖÃΪNULL
+ *@return ERR_OK±íʾÇëÇó³É¹¦,¾ßÌå¿ÉÒԴӵǽӦ´ðÖÐÈ¡µÃÐÅÏ¢
+ [Ḭ̈߳²È«]
+ */}
+ function DoLogout(const szUserID: PChar; const lpReserved: Pointer = nil): Integer; virtual; stdcall; abstract;
+
+ {/**
+ * ¹Ø±ÕÇåÀíͨÐŶÔÏó,ÊÍ·ÅÏàÓ¦µÄ×ÊÔ´
+ @return R_OK³É¹¦,ÆäËû±íʾʧ°Ü
+ [Ḭ̈߳²È«]
+ */}
+ function Stop(): Integer; virtual; stdcall; abstract;
+
+ {/**
+ * »ñÈ¡Á¬½Ó״̬
+ *@param iIndexÁ¬½Ó±àºÅ.SERVICE_TYPE_TRADE - ±íʾ½»Ò×Á¬½Ó SERVICE_TYPE_QUOTE -ÐÐÇé(¿ÉÄÜ°üº¬»Ø±¨)Á¬½Ó
+ *@return »ñÈ¡Á¬½Ó״̬
+ [Ḭ̈߳²È«]
+ */}
+ function GetStatus(iIndex: Integer): Integer; virtual; stdcall; abstract;
+
+ {/**
+ * »ñÈ¡´íÎóÐÅÏ¢
+ *@param iErrNo »ñÈ¡´íÎóÐÅÏ¢
+ *@return »ñÈ¡´íÎóÐÅÏ¢µÄ˵Ã÷
+ [Ḭ̈߳²È«]
+ */}
+ function GetErrorMsg(iErrNo: Integer): PChar; virtual; stdcall; abstract;
+
+ {/**
+ * °ó¶¨ÊµÀýÏà¹ØÊý¾Ý
+ *@param lpKey Òª°ó¶¨µÄÊý¾Ý»º³åÇø
+ *@param iKeyLen Òª°ó¶¨µÄÊý¾Ý³¤¶È
+ *@return °ó¶¨³É¹¦,°ó¶¨Ê§°Ü
+ [Ḭ̈߳²È«]
+ */}
+ function SetKeyData(const lpKeyData: Pointer; iLen: Integer): Integer; virtual; stdcall; abstract;
+
+ {/**
+ * »ñÈ¡°ó¶¨µÄÊý¾Ý
+ *param iLen ÒªbandingµÄÊý¾Ý³¤¶È
+ *return ·µ»ØÒª°ó¶¨µÄÊý¾ÝÖ¸Õë
+ [Ḭ̈߳²È«]
+ */}
+ function GetKeyData(var iLen: Integer): Pointer; virtual; stdcall; abstract;
+ end;
+
+ ////////////////////////ͨÐÅÒì²½»Øµ÷½Ó¿Ú(×¢Òâ»Øµ÷ÖеÄIFuMessageÏûÏ¢ÓÉSDK¹ÜÀíÆäÉúÃüÖÜÆÚ)//////////////////////////////////////////////////
+ IFuCallBack = class(IHSKnown)
+ public
+ {/**
+ * Á¬½Ó״̬µÄ¸Ä±ä
+ *@param lpComm ͨÐŽӿڶÔÏó
+ *@param iRet ·µ»Ø״̬±êʶ
+ *@param szNotifyTime ·¢ÉúµÄʱ¼ä
+ *@param szMessage ˵Ã÷ÏûÏ¢
+ */}
+ procedure OnConnStateNotify(lpInst: Pointer; iType: Integer; iStatus: Integer;
+ const szNotifyTime: PChar;
+ const szMsg: PChar); virtual; stdcall; abstract;
+
+ {/**
+ * µÇ½Ӧ´ðÏûÏ¢
+ *@param lpComm ͨÐŽӿڶÔÏó
+ */}
+ procedure OnRspLogin(lpInst: Pointer; lpMsg: IFuMessage); virtual; stdcall; abstract;
+
+ {/**
+ * µÇ³ö·´À¡
+ *@param lpComm ͨÐŽӿڶÔÏó
+ */}
+ procedure OnRspLogout(lpInst: Pointer; lpMsg: IFuMessage); virtual; stdcall; abstract;
+
+ {/**
+ *¶©ÔÄ\Í˶©ÐÐÇé»òÕ߻ر¨µÄ½á¹û
+ *@param lpComm ͨÐŽӿڶÔÏó
+ *@param sType ¶©ÔÄÀàÐÍ(µ¥ÍÈÐÐÇé,»Ø±¨µÈ)
+ *@param aAction ÇëÇó·½Ê½(¶©ÔÄ,È¡Ïû,È¡ÏûÈ«²¿,¿ìÕÕ)
+ *@param iResult ¶©ÔĽá¹û,-1δ֪ʧ°Ü,0¶©Ôijɹ¦,1Öظ´¶©ÔÄ,2È¡Ïû³É¹¦,3ûÓж©ÔÄ¿ÉÒÔÈ¡Ïû
+ *@param lpParam ¸½¼ÓµÄ²ÎÊý,ÈôÊǻر¨Ó¦´ð,ÔòÊÇÕ˺Å;ÈôÊÇÐÐÇé,ÔòÊǺÏÔ¼´úÂë;ALLWWW±íʾËùÓÐ;NULLδ֪
+ *@param szMessage ÎÄ×Ö˵Ã÷
+ */}
+ procedure OnRspSubResult(lpInst: Pointer; sType: REGType;
+ aAction: REGAction; iResult: Integer;
+ const lpParam: PChar; const szMsg: PChar); virtual; stdcall; abstract;
+
+ {/**
+ * ÒµÎñ½ÓÊÕµ½ÒµÎñÓ¦´ðÏûÏ¢
+ *@param lpComm ͨÐŽӿڶÔÏó
+ *@param lpAnsData ÒµÎñÓ¦´ðÏûÏ¢
+ */}
+ procedure OnReceivedBiz(lpInst: Pointer; lpAnsData: IFuMessage; iRet: Integer; iKeyID: Integer); virtual; stdcall; abstract;
+
+ {/**
+ * ½ÓÊÕµ½µ¥ÍÈÊг¡ÐÐÇé
+ *@param lpComm ͨÐŽӿڶÔÏó
+ *@param lpInfo µ¥ÍÈÐÐÇéÊý¾Ý
+ */}
+ procedure OnRspMarketInfo(lpInst: Pointer; const lpData: LPCMarketInfo; rAction: REGAction); virtual; stdcall; abstract;
+
+ //½ÓÊÕµ½×éºÏÊг¡ÐÐÇé
+ {/**
+ * ½ÓÊÕµ½µ¥ÍÈÊг¡ÐÐÇé
+ *@param lpComm ͨÐŽӿڶÔÏó
+ *@param lpInfo µ¥ÍÈÐÐÇéÊý¾Ý
+ */}
+ procedure OnRspArgMaketInfo(lpInst: Pointer; const lpData: LPCArgMarketInfo; rAction: REGAction); virtual; stdcall; abstract;
+
+ {/**
+ * ½ÓÊÕµ½Î¯Íз´À¡ÏûÏ¢
+ *@param lpComm ͨÐŽӿڶÔÏó
+ *@param lpInfo ίÍз´À¡ÏûÏ¢
+ */}
+ procedure OnRecvOrderInfo(lpInst: Pointer; const lpInfo: LPCOrderRspInfo); virtual; stdcall; abstract;
+
+ {/**
+ * ½ÓÊÕµ½¶©µ¥³É½»·´À¡
+ *@param lpComm ͨÐŽӿڶÔÏó
+ *@param lpInfo ¶©µ¥³É½»·´À¡
+ */}
+ procedure OnRecvOrderRealInfo(lpInst: Pointer; const lpInfo: LPCRealRspInfo); virtual; stdcall; abstract;
+
+ {/**
+ * ÔÚÏ߸öÈËÏûÏ¢
+ *@param lpComm ͨÐŽӿڶÔÏó
+ *@param szUsrID ÏûÏ¢Ïà¹ØµÄÕ˺Å
+ *@param szMessage Ïà¹ØµÄ¸öÈËÏûÏ¢
+ */}
+ procedure OnRspOnlineMsg(lpInst: Pointer; szUsrID: PChar; szMessage: PChar); virtual; stdcall; abstract;
+ end;
+
+
+implementation
+
+end.
diff --git a/uft_robot/src/FF_300M.bdsproj b/uft_robot/src/FF_300M.bdsproj
new file mode 100644
index 00000000..c15fb491
--- /dev/null
+++ b/uft_robot/src/FF_300M.bdsproj
@@ -0,0 +1,187 @@
+
+
+
+
+
+
+
+
+
+
+
+ FF_300M.dpr
+
+
+ 7.0
+
+
+ 8
+ 0
+ 1
+ 1
+ 0
+ 0
+ 1
+ 1
+ 1
+ 0
+ 0
+ 1
+ 0
+ 1
+ 1
+ 1
+ 0
+ 0
+ 0
+ 0
+ 0
+ 1
+ 0
+ 1
+ 1
+ 1
+ True
+ True
+ WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
+
+ False
+
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ False
+ False
+ False
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+ True
+
+
+
+ 0
+ 0
+ False
+ 1
+ False
+ False
+ False
+ 16384
+ 1048576
+ 4194304
+
+
+
+ F:\slog\FF300W_9113\bin_1
+
+
+
+
+
+
+
+ False
+
+
+
+
+
+ False
+
+
+ True
+ False
+
+
+ False
+
+
+ False
+ False
+ 1
+ 0
+ 0
+ 0
+ False
+ False
+ False
+ False
+ False
+ 2052
+ 936
+
+
+
+
+ 1.0.0.0
+
+
+
+
+
+ 1.0.0.0
+
+
+
+ Microsoft Office 2000 Sample Automation Server Wrapper Components
+ Microsoft Office XP Sample Automation Server Wrapper Components
+
+
+
+
diff --git a/uft_robot/src/FF_300M.bdsproj.local b/uft_robot/src/FF_300M.bdsproj.local
new file mode 100644
index 00000000..4a4ab6dc
--- /dev/null
+++ b/uft_robot/src/FF_300M.bdsproj.local
@@ -0,0 +1,10 @@
+
+
+
+ 2012/12/12 08:08:52.194.pas,C:\Users\Administrator\Documents\RAD Studio\Projects\Unit1.pas=F:\slog\FF300W_9114\FF_300M\fm_main.pas
+ 2012/12/12 08:08:52.219.dfm,C:\Users\Administrator\Documents\RAD Studio\Projects\Unit1.dfm=F:\slog\FF300W_9114\FF_300M\fm_main.dfm
+ 2012/12/12 08:09:06.366.bdsproj,C:\Users\Administrator\Documents\RAD Studio\Projects\Project1.bdsproj=F:\slog\FF300W_9114\FF_300M\FF_300M.bdsproj
+ 2012/12/12 10:46:04.099.pas,F:\slog\FF300W_9114\FF_300M\Unit1.pas=F:\slog\FF300W_9114\FF_300M\ff_dm.pas
+ 2012/12/12 10:46:04.099.dfm,F:\slog\FF300W_9114\FF_300M\Unit1.dfm=F:\slog\FF300W_9114\FF_300M\ff_dm.dfm
+
+
diff --git a/uft_robot/src/FF_300M.cfg b/uft_robot/src/FF_300M.cfg
new file mode 100644
index 00000000..ed36cb68
--- /dev/null
+++ b/uft_robot/src/FF_300M.cfg
@@ -0,0 +1,39 @@
+-$A8
+-$B-
+-$C+
+-$D+
+-$E-
+-$F-
+-$G+
+-$H+
+-$I+
+-$J-
+-$K-
+-$L+
+-$M-
+-$N+
+-$O+
+-$P+
+-$Q-
+-$R-
+-$S-
+-$T-
+-$U-
+-$V+
+-$W-
+-$X+
+-$YD
+-$Z1
+-cg
+-AWinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
+-H+
+-W+
+-M
+-$M16384,1048576
+-K$00400000
+-E"C:\may\ff_300m_ex_wk\bin"
+-LE"c:\program files\borland\delphi7\Projects\Bpl"
+-LN"c:\program files\borland\delphi7\Projects\Bpl"
+-w-UNSAFE_TYPE
+-w-UNSAFE_CODE
+-w-UNSAFE_CAST
diff --git a/uft_robot/src/FF_300M.dof b/uft_robot/src/FF_300M.dof
new file mode 100644
index 00000000..45d6b2fd
--- /dev/null
+++ b/uft_robot/src/FF_300M.dof
@@ -0,0 +1,143 @@
+[FileVersion]
+Version=7.0
+[Compiler]
+A=8
+B=0
+C=1
+D=1
+E=0
+F=0
+G=1
+H=1
+I=1
+J=0
+K=0
+L=1
+M=0
+N=1
+O=1
+P=1
+Q=0
+R=0
+S=0
+T=0
+U=0
+V=1
+W=0
+X=1
+Y=1
+Z=1
+ShowHints=1
+ShowWarnings=1
+UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
+NamespacePrefix=
+SymbolDeprecated=1
+SymbolLibrary=1
+SymbolPlatform=1
+UnitLibrary=1
+UnitPlatform=1
+UnitDeprecated=1
+HResultCompat=1
+HidingMember=1
+HiddenVirtual=1
+Garbage=1
+BoundsError=1
+ZeroNilCompat=1
+StringConstTruncated=1
+ForLoopVarVarPar=1
+TypedConstVarPar=1
+AsgToTypedConst=1
+CaseLabelRange=1
+ForVariable=1
+ConstructingAbstract=1
+ComparisonFalse=1
+ComparisonTrue=1
+ComparingSignedUnsigned=1
+CombiningSignedUnsigned=1
+UnsupportedConstruct=1
+FileOpen=1
+FileOpenUnitSrc=1
+BadGlobalSymbol=1
+DuplicateConstructorDestructor=1
+InvalidDirective=1
+PackageNoLink=1
+PackageThreadVar=1
+ImplicitImport=1
+HPPEMITIgnored=1
+NoRetVal=1
+UseBeforeDef=1
+ForLoopVarUndef=1
+UnitNameMismatch=1
+NoCFGFileFound=1
+MessageDirective=1
+ImplicitVariants=1
+UnicodeToLocale=1
+LocaleToUnicode=1
+ImagebaseMultiple=1
+SuspiciousTypecast=1
+PrivatePropAccessor=1
+UnsafeType=0
+UnsafeCode=0
+UnsafeCast=0
+[Linker]
+MapFile=0
+OutputObjs=0
+ConsoleApp=1
+DebugInfo=0
+RemoteSymbols=0
+MinStackSize=16384
+MaxStackSize=1048576
+ImageBase=4194304
+ExeDescription=
+[Directories]
+OutputDir=C:\may\ff_300m_ex_wk\bin
+UnitOutputDir=
+PackageDLLOutputDir=
+PackageDCPOutputDir=
+SearchPath=
+Packages=vcl;rtl;vclx;indy;inet;xmlrtl;vclie;inetdbbde;inetdbxpress;dbrtl;dsnap;dsnapcon;vcldb;soaprtl;VclSmp;dbexpress;dbxcds;inetdb;bdertl;vcldbx;webdsnap;websnap;adortl;ibxpress;teeui;teedb;tee;dss;visualclx;visualdbclx;vclactnband;vclshlctrls;IntrawebDB_50_70;Intraweb_50_70;Rave50CLX;Rave50VCL;dclOfficeXP
+Conditionals=
+DebugSourceDirs=
+UsePackages=0
+[Parameters]
+RunParams=
+HostApplication=
+Launcher=
+UseLauncher=0
+DebugCWD=
+[Language]
+ActiveLang=
+ProjectLang=
+RootDir=
+[Version Info]
+IncludeVerInfo=0
+AutoIncBuild=0
+MajorVer=1
+MinorVer=0
+Release=0
+Build=0
+Debug=0
+PreRelease=0
+Special=0
+Private=0
+DLL=0
+Locale=2052
+CodePage=936
+[Version Info Keys]
+CompanyName=
+FileDescription=
+FileVersion=1.0.0.0
+InternalName=
+LegalCopyright=
+LegalTrademarks=
+OriginalFilename=
+ProductName=
+ProductVersion=1.0.0.0
+Comments=
+[HistoryLists\hlUnitAliases]
+Count=1
+Item0=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
+[HistoryLists\hlOutputDirectorry]
+Count=2
+Item0=C:\may\ff_300m_ex_wk\bin
+Item1=C:\may\ff_300m_ex_wk\bin_1
diff --git a/uft_robot/src/FF_300M.dpr b/uft_robot/src/FF_300M.dpr
new file mode 100644
index 00000000..f28e3a8d
--- /dev/null
+++ b/uft_robot/src/FF_300M.dpr
@@ -0,0 +1,22 @@
+program FF_300M;
+
+uses
+ Forms,
+ fm_main in 'fm_main.pas' {MAINFORM},
+ do_beep_thread in 'do_beep_thread.pas',
+ ff_hs_base in 'ff_hs_base.pas',
+ s_lib_pas_unit in 's_lib_pas_unit.pas',
+ uFutuDataTypes in 'uFutuDataTypes.pas',
+ uFutuMessageInterface in 'uFutuMessageInterface.pas',
+ uFutuSdkInterface in 'uFutuSdkInterface.pas',
+ ff_dm in 'ff_dm.pas' {DM: TDataModule};
+
+{$R *.res}
+
+begin
+ Application.Initialize;
+ //Application.MainFormOnTaskbar := True;
+ Application.CreateForm(TMAINFORM, MAINFORM);
+ Application.CreateForm(TDM, DM);
+ Application.Run;
+end.
diff --git a/uft_robot/src/FF_300M.dproj b/uft_robot/src/FF_300M.dproj
new file mode 100644
index 00000000..0c9eb00f
--- /dev/null
+++ b/uft_robot/src/FF_300M.dproj
@@ -0,0 +1,56 @@
+
+
+
+ {71aa6909-7e37-4b70-8ae1-1a082991afc4}
+ FF_300M.dpr
+ Debug
+ AnyCPU
+ DCC32
+ ..\..\FZ_FF300M_EX\bin_1\FF_300M.exe
+
+
+ 7.0
+ False
+ False
+ 0
+ F:\slog\FF300W_9113\bin_1
+ RELEASE
+
+
+ 7.0
+ DEBUG
+ F:\slog\FZ_FF300M_EX\bin_1
+
+
+ Delphi.Personality
+
+
+FalseTrueFalseFalseFalse1000FalseFalseFalseFalseFalse20529361.0.0.01.0.0.0
+
+
+
+
+ Microsoft Office 2000 Sample Automation Server Wrapper Components
+ Microsoft Office XP Sample Automation Server Wrapper Components
+ FF_300M.dprFalse
+
+
+
+
+ MainSource
+
+
+
+
+ TDataModule
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/uft_robot/src/FF_300M.dproj.local b/uft_robot/src/FF_300M.dproj.local
new file mode 100644
index 00000000..a105bc38
--- /dev/null
+++ b/uft_robot/src/FF_300M.dproj.local
@@ -0,0 +1,16 @@
+
+
+
+ 2012/12/12 08:08:52.194.pas,C:\Users\Administrator\Documents\RAD Studio\Projects\Unit1.pas=F:\slog\FF300W_9114\FF_300M\fm_main.pas
+ 2012/12/12 08:08:52.219.dfm,C:\Users\Administrator\Documents\RAD Studio\Projects\Unit1.dfm=F:\slog\FF300W_9114\FF_300M\fm_main.dfm
+ 2012/12/12 08:09:06.366.bdsproj,C:\Users\Administrator\Documents\RAD Studio\Projects\Project1.bdsproj=F:\slog\FF300W_9114\FF_300M\FF_300M.bdsproj
+ 2012/12/12 10:46:04.099.pas,F:\slog\FF300W_9114\FF_300M\Unit1.pas=F:\slog\FF300W_9114\FF_300M\ff_dm.pas
+ 2012/12/12 10:46:04.099.dfm,F:\slog\FF300W_9114\FF_300M\Unit1.dfm=F:\slog\FF300W_9114\FF_300M\ff_dm.dfm
+ 2013/04/05 11:55:56.708.pas,F:\slog\FF300W_9114\FF_300M_EX\Unit1.pas=F:\slog\FF300W_9114\FF_300M_EX\ff_qty.pas
+ 2013/04/05 11:55:56.708.dfm,F:\slog\FF300W_9114\FF_300M_EX\Unit1.dfm=F:\slog\FF300W_9114\FF_300M_EX\ff_qty.dfm
+ 2013/04/05 11:57:53.537.pas,F:\slog\FF300W_9114\FF_300M_EX\ff_qty.pas=F:\slog\FF300W_9114\FF_300M_EX\ff_x.pas
+ 2013/04/05 11:57:53.537.dfm,F:\slog\FF300W_9114\FF_300M_EX\ff_qty.dfm=F:\slog\FF300W_9114\FF_300M_EX\ff_x.dfm
+ 2013/04/05 12:05:53.395.pas,F:\slog\FF300W_9114\FF_300M_EX\ff_x.pas=
+ 2013/04/05 12:05:53.395.dfm,F:\slog\FF300W_9114\FF_300M_EX\ff_x.dfm=
+
+
diff --git a/uft_robot/src/FF_300M.identcache b/uft_robot/src/FF_300M.identcache
new file mode 100644
index 00000000..13dfcddf
Binary files /dev/null and b/uft_robot/src/FF_300M.identcache differ
diff --git a/uft_robot/src/FF_300M.res b/uft_robot/src/FF_300M.res
new file mode 100644
index 00000000..e877da3f
Binary files /dev/null and b/uft_robot/src/FF_300M.res differ
diff --git a/uft_robot/src/do_beep_thread.dcu b/uft_robot/src/do_beep_thread.dcu
new file mode 100644
index 00000000..6df9a1df
Binary files /dev/null and b/uft_robot/src/do_beep_thread.dcu differ
diff --git a/uft_robot/src/do_beep_thread.pas b/uft_robot/src/do_beep_thread.pas
new file mode 100644
index 00000000..b2616c51
--- /dev/null
+++ b/uft_robot/src/do_beep_thread.pas
@@ -0,0 +1,161 @@
+unit do_beep_thread;
+
+interface
+
+uses
+ Windows, Messages, SysUtils,Classes,s_lib_pas_unit;
+
+type
+ Tth_beep = class(TThread)
+ i_do_main_loop_mark :Integer;
+ private
+ { Private declarations }
+ protected
+ procedure Execute; override;
+ end;
+
+implementation
+uses ff_hs_base;
+
+procedure Tth_beep.Execute;
+var
+ iRet,i_loop_count :Integer;
+ s_tmp_log:string;
+begin
+ { Place thread code here }
+ //1.check time,loop,wait
+ //2.main loop
+
+ try
+
+ i_loop_count:=888;
+
+ Sleep(5000);
+
+ //frmMain2.GRID_S001.Cells[0,0]:=pc_what_wk;
+
+ if (i_comm_ok=0) Then
+ begin
+ //frmMain2.GRID_S006.Cells[0,0]:='¶Ï¿ª';
+ s_caption_3:='¶Ï¿ª';
+ Exit;
+ end
+ else
+ begin
+ //frmMain2.GRID_S006.Cells[0,0]:='Áª»ú';
+ s_caption_3:='Áª»ú';
+ end;
+
+ //Sleep(15000);
+
+ While not Terminated do
+ begin
+ //Beep();
+ //s_sleep_us(2000000);
+
+ if i_do_main_loop_mark =0 Then
+ begin
+
+ iRet :=888;
+
+ if ( not g_bStop ) then
+ begin
+ if(WAIT_OBJECT_0 = WaitForSingleObject(g_hEvent,INFINITE)) then
+ //if(WAIT_OBJECT_0 = WaitForSingleObject(g_hEvent,1000) ) then
+ begin
+
+ if (i_comm_ok=0) Then
+ begin
+ //frmMain2.GRID_S006.Cells[0,0]:='¶Ï¿ª';
+ s_caption_3:='¶Ï¿ª';
+ Exit;
+ end
+ else
+ begin
+ //frmMain2.GRID_S006.Cells[0,0]:='Áª»ú';
+ s_caption_3:='Áª»ú';
+ end;
+
+ //Í˳ö
+ if g_bStop then
+ begin
+ Exit;
+ end;
+
+ while ( iRet <> 0 ) do
+ begin
+ try
+ W_Log('Call Start',8,999,'check lpComm_Start here!') ;
+ //Sleep(1000);
+
+ //for tasks restart
+ ExitProcess(9);
+
+ iRet := m_lpComm.Start(g_iType);
+ if ( iRet = 0 ) then
+ begin
+ i_comm_ok :=888;
+ ResetEvent(g_hEvent);
+ break;
+ end;
+ Sleep(1000);
+
+ except
+ W_Log('try_except',9,999,'lpComm_Start exception');
+ end;
+ end;
+
+ end;
+ end;
+ end
+ else
+ begin
+ //s_sleep_us(300000);
+ s_sleep_us(200000);
+
+ try
+
+ if( i_loop_count mod 100 =0 ) then ff_get_qty();
+
+ if( i_ff_get_qty_88 >0 ) then
+ begin
+ i_ff_get_qty_88 := i_ff_get_qty_88 -2;
+ ff_get_qty();
+ end;
+
+ except
+ on E: Exception do
+ begin
+ //Assert(false,s_tmp_log);
+ //W_Log('ff_get_qty',19,999,PChar(s_tmp_log));
+ W_Log('ff_get_qty',19,999,PChar(E.Message));
+ ExitProcess(999);
+ end;
+ end;
+
+ try
+ ff_main_wk_loop();
+ except
+ on E: Exception do
+ begin
+ //Assert(false,s_tmp_log);
+ //W_Log('ff_main_wk_loop',i_line_no_001,999,PChar(s_tmp_log));
+ W_Log('ff_main_wk_loop',i_line_no_001,999,PChar(E.Message));
+ ExitProcess(999);
+ end;
+ end;
+
+ //if( i_loop_count mod 18 =0 ) then ff_get_qty();
+ //if( i_loop_count mod 2 =0 ) then ff_main_wk_loop();
+ i_loop_count :=i_loop_count + 1;
+ if(i_loop_count >88888888) then i_loop_count :=0;
+ end;
+ end;
+
+ finally
+ ExitProcess(999);
+ end;
+
+end;
+
+end.
diff --git a/uft_robot/src/ff_dm.dcu b/uft_robot/src/ff_dm.dcu
new file mode 100644
index 00000000..b1e82848
Binary files /dev/null and b/uft_robot/src/ff_dm.dcu differ
diff --git a/uft_robot/src/ff_dm.dfm b/uft_robot/src/ff_dm.dfm
new file mode 100644
index 00000000..6c8290b7
--- /dev/null
+++ b/uft_robot/src/ff_dm.dfm
@@ -0,0 +1,5 @@
+object DM: TDM
+ OldCreateOrder = False
+ Height = 381
+ Width = 581
+end
diff --git a/uft_robot/src/ff_dm.pas b/uft_robot/src/ff_dm.pas
new file mode 100644
index 00000000..952a5802
--- /dev/null
+++ b/uft_robot/src/ff_dm.pas
@@ -0,0 +1,23 @@
+unit ff_dm;
+
+interface
+
+uses
+ SysUtils, Classes;
+
+type
+ TDM = class(TDataModule)
+ private
+ { Private declarations }
+ public
+ { Public declarations }
+ end;
+
+var
+ DM: TDM;
+
+implementation
+
+{$R *.dfm}
+
+end.
diff --git a/uft_robot/src/ff_hs_base.dcu b/uft_robot/src/ff_hs_base.dcu
new file mode 100644
index 00000000..5d027a2d
Binary files /dev/null and b/uft_robot/src/ff_hs_base.dcu differ
diff --git a/uft_robot/src/ff_hs_base.pas b/uft_robot/src/ff_hs_base.pas
new file mode 100644
index 00000000..704009b6
--- /dev/null
+++ b/uft_robot/src/ff_hs_base.pas
@@ -0,0 +1,6022 @@
+unit ff_hs_base;
+
+{
+//ff_300m_ex for ¶àÕË»§Ò»¼üϵ¥
+
+//
+}
+interface
+uses
+ Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,DateUtils,
+ Dialogs,uFutuDataTypes,uFutuMessageInterface,uFutuSdkInterface,fm_main,s_lib_pas_unit,
+ do_beep_thread;
+
+const
+ HSFUSDKDLL='HsFutuSDK.DLL' ;
+
+
+type
+ ////////////////////////¼Ì³Ð»Øµ÷½Ó¿Ú//////////////////////////////////
+ TMyFuCallBack = class (IFuCallBack)
+ public
+ //²éѯ
+ function QueryInterface( const iid:PChar;ppv:Pointer ):Integer;override;stdcall;
+
+ //ÒýÓýӿڣ¬ÒýÓüÆÊý¼ÓÒ»
+ function AddRef():Integer;override;stdcall;
+
+ //ÊͷŽӿڣ¬ÒýÓüÆÊý¼õÒ»£¬¼ÆÊýΪ0ʱÊͷŽӿڵÄʵÏÖ¶ÔÏó
+ function Release():Integer;override;stdcall;
+
+ //Á¬½Ó״̬µÄ¸Ä±ä
+ procedure OnConnStateNotify(lpInst:Pointer;iType:Integer;iRet:Integer;
+ const szNotifyTime:PChar;
+ const szMsg:PChar);override;stdcall;
+
+ //µÇ½Ӧ´ðÏûÏ¢
+ procedure OnRspLogin(lpInst:Pointer;lpMsg:IFuMessage);override;stdcall;
+
+ //µÇ³ö·´À¡
+ procedure OnRspLogout(lpInst:Pointer;lpMsg:IFuMessage);override;stdcall;
+
+ //¶©ÔÄ\Í˶©ÐÐÇé»òÕ߻ر¨µÄ½á¹û
+ procedure OnRspSubResult(lpInst:Pointer;sType:REGType;
+ aAction:REGAction;iResult:Integer;
+ const lpParam:PChar;const szMsg:PChar);override;stdcall;
+
+ //ÒµÎñ½ÓÊÕµ½ÒµÎñÓ¦´ðÏûÏ¢
+ procedure OnReceivedBiz(lpInst:Pointer;lpAnsData:IFuMessage;iRet:Integer;iKeyID:Integer);override;stdcall;
+
+ //½ÓÊÕµ½µ¥ÍÈÊг¡ÐÐÇé
+ procedure OnRspMarketInfo(lpInst:Pointer;const lpData:LPCMarketInfo;rAction:REGAction);override;stdcall;
+
+ //½ÓÊÕµ½×éºÏÊг¡ÐÐÇé
+ procedure OnRspArgMaketInfo(lpInst:Pointer;const lpData:LPCArgMarketInfo;rAction:REGAction);override;stdcall;
+
+ //½ÓÊÕµ½Î¯Íз´À¡ÏûÏ¢
+ procedure OnRecvOrderInfo(lpInst:Pointer;const lpInfo:LPCOrderRspInfo);override;stdcall;
+
+ //½ÓÊÕµ½¶©µ¥³É½»·´À¡
+ procedure OnRecvOrderRealInfo(lpInst:Pointer;const lpInfo:LPCRealRspInfo);override;stdcall;
+
+ //ÔÚÏ߸öÈËÏûÏ¢
+ procedure OnRspOnlineMsg(lpInst:Pointer;szUsrID:PChar;szMessage:PChar);override;stdcall;
+ end;
+ /////////////////////////////////////////////////////////////////////
+
+ /////////////////////////////////////////SDKµ¼³ö½Ó¿Ú////////////////////////////////////////
+ { /**
+ * ²úÉúÒ»ÌõеÄÏûÏ¢
+ *@param iMsgType ÏûÏ¢ÀàÐÍ,Çë²Î¿¼ÓÐЧµÄÏûÏ¢ÀàÐͶ¨Òå
+ *return ·ÇNULL±íʾһÌõÓÐЧµÄÏûÏ¢,NULL±íʾ·ÖÅäÄÚ´æʧ°Ü
+ [Ḭ̈߳²È«]
+ */}
+ function NewFuMessage(iMsgType:Integer=-1;iMsgMode:Integer=-1):IFuMessage;stdcall;external HSFUSDKDLL;
+
+ {/**
+ * ´´½¨ÐµÄϵͳÁ¬½Ó¶ÔÏó
+ *@param lpReserved ±£Áô²ÎÊý,V1°æ±¾±ØÐëÖÃΪNULL
+ *@return ¶ÔÏó½Ó¿Ú¶ÔÏóÖ¸Õë(¿ÉÒÔµ÷ÓÃÆäÄڵĺ¯ÊýʵÏÖ)
+ [Ḭ̈߳²È«]
+ */}
+ function NewFuCommObj(lpReserved:Pointer=nil):Pointer;stdcall;
+ external HSFUSDKDLL name 'NewFuCommObj';
+
+ {/**
+ * »ñÈ¡°æ±¾ºÅ
+ @return °æ±¾ºÅ,Ê®Áù½øÖÆÊý¾Ý,ÀýÈç0x10000000,±íʾ°æ±¾Îª1.0.0.0
+ [Ḭ̈߳²È«]
+ */}
+ function GetSDKVersion():Integer;stdcall;external HSFUSDKDLL;
+ /////////////////////////////////////////SDKµ¼³ö½Ó¿Ú////////////////////////////////////////
+
+const
+ m_ma_max_index =11; //for 12 :0..11
+
+Type
+ //Ϊ¼æÈÝÐÔͳһÒÔ4×Ö½Ú¶ÔÆë,·ñÔòÓÐÊý¾Ý¶ÔÆëµÄÎÊÌâ
+ {$A4}
+ // µ¥ÍÈÐÐÇé
+ LP_s_k_line_data = ^s_k_line_data;
+ s_k_line_data = record
+ i_date :Cardinal;
+ i_open :Cardinal;
+ i_high :Cardinal;
+ i_low :Cardinal;
+ i_close :Cardinal;
+ f_amount :Single;
+ i_vol :Cardinal;
+ i_pre_close :Cardinal;
+ end;
+
+ LP_s_k_line_ma_rsi = ^s_k_line_ma_rsi;
+ s_k_line_ma_rsi = record
+ ai_ma :array [0..m_ma_max_index] of Cardinal;
+ ai_rsi :array [0..5] of Cardinal;
+ end;
+
+
+ LP_s_fc_data = ^s_fc_data;
+
+ s_fc_data = record
+ pc_username :PChar;
+ pc_xxx_name :PChar;
+ pc_fcpwd :PChar;
+
+ i_VOL :Integer;
+ i_long_max:Integer;
+ i_short_max:Integer;
+
+ i_got_it_mark :Integer;
+ i_short_mark :Integer;
+ i_rights_balance:Integer;
+
+ f_rights_balance :Single;
+ f_short_price :Single;
+ f_business_price :Single;
+
+ end;
+
+ LP_s_vol_data = ^s_vol_data;
+
+ s_vol_data = record
+ tm_0 :TDateTime;
+ i_business_amount :Integer;
+ i_VOL :Integer;
+ end;
+
+const
+ m_i_max_chg_kline_in_mem =18888;
+
+ //for F9
+ m_bsk_ask_long=1;
+ //for F10
+ m_bsk_bid_long=2;
+ //for F11
+ m_bsk_bid_short=3;
+ //for F12
+ m_bsk_ask_short=4;
+
+ m_bsk_clear_long=5;
+ m_bsk_clear_short=6;
+
+ m_mairu='1';
+ m_maichu= '2';
+ m_kaicang= '1';
+ m_pingcang= '2';
+ m_jiaoge= '3';
+ m_pingjin= '4';
+
+ m_i_long=1;
+ m_i_short=2;
+
+ m_k_line_file_name ='sh600328.day';
+ m_USER_NAME ='80104267';
+ m_USER_PWD ='158363';
+
+ m_ff_main_ini = '../conf/ff_main.ini';
+ m_ff_rsi_ini = '../conf/ff_rsi.ini';
+ m_ff_local_ini = '../conf/ff_local.ini';
+ m_ff_ma120_ini = '../conf/ff_ma_bb.ini';
+ m_ff_bb100_ini = '../conf/ff_bb_100.ini';
+ m_ff_m30_short_ini = '../conf/ff_m30_short.ini';
+ m_ff_m30_long_ini = '../conf/ff_m30_long.ini';
+ m_ff_short_1_ini = '../conf/ff_short_1.ini';
+ m_ff_action_ini = '../conf/ff_action.ini';
+
+var
+ i_show_string_grid :Integer=0;
+ i_do_ff_qty_loop :Integer=0;
+
+ i_open_price :Integer=0;
+ i_open_vol :Integer=0;
+ i_open_vol_wk :Integer=0;
+
+ c_open_price : array [0..88] of Char;
+ c_open_price_0 : array [0..88] of Char;
+ c_open_price_1 : array [0..88] of Char;
+
+ //for vol ,up power
+ i_chk_power_vol_set :Integer=5000;
+
+ i_chk_power_vol_wk :Integer=5000;
+
+ i_up_count_ex:Integer=0;
+ i_down_count_ex:Integer=0;
+ i_up_vol_sum:Integer=0;
+ i_down_vol_sum:Integer=0;
+
+
+ //for vol display
+ i_vol_start:Integer=0;
+ i_vol_reset:Integer=0;
+ i_vol_stop:Integer=0;
+
+ i_vol_0:Integer=0;
+
+ tdt_vol_0 :TDateTime;
+ i_vol_1:Integer=0;
+
+ tdt_vol_1 :TDateTime;
+
+
+ as_vol_data : array [0..88] of s_vol_data;
+
+ i_clr_long_1_mark :Integer=0;
+ i_clr_short_1_mark :Integer=0;
+
+ i_clr_long_to_001_mark :Integer=0;
+ i_clr_short_to_001_mark :Integer=0;
+
+ //for stop
+ i_stp_long :Integer=0;
+ i_stp_short :Integer=0;
+
+ i_act_stp_long :Integer=0;
+ i_act_stp_short :Integer=0;
+
+ i_set_stp_long :Integer=0;
+ i_set_stp_short :Integer=0;
+
+ i_set_stp_long_wk :Integer=0;
+ i_set_stp_short_wk :Integer=0;
+
+ i_act_stp_long_mark :Integer=0;
+ i_act_stp_short_mark :Integer=0;
+
+ i_stp_delta : Integer=3;
+
+
+
+
+ i_lock_long :Integer=0;
+ i_lock_short :Integer=0;
+
+ i_cut_lock_long :Integer=0;
+ i_cut_lock_short :Integer=0;
+
+ i_set_lock_long :Integer=0;
+ i_set_lock_short :Integer=0;
+
+ i_set_lock_long_wk :Integer=0;
+ i_set_lock_short_wk :Integer=0;
+
+ i_cut_lock_long_mark :Integer=0;
+ i_cut_lock_short_mark :Integer=0;
+
+ i_delta : Integer=12;
+
+ i_open_delta : Integer=12;
+ i_close_delta : Integer=12;
+
+
+ i_only_1 : Integer=0;
+ i_fc_count : Integer=0;
+ i_fc_wk_index : Integer=0;
+ i_fc_wk_index_bak : Integer=88;
+ as_fc_data : array [0..88] of s_fc_data;
+
+ c_error_no :array [0..88] of Char;
+ c_error_info :array [0..888] of Char;
+
+ pc_open_long_time :PChar=nil;
+ pc_open_short_time :PChar=nil;
+ pc_close_long_time :PChar=nil;
+ pc_close_short_time :PChar=nil;
+
+ //<0 for disable
+ //=0 for enable ,just wait to do it
+ //>0 for had did
+ i_open_long_timer :Integer =-8;
+ i_open_short_timer :Integer =-8;
+ i_close_long_timer :Integer =-8;
+ i_close_short_timer :Integer =-8;
+
+var
+ i_lock_for_main_loop :Integer=0;
+
+ s_edit_text_1:string=' ';
+ s_edit_text_2:string=' ';
+
+ s_caption_1:string=' ';
+ s_caption_2:string=' ';
+ s_caption_3:string=' ';
+ s_caption_4:string=' ';
+ s_caption_5:string=' ';
+ s_caption_6:string=' ';
+ s_caption_7:string=' ';
+ s_caption_8:string=' ';
+ s_caption_9:string=' ';
+ s_caption_10:string=' ';
+ s_caption_11:string=' ';
+ s_caption_12:string=' ';
+ s_caption_13:string=' ';
+ s_caption_14:string=' ';
+ s_caption_15:string=' ';
+ s_caption_16:string=' ';
+
+ s_caption_vol:string=' ';
+ s_caption_long_stp:string=' ';
+ s_caption_short_stp:string=' ';
+ s_caption_status:string=' ';
+
+var
+ i_line_no_001 :Integer;
+ i_line_no_002 :Integer;
+ i_line_no_003 :Integer;
+ i_line_no_004 :Integer;
+ i_line_no_005 :Integer;
+ i_line_no_006 :Integer;
+ i_line_no_007 :Integer;
+ i_line_no_008 :Integer;
+
+ i_loop_count_001 :Integer=0;
+
+
+var
+ ai_ma_set :array [0..11] of Integer=(5,10,20,30,50,60,120,200,250,600,1200,2400);
+ ai_rsi_set :array [0..5] of Integer=(6,12,24,9,18,36);
+
+ m_lpComm:IHsFutuComm;
+ m_lpCallBack:TMyFuCallBack;
+
+ i_comm_ok :Integer=0;
+
+ i_ff_get_qty_88 :Integer=0;
+ i_ff_get_qty_flag :Integer=0;
+
+ th_beep :Tth_beep;
+ th_main_loop :Tth_beep;
+ i_beeping :Integer=0;
+
+ g_hEvent :THANDLE;
+ g_iType :Integer=0;
+ g_bStop :Boolean=False;
+
+ tm_0 :TDateTime;
+ tm_1 :TDateTime;
+ tm_2 :TDateTime;
+
+ i_as_k_chg_init_flag :Integer=0;
+ i_s_k_chg_index_wk :Integer=0;
+ i_s_k_chg_index_wk_bak :Integer=0;
+ i_s_k_chg_index_load :Integer=0;
+ i_as_k_base_init_flag:Integer=0;
+
+ as_k_chg : array [0..m_i_max_chg_kline_in_mem] of s_k_line_data;
+ as_k_chg_ma_rsi : array [0..m_i_max_chg_kline_in_mem] of s_k_line_ma_rsi;
+ i_get_price_count :Integer=0;
+
+ iFileHandle : Integer;
+
+ i_will_close_market :Integer=0;
+
+var
+ i_no_trade :Integer=0;
+
+ i_only_short:Integer=0;
+
+ i_only_long:Integer=0;
+ i_mbm_only:Integer=0;
+
+ i_short_stop_index :Integer=0;
+ i_long_stop_index :Integer=0;
+
+ i_sum_short_mbm_count :Integer=0;
+ i_sum_long_mbm_count :Integer=0;
+
+ i_sum_4ma_short_mbm_count :Integer=0;
+ i_sum_4ma_long_mbm_count :Integer=0;
+
+ //for Big Money
+ i_mbm_long :Integer=888;
+ i_mbm_short :Integer=888;
+
+ i_4ma_mbm_long :Integer=888;
+ i_4ma_mbm_short :Integer=888;
+
+ i_short_mbm_mark :Integer=0;
+ i_long_mbm_mark :Integer=0;
+
+ i_4ma_short_mbm_mark :Integer=0;
+ i_4ma_long_mbm_mark :Integer=0;
+
+ i_short_mbm_count :Integer=0;
+ i_long_mbm_count :Integer=0;
+
+ i_4ma_short_mbm_count :Integer=0;
+ i_4ma_long_mbm_count :Integer=0;
+
+ i_long_mbm_count_action_1 :Integer=0;
+ i_short_mbm_count_action_1 :Integer=0;
+
+ i_short_mbm_count_bak :Integer=0;
+ i_long_mbm_count_bak :Integer=0;
+
+ i_4ma_short_mbm_count_bak :Integer=0;
+ i_4ma_long_mbm_count_bak :Integer=0;
+
+ i_short_mbm_index :Integer=0;
+ i_long_mbm_index :Integer=0;
+
+ i_short_mbm_index_1 :Integer=0;
+ i_long_mbm_index_1 :Integer=0;
+
+ i_last_120ma250eq_index :Integer=0;
+
+ f_mbm_cut_long :Single=0.0;
+ f_mbm_stop_long :Single=0.0;
+
+ f_mbm_cut_short :Single=0.0;
+ f_mbm_stop_short :Single=0.0;
+
+ i_short_long_01 :Integer=888;
+ i_short_long_date :Integer=0;
+ i_short_long_index :Integer=888;
+
+ i_wk_log :Integer=8;
+ i_debug_log :Integer=0;
+ i_tmp_log :Integer=-1;
+ i_mbm_log :Integer=28;
+
+ i_make_log_ex :Integer=-1;
+
+ i_make_ex_test :Integer=0;
+ i_make_k_only :Integer=0;
+
+ i_long_short_ctrl:Integer=0;
+
+ i_make_long_mark :Integer=0;
+ i_got_it_mark :Integer=0;
+
+ i_long_act_flag :Integer=-1;
+ i_short_act_flag :Integer=-1;
+
+ i_make_short_mark :Integer =0;
+
+ i_short_mark :Integer=0;
+ f_short_price :Single;
+ f_business_price :Single;
+
+ i_got_it_mark_ex :Integer=0;
+ i_short_mark_ex :Integer=0;
+ f_short_price_ex :Single;
+ f_business_price_ex :Single;
+
+
+ f_last_price_wk :Single=0.0;
+ f_last_price_1 :Single=0.0;
+ f_price_A :Single=0.0;
+
+ f_buy_1 :Single=0.0;
+ f_sale_1 :Single=0.0;
+
+ i_BSK:Integer=0;
+
+ i_stop_check_count:Integer=0;
+ i_stop_short_count:Integer=0;
+
+ c_entrust_no :array [0..88] of Char;
+ c_batch_no :array [0..88] of Char;
+
+ c_rights_balance :array [0..88] of Char;
+ i_rights_balance :Integer=0;
+ f_rights_balance :Single=0.0;
+
+ i_entrust_no_mark :Integer=0;
+
+var
+ pc_username :PChar;
+ pc_user_pwd :PChar;
+
+ pc_what_wk :PChar;
+
+ pc_IP :PChar;
+ pc_BLS:PChar;
+ pc_CLF:Pchar;
+ pc_ENT:Pchar;
+
+ i_rsi_A:Integer=1800;
+ i_rsi_B:Integer=2800;
+ i_rsi_C:Integer=1800;
+
+ i_rsi_AB:Integer=6;
+ i_rsi_BC:Integer=6;
+ i_rsi_IA_min:Integer=8;
+ i_rsi_IA_max:Integer=18;
+
+ f_rsi_stop :Single=18.0;
+ f_rsi_cut :Single=12.0;
+
+ f_rsi_stop_long :Single=18.0;
+ f_rsi_stop_short :Single=18.0;
+
+ f_rsi_cut_long :Single=0.0;
+ f_rsi_cut_short :Single=0.0;
+
+ f_rsi_add :Single=8.0;
+ i_F:Integer=1;
+ i_S:Integer=1;
+ i_T:Integer=1;
+ i_A:Integer=1;
+
+ i_M30:Integer=30;
+ i_M30_stop:Integer=0;
+
+ i_M120:Integer=0;
+ i_M120_stop:Integer=0;
+
+ i_BOX_Y:Integer =8 ;
+
+ i_get_S_mark:Integer =0;
+ i_get_T_mark:Integer =0;
+ i_short_S_mark:Integer =0;
+ i_short_T_mark:Integer =0;
+
+ i_w20_mark :Integer=0;
+ i_w20_A_index :Integer=0;
+ i_w20_B_index :Integer=0;
+ i_w20_C_index :Integer=0;
+
+ i_MA120_BB_mark :Integer=0;
+ i_MA120_BB_n :Integer=0;
+ i_MA120_BB_c :Integer=0;
+ i_MA120_BB_i :Integer=0;
+
+ i_BB_BOX_X :Integer=8;
+ i_BB_BOX_Y :Integer=800;
+
+ i_M30_short_mark :Integer=0;
+ i_M30_short_n :Integer=0;
+ i_M30_short_c :Integer=0;
+ i_M30_short_i :Integer=0;
+
+ i_M30_short_BOX_X :Integer=8;
+ i_M30_short_BOX_Y :Integer=2800;
+
+
+
+Var
+ i_BB_100_BOX_X :Integer=8;
+ i_BB_100_BOX_Y :Integer=3800;
+ i_BB_100_mark :Integer=0;
+ i_BB_100_n :Integer=0;
+ i_BB_100_c :Integer=0;
+ i_BB_100_i :Integer=0;
+
+ i_MA120_120_chg :Integer=0;
+ i_make_long :integer=0;
+ i_make_short :Integer=0;
+
+ i_short_1_mark:Integer=0;
+ i_short_250_mark:Integer=0;
+ i_short_30_mark:Integer=0;
+ i_short_120_mark:Integer=0;
+
+ i_pass3_short_120_mark:Integer=0;
+
+ i_pass_3_mark :Integer=0;
+ i_pass_3_mark_ex :Integer=0;
+
+ i_act_rsi:Integer=10;
+ i_act_m120:Integer=10;
+ i_act_bb_100:Integer=10;
+ i_act_short:Integer=10;
+
+ i_B_S_Flag:Integer=0;
+ i_B_S_Flag_10:Integer=0;
+ i_B_S_Flag_18:Integer=0;
+
+ i_B_Flag:Integer=0;
+ i_S_Flag:Integer=0;
+
+ i_short_pass3_mark :Integer=0;
+
+ i_ADD_FLOSS_MAX :Integer =0;
+ i_long_FLOSS_MAX :Integer =0;
+ i_short_FLOSS_MAX :Integer =0;
+
+var
+ MAINFORM: TMAINFORM;
+
+function ff_chk_power_vol(i:Integer):Integer;
+
+function ff_set_caption():Integer;
+
+function ff_load_k_base():Integer;
+
+function ff_rsi_w20_init():Boolean;
+
+function FF_creat_comm_obj( ):Boolean;
+function FF_release_comm_obj():Boolean;
+function FF_comm_obj_init():Boolean;
+function FF_do_logout(pc_fund_account :PChar):Boolean;
+
+function ff_make_ma_rsi_ex(ii:Integer) :Integer;
+function ff_make_ma_rsi() :Integer;
+function ff_get_ma(i:Integer;j:Integer) :Integer;
+function ff_get_rsi(ii:Integer;jj:Integer) :Integer;
+function ff_get_max_ij_high(i:Integer;j:Integer) :Integer;
+function ff_get_min_ij_low(i:Integer;j:Integer) :Integer;
+function ff_get_max_ij_index(i:Integer;j:Integer) :Integer;
+function ff_get_min_ij_index(i:Integer;j:Integer) :Integer;
+
+function ff_check_rsi_w20(i:Integer):Integer;
+function ff_check_rsi_w20_ex(i:Integer):Integer;
+function ff_check_MA120_BB(i:Integer;i_ma_index :Integer):Integer;
+function ff_check_MA120_BB_ex(i:Integer):Integer;
+
+function ff_check_BB_100(i:Integer;i_ma_index :Integer):Integer;
+function ff_check_BB_100_ex(i:Integer):Integer;
+
+function ff_get_S_L_Mark(i:Integer) :Integer;
+function ff_get_BS_Mark(i:Integer) :Integer;
+function ff_get_long_mark_8(i:Integer) :Integer;
+function ff_get_ma600_mark(i:Integer) :Integer;
+function ff_get_ma600_mark_long(i:Integer) :Integer;
+
+function ff_check_M30_short(i:Integer):Integer;
+function ff_check_M30_short_ex(i:Integer):Integer;
+
+
+
+function ff_check_short_1(i:Integer):Integer;
+function ff_check_short_1_ex(i:Integer):Integer;
+
+function ff_check_short_250(i:Integer):Integer;
+function ff_check_short_30(i:Integer):Integer;
+function ff_check_short_120(i:Integer):Integer;
+function ff_check_long_pass_3(i:Integer):Integer;
+function ff_long_pass_3_ex(i:Integer):Integer;
+
+function ff_make_long_MA30(i:Integer):Integer;
+function ff_make_long_MA60(i:Integer):Integer;
+function ff_make_long_MA250(i:Integer):Integer;
+
+function ff_short_pass3_mark(i:Integer):Integer;
+//function ff_pass3_short_250(i:Integer):Integer;
+function ff_pass3_short_120(i:Integer):Integer;
+
+
+function ff_make_mbm_long(i:Integer):Integer;
+function ff_make_mbm_short(i:Integer):Integer;
+
+function ff_4ma_make_mbm_long(i:Integer):Integer;
+function ff_4ma_make_mbm_short(i:Integer):Integer;
+
+function ff_main_wk_loop():Integer;
+function ff_get_qty():Integer;
+function ff_get_qty_ex():Integer;
+
+function ff_get_profit():Integer;
+
+function ff_cancel_entrust_no():Integer;
+function ff_entrust_no(pc_contract_code:PChar):Integer;
+function ff_order_ex(
+ pc_contract_code:PChar;
+ pc_entrust_price:PChar;
+ pc_entrust_amount:PChar;
+ pc_entrust_bs:PChar;
+ pc_direction:PChar ):Integer;
+
+function ff_passwd_chg(
+ pc_account:PChar;
+ pc_password_type:PChar;
+ pc_old_password:PChar;
+ pc_new_password:PChar ):Integer;
+
+
+function do_beep():Boolean;
+function ff_stop_do_beep():Boolean;
+
+function ff_do_main_loop():Integer;
+
+
+implementation
+
+//³õʼ»¯Í¨ÐŶÔÏó
+function FF_creat_comm_obj():Boolean;
+Var
+ i,j,i_count,j_count,k_count:Integer;
+ i_tmp,j_tmp,k_tmp:Integer;
+ i_index,j_index,k_index:Integer;
+
+
+ i_count_1,j_count_1,k_count_1:Integer;
+ i_tmp_1,j_tmp_1,k_tmp_1:Integer;
+ i_index_1,j_index_1,k_index_1:Integer;
+ s_tmp_log:string;
+
+begin
+ Result := False;
+
+ FF_load_allconf();
+ ff_rsi_w20_init();
+ ff_load_k_base();
+
+
+ //only for test
+ i_make_ex_test :=0;
+ i_count:=0;
+ j_count:=0;
+ k_count:=0;
+
+ i_count_1:=0;
+ j_count_1:=0;
+ k_count_1:=0;
+
+ //Assert(false,s_tmp_log);
+
+ if i_make_ex_test >0 Then for j := 80 to i_s_k_chg_index_wk-2 Do
+ begin
+
+ f_last_price_wk := as_k_chg[j].i_close/100;
+
+ if( Round(as_k_chg[j].i_date/10000) > Round(as_k_chg[j-1].i_date/10000) ) Then
+ begin
+ W_Log('MBM long sum',as_k_chg[j].i_date,i_mbm_log+6,PChar('4MA OK! Count:'+IntToStr(i_sum_long_mbm_count)+
+ ' short: ' + IntToStr(i_sum_short_mbm_count) +
+ ' long-short: ' + IntToStr(i_sum_long_mbm_count -i_sum_short_mbm_count) +
+ ' S-L: ' + IntToStr(i_sum_short_mbm_count -i_sum_long_mbm_count)
+
+ ) );
+ W_Log('MBM long 4ma sum',as_k_chg[j].i_date,i_mbm_log+7,PChar('4MA OK! Count:'+IntToStr(i_sum_4ma_long_mbm_count)+
+ ' short 4ma: ' + IntToStr(i_sum_4ma_short_mbm_count) +
+ ' 4ma L-S: ' + IntToStr(i_sum_4ma_long_mbm_count -i_sum_4ma_short_mbm_count) ) );
+ end;
+
+
+ ff_get_BS_Mark(j);
+
+ ff_4ma_make_mbm_long(j);
+ ff_4ma_make_mbm_short(j);
+
+ i_tmp_1 := ff_make_mbm_long(j);
+
+ if(i_tmp_1 =0) then
+ begin
+ i_tmp_1 := as_k_chg[j].i_close;
+ j_tmp_1 :=ff_get_max_ij_high(j,j+240);
+ k_tmp_1 :=ff_get_min_ij_low(j,j+240);
+ j_index_1:=ff_get_max_ij_index(j,j+240);
+ k_index_1:=ff_get_min_ij_index(j,j+240);
+
+ if(i_tmp_1-k_tmp_1 >1600 ) or (j_tmp_1-i_tmp_1<1000) then
+ begin
+ i_count_1:=i_count_1+1;
+ W_Log('MBM long',as_k_chg[j].i_date,i_mbm_log+1,
+ PChar('Buy:'+IntToStr(i_tmp_1) + '-BAD-' +'Cut Cut:'+IntToStr(k_tmp_1)+' i:'+IntToStr(j_index_1-k_index_1)+' j:'+IntToStr(j_index_1-j)+' k:'+IntToStr(k_index_1-j) ));
+ end
+ else
+ begin
+ j_count_1:=j_count_1+1;
+ W_Log('MBM long',as_k_chg[j].i_date,i_mbm_log+1,
+ PChar('Buy:'+IntToStr(i_tmp_1) + '-GOOD-' +'Stop Stop:'+IntToStr(j_tmp_1)+' i:'+IntToStr(j_index_1-k_index_1)+' j:'+IntToStr(j_index_1-j)+' k:'+IntToStr(k_index_1-j) ));
+ end;
+
+ end;
+
+ i_tmp := ff_make_mbm_short(j);
+
+ if(i_tmp =0) then
+ begin
+ i_tmp := as_k_chg[j].i_close;
+ j_tmp :=ff_get_max_ij_high(j,j+240);
+ k_tmp :=ff_get_min_ij_low(j,j+240);
+ j_index:=ff_get_max_ij_index(j,j+240);
+ k_index:=ff_get_min_ij_index(j,j+240);
+
+ if(j_tmp-i_tmp >1600 ) or (i_tmp-k_tmp<1000) then
+ //if(i_tmp-k_tmp >1600 ) or (j_tmp-i_tmp<1000) then
+ begin
+ i_count:=i_count+1;
+ W_Log('MBM short',as_k_chg[j].i_date,i_mbm_log,
+ PChar('Buy:'+IntToStr(i_tmp) + '-BAD-' +'Cut Cut:'+IntToStr(j_tmp)+' i:'+IntToStr(j_index-k_index)+' j:'+IntToStr(j_index-j)+' k:'+IntToStr(k_index-j) ));
+ end
+ else
+ begin
+ j_count:=j_count+1;
+ W_Log('MBM short',as_k_chg[j].i_date,i_mbm_log,
+ PChar('Buy:'+IntToStr(i_tmp) + '-GOOD-' + 'Stop Stop:'+IntToStr(k_tmp)+' i:'+IntToStr(j_index-k_index)+' j:'+IntToStr(j_index-j)+' k:'+IntToStr(k_index-j) ));
+ end;
+
+ end;
+
+
+ //ff_short_pass3_mark(j);
+ //ff_pass3_short_120(j);
+ //ff_make_mbm_long(j);
+ //ff_make_mbm_short(j);
+
+ //ff_get_BS_Mark(j);
+ //ff_make_long_MA30(j);
+ //ff_make_long_MA250(j);
+
+ //ff_check_short_1(j);
+ //ff_check_short_1_ex(j);
+ //ff_check_short_30(j);
+ //ff_check_short_250(j);
+ //ff_check_short_120(j);
+
+ //ff_long_pass_3_ex(j);
+ //ff_check_long_pass_3(j);
+
+ if as_k_chg[j].i_date = 1131314 then
+ begin
+ //ff_make_mbm_short(j);
+ //ff_short_pass3_mark(j);
+ //ff_pass3_short_120(j);
+
+ //ff_make_long_MA30(j);
+
+ //ff_check_long_pass_3(j);
+ //ff_check_short_250(j);
+ //ff_check_long_pass_3(j);
+ //ff_check_short_1(j);
+ //ff_check_short_1_ex(j);
+ end;
+ //ff_check_M30_short(j);
+ //ff_check_M30_short_ex(j);
+
+ //ff_check_rsi_w20(j);
+ //ff_check_rsi_w20_ex(j);
+
+ //ff_check_MA120_BB(j,3);
+ //ff_check_MA120_BB_ex(j);
+ //ff_check_BB_100(j,3);
+ //ff_check_BB_100_ex(j);
+ end;
+
+ if i_make_ex_test >0 Then W_Log('MBM long',88888,i_mbm_log+1,PChar('Stop:'+IntToStr(j_count_1) + '----------' + 'Cut:'+IntToStr(i_count_1) ));
+ if i_make_ex_test >0 Then W_Log('MBM short',888,i_mbm_log,PChar('Stop:'+IntToStr(j_count) + '----------' + 'Cut:'+IntToStr(i_count) ));
+
+ //for test
+ if i_make_ex_test >0 Then ExitProcess(888);
+ //only for test End
+
+ for j := 888 to i_s_k_chg_index_wk-2 Do
+ begin
+ //for short long lamp
+ ff_get_BS_Mark(j);
+
+ ff_4ma_make_mbm_long(j);
+ ff_4ma_make_mbm_short(j);
+
+ ff_make_mbm_long(j);
+ ff_make_mbm_short(j);
+ end;
+
+
+ //ºÜÖØÒª:¼ì²éһϰ汾ÊÇ·ñ·ûºÏ
+ if HSFUSDK_VERSION <> GetSDKVersion() then
+ begin
+ //MessageBox(Self.Handle,'Í·Îļþ°æ±¾Óë¿âÎļþ°æ±¾²»Æ¥Åä,½«¿ÉÄܵ¼Ö¼æÈÝÐÔÎÊÌâ!','°æ±¾¾¯¸æ',MB_OK or MB_ICONWARNING);
+ Exit;
+ end;
+
+ //µÚÒ»²½ ´´½¨Ò»¸öͨÐŶÔÏó
+ m_lpComm := NewFuCommObj(nil);
+ if nil = m_lpComm then
+ begin
+ //Form1.AddLog('´´½¨Í¨ÐŶÔÏóʧ°Ü');
+ Exit;
+ end;
+ //Form1.AddLog('´´½¨Í¨ÐŶÔÏóOK');
+ //´´½¨»Øµ÷¶ÔÏó
+ m_lpCallBack := TMyFuCallBack.Create;
+
+ FF_comm_obj_init();
+
+ //
+ if( i_comm_ok >0) then
+ begin
+ W_Log('create_thread',i_wk_log,i_wk_log,'call do_beep!');
+ do_beep();
+ end;
+end;
+
+//ÊÍ·ÅͨÐŶÔÏó
+function FF_release_comm_obj():Boolean;
+begin
+ Result := False;
+ if Assigned(m_lpComm) then
+ begin
+ //FileClose(iFileHandle);
+ if i_beeping >0 then ff_stop_do_beep();
+
+ m_lpComm.SubscribeRequest(UnKnownType,CxlAll,'ALLWWW');
+ m_lpComm.DoLogout(pc_username);
+ //¹Ø±Õ×Ô¶¯ÖØÁ¬Ïß³Ì
+ g_bStop := true;
+ SetEvent(g_hEvent);
+ Sleep(2000);
+ WaitForSingleObject(th_beep.Handle,10000);
+ CloseHandle(th_beep.Handle);
+ WaitForSingleObject(th_main_loop.Handle,10000);
+ CloseHandle(th_main_loop.Handle);
+
+ //¹Ø±ÕͨÐÅÁ¬½Ó
+ m_lpComm.Stop();
+ m_lpComm.Release();
+ m_lpComm := nil;
+ m_lpCallBack.Destroy;
+ end;
+end;
+
+function FF_comm_obj_init():Boolean;
+var
+ i_loop,iRet:Integer;
+ //szServer:string;
+ sLog:string;
+begin
+ Result := False;
+
+ //ºÜÖØÒª:¼ì²éһϰ汾ÊÇ·ñ·ûºÏ
+ if HSFUSDK_VERSION <> GetSDKVersion() then
+ begin
+ //MessageBox(Self.Handle,'Í·Îļþ°æ±¾Óë¿âÎļþ°æ±¾²»Æ¥Åä,½«¿ÉÄܵ¼Ö¼æÈÝÐÔÎÊÌâ!','°æ±¾¾¯¸æ',MB_OK or MB_ICONWARNING);
+ Exit;
+ end;
+
+ //szServer := '222.66.166.146:2800';
+ pc_IP := FF_ffconf(m_ff_main_ini,'Sever','IP');
+ pc_BLS:= FF_ffconf(m_ff_main_ini,'Sever','BLS');
+ pc_CLF:= FF_ffconf(m_ff_main_ini,'Sever','CLF');
+ pc_ENT:= FF_ffconf(m_ff_main_ini,'Sever','ENT');
+
+ pc_username:= FF_ffconf(m_ff_local_ini,'Main','FC');
+ pc_user_pwd:= FF_ffconf(m_ff_local_ini,'Main','FCPWD');
+
+ //sBiz:=
+ //sDatF:=
+ //sL:=
+ //ÉèÖÃÅäÖòÎÊý
+ m_lpComm.SetConfig('futu','server',pc_IP); //t2·þÎñÆ÷µØÖ·
+ //m_lpComm.SetConfig('futu','biz_license_str','31332263F984F45D4B07689AB3352E19'); //ÊÚȨҵÎñÖ¤Êé´®
+ //m_lpComm.SetConfig('futu','comm_license_file','fz_3rd.dat');//t2ͨÐÅÖ¤Êé
+ //m_lpComm.SetConfig('futu','entrust_type','L');//ίÍз½Ê½
+
+ m_lpComm.SetConfig('futu','biz_license_str',pc_BLS); //ÊÚȨҵÎñÖ¤Êé´®
+ m_lpComm.SetConfig('futu','comm_license_file',pc_CLF);//t2ͨÐÅÖ¤Êé
+
+ m_lpComm.SetConfig('futu','entrust_type',pc_ENT);//ίÍз½Ê½
+
+ //µÚ¶þ²½ ³õʼ»¯½Ó¿Ú¶ÔÏó
+ iRet := m_lpComm.Init(m_lpCallBack);
+ if 0<> iRet then
+ begin
+ //sLog := '½Ó¿Ú³õʼ»¯Ê§°Ü:'+m_lpComm.GetErrorMsg(iRet);
+ Exit;
+ end;
+
+ //³õʼ»¯³É¹¦
+ sLog := '½Ó¿Ú³õʼ»¯³É¹¦!';
+
+ iRet := m_lpComm.Start(SERVICE_TYPE_TRADE);
+ if 0 <> iRet then
+ begin
+ sLog := 'Æô¶¯½»Ò×Á¬½Óʧ°Ü:'+m_lpComm.GetErrorMsg(iRet);
+ W_Log('m_lpComm.Start',i_wk_log,i_wk_log,PChar(sLog));
+ Exit;
+ end;
+ //Form1.AddLog('´´½¨Í¨ÐŶÔÏóOK 999');
+ //½¨Á¢Í¨ÐÅÁ¬½Ó
+ iRet := m_lpComm.Start(SERVICE_TYPE_QUOTE);
+ if 0 <> iRet then
+ begin
+ sLog := 'Æô¶¯ÐÐÇéÁ¬½Óʧ°Ü:'+m_lpComm.GetErrorMsg(iRet);
+ W_Log('m_lpComm.Start',i_wk_log,i_wk_log,PChar(sLog));
+ Exit;
+ end;
+ //Form1.AddLog('´´½¨Í¨ÐŶÔÏóOK 1000');
+ //µÚÈý²½ Ò»ÇвÙ×÷´ÓµÇ½¿ªÊ¼
+
+ for i_loop := 0 to i_fc_count-1 Do
+ begin
+ if( as_fc_data[i_loop].pc_fcpwd = nil ) Then as_fc_data[i_loop].pc_fcpwd :=pc_user_pwd;
+
+ iRet := m_lpComm.DoLogin( as_fc_data[i_loop].pc_username ,as_fc_data[i_loop].pc_fcpwd,1);
+ if iRet <> 0 then
+ begin
+ sLog := 'µÇ½ʧ°Ü:'+IntToStr(iRet)+':'+m_lpComm.GetErrorMsg(iRet);
+ W_Log('DoLogin',i_wk_log,i_wk_log,PChar(sLog));
+ ExitProcess(199);
+ end;
+ //Form1.AddLog('´´½¨Í¨ÐŶÔÏóOK 1888');
+ end;
+
+ pc_username :=as_fc_data[i_fc_wk_index].pc_username;
+
+ s_caption_12:=pc_what_wk;
+
+ //¶©ÔÄÐÐÇé
+ m_lpComm.SubscribeRequest(SingleCode,Subscription,pc_what_wk);
+ m_lpComm.SubscribeRequest(RspReport,Subscription,pc_username);
+
+
+ //for password chg
+ //ff_passwd_chg(pc_username,'0',pc_user_pwd,'138688');
+
+ i_comm_ok :=888;
+
+ if (i_comm_ok=0) Then
+ begin
+ s_caption_3:='¶Ï¿ª';
+ end
+ else
+ begin
+ s_caption_3:='Áª»ú';
+ end;
+
+
+end;
+
+
+
+function FF_do_logout(pc_fund_account :PChar):Boolean;
+var
+ iRet:Integer;
+begin
+ //µÇ³ö
+ if Assigned(m_lpComm) then
+ begin
+ iRet := m_lpComm.DoLogout(pc_fund_account);
+ if 0 <> iRet then
+ begin
+ //Form1.AddLog('µÇ³öʧ°Ü:'+m_lpComm.GetErrorMsg(iRet));
+ end;
+ end;
+
+ Result :=True;
+
+end;
+
+
+
+
+{ TMyFuCallBack }
+ ////////////////////////////////////ÏûÏ¢»Øµ÷º¯ÊýʵÏÖ///////////////////////////////////////////////////
+function TMyFuCallBack.QueryInterface( const iid:PChar;ppv:Pointer ):Integer;
+begin
+ Result := 0;
+end;
+
+function TMyFuCallBack.AddRef():Integer;
+begin
+ Result := 0;
+end;
+
+function TMyFuCallBack.Release():Integer;
+begin
+ Result := 0;
+end;
+
+procedure TMyFuCallBack.OnConnStateNotify(lpInst: Pointer; iType:Integer;iRet: Integer; const szNotifyTime, szMsg: PChar);
+begin
+ //Form1.Addlog('Á¬½Ó״̬±ä»¯:'+szNotifyTime+'-> '+szMsg+':'+IntToStr(iType));
+ if iRet = 0 then//Á¬½Ó¶Ï¿ªÁË
+ begin
+ i_comm_ok:=0;
+ g_iType := iType;
+ SetEvent(g_hEvent);
+ end;
+end;
+
+procedure TMyFuCallBack.OnReceivedBiz(lpInst: Pointer;lpAnsData: IFuMessage;iRet:Integer;iKeyID:Integer);
+begin
+ //Form1.AddLog('ÊÕµ½Òì²½Ó¦´ðÏûÏ¢:type'+IntToStr(lpAnsData.GetMsgType()));
+ //Form1.ShowFuMessage(lpAnsData);
+end;
+
+procedure TMyFuCallBack.OnRecvOrderInfo(lpInst: Pointer;const lpInfo: LPCOrderRspInfo);
+begin
+ //Form1.AddLog('ÊÕµ½Î¯Íз´À¡ÏûÏ¢:type'+IntToStr(lpInfo.fund_account));
+end;
+
+procedure TMyFuCallBack.OnRecvOrderRealInfo(lpInst: Pointer;const lpInfo: LPCRealRspInfo);
+var
+ c_log :array [0..88] of char;
+ s_tmp:string;
+begin
+ //Form1.AddLog('ÊÕµ½³É½»·´À¡ÏûÏ¢:type'+IntToStr(lpInfo.fund_account));
+ //entrust_bs: array[0..8] of Char; //5 ÂòÂô±êʶ
+ //entrust_direction: array[0..8] of Char;//6 ¿ªÆ½±êʶ
+ //business_price: Double; //7 ³É½»¼Û¸ñ
+ //business_amount: Double; //8 ³É½»ÊýÁ¿
+
+ //for i_got_it_mark,i_short_mark ,etc ,gobal var error
+ Exit;
+
+ FillChar(c_log,SizeOf(c_log),0);
+
+ StrCopy(c_log,lpInfo.entrust_bs);
+
+ if c_log[0] = '2' Then
+ begin
+ FillChar(c_log,SizeOf(c_log),0);
+ StrCopy(c_log,lpInfo.entrust_direction);
+
+ //kaicang
+ if c_log[0]= '1' Then
+ begin
+ f_short_price :=lpInfo.business_price;
+ s_tmp:=FloatToStrF(lpInfo.business_price,ffFixed,8,2);
+ i_short_mark :=i_short_mark + Round(lpInfo.business_amount);
+
+ s_caption_9:='¿Õ '+Trim(s_tmp);
+ s_caption_11:=IntToStr(i_short_mark);
+
+ //MAINFORM.Label9.Caption :='¿Õ '+Trim(s_tmp);
+ //MAINFORM.Label11.Caption :=IntToStr(i_short_mark);
+
+ if(i_short_mark > (i_F + i_S -1)) then i_short_S_mark :=888 else i_short_S_mark :=0;
+ if(i_short_mark > (i_F + i_S + i_T -1)) then i_short_T_mark :=888 else i_short_T_mark :=0;
+ end;
+
+ //pingcang
+ if c_log[0]= '2' Then
+ begin
+ f_short_price :=lpInfo.business_price;
+ s_tmp:=FloatToStrF(lpInfo.business_price,ffFixed,8,2);
+ i_got_it_mark :=i_got_it_mark - Round(lpInfo.business_amount);
+
+ s_caption_8:='¶à '+Trim(s_tmp);
+ s_caption_10:=IntToStr(i_got_it_mark);
+ //MAINFORM.Label8.Caption :='¶à '+Trim(s_tmp);
+ //MAINFORM.Label10.Caption:=IntToStr(i_got_it_mark);
+
+ if(i_got_it_mark > (i_F + i_S -1) ) then i_get_S_mark :=888 else i_get_S_mark :=0;
+ if(i_got_it_mark > (i_F + i_S + i_T -1 )) then i_get_T_mark :=888 else i_get_T_mark:=0;
+ end;
+
+ end
+ else if c_log[0] = '1' Then
+ begin
+ FillChar(c_log,SizeOf(c_log),0);
+ StrCopy(c_log,lpInfo.entrust_direction);
+
+ //kaicang
+ if c_log[0]= '1' Then
+ begin
+ f_business_price :=lpInfo.business_price;
+ s_tmp:=FloatToStrF(lpInfo.business_price,ffFixed,8,2);
+ i_got_it_mark :=i_got_it_mark + Round(lpInfo.business_amount);
+
+ s_caption_8:='¶à '+Trim(s_tmp);
+ s_caption_10:=IntToStr(i_got_it_mark);
+
+ //MAINFORM.Label8.Caption :='¶à '+Trim(s_tmp);
+ //MAINFORM.Label10.Caption:=IntToStr(i_got_it_mark);
+
+ if(i_got_it_mark > (i_F + i_S -1) ) then i_get_S_mark :=888 else i_get_S_mark :=0;
+ if(i_got_it_mark > (i_F + i_S + i_T -1 )) then i_get_T_mark :=888 else i_get_T_mark:=0;
+ end;
+
+ //pingcang
+ if c_log[0]= '2' Then
+ begin
+
+ f_short_price :=lpInfo.business_price;
+ s_tmp:=FloatToStrF(lpInfo.business_price,ffFixed,8,2);
+ i_short_mark :=i_short_mark - Round(lpInfo.business_amount);
+
+ s_caption_9:='¿Õ '+Trim(s_tmp);
+ s_caption_11:=IntToStr(i_short_mark);
+
+ //MAINFORM.Label9.Caption :='¿Õ '+Trim(s_tmp);
+ //MAINFORM.Label11.Caption :=IntToStr(i_short_mark);
+
+ if(i_short_mark > (i_F + i_S -1)) then i_short_S_mark :=888 else i_short_S_mark :=0;
+ if(i_short_mark > (i_F + i_S + i_T -1)) then i_short_T_mark :=888 else i_short_T_mark :=0;
+ end;
+
+ end;
+
+ //frmMain2.CalcAll;
+ //frmMain2.GRID.Repaint;
+
+end;
+
+procedure TMyFuCallBack.OnRspArgMaketInfo(lpInst: Pointer;const lpData: LPCArgMarketInfo;rAction:REGAction);
+begin
+ //Form1.AddLog('ÊÕµ½×éºÏÐÐÇéÏûÏ¢.×éºÏ´úÂë:'+lpData.arbicontract_id);
+end;
+
+procedure TMyFuCallBack.OnRspLogin(lpInst: Pointer; lpMsg: IFuMessage);
+begin
+ //Form1.AddLog('Òì²½ÊÕµ½µÇ½Ӧ´ð:');
+ //Form1.ShowFuMessage(lpMsg);
+end;
+
+procedure TMyFuCallBack.OnRspLogout(lpInst: Pointer; lpMsg: IFuMessage);
+begin
+ //Form1.AddLog('Òì²½ÊÕµ½µÇ³öÓ¦´ð:');
+ //Form1.ShowFuMessage(lpMsg);
+end;
+
+procedure TMyFuCallBack.OnRspMarketInfo(lpInst: Pointer;const lpData: LPCMarketInfo;rAction:REGAction);
+var
+ //iFileHandle : Integer;
+ s_tmp:string;
+ i_loop :Integer;
+ i_tmp :Integer;
+begin
+ //cout<<"µ¥ÍÈÐÐÇé:("<futu_exch_type<<":"<contract_code<<")"<futu_last_price<<"\t"<sale_low_price<<"\t";
+ //cout<0) Then Exit;
+
+ s_tmp :=FloatToStrF(lpData.futu_last_price,ffFixed,8,2) + ' MA30' +
+
+ IntToStr(as_k_chg_ma_rsi[i_s_k_chg_index_wk].ai_ma[3]) + ' MA60' +
+ IntToStr(as_k_chg_ma_rsi[i_s_k_chg_index_wk].ai_ma[5]) + ' RSI6' +
+ IntToStr(as_k_chg_ma_rsi[i_s_k_chg_index_wk-1].ai_rsi[0]) + ' ' +
+ IntToStr(as_k_chg_ma_rsi[i_s_k_chg_index_wk].ai_rsi[0]) ;
+ tm_1 :=Now;
+
+ if( lpData.futu_last_price <10 ) Then Exit;
+
+ f_last_price_wk := lpData.futu_last_price;
+
+ //20120622 add
+ if(i_got_it_mark =0 ) Then i_long_FLOSS_MAX :=0;
+ if(i_got_it_mark >0 ) and
+ (f_last_price_wk - f_business_price < -3 ) then
+ begin
+ if i_long_FLOSS_MAX < Round(f_business_price - f_last_price_wk ) Then
+ i_long_FLOSS_MAX := Round(f_business_price - f_last_price_wk );
+ end;
+
+ if(i_short_mark =0 ) Then i_short_FLOSS_MAX :=0;
+ if(i_short_mark >0 ) and
+ (f_last_price_wk - f_business_price > 3 ) then
+ begin
+ if i_short_FLOSS_MAX < Round(f_last_price_wk - f_business_price ) Then
+ i_short_FLOSS_MAX := Round(f_last_price_wk - f_business_price );
+ end;
+ //20120622 add end
+
+ if i_s_k_chg_index_wk > 8 then f_last_price_1 := as_k_chg[i_s_k_chg_index_wk-1].i_close /100
+ else f_last_price_1 := f_last_price_wk;
+
+ if (i_get_price_count <1 ) or ( i_get_price_count > m_i_max_chg_kline_in_mem-8 ) then
+ begin
+ i_get_price_count :=0;
+ end;
+
+ if i_get_price_count = 0 then
+ begin
+ s_tmp := FormatDateTime('mmddhhnn',Now);
+ as_k_chg[i_s_k_chg_index_wk].i_date := StrToInt(s_tmp);
+
+ as_k_chg[i_s_k_chg_index_wk].i_open := Round(lpData.futu_last_price * 100);
+ as_k_chg[i_s_k_chg_index_wk].i_close :=Round(lpData.futu_last_price * 100);
+ as_k_chg[i_s_k_chg_index_wk].i_high := Round(lpData.futu_last_price * 100);
+ as_k_chg[i_s_k_chg_index_wk].i_low := Round(lpData.futu_last_price * 100);
+
+ tm_0 :=Now;
+
+ FillChar(as_vol_data,sizeof(as_vol_data),0);
+
+ for i_loop := 0 to 19 Do
+ begin
+ as_vol_data[i_loop].tm_0 :=Now;
+ as_vol_data[i_loop].i_business_amount := Round(lpData.business_amount);
+ end;
+
+ end;
+
+ //for vol display
+ tm_2 :=Now;
+
+ if( i_vol_start =888 ) and ( i_vol_reset =0 ) Then
+ begin
+ i_vol_0 := Round(lpData.business_amount);
+ i_vol_start :=999;
+ tdt_vol_0 :=Now;
+ end;
+
+ if( i_vol_start =999 ) and ( i_vol_reset =0 ) Then
+ begin
+ i_vol_1:= Round(lpData.business_amount) - i_vol_0;
+ i_tmp :=SecondsBetween(tdt_vol_0,tm_2);
+ if (i_tmp < 59) Then
+ begin
+ s_caption_vol :=IntToStr(i_tmp) + ' : ' + IntToStr(Round((60 /(i_tmp+1)) * i_vol_1));
+ end
+ else
+ begin
+ i_vol_0 := Round(lpData.business_amount);
+ i_vol_start :=999;
+ tdt_vol_0 :=Now;
+ end;
+ end;
+
+ for i_loop := 0 to 19 Do
+ begin
+ if (SecondsBetween(as_vol_data[i_loop].tm_0,tm_2) > ((i_loop+1)*3-1) ) Then
+ begin
+ as_vol_data[i_loop].tm_0:=tm_2;
+ as_vol_data[i_loop].i_vol := Round(lpData.business_amount) - as_vol_data[i_loop].i_business_amount;
+ as_vol_data[i_loop].i_business_amount := Round(lpData.business_amount);
+ end;
+ end;
+
+ if( i_vol_start =0 ) and ( i_vol_reset =0 ) Then
+ begin
+ s_caption_vol :=IntToStr(as_vol_data[7].i_vol + as_vol_data[2].i_vol* 2 + as_vol_data[1].i_vol * 2 + as_vol_data[0].i_vol*2 ) ;
+ end;
+
+ if i_as_k_chg_init_flag = 0 then
+ begin
+ FillChar(as_k_chg,SizeOf(as_k_chg),0);
+ FillChar(as_k_chg_ma_rsi,sizeof(as_k_chg_ma_rsi),0);
+ i_as_k_chg_init_flag :=888;
+ i_s_k_chg_index_wk :=0;
+
+ s_tmp := FormatDateTime('mmddhhnn',Now);
+
+ as_k_chg[i_s_k_chg_index_wk].i_date := StrToInt(s_tmp);
+ as_k_chg[i_s_k_chg_index_wk].i_open := Round(lpData.futu_last_price * 100);
+ as_k_chg[i_s_k_chg_index_wk].i_close :=Round(lpData.futu_last_price * 100);
+ as_k_chg[i_s_k_chg_index_wk].i_high := Round(lpData.futu_last_price * 100);
+ as_k_chg[i_s_k_chg_index_wk].i_low := Round(lpData.futu_last_price * 100);
+
+ tm_0 :=Now;
+ end;
+
+ s_tmp := FormatDateTime('hhnn',Now);
+
+ if (SecondsBetween(tm_0,tm_1) > 59 ) or
+ ( (SecondsBetween(tm_0,tm_1) > 50 ) and (i_will_close_market = 888) ) then
+ Begin
+ {
+ Form1.AddLog('ÊÕµ½µ¥ÍÈÐÐÇéÊý¾Ý:'+lpData.contract_code +' ' +
+ FloatToStrF(lpData.futu_last_price,ffFixed,8,2) + ' MA30' +
+ IntToStr(as_k_chg_ma_rsi[i_s_k_chg_index_wk].ai_ma[3]) + ' MA60' +
+ IntToStr(as_k_chg_ma_rsi[i_s_k_chg_index_wk].ai_ma[5]) + ' RSI6' +
+ IntToStr(as_k_chg_ma_rsi[i_s_k_chg_index_wk-1].ai_rsi[0]) + ' ' +
+ IntToStr(as_k_chg_ma_rsi[i_s_k_chg_index_wk].ai_rsi[0]) +' ' +
+ IntTostr(i_got_it_mark) + ' ' +
+ FloatToStrF(f_business_price,ffFixed,8,2) );
+ }
+
+ as_k_chg[i_s_k_chg_index_wk].i_close := Round(lpData.futu_last_price * 100);
+ as_k_chg[i_s_k_chg_index_wk].i_pre_close := Round(lpData.business_amount);
+
+ if as_k_chg[i_s_k_chg_index_wk].i_close > as_k_chg[i_s_k_chg_index_wk].i_high then
+ as_k_chg[i_s_k_chg_index_wk].i_high:= as_k_chg[i_s_k_chg_index_wk].i_close;
+ if as_k_chg[i_s_k_chg_index_wk].i_close < as_k_chg[i_s_k_chg_index_wk].i_low then
+ as_k_chg[i_s_k_chg_index_wk].i_low:= as_k_chg[i_s_k_chg_index_wk].i_close;
+
+ if i_s_k_chg_index_wk > i_s_k_chg_index_load then
+ as_k_chg[i_s_k_chg_index_wk].i_vol:= as_k_chg[i_s_k_chg_index_wk].i_pre_close-as_k_chg[i_s_k_chg_index_wk-1].i_pre_close;
+
+ s_tmp := FormatDateTime('mmddhhnn',Now);
+ as_k_chg[i_s_k_chg_index_wk].i_date := StrToInt(s_tmp);
+
+ s_tmp := FormatDateTime('hhnn',Now);
+ if( s_tmp = '1514' ) Then i_will_close_market := 888;
+
+ s_tmp := FormatDateTime('nn',Now);
+
+ tm_0 :=Now;
+ tm_1 :=Now;
+
+ iFileHandle :=FileOpen(m_k_line_file_name,fmOpenWrite);
+ if iFileHandle > 0 Then
+ begin
+
+ if( as_k_chg[i_s_k_chg_index_wk].i_vol =0 ) and ( s_tmp = '15' ) then
+ as_k_chg[i_s_k_chg_index_wk].i_vol := Round(lpData.business_amount);
+
+ FileSeek(iFileHandle,0,2);
+ if ( as_k_chg[i_s_k_chg_index_wk].i_close <100 ) or
+ ( as_k_chg[i_s_k_chg_index_wk].i_high <100 ) or
+ ( as_k_chg[i_s_k_chg_index_wk].i_low <100 ) or
+ ( as_k_chg[i_s_k_chg_index_wk].i_vol =0 ) or
+ ( as_k_chg[i_s_k_chg_index_wk].i_open <100 ) Then
+ begin
+ FileClose(iFileHandle);
+ end
+ else
+ begin
+ FileWrite(iFileHandle, as_k_chg[i_s_k_chg_index_wk], SizeOf(s_k_line_data));
+ FileClose(iFileHandle);
+ //for FF_300k
+ //try
+
+ //frmMain2.StkDataFile.writeStkDataToM(1,@as_k_chg[i_s_k_chg_index_wk]);
+ //except
+ // W_Log('try_except_0',1119,999,'StkDataFile.writeStkDataToM exception');
+ //end;
+ end;
+ end;
+
+
+
+ ff_make_ma_rsi_ex(i_s_k_chg_index_wk);
+
+ i_s_k_chg_index_wk_bak:=i_s_k_chg_index_wk;
+
+ s_tmp := FormatDateTime('mmddhhnn',Now);
+ as_k_chg[i_s_k_chg_index_wk+1].i_date := StrToInt(s_tmp);
+
+ if i_s_k_chg_index_wk > m_i_max_chg_kline_in_mem -8 then
+ begin
+ FillChar(as_k_chg,SizeOf(as_k_chg),0);
+ FillChar(as_k_chg_ma_rsi,sizeof(as_k_chg_ma_rsi),0);
+ i_as_k_chg_init_flag :=888;
+ i_s_k_chg_index_wk :=0;
+ end;
+
+ as_k_chg[i_s_k_chg_index_wk+1].i_open := Round(lpData.futu_last_price * 100);
+ as_k_chg[i_s_k_chg_index_wk+1].i_close :=Round(lpData.futu_last_price * 100);
+ as_k_chg[i_s_k_chg_index_wk+1].i_high := Round(lpData.futu_last_price * 100);
+ as_k_chg[i_s_k_chg_index_wk+1].i_low := Round(lpData.futu_last_price * 100);
+ //try
+ //frmMain2.StkDataFile.writeStkDataToM(0,@as_k_chg[i_s_k_chg_index_wk]);
+ //except
+ // W_Log('try_except_1',11119,999,'StkDataFile.writeStkDataToM exception');
+ //end;
+ //frmMain2.CalcAll;
+ //frmMain2.GRID.Repaint;
+
+ i_s_k_chg_index_wk:=i_s_k_chg_index_wk+1;
+ ff_make_ma_rsi_ex(i_s_k_chg_index_wk);
+ end
+ else
+ begin
+ as_k_chg[i_s_k_chg_index_wk].i_close := Round(lpData.futu_last_price * 100);
+ ff_make_ma_rsi_ex(i_s_k_chg_index_wk);
+
+ if as_k_chg[i_s_k_chg_index_wk].i_close > as_k_chg[i_s_k_chg_index_wk].i_high then
+ as_k_chg[i_s_k_chg_index_wk].i_high:= as_k_chg[i_s_k_chg_index_wk].i_close;
+ if as_k_chg[i_s_k_chg_index_wk].i_close < as_k_chg[i_s_k_chg_index_wk].i_low then
+ as_k_chg[i_s_k_chg_index_wk].i_low:= as_k_chg[i_s_k_chg_index_wk].i_close;
+
+ //if i_s_k_chg_index_wk > i_s_k_chg_index_load then
+ // as_k_chg[i_s_k_chg_index_wk].i_vol:= as_k_chg[i_s_k_chg_index_wk].i_pre_close-as_k_chg[i_s_k_chg_index_wk-1].i_pre_close;
+
+ //try
+ // frmMain2.StkDataFile.writeStkDataToM(1,@as_k_chg[i_s_k_chg_index_wk]);
+ //except
+ // W_Log('try_except_2',1119,999,'StkDataFile.writeStkDataToM exception');
+ //end;
+
+
+ end;
+
+ if(i_long_mbm_count > 0) Then
+ begin
+ //frmMain2.GRID_S002.Cells[0,0]:='L5 ' + IntToStr(i_long_mbm_count);
+ //frmMain2.GRID_S002.Cells[1,0]:='L4 ' + IntToStr(i_4ma_long_mbm_count);
+ end;
+
+ if(i_short_mbm_count > 0) Then
+ begin
+ //frmMain2.GRID_S002.Cells[0,0]:='S5 ' + IntToStr(i_short_mbm_count);
+ //frmMain2.GRID_S002.Cells[1,0]:='S4 ' + IntToStr(i_4ma_short_mbm_count);
+ end;
+
+
+ //frmMain2.GRID_S002.Cells[0,1]:='RSI';
+ //frmMain2.GRID_S002.Cells[1,1]:=FloatToStrF(as_k_chg_ma_rsi[i_s_k_chg_index_wk].ai_rsi[0]/100,ffFixed,7,2);
+
+ //MAINFORM.Label1.Caption:='Âô '+FloatToStrF(lpData.sale_low_price,ffFixed,7,2);
+ //MAINFORM.Label2.Caption:=IntToStr(lpData.sale_low_amount);
+
+ //MAINFORM.Label5.Caption:='Âò '+FloatToStrF(lpData.buy_high_price,ffFixed,7,2);
+ //MAINFORM.Label6.Caption:=IntToStr(lpData.buy_high_amount);
+
+ //MAINFORM.Label7.Caption:=pc_username;
+
+ s_caption_1:='Âô '+FloatToStrF(lpData.sale_low_price,ffFixed,7,2);
+ s_caption_2:=IntToStr(lpData.sale_low_amount);
+
+ s_caption_5:='Âò '+FloatToStrF(lpData.buy_high_price,ffFixed,7,2);
+ s_caption_6:=IntToStr(lpData.buy_high_amount);
+
+ s_caption_7:=pc_username;
+
+ f_buy_1 :=lpData.buy_high_price;
+ f_sale_1 :=lpData.sale_low_price;
+
+ //for
+ if ( (i_get_price_count mod 18 ) =0 ) Then
+ begin
+ //frmMain2.CalcAll;
+ //frmMain2.GRID.Repaint;
+ //frmMain2.GridSxxxRePaint;
+ end;
+
+ i_get_price_count:=i_get_price_count+1;
+
+end;
+
+procedure TMyFuCallBack.OnRspOnlineMsg(lpInst: Pointer; szUsrID,szMessage: PChar);
+begin
+ //Form1.AddLog('ÊÕµ½ÔÚÏßÏûÏ¢.');
+end;
+
+procedure TMyFuCallBack.OnRspSubResult(lpInst: Pointer; sType: REGType;aAction: REGAction; iResult: Integer; const lpParam, szMsg: PChar);
+begin
+ //Form1.AddLog('ÊÕµ½¶©ÔĽá¹ûÓ¦´ð.');
+end;
+
+
+
+
+//from cpp
+function ff_get_rsi(ii:Integer;jj:Integer) :Integer;
+var
+ n :Integer;
+ i :Integer;
+ j :Integer;
+ sum1:Single;
+ sum2:Single;
+ AX1:Double;
+ BX1:Double;
+begin
+ n := ai_rsi_set[jj];
+
+ for i:=0 to ii do
+ begin
+
+ if( i < n+8 ) Then
+ begin
+ as_k_chg_ma_rsi[i].ai_rsi[jj] :=5000;
+ Continue;
+ end;
+
+ sum1:=0.0;
+ sum2:=0.0;
+
+ for j:=0 to n-1 do
+ begin
+ if(as_k_chg[i - j].i_close > as_k_chg[(i - j) - 1].i_close) Then
+ sum1 := sum1 + as_k_chg[i - j].i_close/100 - as_k_chg[(i - j) - 1].i_close/100
+ else
+ if(as_k_chg[i - j].i_close < as_k_chg[(i - j) - 1].i_close) Then
+ sum2 := sum2 + as_k_chg[(i - j) - 1].i_close/100 - as_k_chg[i - j].i_close/100;
+
+ end;
+
+ AX1 := sum1/n;
+ BX1 := sum2/n;
+
+ if ( sum1 < 0.001 ) and (sum2 <0.001) Then
+ begin
+ Result :=0;
+ as_k_chg_ma_rsi[i].ai_rsi[jj] :=as_k_chg_ma_rsi[i-1].ai_rsi[jj];
+ Exit;
+ end;
+
+ BX1 := 10000.0 *2*(AX1/(AX1+BX1)/3.0);
+
+ as_k_chg_ma_rsi[i].ai_rsi[jj] :=Round( as_k_chg_ma_rsi[i-1].ai_rsi[jj]/3) + Round(BX1);
+ //as_k_chg_ma_rsi[i].ai_rsi[jj] :=Round(BX1);
+
+ end;
+
+ Result :=0;
+end;
+
+
+
+function ff_get_ma(i:Integer;j:Integer) :Integer;
+var
+ k :Integer;
+ f_tmp :Single;
+begin
+ f_tmp :=0.0;
+ for k:=i - ai_ma_set[j]+1 to i do f_tmp:=f_tmp+as_k_chg[k].i_close;
+ as_k_chg_ma_rsi[i].ai_ma[j] := Round(f_tmp/ai_ma_set[j]);
+ Result :=0;
+end;
+
+
+//from cpp
+function ff_get_rsi_ex(i:Integer;jj:Integer) :Integer;
+var
+ n :Integer;
+ j :Integer;
+ sum1:Single;
+ sum2:Single;
+ AX1:Double;
+ BX1:Double;
+begin
+ n := ai_rsi_set[jj];
+ Result :=0;
+
+ if( i < 88 ) Then
+ begin
+ as_k_chg_ma_rsi[i].ai_rsi[jj] :=5000;
+ Exit;
+ end;
+
+ sum1:=0.0;
+ sum2:=0.0;
+
+ for j:=0 to n-1 do
+ begin
+ if(as_k_chg[i - j].i_close > as_k_chg[(i - j) - 1].i_close) Then
+ sum1 := sum1 + as_k_chg[i - j].i_close/100 - as_k_chg[(i - j) - 1].i_close/100
+ else
+ if(as_k_chg[i - j].i_close < as_k_chg[(i - j) - 1].i_close) Then
+ sum2 := sum2 + as_k_chg[(i - j) - 1].i_close/100 - as_k_chg[i - j].i_close/100;
+
+ end;
+
+ AX1 := sum1/n;
+ BX1 := sum2/n;
+
+ if ( sum1 < 0.001 ) and (sum2 <0.001) Then
+ begin
+ Result :=0;
+ as_k_chg_ma_rsi[i].ai_rsi[jj] :=as_k_chg_ma_rsi[i-1].ai_rsi[jj];
+ Exit;
+ end;
+
+
+ BX1 := 10000.0 *2*(AX1/(AX1+BX1)/3.0);
+
+ as_k_chg_ma_rsi[i].ai_rsi[jj] :=Round( as_k_chg_ma_rsi[i-1].ai_rsi[jj]/3) + Round(BX1);
+
+ Result :=0;
+end;
+
+
+
+function ff_get_max_ij_high(i:Integer;j:Integer) :Integer;
+var
+ k :Integer;
+ i_m :Integer;
+begin
+ i_m :=as_k_chg[i].i_high;
+ for k:=i to j do if Integer(as_k_chg[k].i_high) > i_m then i_m :=as_k_chg[k].i_high;
+ Result :=i_m;
+end;
+
+function ff_get_max_ij_index(i:Integer;j:Integer) :Integer;
+var
+ k :Integer;
+ i_m :Integer;
+ i_index :Integer;
+begin
+ i_m :=as_k_chg[i].i_high;
+ i_index :=i;
+ for k:=i to j do if Integer(as_k_chg[k].i_high) > i_m then
+ begin
+ i_m :=as_k_chg[k].i_high;
+ i_index :=k;
+ end;
+ Result :=i_index;
+end;
+
+function ff_get_min_ij_low(i:Integer;j:Integer) :Integer;
+var
+ k :Integer;
+ i_m :Integer;
+begin
+ i_m :=as_k_chg[i].i_low;
+ for k:=i to j do if Integer(as_k_chg[k].i_low) < i_m then i_m :=as_k_chg[k].i_low;
+ Result :=i_m;
+end;
+
+function ff_get_min_ij_index(i:Integer;j:Integer) :Integer;
+var
+ k :Integer;
+ i_m :Integer;
+ i_index :Integer;
+begin
+ i_index :=i;
+ i_m :=as_k_chg[i].i_low;
+ for k:=i to j do if Integer(as_k_chg[k].i_low) < i_m then
+ begin
+ i_m :=as_k_chg[k].i_low;
+ i_index :=k;
+ end;
+ Result :=i_index;
+end;
+
+function ff_make_ma_rsi_ex(ii:Integer) :Integer;
+var
+ j :Integer;
+begin
+ for j:=0 to m_ma_max_index do if( ii > ai_ma_set[j]-1 ) Then ff_get_ma(ii,j);
+ for j:=0 to 5 do ff_get_rsi_ex(ii,j);
+ Result :=0;
+end;
+
+
+function ff_make_ma_rsi() :Integer;
+var
+ i :Integer;
+ j :Integer;
+begin
+
+ for i:=0 to i_s_k_chg_index_wk do
+ begin
+ for j:=0 to m_ma_max_index do if( i > ai_ma_set[j]-1 ) Then ff_get_ma(i,j);
+ end;
+
+ i := i_s_k_chg_index_wk;
+
+ for j:=0 to 5 do ff_get_rsi(i,j);
+
+ Result :=0;
+end;
+
+function ff_check_rsi_w20(i:Integer):Integer;
+var
+ j :Integer;
+ k :Integer;
+begin
+
+ Result := -1;
+ if ( i< 88 ) Then Exit;
+
+ if(i_act_rsi = 0) then Exit;
+
+ if(i_w20_mark = 888) Then Exit;
+
+ if (as_k_chg_ma_rsi[i].ai_rsi[0] > 6000) or (as_k_chg_ma_rsi[i].ai_rsi[0] < 2100) Then Exit;
+
+ if (as_k_chg_ma_rsi[i-1].ai_rsi[0] < Cardinal(i_rsi_A)) or
+ (as_k_chg_ma_rsi[i-2].ai_rsi[0] < Cardinal(i_rsi_A)) or
+ (as_k_chg_ma_rsi[i-3].ai_rsi[0] < Cardinal(i_rsi_A)) Then
+ begin
+ for j := 0 to i_rsi_AB Do
+ if as_k_chg_ma_rsi[i-j-2].ai_rsi[0] > Cardinal(i_rsi_B) Then
+ begin
+ for k := 0 to i_rsi_BC Do
+ if as_k_chg_ma_rsi[i-j-k-2].ai_rsi[0] < Cardinal(i_rsi_C) Then
+ begin
+
+ W_Log('W20',as_k_chg[i].i_date,i_wk_log,'RSI W20!');
+
+ Result :=-2;
+ i_w20_mark :=888;
+ i_w20_C_index :=i-j-k-2;
+ i_w20_B_index :=i-j-2;
+ i_w20_A_index :=i-1;
+ Exit;
+ end;
+ end;
+ End;
+
+ Result :=-1;
+
+end;
+
+function ff_check_MA120_BB(i:Integer;i_ma_index :Integer):Integer;
+var
+ j :Integer;
+ n :Integer;
+ a :Integer;
+ b :Integer;
+ c :Integer;
+begin
+
+ Result := -1;
+
+ if (i_act_m120 = 0) then exit;
+
+ if ( i< 888 ) Then Exit;
+
+ if ( i - i_MA120_BB_mark > i_BB_BOX_X*3 ) Then i_MA120_BB_mark:=0;
+
+ if(i_MA120_BB_mark >888) Then Exit;
+
+ //ai_ma[6] for MA120
+ if( as_k_chg[i].i_close < as_k_chg_ma_rsi[i-1].ai_ma[6] - 100 ) Then Exit;
+
+ if( as_k_chg[i].i_close > as_k_chg_ma_rsi[i-1].ai_ma[6] +800 ) Then Exit;
+
+ if( as_k_chg_ma_rsi[i].ai_ma[i_ma_index] < (as_k_chg_ma_rsi[i].ai_ma[6] ) ) Then Exit;
+
+ n := ff_get_min_ij_index(i-i_BB_BOX_X-2,i);
+
+ c := ff_get_max_ij_index(i-5*i_BB_BOX_X,n);
+
+ b := ff_get_min_ij_index(c-8*i_BB_BOX_X,c);
+
+ a := ff_get_max_ij_index(b-8*i_BB_BOX_X,b);
+
+ if ( Integer(as_k_chg[a].i_high + 800 ) < ff_get_max_ij_high(a,n) ) Then Exit;
+
+ //MA30 < MA120
+ for j := a - i_BB_BOX_X*2 to n - i_BB_BOX_X Do
+ begin
+ if as_k_chg_ma_rsi[j].ai_ma[i_ma_index] > as_k_chg_ma_rsi[j].ai_ma[6] then Exit;
+ end;
+
+ if( c > (n - i_BB_BOX_X + 2 ) ) Then Exit;
+
+ if as_k_chg[c].i_high >( as_k_chg[n].i_close + 1600) Then Exit;
+
+ if (as_k_chg[a].i_high > (as_k_chg[c].i_high + 600) ) Then Exit;
+
+ if (as_k_chg[c].i_high > (as_k_chg[a].i_high + 600) ) Then Exit;
+
+ if (as_k_chg[n].i_low < as_k_chg[b].i_low ) Then Exit;
+
+ if (as_k_chg[n].i_close - as_k_chg[b].i_low) < Round(( as_k_chg[c].i_high - as_k_chg[b].i_low)/3) Then Exit;
+ if (as_k_chg[n].i_close - as_k_chg[b].i_low) < Round(( as_k_chg[a].i_high - as_k_chg[b].i_low)/3) Then Exit;
+
+ if( b - a < i_BB_BOX_X*2 ) Then Exit;
+ if( c - b < i_BB_BOX_X ) Then Exit;
+ if( i - n < 2 ) Then Exit;
+
+ i_MA120_BB_c :=c;
+ i_MA120_BB_n :=n;
+ i_MA120_BB_i :=i;
+ i_MA120_BB_mark := i;
+
+ W_Log('M120 BB',i_tmp_log,i_make_log_ex,'n !!!');
+ W_Log('M120 BB',i_tmp_log,i_make_log_ex,'c !!!');
+ W_Log('M120 BB',i_tmp_log,i_make_log_ex,'b !!!');
+ W_Log('M120 BB',i_tmp_log,i_make_log_ex,'a !!!');
+
+ Result :=-1;
+
+end;
+
+function ff_check_MA120_BB_ex(i:Integer):Integer;
+begin
+ Result := -1;
+ if ( i< 888 ) Then Exit;
+
+ if ( i - i_MA120_BB_mark > i_BB_BOX_X*2 ) Then i_MA120_BB_mark:=0;
+
+ if ( i_MA120_BB_mark =0 ) Then Exit;
+
+ W_Log('M120_BB_EX',i_tmp_log,i_make_log_ex,'1 888!!!');
+
+ if( f_last_price_wk < ff_get_min_ij_low(i_MA120_BB_n,i_MA120_BB_i)/100 -2.0 ) Then
+ begin
+ W_Log('M120_BB_EX',i_tmp_log,i_make_log_ex,'2 888!!!');
+
+ i_MA120_BB_mark:=0;
+ end;
+
+ if( f_last_price_wk > (as_k_chg[i_MA120_BB_c].i_high /100+ 5.0) ) Then
+ begin
+ W_Log('M120_BB_EX',i_tmp_log,i_make_log_ex,'2.5 f_last_price_wk 888!!!');
+
+ W_Log('M120_BB_EX',i_tmp_log,i_make_log_ex,'3 888!!!');
+ i_MA120_BB_mark:=0;
+ end;
+
+ W_Log('M120_BB_EX',i_tmp_log,i_make_log_ex,'4 888!!!');
+
+ if ( i_MA120_BB_mark =0 ) Then Exit;
+
+ W_Log('M120_BB_EX',i_tmp_log,i_make_log_ex,'5 f_last_price_wk 888!!!');
+ W_Log('M120_BB_EX',i_tmp_log,i_make_log_ex,'6 max high!!');
+
+ if( f_last_price_wk > ff_get_max_ij_high(i_MA120_BB_n,i_MA120_BB_i)/100 ) and
+ ( f_last_price_wk < ( ff_get_max_ij_high(i_MA120_BB_n,i_MA120_BB_i)/100 + 5 )) then
+ begin
+ W_Log('M120_BB_EX',as_k_chg[i].i_date,i_wk_log,'88888888!!!');
+ Result :=0;
+ i_MA120_BB_mark :=0;
+ Exit;
+ end;
+ Result :=-1;
+
+end;
+
+
+
+function ff_check_rsi_w20_ex(i:Integer):Integer;
+begin
+
+ Result := -1;
+ if ( i< 88 ) Then Exit;
+
+ if(i_w20_mark = 0) Then Exit;
+
+ if i_w20_A_index > i-i_rsi_IA_min Then Exit;
+
+ //if i - i_w20_A_index > i_rsi_IA_max Then i_w20_mark :=0;
+
+ if(f_last_price_wk < (ff_get_min_ij_low(i_w20_A_index,i-i_rsi_IA_min)/100-1.0) ) Then
+ begin
+ i_w20_mark :=0;
+ end;
+
+ if(f_last_price_wk > (ff_get_max_ij_high(i_w20_A_index,i-i_rsi_IA_max)/100+5.0) ) Then
+ begin
+ i_w20_mark :=0;
+ end;
+
+ if(i_w20_mark = 0) Then Exit;
+
+ if( ff_get_max_ij_high(i_w20_A_index,i-2) - ff_get_min_ij_low(i_w20_A_index,i-2) < i_BOX_Y ) then
+ begin
+ if( f_last_price_wk > (ff_get_max_ij_high(i_w20_A_index,i_w20_A_index + i_rsi_IA_min)/100 + 1.0)) and
+ ( f_last_price_wk < (ff_get_max_ij_high(i_w20_A_index,i_w20_A_index + i_rsi_IA_min)/100 + 5.0)) then
+ begin
+ W_Log('W20_EX',as_k_chg[i].i_date,i_wk_log,'888888 !!!');
+ Result :=0;
+ i_w20_mark :=0;
+ Exit;
+ end;
+ end
+ else
+ begin
+ i_w20_mark :=0;
+ end;
+
+ Result :=-1;
+
+end;
+
+
+function ff_check_BB_100(i:Integer;i_ma_index :Integer):Integer;
+var
+ j :Integer;
+ n :Integer;
+ a :Integer;
+ b :Integer;
+ c :Integer;
+begin
+
+ Result := -1;
+
+ if(i_act_bb_100= 0) then exit;
+
+ if ( i< 888 ) Then Exit;
+
+ if ( i - i_BB_100_mark > i_BB_100_BOX_X*5 ) Then i_BB_100_mark:=0;
+
+ if(i_BB_100_mark >888) Then Exit;
+
+ //ai_ma[6] for MA120
+ if( as_k_chg[i].i_close < as_k_chg_ma_rsi[i-1].ai_ma[6] - 100 ) Then Exit;
+ if( as_k_chg[i].i_close > as_k_chg_ma_rsi[i-1].ai_ma[6] +1200 ) Then Exit;
+
+ if( as_k_chg_ma_rsi[i].ai_ma[3] < (as_k_chg_ma_rsi[i].ai_ma[6] ) ) Then Exit;
+ if( as_k_chg_ma_rsi[i].ai_ma[5] < (as_k_chg_ma_rsi[i].ai_ma[6] ) ) Then Exit;
+
+ n := ff_get_min_ij_index(i-i_BB_100_BOX_X-2,i);
+
+ c := ff_get_max_ij_index(i-5*i_BB_100_BOX_X,n);
+
+ b := ff_get_min_ij_index(c-12*i_BB_100_BOX_X,c);
+
+ a := ff_get_max_ij_index(b-12*i_BB_100_BOX_X,b);
+
+ if ( Integer(as_k_chg[a].i_high + 800 ) < ff_get_max_ij_high(a,n) ) Then Exit;
+
+ if ( Integer(as_k_chg[a].i_high - as_k_chg[b].i_low) > Round( (Integer(as_k_chg[a].i_high) - ff_get_min_ij_low(a-12*i_BB_100_BOX_X,a) )/2) ) Then Exit;
+
+
+ //MA30 < MA120
+ for j := a - i_BB_100_BOX_X*2 to n - i_BB_100_BOX_X Do
+ begin
+ if as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[6] then Exit;
+ if as_k_chg_ma_rsi[j].ai_ma[5] < (as_k_chg_ma_rsi[j].ai_ma[6] - 200) then Exit;
+ if( as_k_chg[j].i_close < as_k_chg_ma_rsi[j-1].ai_ma[6] - 100 ) Then Exit;
+ end;
+
+ if( c > (n - i_BB_100_BOX_X + 2 ) ) Then Exit;
+
+ if as_k_chg[c].i_high > (as_k_chg[n].i_close + 2800) Then Exit;
+
+ if (as_k_chg[a].i_high > (as_k_chg[c].i_high + 1200) ) Then Exit;
+
+ if (as_k_chg[c].i_high > (as_k_chg[a].i_high + 1200) ) Then Exit;
+
+ if (as_k_chg[n].i_low < as_k_chg[b].i_low ) Then Exit;
+
+ if (as_k_chg[n].i_close - as_k_chg[b].i_low) < Round(( as_k_chg[c].i_high - as_k_chg[b].i_low)/3) Then Exit;
+ if (as_k_chg[n].i_close - as_k_chg[b].i_low) < Round(( as_k_chg[a].i_high - as_k_chg[b].i_low)/3) Then Exit;
+
+ if( b - a < i_BB_100_BOX_X*2 ) Then Exit;
+ if( c - b < i_BB_100_BOX_X ) Then Exit;
+ if( i - n < 2 ) Then Exit;
+
+ i_BB_100_c :=c;
+ i_BB_100_n :=n;
+ i_BB_100_i :=i;
+ i_BB_100_mark := i;
+
+ W_Log('BB_100',i_tmp_log,i_make_log_ex,'n !!!');
+ W_Log('BB_100',i_tmp_log,i_make_log_ex,'c !!!');
+ W_Log('BB_100',i_tmp_log,i_make_log_ex,'b !!!');
+ W_Log('BB_100',i_tmp_log,i_make_log_ex,'a !!!');
+
+ Result :=-1;
+
+end;
+
+
+function ff_check_BB_100_ex(i:Integer):Integer;
+begin
+ Result := -1;
+ if ( i< 888 ) Then Exit;
+
+ if ( i_BB_100_mark =0 ) Then Exit;
+
+ //W_Log('BB_100_EX',as_k_chg[i].i_date,8,'1 888!!!');
+
+ if( f_last_price_wk < ff_get_min_ij_low(i_BB_100_n,i_BB_100_i)/100 -2.0 ) Then
+ begin
+ //W_Log('BB_100_EX',as_k_chg[i].i_date,8,'2 888!!!');
+ i_BB_100_mark:=0;
+ end;
+
+ if( f_last_price_wk > (as_k_chg[i_BB_100_c].i_high /100+ 5.0) ) Then
+ begin
+ //W_Log('BB_100_EX',as_k_chg[i].i_high,8,'2.5 f_last_price_wk 888!!!');
+ //W_Log('BB_100_EX',as_k_chg[i].i_date,8,'3 888!!!');
+ i_BB_100_mark:=0;
+ end;
+
+ //W_Log('BB_100_EX',as_k_chg[i].i_date,8,'4 888!!!');
+
+ if ( i_BB_100_mark =0 ) Then Exit;
+
+ //W_Log('BB_100_EX',as_k_chg[i].i_high,8,'5 f_last_price_wk 888!!!');
+ //W_Log('BB_100_EX',ff_get_max_ij_high(i_BB_100_n,i_BB_100_i),8,'6 max high!!');
+
+ if( f_last_price_wk > ff_get_max_ij_high(i_BB_100_n,i_BB_100_i)/100 ) and
+ ( f_last_price_wk < ( ff_get_max_ij_high(i_BB_100_n,i_BB_100_i)/100 + 5 )) then
+ begin
+ W_Log('BB_100_EX',as_k_chg[i].i_date,i_wk_log,'88888888!!!');
+ Result :=0;
+ i_BB_100_mark:=0;
+ Exit;
+ end;
+ Result :=-1;
+
+end;
+
+
+function ff_get_S_L_Mark(i:Integer) :Integer;
+begin
+ Result := -1;
+
+ if ( i< 888 ) Then Exit;
+
+ i_MA120_120_chg := as_k_chg_ma_rsi[i].ai_ma[6] - as_k_chg_ma_rsi[i-120].ai_ma[6];
+
+ if(i_MA120_120_chg > 1600 ) Then
+ begin
+ f_rsi_stop_long :=f_rsi_stop*2;
+ i_make_long :=888
+ end
+ else
+ begin
+ i_make_long :=0;
+ f_rsi_stop_long :=f_rsi_stop;
+ end;
+
+ if(i_MA120_120_chg < -1600 ) Then
+ begin
+ f_rsi_stop_short :=f_rsi_stop*2;
+ i_make_short :=888
+ end
+ else
+ begin
+ f_rsi_stop_short :=f_rsi_stop;
+ i_make_short :=0;
+ end;
+
+ if ( f_mbm_stop_short >1.0 ) Then
+ f_rsi_stop_short :=f_mbm_stop_short;
+
+ if ( f_mbm_stop_long >1.0 ) Then
+ f_rsi_stop_long :=f_mbm_stop_long;
+
+ if ( f_mbm_cut_short >1.0 ) Then
+ f_rsi_cut_short :=f_mbm_cut_short
+ else
+ f_rsi_cut_short :=f_rsi_cut;
+
+ if ( f_mbm_stop_long >1.0 ) Then
+ f_rsi_cut_long :=f_mbm_cut_long
+ else
+ f_rsi_cut_long :=f_rsi_cut;
+
+end;
+
+
+
+
+
+
+
+function ff_check_M30_short(i:Integer):Integer;
+var
+ j :Integer;
+ n :Integer;
+ a :Integer;
+ b :Integer;
+ c :Integer;
+begin
+
+ Result := -1;
+
+ if ( i< 288 ) Then Exit;
+
+ if ( i - i_M30_short_mark > i_M30_short_BOX_X*2 ) Then i_M30_short_mark:=0;
+
+ if(i_M30_short_mark >288) Then Exit;
+
+ //ai_ma[6] for MA120
+ if( as_k_chg[i].i_close > as_k_chg_ma_rsi[i-1].ai_ma[5] - 100 ) Then Exit;
+
+ if( as_k_chg[i].i_close < as_k_chg_ma_rsi[i-1].ai_ma[5] - 1200 ) Then Exit;
+
+ if( as_k_chg_ma_rsi[i].ai_ma[3] < (as_k_chg_ma_rsi[i].ai_ma[6] ) ) Then Exit;
+ if( as_k_chg_ma_rsi[i].ai_ma[5] < (as_k_chg_ma_rsi[i].ai_ma[6] ) ) Then Exit;
+
+ n := ff_get_max_ij_index(i-i_M30_short_BOX_X-2,i);
+
+ c := ff_get_min_ij_index(i-5*i_M30_short_BOX_X,n);
+
+ b := ff_get_max_ij_index(c-8*i_M30_short_BOX_X,c);
+
+ a := ff_get_min_ij_index(b-8*i_M30_short_BOX_X,b);
+
+ if ( Integer(as_k_chg[a].i_low + 800 ) < ff_get_min_ij_low(a,n) ) Then Exit;
+
+ //MA30 < MA120
+ for j := a to n - i_M30_short_BOX_X Do
+ begin
+ if as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[6] then Exit;
+ end;
+
+ if( c > (n - i_M30_short_BOX_X + 2 ) ) Then Exit;
+
+ //if ((as_k_chg[c].i_low +1600) < as_k_chg[n].i_close) Then Exit;
+
+ //if (as_k_chg[a].i_low > (as_k_chg[c].i_low + 800) ) Then Exit;
+
+ //if (as_k_chg[c].i_low > (as_k_chg[a].i_low + 800) ) Then Exit;
+
+ if (as_k_chg[n].i_high > as_k_chg[b].i_high ) Then Exit;
+
+ if( b - a < i_M30_short_BOX_X*2 ) Then Exit;
+ if( c - b < i_M30_short_BOX_X ) Then Exit;
+ if( i - n < 2 ) Then Exit;
+
+ i_M30_short_c :=c;
+ i_M30_short_n :=n;
+ i_M30_short_i :=i;
+ i_M30_short_mark := i;
+
+ //W_Log('M30_short',as_k_chg[n].i_date,8,'n !!!');
+ //W_Log('M30_short',as_k_chg[c].i_date,8,'c !!!');
+ //W_Log('M30_short',as_k_chg[b].i_date,8,'b !!!');
+ //W_Log('M30_short',as_k_chg[a].i_date,8,'a !!!');
+
+ Result :=-1;
+
+end;
+
+function ff_check_M30_short_ex(i:Integer):Integer;
+begin
+ Result := -1;
+ if ( i< 288 ) Then Exit;
+
+ if ( i_M30_short_mark =0 ) Then Exit;
+
+ //W_Log('M30_short_EX',as_k_chg[i].i_date,8,'1 888!!!');
+
+ if( f_last_price_wk > ff_get_max_ij_high(i_M30_short_n,i_M30_short_i)/100 -2.0 ) Then
+ begin
+ //W_Log('M30_short_EX',as_k_chg[i].i_date,8,'2 888!!!');
+ i_M30_short_mark:=0;
+ end;
+
+ if( f_last_price_wk < (as_k_chg[i_M30_short_c].i_low /100 - 15.0) ) Then
+ begin
+ //W_Log('M30_short_EX',as_k_chg[i].i_high,8,'2.5 f_last_price_wk 888!!!');
+
+ //W_Log('M30_short_EX',as_k_chg[i].i_date,8,'3 888!!!');
+ i_M30_short_mark:=0;
+ end;
+
+ //W_Log('M120_BB_EX',as_k_chg[i].i_date,8,'4 888!!!');
+
+ if ( i_M30_short_mark =0 ) Then Exit;
+
+ //W_Log('M30_short_EX',as_k_chg[i].i_low,8,'5 f_last_price_wk 888!!!');
+ //W_Log('M30_short_EX',ff_get_min_ij_low(i_M30_short_n,i_M30_short_i),8,'6 min low!!');
+
+ if( f_last_price_wk > as_k_chg_ma_rsi[i-1].ai_ma[6]/100 ) Then Exit;
+
+ if( f_last_price_wk < ff_get_min_ij_low(i_M30_short_n,i_M30_short_i)/100 ) and
+ ( f_last_price_wk > ( ff_get_min_ij_low(i_M30_short_n,i_M30_short_i)/100 - 15 )) then
+ begin
+ W_Log('M30_short_EX',as_k_chg[i].i_date,i_wk_log,'88888888!!');
+ Result :=0;
+ i_M30_short_mark:=0;
+ Exit;
+ end;
+ Result :=-1;
+
+end;
+
+function ff_check_short_1(i:Integer):Integer;
+var
+ j:Integer;
+ a:Integer;
+ b:Integer;
+ k:Integer;
+ m:Cardinal;
+begin
+
+ Result := -1;
+
+ if (i_act_short =0) then Exit;
+
+ if ( i< 888 ) Then Exit;
+
+ if ( i - i_short_1_mark > i_BB_BOX_X*3 ) Then i_short_1_mark:=0;
+
+ if(i_short_1_mark >888) Then Exit;
+
+ //ai_ma[6] for MA120
+ if( as_k_chg[i].i_close > as_k_chg_ma_rsi[i-1].ai_ma[6] ) Then Exit;
+ if( as_k_chg[i].i_close > as_k_chg_ma_rsi[i-1].ai_ma[5] ) Then Exit;
+ if( as_k_chg[i].i_close > as_k_chg_ma_rsi[i-1].ai_ma[3] ) Then Exit;
+ if( as_k_chg[i].i_close > as_k_chg_ma_rsi[i-1].ai_ma[8] ) Then Exit;
+
+ if( as_k_chg_ma_rsi[i].ai_ma[6] > as_k_chg_ma_rsi[i].ai_ma[8] + 30 ) Then Exit;
+ m:=400;
+ a:=0;
+ k:=i;
+ for j := k downto k-i_BB_BOX_X*8 Do
+ begin
+ if(( as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[3] + m ) and
+ ( as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[6] + m ) and
+ ( as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[8] + m ) and
+ ( as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[6] + m ) and
+ ( as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[8] + m ) and
+ ( as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[3] + m ) and
+ ( as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[5] + m ) and
+ ( as_k_chg_ma_rsi[j].ai_ma[5] < as_k_chg_ma_rsi[j].ai_ma[6] + m ) and
+ ( as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[5] + m ) and
+ ( as_k_chg_ma_rsi[j].ai_ma[5] < as_k_chg_ma_rsi[j].ai_ma[8] + m ) and
+ ( as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[5] + m ) and
+ ( as_k_chg_ma_rsi[j].ai_ma[5] < as_k_chg_ma_rsi[j].ai_ma[3] + m ) ) Then
+ begin
+ a:=j;
+ Break;
+ end;
+ end;
+
+ if(a = 0) Then Exit;
+
+ if( ff_get_max_ij_high(i-i_BB_BOX_X*8 ,i) < integer(as_k_chg_ma_rsi[a].ai_ma[6]) ) Then Exit;
+
+ if( ff_get_max_ij_high(i-3 ,i) < integer(as_k_chg_ma_rsi[i].ai_ma[3]) ) Then Exit;
+
+
+ b:=0;
+ k:=i;
+ for j := k downto k-i_BB_BOX_X*8 Do
+ begin
+ if(( as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[8] + 20 ) and
+ ( as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[6] + 20 ) )Then
+ begin
+ b:=j;
+ Break;
+ end;
+ end;
+
+ if((b = 0) or (b < a - i_BB_BOX_X*2 ) ) Then Exit;
+
+ if( as_k_chg[b].i_high + 1200 < as_k_chg_ma_rsi[b].ai_ma[6] ) Then exit;
+
+ if( as_k_chg_ma_rsi[i-1].ai_ma[3] > as_k_chg_ma_rsi[i-1].ai_ma[5] ) Then Exit;
+ if( as_k_chg_ma_rsi[i-1].ai_ma[5] > as_k_chg_ma_rsi[i-1].ai_ma[6] ) Then Exit;
+ if( as_k_chg_ma_rsi[i-1].ai_ma[6] > as_k_chg_ma_rsi[i-1].ai_ma[8] ) Then Exit;
+
+ if( as_k_chg_ma_rsi[i-1].ai_ma[3] > as_k_chg_ma_rsi[a].ai_ma[3] ) Then Exit;
+ if( as_k_chg_ma_rsi[i-1].ai_ma[5] > as_k_chg_ma_rsi[a].ai_ma[5] ) Then Exit;
+ if( as_k_chg_ma_rsi[i-1].ai_ma[6] > as_k_chg_ma_rsi[a].ai_ma[6] ) Then Exit;
+ if( as_k_chg_ma_rsi[i-1].ai_ma[8] > as_k_chg_ma_rsi[a].ai_ma[8] ) Then Exit;
+
+ if( ff_get_max_ij_high(i-3 ,i) > integer(as_k_chg_ma_rsi[i].ai_ma[6]) ) and
+ ( as_k_chg[i].i_close > as_k_chg_ma_rsi[i].ai_ma[5] ) and
+ ( as_k_chg[i].i_close > as_k_chg_ma_rsi[i].ai_ma[3] ) and
+ ( as_k_chg[i].i_close < as_k_chg_ma_rsi[i-1].ai_ma[6] ) Then
+ begin
+ i_short_1_mark:=i;
+ W_Log('short_1',as_k_chg[i].i_date,i_wk_log,'Down Under M120, SET i_short_1_mark');
+ Result :=0;
+ Exit;
+ End;
+
+
+ if( as_k_chg[i].i_close < as_k_chg_ma_rsi[i-1].ai_ma[3] ) Then
+ begin
+ i_short_1_mark:=i;
+ W_Log('Short_1',as_k_chg[i].i_date,i_wk_log,'SET i_short_1_mark!');
+ Result :=0;
+ Exit;
+ End;
+
+ Result :=-1;
+
+end;
+
+
+function ff_check_short_1_ex(i:Integer):Integer;
+begin
+ Result := -1;
+ if ( i< 288 ) Then Exit;
+
+ if ( i_short_1_mark =0 ) Then Exit;
+
+ if( f_last_price_wk > ff_get_max_ij_high(i-5,i-1)/100 + 2.0 ) Then
+ begin
+ i_short_1_mark:=0;
+ end;
+
+ if( f_last_price_wk < (ff_get_min_ij_low(i-i_BB_BOX_X*2,i-1)/100 - 3.0 ) ) Then
+ begin
+ i_short_1_mark:=0;
+ end;
+
+ if ( i_short_1_mark =0 ) Then Exit;
+
+ if( f_last_price_wk < as_k_chg_ma_rsi[i-1].ai_ma[3]/100 ) and
+ ( f_last_price_wk > ( as_k_chg_ma_rsi[i-1].ai_ma[3]/100 -5 ) ) Then
+ begin
+ W_Log('Short_1',as_k_chg[i].i_date,i_wk_log,'88888888!!');
+ i_short_1_mark:=0;
+ Result :=0;
+ Exit;
+ end;
+ Result :=-1;
+end;
+
+
+function ff_get_BS_Mark(i:Integer) :Integer;
+begin
+ Result := -1;
+
+ if ( i< 888 ) Then Exit;
+
+ i_B_S_Flag_10 :=as_k_chg_ma_rsi[i-10].ai_ma[6] - as_k_chg_ma_rsi[i-10].ai_ma[8];
+ i_B_S_Flag_18 :=as_k_chg_ma_rsi[i-18].ai_ma[6] - as_k_chg_ma_rsi[i-18].ai_ma[8];
+
+ i_B_S_Flag :=as_k_chg_ma_rsi[i].ai_ma[6] - as_k_chg_ma_rsi[i].ai_ma[8];
+
+ if i_B_S_Flag >0 Then
+ begin
+ //i_act_rsi:=10;
+ //i_act_m120:=10;
+ //i_act_bb_100:=10;
+ //i_act_short:=0;
+ end
+ else
+ begin
+ //i_act_short:=10;
+ //i_act_rsi:=0;
+ //i_act_m120:=0;
+ //i_act_bb_100:=0;
+ end;
+
+ if ( Integer(as_k_chg_ma_rsi[i].ai_ma[8] - as_k_chg_ma_rsi[i].ai_ma[3]) > 700 ) and
+ ( i_short_long_01 = 888 ) Then
+ begin
+ if (as_k_chg_ma_rsi[i].ai_ma[8] > as_k_chg_ma_rsi[i].ai_ma[6] + 100 ) and
+ (as_k_chg_ma_rsi[i].ai_ma[6] > as_k_chg_ma_rsi[i].ai_ma[5] + 50 ) and
+ (as_k_chg_ma_rsi[i].ai_ma[5] > as_k_chg_ma_rsi[i].ai_ma[3] + 100 ) Then
+ begin
+ //for short
+ i_short_long_01 :=0;
+ i_short_long_date := as_k_chg[i].i_date mod 10000;
+ i_short_long_index :=i;
+ W_Log(PChar(IntToStr(as_k_chg[i].i_date)),i_wk_log,i_wk_log,'DO SHORT ONLY!');
+ end;
+ end;
+
+ if ( Integer(as_k_chg_ma_rsi[i].ai_ma[8]) < as_k_chg[i].i_high ) and
+ ( i_short_long_01 = 0 ) Then
+ begin
+ i_short_long_01 :=888;
+ W_Log(PChar(IntToStr(as_k_chg[i].i_date)),i_wk_log,i_wk_log,'DO SHORT END!');
+ end;
+
+
+ if ( Integer(as_k_chg_ma_rsi[i].ai_ma[3] - as_k_chg_ma_rsi[i].ai_ma[8]) > 700 ) and
+ ( i_short_long_01 = 888 ) Then
+ begin
+ if (as_k_chg_ma_rsi[i].ai_ma[3] > as_k_chg_ma_rsi[i].ai_ma[5] + 100 ) and
+ (as_k_chg_ma_rsi[i].ai_ma[5] > as_k_chg_ma_rsi[i].ai_ma[6] + 50 ) and
+ (as_k_chg_ma_rsi[i].ai_ma[6] > as_k_chg_ma_rsi[i].ai_ma[8] + 100 ) Then
+ begin
+ //for short
+ i_short_long_01 :=1;
+ i_short_long_index :=i;
+ i_short_long_date := as_k_chg[i].i_date mod 10000;
+ W_Log(PChar(IntToStr(as_k_chg[i].i_date)),i_wk_log,i_wk_log,'DO LONG ONLY!');
+ end;
+ end;
+
+ if ( Integer(as_k_chg_ma_rsi[i].ai_ma[8]) > as_k_chg[i].i_low ) and
+ ( i_short_long_01 = 1 ) Then
+ begin
+ i_short_long_01 :=888;
+ W_Log(PChar(IntToStr(as_k_chg[i].i_date)),i_wk_log,i_wk_log,'DO LONG END!');
+ end;
+
+ if (i_short_long_01=0) Then
+ begin
+ //frmMain2.GRID_S008.Cells[0,0]:='SHORT';
+ //frmMain2.Header.Cells[12,0] := IntToStr(i_short_long_date);
+ //frmMain2.Header.Cells[13,0] := 'SHORT!';
+ end
+ else if (i_short_long_01=1) Then
+ begin
+ //frmMain2.GRID_S008.Cells[0,0]:='LONG';
+ //frmMain2.Header.Cells[12,0] := IntToStr(i_short_long_date);
+ //frmMain2.Header.Cells[13,0] := 'LONG!';
+ end
+ else
+ begin
+ //frmMain2.GRID_S008.Cells[0,0]:='NOTRADE';
+ //frmMain2.Header.Cells[12,0] := ' ';
+ //frmMain2.Header.Cells[13,0] := 'NO TRADE!';
+ end;
+
+end;
+
+function ff_get_long_mark_8(i:Integer) :Integer;
+var
+ i_B_S_Flag_tmp:Integer;
+ i_B_S_Flag_10_tmp:Integer;
+ i_B_S_Flag_18_tmp:Integer;
+begin
+ Result := -1;
+
+ if ( i< 888 ) Then Exit;
+
+ i_B_S_Flag_10_tmp :=as_k_chg_ma_rsi[i-10].ai_ma[6] - as_k_chg_ma_rsi[i-10].ai_ma[8];
+ i_B_S_Flag_18_tmp :=as_k_chg_ma_rsi[i-18].ai_ma[6] - as_k_chg_ma_rsi[i-18].ai_ma[8];
+ i_B_S_Flag_tmp :=as_k_chg_ma_rsi[i].ai_ma[6] - as_k_chg_ma_rsi[i].ai_ma[8];
+
+ //if( i_B_S_Flag_18_tmp>0 ) and ( i_B_S_Flag_10_tmp>0 ) Then
+ //if (i_B_S_Flag_tmp < 0 ) Then
+ //begin
+ // Result :=i;
+ //end;
+
+ if( i_B_S_Flag_18_tmp<0 ) and ( i_B_S_Flag_10_tmp<0 ) Then
+ if (i_B_S_Flag_tmp > 0 ) Then
+ begin
+ Result :=i;
+ end;
+
+end;
+
+function ff_get_ma600_mark(i:Integer) :Integer;
+var
+ i_low_600:Integer;
+ i_high_600:Integer;
+ i_check_count:Integer;
+begin
+ Result := -1;
+
+ if ( i< 888 ) Then Exit;
+
+ i_check_count :=38;
+
+ i_low_600 :=ff_get_min_ij_low(i-i_check_count,i);
+ i_high_600 :=ff_get_max_ij_high(i-i_check_count,i);
+
+ if ( i_low_600 < as_k_chg_ma_rsi[i-i_check_count].ai_ma[9] ) and
+ ( i_low_600 < as_k_chg_ma_rsi[i].ai_ma[9] ) and
+ ( as_k_chg_ma_rsi[i].ai_ma[0] > as_k_chg_ma_rsi[i-i_check_count].ai_ma[9] - 1000 ) and
+ ( as_k_chg_ma_rsi[i].ai_ma[0] > as_k_chg_ma_rsi[i].ai_ma[9] -1000 ) and
+ ( i_low_600 > as_k_chg_ma_rsi[i-i_check_count].ai_ma[9] - 1200 ) and
+ ( i_low_600 > as_k_chg_ma_rsi[i].ai_ma[9] - 1200 ) and
+
+ //( as_k_chg_ma_rsi[i-300].ai_ma[9] < as_k_chg_ma_rsi[i].ai_ma[9] ) and
+
+ ( as_k_chg_ma_rsi[i].ai_ma[6] < as_k_chg_ma_rsi[i].ai_ma[9] ) and
+
+ ( i_high_600 < as_k_chg_ma_rsi[i-i_check_count].ai_ma[9] ) and
+ ( i_high_600 < as_k_chg_ma_rsi[i].ai_ma[9] )
+ //( i_high_600 > as_k_chg_ma_rsi[i-10].ai_ma[9] - 500 ) and
+ //( i_high_600 > as_k_chg_ma_rsi[i].ai_ma[9] -500 )
+ Then
+ begin
+
+ if( ( as_k_chg_ma_rsi[i-1].ai_ma[8] > as_k_chg_ma_rsi[i-1].ai_ma[6] ) and
+ ( as_k_chg_ma_rsi[i-1].ai_ma[6] > as_k_chg_ma_rsi[i-1].ai_ma[5] ) and
+ ( as_k_chg_ma_rsi[i-1].ai_ma[5] > as_k_chg_ma_rsi[i-1].ai_ma[4] ) and
+
+ ( as_k_chg_ma_rsi[i-1].ai_ma[3] < as_k_chg_ma_rsi[i-5].ai_ma[3] ) and
+ ( as_k_chg_ma_rsi[i-1].ai_ma[4] < as_k_chg_ma_rsi[i-5].ai_ma[4] ) and
+ ( as_k_chg_ma_rsi[i-1].ai_ma[5] < as_k_chg_ma_rsi[i-5].ai_ma[5] ) and
+
+ ( as_k_chg_ma_rsi[i-1].ai_ma[4] > as_k_chg_ma_rsi[i-1].ai_ma[3] ) ) Then
+
+ Result:=i;
+
+ end;
+
+end;
+
+function ff_get_ma600_mark_long(i:Integer) :Integer;
+var
+ i_low_600:Integer;
+ i_high_600:Integer;
+ i_check_count:Integer;
+begin
+ Result := -1;
+
+ if ( i< 888 ) Then Exit;
+
+ i_check_count :=28;
+
+ i_low_600 :=ff_get_min_ij_low(i-i_check_count,i);
+ i_high_600 :=ff_get_max_ij_high(i-i_check_count,i);
+
+ if ( i_low_600 > as_k_chg_ma_rsi[i-i_check_count].ai_ma[9] ) and
+ ( i_low_600 > as_k_chg_ma_rsi[i].ai_ma[9] ) and
+ ( as_k_chg_ma_rsi[i].ai_ma[1] < as_k_chg_ma_rsi[i-i_check_count].ai_ma[9] + 1000 ) and
+ ( as_k_chg_ma_rsi[i].ai_ma[1] < as_k_chg_ma_rsi[i].ai_ma[9] + 1000 ) and
+ ( i_high_600 < as_k_chg_ma_rsi[i-i_check_count].ai_ma[9] + 1200 ) and
+ ( i_high_600 < as_k_chg_ma_rsi[i].ai_ma[9] + 1200 ) and
+
+ ( as_k_chg_ma_rsi[i-300].ai_ma[9] > as_k_chg_ma_rsi[i].ai_ma[9] ) and
+
+ //( as_k_chg_ma_rsi[i].ai_ma[5] > as_k_chg_ma_rsi[i].ai_ma[9] ) and
+
+ ( i_high_600 > as_k_chg_ma_rsi[i-i_check_count].ai_ma[9] ) and
+ ( i_high_600 > as_k_chg_ma_rsi[i].ai_ma[9] )
+ Then
+ begin
+
+ if( ( as_k_chg_ma_rsi[i-1].ai_ma[8] < as_k_chg_ma_rsi[i-1].ai_ma[6] ) and
+ ( as_k_chg_ma_rsi[i-1].ai_ma[6] < as_k_chg_ma_rsi[i-1].ai_ma[5] ) and
+ ( as_k_chg_ma_rsi[i-1].ai_ma[5] < as_k_chg_ma_rsi[i-1].ai_ma[4] ) and
+
+ ( as_k_chg_ma_rsi[i-1].ai_ma[3] > as_k_chg_ma_rsi[i-5].ai_ma[3] ) and
+ ( as_k_chg_ma_rsi[i-1].ai_ma[4] > as_k_chg_ma_rsi[i-5].ai_ma[4] ) and
+ ( as_k_chg_ma_rsi[i-1].ai_ma[5] > as_k_chg_ma_rsi[i-5].ai_ma[5] ) and
+
+ ( as_k_chg_ma_rsi[i-1].ai_ma[4] < as_k_chg_ma_rsi[i-1].ai_ma[3] ) ) Then
+
+ Result:=i;
+
+ end;
+
+end;
+
+
+
+
+
+function ff_check_short_250(i:Integer):Integer;
+var
+ j:Integer;
+ b:Integer;
+ k:Integer;
+ i_high:Integer;
+ i_low:Integer;
+
+begin
+
+ Result := -1;
+
+ if (i_act_short =0) then Exit;
+
+ if ( i< 888 ) Then Exit;
+
+ if ( i - i_short_250_mark > i_BB_BOX_X ) Then i_short_250_mark:=0;
+
+ if( i_short_250_mark >888 ) Then Exit;
+
+ if( as_k_chg[i].i_close < as_k_chg_ma_rsi[i-1].ai_ma[6] ) Then Exit;
+
+ b:=0;
+ k:=i;
+ for j := k-120 to i-i_BB_BOX_X Do
+ begin
+ if( as_k_chg[j].i_high > as_k_chg_ma_rsi[j].ai_ma[8] + 20 ) Then
+ begin
+ Exit;
+ end;
+ end;
+
+
+ b:=0;
+ k:=i;
+ for j := k downto 888 Do
+ begin
+ if(( as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[8] + 20 ) and
+ ( as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[6] + 20 ) )Then
+ begin
+ b:=j;
+ Break;
+ end;
+ end;
+
+ if b =0 then Exit;
+
+ i_high := ff_get_max_ij_high(b ,i);
+ i_low :=ff_get_min_ij_low(b,i);
+
+ if( i_high < integer(as_k_chg[i].i_close) ) Then Exit;
+
+ if( i_low > integer(as_k_chg[i].i_low - 800) ) Then Exit;
+
+ if( (i_high - i_low) > integer(3*( integer(as_k_chg[i].i_high) - i_low ))) Then Exit;
+
+ if( (100*(i_high - i_low)/(i_high+100)) < 1) Then Exit;
+
+ if( as_k_chg[b].i_close < as_k_chg[i].i_close + 800 ) Then Exit;
+
+ if( as_k_chg_ma_rsi[i-1].ai_ma[6] > as_k_chg_ma_rsi[b].ai_ma[6] ) Then Exit;
+ if( as_k_chg_ma_rsi[i-1].ai_ma[8] > as_k_chg_ma_rsi[b].ai_ma[8] ) Then Exit;
+
+ if( as_k_chg_ma_rsi[i].ai_ma[3] > as_k_chg_ma_rsi[i].ai_ma[8] ) Then Exit;
+ if( as_k_chg_ma_rsi[i].ai_ma[5] > as_k_chg_ma_rsi[i].ai_ma[8] ) Then Exit;
+ if( as_k_chg_ma_rsi[i].ai_ma[6] > as_k_chg_ma_rsi[i].ai_ma[8] ) Then Exit;
+
+ if( ff_get_max_ij_high(i-3 ,i) > integer(as_k_chg_ma_rsi[i].ai_ma[8]) ) and
+ ( as_k_chg[i].i_close > as_k_chg_ma_rsi[i].ai_ma[6] ) and
+ ( as_k_chg[i].i_close > as_k_chg_ma_rsi[i].ai_ma[3] ) and
+ ( as_k_chg[i].i_close < as_k_chg_ma_rsi[i-1].ai_ma[8] ) Then
+ begin
+ i_short_250_mark:=i;
+ W_Log('Short_1',as_k_chg[i].i_date,i_wk_log,'SET i_short_250_mark!');
+ Result :=0;
+ Exit;
+ End;
+
+ Result :=-1;
+
+end;
+
+
+
+
+
+function ff_check_short_30(i:Integer):Integer;
+var
+ j:Integer;
+ b:Integer;
+ k:Integer;
+ i_high:Integer;
+begin
+
+ Result := -1;
+
+ if (i_act_short =0) then Exit;
+
+ if ( i< 888 ) Then Exit;
+
+ if ( i - i_short_30_mark > i_BB_BOX_X ) Then i_short_30_mark:=0;
+
+ if( i_short_30_mark >888 ) Then Exit;
+
+ if( as_k_chg[i].i_close > as_k_chg_ma_rsi[i-1].ai_ma[5] ) Then Exit;
+ if( as_k_chg[i].i_close > as_k_chg_ma_rsi[i-1].ai_ma[6] ) Then Exit;
+ if( as_k_chg[i].i_close > as_k_chg_ma_rsi[i-1].ai_ma[8] ) Then Exit;
+
+ k:=i;
+ for j := k-5 downto k-i_BB_BOX_X-5 Do
+ begin
+ if( as_k_chg[j].i_high > as_k_chg_ma_rsi[j].ai_ma[3] ) Then Exit;
+ end;
+
+ b:=0;
+ k:=i;
+ for j := k downto 888 Do
+ begin
+ if(( as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[8] + 20 ) and
+ ( as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[6] + 20 ) )Then
+ begin
+ b:=j;
+ Break;
+ end;
+ end;
+
+ if b =0 then Exit;
+
+ //for 1.5 hour
+ if ( (i-b) > 58) then Exit;
+
+ i_high := ff_get_max_ij_high(b ,i);
+
+ if( i_high < integer(as_k_chg[i].i_close) ) Then Exit;
+ if( as_k_chg[b].i_close < as_k_chg[i].i_close + 800 ) Then Exit;
+
+ if( as_k_chg_ma_rsi[i-1].ai_ma[6] > as_k_chg_ma_rsi[b].ai_ma[6] +100 ) Then Exit;
+ if( as_k_chg_ma_rsi[i-1].ai_ma[8] > as_k_chg_ma_rsi[b].ai_ma[8] +100 ) Then Exit;
+
+ if( ff_get_max_ij_high(i-6 ,i) > integer(as_k_chg_ma_rsi[i].ai_ma[3]) ) and
+ ( as_k_chg[i-1].i_close < as_k_chg_ma_rsi[i-1].ai_ma[3] ) and
+ ( as_k_chg[i].i_close < as_k_chg[i-1].i_close ) and
+ ( ( as_k_chg[i-2].i_high > as_k_chg_ma_rsi[i-2].ai_ma[3] ) or
+ ( as_k_chg[i-3].i_high > as_k_chg_ma_rsi[i-3].ai_ma[3] ) or
+ ( as_k_chg[i-4].i_high > as_k_chg_ma_rsi[i-4].ai_ma[3] ) or
+ ( as_k_chg[i-1].i_high > as_k_chg_ma_rsi[i-1].ai_ma[3] ) or
+ ( as_k_chg[i-6].i_high > as_k_chg_ma_rsi[i-6].ai_ma[3] ) or
+ ( as_k_chg[i-5].i_high > as_k_chg_ma_rsi[i-5].ai_ma[3] ) ) Then
+ begin
+ i_short_30_mark:=i;
+ W_Log('short_30',as_k_chg[i].i_date,i_wk_log,'short 30!!!');
+ Result :=0;
+ Exit;
+ End;
+
+ Result :=-1;
+
+end;
+
+function ff_check_short_120(i:Integer):Integer;
+var
+ j:Integer;
+ k:Integer;
+ i_high:Integer;
+ i_low:Integer;
+begin
+
+ Result := -1;
+
+ if (i_act_short =0) then Exit;
+
+ if ( i< 888 ) Then Exit;
+
+ if ( i - i_short_120_mark > i_BB_BOX_X ) Then i_short_120_mark:=0;
+
+
+ if( i_short_120_mark >888 ) Then Exit;
+
+ if(as_k_chg_ma_rsi[i].ai_ma[6] > as_k_chg_ma_rsi[i].ai_ma[8] ) Then Exit;
+ if( as_k_chg[i].i_close > as_k_chg_ma_rsi[i-1].ai_ma[6] ) Then Exit;
+
+ k:=i;
+ for j := k-5 downto k-128 Do
+ begin
+ if( as_k_chg[j].i_high > as_k_chg_ma_rsi[j].ai_ma[6] ) Then Exit;
+ end;
+
+ i_low := ff_get_min_ij_low(i-i_BB_BOX_X*8 ,i);
+
+ if( i_low > integer(as_k_chg[i].i_close ) ) Then Exit;
+
+ i_high := ff_get_max_ij_high(i-i_BB_BOX_X*3,i-5);
+ if( i_high > integer(as_k_chg_ma_rsi[i].ai_ma[6]) ) Then Exit;
+
+ if(ff_get_max_ij_high(i-3 ,i) > integer(as_k_chg_ma_rsi[i].ai_ma[6]) ) and
+ ( as_k_chg[i].i_close > as_k_chg_ma_rsi[i].ai_ma[3] ) and
+ ( as_k_chg[i].i_close > as_k_chg_ma_rsi[i].ai_ma[5] ) and
+ ( as_k_chg[i].i_close < as_k_chg_ma_rsi[i].ai_ma[6] ) Then
+ begin
+ i_short_120_mark:=i;
+ W_Log('short_120',as_k_chg[i].i_date,8,'short 120!!!');
+ Result :=0;
+ Exit;
+ End;
+
+ Result :=-1;
+
+end;
+
+
+function ff_short_pass3_mark(i:Integer):Integer;
+var
+ j:Integer;
+ c:Integer;
+ b:Integer;
+ a:Integer;
+ k:Integer;
+begin
+
+ Result := -1;
+
+ if ( i< 888 ) Then Exit;
+
+ if ( i - i_short_pass3_mark > 58 ) Then i_short_pass3_mark:=0;
+
+ if( i_short_pass3_mark >888 ) Then Exit;
+
+ if( as_k_chg[i].i_close > as_k_chg_ma_rsi[i-1].ai_ma[8] ) Then Exit;
+ if( as_k_chg[i].i_close > as_k_chg_ma_rsi[i-1].ai_ma[5] ) Then Exit;
+ if( as_k_chg[i].i_close > as_k_chg_ma_rsi[i-1].ai_ma[6] ) Then Exit;
+
+ k:=i;
+ for j := k-8 downto k-38 Do
+ begin
+ // if( as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[6] ) Then Exit;
+ end;
+
+ k:=i;
+ c:=0;
+ for j := k-1 downto k-i_BB_BOX_X*6 Do
+ begin
+ if(( as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[3] + 20 ) and
+ ( as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[8] + 20 ) )Then
+ begin
+ c:=j;
+ Break;
+ end;
+ end;
+
+ if( c=0 ) Then Exit;
+
+ k:=i;
+ b:=0;
+ for j := k-1 downto k-i_BB_BOX_X*6 Do
+ begin
+ if(( as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[3] + 20 ) and
+ ( as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[6] + 20 ) )Then
+ begin
+ b:=j;
+ Break;
+ end;
+ end;
+
+ if( b=0 ) Then Exit;
+
+ a:=0;
+ k:=i;
+ for j := k-1 downto k-i_BB_BOX_X*6 Do
+ begin
+ if(( as_k_chg_ma_rsi[j].ai_ma[5] < as_k_chg_ma_rsi[j].ai_ma[3] + 20 ) and
+ ( as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[5] + 20 ) )Then
+ begin
+ a:=j;
+ Break;
+ end;
+ end;
+
+ if( a=0 ) Then Exit;
+
+ if( (i-a)>i_BB_BOX_X ) and ( (i-b)>i_BB_BOX_X ) and ( (i-c)>i_BB_BOX_X ) Then Exit;
+
+
+ for j := a-2 downto a-i_BB_BOX_X Do
+ begin
+ if( as_k_chg_ma_rsi[j].ai_ma[5] > as_k_chg_ma_rsi[j].ai_ma[3] ) Then Exit;
+ end;
+
+ for j := b-2 downto b-i_BB_BOX_X Do
+ begin
+ if( as_k_chg_ma_rsi[j].ai_ma[6] > as_k_chg_ma_rsi[j].ai_ma[3] ) Then Exit;
+ end;
+
+ for j := c-2 downto c-i_BB_BOX_X Do
+ begin
+ if( as_k_chg_ma_rsi[j].ai_ma[8] > as_k_chg_ma_rsi[j].ai_ma[3] ) Then Exit;
+ end;
+
+ i_short_pass3_mark:=i;
+ W_Log('short_pass3_mark',as_k_chg[i].i_date,i_wk_log,'SET short pass3_mark!!!');
+
+ Result :=0;
+
+end;
+
+
+
+function ff_pass3_short_120(i:Integer):Integer;
+var
+ j:Integer;
+ k:Integer;
+ i_high:Integer;
+ i_low:Integer;
+begin
+
+ Result := -1;
+
+ if (i_act_short =0) then Exit;
+
+ if( i_short_pass3_mark = 0 ) Then Exit;
+
+ if ( i - i_pass3_short_120_mark > i_BB_BOX_X ) Then i_pass3_short_120_mark:=0;
+
+ if( i_pass3_short_120_mark >888 ) Then Exit;
+
+ if ( i< 888 ) Then Exit;
+
+ if(as_k_chg_ma_rsi[i].ai_ma[6] > as_k_chg_ma_rsi[i].ai_ma[8] ) Then Exit;
+ if(as_k_chg_ma_rsi[i].ai_ma[5] > as_k_chg_ma_rsi[i].ai_ma[8] ) Then Exit;
+
+ if( as_k_chg[i].i_close > as_k_chg_ma_rsi[i-1].ai_ma[6] ) Then Exit;
+
+ if(ff_get_max_ij_high(i-3 ,i) > integer(as_k_chg_ma_rsi[i].ai_ma[6]) ) and
+ ( as_k_chg[i].i_close > as_k_chg_ma_rsi[i].ai_ma[3] ) and
+ ( as_k_chg[i].i_close < as_k_chg_ma_rsi[i].ai_ma[6] ) Then
+ begin
+ i_pass3_short_120_mark:=i;
+ W_Log('pass3_short120',as_k_chg[i].i_date,i_wk_log,'pass3_short120!!!');
+ Result :=0;
+ Exit;
+ End;
+
+ Result :=-1;
+
+end;
+
+
+
+
+function ff_check_long_pass_3(i:Integer):Integer;
+var
+ j:Integer;
+ b:Integer;
+ a:Integer;
+ k:Integer;
+begin
+
+ Result := -1;
+
+ if ( i< 888 ) Then Exit;
+
+ if ( i - i_pass_3_mark > i_BB_BOX_X ) Then i_pass_3_mark:=0;
+
+ if( i_pass_3_mark >888 ) Then Exit;
+
+ if( as_k_chg[i].i_close < as_k_chg_ma_rsi[i-1].ai_ma[8] ) Then Exit;
+ if( as_k_chg[i].i_close < as_k_chg_ma_rsi[i-1].ai_ma[5] ) Then Exit;
+ if( as_k_chg[i].i_close < as_k_chg_ma_rsi[i-1].ai_ma[6] ) Then Exit;
+
+ k:=i;
+ for j := k-8 downto k-188 Do
+ begin
+ if( as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[6] ) Then Exit;
+ if( as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[5] ) Then Exit;
+ end;
+
+ k:=i;
+ b:=0;
+ for j := k-1 downto k-i_BB_BOX_X*6 Do
+ begin
+ if( as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[3] ) Then Exit;
+
+ if(( as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[3] + 30 ) and
+ ( as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[6] + 30 ) )Then
+ begin
+ b:=j;
+ Break;
+ end;
+ end;
+
+ if( b=0 ) Then Exit;
+
+ a:=0;
+ k:=i;
+ for j := b-2 downto k-i_BB_BOX_X*5 Do
+ begin
+ if( as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[3] ) Then Exit;
+ if( as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[3] ) Then Exit;
+
+ if(( as_k_chg_ma_rsi[j].ai_ma[5] < as_k_chg_ma_rsi[j].ai_ma[3] + 30 ) and
+ ( as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[5] + 30 ) )Then
+ begin
+ a:=j;
+ Break;
+ end;
+ end;
+
+ if( a=0 ) Then Exit;
+
+ for j := a-2 downto a-i_BB_BOX_X Do
+ begin
+ if( as_k_chg_ma_rsi[j].ai_ma[5] < as_k_chg_ma_rsi[j].ai_ma[3] ) Then Exit;
+ end;
+
+ if( as_k_chg_ma_rsi[i].ai_ma[8] > as_k_chg_ma_rsi[i].ai_ma[3] ) Then Exit;
+ if( as_k_chg_ma_rsi[i].ai_ma[6] > as_k_chg_ma_rsi[i].ai_ma[3] ) Then Exit;
+ if( as_k_chg_ma_rsi[i].ai_ma[5] > as_k_chg_ma_rsi[i].ai_ma[3] ) Then Exit;
+
+ i_pass_3_mark:=i;
+ W_Log('pass_3',as_k_chg[i].i_date,8,'long pass_3!!!');
+
+ Result :=0;
+
+end;
+
+
+function ff_long_pass_3_ex(i:Integer):Integer;
+var
+ j:Integer;
+ c:Integer;
+ b:Integer;
+ a:Integer;
+ k:Integer;
+begin
+
+ Result := -1;
+
+ if ( i< 888 ) Then Exit;
+
+ if ( i - i_pass_3_mark_ex > i_BB_BOX_X ) Then i_pass_3_mark_ex:=0;
+
+ if( i_pass_3_mark_ex >888 ) Then Exit;
+
+ if( as_k_chg[i].i_close < as_k_chg_ma_rsi[i-1].ai_ma[8] ) Then Exit;
+ if( as_k_chg[i].i_close < as_k_chg_ma_rsi[i-1].ai_ma[5] ) Then Exit;
+ if( as_k_chg[i].i_close < as_k_chg_ma_rsi[i-1].ai_ma[6] ) Then Exit;
+
+ if( as_k_chg_ma_rsi[i].ai_ma[8] > as_k_chg_ma_rsi[i].ai_ma[6] + 50 ) Then Exit;
+
+ if( as_k_chg_ma_rsi[i].ai_ma[6] < as_k_chg_ma_rsi[i-20].ai_ma[6] + 50 ) Then Exit;
+ if( as_k_chg_ma_rsi[i].ai_ma[8] + 100 < as_k_chg_ma_rsi[i-20].ai_ma[8] ) Then Exit;
+
+ k:=i;
+ c:=0;
+ for j := k-1 downto k-i_BB_BOX_X*6 Do
+ begin
+ if(( as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[3] + 20 ) and
+ ( as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[8] + 20 ) )Then
+ begin
+ c:=j;
+ Break;
+ end;
+ end;
+
+ if( c=0 ) Then Exit;
+
+ k:=i;
+ b:=0;
+ for j := k-1 downto k-i_BB_BOX_X*6 Do
+ begin
+ if(( as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[3] + 20 ) and
+ ( as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[6] + 20 ) )Then
+ begin
+ b:=j;
+ Break;
+ end;
+ end;
+
+ if( b=0 ) Then Exit;
+
+ a:=0;
+ k:=i;
+ for j := k-1 downto k-i_BB_BOX_X*6 Do
+ begin
+ if(( as_k_chg_ma_rsi[j].ai_ma[5] < as_k_chg_ma_rsi[j].ai_ma[3] + 20 ) and
+ ( as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[5] + 20 ) )Then
+ begin
+ a:=j;
+ Break;
+ end;
+ end;
+
+ if( a=0 ) Then Exit;
+
+ if( (i-a)>i_BB_BOX_X ) and ( (i-b)>i_BB_BOX_X ) and ( (i-c)>i_BB_BOX_X ) Then Exit;
+
+
+ if( as_k_chg_ma_rsi[i].ai_ma[8] > as_k_chg_ma_rsi[i].ai_ma[3] ) Then Exit;
+ if( as_k_chg_ma_rsi[i].ai_ma[6] > as_k_chg_ma_rsi[i].ai_ma[3] ) Then Exit;
+ if( as_k_chg_ma_rsi[i].ai_ma[5] > as_k_chg_ma_rsi[i].ai_ma[3] ) Then Exit;
+
+ i_pass_3_mark_ex:=i;
+ W_Log('pass_3_ex',as_k_chg[i].i_date,i_wk_log,'long pass_3_ex!!!');
+
+ Result :=0;
+
+end;
+
+function ff_short_pass_3_ex(i:Integer):Integer;
+var
+ j:Integer;
+ b:Integer;
+ a:Integer;
+ k:Integer;
+begin
+
+ Result := -1;
+
+ if ( i< 888 ) Then Exit;
+
+ if ( i - i_pass_3_mark > i_BB_BOX_X ) Then i_pass_3_mark:=0;
+
+ if( i_pass_3_mark >888 ) Then Exit;
+
+ if( as_k_chg[i].i_close < as_k_chg_ma_rsi[i-1].ai_ma[8] ) Then Exit;
+ if( as_k_chg[i].i_close < as_k_chg_ma_rsi[i-1].ai_ma[5] ) Then Exit;
+ if( as_k_chg[i].i_close < as_k_chg_ma_rsi[i-1].ai_ma[6] ) Then Exit;
+
+ k:=i;
+ for j := k-8 downto k-188 Do
+ begin
+ if( as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[6] ) Then Exit;
+ if( as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[5] ) Then Exit;
+ end;
+
+ k:=i;
+ b:=0;
+ for j := k-1 downto k-i_BB_BOX_X*6 Do
+ begin
+ if( as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[3] ) Then Exit;
+
+ if(( as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[3] + 30 ) and
+ ( as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[6] + 30 ) )Then
+ begin
+ b:=j;
+ Break;
+ end;
+ end;
+
+ if( b=0 ) Then Exit;
+
+ a:=0;
+ k:=i;
+ for j := b-2 downto k-i_BB_BOX_X*5 Do
+ begin
+ if( as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[3] ) Then Exit;
+ if( as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[3] ) Then Exit;
+
+ if(( as_k_chg_ma_rsi[j].ai_ma[5] < as_k_chg_ma_rsi[j].ai_ma[3] + 30 ) and
+ ( as_k_chg_ma_rsi[j].ai_ma[3] < as_k_chg_ma_rsi[j].ai_ma[5] + 30 ) )Then
+ begin
+ a:=j;
+ Break;
+ end;
+ end;
+
+ if( a=0 ) Then Exit;
+
+ for j := a-2 downto a-i_BB_BOX_X Do
+ begin
+ if( as_k_chg_ma_rsi[j].ai_ma[5] < as_k_chg_ma_rsi[j].ai_ma[3] ) Then Exit;
+ end;
+
+ if( as_k_chg_ma_rsi[i].ai_ma[8] > as_k_chg_ma_rsi[i].ai_ma[3] ) Then Exit;
+ if( as_k_chg_ma_rsi[i].ai_ma[6] > as_k_chg_ma_rsi[i].ai_ma[3] ) Then Exit;
+ if( as_k_chg_ma_rsi[i].ai_ma[5] > as_k_chg_ma_rsi[i].ai_ma[3] ) Then Exit;
+
+ i_pass_3_mark:=i;
+ W_Log('pass_3',as_k_chg[i].i_date,8,'long pass_3!!!');
+
+ Result :=0;
+
+end;
+
+
+
+function ff_make_long_MA30(i:Integer):Integer;
+var
+ j:Integer;
+ b:Integer;
+ a:Integer;
+ k:Integer;
+begin
+
+ Result := -1;
+
+ if ( i< 888 ) Then Exit;
+
+ if ( i_short_long_01 <> 1 ) Then Exit;
+ if ( i > i_short_long_index +38) Then Exit;
+
+ if( as_k_chg_ma_rsi[i-1].ai_ma[6] < as_k_chg_ma_rsi[i-8].ai_ma[6] ) Then Exit;
+
+ if( as_k_chg[i].i_close < as_k_chg_ma_rsi[i-1].ai_ma[8] ) Then Exit;
+ if( as_k_chg[i].i_close < as_k_chg_ma_rsi[i-1].ai_ma[6] ) Then Exit;
+
+ if( as_k_chg_ma_rsi[i-1].ai_ma[3] < as_k_chg_ma_rsi[i-1].ai_ma[5] ) Then Exit;
+
+ k:=i;
+ b:=0;
+ for j := k-1 downto k-i_BB_BOX_X*2 Do
+ begin
+ if( as_k_chg[j].i_low > as_k_chg_ma_rsi[j].ai_ma[3] ) Then
+ begin
+ b:=j;
+ Break;
+ end;
+ end;
+
+ if( b=0 ) Then Exit;
+
+ if ( ff_get_min_ij_low(b,i) < as_k_chg_ma_rsi[i].ai_ma[3]) and
+ ( ff_get_min_ij_low(b,i) > as_k_chg_ma_rsi[i].ai_ma[5]) and
+ (as_k_chg_ma_rsi[i].ai_ma[3] > as_k_chg_ma_rsi[b].ai_ma[3] ) and
+ (as_k_chg[i].i_close > ff_get_max_ij_high(i-3,i-1) ) and
+ ( as_k_chg[i].i_close > as_k_chg_ma_rsi[i].ai_ma[3] ) Then
+ begin
+ W_Log('LONY_MA30',as_k_chg[i].i_date,i_tmp_log,'MAKE LONG_MA30!!!' );
+ Result :=0;
+ end;
+
+end;
+
+
+function ff_make_long_MA60(i:Integer):Integer;
+var
+ j:Integer;
+ b:Integer;
+ a:Integer;
+ k:Integer;
+begin
+
+ Result := -1;
+
+ if ( i< 888 ) Then Exit;
+
+ if ( i_short_long_01 <> 1 ) Then Exit;
+ if ( i > i_short_long_index +38) Then Exit;
+
+ if( as_k_chg_ma_rsi[i-1].ai_ma[8] < as_k_chg_ma_rsi[i-8].ai_ma[8] ) Then Exit;
+ if( as_k_chg_ma_rsi[i-1].ai_ma[6] < as_k_chg_ma_rsi[i-8].ai_ma[6] ) Then Exit;
+
+ if( as_k_chg[i].i_close < as_k_chg_ma_rsi[i-1].ai_ma[8] ) Then Exit;
+ if( as_k_chg[i].i_close < as_k_chg_ma_rsi[i-1].ai_ma[6] ) Then Exit;
+
+ if( as_k_chg_ma_rsi[i-1].ai_ma[3] < as_k_chg_ma_rsi[i-1].ai_ma[5] ) Then Exit;
+
+ k:=i;
+ b:=0;
+ for j := k-1 downto k-i_BB_BOX_X*2 Do
+ begin
+ if( as_k_chg[j].i_low > as_k_chg_ma_rsi[j].ai_ma[5] ) Then
+ begin
+ b:=j;
+ Break;
+ end;
+ end;
+
+ if( b=0 ) Then Exit;
+
+ if ( ff_get_min_ij_low(b,i) < as_k_chg_ma_rsi[i].ai_ma[5]) and
+ ( ff_get_min_ij_low(b,i) > as_k_chg_ma_rsi[i].ai_ma[6]) and
+ (as_k_chg_ma_rsi[i].ai_ma[5] > as_k_chg_ma_rsi[b].ai_ma[5] ) and
+
+ (as_k_chg[i].i_close > ff_get_max_ij_high(i-3,i-1) ) and
+
+ ( as_k_chg[i].i_close > as_k_chg_ma_rsi[i].ai_ma[5] ) Then
+ begin
+ W_Log('LONY_MA60',as_k_chg[i].i_date,i_tmp_log,'MAKE LONG_MA60!!!' );
+ Result :=0;
+ end;
+
+end;
+
+function ff_make_long_MA250(i:Integer):Integer;
+var
+ j:Integer;
+ b:Integer;
+ a:Integer;
+ k:Integer;
+begin
+
+ Result := -1;
+
+ if ( i< 888 ) Then Exit;
+
+ //if ( i_short_long_01 <> 1 ) Then Exit;
+ //if ( i > i_short_long_index +38) Then Exit;
+
+ if( as_k_chg_ma_rsi[i-1].ai_ma[8] < as_k_chg_ma_rsi[i-8].ai_ma[8] ) Then Exit;
+
+ b:=0;
+ k:=i;
+ for j := k downto k-288 Do
+ begin
+ if(( as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[8] + 20 ) and
+ ( as_k_chg_ma_rsi[j].ai_ma[8] < as_k_chg_ma_rsi[j].ai_ma[6] + 20 ) )Then
+ begin
+ b:=j;
+ Break;
+ end;
+ end;
+
+ if( b=0 ) Then Exit;
+
+ if( as_k_chg_ma_rsi[i-1].ai_ma[8] < as_k_chg_ma_rsi[b].ai_ma[8] ) Then Exit;
+
+ if( i-b< 58 ) Then Exit;
+
+ for j := b+8 to b+58 Do
+ begin
+ if( as_k_chg_ma_rsi[j].ai_ma[6] < as_k_chg_ma_rsi[j].ai_ma[8] ) Then Exit;
+ if( as_k_chg[j].i_close < as_k_chg_ma_rsi[j].ai_ma[8] ) Then Exit;
+ end;
+
+ if (as_k_chg[i].i_close > ff_get_max_ij_high(i-8,i-2) ) and
+ ( ff_get_max_ij_high(i-8,i-2) < as_k_chg_ma_rsi[i].ai_ma[8]) and
+ ( as_k_chg[i].i_close > as_k_chg_ma_rsi[i].ai_ma[8] ) Then
+ begin
+ W_Log('LONY_MA250',as_k_chg[i].i_date,i_tmp_log,'MAKE LONG_MA250!!!' );
+ Result :=0;
+ end;
+
+end;
+
+
+function ff_chk_power_vol(i:Integer):Integer;
+var
+ j:Integer;
+ k:Integer;
+ i_tmp :Integer;
+ i_tmp_1 :Integer;
+ i_up_count_wk :Integer;
+ i_down_count_wk :Integer;
+ i_up_sum_wk :Integer;
+ i_down_sum_wk :Integer;
+
+begin
+
+ Result := -1;
+
+ k:=i-1;
+
+ i_up_count_wk :=0;
+ i_down_count_wk :=0;
+
+ i_up_sum_wk :=0;
+ i_down_sum_wk :=0;
+
+ for j := k downto 8 Do
+ begin
+ i_tmp:= Round(as_k_chg[j].i_date/10000);
+ i_tmp_1 :=Round(as_k_chg[j-1].i_date/10000);
+
+
+ if( i_tmp <> i_tmp_1 ) Then
+ begin
+ Break;
+ end;
+
+ if( as_k_chg[j].i_open < as_k_chg[j].i_close ) and ( as_k_chg[j].i_vol > i_chk_power_vol_wk ) Then
+ begin
+ i_up_count_wk := i_up_count_wk +1;
+ i_up_sum_wk:=i_up_sum_wk + as_k_chg[j].i_vol;
+ end;
+
+ if( as_k_chg[j].i_open > as_k_chg[j].i_close ) and ( as_k_chg[j].i_vol > i_chk_power_vol_wk ) Then
+ begin
+ i_down_count_wk := i_down_count_wk +1;
+ i_down_sum_wk:=i_down_sum_wk + as_k_chg[j].i_vol;
+ end;
+
+ end;
+
+ i_up_count_ex:=i_up_count_wk;
+ i_down_count_ex:=i_down_count_wk;
+ i_up_vol_sum:= i_up_sum_wk;
+ i_down_vol_sum:=i_down_sum_wk;
+
+end;
+
+
+
+//start for big money
+function ff_4ma_make_mbm_long(i:Integer):Integer;
+var
+ j:Integer;
+ b:Integer;
+ k:Integer;
+begin
+
+ Result := -1;
+
+ if ( i< 888 ) Then Exit;
+
+ if(
+ ( as_k_chg_ma_rsi[i-1].ai_ma[6] < as_k_chg_ma_rsi[i-1].ai_ma[5] ) and
+ ( as_k_chg_ma_rsi[i-1].ai_ma[5] < as_k_chg_ma_rsi[i-1].ai_ma[4] ) and
+
+ ( as_k_chg_ma_rsi[i-1].ai_ma[3] > as_k_chg_ma_rsi[i-3].ai_ma[3] ) and
+ ( as_k_chg_ma_rsi[i-1].ai_ma[4] > as_k_chg_ma_rsi[i-3].ai_ma[4] ) and
+ ( as_k_chg_ma_rsi[i-1].ai_ma[5] > as_k_chg_ma_rsi[i-3].ai_ma[5] ) and
+
+ ( as_k_chg_ma_rsi[i-1].ai_ma[4] < as_k_chg_ma_rsi[i-1].ai_ma[3] ) ) Then
+ begin
+ if(i_4ma_mbm_long = 888) Then
+ begin
+ //check how long
+ k:=i;
+ b:=0;
+ for j := k-888 to k Do
+ begin
+ if( not (
+ ( as_k_chg_ma_rsi[j-1].ai_ma[6] > as_k_chg_ma_rsi[j-1].ai_ma[5] ) and
+ ( as_k_chg_ma_rsi[j-1].ai_ma[5] > as_k_chg_ma_rsi[j-1].ai_ma[4] ) and
+ ( as_k_chg_ma_rsi[j-1].ai_ma[4] > as_k_chg_ma_rsi[j-1].ai_ma[3] ) ) )Then
+ begin
+ if( not (
+ ( as_k_chg_ma_rsi[j-1].ai_ma[6] < as_k_chg_ma_rsi[j-1].ai_ma[5] ) and
+ ( as_k_chg_ma_rsi[j-1].ai_ma[5] < as_k_chg_ma_rsi[j-1].ai_ma[4] ) and
+ ( as_k_chg_ma_rsi[j-1].ai_ma[4] < as_k_chg_ma_rsi[j-1].ai_ma[3] ) ) )Then
+ begin
+ b:=j;
+ Break;
+ end;
+ end;
+ end;
+
+ if( b=0 ) Then Exit;
+ if( i-b<18 ) Then Exit;
+
+ i_4ma_long_mbm_mark :=i;
+
+ i_4ma_long_mbm_count_bak :=i_4ma_long_mbm_count;
+ i_4ma_long_mbm_count :=i_4ma_long_mbm_count +1;
+
+ i_sum_4ma_long_mbm_count := i_sum_4ma_long_mbm_count +1;
+
+ if(i_4ma_long_mbm_count <0) Then W_Log('MBM 4ma long',as_k_chg[i].i_date,i_mbm_log+1,PChar('4MA OK! Count:'+IntToStr(i_4ma_long_mbm_count)) );
+
+ if( (i_sum_4ma_long_mbm_count mod 5) =0 ) Then W_Log('MBM 4ma long sum',as_k_chg[i].i_date,i_mbm_log+2,PChar('4MA OK! Count:'+IntToStr(i_sum_4ma_long_mbm_count)+ ' vs 4ma short ' + IntToStr(i_sum_4ma_short_mbm_count) ) );
+
+ i_4ma_mbm_long := m_i_long;
+ end;
+
+ i_4ma_mbm_long := m_i_long;
+ i_4ma_short_mbm_count :=0;
+
+ i_4ma_short_mbm_mark :=0;
+ i_4ma_mbm_short := 888;
+
+ end
+ else
+ begin
+ i_4ma_long_mbm_mark :=0;
+ i_4ma_mbm_long := 888;
+ end;
+
+end;
+
+function ff_4ma_make_mbm_short(i:Integer):Integer;
+var
+ j:Integer;
+ b:Integer;
+ k:Integer;
+begin
+
+ Result := -1;
+
+ if ( i< 888 ) Then Exit;
+
+ if(
+ ( as_k_chg_ma_rsi[i-1].ai_ma[6] > as_k_chg_ma_rsi[i-1].ai_ma[5] ) and
+ ( as_k_chg_ma_rsi[i-1].ai_ma[5] > as_k_chg_ma_rsi[i-1].ai_ma[4] ) and
+
+ ( as_k_chg_ma_rsi[i-1].ai_ma[3] < as_k_chg_ma_rsi[i-5].ai_ma[3] ) and
+ ( as_k_chg_ma_rsi[i-1].ai_ma[4] < as_k_chg_ma_rsi[i-5].ai_ma[4] ) and
+ ( as_k_chg_ma_rsi[i-1].ai_ma[5] < as_k_chg_ma_rsi[i-5].ai_ma[5] ) and
+
+ ( as_k_chg_ma_rsi[i-1].ai_ma[4] > as_k_chg_ma_rsi[i-1].ai_ma[3] ) ) Then
+ begin
+ if(i_4ma_mbm_short = 888) Then
+ begin
+ //check how long
+ k:=i;
+ b:=0;
+ for j := k-888 to k Do
+ begin
+ if( not (
+ ( as_k_chg_ma_rsi[j-1].ai_ma[6] < as_k_chg_ma_rsi[j-1].ai_ma[5] ) and
+ ( as_k_chg_ma_rsi[j-1].ai_ma[5] < as_k_chg_ma_rsi[j-1].ai_ma[4] ) and
+ ( as_k_chg_ma_rsi[j-1].ai_ma[4] < as_k_chg_ma_rsi[j-1].ai_ma[3] ) ) )Then
+ begin
+ if( not (
+ ( as_k_chg_ma_rsi[j-1].ai_ma[6] > as_k_chg_ma_rsi[j-1].ai_ma[5] ) and
+ ( as_k_chg_ma_rsi[j-1].ai_ma[5] > as_k_chg_ma_rsi[j-1].ai_ma[4] ) and
+ ( as_k_chg_ma_rsi[j-1].ai_ma[4] > as_k_chg_ma_rsi[j-1].ai_ma[3] ) ) )Then
+ begin
+ b:=j;
+ Break;
+ end;
+ end;
+ end;
+
+ if( b=0 ) Then Exit;
+ if( i-b<18 ) Then Exit;
+
+
+
+ i_4ma_short_mbm_mark :=i;
+
+ i_4ma_short_mbm_count_bak :=i_4ma_short_mbm_count;
+
+ i_4ma_short_mbm_count :=i_4ma_short_mbm_count +1;
+
+ i_sum_4ma_short_mbm_count := i_sum_4ma_short_mbm_count +1;
+
+ if(i_4ma_short_mbm_count <0) Then W_Log('MBM 4ma_short',as_k_chg[i].i_date,i_mbm_log,PChar('4MA OK! Count:'+IntToStr(i_4ma_short_mbm_count)) );
+
+ if( (i_sum_4ma_short_mbm_count mod 5) =0 ) Then W_Log('MBM short 4ma sum',as_k_chg[i].i_date,i_mbm_log+3,PChar('4MA OK! Count:'+IntToStr(i_sum_4ma_short_mbm_count)+ ' vs 4ma long ' + IntToStr(i_sum_4ma_long_mbm_count) ) );
+
+ i_4ma_mbm_short := m_i_short;
+ end;
+
+ i_4ma_mbm_short := m_i_short;
+
+ i_4ma_long_mbm_count :=0;
+ i_4ma_long_mbm_mark :=0;
+ i_4ma_mbm_long := 888;
+
+ end
+ else
+ begin
+ i_4ma_short_mbm_mark :=0;
+ i_4ma_mbm_short := 888;
+ end;
+
+end;
+
+
+
+
+function ff_make_mbm_long(i:Integer):Integer;
+var
+ j:Integer;
+ b:Integer;
+ k:Integer;
+begin
+
+ Result := -1;
+
+ if(( as_k_chg_ma_rsi[i].ai_ma[8] < as_k_chg_ma_rsi[i].ai_ma[6] + 40 ) and
+ ( as_k_chg_ma_rsi[i].ai_ma[6] < as_k_chg_ma_rsi[i].ai_ma[8] +40 ) )Then
+ begin
+ i_last_120ma250eq_index :=i;
+ end;
+
+ if ( i< 888 ) Then Exit;
+
+ if( ( as_k_chg_ma_rsi[i-1].ai_ma[8] < as_k_chg_ma_rsi[i-1].ai_ma[6] ) and
+ ( as_k_chg_ma_rsi[i-1].ai_ma[6] < as_k_chg_ma_rsi[i-1].ai_ma[5] ) and
+ ( as_k_chg_ma_rsi[i-1].ai_ma[5] < as_k_chg_ma_rsi[i-1].ai_ma[4] ) and
+
+ ( as_k_chg_ma_rsi[i-1].ai_ma[3] > as_k_chg_ma_rsi[i-5].ai_ma[3] ) and
+ ( as_k_chg_ma_rsi[i-1].ai_ma[4] > as_k_chg_ma_rsi[i-5].ai_ma[4] ) and
+ ( as_k_chg_ma_rsi[i-1].ai_ma[5] > as_k_chg_ma_rsi[i-5].ai_ma[5] ) and
+
+ ( as_k_chg_ma_rsi[i-1].ai_ma[4] < as_k_chg_ma_rsi[i-1].ai_ma[3] ) ) Then
+ begin
+ if(i_mbm_long = 888) Then
+ begin
+ //check how long
+ k:=i;
+ b:=0;
+ for j := k-888 to k Do
+ begin
+ if( not ( ( as_k_chg_ma_rsi[j-1].ai_ma[8] > as_k_chg_ma_rsi[j-1].ai_ma[6] ) and
+ ( as_k_chg_ma_rsi[j-1].ai_ma[6] > as_k_chg_ma_rsi[j-1].ai_ma[5] ) and
+ ( as_k_chg_ma_rsi[j-1].ai_ma[5] > as_k_chg_ma_rsi[j-1].ai_ma[4] ) and
+ ( as_k_chg_ma_rsi[j-1].ai_ma[4] > as_k_chg_ma_rsi[j-1].ai_ma[3] ) ) )Then
+ begin
+ if( not ( ( as_k_chg_ma_rsi[j-1].ai_ma[8] < as_k_chg_ma_rsi[j-1].ai_ma[6] ) and
+ ( as_k_chg_ma_rsi[j-1].ai_ma[6] < as_k_chg_ma_rsi[j-1].ai_ma[5] ) and
+ ( as_k_chg_ma_rsi[j-1].ai_ma[5] < as_k_chg_ma_rsi[j-1].ai_ma[4] ) and
+ ( as_k_chg_ma_rsi[j-1].ai_ma[4] < as_k_chg_ma_rsi[j-1].ai_ma[3] ) ) )Then
+ begin
+ b:=j;
+ Break;
+ end;
+ end;
+ end;
+
+ if( b=0 ) Then Exit;
+ if( i-b<58 ) Then Exit;
+
+
+ if(i_long_mbm_count>0) Then
+ begin
+ if( (i-i_long_mbm_index)<18 ) Then Exit;
+ end;
+
+
+ i_long_mbm_mark :=i;
+
+ i_long_mbm_count_bak :=i_long_mbm_count;
+ i_long_mbm_count :=i_long_mbm_count +1;
+
+ i_sum_long_mbm_count := i_sum_long_mbm_count +1;
+
+ if( (i_sum_long_mbm_count mod 5) =0 ) Then W_Log('MBM long sum',as_k_chg[i].i_date,i_mbm_log+4,PChar('4MA OK! Count:'+IntToStr(i_sum_long_mbm_count)+ ' vs short ' + IntToStr(i_sum_short_mbm_count) ) );
+
+ if (i_long_mbm_count = 1) Then i_long_mbm_count_action_1:=1 else i_long_mbm_count_action_1:=0;
+
+ if ( i_long_mbm_count<3 ) and ( i_long_mbm_count>0 ) Then
+ begin
+
+ Result :=0;
+
+ if ( i_long_mbm_count=2 ) Then Result :=0 else Result :=1;
+
+ if( i_4ma_long_mbm_count >4 ) and ( i_long_mbm_count=1 ) Then Result :=0;
+
+ //if( i_4ma_long_mbm_count <3 ) and ( i_long_mbm_count=2 ) Then Result :=1;
+
+ //if( i_4ma_long_mbm_count >2 ) and ( i_long_mbm_count=3 ) Then Result :=0;
+
+ {
+ if(i_short_mbm_count >5) and ( i_long_mbm_count=1 ) Then Result :=1;
+ //20120918 for test //
+ if(i_short_mbm_count_bak >5) and ( i_long_mbm_count=2 ) Then Result :=1;
+
+ if(i_short_mbm_count_bak >5) Then Result :=1;
+
+ if(i_long_mbm_count_bak >5) and ( i_long_mbm_count=1 ) Then Result :=1;
+ if(i_long_mbm_count_bak >5) and ( i_long_mbm_count=2 ) Then Result :=1;
+
+ if(Result =0) Then W_Log('MBM long',as_k_chg[i].i_date,i_wk_log,PChar('MA OK! Count:'+IntToStr(i_long_mbm_count)) );
+ }
+ i_long_mbm_index :=i;
+
+ end;
+
+ if(i_long_mbm_count <88) Then W_Log('MBM long',as_k_chg[i].i_date,i_mbm_log+1,PChar('MA OK! Count:'+IntToStr(i_long_mbm_count)) );
+
+ i_mbm_long := m_i_long;
+ end;
+
+ i_mbm_long := m_i_long;
+ f_mbm_cut_long :=f_rsi_cut*1.5;
+ f_mbm_stop_long :=f_rsi_stop*2;
+
+ i_long_mbm_index_1 :=i;
+
+ i_short_mbm_count :=0;
+
+ i_short_mbm_mark :=0;
+ i_mbm_short := 888;
+ f_mbm_cut_short :=0.0;
+ f_mbm_stop_short :=0.0;
+
+ end
+ else
+ begin
+ i_long_mbm_mark :=0;
+ i_mbm_long := 888;
+ f_mbm_cut_long :=0.0;
+ f_mbm_stop_long :=0.0;
+ end;
+
+ if (i_mbm_long = m_i_long) and ( as_k_chg[i].i_close < as_k_chg_ma_rsi[i].ai_ma[4] ) Then
+ begin
+ f_mbm_cut_long :=0.0;
+ f_mbm_stop_long :=0.0;
+ end;
+
+ if ( i_long_mbm_count_action_1=1 ) Then
+ begin
+ //i_long_mbm_count_action_1:=0;
+ //i_long_mbm_index :=i;
+ //W_Log('MBM Action_1',as_k_chg[i].i_date,i_tmp_log,'MBM do long!!!' );
+ //Result :=0;
+ //Exit;
+ end;
+
+
+ if ( i i_long_mbm_mark +58 ) Then Exit;
+
+ //if (i < i_long_mbm_mark + 3 ) Then Exit;
+ //if (i > i_last_120ma250eq_index +78 ) Then Exit;
+
+ if(i_long_mbm_count >3) Then Exit;
+
+ if (i_mbm_long = m_i_long) and
+ //(as_k_chg[i].i_close > ff_get_max_ij_high(i-3,i-1) ) and
+ ( as_k_chg[i].i_close > as_k_chg_ma_rsi[i].ai_ma[3] ) Then
+ begin
+ //i_long_mbm_index :=i;
+ //W_Log('MBM Action',as_k_chg[i].i_date,i_tmp_log,'Set MBM long lamp!!!' );
+ //Result :=0;
+ end;
+
+end;
+
+
+function ff_make_mbm_short(i:Integer):Integer;
+var
+ j:Integer;
+ b:Integer;
+ k:Integer;
+begin
+
+ Result := -1;
+
+ if(( as_k_chg_ma_rsi[i].ai_ma[8] < as_k_chg_ma_rsi[i].ai_ma[6] + 40 ) and
+ ( as_k_chg_ma_rsi[i].ai_ma[6] < as_k_chg_ma_rsi[i].ai_ma[8] +40 ) )Then
+ begin
+ i_last_120ma250eq_index :=i;
+ end;
+
+ if ( i< 888 ) Then Exit;
+
+ if( ( as_k_chg_ma_rsi[i-1].ai_ma[8] > as_k_chg_ma_rsi[i-1].ai_ma[6] ) and
+ ( as_k_chg_ma_rsi[i-1].ai_ma[6] > as_k_chg_ma_rsi[i-1].ai_ma[5] ) and
+ ( as_k_chg_ma_rsi[i-1].ai_ma[5] > as_k_chg_ma_rsi[i-1].ai_ma[4] ) and
+
+ ( as_k_chg_ma_rsi[i-1].ai_ma[3] < as_k_chg_ma_rsi[i-5].ai_ma[3] ) and
+ ( as_k_chg_ma_rsi[i-1].ai_ma[4] < as_k_chg_ma_rsi[i-5].ai_ma[4] ) and
+ ( as_k_chg_ma_rsi[i-1].ai_ma[5] < as_k_chg_ma_rsi[i-5].ai_ma[5] ) and
+
+ ( as_k_chg_ma_rsi[i-1].ai_ma[4] > as_k_chg_ma_rsi[i-1].ai_ma[3] ) ) Then
+ begin
+ if(i_mbm_short = 888) Then
+ begin
+ //check how long
+ k:=i;
+ b:=0;
+ for j := k-888 to k Do
+ begin
+ if( not ( ( as_k_chg_ma_rsi[j-1].ai_ma[8] < as_k_chg_ma_rsi[j-1].ai_ma[6] ) and
+ ( as_k_chg_ma_rsi[j-1].ai_ma[6] < as_k_chg_ma_rsi[j-1].ai_ma[5] ) and
+ ( as_k_chg_ma_rsi[j-1].ai_ma[5] < as_k_chg_ma_rsi[j-1].ai_ma[4] ) and
+ ( as_k_chg_ma_rsi[j-1].ai_ma[4] < as_k_chg_ma_rsi[j-1].ai_ma[3] ) ) )Then
+ begin
+ if( not ( ( as_k_chg_ma_rsi[j-1].ai_ma[8] > as_k_chg_ma_rsi[j-1].ai_ma[6] ) and
+ ( as_k_chg_ma_rsi[j-1].ai_ma[6] > as_k_chg_ma_rsi[j-1].ai_ma[5] ) and
+ ( as_k_chg_ma_rsi[j-1].ai_ma[5] > as_k_chg_ma_rsi[j-1].ai_ma[4] ) and
+ ( as_k_chg_ma_rsi[j-1].ai_ma[4] > as_k_chg_ma_rsi[j-1].ai_ma[3] ) ) )Then
+ begin
+ b:=j;
+ Break;
+ end;
+ end;
+ end;
+
+ if( b=0 ) Then Exit;
+ if( i-b<58 ) Then Exit;
+
+ if(i_short_mbm_count>0) Then
+ begin
+ if( (i-i_short_mbm_index)<18 ) Then Exit;
+ end;
+
+ i_short_mbm_mark :=i;
+
+ i_short_mbm_count_bak :=i_short_mbm_count;
+
+ i_short_mbm_count :=i_short_mbm_count +1;
+
+ i_sum_short_mbm_count := i_sum_short_mbm_count +1;
+ if( (i_sum_short_mbm_count mod 5) =0 ) Then W_Log('MBM short sum',as_k_chg[i].i_date,i_mbm_log+5,PChar('4MA OK! Count:'+IntToStr(i_sum_short_mbm_count)+ ' vs 4ma long ' + IntToStr(i_sum_long_mbm_count) ) );
+
+ if (i_short_mbm_count = 1) Then i_short_mbm_count_action_1:=1 else i_short_mbm_count_action_1:=0;
+
+ if ( i_short_mbm_count<3 ) and ( i_short_mbm_count>0 ) Then
+ begin
+ Result :=0;
+
+ if ( i_short_mbm_count=2 ) Then Result :=0 else Result :=1;
+ if( i_4ma_short_mbm_count >4 ) and ( i_short_mbm_count=1 ) Then Result :=0;
+ //if( i_4ma_short_mbm_count <3 ) and ( i_short_mbm_count=2 ) Then Result :=1;
+ //if( i_4ma_short_mbm_count >2 ) and ( i_short_mbm_count=3 ) Then Result :=0;
+
+ {
+ if(i_long_mbm_count >3) and ( i_short_mbm_count=1 ) Then Result :=1;
+ //20120918 for test //
+ if(i_long_mbm_count_bak >3) and ( i_short_mbm_count=2 ) Then Result :=1;
+ if(i_short_mbm_count_bak >3) and ( i_short_mbm_count=1 ) Then Result :=1;
+ if(i_short_mbm_count_bak >3) and ( i_short_mbm_count=2 ) Then Result :=1;
+ if(Result =0) Then W_Log('MBM short',as_k_chg[i].i_date,i_wk_log,PChar('MA OK! Count:'+IntToStr(i_short_mbm_count)) );
+ }
+ i_short_mbm_index :=i;
+
+ end;
+
+
+ if(i_short_mbm_count <88) Then W_Log('MBM short',as_k_chg[i].i_date,i_mbm_log,PChar('MA OK! Count:'+IntToStr(i_short_mbm_count)) );
+
+ i_mbm_short := m_i_short;
+ end;
+
+ i_mbm_short := m_i_short;
+ f_mbm_cut_short :=f_rsi_cut*1.5;
+ f_mbm_stop_short :=f_rsi_stop*2;
+
+ i_short_mbm_index_1 :=i;
+
+
+ i_long_mbm_count :=0;
+ i_long_mbm_mark :=0;
+ i_mbm_long := 888;
+ f_mbm_cut_long :=0.0;
+ f_mbm_stop_long :=0.0;
+
+
+ end
+ else
+ begin
+ i_short_mbm_mark :=0;
+ i_mbm_short := 888;
+ f_mbm_cut_short :=0.0;
+ f_mbm_stop_short :=0.0;
+
+ end;
+
+ if (i_mbm_short = m_i_short) and ( as_k_chg[i].i_close > as_k_chg_ma_rsi[i].ai_ma[4] ) Then
+ begin
+ f_mbm_cut_short :=0.0;
+ f_mbm_stop_short :=0.0;
+ end;
+
+ if ( i_short_mbm_count_action_1=1 ) Then
+ begin
+ //i_short_mbm_count_action_1:=0;
+ //i_short_mbm_index :=i;
+ //W_Log('MBM Action_1',as_k_chg[i].i_date,i_tmp_log,'MBM do short!' );
+ //Result :=0;
+ //Exit;
+ end;
+
+ if ( i < i_long_mbm_index_1 + 168 ) Then Exit;
+
+ if( i - i_short_mbm_index < i_BB_BOX_X*2 ) Then Exit;
+
+ if (i > i_short_mbm_mark +58 ) Then Exit;
+ //if (i < i_short_mbm_mark +3 ) Then Exit;
+
+ //if (i > i_last_120ma250eq_index +68 ) Then Exit;
+
+ if(i_short_mbm_count >3) Then Exit;
+
+
+ if (i_mbm_short = m_i_short) and
+ //(as_k_chg[i].i_close < ff_get_min_ij_low(i-3,i-1) ) and
+ ( as_k_chg[i].i_close < as_k_chg_ma_rsi[i].ai_ma[3] ) Then
+ begin
+ //i_short_mbm_index :=i;
+ //W_Log('MBM Action',as_k_chg[i].i_date,i_tmp_log,'Set MBM short lamp!!!' );
+ //Result :=0;
+ end;
+
+end;
+
+
+//end for big money
+
+
+function ff_set_caption():Integer;
+var
+ p,q:PChar;
+ i_loop_wk:Integer;
+begin
+ MAINFORM.Label1.Caption :=s_caption_1;
+ MAINFORM.Label2.Caption :=s_caption_2;
+ MAINFORM.Label3.Caption :=s_caption_3;
+ MAINFORM.Label4.Caption :=s_caption_4;
+ MAINFORM.Label5.Caption :=s_caption_5;
+ MAINFORM.Label6.Caption :=s_caption_6;
+ MAINFORM.Label7.Caption :=s_caption_7;
+ MAINFORM.Label8.Caption :=s_caption_8;
+ MAINFORM.Label9.Caption :=s_caption_9;
+ MAINFORM.Label10.Caption :=s_caption_10;
+ MAINFORM.Label11.Caption :=s_caption_11;
+ MAINFORM.Label12.Caption :=s_caption_12;
+ MAINFORM.Label13.Caption :=s_caption_13;
+ MAINFORM.Label14.Caption :=s_caption_14;
+ MAINFORM.Label15.Caption :=s_caption_15;
+ MAINFORM.Label16.Caption :=s_caption_16;
+ MAINFORM.Label_status.Caption :=s_caption_status;
+
+ MAINFORM.Label_Vol.Caption :=s_caption_vol;
+ MAINFORM.Label_long_stp.Caption :=s_caption_long_stp;
+ MAINFORM.Label_short_stp.Caption :=s_caption_short_stp;
+
+ if (i_lock_short=0) Then MAINFORM.N5.Checked:=False;
+ if (i_lock_long=0) Then MAINFORM.N4.Checked:=False;
+ if (i_lock_short>0) Then MAINFORM.N5.Checked:=True;
+ if (i_lock_long>0) Then MAINFORM.N4.Checked:=True;
+
+ if MAINFORM.N4.Checked =True Then s_caption_15 :='Ëø' else s_caption_15 :=' ';
+ if MAINFORM.N5.Checked =True Then s_caption_16 :='Ëø' else s_caption_16 :=' ';
+
+ if (i_stp_short=0) Then MAINFORM.Short_STP.Checked:=False;
+ if (i_stp_long=0) Then MAINFORM.Long_STP.Checked:=False;
+ if (i_stp_short>0) Then MAINFORM.Short_STP.Checked:=True;
+ if (i_stp_long>0) Then MAINFORM.Long_STP.Checked:=True;
+
+ if MAINFORM.Short_STP.Checked =True Then s_caption_short_stp :='+' else s_caption_short_stp :=' ';
+ if MAINFORM.Long_STP.Checked =True Then s_caption_long_stp :='+' else s_caption_long_stp :=' ';
+
+ if( StrLen(PChar(MAINFORM.Edit_vol_chk.Text)) >2 ) Then i_chk_power_vol_wk := StrToInt(MAINFORM.Edit_vol_chk.Text)
+ else i_chk_power_vol_wk :=1000;
+
+ MAINFORM.Label_up_power.Caption := '¶à·½Á¿ÄÜ '+IntToStr(i_up_count_ex) + ' : '+IntToStr(i_up_vol_sum);
+ MAINFORM.Label_down_power.Caption :='¿Õ·½Á¿ÄÜ '+IntToStr(i_down_count_ex) + ' : '+IntToStr(i_down_vol_sum);
+
+ if i_show_string_grid <1 Then
+ begin
+ MAINFORM.Height :=418;
+ end
+ else
+ begin
+ MAINFORM.ff_sg.Height:=558;
+ MAINFORM.Height :=988;
+ MAINFORM.Top:=1;
+ MAINFORM.Left:=1;
+
+ for i_loop_wk := 0 to i_fc_count-1 Do
+ begin
+ MAINFORM.ff_sg.Cells[0,i_loop_wk+1] :=as_fc_data[i_loop_wk].pc_username;
+ MAINFORM.ff_sg.Cells[1,i_loop_wk+1] :=as_fc_data[i_loop_wk].pc_xxx_name;
+ MAINFORM.ff_sg.Cells[2,i_loop_wk+1] :=IntToStr(as_fc_data[i_loop_wk].i_got_it_mark);
+
+ if (as_fc_data[i_loop_wk].i_got_it_mark >0) then
+ begin
+ MAINFORM.ff_sg.Cells[2,i_loop_wk+1] :=FloatToStrF(as_fc_data[i_loop_wk].f_business_price,ffFixed,8,2);
+ MAINFORM.ff_sg.Cells[3,i_loop_wk+1] :=IntToStr(as_fc_data[i_loop_wk].i_got_it_mark);
+ end
+ else
+ begin
+ MAINFORM.ff_sg.Cells[2,i_loop_wk+1] :=' ';
+ MAINFORM.ff_sg.Cells[3,i_loop_wk+1] :=' ';
+ end;
+
+ if (as_fc_data[i_loop_wk].i_short_mark >0 ) then
+ begin
+ MAINFORM.ff_sg.Cells[4,i_loop_wk+1] :=FloatToStrF(as_fc_data[i_loop_wk].f_short_price,ffFixed,8,2);
+ MAINFORM.ff_sg.Cells[5,i_loop_wk+1] :=IntToStr(as_fc_data[i_loop_wk].i_short_mark);
+ end
+ else
+ begin
+ MAINFORM.ff_sg.Cells[4,i_loop_wk+1] :=' ';
+ MAINFORM.ff_sg.Cells[5,i_loop_wk+1] :=' ';
+ end;
+ MAINFORM.ff_sg.Cells[6,i_loop_wk+1] :=FloatToStrF(as_fc_data[i_loop_wk].f_rights_balance,ffFixed,11,2);
+ end;
+ end;
+
+ if( StrLen(PChar(MAINFORM.Edit_open_price.Text)) >3 ) Then
+ begin
+ FillChar(c_open_price,SizeOf(c_open_price),0);
+ StrCopy(c_open_price,PChar(MAINFORM.Edit_open_price.Text));
+ end;
+
+ if( StrLen(c_open_price) >3 ) Then
+ begin
+ i_open_vol :=0;
+ q:=StrPos(c_open_price,':');
+ if(q <>nil) Then
+ begin
+ q[0]:=#0;
+ p:=@q[1];
+ i_open_price :=StrToInt(c_open_price);
+ if(StrLen(p) >0) Then i_open_vol :=StrToInt(p);
+ end
+ else
+ i_open_price := StrToInt(c_open_price)
+ end
+ else i_open_price :=0;
+
+end;
+
+
+
+function ff_load_k_base():Integer;
+var
+ //iFileHandle : Integer;
+ iFileLength : Integer;
+ iBytesRead : Integer;
+ i :Integer;
+ k_line_file_name :String;
+ pc_Buffer :PChar;
+
+begin
+
+ Result :=0;
+
+ FillChar(as_k_chg,SizeOf(as_k_chg),0);
+ FillChar(as_k_chg_ma_rsi,sizeof(as_k_chg_ma_rsi),0);
+
+ pc_Buffer := @as_k_chg[0];
+
+ tm_0 := Now;
+ tm_1 := Now;
+
+ k_line_file_name :=m_k_line_file_name;
+
+ if not FileExists(k_line_file_name) then
+ begin
+ iFileHandle := FileCreate(k_line_file_name);
+ FileClose(iFileHandle);
+ end;
+
+ iFileHandle :=FileOpen(k_line_file_name,fmOpenRead);
+ if iFileHandle > -1 Then
+ begin
+ iFileLength := FileSeek(iFileHandle,0,2);
+ FileSeek(iFileHandle,0,0);
+
+ if( iFileLength > (m_i_max_chg_kline_in_mem -5888)*SizeOf(s_k_line_data) ) then
+ FileSeek(iFileHandle,
+ iFileLength -(m_i_max_chg_kline_in_mem -5888)*SizeOf(s_k_line_data) ,0);
+
+ iBytesRead := FileRead(iFileHandle, pc_Buffer^, iFileLength);
+ FileClose(iFileHandle);
+ end
+ else Exit;
+
+ DeleteFile(k_line_file_name);
+ iFileHandle := FileCreate(k_line_file_name);
+
+
+ if iBytesRead > 0 Then
+ begin
+
+ for i := 0 to Round(iBytesRead/SizeOf(s_k_line_data)-1) do
+ begin
+ if ( as_k_chg[i].i_open > 0 ) and ( as_k_chg[i].i_low > 0 ) then
+ FileWrite(iFileHandle, as_k_chg[i], SizeOf(s_k_line_data));
+ end;
+ i_s_k_chg_index_wk :=Round(iBytesRead/SizeOf(s_k_line_data)) - 1 + 1;
+ i_s_k_chg_index_load := Round(iBytesRead/SizeOf(s_k_line_data));
+ i_as_k_base_init_flag :=888;
+ i_as_k_chg_init_flag:=888;
+
+ as_k_chg[i_s_k_chg_index_wk].i_open := as_k_chg[i_s_k_chg_index_wk-1].i_open;
+ as_k_chg[i_s_k_chg_index_wk].i_close :=as_k_chg[i_s_k_chg_index_wk-1].i_close;
+ as_k_chg[i_s_k_chg_index_wk].i_high :=as_k_chg[i_s_k_chg_index_wk-1].i_high;
+ as_k_chg[i_s_k_chg_index_wk].i_low := as_k_chg[i_s_k_chg_index_wk-1].i_low;
+
+ for i := 0 to i_s_k_chg_index_wk do ff_make_ma_rsi_ex(i);
+
+ end
+ else i_s_k_chg_index_wk :=0;
+
+ FileClose(iFileHandle);
+
+End;
+
+function ff_passwd_chg(
+ pc_account:PChar;
+ pc_password_type:PChar;
+ pc_old_password:PChar;
+ pc_new_password:PChar ):Integer;
+var
+ iRet :Integer;
+ lpReqMsg,lpAnsMsg:IFuMessage;
+ lpRecord,lpAnsRecord:IFuRecord;
+ c_log :array [0..88] of char;
+
+begin
+ Result :=0;
+
+ if not Assigned(m_lpComm) then Exit;
+ if ( i_comm_ok = 0 ) Then Exit;
+
+ //ÒµÎñ²Ù×÷ίÍÐϵ¥
+ lpReqMsg := NewFuMessage(MSG_TYPE_MODIFY_PASSWORD,Integer(MSG_MODE_REQUEST)); //¿Í»§ÐÞ¸ÄÃÜÂë
+ lpAnsMsg := NewFuMessage(MSG_TYPE_UNKNOWN,Integer(MSG_MODE_ANSWER)); //½ÓÊÕÏûÏ¢(ÎÞ¹ØÏûÏ¢ÀàÐÍ)
+
+ //´ò°üÇëÇó²ÎÊý(×Ö¶Î˳ÐòÎÞ¹Ø,Öظ´ÉèÖÃ×Ö¶ÎÔò¸²¸ÇÆäÖµ)
+ lpRecord := lpReqMsg.AddRecord();
+
+
+ lpRecord.SetString('fund_account',pc_account);
+ lpRecord.SetString('password_type',pc_password_type);
+ lpRecord.SetString('password', pc_old_password);
+ lpRecord.SetString('new_password', pc_new_password);
+
+ //ͬ²½½ÓÊÕÏûÏ¢
+ iRet := m_lpComm.SyncSendRecv(lpReqMsg,lpAnsMsg);
+ if iRet <> 0 then
+ begin
+ //cout<<"ͬ²½Î¯ÍÐʧ°Ü:iRet="<GetErrorMsg(iRet)<0 then
+ begin
+ lpAnsRecord := lpAnsMsg.GetRecord(0);
+ FillChar(c_log,SizeOf(c_log),0);
+ StrCopy(c_log,lpAnsRecord.GetString('result'));
+
+ W_Log(pc_new_password,i_tmp_log,i_wk_log,c_log);
+ end;
+
+ lpReqMsg.Release();
+ lpAnsMsg.Release();
+end;
+
+
+
+
+
+
+function ff_order_ex(
+ pc_contract_code:PChar;
+ pc_entrust_price:PChar;
+ pc_entrust_amount:PChar;
+ pc_entrust_bs:PChar;
+ pc_direction:PChar ):Integer;
+var
+ iRet :Integer;
+ lpReqMsg,lpAnsMsg:IFuMessage;
+ lpRecord,lpAnsRecord:IFuRecord;
+begin
+ Result :=0;
+
+ if not Assigned(m_lpComm) then Exit;
+ if ( i_comm_ok = 0 ) Then Exit;
+
+ //ÒµÎñ²Ù×÷ίÍÐϵ¥
+ lpReqMsg := NewFuMessage(MSG_TYPE_NEW_SINGLE_ORDER,Integer(MSG_MODE_REQUEST)); //ίÍÐϵ¥
+ lpAnsMsg := NewFuMessage(MSG_TYPE_UNKNOWN,Integer(MSG_MODE_ANSWER)); //½ÓÊÕÏûÏ¢(ÎÞ¹ØÏûÏ¢ÀàÐÍ)
+
+ //´ò°üÇëÇó²ÎÊý(×Ö¶Î˳ÐòÎÞ¹Ø,Öظ´ÉèÖÃ×Ö¶ÎÔò¸²¸ÇÆäÖµ)
+ lpRecord := lpReqMsg.AddRecord();
+
+
+ lpRecord.SetString('fund_account',pc_username);
+ //lpRecord.SetString('password',pc_user_pwd);
+ lpRecord.SetString('futu_exch_type','F4');
+ lpRecord.SetString('futures_account','');
+ lpRecord.SetString('contract_code',pc_contract_code);
+ //buy
+ lpRecord.SetString('entrust_bs',pc_entrust_bs);
+ //long,open
+ lpRecord.SetString('futures_direction',pc_direction);
+
+ lpRecord.SetString('hedge_type','0');
+ lpRecord.SetString('futu_entrust_prop','0');
+
+
+ lpRecord.SetString('futu_entrust_price',pc_entrust_price);
+
+ lpRecord.SetString('entrust_amount',pc_entrust_amount);
+
+ lpRecord.SetString('entrust_kind','0');
+
+ //ͬ²½½ÓÊÕÏûÏ¢
+ iRet := m_lpComm.SyncSendRecv(lpReqMsg,lpAnsMsg);
+ if iRet <> 0 then
+ begin
+
+ if lpAnsMsg.GetCount()>0 then
+ begin
+
+ lpAnsRecord := lpAnsMsg.GetRecord(0);
+ FillChar(c_error_no,SizeOf(c_error_no),0);
+ FillChar(c_error_info,SizeOf(c_error_info),0);
+
+ StrCopy(c_error_no,lpAnsRecord.GetString('error_no'));
+ StrCopy(c_error_info,lpAnsRecord.GetString('error_info'));
+
+ W_Log('order_ex_error',iRet,i_wk_log,c_error_no);
+ W_Log('order_ex_error',iRet,i_wk_log,c_error_info);
+
+ end;
+
+
+ //cout<<"ͬ²½Î¯ÍÐʧ°Ü:iRet="<GetErrorMsg(iRet)<0 then
+ begin
+ lpAnsRecord := lpAnsMsg.GetRecord(0);
+ FillChar(c_batch_no,SizeOf(c_batch_no),0);
+ FillChar(c_entrust_no,SizeOf(c_entrust_no),0);
+
+ StrCopy(c_entrust_no,lpAnsRecord.GetString('entrust_no'));
+ StrCopy(c_entrust_no,lpAnsRecord.GetString('batch_no'));
+ end;
+
+ lpReqMsg.Release();
+ lpAnsMsg.Release();
+end;
+
+
+
+function ff_entrust_no(pc_contract_code:PChar):Integer;
+var
+ iRet :Integer;
+ lpReqMsg,lpAnsMsg:IFuMessage;
+ lpRecord,lpAnsRecord:IFuRecord;
+begin
+ Result :=0;
+
+ if not Assigned(m_lpComm) then Exit;
+ if ( i_comm_ok = 0 ) Then Exit;
+
+ FillChar(c_batch_no,SizeOf(c_batch_no),0);
+ FillChar(c_entrust_no,SizeOf(c_entrust_no),0);
+
+
+ //ÒµÎñ²Ù×÷ίÍÐϵ¥
+ lpReqMsg := NewFuMessage(MSG_TYPE_GET_ENTRUST_ORDERS,Integer(MSG_MODE_REQUEST)); //ίÍÐϵ¥
+ lpAnsMsg := NewFuMessage(MSG_TYPE_UNKNOWN,Integer(MSG_MODE_ANSWER)); //½ÓÊÕÏûÏ¢(ÎÞ¹ØÏûÏ¢ÀàÐÍ)
+
+ //´ò°üÇëÇó²ÎÊý(×Ö¶Î˳ÐòÎÞ¹Ø,Öظ´ÉèÖÃ×Ö¶ÎÔò¸²¸ÇÆäÖµ)
+ lpRecord := lpReqMsg.AddRecord();
+
+
+ lpRecord.SetString('fund_account',pc_username);
+ //lpRecord.SetString('password',pc_user_pwd);
+ lpRecord.SetString('futu_exch_type','F4');
+ lpRecord.SetString('futures_account','');
+ lpRecord.SetString('contract_code',pc_contract_code);
+
+ lpRecord.SetString('en_entrust_status','012347C');
+ lpRecord.SetString('query_direction','0');
+
+ lpRecord.SetString('futu_entrust_type','0');
+
+ //ͬ²½½ÓÊÕÏûÏ¢
+ iRet := m_lpComm.SyncSendRecv(lpReqMsg,lpAnsMsg);
+ if iRet <> 0 then
+ begin
+ //cout<<"ͬ²½Î¯ÍÐʧ°Ü:iRet="<GetErrorMsg(iRet)<0 then
+ begin
+
+ lpAnsRecord := lpAnsMsg.GetRecord(0);
+ FillChar(c_batch_no,SizeOf(c_batch_no),0);
+ FillChar(c_entrust_no,SizeOf(c_entrust_no),0);
+
+ StrCopy(c_entrust_no,lpAnsRecord.GetString('entrust_no'));
+ StrCopy(c_entrust_no,lpAnsRecord.GetString('batch_no'));
+
+ i_entrust_no_mark :=888;
+
+ end;
+
+ lpReqMsg.Release();
+ lpAnsMsg.Release();
+
+end;
+
+
+function ff_cancel_entrust_no():Integer;
+var
+ iRet :Integer;
+ lpReqMsg,lpAnsMsg:IFuMessage;
+ lpRecord:IFuRecord;
+ lpAnsRecord:IFuRecord;
+
+begin
+ Result :=0;
+
+ iRet := StrLen(c_entrust_no);
+ if(iRet =0) Then Exit;
+
+ if not Assigned(m_lpComm) then Exit;
+ if ( i_comm_ok = 0 ) Then Exit;
+
+ //ÒµÎñ²Ù×÷ίÍÐϵ¥
+ lpReqMsg := NewFuMessage(MSG_TYPE_CANCEL_ORDER,Integer(MSG_MODE_REQUEST));
+ lpAnsMsg := NewFuMessage(MSG_TYPE_UNKNOWN,Integer(MSG_MODE_ANSWER)); //½ÓÊÕÏûÏ¢(ÎÞ¹ØÏûÏ¢ÀàÐÍ)
+
+ //´ò°üÇëÇó²ÎÊý(×Ö¶Î˳ÐòÎÞ¹Ø,Öظ´ÉèÖÃ×Ö¶ÎÔò¸²¸ÇÆäÖµ)
+ lpRecord := lpReqMsg.AddRecord();
+
+ lpRecord.SetString('fund_account',pc_username);
+ //lpRecord.SetString('password',pc_user_pwd);
+ lpRecord.SetString('futu_exch_type','F4');
+ lpRecord.SetString('entrust_no',c_entrust_no); //ίÍкÅ
+
+ //ͬ²½½ÓÊÕÏûÏ¢
+ iRet := m_lpComm.SyncSendRecv(lpReqMsg,lpAnsMsg);
+ if iRet <> 0 then
+ begin
+
+ if lpAnsMsg.GetCount()>0 then
+ begin
+
+ lpAnsRecord := lpAnsMsg.GetRecord(0);
+ FillChar(c_error_no,SizeOf(c_error_no),0);
+ FillChar(c_error_info,SizeOf(c_error_info),0);
+
+ StrCopy(c_error_no,lpAnsRecord.GetString('error_no'));
+ StrCopy(c_error_info,lpAnsRecord.GetString('error_info'));
+
+ W_Log('cancel_error',iRet,i_wk_log,c_error_no);
+ W_Log('cancel_error',iRet,i_wk_log,c_error_info);
+
+ end;
+
+
+ //cout<<"ͬ²½Î¯ÍÐʧ°Ü:iRet="<GetErrorMsg(iRet)<0) Then
+ begin
+ for I := 0 to i_get_count-1 do
+ begin
+ lpAnsRecord := lpAnsMsg.GetRecord(I);
+ FillChar(c_log,SizeOf(c_log),0);
+
+ StrCopy(c_log,lpAnsRecord.GetString('contract_code'));
+ s_tmp:=c_log;
+ s_tmp1:=pc_what_wk;
+
+ FillChar(c_log,SizeOf(c_log),0);
+
+ StrCopy(c_log,lpAnsRecord.GetString('entrust_bs'));
+ if c_log[0] = '2' Then
+ begin
+ if(s_tmp = s_tmp1) Then
+ begin
+
+ StrCopy(c_log,lpAnsRecord.GetString('futu_average_price'));
+ f_short_price :=StrToFloat(c_log);
+
+
+ s_caption_9:='¿Õ '+Trim(c_log);
+
+ FillChar(c_log,SizeOf(c_log),0);
+ StrCopy(c_log,lpAnsRecord.GetString('real_amount'));
+
+
+ i_short_mark :=Round(StrToFloat(c_log));
+
+ s_caption_11:=Trim(c_log);
+
+ if(i_short_mark > (i_F + i_S -1)) then i_short_S_mark :=888 else i_short_S_mark :=0;
+ if(i_short_mark > (i_F + i_S + i_T -1)) then i_short_T_mark :=888 else i_short_T_mark :=0;
+ end
+ end
+ else if c_log[0] = '1' Then
+ begin
+ if(s_tmp = s_tmp1) Then
+ begin
+
+ StrCopy(c_log,lpAnsRecord.GetString('futu_average_price'));
+
+ f_business_price :=StrToFloat(c_log);
+
+ s_caption_8:='¶à '+Trim(c_log);
+
+ FillChar(c_log,SizeOf(c_log),0);
+
+ StrCopy(c_log,lpAnsRecord.GetString('real_amount'));
+
+ s_caption_10:=Trim(c_log);
+
+ i_got_it_mark :=Round(StrToFloat(c_log));
+
+ if(i_got_it_mark > (i_F + i_S -1) ) then i_get_S_mark :=888 else i_get_S_mark :=0;
+ if(i_got_it_mark > (i_F + i_S + i_T -1 )) then i_get_T_mark :=888 else i_get_T_mark:=0;
+ end;
+ end;
+ end;
+ end
+ else
+ begin
+
+ i_got_it_mark :=0;
+ i_get_S_mark :=0;
+ i_get_T_mark :=0;
+ i_short_mark :=0;
+ i_short_S_mark :=0;
+ i_short_T_mark :=0;
+
+ //frmMain2.GRID_S001.Cells[0,0]:=pc_what_wk;
+
+ end;
+
+ lpReqMsg.Release();
+ lpAnsMsg.Release();
+
+ if(i_long_act_flag=-1) and (i_got_it_mark =0) Then i_long_act_flag :=1;
+ if(i_short_act_flag=-1) and (i_short_mark =0) Then i_short_act_flag :=1;
+
+end;
+
+
+function ff_get_qty_ex():Integer;
+var
+ iRet :Integer;
+ lpReqMsg,lpAnsMsg:IFuMessage;
+ lpRecord,lpAnsRecord:IFuRecord;
+ c_log :array [0..88] of char;
+ s_tmp:string;
+ s_tmp1:string;
+
+ I,i_get_count:Integer;
+
+begin
+ Result :=0;
+
+ if not Assigned(m_lpComm) then Exit;
+
+ if ( i_comm_ok = 0 ) Then Exit;
+
+ //for
+ i_short_mark_ex :=0;
+ i_got_it_mark_ex:=0;
+ f_short_price_ex :=0.0;
+ f_business_price_ex :=0.0;
+
+ //ÒµÎñ²Ù×÷ίÍÐϵ¥
+ lpReqMsg := NewFuMessage(MSG_TYPE_GET_HOLDSINFO,Integer(MSG_MODE_REQUEST)); //ίÍÐϵ¥
+ lpAnsMsg := NewFuMessage(MSG_TYPE_UNKNOWN,Integer(MSG_MODE_ANSWER)); //½ÓÊÕÏûÏ¢(ÎÞ¹ØÏûÏ¢ÀàÐÍ)
+
+ //´ò°üÇëÇó²ÎÊý(×Ö¶Î˳ÐòÎÞ¹Ø,Öظ´ÉèÖÃ×Ö¶ÎÔò¸²¸ÇÆäÖµ)
+ lpRecord := lpReqMsg.AddRecord();
+
+
+ lpRecord.SetString('fund_account',pc_username);
+ //lpRecord.SetString('password',pc_user_pwd);
+ lpRecord.SetString('futu_exch_type','');
+
+ lpRecord.SetString('futures_account','');
+ lpRecord.SetString('contract_code','');
+ lpRecord.SetString('entrust_bs','');
+ lpRecord.SetString('query_direction','0');
+ lpRecord.SetString('query_mode','1');
+ lpRecord.SetString('request_num','50');
+ lpRecord.SetString('action_in','');
+ lpRecord.SetString('position_str','0');
+ lpRecord.SetString('switch_type','1');
+
+ iRet := m_lpComm.SyncSendRecv(lpReqMsg,lpAnsMsg);
+
+ //Form1.ShowFuMessage(lpAnsMsg);
+
+ i_get_count:=0;
+ if (iRet = 0) Then i_get_count :=lpAnsMsg.GetCount;
+
+ if (iRet = 0) and (i_get_count >0) Then
+ begin
+ for I := 0 to i_get_count-1 do
+ begin
+ lpAnsRecord := lpAnsMsg.GetRecord(I);
+ FillChar(c_log,SizeOf(c_log),0);
+
+ StrCopy(c_log,lpAnsRecord.GetString('contract_code'));
+ s_tmp:=c_log;
+ s_tmp1:=pc_what_wk;
+
+ FillChar(c_log,SizeOf(c_log),0);
+
+ StrCopy(c_log,lpAnsRecord.GetString('entrust_bs'));
+ if c_log[0] = '2' Then
+ begin
+ if(s_tmp = s_tmp1) Then
+ begin
+
+ StrCopy(c_log,lpAnsRecord.GetString('futu_average_price'));
+
+ f_short_price_ex :=StrToFloat(c_log);
+
+ FillChar(c_log,SizeOf(c_log),0);
+ StrCopy(c_log,lpAnsRecord.GetString('real_amount'));
+
+ i_short_mark_ex :=Round(StrToFloat(c_log));
+ end
+ end
+ else if c_log[0] = '1' Then
+ begin
+ if(s_tmp = s_tmp1) Then
+ begin
+
+ StrCopy(c_log,lpAnsRecord.GetString('futu_average_price'));
+
+ f_business_price_ex :=StrToFloat(c_log);
+
+ FillChar(c_log,SizeOf(c_log),0);
+
+ StrCopy(c_log,lpAnsRecord.GetString('real_amount'));
+
+ i_got_it_mark_ex :=Round(StrToFloat(c_log));
+ end;
+ end;
+ end;
+ end
+ else
+ begin
+ i_short_mark_ex :=0;
+ i_got_it_mark_ex:=0;
+ f_short_price_ex :=0.0;
+ f_business_price_ex :=0.0;
+ end;
+
+ lpReqMsg.Release();
+ lpAnsMsg.Release();
+end;
+
+
+//20130221
+
+function ff_get_profit():Integer;
+var
+ iRet :Integer;
+ lpReqMsg,lpAnsMsg:IFuMessage;
+ lpRecord,lpAnsRecord:IFuRecord;
+begin
+ Result :=0;
+
+ if not Assigned(m_lpComm) then Exit;
+ if ( i_comm_ok = 0 ) Then Exit;
+
+ FillChar(c_batch_no,SizeOf(c_batch_no),0);
+ FillChar(c_entrust_no,SizeOf(c_entrust_no),0);
+
+
+ //ÒµÎñ²Ù×÷ίÍÐϵ¥
+ lpReqMsg := NewFuMessage(MSG_TYPE_GET_PROFIT,Integer(MSG_MODE_REQUEST)); //ίÍÐϵ¥
+ lpAnsMsg := NewFuMessage(MSG_TYPE_UNKNOWN,Integer(MSG_MODE_ANSWER)); //½ÓÊÕÏûÏ¢(ÎÞ¹ØÏûÏ¢ÀàÐÍ)
+
+ //´ò°üÇëÇó²ÎÊý(×Ö¶Î˳ÐòÎÞ¹Ø,Öظ´ÉèÖÃ×Ö¶ÎÔò¸²¸ÇÆäÖµ)
+ lpRecord := lpReqMsg.AddRecord();
+
+
+ lpRecord.SetString('fund_account',pc_username);
+ //lpRecord.SetString('password',pc_user_pwd);
+ lpRecord.SetString('money_type','0');
+
+ //ͬ²½½ÓÊÕÏûÏ¢
+ iRet := m_lpComm.SyncSendRecv(lpReqMsg,lpAnsMsg);
+ if iRet <> 0 then
+ begin
+ //cout<<"ͬ²½Î¯ÍÐʧ°Ü:iRet="<GetErrorMsg(iRet)<0 then
+ begin
+ lpAnsRecord := lpAnsMsg.GetRecord(0);
+ FillChar(c_rights_balance,SizeOf(c_rights_balance),0);
+ StrCopy(c_rights_balance,lpAnsRecord.GetString('rights_balance'));
+ f_rights_balance :=StrToFloat(c_rights_balance);
+ i_rights_balance :=Round( StrToFloat(c_rights_balance) /10000 );
+ end;
+
+ lpReqMsg.Release();
+ lpAnsMsg.Release();
+
+
+end;
+
+//20130221 end
+
+
+
+function ff_main_wk_loop():Integer;
+var
+ i_loop_wk,i_loop,i_tmp :Integer;
+ i_tmp_1 :Integer;
+ i_tmp_2 :Integer;
+ i_tmp_3 :Integer;
+ i_tmp_4 :Integer;
+ i_tmp_5 :Integer;
+ i_tmp_6 :Integer;
+ i_tmp_7 :Integer;
+ i_tmp_8 :Integer;
+ i_index_8 :Integer;
+
+ i_tmp_9 :Integer;
+
+ s_tmp,s_tmp1:string;
+
+ pc_username_bak:PChar;
+
+
+begin
+ Result :=0;
+
+ i_line_no_001:=1;
+ i_line_no_001:=i_line_no_001+1;
+
+ if i_only_1 = 1 Then s_caption_14 :='µ¥·¢' else s_caption_14 :='Ⱥ·¢';
+
+ if (i_comm_ok=0) Then
+ begin
+ //frmMain2.GRID_S006.Cells[0,0]:='¶Ï¿ª';
+ s_caption_3:='¶Ï¿ª';
+ Exit;
+ end
+ else
+ begin
+ //frmMain2.GRID_S006.Cells[0,0]:='Áª»ú';
+ s_caption_3:='Áª»ú';
+ end;
+
+ if i_do_ff_qty_loop >0 Then
+ begin
+ i_do_ff_qty_loop :=0;
+ for i_loop_wk := 0 to i_fc_count-1 Do
+ begin
+ pc_username :=as_fc_data[i_loop_wk].pc_username;
+ ff_get_qty_ex();
+ ff_get_profit();
+ as_fc_data[i_loop_wk].i_short_mark := i_short_mark_ex;
+ as_fc_data[i_loop_wk].i_got_it_mark := i_got_it_mark_ex;
+ as_fc_data[i_loop_wk].i_rights_balance := i_rights_balance;
+ as_fc_data[i_loop_wk].f_short_price :=f_short_price_ex;
+ as_fc_data[i_loop_wk].f_business_price :=f_business_price_ex;
+ as_fc_data[i_loop_wk].f_rights_balance :=f_rights_balance;
+ end;
+ end;
+
+ pc_username :=as_fc_data[i_fc_wk_index].pc_username;
+ s_caption_7:=pc_username;
+ s_caption_13:=as_fc_data[i_fc_wk_index].pc_xxx_name;
+
+ i_line_no_001:=i_line_no_001+1;
+
+ if (i_no_trade=0) Then
+ begin
+ //s_caption_4:='×Ô¶¯';
+ end
+ else
+ begin
+ //s_caption_4:='ÊÖ¶¯';
+ end;
+ i_line_no_001:=i_line_no_001+1;
+
+
+ if(i_long_mbm_count > 0) Then
+ begin
+ //frmMain2.GRID_S002.Cells[0,0]:='L5 ' + IntToStr(i_long_mbm_count);
+ //frmMain2.GRID_S002.Cells[1,0]:='L4 ' + IntToStr(i_4ma_long_mbm_count);
+ end;
+ i_line_no_001:=i_line_no_001+1;
+
+ if(i_short_mbm_count > 0) Then
+ begin
+ //frmMain2.GRID_S002.Cells[0,0]:='S5 ' + IntToStr(i_short_mbm_count);
+ //frmMain2.GRID_S002.Cells[1,0]:='S4 ' + IntToStr(i_4ma_short_mbm_count);
+ end;
+
+ i_line_no_001:=i_line_no_001+1;
+
+ //for i_sum_long_mbm_count ... ...
+ if( 1 > 0) Then
+ begin
+ //frmMain2.GRID_S003.Cells[0,0]:='SL5 ';
+ //frmMain2.GRID_S003.Cells[1,0]:=IntToStr(i_sum_long_mbm_count);
+ //frmMain2.GRID_S003.Cells[0,1]:='SS5 ';
+ //frmMain2.GRID_S003.Cells[1,1]:=IntToStr(i_sum_short_mbm_count);
+ //frmMain2.GRID_S003.Cells[0,2]:='SD5 ';
+ //frmMain2.GRID_S003.Cells[1,2]:=IntToStr(i_sum_long_mbm_count-i_sum_short_mbm_count);
+
+ //frmMain2.GRID_S003.Cells[0,3]:='SL4 ';
+ //frmMain2.GRID_S003.Cells[1,3]:=IntToStr(i_sum_4ma_long_mbm_count);
+ //frmMain2.GRID_S003.Cells[0,4]:='SS4 ';
+ //frmMain2.GRID_S003.Cells[1,4]:=IntToStr(i_sum_4ma_short_mbm_count);
+ //frmMain2.GRID_S003.Cells[0,5]:='SD4 ';
+ //frmMain2.GRID_S003.Cells[1,5]:=IntToStr(i_sum_4ma_long_mbm_count-i_sum_4ma_short_mbm_count);
+
+ end;
+
+ i_line_no_001:=i_line_no_001+1;
+
+
+ //frmMain2.GRID_S002.Cells[0,1]:='RSI';
+ //frmMain2.GRID_S002.Cells[1,1]:=FloatToStrF(as_k_chg_ma_rsi[i_s_k_chg_index_wk].ai_rsi[0]/100,ffFixed,7,2);
+ i_line_no_001:=i_line_no_001+1;
+
+ if not Assigned(m_lpComm) then Exit;
+ if ( i_comm_ok = 0 ) Then Exit;
+
+
+ ff_chk_power_vol(i_s_k_chg_index_wk);
+
+
+ i_line_no_001:=i_line_no_001+1;
+ //for get K line Only
+ if (i_make_k_only >0) Then Exit;
+ i_line_no_001:=i_line_no_001+1;
+
+
+ if i_do_ff_qty_loop >0 Then
+ begin
+ i_do_ff_qty_loop :=0;
+ for i_loop_wk := 0 to i_fc_count-1 Do
+ begin
+ ff_get_qty();
+ ff_get_profit();
+ as_fc_data[i_loop_wk].i_short_mark := i_short_mark;
+ as_fc_data[i_loop_wk].i_got_it_mark := i_got_it_mark;
+ as_fc_data[i_loop_wk].i_rights_balance := i_rights_balance;
+ end;
+ end;
+
+
+ if(i_fc_wk_index_bak <> i_fc_wk_index) Then
+ begin
+ s_caption_8:=' ';
+ s_caption_9:=' ';
+ s_caption_10:=' ';
+ s_caption_11:=' ';
+
+ i_fc_wk_index_bak :=i_fc_wk_index;
+ ff_get_qty();
+ ff_get_profit();
+ as_fc_data[i_fc_wk_index].i_rights_balance := i_rights_balance;
+ s_caption_4:=c_rights_balance;
+ end;
+
+ if (i_short_mark=0) Then i_lock_short :=0;
+ if (i_got_it_mark=0) Then i_lock_long :=0;
+
+ if(i_ff_get_qty_flag >1) Then
+ begin
+ i_ff_get_qty_flag := i_ff_get_qty_flag -1;
+ ff_get_qty();
+ end;
+
+ //for ff_action.ini
+ s_tmp := FormatDateTime('yyyymmddhhnnss',Now);
+
+ if( i_open_long_timer =0 ) and
+ (pc_open_long_time <>nil) and (StrLen(pc_open_long_time) = StrLen(PChar(s_tmp))) Then
+ begin
+ s_tmp1:=pc_open_long_time;
+ if(s_tmp > s_tmp1) Then
+ begin
+ i_BSK :=1;
+ i_open_long_timer :=888;
+ end;
+ end;
+
+ if( i_open_short_timer =0 ) and
+ (pc_open_short_time <>nil) and (StrLen(pc_open_short_time) = StrLen(PChar(s_tmp))) Then
+ begin
+ s_tmp1:=pc_open_short_time;
+ if(s_tmp > s_tmp1) Then
+ begin
+ i_BSK :=3;
+ i_open_short_timer :=888;
+ end;
+ end;
+
+
+ if( i_close_long_timer =0 ) and
+ (pc_close_long_time <>nil) and (StrLen(pc_close_long_time) = StrLen(PChar(s_tmp))) Then
+ begin
+ s_tmp1:=pc_close_long_time;
+ if(s_tmp > s_tmp1) Then
+ begin
+ i_BSK :=5;
+ i_close_long_timer :=888;
+ end;
+ end;
+
+
+ if( i_close_short_timer =0 ) and
+ (pc_close_short_time <>nil) and (StrLen(pc_close_short_time) = StrLen(PChar(s_tmp))) Then
+ begin
+ s_tmp1:=pc_close_short_time;
+ if(s_tmp > s_tmp1) Then
+ begin
+ i_BSK :=6;
+ i_close_short_timer :=888;
+ end;
+ end;
+
+
+
+ if (i_BSK = 1 ) or (i_BSK = 2) and (f_last_price_wk >8.0) Then
+ begin
+
+ i_ff_get_qty_flag := 18;
+
+ //for loop add
+ for i_loop_wk := 0 to i_fc_count-1 Do
+ begin
+
+ if i_only_1 = 1 Then i_loop:= i_fc_wk_index else i_loop :=i_loop_wk;
+
+ if as_fc_data[i_loop].pc_username = nil then Break;
+ pc_username := as_fc_data[i_loop].pc_username;
+
+ //ff_entrust_no(pc_what_wk);
+ //ff_cancel_entrust_no();
+ ff_get_qty();
+
+ if(i_BSK =1) Then s_tmp := FloatToStrF(f_sale_1+i_open_delta,ffFixed,8,2 );
+ if(i_BSK =2) Then s_tmp := FloatToStrF(f_buy_1-1.0,ffFixed,8,2 );
+ if(i_BSK =2) and ( i_open_price >0 ) Then s_tmp := IntToStr(i_open_price);
+
+ i_BSK :=0;
+
+ if (i_got_it_mark > (as_fc_data[i_loop].i_long_max-1)) then Continue;
+
+ //ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_F)),m_mairu,m_kaicang);
+ ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(as_fc_data[i_loop].i_VOL)),m_mairu,m_kaicang);
+
+ W_Log('main_loop',as_k_chg[i_s_k_chg_index_wk].i_date,i_wk_log,'BSK,make long position!');
+ //Sleep(2000);
+ //ff_get_qty();
+
+ if i_only_1 = 1 Then Break;
+
+ end
+ end
+ else if (i_BSK = 1 ) or (i_BSK = 2) then i_BSK :=0;
+
+ if (i_BSK =3) or (i_BSK =4) and (f_last_price_wk >8.0) Then
+ begin
+
+ i_ff_get_qty_flag := 18;
+ //for loop add
+ for i_loop_wk := 0 to i_fc_count-1 Do
+ begin
+
+ if i_only_1 = 1 Then i_loop:= i_fc_wk_index else i_loop :=i_loop_wk;
+
+ if as_fc_data[i_loop].pc_username = nil then Break;
+ pc_username := as_fc_data[i_loop].pc_username;
+
+ //ff_entrust_no(pc_what_wk);
+ //ff_cancel_entrust_no();
+ ff_get_qty();
+
+ if(i_BSK =3) Then s_tmp := FloatToStrF(f_buy_1-i_open_delta,ffFixed,8,2 );
+ if(i_BSK =4) Then s_tmp := FloatToStrF(f_sale_1 + 1.0,ffFixed,8,2 );
+ if(i_BSK =4) and ( i_open_price >0 ) Then s_tmp := IntToStr(i_open_price);
+
+ i_BSK :=0;
+
+ if ( i_short_mark > (as_fc_data[i_loop].i_short_max-1)) then Continue;
+
+ //ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_F)),m_maichu,m_kaicang);
+
+ ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(as_fc_data[i_loop].i_VOL)),m_maichu,m_kaicang);
+
+ W_Log('main_loop',as_k_chg[i_s_k_chg_index_wk].i_date,i_wk_log,'BSK,make short position!');
+ //Sleep(2000);
+ //ff_get_qty();
+ //frmMain2.GRID_S002.Repaint;
+
+ if i_only_1 = 1 Then Break;
+
+ end
+ end
+ else if (i_BSK =3) or (i_BSK =4) then i_BSK :=0;
+
+ //for stp, auto_trade
+
+ if( i_stp_long >0 ) and (i_BSK =0 ) and (i_act_stp_long_mark=0) Then
+ if(i_got_it_mark >-1) and (f_last_price_wk >8.0) Then
+ begin
+ //if( i_set_stp_long_wk =0 ) Then i_set_stp_long_wk := Round(f_business_price+0.49);
+ if( i_set_stp_long_wk >0 ) and ( i_set_stp_long_wk < Round(f_last_price_wk + 0.49)) Then
+ begin
+ i_stp_long :=0;
+ i_act_stp_long_mark:=888;
+ i_ff_get_qty_flag := 18;
+ i_act_stp_long :=888;
+ i_BSK :=m_bsk_ask_long;
+ W_Log('main_loop',as_k_chg[i_s_k_chg_index_wk].i_date,i_wk_log,'Long STP!');
+ end;
+ end;
+
+ if( i_stp_short >0 ) and (i_BSK =0 ) and (i_act_stp_short_mark=0) Then
+ if(i_got_it_mark >-1) and (f_last_price_wk >8.0) Then
+ begin
+ //if( i_set_stp_short_wk =0 ) Then i_set_stp_short_wk := Round(f_business_price+0.49);
+ if( i_set_stp_short_wk >0 ) and ( i_set_stp_short_wk > Round(f_last_price_wk - 0.49)) Then
+ begin
+ i_stp_short :=0;
+ i_act_stp_short_mark:=888;
+ i_ff_get_qty_flag := 18;
+ i_act_stp_short :=888;
+ i_BSK :=m_bsk_bid_short;
+ W_Log('main_loop',as_k_chg[i_s_k_chg_index_wk].i_date,i_wk_log,'Short STP!');
+ end;
+ end;
+ //end stp
+
+ //for locked, auto_clear
+
+ if( i_lock_long >0 ) and (i_BSK =0 ) and (i_cut_lock_long_mark=0) Then
+ //if(i_got_it_mark >0) and (f_last_price_wk >8.0) and (f_last_price_wk - f_business_price < 0.50 ) Then
+ if(i_got_it_mark >0) and (f_last_price_wk >8.0) Then
+ begin
+ if( i_set_lock_long_wk =0 ) Then i_set_lock_long_wk := Round(f_business_price+0.49);
+ if( i_set_lock_long_wk >0 ) and ( i_set_lock_long_wk >Round(f_last_price_wk-0.49)) Then
+ begin
+ i_lock_long :=0;
+ i_cut_lock_long_mark:=888;
+ i_ff_get_qty_flag := 18;
+ i_cut_lock_long :=888;
+ i_BSK :=m_bsk_clear_long;
+ W_Log('main_loop',as_k_chg[i_s_k_chg_index_wk].i_date,i_wk_log,'Locked Long Clear!');
+ end;
+ end;
+
+ if( i_lock_short >0 ) and (i_BSK =0 ) and (i_cut_lock_short_mark=0) Then
+ //if(i_short_mark >0) and (f_last_price_wk >8.0) and ( f_short_price - f_last_price_wk <0.50 ) Then
+ if(i_short_mark >0) and (f_last_price_wk >8.0) Then
+ begin
+ if( i_set_lock_short_wk =0 ) Then i_set_lock_short_wk := Round(f_short_price-0.49);
+ if( i_set_lock_short_wk >0 ) and ( i_set_lock_short_wk 0) and (f_last_price_wk >8.0) Then
+ if (i_BSK = 5 ) and (f_last_price_wk >8.0) Then
+ begin
+ i_ff_get_qty_flag := 18;
+
+ i_BSK :=0;
+
+ if ( i_lock_long > 0 ) and (i_cut_lock_long =0) Then
+ begin
+ s_caption_status :='ÒÑËø¶à²Ö£¬²»µÃ½øÐг嶯µÄƽ¶à²Ù×÷£¡';
+ end
+ else
+ begin
+ //for loop add
+ for i_loop_wk := 0 to i_fc_count-1 Do
+ begin
+
+ //for reset
+ if ( i_lock_long > 0 ) and (i_cut_lock_long >0) Then
+ begin
+ i_cut_lock_long :=0;
+ end;
+
+ if i_only_1 = 1 Then i_loop:= i_fc_wk_index else i_loop :=i_loop_wk;
+
+ if as_fc_data[i_loop].pc_username = nil then Break;
+ pc_username := as_fc_data[i_loop].pc_username;
+
+ s_tmp := FloatToStrF(f_last_price_wk - i_close_delta,ffFixed,8,2 );
+
+ //ff_entrust_no(pc_what_wk);
+ //ff_cancel_entrust_no();
+ ff_get_qty();
+
+ if(i_clr_long_1_mark >0) Then
+ //if (i_loop <> i_fc_wk_index ) Then
+ i_got_it_mark :=as_fc_data[i_loop].i_VOL;
+
+ if(i_clr_long_to_001_mark >0) Then
+ begin
+ if(i_got_it_mark <2) Then
+ ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_got_it_mark)),m_maichu,m_pingcang)
+ else
+ ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_got_it_mark-1)),m_maichu,m_pingcang);
+ end
+ else
+ ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_got_it_mark)),m_maichu,m_pingcang);
+
+
+ W_Log('main_loop',as_k_chg[i_s_k_chg_index_wk].i_date,i_wk_log,'-12,BSK,long clear!');
+ //Sleep(2000);
+ //ff_get_qty();
+ //frmMain2.GRID_S002.Repaint;
+
+ if i_only_1 = 1 Then Break;
+
+ end
+ end;
+
+ if(i_clr_long_1_mark >0) Then i_clr_long_1_mark :=0;
+ if(i_clr_long_to_001_mark >0) Then i_clr_long_to_001_mark :=0;
+
+ end
+ else if (i_BSK = 5 ) then i_BSK :=0;
+
+ i_line_no_001:=i_line_no_001+1;
+
+ if (i_BSK = 7 ) and (f_last_price_wk >8.0) Then
+ //if (i_BSK = 7 ) and (i_got_it_mark >0) and (f_last_price_wk >8.0) Then
+ begin
+ //i_ff_get_qty_flag := 18;
+
+ for i_loop_wk := 0 to i_fc_count-1 Do
+ begin
+
+ if i_only_1 = 1 Then i_loop:= i_fc_wk_index else i_loop :=i_loop_wk;
+
+ if as_fc_data[i_loop].pc_username = nil then Break;
+ pc_username := as_fc_data[i_loop].pc_username;
+
+ i_got_it_mark :=as_fc_data[i_loop].i_VOL;
+
+ //ff_entrust_no(pc_what_wk);
+ //ff_cancel_entrust_no();
+
+ ff_get_qty();
+
+ i_BSK :=0;
+ s_tmp := FloatToStrF(f_last_price_wk + 2.0,ffFixed,8,2 );
+ if( i_open_price >0 ) Then s_tmp := IntToStr(i_open_price);
+
+ if( i_open_price >0 ) and (i_open_vol >0) Then
+ ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_open_vol)),m_maichu,m_pingcang)
+ else
+ //20120309 chg
+ //if(i_got_it_mark <2) Then
+ ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_got_it_mark)),m_maichu,m_pingcang);
+ //else
+ // ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_got_it_mark-1)),m_maichu,m_pingcang);
+
+ W_Log('main_loop',as_k_chg[i_s_k_chg_index_wk].i_date,i_wk_log,'+2,BSK,long clear!');
+ //Sleep(2000);
+ //ff_get_qty();
+ //frmMain2.GRID_S002.Repaint;
+ if i_only_1 = 1 Then Break;
+ end
+ end
+ else if (i_BSK = 7 ) then i_BSK :=0;
+
+
+ i_line_no_001:=i_line_no_001+1;
+
+
+ if (i_BSK = 6 ) and (i_short_mark >0) and (f_last_price_wk >8.0) Then
+ begin
+ i_ff_get_qty_flag := 18;
+
+ i_BSK :=0;
+
+ if (i_lock_short > 0 ) and ( i_cut_lock_short=0 )Then
+ begin
+ s_caption_status :='ÒÑËø¶à²Ö£¬²»µÃ½øÐг嶯µÄƽ¶à²Ù×÷£¡';
+ end
+ else
+ begin
+
+ for i_loop_wk := 0 to i_fc_count-1 Do
+ begin
+
+ if (i_lock_short > 0 ) and ( i_cut_lock_short>0 )Then
+ begin
+ i_cut_lock_short :=0;
+ end;
+
+ if i_only_1 = 1 Then i_loop:= i_fc_wk_index else i_loop :=i_loop_wk;
+
+ if as_fc_data[i_loop].pc_username = nil then Break;
+ pc_username := as_fc_data[i_loop].pc_username;
+ i_short_mark :=as_fc_data[i_loop].i_VOL;
+
+ //ff_entrust_no(pc_what_wk);
+ //ff_cancel_entrust_no();
+
+ ff_get_qty();
+
+ if(i_clr_short_1_mark >0) Then
+ i_short_mark :=as_fc_data[i_loop].i_VOL;
+
+ s_tmp := FloatToStrF(f_last_price_wk + i_close_delta,ffFixed,8,2 );
+
+ if(i_clr_short_to_001_mark >0) Then
+ begin
+ if(i_short_mark <2) Then
+ ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_short_mark)),m_mairu,m_pingcang)
+ else
+ ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_short_mark-1)),m_mairu,m_pingcang);
+ end
+ else
+ //if(i_short_mark <2) Then
+ ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_short_mark)),m_mairu,m_pingcang);
+ //else
+ // ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_short_mark-1)),m_mairu,m_pingcang);
+
+ W_Log('main_loop',as_k_chg[i_s_k_chg_index_wk].i_date,i_wk_log,'+12 BSK,short clear!');
+ //Sleep(2000);
+ //ff_get_qty();
+ //frmMain2.GRID_S002.Repaint;
+ if i_only_1 = 1 Then Break;
+ end
+ end;
+
+ if(i_clr_short_1_mark >0) Then i_clr_short_1_mark :=0;
+ if(i_clr_short_to_001_mark >0) Then i_clr_short_to_001_mark:=0;
+
+ end
+ else if (i_BSK = 6 ) then i_BSK :=0;
+
+ i_line_no_001:=i_line_no_001+1;
+
+ if (i_BSK = 8 ) and (i_short_mark >0) and (f_last_price_wk >8.0) Then
+ begin
+ //i_ff_get_qty_flag := 18;
+
+ i_BSK :=0;
+ for i_loop_wk := 0 to i_fc_count-1 Do
+ begin
+ if i_only_1 = 1 Then i_loop:= i_fc_wk_index else i_loop :=i_loop_wk;
+
+ if as_fc_data[i_loop].pc_username = nil then Break;
+ pc_username := as_fc_data[i_loop].pc_username;
+ i_short_mark :=as_fc_data[i_loop].i_VOL;
+
+ //ff_entrust_no(pc_what_wk);
+ //ff_cancel_entrust_no();
+
+ ff_get_qty();
+
+ s_tmp := FloatToStrF(f_last_price_wk - 2.0,ffFixed,8,2 );
+ if( i_open_price >0 ) Then s_tmp := IntToStr(i_open_price);
+ //ff_entrust_no(pc_what_wk);
+ //ff_cancel_entrust_no();
+
+ //if(i_short_mark <2) Then
+ if( i_open_price >0 ) and (i_open_vol >0) Then
+ ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_open_vol)),m_mairu,m_pingcang)
+ else
+ ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_short_mark)),m_mairu,m_pingcang);
+ //else
+ //ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_short_mark-1)),m_mairu,m_pingcang);
+
+ W_Log('main_loop',as_k_chg[i_s_k_chg_index_wk].i_date,i_wk_log,'-2,BSK,short clear!');
+ //Sleep(2000);
+ //ff_get_qty();
+ //frmMain2.GRID_S002.Repaint;
+ if i_only_1 = 1 Then Break;
+ end
+ end
+ else if (i_BSK = 8 ) then i_BSK :=0;
+
+ if (i_BSK = 9 ) and (f_last_price_wk >8.0) Then
+ begin
+ i_BSK :=0;
+
+ for i_loop_wk := 0 to i_fc_count-1 Do
+ begin
+ if i_only_1 = 1 Then i_loop:= i_fc_wk_index else i_loop :=i_loop_wk;
+
+ if as_fc_data[i_loop].pc_username = nil then Break;
+ pc_username := as_fc_data[i_loop].pc_username;
+
+ ff_entrust_no(pc_what_wk);
+ ff_cancel_entrust_no();
+
+ if i_only_1 = 1 Then Break;
+ end
+ end
+ else if (i_BSK = 9 ) then i_BSK :=0;
+
+ //for ff_300m_ex : Exit Here!
+ Exit;
+
+
+ i_line_no_001:=i_line_no_001+1;
+
+ ff_short_pass3_mark(i_s_k_chg_index_wk-1);
+
+ i_line_no_001:=i_line_no_001+1;
+
+ ff_get_BS_Mark(i_s_k_chg_index_wk-1);
+
+ i_line_no_001:=i_line_no_001+1;
+
+ ff_get_S_L_Mark (i_s_k_chg_index_wk-1);
+
+ i_line_no_001:=i_line_no_001+1;
+
+ if( f_last_price_wk < 1 ) Then Exit;
+
+ i_line_no_001:=i_line_no_001+1;
+ //for auto_clear
+ i_tmp := i_B_S_Flag;
+ if( i_B_S_Flag_18>0 ) and ( i_B_S_Flag_10>0 ) Then
+ if (i_tmp < 0 ) and (i_got_it_mark >0) and (f_last_price_wk >8.0) Then
+ begin
+ s_tmp := FloatToStrF(f_last_price_wk - 2.0,ffFixed,8,2 );
+ ff_entrust_no(pc_what_wk);
+ ff_cancel_entrust_no();
+ ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_got_it_mark)),m_maichu,m_pingcang);
+ W_Log('main_loop',as_k_chg[i_s_k_chg_index_wk].i_date,i_wk_log,'Auto_Clear_Long!');
+ Sleep(2000);
+ ff_get_qty();
+ //frmMain2.GRID_S002.Repaint;
+ end;
+ i_line_no_001:=i_line_no_001+1;
+
+ i_tmp := i_B_S_Flag;
+ if( i_B_S_Flag_18 <0 ) and ( i_B_S_Flag_10 < 0 ) Then
+ if (i_tmp >0 ) and (i_short_mark >0) and (f_last_price_wk >8.0) Then
+ begin
+ s_tmp := FloatToStrF(f_last_price_wk + 2.0,ffFixed,8,2 );
+ ff_entrust_no(pc_what_wk);
+ ff_cancel_entrust_no();
+
+ ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_short_mark)),m_mairu,m_pingcang);
+
+ W_Log('main_loop',as_k_chg[i_s_k_chg_index_wk].i_date,i_wk_log,'auto_clear_short!');
+ Sleep(2000);
+ ff_get_qty();
+ //frmMain2.GRID_S002.Repaint;
+ end;
+
+ //for auto_clear_end
+ i_line_no_001:=i_line_no_001+1;
+
+ if( i_get_S_mark =0 ) and (i_S > 0 ) and
+ (f_last_price_wk > f_last_price_1 + i_A ) and
+ (i_got_it_mark >0 ) and
+
+ //(i_ADD_FLOSS_MAX > i_long_FLOSS_MAX) and
+
+ (f_last_price_wk - f_business_price > f_rsi_add ) and
+ (f_last_price_wk - f_business_price < f_rsi_add*2 ) then
+ begin
+ if i_B_S_Flag >0 Then
+ begin
+ i_get_S_mark :=888;
+ s_tmp := FloatToStrF(f_last_price_wk + 1,ffFixed,8,2 );
+ ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_S)),'1','1');
+
+ W_Log('main_loop',as_k_chg[i_s_k_chg_index_wk].i_date,i_wk_log,'8,add long position!');
+
+ Sleep(2000);
+ ff_get_qty();
+ end;
+
+ end;
+
+ i_line_no_001:=i_line_no_001+1;
+
+ if( i_short_S_mark =0 ) and (i_S > 0 ) and
+ (f_last_price_wk < f_last_price_1 - i_A ) and
+ (i_short_mark >0 ) and
+
+ //(i_ADD_FLOSS_MAX > i_short_FLOSS_MAX) and
+
+ (f_short_price - f_last_price_wk > f_rsi_add ) and
+ (f_short_price - f_last_price_wk < f_rsi_add*2 ) then
+ begin
+ if i_B_S_Flag <0 Then
+ begin
+ i_short_S_mark :=888;
+ s_tmp := FloatToStrF(f_last_price_wk - 2.0,ffFixed,8,2 );
+ ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_S)),'2','1');
+
+ W_Log('main_loop',as_k_chg[i_s_k_chg_index_wk].i_date,i_wk_log,'8,add short position!');
+
+ Sleep(2000);
+ ff_get_qty();
+ end;
+ end;
+
+ i_line_no_001:=i_line_no_001+1;
+
+ if( i_make_short_mark >0 ) and
+ (i_s_k_chg_index_wk - i_make_short_mark >0) then i_make_short_mark :=0;
+
+ i_tmp_1 :=ff_check_short_250(i_s_k_chg_index_wk);
+
+ i_line_no_001:=i_line_no_001+1;
+
+
+ i_tmp_2 :=ff_check_short_30(i_s_k_chg_index_wk);
+
+ i_line_no_001:=i_line_no_001+1;
+
+ i_tmp_3 :=ff_check_short_120(i_s_k_chg_index_wk);
+
+ i_line_no_001:=i_line_no_001+1;
+
+ //for No MA120 Short
+ i_tmp_3 :=1;
+
+ i_tmp_4 :=ff_pass3_short_120(i_s_k_chg_index_wk);
+
+ i_line_no_001:=i_line_no_001+1;
+
+ i_tmp_7:=ff_make_mbm_short(i_s_k_chg_index_wk);
+
+ i_line_no_001:=i_line_no_001+1;
+
+ ff_check_short_1(i_s_k_chg_index_wk-1);
+
+ i_tmp :=ff_check_short_1_ex(i_s_k_chg_index_wk-1);
+
+ if i_mbm_only = 1 then
+ begin
+ i_tmp_1 :=1;
+ i_tmp_2 :=1;
+ i_tmp_3 :=1;
+ i_tmp_4 :=1;
+ i_tmp :=1;
+ i_tmp_7 :=1;
+ end;
+
+ i_tmp_9 :=ff_get_ma600_mark(i_s_k_chg_index_wk-1);
+ if(i_tmp_9 >0) Then
+ begin
+ if( i_short_act_flag >0) Then
+ begin
+ i_short_act_flag := i_short_act_flag-1;
+ i_tmp_7:=0;
+ W_Log('main_loop',as_k_chg[i_s_k_chg_index_wk].i_date,i_wk_log,'i_tmp_9,make a short position!');
+ end;
+ end;
+
+ i_line_no_001:=i_line_no_001+1;
+
+ if( (i_tmp = 0) or (i_tmp_1=0) or (i_tmp_2=0) or (i_tmp_3 = 0) or (i_tmp_4=0) or
+ ( (i_tmp_7 =0 ) and (i_s_k_chg_index_wk - i_short_stop_index>28) ) ) then
+ begin
+ if(i_no_trade=0) Then if ( (i_only_short=1) or ( i_long_short_ctrl = 0 ) ) then
+ begin
+ if i_B_S_Flag <0 Then
+ begin
+ s_tmp := FloatToStrF(f_last_price_wk - 2.0,ffFixed,8,2 );
+ if( i_short_mark =0 ) and ( i_make_short_mark =0 ) then
+ begin
+ ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_F)),'2','1');
+
+ W_Log('main_loop',as_k_chg[i_s_k_chg_index_wk].i_date,i_wk_log,'8,make a short position!');
+
+ Sleep(2000);
+ ff_get_qty();
+ i_make_short_mark := i_s_k_chg_index_wk;
+ end;
+ end;
+ end;
+ end;
+
+ i_line_no_001:=i_line_no_001+1;
+ ff_4ma_make_mbm_short(i_s_k_chg_index_wk);
+ i_line_no_001:=i_line_no_001+1;
+ ff_4ma_make_mbm_long(i_s_k_chg_index_wk);
+ i_line_no_001:=i_line_no_001+1;
+
+ i_tmp_7:=ff_make_mbm_long(i_s_k_chg_index_wk);
+ i_line_no_001:=i_line_no_001+1;
+
+ i_tmp_6:=ff_long_pass_3_ex(i_s_k_chg_index_wk);
+ i_line_no_001:=i_line_no_001+1;
+
+ i_tmp_4 :=ff_make_long_MA30(i_s_k_chg_index_wk);
+ i_line_no_001:=i_line_no_001+1;
+ i_tmp_4 :=1;
+
+ i_tmp_5 :=ff_make_long_MA60(i_s_k_chg_index_wk);
+ i_line_no_001:=i_line_no_001+1;
+ i_tmp_5 :=1;
+ i_tmp_5 :=ff_make_long_MA250(i_s_k_chg_index_wk);
+ i_line_no_001:=i_line_no_001+1;
+ //i_tmp_5 :=1;
+
+ i_tmp_3 := ff_check_long_pass_3(i_s_k_chg_index_wk);
+ i_line_no_001:=i_line_no_001+1;
+
+ ff_check_BB_100(i_s_k_chg_index_wk,3);
+ i_line_no_001:=i_line_no_001+1;
+ i_tmp_2 := ff_check_BB_100_ex(i_s_k_chg_index_wk);
+ i_line_no_001:=i_line_no_001+1;
+
+ ff_check_MA120_BB(i_s_k_chg_index_wk,3);
+ i_line_no_001:=i_line_no_001+1;
+ i_tmp_1 := ff_check_MA120_BB_ex(i_s_k_chg_index_wk);
+ i_line_no_001:=i_line_no_001+1;
+
+ if( i_make_long_mark >0 ) and
+ (i_s_k_chg_index_wk - i_make_long_mark >0) then i_make_long_mark :=0;
+
+ ff_check_rsi_w20(i_s_k_chg_index_wk-1);
+ i_line_no_001:=i_line_no_001+1;
+ i_tmp := ff_check_rsi_w20_ex(i_s_k_chg_index_wk);
+ i_line_no_001:=i_line_no_001+1;
+
+ if i_mbm_only = 1 then
+ begin
+ i_tmp_1 :=1;
+ i_tmp_2 :=1;
+ i_tmp_3 :=1;
+ i_tmp_4 :=1;
+ i_tmp_5 :=1;
+ i_tmp_6 :=1;
+ i_tmp_7 :=1;
+ i_tmp :=1;
+ end;
+
+ i_tmp_9 :=ff_get_ma600_mark_long(i_s_k_chg_index_wk-1);
+ if(i_tmp_9 >0) Then
+ begin
+ if( i_long_act_flag >0) Then
+ begin
+ i_long_act_flag := i_long_act_flag-1;
+ i_tmp_7:=0;
+ W_Log('main_loop',as_k_chg[i_s_k_chg_index_wk].i_date,i_wk_log,'i_tmp_9,make a long position!');
+ end
+ end;
+
+ i_line_no_001:=i_line_no_001+1;
+
+ if( (i_tmp = 0) or (i_tmp_1=0) or (i_tmp_2=0) or (i_tmp_3=0) or (i_tmp_4=0) or (i_tmp_5=0) or (i_tmp_6 =0) or (i_tmp_7 =0) ) then
+ begin
+ if(i_no_trade=0) Then if ( ( i_only_long=1 ) or ( i_long_short_ctrl = 0 ) ) Then
+ begin
+ if (i_B_S_Flag >0) or ( (i_s_k_chg_index_wk - i_short_stop_index<28) and (i_tmp=0) ) or
+ (i_tmp_3=0) or (i_tmp_4=0) or (i_tmp_5=0) or (i_tmp_6=0) or (i_tmp_2=0) or
+ (i_tmp_1=0) or (i_tmp_7 =0) Then
+ begin
+ s_tmp := FloatToStrF(f_last_price_wk + 1,ffFixed,8,2 );
+ if( i_got_it_mark =0 ) and ( i_make_long_mark =0 ) then
+ begin
+ ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_F)),'1','1');
+
+ W_Log('main_loop',as_k_chg[i_s_k_chg_index_wk].i_date,i_wk_log,'8,make a long position!');
+
+ Sleep(2000);
+ ff_get_qty();
+ i_make_long_mark := i_s_k_chg_index_wk;
+ end;
+ end;
+ end;
+ end;
+ i_line_no_001:=i_line_no_001+1;
+
+ //for short Stop
+ if( i_short_mark >0 ) and ( f_last_price_wk > ( f_short_price + f_rsi_cut_short ) ) then
+ begin
+ i_stop_short_count := i_stop_short_count+1;
+ if( i_stop_short_count > 1) then
+ begin
+ i_stop_short_count:=0;
+
+ //for OPEN, NO CUT!
+ s_tmp := FormatDateTime('hhnn',Now);
+ if ( (s_tmp <>'0915') and (s_tmp <>'0916') and (s_tmp <>'0916') and (s_tmp <>'0916') and
+ (s_tmp <>'915') and (s_tmp <>'916') and (s_tmp <>'916') and (s_tmp <>'916') ) Then
+ begin
+
+ s_tmp := FloatToStrF(f_last_price_wk + 2.0,ffFixed,8,2 );
+ ff_entrust_no(pc_what_wk);
+ ff_cancel_entrust_no();
+ ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_short_mark)),m_mairu,m_pingcang);
+ i_stop_short_count:=0;
+
+ W_Log('main_loop',as_k_chg[i_s_k_chg_index_wk].i_date,i_wk_log,'99,Cut Short!');
+
+ //for make a long
+ ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_short_mark)),m_mairu,m_pingcang);
+
+ if( as_k_chg[i_s_k_chg_index_wk].i_close > as_k_chg_ma_rsi[i_s_k_chg_index_wk-1].ai_ma[6] ) and
+ ( as_k_chg[i_s_k_chg_index_wk].i_close > as_k_chg_ma_rsi[i_s_k_chg_index_wk-1].ai_ma[3] ) and
+ ( as_k_chg[i_s_k_chg_index_wk].i_close < as_k_chg_ma_rsi[i_s_k_chg_index_wk-1].ai_ma[8] ) and
+ ( as_k_chg[i_s_k_chg_index_wk].i_close > as_k_chg_ma_rsi[i_s_k_chg_index_wk-1].ai_ma[5] ) Then
+ begin
+ ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_short_mark)),m_mairu,m_kaicang);
+ W_Log('main_loop',as_k_chg[i_s_k_chg_index_wk].i_date,i_wk_log,'88,Make Long!');
+ end;
+
+ Sleep(2000);
+ ff_get_qty();
+
+ end;
+ end;
+ end
+ else if( i_short_mark >0 ) and ( f_short_price > f_last_price_wk + f_rsi_stop_short ) then
+ begin
+ i_stop_short_count := i_stop_short_count+1;
+
+ if (i_M120 >0 ) and
+ ((Integer(as_k_chg_ma_rsi[ i_s_k_chg_index_wk-1 ].ai_ma[6]) + i_M120) <
+ (Integer(as_k_chg_ma_rsi[ i_s_k_chg_index_wk-2 ].ai_ma[6]) ) ) Then
+ begin
+ i_M120_stop :=888;
+ end
+ else if i_M120 >0 then
+ begin
+ i_M120_stop :=8;
+ end
+ else i_M120_stop :=0;
+
+ if (i_M30 >0 ) and
+ ( (Integer(as_k_chg_ma_rsi[ i_s_k_chg_index_wk-1 ].ai_ma[3]) + i_M30 ) <
+ (Integer(as_k_chg_ma_rsi[ i_s_k_chg_index_wk-2 ].ai_ma[3]) ) ) Then
+ begin
+ i_M30_stop :=888;
+ end
+ else if i_M30 >0 then
+ begin
+ i_M30_stop :=8;
+ end
+ else i_M30_stop :=0;
+
+ if ( i_M120_stop = 888 ) or ( i_M30_stop =888 ) or
+ ( (i_M30_stop =0) and (i_M120_stop =0) ) Then
+ begin
+
+ //M30 delta check
+ //if ( (Integer(as_k_chg_ma_rsi[ i_s_k_chg_index_wk-1 ].ai_ma[3]) + i_M30 ) >
+ // Integer(as_k_chg_ma_rsi[ i_s_k_chg_index_wk-2 ].ai_ma[3]) ) Then
+ //begin
+
+ if( i_stop_short_count > 1) then
+ begin
+ s_tmp := FloatToStrF(f_last_price_wk + 2.0,ffFixed,8,2 );
+ ff_entrust_no(pc_what_wk);
+ ff_cancel_entrust_no();
+ ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_short_mark)),m_mairu,m_pingcang);
+ W_Log('main_loop',as_k_chg[i_s_k_chg_index_wk].i_date,i_wk_log,'888,Stop Short Profit!');
+ i_stop_short_count:=0;
+
+ i_short_stop_index :=i_s_k_chg_index_wk;
+
+ Sleep(2000);
+ ff_get_qty();
+ end;
+
+ end;
+ end;
+
+ i_line_no_001:=i_line_no_001+1;
+
+ //for Stop
+ if( i_got_it_mark >0 ) and ( f_last_price_wk - f_business_price > f_rsi_stop_long ) then
+ begin
+
+ i_stop_check_count := i_stop_check_count+1;
+
+ if (i_M120 >0 ) and
+ (Integer(as_k_chg_ma_rsi[ i_s_k_chg_index_wk-1 ].ai_ma[6]) <
+ (Integer(as_k_chg_ma_rsi[ i_s_k_chg_index_wk-2 ].ai_ma[6]) + i_M120 ) ) Then
+ begin
+ i_M120_stop :=888;
+ end
+ else if i_M120 >0 then
+ begin
+ i_M120_stop :=8;
+ end
+ else i_M120_stop :=0;
+
+ if (i_M30 >0 ) and
+ (Integer(as_k_chg_ma_rsi[ i_s_k_chg_index_wk-1 ].ai_ma[3]) <
+ (Integer(as_k_chg_ma_rsi[ i_s_k_chg_index_wk-2 ].ai_ma[3]) + i_M30 ) ) Then
+ begin
+ i_M30_stop :=888;
+ end
+ else if i_M30 >0 then
+ begin
+ i_M30_stop :=8;
+ end
+ else i_M30_stop :=0;
+
+ if ( i_M120_stop = 888 ) or ( i_M30_stop =888 ) or
+ ( (i_M30_stop =0) and (i_M120_stop =0) ) Then
+ begin
+
+ if( i_stop_check_count > 1) then
+ begin
+ s_tmp := FloatToStrF(f_last_price_wk - 1.0,ffFixed,8,2 );
+ ff_entrust_no(pc_what_wk);
+ ff_cancel_entrust_no();
+ ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_got_it_mark)),m_maichu,m_pingcang);
+ i_stop_check_count:=0;
+ W_Log('main_loop',as_k_chg[i_s_k_chg_index_wk].i_date,i_wk_log,'888,Stop Long Profit!');
+
+ i_long_stop_index :=i_s_k_chg_index_wk;
+
+ Sleep(2000);
+ ff_get_qty();
+ end;
+
+ end;
+
+ end
+ else if( i_got_it_mark > 0 ) and ( f_business_price - f_last_price_wk > f_rsi_cut_long ) then
+ begin
+
+ s_tmp := FormatDateTime('hhnn',Now);
+ if ( (s_tmp <>'0915') and (s_tmp <>'0916') and (s_tmp <>'0917') and (s_tmp <>'0918') and
+ (s_tmp <>'915') and (s_tmp <>'916') and (s_tmp <>'917') and (s_tmp <>'918') ) Then
+ begin
+
+ i_stop_check_count := i_stop_check_count+1;
+ if( i_stop_check_count > 1) then
+ begin
+ i_stop_check_count:=0;
+ s_tmp := FloatToStrF(f_last_price_wk - 2.0,ffFixed,8,2 );
+ ff_entrust_no(pc_what_wk);
+ ff_cancel_entrust_no();
+ ff_order_ex(pc_what_wk,PChar(s_tmp),PChar(IntToStr(i_got_it_mark)),m_maichu,m_pingcang);
+ W_Log('main_loop',as_k_chg[i_s_k_chg_index_wk].i_date,i_wk_log,'999,Cut loss!');
+ i_stop_check_count:=0;
+ Sleep(2000);
+ ff_get_qty();
+ end;
+
+ end;
+ end;
+
+end;
+
+function do_beep():Boolean;
+begin
+ Result :=False;
+ if i_beeping =1 then Exit;
+ i_beeping :=1;
+ g_hEvent := CreateEvent(nil,TRUE,FALSE,nil);
+ //Application.ProcessMessages;
+ th_beep := Tth_beep.Create(false);
+ th_beep.i_do_main_loop_mark :=0;
+
+ th_main_loop := Tth_beep.Create(false);
+ th_main_loop.i_do_main_loop_mark :=888;
+
+ Result :=True;
+end;
+
+function ff_stop_do_beep():Boolean;
+begin
+ Result :=True;
+ if i_beeping =0 then Exit;
+ th_main_loop.Terminate;
+ th_beep.Terminate;
+ sleep(3000);
+ //for not need
+ //th_main_loop.Destroy;
+ //th_beep.Destroy;
+ i_beeping :=0;
+end;
+
+function ff_rsi_w20_init():Boolean;
+var
+ pc_tmp :PChar;
+ s_tmp: string;
+ i_loop:Integer;
+ s_tmp1 :string;
+
+begin
+
+ FillChar(as_fc_data,sizeof(as_fc_data),0);
+
+ FillChar(c_batch_no,SizeOf(c_batch_no),0);
+ FillChar(c_entrust_no,SizeOf(c_entrust_no),0);
+
+ s_tmp := FormatDateTime('yyyymmddhhnnss',Now);
+
+ pc_tmp := FF_ffconf(m_ff_action_ini,'LONG','OPEN_TIME');
+ if pc_tmp <> nil then pc_open_long_time :=pc_tmp;
+
+ s_tmp1:=pc_open_long_time;
+ if (pc_open_long_time <> nil) and ( StrLen(pc_open_long_time) = StrLen(PChar(s_tmp)) ) then
+ begin
+ if(s_tmp >= s_tmp1) Then i_open_long_timer:=-888 else i_open_long_timer :=0;
+ end;
+
+ pc_tmp := FF_ffconf(m_ff_action_ini,'SHORT','OPEN_TIME');
+ if pc_tmp <> nil then pc_open_short_time :=pc_tmp;
+
+ s_tmp1:=pc_open_short_time;
+ if (pc_open_short_time <> nil) and ( StrLen(pc_open_short_time) = StrLen(PChar(s_tmp)) ) then
+ begin
+ if(s_tmp >= s_tmp1) Then i_open_short_timer:=-888 else i_open_short_timer :=0;
+ end;
+
+ pc_tmp := FF_ffconf(m_ff_action_ini,'LONG','CLOSE_TIME');
+ if pc_tmp <> nil then pc_close_long_time :=pc_tmp;
+
+ s_tmp1:=pc_close_long_time;
+ if (pc_close_long_time <> nil) and ( StrLen(pc_close_long_time) = StrLen(PChar(s_tmp)) ) then
+ begin
+ if(s_tmp >= s_tmp1) Then i_close_long_timer:=-888 else i_close_long_timer :=0;
+ end;
+
+ pc_tmp := FF_ffconf(m_ff_action_ini,'SHORT','CLOSE_TIME');
+ if pc_tmp <> nil then pc_close_short_time :=pc_tmp;
+
+ s_tmp1:=pc_close_short_time;
+ if (pc_close_long_time <> nil) and ( StrLen(pc_close_short_time) = StrLen(PChar(s_tmp)) ) then
+ begin
+ if(s_tmp >= s_tmp1) Then i_close_short_timer:=-888 else i_close_short_timer :=0;
+ end;
+
+ for i_loop := 0 to 78 Do
+ begin
+ s_tmp :='FC.'+IntToStr(i_loop);
+ pc_tmp := FF_ffconf(m_ff_local_ini,'FC',PChar(s_tmp));
+ i_fc_count :=i_loop;
+ if pc_tmp <> nil then as_fc_data[i_loop].pc_username :=pc_tmp else Break;
+
+ s_tmp :='FCPWD.'+IntToStr(i_loop);
+ pc_tmp := FF_ffconf(m_ff_local_ini,'FC',PChar(s_tmp));
+ i_fc_count :=i_loop;
+ if pc_tmp <> nil then as_fc_data[i_loop].pc_fcpwd :=pc_tmp;
+
+ s_tmp :='NAME.'+IntToStr(i_loop);
+ pc_tmp := FF_ffconf(m_ff_local_ini,'FC',PChar(s_tmp));
+ i_fc_count :=i_loop;
+ if pc_tmp <> nil then as_fc_data[i_loop].pc_xxx_name :=pc_tmp else Break;
+
+ s_tmp :='VOL.'+IntToStr(i_loop);
+ pc_tmp := FF_ffconf(m_ff_local_ini,'FC',PChar(s_tmp));
+ i_fc_count :=i_loop;
+ if pc_tmp <> nil then as_fc_data[i_loop].i_VOL :=StrToInt(pc_tmp) else Break;
+
+ s_tmp :='LONG_MAX.'+IntToStr(i_loop);
+ pc_tmp := FF_ffconf(m_ff_local_ini,'FC',PChar(s_tmp));
+ i_fc_count :=i_loop;
+ if pc_tmp <> nil then as_fc_data[i_loop].i_long_max :=StrToInt(pc_tmp) else Break;
+
+ s_tmp :='SHORT_MAX.'+IntToStr(i_loop);
+ pc_tmp := FF_ffconf(m_ff_local_ini,'FC',PChar(s_tmp));
+ i_fc_count :=i_loop;
+ if pc_tmp <> nil then as_fc_data[i_loop].i_short_max :=StrToInt(pc_tmp) else Break;
+
+ end;
+
+ Result :=True;
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini,'W20','A_min');
+ if pc_tmp <> nil then i_rsi_A :=StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini,'W20','B_min');
+ if pc_tmp <> nil then i_rsi_B :=StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini,'W20','C_min');
+ if pc_tmp <> nil then i_rsi_C :=StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini,'W20','AB_max');
+ if pc_tmp <> nil then i_rsi_AB :=StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini,'W20','BC_max');
+ if pc_tmp <> nil then i_rsi_BC :=StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini,'W20','IA_min');
+ if pc_tmp <> nil then i_rsi_IA_min :=StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini,'W20','IA_max');
+ if pc_tmp <> nil then i_rsi_IA_max :=StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini,'W20','CUT');
+ if pc_tmp <> nil then f_rsi_cut :=StrToFloat(pc_tmp);
+
+ //f_mbm_cut_all :=f_rsi_cut*3;
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini,'W20','STOP');
+ if pc_tmp <> nil then f_rsi_stop :=StrToFloat(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini,'W20','ADD');
+ if pc_tmp <> nil then f_rsi_add :=StrToFloat(pc_tmp);
+
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini,'W20','F');
+ if pc_tmp <> nil then i_F :=StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini,'W20','S');
+ if pc_tmp <> nil then i_S :=StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini,'W20','T');
+ if pc_tmp <> nil then i_T :=StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini,'W20','A');
+ if pc_tmp <> nil then i_A :=StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini,'W20','M30');
+ if pc_tmp <> nil then i_M30 :=StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini,'W20','M120');
+ if pc_tmp <> nil then i_M120 :=StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini,'W20','BOX_Y');
+ if pc_tmp <> nil then i_BOX_Y :=StrToInt(pc_tmp);
+
+ pc_tmp:= FF_ffconf(m_ff_local_ini,'What','KONLY');
+ if pc_tmp <> nil then i_make_k_only :=StrToInt(pc_tmp);
+
+ pc_tmp:= FF_ffconf(m_ff_local_ini,'What','LS_CTRL');
+ if pc_tmp <> nil then i_long_short_ctrl :=StrToInt(pc_tmp);
+
+ pc_tmp:= FF_ffconf(m_ff_local_ini,'What','CODE');
+ if pc_tmp <> nil then pc_what_wk :=pc_tmp;
+
+ pc_tmp:= FF_ffconf(m_ff_local_ini,'What','MBM_ONLY');
+ if pc_tmp <> nil then i_mbm_only :=StrToInt(pc_tmp);
+
+ pc_tmp:= FF_ffconf(m_ff_local_ini,'What','LONG_ONLY');
+ if pc_tmp <> nil then i_only_long :=StrToInt(pc_tmp);
+
+ pc_tmp:= FF_ffconf(m_ff_local_ini,'What','SHORT_ONLY');
+ if pc_tmp <> nil then i_only_short :=StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_ma120_ini,'M120BB','BOX_Y');
+ if pc_tmp <> nil then i_BB_BOX_Y :=StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_ma120_ini,'M120BB','BOX_X');
+ if pc_tmp <> nil then i_BB_BOX_X :=StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_bb100_ini,'BB_100','BOX_X');
+ if pc_tmp <> nil then i_BB_100_BOX_X :=StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_bb100_ini,'BB_100','BOX_Y');
+ if pc_tmp <> nil then i_BB_100_BOX_Y :=StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_m30_short_ini,'M30','BOX_X');
+ if pc_tmp <> nil then i_M30_short_BOX_X :=StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_m30_short_ini,'M30','BOX_Y');
+ if pc_tmp <> nil then i_M30_short_BOX_Y :=StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_short_1_ini,'Main','ACT');
+ if pc_tmp <> nil then i_act_short :=StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini,'W20','ACT');
+ if pc_tmp <> nil then i_act_rsi :=StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_rsi_ini,'W20','ADD_FLOSS_MAX');
+ if pc_tmp <> nil then i_ADD_FLOSS_MAX :=StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_ma120_ini,'M120BB','ACT');
+ if pc_tmp <> nil then i_act_m120 :=StrToInt(pc_tmp);
+
+ pc_tmp := FF_ffconf(m_ff_bb100_ini,'BB_100','ACT');
+ if pc_tmp <> nil then i_act_bb_100 :=StrToInt(pc_tmp);
+
+ f_rsi_stop_long :=f_rsi_stop;
+ f_rsi_stop_short :=f_rsi_stop;
+
+ pc_tmp:= FF_ffconf(m_ff_local_ini,'What','OPEN_DELTA');
+ if pc_tmp <> nil then i_open_delta :=StrToInt(pc_tmp);
+
+ pc_tmp:= FF_ffconf(m_ff_local_ini,'What','CLOSE_DELTA');
+ if pc_tmp <> nil then i_close_delta :=StrToInt(pc_tmp);
+
+ pc_tmp:= FF_ffconf(m_ff_local_ini,'What','STP_DELTA');
+ if pc_tmp <> nil then i_stp_delta :=StrToInt(pc_tmp);
+
+ pc_tmp:= FF_ffconf(m_ff_local_ini,'What','CHK_POWER_VOL');
+ if pc_tmp <> nil then i_chk_power_vol_set :=StrToInt(pc_tmp);
+
+end;
+
+function ff_do_main_loop():Integer;
+var
+ s_tmp_log :string;
+begin
+
+ i_lock_for_main_loop:=1;
+
+ Result :=0;
+
+ i_loop_count_001 :=i_loop_count_001 + 1;
+ if(i_loop_count_001 >88888888) then i_loop_count_001 :=0;
+
+ try
+
+ if( i_loop_count_001 mod 100 =0 ) then ff_get_qty();
+
+ if( i_ff_get_qty_88 >0 ) then
+ begin
+ i_ff_get_qty_88 := i_ff_get_qty_88 -2;
+ ff_get_qty();
+ end;
+
+ except
+ on E: Exception do
+ begin
+ //Assert(false,s_tmp_log);
+ //W_Log('ff_do_main_loop ff_get_qty',19,999,PChar(s_tmp_log));
+ W_Log('ff_do_main_loop ff_get_qty',19,999,PChar(E.Message));
+ ExitProcess(999);
+ end;
+ end;
+
+ try
+ ff_main_wk_loop();
+ except
+ on E: Exception do
+ begin
+ //Assert(false,s_tmp_log);
+ //W_Log('ff_do_main_loop ff_main_wk_loop',i_line_no_001,999,PChar(s_tmp_log));
+ W_Log('ff_do_main_loop ff_main_wk_loop',i_line_no_001,999,PChar(E.Message));
+ ExitProcess(999);
+ end;
+ end;
+
+ i_lock_for_main_loop:=0;
+
+end;
+
+
+end.
diff --git a/uft_robot/src/ff_qty.dfm b/uft_robot/src/ff_qty.dfm
new file mode 100644
index 00000000..f8324299
--- /dev/null
+++ b/uft_robot/src/ff_qty.dfm
@@ -0,0 +1,25 @@
+object fm_x: Tfm_x
+ Left = 0
+ Top = 0
+ ClientHeight = 300
+ ClientWidth = 635
+ Color = clBlack
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clWindowText
+ Font.Height = -11
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ OldCreateOrder = False
+ PixelsPerInch = 96
+ TextHeight = 13
+ object StringGrid1: TStringGrid
+ Left = 0
+ Top = 0
+ Width = 641
+ Height = 297
+ Color = clBlack
+ FixedCols = 0
+ FixedRows = 0
+ TabOrder = 0
+ end
+end
diff --git a/uft_robot/src/ff_qty.pas b/uft_robot/src/ff_qty.pas
new file mode 100644
index 00000000..c2554dcf
--- /dev/null
+++ b/uft_robot/src/ff_qty.pas
@@ -0,0 +1,25 @@
+unit ff_qty;
+
+interface
+
+uses
+ Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+ Dialogs, Grids;
+
+type
+ Tfm_x = class(TForm)
+ StringGrid1: TStringGrid;
+ private
+ { Private declarations }
+ public
+ { Public declarations }
+ end;
+
+var
+ fm_x: Tfm_x;
+
+implementation
+
+{$R *.dfm}
+
+end.
diff --git a/uft_robot/src/ff_x.dcu b/uft_robot/src/ff_x.dcu
new file mode 100644
index 00000000..ac5e8303
Binary files /dev/null and b/uft_robot/src/ff_x.dcu differ
diff --git a/uft_robot/src/ff_x.dfm b/uft_robot/src/ff_x.dfm
new file mode 100644
index 00000000..f8324299
--- /dev/null
+++ b/uft_robot/src/ff_x.dfm
@@ -0,0 +1,25 @@
+object fm_x: Tfm_x
+ Left = 0
+ Top = 0
+ ClientHeight = 300
+ ClientWidth = 635
+ Color = clBlack
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clWindowText
+ Font.Height = -11
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ OldCreateOrder = False
+ PixelsPerInch = 96
+ TextHeight = 13
+ object StringGrid1: TStringGrid
+ Left = 0
+ Top = 0
+ Width = 641
+ Height = 297
+ Color = clBlack
+ FixedCols = 0
+ FixedRows = 0
+ TabOrder = 0
+ end
+end
diff --git a/uft_robot/src/ff_x.pas b/uft_robot/src/ff_x.pas
new file mode 100644
index 00000000..c0223134
--- /dev/null
+++ b/uft_robot/src/ff_x.pas
@@ -0,0 +1,25 @@
+unit ff_x;
+
+interface
+
+uses
+ Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+ Dialogs, Grids;
+
+type
+ Tfm_x = class(TForm)
+ StringGrid1: TStringGrid;
+ private
+ { Private declarations }
+ public
+ { Public declarations }
+ end;
+
+var
+ fm_x: Tfm_x;
+
+implementation
+
+{$R *.dfm}
+
+end.
diff --git a/uft_robot/src/fm_main.dcu b/uft_robot/src/fm_main.dcu
new file mode 100644
index 00000000..4ffeb5db
Binary files /dev/null and b/uft_robot/src/fm_main.dcu differ
diff --git a/uft_robot/src/fm_main.ddp b/uft_robot/src/fm_main.ddp
new file mode 100644
index 00000000..4370276c
Binary files /dev/null and b/uft_robot/src/fm_main.ddp differ
diff --git a/uft_robot/src/fm_main.dfm b/uft_robot/src/fm_main.dfm
new file mode 100644
index 00000000..264867f3
--- /dev/null
+++ b/uft_robot/src/fm_main.dfm
@@ -0,0 +1,790 @@
+object MAINFORM: TMAINFORM
+ Left = 10
+ Top = 27
+ Width = 765
+ Height = 912
+ Caption = 'FF_300M'
+ Color = clBlack
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clLime
+ Font.Height = -21
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ Menu = MainMenu1
+ OldCreateOrder = False
+ OnCreate = FormCreate
+ OnDestroy = FormDestroy
+ PixelsPerInch = 96
+ TextHeight = 25
+ object Label1: TLabel
+ Left = 131
+ Top = 39
+ Width = 78
+ Height = 24
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clRed
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label2: TLabel
+ Left = 466
+ Top = 39
+ Width = 78
+ Height = 24
+ Alignment = taRightJustify
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clFuchsia
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label3: TLabel
+ Left = 424
+ Top = 323
+ Width = 78
+ Height = 24
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clFuchsia
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label4: TLabel
+ Left = 611
+ Top = 68
+ Width = 78
+ Height = 24
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clFuchsia
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label5: TLabel
+ Left = 131
+ Top = 69
+ Width = 78
+ Height = 24
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label6: TLabel
+ Left = 466
+ Top = 69
+ Width = 78
+ Height = 24
+ Alignment = taRightJustify
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label7: TLabel
+ Left = 136
+ Top = 323
+ Width = 78
+ Height = 24
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clFuchsia
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label8: TLabel
+ Left = 131
+ Top = 110
+ Width = 104
+ Height = 24
+ Caption = ' '
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clRed
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label9: TLabel
+ Left = 131
+ Top = 160
+ Width = 104
+ Height = 24
+ Caption = ' '
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label10: TLabel
+ Left = 461
+ Top = 110
+ Width = 78
+ Height = 24
+ Alignment = taRightJustify
+ Caption = ' '
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clFuchsia
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label11: TLabel
+ Left = 461
+ Top = 160
+ Width = 78
+ Height = 24
+ Alignment = taRightJustify
+ Caption = ' '
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label12: TLabel
+ Left = 3
+ Top = 68
+ Width = 78
+ Height = 24
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clFuchsia
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label13: TLabel
+ Left = 268
+ Top = 323
+ Width = 78
+ Height = 24
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clFuchsia
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label14: TLabel
+ Left = 520
+ Top = 323
+ Width = 78
+ Height = 24
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clFuchsia
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label15: TLabel
+ Left = 569
+ Top = 104
+ Width = 13
+ Height = 24
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label16: TLabel
+ Left = 569
+ Top = 160
+ Width = 13
+ Height = 24
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label_Vol: TLabel
+ Left = 388
+ Top = 8
+ Width = 13
+ Height = 24
+ Alignment = taRightJustify
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label_long_stp: TLabel
+ Left = 424
+ Top = 110
+ Width = 13
+ Height = 24
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label_short_stp: TLabel
+ Left = 424
+ Top = 160
+ Width = 13
+ Height = 24
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label_up_power: TLabel
+ Left = 126
+ Top = 221
+ Width = 78
+ Height = 24
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clRed
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label_down_power: TLabel
+ Left = 424
+ Top = 221
+ Width = 78
+ Height = 24
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ end
+ object Label_status: TLabel
+ Left = 126
+ Top = 281
+ Width = 78
+ Height = 24
+ Caption = 'Label1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = #24188#22278
+ Font.Style = [fsBold]
+ ParentFont = False
+ OnClick = Label_statusClick
+ end
+ object BitBtn1: TBitBtn
+ Left = 8
+ Top = 8
+ Width = 33
+ Height = 25
+ Caption = #24320#22810
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clRed
+ Font.Height = -19
+ Font.Name = #38582#20070
+ Font.Style = []
+ ParentFont = False
+ TabOrder = 1
+ OnClick = BitBtn1Click
+ end
+ object BitBtn2: TBitBtn
+ Left = 8
+ Top = 323
+ Width = 33
+ Height = 24
+ Caption = #28165'0'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clRed
+ Font.Height = -19
+ Font.Name = #38582#20070
+ Font.Style = [fsBold]
+ ParentFont = False
+ TabOrder = 2
+ OnClick = BitBtn2Click
+ end
+ object BitBtn3: TBitBtn
+ Left = 696
+ Top = 8
+ Width = 37
+ Height = 25
+ Caption = #24320#31354
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clBlue
+ Font.Height = -19
+ Font.Name = #38582#20070
+ Font.Style = []
+ ParentFont = False
+ TabOrder = 3
+ OnClick = BitBtn3Click
+ end
+ object BitBtn4: TBitBtn
+ Left = 696
+ Top = 323
+ Width = 37
+ Height = 24
+ Caption = #28165'0'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clBlue
+ Font.Height = -19
+ Font.Name = #38582#20070
+ Font.Style = []
+ ParentFont = False
+ TabOrder = 4
+ OnClick = BitBtn4Click
+ end
+ object F7FC: TBitBtn
+ Left = 368
+ Top = 317
+ Width = 33
+ Height = 30
+ Caption = 'F7'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clFuchsia
+ Font.Height = -29
+ Font.Name = #38582#20070
+ Font.Style = [fsBold]
+ ParentFont = False
+ TabOrder = 0
+ OnClick = NextFCClick
+ end
+ object Edit1: TEdit
+ Left = 611
+ Top = 98
+ Width = 117
+ Height = 37
+ Color = clWindowText
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ ParentFont = False
+ TabOrder = 5
+ OnKeyPress = Edit1KeyPress
+ end
+ object Edit2: TEdit
+ Left = 611
+ Top = 154
+ Width = 117
+ Height = 37
+ Color = clWindowText
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ ParentFont = False
+ TabOrder = 6
+ OnKeyPress = Edit2KeyPress
+ end
+ object BitBtn5: TBitBtn
+ Left = 616
+ Top = 11
+ Width = 42
+ Height = 23
+ Caption = #25764#21333
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clFuchsia
+ Font.Height = -29
+ Font.Name = #38582#20070
+ Font.Style = []
+ ParentFont = False
+ TabOrder = 7
+ OnClick = CancelOrderClick
+ end
+ object Edit_long_stp: TEdit
+ Left = 3
+ Top = 98
+ Width = 117
+ Height = 37
+ Color = clWindowText
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ ParentFont = False
+ TabOrder = 8
+ OnKeyPress = Edit_long_stpKeyPress
+ end
+ object Edit_short_stp: TEdit
+ Left = 3
+ Top = 154
+ Width = 117
+ Height = 37
+ Color = clWindowText
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ ParentFont = False
+ TabOrder = 9
+ OnKeyPress = Edit_short_stpKeyPress
+ end
+ object BitBtn6: TBitBtn
+ Left = 8
+ Top = 251
+ Width = 33
+ Height = 24
+ Caption = '-1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clRed
+ Font.Height = -19
+ Font.Name = #38582#20070
+ Font.Style = [fsBold]
+ ParentFont = False
+ TabOrder = 10
+ OnClick = BitBtn6Click
+ end
+ object BitBtn7: TBitBtn
+ Left = 696
+ Top = 251
+ Width = 37
+ Height = 24
+ Caption = '-1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clBlue
+ Font.Height = -19
+ Font.Name = #38582#20070
+ Font.Style = [fsBold]
+ ParentFont = False
+ TabOrder = 11
+ OnClick = BitBtn7Click
+ end
+ object BitBtn8: TBitBtn
+ Left = 616
+ Top = 323
+ Width = 37
+ Height = 24
+ Caption = #30041'1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clBlue
+ Font.Height = -19
+ Font.Name = #38582#20070
+ Font.Style = []
+ ParentFont = False
+ TabOrder = 12
+ OnClick = BitBtn8Click
+ end
+ object BitBtn9: TBitBtn
+ Left = 92
+ Top = 323
+ Width = 33
+ Height = 24
+ Caption = #30041'1'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clRed
+ Font.Height = -19
+ Font.Name = #38582#20070
+ Font.Style = [fsBold]
+ ParentFont = False
+ TabOrder = 13
+ OnClick = BitBtn9Click
+ end
+ object BitBtn10: TBitBtn
+ Left = 92
+ Top = 251
+ Width = 33
+ Height = 24
+ Caption = '0 +'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clRed
+ Font.Height = -19
+ Font.Name = #38582#20070
+ Font.Style = [fsBold]
+ ParentFont = False
+ TabOrder = 14
+ OnClick = BitBtn10Click
+ end
+ object BitBtn11: TBitBtn
+ Left = 616
+ Top = 251
+ Width = 37
+ Height = 24
+ Caption = '0 +'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clBlue
+ Font.Height = -19
+ Font.Name = #38582#20070
+ Font.Style = [fsBold]
+ ParentFont = False
+ TabOrder = 15
+ OnClick = BitBtn11Click
+ end
+ object Edit_vol_chk: TEdit
+ Left = 3
+ Top = 208
+ Width = 117
+ Height = 37
+ Color = clWindowText
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ ParentFont = False
+ TabOrder = 16
+ OnKeyPress = Edit_vol_chkKeyPress
+ end
+ object BitBtn12: TBitBtn
+ Left = 92
+ Top = 8
+ Width = 33
+ Height = 25
+ Caption = 'C'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clRed
+ Font.Height = -19
+ Font.Name = #38582#20070
+ Font.Style = []
+ ParentFont = False
+ TabOrder = 17
+ OnClick = BitBtn12Click
+ end
+ object Edit_open_price: TEdit
+ Left = 616
+ Top = 280
+ Width = 117
+ Height = 37
+ Color = clWindowText
+ Font.Charset = DEFAULT_CHARSET
+ Font.Color = clLime
+ Font.Height = -24
+ Font.Name = 'Tahoma'
+ Font.Style = []
+ ParentFont = False
+ TabOrder = 18
+ Text = '0'
+ OnKeyPress = Edit_open_priceKeyPress
+ end
+ object ff_sg: TStringGrid
+ Left = 8
+ Top = 368
+ Width = 725
+ Height = 473
+ Color = clBlack
+ ColCount = 7
+ FixedCols = 0
+ FixedRows = 0
+ TabOrder = 19
+ OnDrawCell = ff_sgDrawCell
+ end
+ object BitBtn13: TBitBtn
+ Left = 368
+ Top = 244
+ Width = 33
+ Height = 30
+ Caption = 'V'
+ Font.Charset = GB2312_CHARSET
+ Font.Color = clFuchsia
+ Font.Height = -29
+ Font.Name = #38582#20070
+ Font.Style = [fsBold]
+ ParentFont = False
+ TabOrder = 20
+ OnClick = BitBtn13Click
+ end
+ object MainMenu1: TMainMenu
+ AutoHotkeys = maManual
+ Left = 667
+ Top = 40
+ object N3: TMenuItem
+ Caption = #25511#21046
+ object N16: TMenuItem
+ Caption = #27490#36194#21152#20493
+ end
+ object N17: TMenuItem
+ Caption = #27490#36194#20943#21322
+ end
+ object N20: TMenuItem
+ Caption = '--------'
+ end
+ object N18: TMenuItem
+ Caption = #27490#25439#21152#20493
+ end
+ object N19: TMenuItem
+ Caption = #27490#25439#20943#21322
+ end
+ object N14: TMenuItem
+ Caption = '--------'
+ end
+ object N15: TMenuItem
+ Caption = #25163#21160#20132#26131
+ OnClick = N15Click
+ end
+ object N27: TMenuItem
+ Caption = #33258#21160#20132#26131
+ OnClick = N27Click
+ end
+ object N33: TMenuItem
+ Caption = '--------'
+ end
+ object ShortOnly: TMenuItem
+ Caption = 'Short Only'
+ OnClick = ShortOnlyClick
+ end
+ object N35: TMenuItem
+ Caption = '--------'
+ end
+ object LongOnly: TMenuItem
+ Caption = 'Long Only'
+ OnClick = LongOnlyClick
+ end
+ object N34: TMenuItem
+ Caption = '--------'
+ end
+ object Konly: TMenuItem
+ Caption = 'K Only'
+ Checked = True
+ OnClick = KonlyClick
+ end
+ object N1: TMenuItem
+ Caption = '--------'
+ end
+ object Only1: TMenuItem
+ Caption = #21333#21457
+ OnClick = Only1Click
+ end
+ object NextFC: TMenuItem
+ Caption = 'Next FC'
+ ShortCut = 118
+ OnClick = NextFCClick
+ end
+ object N2: TMenuItem
+ Caption = '--------'
+ end
+ object N4: TMenuItem
+ Caption = #22810#21333#38145#20179
+ OnClick = N4Click
+ end
+ object N5: TMenuItem
+ Caption = #31354#21333#38145#20179
+ OnClick = N5Click
+ end
+ object N6: TMenuItem
+ Caption = '--------'
+ end
+ object Long_STP: TMenuItem
+ Caption = #22810#21333'STP'
+ OnClick = Long_STPClick
+ end
+ object Short_STP: TMenuItem
+ Caption = #31354#21333'STP'
+ OnClick = Short_STPClick
+ end
+ end
+ object N21: TMenuItem
+ Caption = #20132#26131
+ object N22: TMenuItem
+ Caption = #21334#20215#20316#22810
+ ShortCut = 120
+ OnClick = N22Click
+ end
+ object N23: TMenuItem
+ Caption = #20080#20215#20316#22810
+ ShortCut = 121
+ OnClick = N23Click
+ end
+ object N26: TMenuItem
+ Caption = '--------'
+ end
+ object N24: TMenuItem
+ Caption = #20080#20215#20316#31354
+ ShortCut = 122
+ OnClick = N24Click
+ end
+ object N25: TMenuItem
+ Caption = #21334#20215#20316#31354
+ ShortCut = 123
+ OnClick = N25Click
+ end
+ object N28: TMenuItem
+ Caption = '--------'
+ end
+ object N29: TMenuItem
+ Caption = #22810#22836#24179#20179
+ ShortCut = 114
+ OnClick = N29Click
+ end
+ object N30: TMenuItem
+ Caption = '--------'
+ end
+ object N31: TMenuItem
+ Caption = '--------'
+ end
+ object N32: TMenuItem
+ Caption = #31354#22836#24179#20179
+ ShortCut = 115
+ OnClick = N32Click
+ end
+ object N36: TMenuItem
+ Caption = '--------'
+ end
+ object N38: TMenuItem
+ Caption = '--------'
+ end
+ object N37: TMenuItem
+ Caption = 'ClearLong +1'
+ ShortCut = 116
+ OnClick = N37Click
+ end
+ object N39: TMenuItem
+ Caption = '--------'
+ end
+ object N40: TMenuItem
+ Caption = '--------'
+ end
+ object ClearShort11: TMenuItem
+ Caption = 'ClearShort -1'
+ ShortCut = 117
+ OnClick = ClearShort11Click
+ end
+ object N41: TMenuItem
+ Caption = '--------'
+ end
+ object CancelOrder: TMenuItem
+ Caption = 'CancelOrder'
+ ShortCut = 119
+ OnClick = CancelOrderClick
+ end
+ end
+ end
+ object Timer1: TTimer
+ Interval = 150
+ OnTimer = Timer1Timer
+ Left = 704
+ Top = 40
+ end
+end
diff --git a/uft_robot/src/fm_main.pas b/uft_robot/src/fm_main.pas
new file mode 100644
index 00000000..a5892673
--- /dev/null
+++ b/uft_robot/src/fm_main.pas
@@ -0,0 +1,700 @@
+unit fm_main;
+
+interface
+
+uses
+ Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
+ Dialogs, Menus, StdCtrls, ExtCtrls, Buttons, Grids;
+
+type
+ TMAINFORM = class(TForm)
+ MainMenu1: TMainMenu;
+ N3: TMenuItem;
+ N16: TMenuItem;
+ N17: TMenuItem;
+ N20: TMenuItem;
+ N18: TMenuItem;
+ N19: TMenuItem;
+ N14: TMenuItem;
+ N15: TMenuItem;
+ N27: TMenuItem;
+ N33: TMenuItem;
+ ShortOnly: TMenuItem;
+ N35: TMenuItem;
+ LongOnly: TMenuItem;
+ N34: TMenuItem;
+ Konly: TMenuItem;
+ N21: TMenuItem;
+ N22: TMenuItem;
+ N23: TMenuItem;
+ N26: TMenuItem;
+ N24: TMenuItem;
+ N25: TMenuItem;
+ N28: TMenuItem;
+ N29: TMenuItem;
+ N30: TMenuItem;
+ N31: TMenuItem;
+ N32: TMenuItem;
+ N36: TMenuItem;
+ N38: TMenuItem;
+ N37: TMenuItem;
+ N39: TMenuItem;
+ N40: TMenuItem;
+ ClearShort11: TMenuItem;
+ N41: TMenuItem;
+ CancelOrder: TMenuItem;
+ Label1: TLabel;
+ Label2: TLabel;
+ Label3: TLabel;
+ Label4: TLabel;
+ Label5: TLabel;
+ Label6: TLabel;
+ Label7: TLabel;
+ Label8: TLabel;
+ Label9: TLabel;
+ Label10: TLabel;
+ Label11: TLabel;
+ Timer1: TTimer;
+ N1: TMenuItem;
+ NextFC: TMenuItem;
+ Only1: TMenuItem;
+ Label12: TLabel;
+ Label13: TLabel;
+ Label14: TLabel;
+ BitBtn1: TBitBtn;
+ BitBtn2: TBitBtn;
+ BitBtn3: TBitBtn;
+ BitBtn4: TBitBtn;
+ F7FC: TBitBtn;
+ Label15: TLabel;
+ Label16: TLabel;
+ N2: TMenuItem;
+ N4: TMenuItem;
+ N5: TMenuItem;
+ Edit1: TEdit;
+ Edit2: TEdit;
+ BitBtn5: TBitBtn;
+ Edit_long_stp: TEdit;
+ Edit_short_stp: TEdit;
+ Label_Vol: TLabel;
+ Label_long_stp: TLabel;
+ Label_short_stp: TLabel;
+ N6: TMenuItem;
+ Long_STP: TMenuItem;
+ Short_STP: TMenuItem;
+ BitBtn6: TBitBtn;
+ BitBtn7: TBitBtn;
+ BitBtn8: TBitBtn;
+ BitBtn9: TBitBtn;
+ BitBtn10: TBitBtn;
+ BitBtn11: TBitBtn;
+ Edit_vol_chk: TEdit;
+ Label_up_power: TLabel;
+ Label_down_power: TLabel;
+ BitBtn12: TBitBtn;
+ Edit_open_price: TEdit;
+ Label_status: TLabel;
+ ff_sg: TStringGrid;
+ BitBtn13: TBitBtn;
+ procedure FormCreate(Sender: TObject);
+ procedure FormDestroy(Sender: TObject);
+ procedure LongOnlyClick(Sender: TObject);
+ procedure ShortOnlyClick(Sender: TObject);
+ procedure KonlyClick(Sender: TObject);
+ procedure N15Click(Sender: TObject);
+ procedure N27Click(Sender: TObject);
+ procedure Timer1Timer(Sender: TObject);
+ procedure N22Click(Sender: TObject);
+ procedure N23Click(Sender: TObject);
+ procedure N24Click(Sender: TObject);
+ procedure N25Click(Sender: TObject);
+ procedure N29Click(Sender: TObject);
+ procedure N32Click(Sender: TObject);
+ procedure N37Click(Sender: TObject);
+ procedure ClearShort11Click(Sender: TObject);
+ procedure CancelOrderClick(Sender: TObject);
+ procedure NextFCClick(Sender: TObject);
+ procedure Only1Click(Sender: TObject);
+ procedure BitBtn1Click(Sender: TObject);
+ procedure BitBtn3Click(Sender: TObject);
+ procedure BitBtn2Click(Sender: TObject);
+ procedure BitBtn4Click(Sender: TObject);
+ procedure N4Click(Sender: TObject);
+ procedure N5Click(Sender: TObject);
+ procedure Edit1KeyPress(Sender: TObject; var Key: Char);
+ procedure Edit2KeyPress(Sender: TObject; var Key: Char);
+ procedure Long_STPClick(Sender: TObject);
+ procedure Short_STPClick(Sender: TObject);
+ procedure Edit_long_stpKeyPress(Sender: TObject; var Key: Char);
+ procedure Edit_short_stpKeyPress(Sender: TObject; var Key: Char);
+ procedure BitBtn6Click(Sender: TObject);
+ procedure BitBtn7Click(Sender: TObject);
+ procedure BitBtn8Click(Sender: TObject);
+ procedure BitBtn9Click(Sender: TObject);
+ procedure BitBtn10Click(Sender: TObject);
+ procedure BitBtn11Click(Sender: TObject);
+ procedure BitBtn12Click(Sender: TObject);
+ procedure Label_statusClick(Sender: TObject);
+ procedure Edit_open_priceKeyPress(Sender: TObject; var Key: Char);
+ procedure Edit_vol_chkKeyPress(Sender: TObject; var Key: Char);
+ procedure BitBtn13Click(Sender: TObject);
+ procedure ff_sgDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect;
+ State: TGridDrawState);
+ private
+ { Private declarations }
+ public
+ { Public declarations }
+ end;
+
+//var
+// MAINFORM: TMAINFORM;
+
+implementation
+
+{$R *.dfm}
+
+uses ff_hs_base,s_lib_pas_unit;
+
+procedure TMAINFORM.BitBtn10Click(Sender: TObject);
+begin
+ if f_buy_1 <1.0 Then Exit;
+
+ i_stp_long :=0;
+ Long_STP.Checked :=False;
+
+ i_set_stp_long_wk := Round(f_last_price_wk-0.49 + i_stp_delta);
+ Edit_long_stp.Text:=IntToStr(i_set_stp_long_wk);
+
+ Long_STPClick(Sender);
+
+ i_BSK :=m_bsk_clear_long;
+ s_caption_8:=' ';
+ s_caption_9:=' ';
+ s_caption_10:=' ';
+ s_caption_11:=' ';
+end;
+
+procedure TMAINFORM.BitBtn11Click(Sender: TObject);
+begin
+
+ if f_buy_1 <1.0 Then Exit;
+
+ i_stp_short :=0;
+ Short_STP.Checked :=False;
+
+ i_set_stp_short_wk := Round(f_last_price_wk+0.49 - i_stp_delta);
+ Edit_short_stp.Text:=IntToStr(i_set_stp_short_wk);
+ Short_STPClick(Sender);
+
+ i_BSK :=m_bsk_clear_short;
+ s_caption_8:=' ';
+ s_caption_9:=' ';
+ s_caption_10:=' ';
+ s_caption_11:=' ';
+
+end;
+
+procedure TMAINFORM.BitBtn12Click(Sender: TObject);
+begin
+ if( i_vol_start =0 ) and ( i_vol_reset =0 ) Then
+ begin
+ i_vol_start :=888;
+ i_vol_reset :=0;
+ tdt_vol_0 :=Now;
+ end;
+
+ if( i_vol_start =999 ) and ( i_vol_reset =0 ) Then
+ begin
+ i_vol_start :=0;
+ i_vol_reset :=0;
+ tdt_vol_0 :=Now;
+ end;
+
+end;
+
+procedure TMAINFORM.BitBtn13Click(Sender: TObject);
+begin
+ if i_show_string_grid <1 Then i_show_string_grid :=1 else i_show_string_grid :=0;
+ if i_do_ff_qty_loop =0 Then i_do_ff_qty_loop :=888;
+end;
+
+procedure TMAINFORM.BitBtn1Click(Sender: TObject);
+begin
+ if f_buy_1 <1.0 Then Exit;
+ i_BSK:=m_bsk_ask_long;
+end;
+
+procedure TMAINFORM.BitBtn2Click(Sender: TObject);
+begin
+ if f_buy_1 <1.0 Then Exit;
+ i_BSK :=m_bsk_clear_long;
+ s_caption_8:=' ';
+ s_caption_9:=' ';
+ s_caption_10:=' ';
+ s_caption_11:=' ';
+end;
+
+procedure TMAINFORM.BitBtn3Click(Sender: TObject);
+begin
+ if f_buy_1 <1.0 Then Exit;
+ i_BSK:=m_bsk_bid_short;
+end;
+
+procedure TMAINFORM.BitBtn4Click(Sender: TObject);
+begin
+ if f_buy_1 <1.0 Then Exit;
+ i_BSK :=m_bsk_clear_short;
+ s_caption_8:=' ';
+ s_caption_9:=' ';
+ s_caption_10:=' ';
+ s_caption_11:=' ';
+end;
+
+procedure TMAINFORM.BitBtn6Click(Sender: TObject);
+begin
+
+ if f_buy_1 <1.0 Then Exit;
+
+ i_clr_long_1_mark :=888;
+ i_BSK :=m_bsk_clear_long;
+ s_caption_8:=' ';
+ s_caption_9:=' ';
+ s_caption_10:=' ';
+ s_caption_11:=' ';
+end;
+
+procedure TMAINFORM.BitBtn7Click(Sender: TObject);
+begin
+ if f_buy_1 <1.0 Then Exit;
+ i_BSK :=m_bsk_clear_short;
+ s_caption_8:=' ';
+ s_caption_9:=' ';
+ s_caption_10:=' ';
+ s_caption_11:=' ';
+ i_clr_short_1_mark:=888;
+end;
+
+procedure TMAINFORM.BitBtn8Click(Sender: TObject);
+begin
+ if f_buy_1 <1.0 Then Exit;
+ i_BSK :=m_bsk_clear_short;
+ s_caption_8:=' ';
+ s_caption_9:=' ';
+ s_caption_10:=' ';
+ s_caption_11:=' ';
+ i_clr_short_to_001_mark :=888;
+end;
+
+procedure TMAINFORM.BitBtn9Click(Sender: TObject);
+begin
+ if f_buy_1 <1.0 Then Exit;
+
+ i_clr_long_to_001_mark :=888;
+ i_BSK :=m_bsk_clear_long;
+ s_caption_8:=' ';
+ s_caption_9:=' ';
+ s_caption_10:=' ';
+ s_caption_11:=' ';
+end;
+
+procedure TMAINFORM.CancelOrderClick(Sender: TObject);
+begin
+ //ClearOrder
+ i_BSK :=9;
+end;
+
+procedure TMAINFORM.ClearShort11Click(Sender: TObject);
+begin
+ //ClearShort -2
+ if f_buy_1 <1.0 Then Exit;
+ i_BSK :=8;
+ //i_ff_get_qty_88 := 188;
+
+end;
+
+procedure TMAINFORM.Edit1KeyPress(Sender: TObject; var Key: Char);
+begin
+ if Key in ['a'..'z'] + ['A'..'Z']then Key := #0;
+ i_lock_long:=0;
+end;
+
+procedure TMAINFORM.Edit2KeyPress(Sender: TObject; var Key: Char);
+begin
+ if Key in ['a'..'z'] + ['A'..'Z']then Key := #0;
+ i_lock_short :=0;
+end;
+
+procedure TMAINFORM.Edit_long_stpKeyPress(Sender: TObject; var Key: Char);
+begin
+ if Key in ['a'..'z'] + ['A'..'Z']then Key := #0;
+ i_stp_long:=0;
+end;
+
+procedure TMAINFORM.Edit_open_priceKeyPress(Sender: TObject; var Key: Char);
+begin
+ if Key in ['a'..'z'] + ['A'..'Z']then Key := #0;
+end;
+
+procedure TMAINFORM.Edit_short_stpKeyPress(Sender: TObject; var Key: Char);
+begin
+ if Key in ['a'..'z'] + ['A'..'Z']then Key := #0;
+ i_stp_short:=0;
+end;
+
+procedure TMAINFORM.Edit_vol_chkKeyPress(Sender: TObject; var Key: Char);
+begin
+ if Key in ['a'..'z'] + ['A'..'Z']then Key := #0;
+end;
+
+procedure TMAINFORM.ff_sgDrawCell(Sender: TObject; ACol, ARow: Integer;
+ Rect: TRect; State: TGridDrawState);
+var
+ iBackColor,iFrontColor:Integer;
+begin
+ case ( ACol ) of
+ 0: iFrontColor :=clYellow;
+ 1: iFrontColor :=$00FF00;
+ 2: iFrontColor :=clRed;
+ 3: iFrontColor :=$ff00ff;
+ 4: iFrontColor :=$00FF00;
+ 5: iFrontColor :=$ff00ff;
+ 6: iFrontColor := clYellow;
+ end;
+
+ with TStringGrid(Sender) do
+ begin
+ Canvas.Font.Color := iFrontColor;
+ Canvas.FillRect(Rect);
+ Canvas.TextRect(Rect,Rect.Left+2,Rect.Top+2,Cells[ACol,ARow]);
+ end;
+
+end;
+
+procedure TMAINFORM.FormCreate(Sender: TObject);
+begin
+ FillChar(c_open_price,SizeOf(c_open_price),0);
+
+ FF_creat_comm_obj();
+
+ //DoubleBuffered:=True;
+ if(i_make_k_only >0) then
+ begin
+ Konly.Checked:=True;
+ end
+ else
+ Konly.Checked:=false;
+
+
+ if(i_only_long=0) then
+ begin
+ LongOnly.Checked:=False;
+ end
+ else if(i_only_long=1) then
+ begin
+ LongOnly.Checked:=True;
+ end;
+
+ if(i_only_short=0) then
+ begin
+ ShortOnly.Checked:=False;
+ end
+ else if(i_only_short=1) then
+ begin
+ ShortOnly.Checked:=True;
+ end;
+
+ if(i_only_long=0) and (i_only_short=0) then i_long_short_ctrl :=0;
+ if(i_only_long=1) or (i_only_short=1) then i_long_short_ctrl :=1;
+
+ Edit_vol_chk.Text:=IntToStr(i_chk_power_vol_set);
+
+
+ //ff_sg.Options := Header.Options - [goVertLine, goHorzLine];
+ ff_sg.ColCount:=7;
+ ff_sg.RowCount:=i_fc_count+1;
+
+ ff_sg.Color := clBlack;
+ ff_sg.Cells[0,0] := 'ÕË ºÅ';
+ ff_sg.Cells[1,0] := 'Ãû ³Æ';
+ ff_sg.Cells[2,0] := '¶à ³É ±¾';
+ ff_sg.Cells[3,0] := '¶àÊýÁ¿';
+ ff_sg.Cells[4,0] := '¿Õ ³É ±¾';
+ ff_sg.Cells[5,0] := '¿ÕÊýÁ¿';
+ ff_sg.Cells[6,0] := '×Ü ×Ê ²ú';
+
+ ff_sg.ColWidths[0]:=100;
+ ff_sg.ColWidths[1]:=100;
+ ff_sg.ColWidths[2]:=100;
+ ff_sg.ColWidths[3]:=70;
+ ff_sg.ColWidths[4]:=100;
+ ff_sg.ColWidths[5]:=70;
+ ff_sg.ColWidths[6]:=120;
+
+end;
+
+procedure TMAINFORM.FormDestroy(Sender: TObject);
+begin
+ FF_release_comm_obj();
+end;
+
+procedure TMAINFORM.KonlyClick(Sender: TObject);
+begin
+ if(i_make_k_only =0) and (Konly.Checked = false) then
+ begin
+ Konly.Checked:=True;
+ i_make_k_only :=128;
+ end
+ else if(i_make_k_only >0) and (Konly.Checked = true) then
+ begin
+ Konly.Checked:=false;
+ i_make_k_only :=0;
+ end;
+end;
+
+procedure TMAINFORM.Label_statusClick(Sender: TObject);
+begin
+ s_caption_status :=' ';
+end;
+
+procedure TMAINFORM.LongOnlyClick(Sender: TObject);
+begin
+ if(i_only_long=0) and (LongOnly.Checked = false) then
+ begin
+ LongOnly.Checked:=True;
+ i_only_long:=1;
+ i_only_short:=0;
+ end
+ else if(i_only_long=1) and (LongOnly.Checked = true) then
+ begin
+ LongOnly.Checked:=false;
+ i_only_long:=0;
+ end;
+
+ if(i_only_short=0) then
+ begin
+ ShortOnly.Checked:=False;
+ end
+ else if(i_only_short=1) then
+ begin
+ ShortOnly.Checked:=True;
+ end;
+
+ if(i_only_long=0) and (i_only_short=0) then i_long_short_ctrl :=0;
+ if(i_only_long=1) or (i_only_short=1) then i_long_short_ctrl :=1;
+
+end;
+
+procedure TMAINFORM.Long_STPClick(Sender: TObject);
+begin
+ if Long_STP.Checked =True Then Long_STP.Checked :=False else Long_STP.Checked :=True;
+ if Long_STP.Checked =True Then s_caption_long_stp :='+' else s_caption_long_stp :=' ';
+ if Long_STP.Checked =True Then i_stp_long :=888 else i_stp_long :=0;
+ if Long_STP.Checked =True Then i_act_stp_long_mark :=0;
+
+ if i_stp_long =888 Then Long_STP.Checked :=True;
+
+ if( StrLen(PChar(Edit_long_stp.Text)) >0 ) Then i_set_stp_long := StrToInt(Edit_long_stp.Text)
+ else i_set_stp_long :=0;
+
+ if( i_set_stp_long > 9 ) Then
+ begin
+ i_set_stp_long_wk := i_set_stp_long;
+ end
+ else i_set_stp_long_wk :=0;
+end;
+
+
+procedure TMAINFORM.N15Click(Sender: TObject);
+begin
+ i_no_trade:=888;
+
+end;
+
+procedure TMAINFORM.N22Click(Sender: TObject);
+begin
+ if f_sale_1 <1.0 Then Exit;
+ i_BSK :=1;
+ i_ff_get_qty_88 := 88;
+end;
+
+procedure TMAINFORM.N23Click(Sender: TObject);
+begin
+ if f_buy_1 <1.0 Then Exit;
+ i_BSK :=2;
+ i_ff_get_qty_88 := 88;
+end;
+
+procedure TMAINFORM.N24Click(Sender: TObject);
+begin
+ if f_buy_1 <1.0 Then Exit;
+ i_BSK :=3;
+ i_ff_get_qty_88 := 88;
+end;
+
+procedure TMAINFORM.N25Click(Sender: TObject);
+begin
+ if f_sale_1 <1.0 Then Exit;
+ i_BSK :=4;
+ i_ff_get_qty_88 := 88;
+
+end;
+
+procedure TMAINFORM.N27Click(Sender: TObject);
+begin
+ i_no_trade:=0;
+end;
+
+procedure TMAINFORM.N29Click(Sender: TObject);
+begin
+ if f_buy_1 <1.0 Then Exit;
+ i_BSK :=5;
+ s_caption_8:=' ';
+ s_caption_9:=' ';
+ s_caption_10:=' ';
+ s_caption_11:=' ';
+
+end;
+
+procedure TMAINFORM.N32Click(Sender: TObject);
+begin
+ if f_buy_1 <1.0 Then Exit;
+ i_BSK :=6;
+
+ s_caption_8:=' ';
+ s_caption_9:=' ';
+ s_caption_10:=' ';
+ s_caption_11:=' ';
+
+end;
+
+procedure TMAINFORM.N37Click(Sender: TObject);
+begin
+ //ClearLong +2
+ if f_buy_1 <1.0 Then Exit;
+ i_BSK :=7;
+ //i_ff_get_qty_88 := 188;
+
+end;
+
+procedure TMAINFORM.N4Click(Sender: TObject);
+begin
+ i_cut_lock_long :=0;
+
+ if N4.Checked =True Then N4.Checked :=False else N4.Checked :=True;
+ if N4.Checked =True Then s_caption_15 :='Ëø' else s_caption_15 :=' ';
+ if N4.Checked =True Then i_lock_long :=888 else i_lock_long :=0;
+ if N4.Checked =True Then i_cut_lock_long_mark :=0;
+
+ if i_lock_long =888 Then N4.Checked :=True;
+
+ if( StrLen(PChar(Edit1.Text)) >0 ) Then i_set_lock_long := StrToInt(Edit1.Text)
+ else i_set_lock_long :=0;
+
+ if( i_set_lock_long > 9 ) Then
+ begin
+ i_set_lock_long_wk := i_set_lock_long;
+ end
+ else i_set_lock_long_wk :=0;
+
+end;
+
+procedure TMAINFORM.N5Click(Sender: TObject);
+begin
+ i_cut_lock_short :=0;
+
+ if N5.Checked =True Then N5.Checked :=False else N5.Checked :=True;
+ if N5.Checked =True Then s_caption_16 :='Ëø' else s_caption_16 :=' ';
+ if N5.Checked =True Then i_lock_short :=888 else i_lock_short :=0;
+ if N5.Checked =True Then i_cut_lock_short_mark :=0;
+
+ if i_lock_short =888 Then N5.Checked :=True;
+
+ if( StrLen(PChar(Edit2.Text)) >0 ) Then i_set_lock_short := StrToInt(Edit2.Text)
+ else i_set_lock_short :=0;
+
+ if( i_set_lock_short > 9 ) Then
+ begin
+ i_set_lock_short_wk := i_set_lock_short;
+ end
+ else i_set_lock_short_wk :=0;
+
+end;
+
+procedure TMAINFORM.NextFCClick(Sender: TObject);
+begin
+
+ i_fc_wk_index := i_fc_wk_index +1;
+ if(i_fc_wk_index >i_fc_count -1 ) Then i_fc_wk_index := 0;
+
+ s_caption_8:=' ';
+ s_caption_9:=' ';
+ s_caption_10:=' ';
+ s_caption_11:=' ';
+
+ i_got_it_mark :=0;
+ i_short_mark :=0;
+ i_ff_get_qty_88 := 8;
+end;
+
+procedure TMAINFORM.Only1Click(Sender: TObject);
+begin
+ if Only1.Checked =True Then Only1.Checked :=False else Only1.Checked :=True;
+ if Only1.Checked =True Then i_only_1 := 1 else i_only_1 := 0;
+
+ if Only1.Checked =True Then s_caption_14 :='µ¥·¢' else s_caption_14 :='Ⱥ·¢';
+
+end;
+
+procedure TMAINFORM.ShortOnlyClick(Sender: TObject);
+begin
+ if(i_only_short=0) and (ShortOnly.Checked = false) then
+ begin
+ ShortOnly.Checked:=True;
+ i_only_short:=1;
+ i_only_long:=0;
+ end
+ else if(i_only_short=1) and (ShortOnly.Checked = true) then
+ begin
+ ShortOnly.Checked:=false;
+ i_only_short:=0;
+ end;
+
+ if(i_only_long=0) then
+ begin
+ LongOnly.Checked:=False;
+ end
+ else if(i_only_long=1) then
+ begin
+ LongOnly.Checked:=True;
+ end;
+
+ if(i_only_long=0) and (i_only_short=0) then i_long_short_ctrl :=0;
+ if(i_only_long=1) or (i_only_short=1) then i_long_short_ctrl :=1;
+
+end;
+
+procedure TMAINFORM.Short_STPClick(Sender: TObject);
+begin
+ if Short_STP.Checked =True Then Short_STP.Checked :=False else Short_STP.Checked :=True;
+ if Short_STP.Checked =True Then s_caption_short_stp :='+' else s_caption_short_stp :=' ';
+ if Short_STP.Checked =True Then i_stp_short :=888 else i_stp_short :=0;
+ if Short_STP.Checked =True Then i_act_stp_short_mark :=0;
+
+ if i_stp_short =888 Then Short_STP.Checked :=True;
+
+ if( StrLen(PChar(Edit_short_stp.Text)) >0 ) Then i_set_stp_short := StrToInt(Edit_short_stp.Text)
+ else i_set_stp_short :=0;
+
+ if( i_set_stp_short > 9 ) Then
+ begin
+ i_set_stp_short_wk := i_set_stp_short;
+ end
+ else i_set_stp_short_wk :=0;
+end;
+
+procedure TMAINFORM.Timer1Timer(Sender: TObject);
+begin
+ ff_set_caption();
+end;
+
+end.
diff --git a/uft_robot/src/s_lib_pas_unit.dcu b/uft_robot/src/s_lib_pas_unit.dcu
new file mode 100644
index 00000000..c8fbd27b
Binary files /dev/null and b/uft_robot/src/s_lib_pas_unit.dcu differ
diff --git a/uft_robot/src/s_lib_pas_unit.pas b/uft_robot/src/s_lib_pas_unit.pas
new file mode 100644
index 00000000..9739c342
--- /dev/null
+++ b/uft_robot/src/s_lib_pas_unit.pas
@@ -0,0 +1,146 @@
+unit s_lib_pas_unit;
+
+interface
+uses Windows;
+
+const
+ m_error_log =0;
+ m_info_log =1;
+
+
+ m_dead_lock_exit =118;
+ m_exit_be_killed =119;
+ m_error_exit =117;
+ m_exit =0;
+ FFdll = 'flyingfish.dll';
+ FF_NTSRTS_DLL = 'ff_ntsrts.dll';
+
+var
+ m_module_name :array[0..255] of Char;
+
+
+
+function W_Log(
+ pc_module :PChar;
+ i_lineno :Integer;
+ int :Integer;
+ pc_log :PChar
+ ):Integer;cdecl;
+external 'flyingfish.dll' name 'W_Log';
+
+
+function GetKeyValue(
+ inifilename :PChar;
+ section :PChar;
+ key :PChar;
+ datatype :PChar;
+ {
+ /* c for null end char */
+ /* s for short */
+ /* i for int */
+ /* l for long */
+ /* f for float */
+ /* d for double */
+ }
+ value :PChar
+ ):Integer;cdecl;
+external 'flyingfish.dll' name 'GetKeyValue';
+
+function WriteIni(
+ c_filename :PChar;
+ c_section :PChar;
+ c_key :PChar;
+ c_value :PChar
+ ):Integer;cdecl;
+external 'flyingfish.dll' name 'WriteIni';
+
+
+procedure s_sleep_us(l_us:Integer);cdecl;
+external 'flyingfish.dll' name 's_sleep_us';
+
+function FF_exit(i_exit:Integer):Integer;cdecl;
+external 'flyingfish.dll' name 'FF_exit';
+
+function FF_RtsMain(
+ p_cert_passwd :PChar
+ ):Integer;cdecl;
+external FF_NTSRTS_DLL name 'FF_RtsMain';
+
+function FF_NtsMain(
+ p_cert_passwd :PChar
+ ):Integer;cdecl;
+external FF_NTSRTS_DLL name 'FF_NtsMain';
+
+function FF_webMain(
+ p_cert_passwd :PChar
+ ):Integer;cdecl;
+external FF_NTSRTS_DLL name 'FF_webMain';
+
+function FF_CAMain(
+ p_cert_passwd :PChar
+ ):Integer;cdecl;
+external FF_NTSRTS_DLL name 'FF_CAMain';
+
+function FF_init(
+ p_cert_passwd :PChar
+ ):Integer;cdecl;
+external 'flyingfish.dll' name 'FF_init';
+
+
+function FF_get_thdinfo1(
+ p_v :Pointer
+ ):Integer;cdecl;
+external 'flyingfish.dll' name 'FF_get_thdinfo';
+
+function FF_get_thdinfo(
+ p_v :Pointer;pv_size:Integer
+ ):Integer;cdecl;
+external 'flyingfish.dll' name 'FF_get_thdinfo1';
+
+function CurDate(
+ buf :PChar
+ ):PChar;cdecl;
+external 'flyingfish.dll' name 'CurDate';
+function CurTime(
+ buf :PChar
+ ):PChar;cdecl;
+external 'flyingfish.dll' name 'CurTime';
+
+function FF_W_Info1(
+ pc_file_name:PChar;
+ pc_info:PChar;
+ i_flag:Integer
+ ):PChar;cdecl;
+external 'flyingfish.dll' name 'FF_W_Info1';
+
+//int FF_cert_key_passwd(char *p_keyfile,char *p_oldpass,char *p_newpass)
+function FF_cert_key_passwd(
+ p_key_file :PChar;
+ p_oldpass:PChar;
+ p_newpass:PChar
+ ):Integer;cdecl;
+external 'flyingfish.dll' name 'FF_cert_key_passwd';
+//char *FF_ffconf(char *c_filename,char *c_section,char *c_name)
+function FF_ffconf(
+c_filename:PChar;
+c_section:PChar;
+c_name:PChar
+):PChar;cdecl;
+external 'flyingfish.dll' name 'FF_ffconf';
+
+function FF_load_allconf():PChar;cdecl;
+external 'flyingfish.dll' name 'FF_load_allconf';
+
+
+//int FF_key_passwd_check(char *p_keyfile,char *p_passwd)
+function FF_key_passwd_check(
+ p_keyfile :PChar;
+ p_passwd:PChar
+ ):Integer;cdecl;
+external FFdll name 'FF_key_passwd_check';
+
+
+
+implementation
+
+end.
diff --git a/uft_robot/src/sh600328.day b/uft_robot/src/sh600328.day
new file mode 100644
index 00000000..e69de29b
diff --git a/uft_robot/src/uFutuDataTypes.dcu b/uft_robot/src/uFutuDataTypes.dcu
new file mode 100644
index 00000000..e859133f
Binary files /dev/null and b/uft_robot/src/uFutuDataTypes.dcu differ
diff --git a/uft_robot/src/uFutuDataTypes.pas b/uft_robot/src/uFutuDataTypes.pas
new file mode 100644
index 00000000..4af83d95
--- /dev/null
+++ b/uft_robot/src/uFutuDataTypes.pas
@@ -0,0 +1,286 @@
+{/**********************************************************************
+* Ô´³ÌÐòÃû³Æ: futu_data_types.h
+* Èí¼þÖø×÷Ȩ: ºãÉúµç×ӹɷÝÓÐÏÞ¹«Ë¾
+* ϵͳÃû³Æ : 06°æ±¾ÆÚ»õϵͳ
+* Ä£¿éÃû³Æ : ºãÉúÆÚ»õÖܱ߽ӿÚ
+* ¹¦ÄÜ˵Ã÷ : Öܱ߽ӿڳ£ÓÃÊý¾ÝÀàÐͶ¨Òå
+* ×÷ Õß : xdx
+* ¿ª·¢ÈÕÆÚ : 20110315
+* ±¸ ×¢ : Êý¾ÝÀàÐͶ¨Òå
+* ÐÞ¸ÄÈËÔ± £º
+* ÐÞ¸ÄÈÕÆÚ £º
+* ÐÞ¸Ä˵Ã÷ £º20110315 ´´½¨
+20110701 luyj Ð޸ĵ¥ºÅ20110603001 °æ±¾Ôö¼Óµ½V1.0.0.1
+20110802 luyj Ð޸ĵ¥ºÅ20110802006 °æ±¾Ôö¼Óµ½V1.0.0.2
+20110809 luyj Ð޸ĵ¥ºÅ20110808022 °æ±¾Ôö¼Óµ½V1.0.0.3
+20110824 luyj Ð޸ĵ¥ºÅ20110819035 °æ±¾Ôö¼Óµ½V1.0.0.4
+20110913 luyj Ð޸ĵ¥ºÅ20110913002 °æ±¾Ôö¼Óµ½V1.0.0.5
+20111026 luyj Ð޸ĵ¥ºÅ20111026001 °æ±¾Ôö¼Óµ½V1.0.0.6
+20111027 luyj Ð޸ĵ¥ºÅ20111103023 °æ±¾Ôö¼Óµ½V1.0.0.7
+20111027 luyj Ð޸ĵ¥ºÅ20111124003 °æ±¾Ôö¼Óµ½V1.0.0.8
+20120207 luyj Ð޸ĵ¥ºÅ20120207003 °æ±¾Ôö¼Óµ½V1.0.0.9
+20120216 tangui Ð޸ĵ¥ºÅ20120214036 °æ±¾Ôö¼Óµ½V1.0.0.10
+20120216 tangui Ð޸ĵ¥ºÅ20120214036 °æ±¾Ôö¼Óµ½V1.0.0.11
+20120504 tangui Ð޸ĵ¥ºÅ20120412046 °æ±¾Ôö¼Óµ½V1.0.0.12
+20120512 tangui Ð޸ĵ¥ºÅ20120509021 °æ±¾Ôö¼Óµ½V1.0.0.13
+20120720 tanghui Ð޸ĵ¥ºÅ20120515030 °æ±¾Ôö¼Óµ½V1.0.0.14
+**********************************************************************/}
+unit uFutuDataTypes;
+
+interface
+
+const
+ //¶¨Òå°æ±¾ÐÅÏ¢
+ HSFUSDK_VERSION = $10000014;
+ HSFUSDK_VERSTRING = 'V1.0.0.14';
+
+ //¶¨ÒåÁ¬½Ó·þÎñÀàÐÍ
+ SERVICE_TYPE_TRADE = 1;//½»Ò×·þÎñ
+ SERVICE_TYPE_QUOTE = 2;//ÐÐÇé»Ø±¨·þÎñ
+
+ //¶¨ÒåÏûÏ¢ÀàÐÍ
+ MSG_TYPE_UNKNOWN = -1; //δ֪ÏûÏ¢ÀàÐÍ
+
+ MSG_TYPE_USER_LOGIN = 100; //Óû§µÇ¼
+ MSG_TYPE_USER_LOGOUT = 101; //UFT¿Í»§×¢Ïú
+ MSG_TYPE_CONFIRM_BILL = 102;//¿Í»§È·ÈÏÕ˵¥
+ MSG_TYPE_CHECK_CONTRACT_CODE = 103;//¼ì²éºÏÔ¼´úÂë(µ¥ÍÈ)
+ MSG_TYPE_CHECK_ENTRUST_PRICE = 104;//¼ì²éίÍм۸ñ
+ MSG_TYPE_NEW_SINGLE_ORDER = 105;//ίÍÐϵ¥
+ MSG_TYPE_CANCEL_ORDER = 106;//ίÍг·µ¥
+ MSG_TYPE_BANK_TRANSFER = 107;//ÒøÆÚתÕË
+ MSG_TYPE_MODIFY_PASSWORD = 108;//¿Í»§ÐÞ¸ÄÃÜÂë
+
+ //20110822 luyj Ôö¼Ó×éºÏίÍÐ Ð޸ĵ¥ºÅ:20110819035
+ MSG_TYPE_CHECK_COMBIN_CODE = 109;//¼ì²é×éºÏºÏÔ¼´úÂë
+ MSG_TYPE_NEW_COMBIN_ORDER = 110;//×éºÏίÍÐÈ·ÈÏ
+ //20110822 end
+
+ MSG_TYPE_GET_TRADING_CODE = 200;//½»Ò×±àÂë²éѯ
+ MSG_TYPE_GET_PROFIT = 201;//ÆÚ»õ¿Í»§×ʽðȨÒæ²éѯ
+ MSG_TYPE_GET_HOLDSINFO = 202;//³Ö²Ö²éѯ
+ MSG_TYPE_GET_ENTRUST_ORDERS = 203;//ίÍвéѯ
+ MSG_TYPE_GET_TRANS_DETAIL = 204;//³É½»Ã÷ϸ²éѯ
+ MSG_TYPE_GET_FUNDJOUR = 205;//ÀúÊ·×ʽðÁ÷Ë®²éѯ
+ MSG_TYPE_GET_FUND_HISTRANSJOUR = 206;//²éÀúʷתÕËÁ÷Ë®
+ MSG_TYPE_GET_BANK_ACCOUNT = 207;//ÒøÐÐÕ˺Ųéѯ
+ MSG_TYPE_GET_BANK_TRANSJOUR = 208;//ÒøÆÚתÕËÁ÷Ë®²éѯ
+ MSG_TYPE_GET_BANKBALA = 209;//ÒøÐÐÕË»§Óà¶î²éѯ
+ MSG_TYPE_GET_MARKET_DATA = 210;//ÆÚ»õÐÐÇé²éѯ
+ MSG_TYPE_GET_MARGIN = 211;//ºÏÔ¼±£Ö¤½ð²éѯ
+ MSG_TYPE_GET_FUTU_BANKINFO = 212;//ÆÚ»õµÇ¼ÇÒøÐÐÐÅÏ¢²éѯ
+ MSG_TYPE_GET_EXCH_TIME = 213;//½»Ò×Ëùʱ¼ä²î²éѯ
+ MSG_TYPE_GET_FMMC_PWD = 214;//¼à¿ØÖÐÐĽáË㵥ϵͳÃÜÂë²éѯ
+ MSG_TYPE_GET_BILL = 215;//½áËãµ¥²éѯ
+ MSG_TYPE_GET_HIS_ENTRUST = 216;//ÀúʷίÍвéѯ
+ MSG_TYPE_GET_HIS_BUSINESS = 217;//ÀúÊ·³É½»²éѯ
+ MSG_TYPE_GET_HIS_FUND = 218;//ÀúÊ·×ʽð²éѯ
+ MSG_TYPE_UFT_ORDERHSACK = 219;//ίÍз´À¡
+ MSG_TYPE_UFT_ORDEREXACK = 220;//³É½»·´À¡
+
+ //20110822 luyj Ôö¼Ó×éºÏίÍÐÏà¹Ø²éѯ(06) Ð޸ĵ¥ºÅ:20110819035
+ MSG_TYPE_GET_COMBIN_CODE = 221; //²éѯ×éºÏ´úÂë
+ MSG_TYPE_GET_COMBIN_QUOTE = 222; //²éѯ×éºÏÐÐÇé
+ MSG_TYPE_CHECK_PWD = 223; //УÑéÃÜÂë
+ //20110822 end
+
+ //20120426 tanghui Ôö¼Óµ¥¿Í»§²é·ÑÓÃÊôÐԺͱ£Ö¤½ðÊôÐÔ Ð޸ĵ¥:20120412046
+ MSG_TYPE_GET_FEE_PROPERTY = 224; //UFT¿Í»§²éѯ·ÑÓÃÊôÐÔ
+ MSG_TYPE_GET_MARGIN_PROPERTY = 225; //UFT¿Í»§²éѯ±£Ö¤½ðÊôÐÔ
+
+type
+ //¶¨ÒåIntegerÖ¸Õë
+ PInteger = ^Integer;
+ //¶©ÔÄÀàÐÍ
+ REGType =
+ (
+ UnKnownType = -1, // δ֪ÀàÐÍ
+ SingleCode = 0, // µ¥ÍÈÐÐÇé
+ RspReport = 1, // ίÍлر¨
+ CombinCode = 2, // ×éºÏÐÐÇé
+ OnlineMsg = 3 // ÔÚÏßÏûÏ¢
+ );
+
+ //¶©ÔĶ¯×÷
+ REGAction =
+ (
+ UnKnownAction = -1, // δ֪¶¯×÷
+ Subscription = 0, // ¶©ÔÄË¢ÐÂ(Ö÷ÒªÖ¸ÐÐÇé)»òÕßָʾ²»ÊÇÍ˶©
+ CxlAll = 1, // È¡ÏûÈ«²¿µÄ¶©ÔÄ
+ CxlFlag = 2, // ¸ù¾ÝÖƶ¨ÀàÐͶ©ÔÄ
+ Snapshot = 3 // ²éѯ¿ìÕÕ(Ö÷ÒªÖ¸ÐÐÇé)
+ );
+
+ //Á¬½ÓµÄ״̬
+ CONState =
+ (
+ Uninitialized = -1, // Á¬½Óδ³õʼ»¯
+ Disconnected = $0000, // δÁ¬½Ó
+ Connecting = $0001, // socketÕýÔÚÁ¬½Ó
+ Connected = $0002, // socketÒÑÁ¬½Ó
+ SafeConnecting = $0004, // ÕýÔÚ½¨Á¢°²È«Á¬½Ó
+ SafeConnected = $0008, // Òѽ¨Á¢°²È«Á¬½Ó
+ Registering = $0010, // Õý×¢²á
+ Registered = $0020, // ÒÑ×¢²á
+ Rejected = $0040// ±»¾Ü¾ø,½«±»¹Ø±Õ
+ );
+
+ //¶¨ÒåÏûϢģʽ(FUTU_MSG_MODE¶¨Òå)
+ FUTU_MSG_MODE =
+ (
+ MSG_MODE_UNKNOWN = -1, //δ֪ÏûϢģʽ
+ MSG_MODE_REQUEST = 0, //±íʾÊÇÇëÇóÏûÏ¢
+ MSG_MODE_ANSWER = 1 //±íʾÊÇÓ¦´ðÏûÏ¢
+ );
+
+ //Ϊ¼æÈÝÐÔͳһÒÔ4×Ö½Ú¶ÔÆë,·ñÔòÓÐÊý¾Ý¶ÔÆëµÄÎÊÌâ
+ {$A4}
+ // µ¥ÍÈÐÐÇé
+ LPCMarketInfo = ^CMarketInfo;
+ CMarketInfo = record
+ contract_code: array[0..12] of Char; //0 ºÏÔ¼´úÂë,
+ pre_square_price: Double; //1 ×òÈÕ½»¸î½áËã¼Û
+ futu_open_price: Double; //2 ¿ªÅ̼Û
+ futu_last_price: Double; //3 ×îм۸ñ
+ buy_high_price: Double; //4 ×î¸ßÂòÈë¼Û
+ buy_high_amount: Integer; //5 ×î¸ßÂòÈë¼ÛÂòÁ¿
+ buy_total_amount: Integer; //6 È«²¿ÂòÁ¿
+ sale_low_price: Double; //7 ×îµÍÂô¼Û¼Û¸ñ
+ sale_low_amount: Integer; //8 ×îµÍÂô¼ÛÂôÁ¿
+ sale_total_amount: Integer; //9 È«²¿ÂôÁ¿
+ futu_high_price: Double; //10 ×î¸ß¼Û
+ futu_low_price: Double; //11 ×îµÍ¼Û
+ average_price: Double; //12 ¾ù¼Û
+ change_direction: Double; //13 Ç÷ÊÆ
+ business_amount: Integer; //14 ³É½»Á¿
+ bear_amount: Integer; //15 ×ܳÖÁ¿
+ business_balance: Double; //16 ³É½»¶î
+ uplimited_price: Double; //17 ÕÇÍ£°å
+ downlimited_price: Double; //18 µøÍ£°å
+ futu_exch_type: array[0..2] of Char; //19 ½»Ò×Àà±ð
+ form_buy_price: Double; //20 ×éºÏÂòÈë¼Û¸ñ
+ form_sale_price: Double; //21 ×éºÏÂô³ö¼Û¸ñ
+ form_buy_amount: Integer; //22 ×éºÏÂòÈëÊýÁ¿
+ form_sale_amount: Integer; //23 ×éºÏÂô³öÊýÁ¿
+ pre_close_price: Double; //24 ×òÈÕÊÕÅ̼Û
+ pre_open_interest: Double; //25 ×òÈÕ¿ÕÅÌÁ¿
+ futu_close_price: Double; //26 ½ñÈÕÊÕÅ̼Û
+ square_price: Double; //27 ½áËã¼Û
+ pre_delta: Double; //28 ×òÈÕÐéʵ¶È
+ curr_delta: Double; //29 ½ñÈÕÐéʵ¶È
+ bid_price2: Double; //30 Âò¶þ¼Û
+ bid_volume2: Integer; //31 Âò¶þÁ¿
+ bid_price3: Double; //32 ÂòÈý¼Û
+ bid_volume3: Integer; //33 ÂòÈýÁ¿
+ bid_price4: Double; //34 ÂòËļÛ
+ bid_volume4: Integer; //35 ÂòËÄÁ¿
+ bid_price5: Double; //36 ÂòÎå¼Û
+ bid_volume5: Integer; //37 ÂòÎåÁ¿
+ ask_price2: Double; //38 Âô¶þ¼Û
+ ask_volume2: Integer; //39 Âô¶þÁ¿
+ ask_price3: Double; //40 ÂôÈý¼Û
+ ask_volume3: Integer; //41 ÂôÈýÁ¿
+ ask_price4: Double; //42 ÂôËļÛ
+ ask_volume4: Integer; //43 ÂôËÄÁ¿
+ ask_price5: Double; //44 ÂôÎå¼Û
+ ask_volume5: Integer; //45 ÂôÎåÁ¿
+ end;
+
+ // ×éºÏÐÐÇé
+ LPCArgMarketInfo = ^CArgMarketInfo;
+ CArgMarketInfo = record
+ arbicontract_id: array[0..30] of Char; //0 Ì×ÀûºÏÔ¼ºÅ
+ futu_exch_type: array[0..2] of Char; //1 ½»Ò×Àà±ð
+ first_code: array[0..12] of Char; //2 µÚÒ»ÍÈ
+ second_code: array[0..12] of Char; //3 µÚ¶þÍÈ
+ arbi_type: Char; //4 ×éºÏÀàÐÍ1-SPD, 2 -IPS
+ buy_price: Double; //5 ×î¸ßÂòÈë¼Û
+ buy_amount: Integer; //6 ×î¸ßÂòÈë¼ÛÂòÁ¿
+ buy_total_amount: Integer; //7 È«²¿ÂòÁ¿
+ sale_price: Double; //8 ×îµÍÂô¼Û¼Û¸ñ
+ sale_amount: Integer; //9 ×îµÍÂô¼ÛÂôÁ¿
+ sale_total_amount: Integer; //10 È«²¿ÂôÁ¿
+ futu_high_price: Double; //11 ×î¸ß¼Û
+ futu_low_price: Double; //12 ×îµÍ¼Û
+ uplimited_price: Double; //13 ÕÇÍ£°å¼Û¸ñ
+ downlimited_price: Double; //14 µøÍ£°å¼Û¸ñ
+ end;
+
+ //ίÍз´À¡ÐÅÏ¢
+ LPCOrderRspInfo = ^COrderRspInfo;
+ COrderRspInfo = record
+ entrust_no: Integer; //0 ίÍкÅ
+ futures_account: array[0..20] of Char; //1 ½»Ò×±àÂë
+ futu_exch_type: array[0..10] of Char; //2 ½»Ò×ËùÀà±ð
+ contract_code: array[0..12] of Char; //3 ºÏÔ¼´úÂë
+ entrust_bs: array[0..8] of Char; //4 ÂòÂô±êʶ
+ entrust_direction: array[0..8] of Char;//6 ¿ªÆ½±êʶ
+ hedge_type: array[0..8] of Char; //7 Ì×±£±êʶ
+ fund_account: Integer; //8 ×ʽðÕË»§
+ futu_report_no: array[0..20] of Char; //9 ±¾µØµ¥ºÅ
+ firm_no: array[0..8] of Char; //10 »áÔ±ºÅ
+ operator_no: array[0..8] of Char; //11 ²Ù×÷Ô±ºÅ
+ client_group: Integer; //12 ¿Í»§Àà±ð
+ entrust_amount: Integer; //13 ίÍÐÊýÁ¿
+ business_total_amount: Integer; //14 ³É½»×ÜÊýÁ¿
+ cacel_amount: Integer; //15 ³·µ¥ÊýÁ¿
+ entrust_price: Double; //16 ίÍм۸ñ
+ entrust_status: Char; //17 ίÍÐ״̬
+ branch_no: Integer; //18 ÓªÒµ²¿ºÅ
+ batch_no: Integer; //19 ίÍÐÅúºÅ
+ futu_entrust_type: Char; //20 ίÍÐÀàÐÍ
+ amount_per_hand: Integer; //21 ºÏÔ¼³ÆÊý
+ forceclose_reason: Char; //22 ǿƽÔÒò
+ init_date : Integer; //23 ½»Ò×ÈÕÆÚ
+ curr_time :Integer; //24 µ±Ç°Ê±¼ä
+ confirm_no : array[0..20] of Char; //25 Ö÷³¡µ¥ºÅ
+ weave_type : Integer; //26 ×éºÏίÍÐÀàÐÍ
+ arbitrage_code : array[0..20] of Char; //27 ×éºÏίÍÐÀàÐÍ
+ time_condition : Integer; //28 ÓÐЧÆÚÀàÐÍ
+ volume_condition : Integer; //29 ³É½»Á¿ÀàÐÍ
+ futu_entrust_prop : Integer; //30 ÆÚ»õίÍÐÊôÐÔ
+ frozen_fare : Double; //31 ¶³½á×Ü·ÑÓÃ
+ //20120428 tanghui ίÍз´À¡ºÍ³É½»·´À¡Ôö¼Ó´íÎóÐÅÏ¢×ֶΠÐ޸ĵ¥:20120412049
+ error_message : array[0..254] of Char; //32 ´íÎóÐÅÏ¢
+ end;
+
+ //³É½»·´À¡ÐÅÏ¢
+ LPCRealRspInfo = ^CRealRspInfo;
+ CRealRspInfo = record
+ entrust_no: Integer; //0 ίÍкÅ
+ futures_account: array[0..20] of Char; //1 ½»Ò×±àÂë
+ futu_exch_type: array[0..10] of Char; //2 ½»Ò×ËùÀà±ð
+ business_no: array[0..20] of Char; //3 ³É½»±àºÅ
+ contract_code: array[0..12] of Char; //4 ºÏÔ¼´úÂë
+ entrust_bs: array[0..8] of Char; //5 ÂòÂô±êʶ
+ entrust_direction: array[0..8] of Char;//6 ¿ªÆ½±êʶ
+ business_price: Double; //7 ³É½»¼Û¸ñ
+ business_amount: Double; //8 ³É½»ÊýÁ¿
+ hedge_type: array[0..8] of Char; //9 Ì×±£±êʶ
+ fund_account: Integer; //10 ×ʽðÕË»§
+ futu_report_no: array[0..20] of Char; //11 ±¾µØµ¥ºÅ
+ firm_no: array[0..8] of Char; //12 »áÔ±ºÅ
+ operator_no: array[0..8] of Char; //13 ²Ù×÷Ô±ºÅ
+ client_group: Integer; //14 ¿Í»§Àà±ð
+ entrust_amount: Integer; //15 ίÍÐÊýÁ¿
+ business_total_amount: Integer; //16 ³É½»×ÜÊýÁ¿
+ cacel_amount: Integer; //17 ³·µ¥ÊýÁ¿
+ entrust_price: Double; //18 ίÍм۸ñ
+ entrust_status: Char; //19 ίÍÐ״̬
+ branch_no: Integer; //20 ÓªÒµ²¿ºÅ
+ batch_no: Integer; //21 ίÍÐÅúºÅ
+ futu_entrust_type: Char; //22 ίÍÐÀàÐÍ
+ amount_per_hand: Integer; //23 ºÏÔ¼³ÆÊý
+ forceclose_reason: Char; //24 ǿƽÔÒò
+ init_date : Integer; //25 ½»Ò×ÈÕÆÚ
+ business_time :Integer; //26 ³É½»Ê±¼ä
+ confirm_no : array[0..20] of Char; //27 Ö÷³¡µ¥ºÅ
+ frozen_fare : Double; //28 ¶³½á×Ü·ÑÓÃ
+ //20120428 tanghui ίÍз´À¡ºÍ³É½»·´À¡Ôö¼Ó´íÎóÐÅÏ¢×ֶΠÐ޸ĵ¥:20120412049
+ error_message : array[0..254] of Char; //29 ´íÎóÐÅÏ¢
+ end;
+{$A8}
+implementation
+
+end.
+
diff --git a/uft_robot/src/uFutuMessageInterface.dcu b/uft_robot/src/uFutuMessageInterface.dcu
new file mode 100644
index 00000000..cac70522
Binary files /dev/null and b/uft_robot/src/uFutuMessageInterface.dcu differ
diff --git a/uft_robot/src/uFutuMessageInterface.pas b/uft_robot/src/uFutuMessageInterface.pas
new file mode 100644
index 00000000..f20f64c5
--- /dev/null
+++ b/uft_robot/src/uFutuMessageInterface.pas
@@ -0,0 +1,253 @@
+{/**********************************************************************
+* Ô´³ÌÐòÃû³Æ: futu_message_interface.h
+* Èí¼þÖø×÷Ȩ: ºãÉúµç×ӹɷÝÓÐÏÞ¹«Ë¾
+* ϵͳÃû³Æ : 06°æ±¾ÆÚ»õϵͳ
+* Ä£¿éÃû³Æ : ºãÉúÆÚ»õÖܱ߽ӿÚ
+* ¹¦ÄÜ˵Ã÷ : Öܱ߽ӿÚÊý¾Ý²Ù×÷¶¨Òå
+* ×÷ Õß : xdx
+* ¿ª·¢ÈÕÆÚ : 20110315
+* ±¸ ×¢ : Êý¾ÝÀàÐͶ¨Òå
+* ÐÞ¸ÄÈËÔ± £º
+* ÐÞ¸ÄÈÕÆÚ £º
+* ÐÞ¸Ä˵Ã÷ £º20110315 ´´½¨
+**********************************************************************/}
+
+unit uFutuMessageInterface;
+
+interface
+
+uses
+ Classes;
+
+type
+
+//¸÷Àà½Ó¿ÚͳһµÄ²éѯÓëÒýÓÃ½Ó¿Ú (²ÎÕÕCOM±ê×¼)
+IHSKnown = class
+public
+ {/**
+ * ²éѯÓ뵱ǰ½Ó¿ÚÏà¹ØµÄÆäËû½Ó¿Ú(±¾½Ó¿ÚÖÐÒ»°ã²»Ê¹ÓÃ)
+ *@param HS_SID iid ½Ó¿ÚÈ«¾ÖΨһ±êʶ
+ *@param IKnown **ppv ·µ»Øiid¶ÔÓ¦µÄ½Ó¿ÚÖ¸Õë
+ *@return R_OK ³É¹¦£¬R_FAIL δ²éµ½iid ÏàÓ¦½Ó¿Ú
+ */}
+ function QueryInterface( const iid:PChar;ppv:Pointer ):Integer;virtual;stdcall;abstract;
+
+ {/**
+ * ÒýÓýӿڣ¬ÒýÓüÆÊý¼ÓÒ»
+ *@return µ±Ç°ÒýÓüÆÊý
+ */}
+ function AddRef():Integer;virtual;stdcall;abstract;
+
+ {/**
+ * ÊͷŽӿڣ¬ÒýÓüÆÊý¼õÒ»£¬¼ÆÊýΪ0ʱÊͷŽӿڵÄʵÏÖ¶ÔÏó
+ *@param R_OK±íʾ³É¹¦,ÆäËû±íʾʧ°Ü
+ */}
+ function Release():Integer;virtual;stdcall;abstract;
+end;
+
+
+{/*
+ Ò»ÌõÏûÏ¢Êý¾Ý¼Ç¼,°üº¬Á˺ܶàµÄtag=value,ÆäÖÐtag²»Öظ´
+ Öظ´²åÈëÏàͬµÄtag,Ôò¸²¸ÇÉϴεÄÊý¾Ý
+ ΪÁËʹ½Ó¿Ú¿çÓïÑÔ,½öÖ§³ÖÒÔÏÂÊý¾ÝÀàÐÍ:
+ µ¥×Ö·ûÐÍ(char),Èç'A','1',
+ ÕûÐÍ(int),Èç123,-2343
+ ¸¡µãÐÍ(float),Èç23.50,-34.34
+ ×Ö·û´®ÐÍ(CÓïÑÔ·ç¸ñ'\0'½áβµÄ´®)(char*),Èç"Hello World"
+ ×¢ÒâÆä½Ó¿Ú·½·¨Ḭ̈߳²È«ÐÔ
+*/}
+IFuRecord = class(IHSKnown)
+public
+ ///Ìí¼ÓÊý¾ÝµÄ·½·¨,Èô´æÔÚfieldÔò¸²¸ÇÆäÖµ
+ {/**
+ * Ìí¼ÓÒ»¸ö×Ö·ûÐÍÖµ
+ *@param sField ×Ö¶ÎÃû³Æ
+ *@param cValue Ò»¸ö×Ö·ûÖµ
+ *@return R_OKÌí¼Ó³É¹¦,ÆäËû±íʾʧ°Ü
+ [·ÇḬ̈߳²È«]
+ */}
+ function SetChar(const sField:PChar;cValue:Char):Integer;virtual;stdcall;abstract;
+
+ {/**
+ * Ìí¼ÓÒ»¸öÕûÐÍÖµ
+ *@param sField ×Ö¶ÎÃû³Æ
+ *@param iValue Ò»¸öÕûÐÍÖµ
+ *@return R_OKÌí¼Ó³É¹¦,ÆäËû±íʾʧ°Ü
+ [·ÇḬ̈߳²È«]
+ */}
+ function SetInt(const sField:PChar;iValue:Integer):Integer;virtual;stdcall;abstract;
+
+ {/**
+ * Ìí¼ÓÒ»¸ö¸¡µãÖµ
+ *@param sField ×Ö¶ÎÃû³Æ
+ *@param cValue Ò»¸ö¸¡µãÖµ
+ *@return R_OKÌí¼Ó³É¹¦,ÆäËû±íʾʧ°Ü
+ [·ÇḬ̈߳²È«]
+ */}
+ function SetDouble(const sField:PChar;dValue:Double):Integer;virtual;stdcall;abstract;
+
+ {/**
+ * Ìí¼ÓÒ»¸ö×Ö·û´®(CÓïÑÔ¸ñʽ'\0'½áβµÄ×Ö·û´®)
+ *@param sField ×Ö¶ÎÃû³Æ
+ *@param cValue Ò»¸ö×Ö·û´®Öµ
+ *@return R_OKÌí¼Ó³É¹¦,ÆäËû±íʾʧ°Ü
+ [·ÇḬ̈߳²È«]
+ */}
+ function SetString(const sField:PChar;const strValue:PChar):Integer;virtual;stdcall;abstract;
+
+ ///¸ù¾Ý×ֶηÃÎÊÊý¾ÝµÄ·½·¨
+
+ {/**
+ * »ñÈ¡Ò»¸ö×Ö·ûÐÍÖµ
+ *@param sField ×Ö¶ÎÃû³Æ
+ *@return ÓÐЧ×Ö·ûÖµ;×ֶβ»´æÔÚÔòĬÈÏ'\0'
+ [Ḭ̈߳²È«]
+ */}
+ function GetChar(const sField:PChar):Char;virtual;stdcall;abstract;
+
+ {/**
+ * »ñÈ¡Ò»¸öÕûÐÍÖµ
+ *@param sField ×Ö¶ÎÃû³Æ
+ *@return ·µ»ØÒ»¸öÕûÐÍÖµ;×ֶβ»´æÔÚÔòĬÈÏ·µ»Ø0
+ [Ḭ̈߳²È«]
+ */}
+ function GetInt(const sField:PChar):Integer;virtual;stdcall;abstract;
+
+ {/**
+ * »ñµÃÒ»¸ö¸¡µãÖµ
+ *@param sField ×Ö¶ÎÃû³Æ
+ *@return ·µ»ØÒ»¸öÕûÐÍÖµ;×ֶβ»´æÔÚÔòĬÈÏ·µ»Ø0.0(×¢Ò⸡µãÐ͵ľ«¶ÈÎÊÌâ)
+ [Ḭ̈߳²È«]
+ */}
+ function GetDouble(const sField:PChar):Double;virtual;stdcall;abstract;
+
+ {/**
+ * »ñµÃÒ»¸ö×Ö·û´®
+ *@param sField ×Ö¶ÎÃû³Æ
+ *@return ·µ»ØÒ»¸ö×Ö·û´®,Èç²»´æÔÚ¸Ã×Ö¶ÎÔò·µ»ØNULL(0)
+ [Ḭ̈߳²È«]
+ */}
+ function GetString(const sField:Pchar):PChar;virtual;stdcall;abstract;
+
+ ///±éÀú·ÃÎÊ·½·¨,ͨ¹ý´Ë·ÃÎʿɱéÀúÕû¸öÌõ¼Ç¼
+ {/**
+ * Òƶ¯µ½¼Ç¼ͷ(µÚÒ»¸ötag=value)
+ *@return R_OK±íʾ³É¹¦,ÆäËû±íʾʧ°Ü
+ [·ÇḬ̈߳²È«]
+ */}
+ function MoveFirst():Integer;virtual;stdcall;abstract;
+
+ {/**
+ * ÏÂÒ»Ìõ¼Ç¼
+ *@return R_OK±íʾ³É¹¦,ÆäËû±íʾʧ°Ü»òÒѾµ½¼Ç¼β
+ [·ÇḬ̈߳²È«]
+ */}
+ function MoveNext():Integer;virtual;stdcall;abstract;
+
+ {/**
+ * ÅжÏÊÇ·ñÒƵ½Á˼Ǽβ
+ *@return 0±íʾδµ½¼Ç¼β,1±íʾÒѵ½¼Ç¼β
+ [·ÇḬ̈߳²È«]
+ */}
+ function IsEOF():Integer;virtual;stdcall;abstract;
+
+ {/**
+ * »ñÈ¡µ±Ç°×Ö¶ÎÃû(ͨ¹ý¸ÃÃû¿ÉÒÔ·ÃÎʵ½Öµ)
+ *@return NULL±íʾÒѵ½½áβ»òÎÞÊý¾Ý,·ÇNULL±íʾ×Ö¶ÎÃû
+ [Ḭ̈߳²È«]
+ */}
+ function GetFieldName():PChar;virtual;stdcall;abstract;
+
+ {/**
+ * ɾ³ýÒ»¸ö×Ö¶Î
+ *@param sField Ҫɾ³ýµÄ×Ö¶ÎÃû
+ *@return R_OK±íʾɾ³ý³É¹¦,ÆäËû±íʾʧ°Ü
+ [·ÇḬ̈߳²È«]
+ */}
+ function RemoveField(const sField:PChar):Integer;virtual;stdcall;abstract;
+
+ {/**
+ * ÊÇ·ñ´æÔÚijºÍ×Ö¶Î
+ *@param sField ×Ö¶ÎÃû
+ *@return 0±íʾ²»´æÔÚ,1±íʾ´æÔÚ
+ [·ÇḬ̈߳²È«]
+ */}
+ function IsExist(const sField:PChar):Integer;virtual;stdcall;abstract;
+
+ {/**
+ * ɾ³ýËùÓеÄ×Ö¶Î
+ *@return R_OK±íʾ³É¹¦,ÆäËû±íʾʧ°Ü
+ [·ÇḬ̈߳²È«]
+ */}
+ function Clear():Integer;virtual;stdcall;abstract;
+
+ {/**
+ * »ñÈ¡¼Ç¼¸öÊý(Field=Value)
+ *@return ±íʾ¼Ç¼µÄÌõÊý
+ [Ḭ̈߳²È«]
+ */}
+ function GetCount():Integer;virtual;stdcall;abstract;
+end;
+
+
+///ÆÚ»õÏûÏ¢½Ó¿Ú,Ò»ÌõÏûÏ¢±íÃ÷ÁËÆäÏûÏ¢µÄÀàÐÍ,²¢ÓÉÒ»¸ö»ò¶àÕâ¸öIFuRecord×é³É
+IFuMessage = class(IHSKnown)
+public
+ {/**
+ * ÉèÖÃÏûÏ¢ÀàÐÍ
+ *@param iType ²Î¼ûFUTU_MSG_TYPEµÄ¶¨Òå
+ *@param iMode ±íʾ´ËÏûÏ¢ÊÇÇëÇó»¹ÊÇÓ¦´ð,0-ÇëÇó,1-Ó¦´ð
+ *@return R_OK±íʾ³É¹¦,ÆäËû±íʾÎÞЧ»ò²»Ö§³ÖµÄÏûÏ¢ÀàÐÍ
+ [·ÇḬ̈߳²È«]
+ */}
+ function SetMsgType(iType:Integer;iMode:Integer):Integer;virtual;stdcall;abstract;
+
+ {/**
+ * »ñÈ¡ÏûÏ¢ÀàÐÍ
+ *@param [int]ÏûÏ¢ÀàÐÍ.²Î¿¼FUTU_MSG_TYPEµÄ¶¨Òå
+ *@return ÏûϢģʽ.²Î¿¼FUTU_MSG_MODEµÄ¶¨Òå
+ [Ḭ̈߳²È«]
+ */}
+ function GetMsgType(iMsgMode:PInteger= nil ):Integer;virtual;stdcall;abstract;
+
+ {/**
+ * »ñÈ¡¼Ç¼ÌõÊý
+ *@param >=0±íʾ¼Ç¼ÌõÊý,ÆäËû±íʾ´íÎó»òʧ°Ü
+ [Ḭ̈߳²È«]
+ */}
+ function GetCount():Integer;virtual;stdcall;abstract;
+
+ {/**
+ * ÐÂÔöÒ»Ìõ¼Ç¼,²Ù×÷·µ»ØµÄÖ¸ÕëÒÔ²Ù×÷ÆäÖµ
+ *@return ·ÇNULL±íʾһÌõÓÐЧµÄ¼Ç¼,NULL±íʾ·ÖÅäÄÚ´æʧ°Ü
+ [·ÇḬ̈߳²È«]
+ */}
+ function AddRecord():IFuRecord;virtual;stdcall;abstract;
+
+ {/**
+ * »ñÈ¡Ò»Ìõ¼Ç¼
+ *@param iIndex ¼Ç¼Ë÷ÒýλÖÃ,´Ó0¿ªÊ¼¼ÆÊý
+ *@return ·ÇNULL±íʾһÌõÓÐЧµÄ¼Ç¼,NULL±íʾË÷ÒýÔ½½ç
+ [·ÇḬ̈߳²È«]
+ */}
+ function GetRecord(iIndex:Integer = 0):IFuRecord;virtual;stdcall;abstract;
+
+ {/**
+ * ɾ³ýÒ»Ìõ¼Ç¼
+ *@param iIndex ¼Ç¼Ë÷ÒýλÖÃ,´Ó0¿ªÊ¼¼ÆÊý
+ *@return R_OK±íʾɾ³ý¹¦ÄÜ,·ñÔòʧ°Ü(¿ÉÄÜÊÇË÷ÒýÔ½½ç)
+ [·ÇḬ̈߳²È«]
+ */}
+ function DelRecord(iIndex:Integer = 0):Integer;virtual;stdcall;abstract;
+
+ {/**
+ * ɾ³ýËùÓеļǼ
+ *@return R_OK±íʾ³É¹¦,ÆäËû±íʾʧ°Ü
+ [·ÇḬ̈߳²È«]
+ */}
+ function Clear():Integer;virtual;stdcall;abstract;
+end;
+
+implementation
+
+end.
diff --git a/uft_robot/src/uFutuSdkInterface.dcu b/uft_robot/src/uFutuSdkInterface.dcu
new file mode 100644
index 00000000..f60d45a3
Binary files /dev/null and b/uft_robot/src/uFutuSdkInterface.dcu differ
diff --git a/uft_robot/src/uFutuSdkInterface.pas b/uft_robot/src/uFutuSdkInterface.pas
new file mode 100644
index 00000000..c1cd0680
--- /dev/null
+++ b/uft_robot/src/uFutuSdkInterface.pas
@@ -0,0 +1,248 @@
+{/**********************************************************************
+* Ô´³ÌÐòÃû³Æ: futu_sdk_interface.h
+* Èí¼þÖø×÷Ȩ: ºãÉúµç×ӹɷÝÓÐÏÞ¹«Ë¾
+* ϵͳÃû³Æ : 06°æ±¾ÆÚ»õϵͳ
+* Ä£¿éÃû³Æ : ºãÉúÆÚ»õÖܱ߽ӿÚ
+* ¹¦ÄÜ˵Ã÷ : ÖܱßͨÐŽӿڶ¨Òå
+* ×÷ Õß : xdx
+* ¿ª·¢ÈÕÆÚ : 20110315
+* ±¸ ×¢ : ÖܱßͨÐŽӿڶ¨Òå
+* ÐÞ¸ÄÈËÔ± £º
+* ÐÞ¸ÄÈÕÆÚ £º
+* ÐÞ¸Ä˵Ã÷ £º20110315 ´´½¨
+**********************************************************************/}
+unit uFutuSdkInterface;
+
+interface
+
+uses
+ Classes,uFutuDataTypes,uFutuMessageInterface;
+
+type
+
+ //Ç°Ïò¶¨Òå
+ IFuCallBack = class;
+
+////////////////////////////////ÆÚ»õͨÐŶÔÏó½Ó¿Ú//////////////////////////////////////////
+ IHsFutuComm = class(IHSKnown)
+ public
+ {/**
+ * ÉèÖÃÅäÖòÎÊý
+ *@param szSection ½ÚµãÃû
+ *@param szName ÅäÖÃÏî
+ *@param szVal ÅäÖÃÖµ
+ *@return R_OK³É¹¦£¬ÆäËûʧ°Ü
+ [·ÇḬ̈߳²È«]
+ */}
+ function SetConfig(const szSection:PChar;const szName:PChar;const szVal:PChar):Integer;virtual;stdcall;abstract;
+
+ {/**
+ * ³õʼ»¯½Ó¿Ú,ʼ»¯¸÷ÖÖÊý¾Ý,²¢´ÓµÇ½·þÎñÆ÷ÉÏÈ¡µÃÏàÓ¦µÄÐÅÏ¢
+ *@param lpCallback Òì²½»Øµ÷¶ÔÏó,ÓÉÓû§¼Ì³Ð¶ÔÓ¦µÄ½Ó¿ÚʵÏÖÖ®,ΪNULLÔò±íʾ²»¹ØÐĻص÷ÐÅÏ¢
+ *@param iTimeOut ³¬Ê±Ê±¼ä,±íʾ³õʼ»¯³¬Ê±Ê±¼ä,µ¥Î»ºÁÃë,-1±íʾÎÞÏÞÆڵȴý.
+ *@return R_OK±íʾ³É¹¦,ÆäËû±íʾʧ°Ü
+ [Ḭ̈߳²È«]
+ */}
+ function Init(lpCallback:IFuCallBack;iTimeOut:Integer=5000):Integer;virtual;stdcall;abstract;
+
+ {/**
+ * Æô¶¯·þÎñ,½¨Á¢¸÷ÖÖÓ¦ÓõÄͨÐÅÁ¬½Ó.µ±Í¨ÐÅÁ¬½Ó¶Ï¿ªÊ±,Ò²¿ÉÒÔµ÷Óô˺¯Êý½øÐÐÖØÐÂÁ¬½Ó
+ *@param iType ÒªÆô¶¯µÄ·þÎñÀàÐÍ.ÔÊÐíÈ¡Öµ(»òÁ½ÕßÏà¼Ó):SERVICE_TYPE_TRADE,SERVICE_TYPE_QUOTE
+ *@param iTimeout Æô¶¯·þÎñ³¬Ê±
+ [Ḭ̈߳²È«]
+ */}
+ function Start(iType:Integer;iTimeOut:Integer=5000):Integer;virtual;stdcall;abstract;
+
+ {/**
+ * Óû§µÇ¼,ÔÚ×ö¾ßÌåµÄÒµÎñ֮ǰ,ÐèÒªÏȵǽÒÔÈ¡µÃÏà¹ØµÄÈÏÖ¤Éí·ÝÐÅÏ¢
+ *@param szUserID Óû§Ãû,Ò»°ãÖ¸×ʲúÕ˺Å
+ *@param szUserPass Óû§ÃÜÂë
+ *@param reportFlag Óû§ÊÇ·ñÐèÒªUFTÖ÷Íƻر¨£¬1ÐèÒª£¬0²»ÐèÒª
+ * *@param lpReserved ÆäËûÊý¾Ý,V1°æ±¾±ØÐëÉèÖÃΪNULL
+ *@return ERR_OK±íʾÇëÇó³É¹¦(µ«´Ëʱ²¢²»±íʾÒѾµÇ½³É¹¦,Ðè´ÓÒì²½»Øµ÷ÖÐÈ¡Ó¦´ðÏûÏ¢)
+ [Ḭ̈߳²È«]
+ */}
+ function DoLogin(const szUserID:PChar;const szUserPass:PChar;const reportFlag:Integer;const lpReserved:Pointer = nil):Integer;virtual;stdcall;abstract;
+
+ {/**luyj 20110701ÓÃÊäÈëµÄ²ÎÊýÀ´½ÓÊÜ»ØÀ¡ÐÅÏ¢¡£²»ÐèÒªÒì²½»Øµ÷¡£Ð޸ĵ¥20110623004
+ * Óû§µÇ¼,ÔÚ×ö¾ßÌåµÄÒµÎñ֮ǰ,ÐèÒªÏȵǽÒÔÈ¡µÃÏà¹ØµÄÈÏÖ¤Éí·ÝÐÅÏ¢
+ *@param szUserID Óû§Ãû,Ò»°ãÖ¸×ʲúÕ˺Å
+ *@param szUserPass Óû§ÃÜÂë
+ *@param lpReceivedMsg Óû§µÄ·µ»ØÐÅÏ¢
+ *@param reportFlag Óû§ÊÇ·ñÐèÒªUFTÖ÷Íƻر¨£¬1ÐèÒª£¬0²»ÐèÒª
+ *@param lpReserved ±£Áô²ÎÊý,±¾°æ±¾½Ó¿Ú±ØÐëÉèÖÃΪNULL
+ *@return ERR_OK±íʾÇëÇó³É¹¦(µ«´Ëʱ²¢²»±íʾÒѾµÇ½³É¹¦,Òª´ÓlpReceivedMsgÈ¡µÃÓ¦´ðÏûÏ¢)
+ [Ḭ̈߳²È«]
+ */}
+ function DoLoginEx(const szUserID:PChar;const szUserPass:PChar;lpReceivedMsg:IFuMessage;const reportFlag:Integer;const lpReserved:Pointer = nil):Integer;virtual;stdcall;abstract;
+
+ {/**
+ *·¢ËÍÒ»¸öÒµÎñÇëÇóÏûÏ¢(·´À¡½á¹ûÔÚÒì²½»Øµ÷ÖнÓÊÕ)
+ *@param lpMessage Ò»ÌõÒµÎñÇëÇóÏûÏ¢,ÓÉÓû§¸ºÔð¹ÜÀíÆäÉúÃüÆÚ
+ *@param iKeyID Ò»¸ö×Ô¶¨Òå±êʶ,Òì²½Ó¦´ð°üÖлá´ø´Ë±êʶ.-1±íʾ²»¹ØÐĴ˱êÖ¾(ÔòĬÈÏÒì²½Ó¦´ðÒÔ×ʽðÕ˺Å×÷Ϊkeyid)
+ *@return ERR_OK±íʾ·¢ËÍÇëÇó³É¹¦,ÐèÒªÔÙÒì²½»Øµ÷ÖÐÈ¡ÏàÓ¦µÄÓ¦´ðÏûÏ¢½á¹û
+ [·ÇḬ̈߳²È«]
+ */}
+ function AsyncSend(const lpReqMsg:IFuMessage;iKeyID:Integer=-1):Integer;virtual;stdcall;abstract;
+
+ {/** ͬ²½·¢ËÍÒ»¸öÒµÎñÇëÇóÏûÏ¢
+ *@param lpReqMsg ÇëÇóµÄÒµÎñÏûÏ¢ [in]
+ *@param lpAnsMsg ͬ²½Ó¦´ðÒµÎñÏûÏ¢[out]
+ *@param iTimeout ³¬Ê±Ê±¼ä,µ¥Î»ºÁÃë
+ *@return ERR_OK±íʾ³É¹¦,ÆäËû±íʾʧ°Ü
+ [·ÇḬ̈߳²È«]
+ */}
+ function SyncSendRecv(const lpReqMsg:IFuMessage;lpAnsMsg:IFuMessage;iTimeout:Integer=3000):Integer;virtual;stdcall;abstract;
+
+ {/**
+ * ·¢ËͶ©ÔÄÇëÇó,ÒµÎñ½ÓÊÕ½á¹û
+ *@param rType ¶©ÔÄÀàÐÍ(²Î¼ûREGTypeµÄ¶¨Òå)
+ *@param rAction ¶©ÔÄ/Í˶©µÈ¶¯×÷(²Î¼ûREGActionµÄ¶¨Òå)
+ *@param szParam ¸ù¾Ý²»Í¬µÄrTypeÇø·Ö:
+ ÈôÊÇÐÐÇé:szParam±íʾ¶©ÔĵĺÏÔ¼Áбí,ÒÔ¶ººÅ·Ö¸î×Ö·û´®,ÀýÈçWS905,a0905,cu0905,IF0905
+ Èô¶©ÔÄÈ«Êг¡µÄÐÐÇé,¶©ÔÄ´úÂëΪALLWWW
+ ºÏÔ¼´®Ö»ÄÜÖ¸¶¨Ò»ÖÖÀàÐÍ(µ¥ÍÈ»òÕß×éºÏ)
+ ÈôÊǻر¨/¸öÈËÏûÏ¢:szParamÔò±íʾ´ý¶©ÔĵÄÓû§Õ˺Å,×¢ÒâÕâÀïµÄÕ˺Ŷ¼Êǵǽ¹ýµÄÕ˺Å
+ *@return ERR_OK±íʾÇëÇó³É¹¦(´ÓÒì²½Ó¦´ðÖÐÈ¡¶©ÔĽá¹û),ÆäËû±íʾÇëÇóʧ°Ü
+ [·ÇḬ̈߳²È«]
+ */}
+ function SubscribeRequest(rType:REGType;rAction:REGAction;const szParam:PChar):Integer;virtual;stdcall;abstract;
+
+ {/*
+ *Óû§µÇ³ö
+ *@param szUserID ´ýµÇ³öµÄÓû§Õ˺Å
+ *@param lpReserved ±£ÁôÖ®ÓÃ,V1°æ±¾±ØÐëÉèÖÃΪNULL
+ *@return ERR_OK±íʾÇëÇó³É¹¦,¾ßÌå¿ÉÒԴӵǽӦ´ðÖÐÈ¡µÃÐÅÏ¢
+ [Ḭ̈߳²È«]
+ */}
+ function DoLogout(const szUserID:PChar;const lpReserved:Pointer = nil):Integer;virtual;stdcall;abstract;
+
+ {/**
+ * ¹Ø±ÕÇåÀíͨÐŶÔÏó,ÊÍ·ÅÏàÓ¦µÄ×ÊÔ´
+ @return R_OK³É¹¦,ÆäËû±íʾʧ°Ü
+ [Ḭ̈߳²È«]
+ */}
+ function Stop():Integer;virtual;stdcall;abstract;
+
+ {/**
+ * »ñÈ¡Á¬½Ó״̬
+ *@param iIndexÁ¬½Ó±àºÅ.SERVICE_TYPE_TRADE - ±íʾ½»Ò×Á¬½Ó SERVICE_TYPE_QUOTE -ÐÐÇé(¿ÉÄÜ°üº¬»Ø±¨)Á¬½Ó
+ *@return »ñÈ¡Á¬½Ó״̬
+ [Ḭ̈߳²È«]
+ */}
+ function GetStatus(iIndex:Integer):Integer;virtual;stdcall;abstract;
+
+ {/**
+ * »ñÈ¡´íÎóÐÅÏ¢
+ *@param iErrNo »ñÈ¡´íÎóÐÅÏ¢
+ *@return »ñÈ¡´íÎóÐÅÏ¢µÄ˵Ã÷
+ [Ḭ̈߳²È«]
+ */}
+ function GetErrorMsg(iErrNo:Integer):PChar;virtual;stdcall;abstract;
+
+ {/**
+ * °ó¶¨ÊµÀýÏà¹ØÊý¾Ý
+ *@param lpKey Òª°ó¶¨µÄÊý¾Ý»º³åÇø
+ *@param iKeyLen Òª°ó¶¨µÄÊý¾Ý³¤¶È
+ *@return °ó¶¨³É¹¦,°ó¶¨Ê§°Ü
+ [Ḭ̈߳²È«]
+ */}
+ function SetKeyData(const lpKeyData:Pointer;iLen:Integer):Integer;virtual;stdcall;abstract;
+
+ {/**
+ * »ñÈ¡°ó¶¨µÄÊý¾Ý
+ *param iLen ÒªbandingµÄÊý¾Ý³¤¶È
+ *return ·µ»ØÒª°ó¶¨µÄÊý¾ÝÖ¸Õë
+ [Ḭ̈߳²È«]
+ */}
+ function GetKeyData(var iLen:Integer):Pointer;virtual;stdcall;abstract;
+ end;
+
+ ////////////////////////ͨÐÅÒì²½»Øµ÷½Ó¿Ú(×¢Òâ»Øµ÷ÖеÄIFuMessageÏûÏ¢ÓÉSDK¹ÜÀíÆäÉúÃüÖÜÆÚ)//////////////////////////////////////////////////
+ IFuCallBack = class(IHSKnown)
+ public
+ {/**
+ * Á¬½Ó״̬µÄ¸Ä±ä
+ *@param lpComm ͨÐŽӿڶÔÏó
+ *@param iRet ·µ»Ø״̬±êʶ
+ *@param szNotifyTime ·¢ÉúµÄʱ¼ä
+ *@param szMessage ˵Ã÷ÏûÏ¢
+ */}
+ procedure OnConnStateNotify(lpInst:Pointer;iType:Integer;iStatus:Integer;
+ const szNotifyTime:PChar;
+ const szMsg:PChar);virtual;stdcall;abstract;
+
+ {/**
+ * µÇ½Ӧ´ðÏûÏ¢
+ *@param lpComm ͨÐŽӿڶÔÏó
+ */}
+ procedure OnRspLogin(lpInst:Pointer;lpMsg:IFuMessage);virtual;stdcall;abstract;
+
+ {/**
+ * µÇ³ö·´À¡
+ *@param lpComm ͨÐŽӿڶÔÏó
+ */}
+ procedure OnRspLogout(lpInst:Pointer;lpMsg:IFuMessage);virtual;stdcall;abstract;
+
+ {/**
+ *¶©ÔÄ\Í˶©ÐÐÇé»òÕ߻ر¨µÄ½á¹û
+ *@param lpComm ͨÐŽӿڶÔÏó
+ *@param sType ¶©ÔÄÀàÐÍ(µ¥ÍÈÐÐÇé,»Ø±¨µÈ)
+ *@param aAction ÇëÇó·½Ê½(¶©ÔÄ,È¡Ïû,È¡ÏûÈ«²¿,¿ìÕÕ)
+ *@param iResult ¶©ÔĽá¹û,-1δ֪ʧ°Ü,0¶©Ôijɹ¦,1Öظ´¶©ÔÄ,2È¡Ïû³É¹¦,3ûÓж©ÔÄ¿ÉÒÔÈ¡Ïû
+ *@param lpParam ¸½¼ÓµÄ²ÎÊý,ÈôÊǻر¨Ó¦´ð,ÔòÊÇÕ˺Å;ÈôÊÇÐÐÇé,ÔòÊǺÏÔ¼´úÂë;ALLWWW±íʾËùÓÐ;NULLδ֪
+ *@param szMessage ÎÄ×Ö˵Ã÷
+ */}
+ procedure OnRspSubResult(lpInst:Pointer;sType:REGType;
+ aAction:REGAction;iResult:Integer;
+ const lpParam:PChar;const szMsg:PChar);virtual;stdcall;abstract;
+
+ {/**
+ * ÒµÎñ½ÓÊÕµ½ÒµÎñÓ¦´ðÏûÏ¢
+ *@param lpComm ͨÐŽӿڶÔÏó
+ *@param lpAnsData ÒµÎñÓ¦´ðÏûÏ¢
+ */}
+ procedure OnReceivedBiz(lpInst:Pointer;lpAnsData:IFuMessage;iRet:Integer;iKeyID:Integer);virtual;stdcall;abstract;
+
+ {/**
+ * ½ÓÊÕµ½µ¥ÍÈÊг¡ÐÐÇé
+ *@param lpComm ͨÐŽӿڶÔÏó
+ *@param lpInfo µ¥ÍÈÐÐÇéÊý¾Ý
+ */}
+ procedure OnRspMarketInfo(lpInst:Pointer;const lpData:LPCMarketInfo;rAction:REGAction);virtual;stdcall;abstract;
+
+ //½ÓÊÕµ½×éºÏÊг¡ÐÐÇé
+ {/**
+ * ½ÓÊÕµ½µ¥ÍÈÊг¡ÐÐÇé
+ *@param lpComm ͨÐŽӿڶÔÏó
+ *@param lpInfo µ¥ÍÈÐÐÇéÊý¾Ý
+ */}
+ procedure OnRspArgMaketInfo(lpInst:Pointer;const lpData:LPCArgMarketInfo;rAction:REGAction);virtual;stdcall;abstract;
+
+ {/**
+ * ½ÓÊÕµ½Î¯Íз´À¡ÏûÏ¢
+ *@param lpComm ͨÐŽӿڶÔÏó
+ *@param lpInfo ίÍз´À¡ÏûÏ¢
+ */}
+ procedure OnRecvOrderInfo(lpInst:Pointer;const lpInfo:LPCOrderRspInfo);virtual;stdcall;abstract;
+
+ {/**
+ * ½ÓÊÕµ½¶©µ¥³É½»·´À¡
+ *@param lpComm ͨÐŽӿڶÔÏó
+ *@param lpInfo ¶©µ¥³É½»·´À¡
+ */}
+ procedure OnRecvOrderRealInfo(lpInst:Pointer;const lpInfo:LPCRealRspInfo);virtual;stdcall;abstract;
+
+ {/**
+ * ÔÚÏ߸öÈËÏûÏ¢
+ *@param lpComm ͨÐŽӿڶÔÏó
+ *@param szUsrID ÏûÏ¢Ïà¹ØµÄÕ˺Å
+ *@param szMessage Ïà¹ØµÄ¸öÈËÏûÏ¢
+ */}
+ procedure OnRspOnlineMsg(lpInst:Pointer;szUsrID:PChar;szMessage:PChar);virtual;stdcall;abstract;
+end;
+
+
+implementation
+
+end.