以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://222.73.7.161/bbs/index.asp)
--  公式模型编写问题提交  (http://222.73.7.161/bbs/list.asp?boardid=4)
----  以下策略为金字塔程序化双边策略(可开多,可开空),请老师更改为两个单边策略(只开空一个策略,只开多一个策略)  (http://222.73.7.161/bbs/dispbbs.asp?boardid=4&id=183724)

--  作者:代人发贴
--  发布时间:2021/1/4 9:49:18
--  以下策略为金字塔程序化双边策略(可开多,可开空),请老师更改为两个单边策略(只开空一个策略,只开多一个策略)

以下策略为金字塔程序化双边策略(可开多,可开空),请老师更改为两个单边策略(只开空一个策略,只开多一个策略),谢谢

//该策略适用于图表程序化交易

 

            //该范例适用于5分钟周期

 

            //此策略仅供参考学习,请勿直接用于实盘

 

 

 

            INPUT:N(55,1,100,1),SS(1,1,100,1),NMIN(10,1,100,1),LONG_CO(0.999,0.001,1.1,0.001),SHORT_CO(1.001,0.001,1.1,0.001);

 

 

 

            BUYTIME:=TIME>OPENTIME(1) AND TIME<CLOSETIME(0)-NMIN*100;      //设置日内交易的开仓时段           

 

            SELLTIME:=TIME>=CLOSETIME(0)-NMIN*100;                                        //设置尾盘的清仓时段      

 

            UP_LINE:REF(HHV(H,N),1)*LONG_CO;                                                    //设置上轨线

            DOWN_LINE:REF(LLV(L,N),1)*SHORT_CO;                                              //设置下轨线

            MIDDLE_LINE:(UP_LINE+DOWN_LINE)/2;                                               //设置中轨线

 

            CONKD:H>=UP_LINE AND BUYTIME ;                                                     //设置开多条件

            CONKK:L<=DOWN_LINE AND BUYTIME;                                                 //设置开空条件

            CONPD:C<MIDDLE_LINE;                                                                      //设置平多条件

            CONPK:C>MIDDLE_LINE;                                                                      //设置平空条件

 

 

 

            SELLSHORT(CONPK AND HOLDING<0,HOLDING,MARKET);

            SELL(CONPD AND HOLDING>0,HOLDING,MARKET);

            BUY(CONKD AND HOLDING=0,SS,MARKET);

            BUYSHORT(CONKK AND HOLDING=0,SS,MARKET);

 

 

 

            IF SELLTIME THEN                                                                               //收盘前全部平仓

                BEGIN

                SELL(HOLDING>0,HOLDING,MARKET);

                SELLSHORT(HOLDING<0,HOLDING,MARKET);

                END


--  作者:FireScript
--  发布时间:2021/1/4 9:54:23
--  
 只开空
INPUT:N(55,1,100,1),SS(1,1,100,1),NMIN(10,1,100,1),LONG_CO(0.999,0.001,1.1,0.001),SHORT_CO(1.001,0.001,1.1,0.001);
BUYTIME:=TIME>OPENTIME(1) AND TIME<CLOSETIME(0)-NMIN*100;      //设置日内交易的开仓时段           
SELLTIME:=TIME>=CLOSETIME(0)-NMIN*100;                                     
UP_LINE:REF(HHV(H,N),1)*LONG_CO;                                             
DOWN_LINE:REF(LLV(L,N),1)*SHORT_CO;                                            
MIDDLE_LINE:(UP_LINE+DOWN_LINE)/2;                                            
                                                    
CONKK:L<=DOWN_LINE AND BUYTIME;                                                                                                                //设置平多条件
CONPK:C>MIDDLE_LINE;                                                                   

 
SELLSHORT(CONPK AND HOLDING<0,HOLDING,MARKET);
BUYSHORT(CONKK AND HOLDING=0,SS,MARKET);
IF SELLTIME THEN                                                                               //收盘前全部平仓
BEGIN
SELLSHORT(HOLDING<0,HOLDING,MARKET);
END



只开多
INPUT:N(55,1,100,1),SS(1,1,100,1),NMIN(10,1,100,1),LONG_CO(0.999,0.001,1.1,0.001),SHORT_CO(1.001,0.001,1.1,0.001);
BUYTIME:=TIME>OPENTIME(1) AND TIME<CLOSETIME(0)-NMIN*100;      //设置日内交易的开仓时段           
SELLTIME:=TIME>=CLOSETIME(0)-NMIN*100;                                        
UP_LINE:REF(HHV(H,N),1)*LONG_CO;                                           
DOWN_LINE:REF(LLV(L,N),1)*SHORT_CO;                                   
MIDDLE_LINE:(UP_LINE+DOWN_LINE)/2;                                             

CONKD:H>=UP_LINE AND BUYTIME ;                                                                                                 
CONPD:C<MIDDLE_LINE;                                                               
                                                               
SELL(CONPD AND HOLDING>0,HOLDING,MARKET);
BUY(CONKD AND HOLDING=0,SS,MARKET);

 IF SELLTIME THEN                                                                               //收盘前全部平仓
BEGIN
SELL(HOLDING>0,HOLDING,MARKET);
END