<em id="8ntms"></em><progress id="8ntms"><track id="8ntms"></track></progress>
  • <em id="8ntms"></em>
    1. <tbody id="8ntms"><track id="8ntms"></track></tbody>
      1. 您現在的位置:程序化交易>> 期貨公式>> 交易開拓者(TB)>> 開拓者公式>>正文內容

        開拓者左右互博 日內隨機交易策略源碼[開拓者公式]

        開拓者左右互博 日內隨機交易策略源碼

        //------------------------------------------------------------------------
        // 簡稱: LeftRightTrading
        // 名稱: LeftRightTrading
        // 類別: 公式應用
        // 類型: 用戶應用
        //------------------------------------------------------------------------
        Params
                Bool bInitStatus(False);
            Numeric InitMyRealMP(0);
            Numeric InitPreMyRealMP(0);
                Numeric FirstGrid(5);
                Numeric TotalGrids(10);
                Numeric GridInterval(5);
                Numeric WinGrid(5);
                Numeric EveryLots(1);
                Numeric OffSet(1);
               
                Numeric StyleChangeGrid(3);
                Bool ProgramTest(False);//是否測試 True 是 False 實盤
               
        Vars
                NumericSeries MidLine;
                Numeric MinPoint;
                Numeric AskLine;
                Numeric BidLine;
                Numeric RealMidLine;
                Numeric MyRealMP(0);
                Numeric TmpGridIndex;
                Numeric qcbz;
                Bool TradeTime;
                Numeric TmpLots;
                Numeric PreRealMidLine;
                Numeric PreMyRealMP;
                Numeric MyBuyPosition;
                Numeric MySellPosition;
                Numeric EndTime;
                Bool        bJudgeTime;       
                Numeric ExitOnCloseMins(14.58);
               
                //Debug
                String FilePath;
               
        Begin
                If((Weekday()!=5)&&(Weekday()!=6)&&(Weekday()!=7)){EndTime=0.151500;ExitOnCloseMins=15.13;}
                If(Weekday()==5){EndTime=0.150000;ExitOnCloseMins=14.58;}
                If(!ProgramTest)TradeTime=(Q_LastTime>=0.091500 And CurrentTime>0.091500 And CurrentTime<0.113000) Or (CurrentTime>0.130000 And CurrentTime<EndTime);
                If(ProgramTest)TradeTime=(CurrentTime>0.091500 And CurrentTime<0.113000) Or (CurrentTime>0.130000 And CurrentTime<EndTime);
               
                FilePath="C:\\LeftRightTrading_ea.txt";
               
                MyRealMP=GetGlobalVar(0);
                qcbz=GetGlobalVar(1);
                PreRealMidLine=GetGlobalVar(2);
                PreMyRealMP=GetGlobalVar(3);
                If(BarStatus==0 And (MyRealMP==InvalidNumeric || bInitStatus))
                {
                        //If(A_BuyPosition>0)MyRealMP=A_BuyPosition;
                        //Else If(A_SellPosition>0)MyRealMP=-1*A_SellPosition;
                        //Else MyRealMP=InitMyRealMP;
                        MyRealMP=InitMyRealMP;
                        PreMyRealMP=InitPreMyRealMP;
                       
                }
               
                If((Weekday()!=5)&&(Weekday()!=6)&&(Weekday()!=7))
                        bJudgeTime=(Time==0.091500 Or Time==0.092500 Or Time==0.093500 Or Time==0.094500 Or Time==0.095500 Or Time==0.100500 Or Time==0.101500 Or Time==0.102500 Or Time==0.103500 Or Time==0.104500 Or Time==0.105500 Or Time==0.110500 Or Time==0.111500 Or Time==0.112500 Or Time==0.130000  Or Time==0.131000  Or Time==0.132000  Or Time==0.133000 Or Time==0.134000 Or Time==0.135000 Or Time==0.140000 Or Time==0.141000 Or Time==0.142000 Or Time==0.14300 Or Time==0.144000 Or Time==0.145000 Or Time==0.150000 Or Time==0.151000);
                If(Weekday()==5)
                        bJudgeTime=(Time==0.091500 Or Time==0.092500 Or Time==0.093500 Or Time==0.094500 Or Time==0.095500 Or Time==0.100500 Or Time==0.101500 Or Time==0.102500 Or Time==0.103500 Or Time==0.104500 Or Time==0.105500 Or Time==0.110500 Or Time==0.111500 Or Time==0.112500 Or Time==0.130000  Or Time==0.131000  Or Time==0.132000  Or Time==0.133000 Or Time==0.134000 Or Time==0.135000 Or Time==0.140000 Or Time==0.141000 Or Time==0.142000 Or Time==0.14300 Or Time==0.144000 Or Time==0.145000);
                If(bJudgeTime)
                {
                        MidLine=Open;
                        PreRealMidLine=MidLine[1];
                }
                Else
                {
                        MidLine=MidLine[1];
                }
                RealMidLine=MidLine;
                MinPoint=MinMove*PriceScale;
                If(!ProgramTest)AskLine=Q_AskPrice;Else AskLine=High;
                If(!ProgramTest)BidLine=Q_BidPrice;Else BidLine=Low;
                If(!ProgramTest)MyBuyPosition=A_BuyPosition;
                If(!ProgramTest)MySellPosition=A_SellPosition;
               
                       
                If(BarStatus==2 && A_AccountID!="" && TradeTime)
                {
                        If(Q_AskPrice<=0 || Q_BidPrice<=0) Return;
                        If(Q_BidPrice==Q_UpperLimit || Q_AskPrice ==Q_LowerLimit) Return;
                        If(High==Low)Return;
                        If((Weekday()!=5)&&(Weekday()!=6)&&(Weekday()!=7))
                                bJudgeTime=(Time==0.091500 Or Time==0.092500 Or Time==0.093500 Or Time==0.094500 Or Time==0.095500 Or Time==0.100500 Or Time==0.101500 Or Time==0.102500 Or Time==0.103500 Or Time==0.104500 Or Time==0.105500 Or Time==0.110500 Or Time==0.111500 Or Time==0.112500 Or Time==0.130000  Or Time==0.131000  Or Time==0.132000  Or Time==0.133000 Or Time==0.134000 Or Time==0.135000 Or Time==0.140000 Or Time==0.141000 Or Time==0.142000 Or Time==0.14300 Or Time==0.144000 Or Time==0.145000 Or Time==0.150000 Or Time==0.151000);
                       
                        If(Weekday()==5)
                                bJudgeTime=(Time==0.091500 Or Time==0.092500 Or Time==0.093500 Or Time==0.094500 Or Time==0.095500 Or Time==0.100500 Or Time==0.101500 Or Time==0.102500 Or Time==0.103500 Or Time==0.104500 Or Time==0.105500 Or Time==0.110500 Or Time==0.111500 Or Time==0.112500 Or Time==0.130000  Or Time==0.131000  Or Time==0.132000  Or Time==0.133000 Or Time==0.134000 Or Time==0.135000 Or Time==0.140000 Or Time==0.141000 Or Time==0.142000 Or Time==0.14300 Or Time==0.144000 Or Time==0.145000);
                        //FileAppend(FilePath,"bJudgeTime=");
                       
                        If(TradeTime)//定時清倉,重置中線值
                        {
                                If(qcbz==1)
                                {
                                        //FileAppend(FilePath,"Excute qcbz=1!  "+", MyRealMP="+Text(MyRealMP)+", MySellPosition="+Text(MySellPosition)+", MyBuyPosition="+Text(MyBuyPosition)+", PreMyRealMP="+Text(PreMyRealMP)+", A_SellProfitLoss="+Text(A_SellProfitLoss)+", A_BuyProfitLoss="+Text(A_BuyProfitLoss));
                                        If(MySellPosition>0 And MyRealMP>0 And A_SellProfitLoss>0)
                                        {
                                                TmpLots=MySellPosition;
                                                A_SendOrder(Enum_Buy,Enum_Exit,TmpLots,Q_AskPrice+OffSet*MinPoint);
                                                If(PreMyRealMP>0)MyRealMP=MyRealMP+PreMyRealMP-IntPart(TmpLots/EveryLots);
                                                Else If (PreMyRealMP<=0 And MyRealMP>0)MyRealMP=MyRealMP-IntPart(TmpLots/EveryLots);
                                                MySellPosition=MySellPosition-TmpLots;
                                        }
                                        If(MyBuyPosition>0 And MyRealMP<0 And A_BuyProfitLoss>0)
                                        {
                                                TmpLots=MyBuyPosition;
                                                A_SendOrder(Enum_Sell,Enum_Exit,TmpLots,Q_BidPrice-OffSet*MinPoint);
                                                If(PreMyRealMP<0)MyRealMP=MyRealMP+PreMyRealMP+IntPart(TmpLots/EveryLots);
                                                Else If (PreMyRealMP>=0)MyRealMP=MyRealMP+IntPart(TmpLots/EveryLots);
                                                MyBuyPosition=MyBuyPosition-TmpLots;
                                        } // cxh99.com

                                        If(MySellPosition>0 And PreMyRealMP>0)
                                        {
                                                TmpLots=Min(MySellPosition,PreMyRealMP*EveryLots);
                                                A_SendOrder(Enum_Buy,Enum_Exit,TmpLots,Q_AskPrice+OffSet*MinPoint);
                                                MyRealMP=MyRealMP+PreMyRealMP-IntPart(TmpLots/EveryLots);
                                                MySellPosition=MySellPosition-TmpLots;
                                        }
                                        If(MyBuyPosition>0 And PreMyRealMP<0)
                                        {
                                                TmpLots=Min(MyBuyPosition,-1*PreMyRealMP*EveryLots);
                                                A_SendOrder(Enum_Sell,Enum_Exit,TmpLots,Q_BidPrice-OffSet*MinPoint);
                                                MyRealMP=MyRealMP+PreMyRealMP+IntPart(TmpLots/EveryLots);
                                                MyBuyPosition=MyBuyPosition-TmpLots;
                                        }
                                        PreMyRealMP=MyRealMP;
                                        MyRealMP=0;
                                        qcbz=0;
                                       
                                }
                                Else {qcbz=1;}
                               
                                If(CurrentTime<ExitOnCloseMins/100 And qcbz!=0)
                                {
                                        //FileAppend(FilePath,"Excute1!  "+"PreMyRealMP="+Text(PreMyRealMP)+"MySellPosition="+Text(MySellPosition)+"MyBuyPosition="+Text(MyBuyPosition));
                                       
                                        If(MySellPosition>0 And PreMyRealMP>0)
                                        {
                                                TmpGridIndex=Abs(BidLine-PreRealMidLine)/(GridInterval*MinPoint);
                                                FileAppend(FilePath,"TmpGridIndex1="+Text(TmpGridIndex));
                                                If(TmpGridIndex>=StyleChangeGrid+1 And AskLine>PreRealMidLine+FirstGrid*MinPoint)
                                                {
                                                        TmpLots=Min(MySellPosition,PreMyRealMP*EveryLots);
                                                        A_SendOrder(Enum_Buy,Enum_Exit,TmpLots,Q_AskPrice+OffSet*MinPoint);
                                                        PreMyRealMP=PreMyRealMP-IntPart(TmpLots/EveryLots);
                                                }
                                                TmpGridIndex=Abs(PreRealMidLine-AskLine)/(GridInterval*MinPoint);
                                                FileAppend(FilePath,"TmpGridIndex2="+Text(TmpGridIndex));
                                                If(TmpGridIndex<=StyleChangeGrid And AskLine<PreRealMidLine-FirstGrid*MinPoint)
                                                {
                                                        TmpLots=Min(MySellPosition,PreMyRealMP*EveryLots);
                                                        A_SendOrder(Enum_Buy,Enum_Exit,TmpLots,Q_AskPrice+OffSet*MinPoint);
                                                        PreMyRealMP=PreMyRealMP-IntPart(TmpLots/EveryLots);
                                                }
                                               
                                        }
                                        Else If(MyBuyPosition>0 And PreMyRealMP<0)
                                        {
                                                TmpGridIndex=Abs(BidLine-PreRealMidLine)/(GridInterval*MinPoint);
                                                FileAppend(FilePath,"TmpGridIndex3="+Text(TmpGridIndex));
                                                If(TmpGridIndex<=StyleChangeGrid And BidLine>PreRealMidLine+FirstGrid*MinPoint)
                                                {
                                                        TmpLots=Min(MyBuyPosition,-1*PreMyRealMP*EveryLots);
                                                        A_SendOrder(Enum_Sell,Enum_Exit,TmpLots,Q_BidPrice-OffSet*MinPoint);
                                                        PreMyRealMP=PreMyRealMP+IntPart(TmpLots/EveryLots);
                                                }
                                                TmpGridIndex=Abs(PreRealMidLine-AskLine)/(GridInterval*MinPoint);
                                                FileAppend(FilePath,"TmpGridIndex4="+Text(TmpGridIndex));
                                                If(TmpGridIndex>=StyleChangeGrid And BidLine<PreRealMidLine-FirstGrid*MinPoint)
                                                {
                                                        TmpLots=Min(MyBuyPosition,-1*PreMyRealMP*EveryLots);
                                                        A_SendOrder(Enum_Sell,Enum_Exit,TmpLots,Q_BidPrice-OffSet*MinPoint);
                                                        PreMyRealMP=PreMyRealMP+IntPart(TmpLots/EveryLots);
                                                }
                                        }
                                        If(PreMyRealMP>0 And AskLine>PreRealMidLine-FirstGrid*MinPoint And MySellPosition>0 )
                                        {
                                                TmpGridIndex=Abs(AskLine-PreRealMidLine)/(GridInterval*MinPoint);
                                                FileAppend(FilePath,"TmpGridIndex5="+Text(TmpGridIndex));
                                                If(TmpGridIndex<=PreMyRealMP-1 And TmpGridIndex<=StyleChangeGrid)
                                                {
                                                        PreMyRealMP=PreMyRealMP-1;
                                                        A_SendOrder(Enum_Buy,Enum_Exit,EveryLots,Q_AskPrice+OffSet*MinPoint);
                                                }
                                        }
                                        Else If(PreMyRealMP<0 And BidLine<PreRealMidLine+FirstGrid*MinPoint And MyBuyPosition>0 )
                                        {
                                                TmpGridIndex=Abs(PreMyRealMP-BidLine)/(GridInterval*MinPoint);
                                                FileAppend(FilePath,"TmpGridIndex6="+Text(TmpGridIndex));
                                                If(-1*TmpGridIndex>=PreMyRealMP+1 And TmpGridIndex<=StyleChangeGrid)
                                                {
                                                        PreMyRealMP=PreMyRealMP+1;
                                                        A_SendOrder(Enum_Sell,Enum_Exit,EveryLots,Q_BidPrice-OffSet*MinPoint);
                                                }
                                        }
                                       
                                       
                                       
                                        If(PreMyRealMP<0 And BidLine>PreRealMidLine+FirstGrid*MinPoint And MyBuyPosition>0 )
                                        {
                                                TmpGridIndex=Abs(BidLine-MinPoint-PreRealMidLine)/(GridInterval*MinPoint);
                                                FileAppend(FilePath,"TmpGridIndex7="+Text(TmpGridIndex));
                                                If(TmpGridIndex<=-1*PreMyRealMP-1 And TmpGridIndex>=StyleChangeGrid)
                                                {
                                                        PreMyRealMP=PreMyRealMP+1;
                                                        A_SendOrder(Enum_Sell,Enum_Exit,EveryLots,Q_BidPrice-OffSet*MinPoint);
                                                }
                                        }
                                        Else If(PreMyRealMP>0 And AskLine<PreRealMidLine-FirstGrid*MinPoint And MySellPosition>0 )
                                        {
                                                TmpGridIndex=Abs(PreMyRealMP-AskLine+MinPoint)/(GridInterval*MinPoint);
                                                FileAppend(FilePath,"TmpGridIndex8="+Text(TmpGridIndex));
                                                If(TmpGridIndex>=PreMyRealMP-1 And TmpGridIndex>=StyleChangeGrid)
                                                {
                                                        PreMyRealMP=PreMyRealMP-1;
                                                        A_SendOrder(Enum_Buy,Enum_Exit,EveryLots,Q_AskPrice+OffSet*MinPoint);
                                                }
                                        }
                                       
                                        If(MySellPosition>0 And MyRealMP>0)
                                        {
                                                TmpGridIndex=Abs(BidLine-RealMidLine)/(GridInterval*MinPoint);
                                                FileAppend(FilePath,"TmpGridIndex9="+Text(TmpGridIndex));
                                                If(TmpGridIndex>=StyleChangeGrid+1 And AskLine>RealMidLine+FirstGrid*MinPoint)
                                                {
                                                        TmpLots=Min(MySellPosition,MyRealMP*EveryLots);
                                                        A_SendOrder(Enum_Buy,Enum_Exit,TmpLots,Q_AskPrice+OffSet*MinPoint);
                                                        MyRealMP=MyRealMP-IntPart(TmpLots/EveryLots);
                                                }
                                                TmpGridIndex=Abs(RealMidLine-AskLine)/(GridInterval*MinPoint);
                                                FileAppend(FilePath,"TmpGridIndex10="+Text(TmpGridIndex));
                                                If(TmpGridIndex<=StyleChangeGrid And AskLine<RealMidLine-FirstGrid*MinPoint)
                                                {
                                                        TmpLots=Min(MySellPosition,MyRealMP*EveryLots);
                                                        A_SendOrder(Enum_Buy,Enum_Exit,TmpLots,Q_AskPrice+OffSet*MinPoint);
                                                        MyRealMP=MyRealMP-IntPart(TmpLots/EveryLots);
                                                }
                                        }///來源: www.51-8.cn QQ 1145508240

                                        Else If(MyBuyPosition>0 And MyRealMP<0)
                                        {
                                                TmpGridIndex=Abs(BidLine-RealMidLine)/(GridInterval*MinPoint);
                                                FileAppend(FilePath,"TmpGridIndex11="+Text(TmpGridIndex));
                                                If(TmpGridIndex<=StyleChangeGrid And BidLine>RealMidLine+FirstGrid*MinPoint)
                                                {
                                                        TmpLots=Min(MyBuyPosition,-1*MyRealMP*EveryLots);
                                                        A_SendOrder(Enum_Sell,Enum_Exit,TmpLots,Q_BidPrice-OffSet*MinPoint);
                                                        MyRealMP=MyRealMP+IntPart(TmpLots/EveryLots);
                                                }
                                                TmpGridIndex=Abs(RealMidLine-AskLine)/(GridInterval*MinPoint);
                                                FileAppend(FilePath,"TmpGridIndex12="+Text(TmpGridIndex));
                                                If(TmpGridIndex>=StyleChangeGrid+1 And BidLine<RealMidLine-FirstGrid*MinPoint)
                                                {
                                                        TmpLots=Min(MyBuyPosition,-1*MyRealMP*EveryLots);
                                                        A_SendOrder(Enum_Sell,Enum_Exit,TmpLots,Q_BidPrice-OffSet*MinPoint);
                                                        MyRealMP=MyRealMP+IntPart(TmpLots/EveryLots);
                                                }
                                        }
                                                                       
                                        If(MyRealMP>0 And AskLine>RealMidLine-FirstGrid*MinPoint And MySellPosition>0)
                                        {
                                                TmpGridIndex=Abs(AskLine-RealMidLine)/(GridInterval*MinPoint);
                                                FileAppend(FilePath,"TmpGridIndex13="+Text(TmpGridIndex));
                                                If(TmpGridIndex<=MyRealMP-1 And TmpGridIndex<=StyleChangeGrid)
                                                {
                                                        MyRealMP=MyRealMP-1;
                                                        A_SendOrder(Enum_Buy,Enum_Exit,TmpLots,Q_AskPrice+OffSet*MinPoint);
                                                        MyRealMP=MyRealMP-IntPart(TmpLots/EveryLots);
                                                }
                                               
                                        }
                                        Else If(MyRealMP<0 And BidLine<RealMidLine+FirstGrid*MinPoint And MyBuyPosition>0)
                                        {
                                                TmpGridIndex=Abs(RealMidLine-BidLine)/(GridInterval*MinPoint);
                                                FileAppend(FilePath,"TmpGridIndex14="+Text(TmpGridIndex));
                                                If(-1*TmpGridIndex>=MyRealMP+1 And TmpGridIndex<=StyleChangeGrid)
                                                {
                                                        MyRealMP=MyRealMP+1;
                                                        A_SendOrder(Enum_Sell,Enum_Exit,TmpLots,Q_BidPrice-OffSet*MinPoint);
                                                        MyRealMP=MyRealMP+IntPart(TmpLots/EveryLots);
                                                }
                                        }                       
                                       
                                        If(MyRealMP>0 And AskLine<RealMidLine-FirstGrid*MinPoint And MySellPosition>0)
                                        {
                                                TmpGridIndex=Abs(RealMidLine-AskLine+MinPoint)/(GridInterval*MinPoint);
                                                FileAppend(FilePath,"TmpGridIndex15="+Text(TmpGridIndex));
                                                If(TmpGridIndex<=MyRealMP-1 And TmpGridIndex>=StyleChangeGrid)
                                                {
                                                        MyRealMP=MyRealMP-1;
                                                        A_SendOrder(Enum_Buy,Enum_Exit,TmpLots,Q_AskPrice+OffSet*MinPoint);
                                                        MyRealMP=MyRealMP-IntPart(TmpLots/EveryLots);
                                                }                                       
                                        }
                                        Else If(MyRealMP<0 And BidLine>RealMidLine+FirstGrid*MinPoint And MyBuyPosition>0)
                                        {
                                                TmpGridIndex=Abs(BidLine-MinPoint-RealMidLine)/(GridInterval*MinPoint);
                                                FileAppend(FilePath,"TmpGridIndex16="+Text(TmpGridIndex));
                                                If(TmpGridIndex<=-1*MyRealMP-1 And TmpGridIndex>=StyleChangeGrid)
                                                {
                                                        MyRealMP=MyRealMP+1;
                                                        A_SendOrder(Enum_Sell,Enum_Exit,TmpLots,Q_BidPrice-OffSet*MinPoint);
                                                }
                                        }
                                       
                                        // www.51-8.cn **********************************************************
                                        //FileAppend(FilePath,"Excute***!  "+", MyRealMP="+Text(MyRealMP)+", BidLine="+Text(BidLine)+", RealMidLine="+Text(RealMidLine)+", FirstGrid="+Text(FirstGrid)+", MinPoint="+Text(MinPoint)+", AskLine="+Text(AskLine)+", TmpGridIndex="+Text(TmpGridIndex));
                                        If(MyRealMP>=0 And BidLine>=RealMidLine+FirstGrid*MinPoint)
                                        {                                       
                                                TmpGridIndex=Abs(BidLine-RealMidLine)/(GridInterval*MinPoint);
                                                FileAppend(FilePath,"TmpGridIndex17="+Text(TmpGridIndex)+"MyRealMP="+Text(MyRealMP)+"TotalGrids="+Text(TotalGrids)+"StyleChangeGrid="+Text(StyleChangeGrid));
                                                If(TmpGridIndex>=MyRealMP+1 And MyRealMP<TotalGrids And TmpGridIndex<=StyleChangeGrid)
                                                {
                                                        MyRealMP=MyRealMP+1;
                                                        A_SendOrder(Enum_Sell,Enum_Entry,TmpLots,Q_BidPrice-OffSet*MinPoint);
                                                        MyRealMP=MyRealMP-IntPart(TmpLots/EveryLots);
                                                }                                       
                                        }
                                        Else If(MyRealMP<=0 And AskLine<=RealMidLine-FirstGrid*MinPoint And MyBuyPosition>0)
                                        {
                                                FileAppend(FilePath, "TmpGridIndex18="+Text(TmpGridIndex)+"MyRealMP="+Text(MyRealMP)+"TotalGrids="+Text(TotalGrids)+"StyleChangeGrid="+Text(StyleChangeGrid));
                                                TmpGridIndex=Abs(RealMidLine-AskLine)/(GridInterval*MinPoint);
                                                If(TmpGridIndex>=-1*MyRealMP+1 And -1*MyRealMP<TotalGrids And TmpGridIndex<=StyleChangeGrid)
                                                {
                                                        MyRealMP=MyRealMP-1;
                                                        A_SendOrder(Enum_Buy,Enum_Entry,TmpLots,Q_AskPrice+OffSet*MinPoint);
                                                }
                                        }
                                       
                                       
                                       
                                        If(MyRealMP<=0 And BidLine>RealMidLine+FirstGrid*MinPoint)
                                        {
                                                TmpGridIndex=Abs(BidLine-RealMidLine)/(GridInterval*MinPoint);
                                                FileAppend(FilePath,"TmpGridIndex19="+Text(TmpGridIndex)+"MyRealMP="+Text(MyRealMP)+"TotalGrids="+Text(TotalGrids)+"StyleChangeGrid="+Text(StyleChangeGrid));
                                                If(TmpGridIndex>=-1*MyRealMP+1 And -1*MyRealMP<TotalGrids And TmpGridIndex>=StyleChangeGrid)
                                                {
                                                        MyRealMP=MyRealMP-1;
                                                        A_SendOrder(Enum_Buy,Enum_Entry,TmpLots,Q_AskPrice+OffSet*MinPoint);
                                                        MyRealMP=MyRealMP-IntPart(TmpLots/EveryLots);
                                                }                                        
                                        }
                                        Else If(MyRealMP>=0 And AskLine<RealMidLine-FirstGrid*MinPoint And MyBuyPosition>0)
                                        {
                                                TmpGridIndex=Abs(RealMidLine-AskLine)/(GridInterval*MinPoint);
                                                FileAppend(FilePath,"TmpGridIndex20="+Text(TmpGridIndex)+"MyRealMP="+Text(MyRealMP)+"TotalGrids="+Text(TotalGrids)+"StyleChangeGrid="+Text(StyleChangeGrid));
                                                If(TmpGridIndex>=MyRealMP+1 And MyRealMP<TotalGrids And TmpGridIndex>=StyleChangeGrid+1)
                                                {
                                                        MyRealMP=MyRealMP+1;
                                                        A_SendOrder(Enum_Sell,Enum_Entry,TmpLots,Q_BidPrice-OffSet*MinPoint);
                                                }
                                        }
                                        //****************************************************************
                                       
                                }
                                Else If(CurrentTime>ExitOnCloseMins/100)
                                {
                                        If(MySellPosition>0)
                                        {
                                                A_SendOrder(Enum_Buy,Enum_Exit,MySellPosition, Q_AskPrice+OffSet*MinPoint);
                                        }
                                        Else If(MyBuyPosition>0)
                                        {
                                                A_SendOrder(Enum_Sell,Enum_Exit,MyBuyPosition, Q_BidPrice-OffSet*MinPoint);
                                        }
                                        MyRealMP=0;
                                        PreMyRealMP=0;
                                }
                        }
                        //Else FileAppend(FilePath,"Not Trading Time.***");
                       
                        SetGlobalVar(0,MyRealMP);
                        SetGlobalVar(1,qcbz);
                        SetGlobalVar(2,PreRealMidLine);
                        SetGlobalVar(3,PreMyRealMP);
                        Commentary("本時段中線="+Text(RealMidLine));
                        Commentary("上時段中線="+Text(PreRealMidLine));
                        Commentary("本時段倉位="+Text(MyRealMP*EveryLots));
                        Commentary("上時段留倉="+Text(PreMyRealMP*EveryLots));
                        Commentary("當前時間="+TimeToString(CurrentTime));
                        Commentary("清倉標志="+Text(qcbz));
                       
                }
        End
        //------------------------------------------------------------------------

        //------------------------------------------------------------------------
        // 簡稱: LeftRightTrading
        // 來源: www.51-8.cn QQ 1145508240

        // 類別: 公式應用
        // 類型: 用戶應用
        //------------------------------------------------------------------------

         

         

         

        有思路,想編寫各種指標公式,程序化交易模型,選股公式,預警公式的朋友

        可聯系技術人員 QQ: 1145508240  有需要幫忙請點擊這里留言?。?!進行 有償 編寫!不貴!點擊查看價格!

         


        【字體: 】【打印文章】【查看評論

        相關文章

          沒有相關內容
          真钱三公