作者:insking
链接:https://zhuanlan.zhihu.com/p/23233739
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
上http://code.tradeclassroom.com 下载交易策略源代码。TradeClassRoom官方交流群:334141701
Input:Len( 30 ) ;
var:mp( 0 ), LongST( 0 ), ShortST( 0 ), LongPT( 0 ), ShortPT( 0 ) ;
mp = marketposition ;
if mp <> 0 and mp[1] <> mp then
begin
ShortST = Highest( high, len ) ;
LongST = Lowest( low, len ) ;
end ;
if Time > 945 and Time <= 1430 and mp = 0 and DailyLosers(date) <= 2 then
begin
if Random( 1 ) >= 0.5 then
buy ("Buy") 1 shares next bar at market ;
if Random( 1 ) < 0.5 then
sellshort ("Short") 1 shares next bar at market ;
end ;
if mp = 1 then sell all shares next bar at LongST stop ;
if mp = -1 then buytocover all shares next bar at ShortST stop ;
if Time >= 1500 and mp <> 0 then
begin
sell all shares next bar at market ;
buytocover all shares next bar at market ;
end ;
链接:https://zhuanlan.zhihu.com/p/23233739
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
上http://code.tradeclassroom.com 下载交易策略源代码。TradeClassRoom官方交流群:334141701
Input:Len( 30 ) ;
var:mp( 0 ), LongST( 0 ), ShortST( 0 ), LongPT( 0 ), ShortPT( 0 ) ;
mp = marketposition ;
if mp <> 0 and mp[1] <> mp then
begin
ShortST = Highest( high, len ) ;
LongST = Lowest( low, len ) ;
end ;
if Time > 945 and Time <= 1430 and mp = 0 and DailyLosers(date) <= 2 then
begin
if Random( 1 ) >= 0.5 then
buy ("Buy") 1 shares next bar at market ;
if Random( 1 ) < 0.5 then
sellshort ("Short") 1 shares next bar at market ;
end ;
if mp = 1 then sell all shares next bar at LongST stop ;
if mp = -1 then buytocover all shares next bar at ShortST stop ;
if Time >= 1500 and mp <> 0 then
begin
sell all shares next bar at market ;
buytocover all shares next bar at market ;
end ;