-- 作者:tclstn
-- 发布时间:2013/1/14 10:47:17
-- 金字塔K逐线模式下 自编的函数是否正确?动态止盈止损功能有时好用有时不好用 没有规律。。。。请高手指点错误在哪?
Function DTZYZS(Formula,T,K,D,F,W) \'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\' \'函数机能:动态止盈止损 \'参数说明:T 0:收阳止盈 1:收阴止盈 2:收阳止损 3:收阴止损 4:价格收阳止盈 5:价格收阴止盈 \' K 持仓价 \' D 指定值 \' F 浮动点 \' W 委托量 \'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'
\'系统会在逐K线模式解释公式时的每个周期都会调用此函数一遍,因此设计时应该注重程序的执行效率,不要重复的执行一些没必要的代码 If order.Holding2=0 Then Exit Function End If
DTZYZS=1 W=abs(W) \' 得到框架名称为"Technic",窗格名称为"Main"的窗格对象 Set Grid = Technic.GetGridByName("Main") \'最新价格取得 Set Report1=marketdata.GetReportData(Grid.StockLabel,Grid.Market) NewPrice=Report1.NewPrice
\'分别处理 Select Case T Case 0 \'收阳止盈 If NewPrice >= K + D Then call order.Sell(0,W,NewPrice-F,0,Grid.StockLabel,Grid.Market,"",0) Application.msgout Cdate(time) & ":【止盈】委托价:" & NewPrice-F & "委托量:" & W DTZYZS=0 End If Exit Function Case 1 \'收阴止盈 If NewPrice <= K - D Then call order.SellShort(0,W,NewPrice+F,0,Grid.StockLabel,Grid.Market,"",0) Application.msgout Cdate(time) & ":【止盈】委托价:" & NewPrice+F & "委托量:" & W DTZYZS=0 End If Exit Function Case 2 \'收阳止损 If NewPrice <= K - D Then call order.Sell(0,W,NewPrice-F,0,Grid.StockLabel,Grid.Market,"",0) Application.msgout Cdate(time) & ":【止损】委托价:" & NewPrice-F & "委托量:" & W DTZYZS=0 End If Exit Function Case 3 \'收阴止损 If NewPrice >= K + D Then call order.SellShort(0,W,NewPrice+F,0,Grid.StockLabel,Grid.Market,"",0) Application.msgout Cdate(time) & ":【止损】委托价:" & NewPrice+F & "委托量:" & W DTZYZS=0 End If Exit Function Case 4 \'价格收阳止盈 If NewPrice >= D Then call order.Sell(0,W,NewPrice-F,0,Grid.StockLabel,Grid.Market,"",0) Application.msgout Cdate(time) & ":【止盈】委托价:" & NewPrice-F & "委托量:" & W DTZYZS=0 End If Exit Function Case 5 \'价格收阴止盈 If NewPrice <= D Then call order.SellShort(0,W,NewPrice+F,0,Grid.StockLabel,Grid.Market,"",0) Application.msgout Cdate(time) & ":【止盈】委托价:" & NewPrice-F & "委托量:" & W DTZYZS=0 End If Exit Function End Select
End Function
1.金字塔K逐线模式下 自编的函数是否正确? 2.动态止盈止损功能有时好用有时不好用 没有规律。。。。请高手指点错误在哪?
|