搜索
楼主: zhx163

20万实盘跟踪展示系统交易

[复制链接]

签到天数: 13 天

发表于 2010-8-2 20:46 | 显示全部楼层
或去除里面设好的交易量,
金币:
奖励:
热心:
注册时间:
2007-10-21

回复 使用道具 举报

签到天数: 13 天

发表于 2010-8-2 20:49 | 显示全部楼层
Params
    Numeric RiskRatio(1);                   // % Risk Per N ( 0 - 100)
    Numeric ATRLength(20);                  // 平均波动周期 ATR Length
    Numeric boLength(20);                   // 短周期 BreakOut Length
    Numeric fsLength(55);                   // 长周期 FailSafe Length
    Numeric teLength(10);                   // 离市周期 Trailing Exit Length
    Bool LastProfitableTradeFilter(True);   // 使用入市过滤条件
Vars
Numeric MinPoint;                       // 最小变动单位
NumericSeries AvgTR;      // ATR
    Numeric N;                              // N 值
    Numeric TotalEquity;                    // 按最新收盘价计算出的总资产
    Numeric TurtleUnits;                    // 交易单位
    NumericSeries DonchianHi;              // 唐奇安通道上轨,延后1个Bar
    NumericSeries DonchianLo;              // 唐奇安通道下轨,延后1个Bar
    NumericSeries fsDonchianHi;            // 唐奇安通道上轨,延后1个Bar,长周期
    NumericSeries fsDonchianLo;            // 唐奇安通道下轨,延后1个Bar,长周期
    Numeric ExitHighestPrice;               // 离市时判断需要的N周期最高价
    Numeric ExitLowestPrice;                // 离市时判断需要的N周期最低价
    Numeric myEntryPrice;                   // 开仓价格
    Numeric myExitPrice;                    // 平仓价格
    Bool SendOrderThisBar(False);          // 当前Bar有过交易
NumericSeries preEntryPrice(0);       // 前一次开仓的价格,存放到全局变量0号位置
BoolSeries PreBreakoutFailure(false); // 前一次突破是否失败
Begin
    If(BarStatus == 0)
    {
  preEntryPrice = InvalidNumeric;
  PreBreakoutFailure = false;
}Else
{
  preEntryPrice = preEntryPrice[1];
        PreBreakoutFailure = PreBreakoutFailure[1];
    }
MinPoint = MinMove*PriceScale;
    AvgTR = XAverage(TrueRange,ATRLength);
N = AvgTR[1];
    TotalEquity = CurrentCapital()+ Abs(CurrentContracts()*Close*ContractUnit()*BigPointValue()*MarginRatio());
    TurtleUnits = (TotalEquity*RiskRatio/100) /(N * ContractUnit()*BigPointValue());
    TurtleUnits = IntPart(TurtleUnits); // 对小数取整
    DonchianHi = HighestFC(High[1],boLength);
    DonchianLo = LowestFC(Low[1],boLength);
fsDonchianHi = HighestFC(High[1],fsLength);
    fsDonchianLo = LowestFC(Low[1],fsLength);
Commentary("N="+Text(N));
Commentary("preEntryPrice="+Text(preEntryPrice));
Commentary("PreBreakoutFailure="+IIFString(PreBreakoutFailure,"True","False"));

    // 当不使用过滤条件,或者使用过滤条件并且条件为PreBreakoutFailure为True进行后续操作
    If(MarketPosition == 0 && ((!LastProfitableTradeFilter) Or (PreBreakoutFailure)))
    {
        // 突破开仓
        If(CrossOver(High,DonchianHi) && TurtleUnits >= 1)
        {
            // 开仓价格取突破上轨+一个价位和最高价之间的较小值,这样能更接近真实情况,并能尽量保证成交
            myEntryPrice = min(high,DonchianHi + MinPoint);
            myEntryPrice = IIF(myEntryPrice < Open, Open,myEntryPrice); // 大跳空的时候用开盘价代替
   preEntryPrice = myEntryPrice;
            Buy(TurtleUnits,myEntryPrice);
   SendOrderThisBar = True;
   PreBreakoutFailure = False;
        }
        If(CrossUnder(Low,DonchianLo) && TurtleUnits >= 1)
        {
            // 开仓价格取突破下轨-一个价位和最低价之间的较大值,这样能更接近真实情况,并能尽量保证成交
            myEntryPrice = max(low,DonchianLo - MinPoint);
            myEntryPrice = IIF(myEntryPrice > Open, Open,myEntryPrice); // 大跳空的时候用开盘价代替
            preEntryPrice = myEntryPrice;
            SendOrderThisBar = True;
            SellShort(TurtleUnits,myEntryPrice);
   SendOrderThisBar = True;
   PreBreakoutFailure = False;
        }
    }
    // 长周期突破开仓 Failsafe Breakout point
    If(MarketPosition == 0)
    {
  Commentary("fsDfsDExitLowestPrice="+Text(ExitLowestPrice));
        If(Low < ExitLowestPrice)
        {
            myExitPrice = max(Low,ExitLowestPrice - MinPoint);
   myExitPrice = IIF(myExitPrice > Open, Open,myExitPrice); // 大跳空的时候用开盘价代替
            Sell(0,myExitPrice);    // 数量用0的情况下将全部平仓
        }Else
        {
            If(preEntryPrice!=InvalidNumeric && TurtleUnits >= 1)
            {
                If(Open >= preEntryPrice + 0.5*N) // 如果开盘就超过设定的1/2N,则直接用开盘价增仓。
                {
                    myEntryPrice = Open;
     preEntryPrice = myEntryPrice;
                    Buy(TurtleUnits,myEntryPrice);
     SendOrderThisBar = True;
                }
                while(High >= preEntryPrice + 0.5*N) // 以最高价为标准,判断能进行几次增仓
                {
                    myEntryPrice = preEntryPrice + 0.5 * N;
                    preEntryPrice = myEntryPrice;
                    Buy(TurtleUnits,myEntryPrice);
     SendOrderThisBar = True;     
                }
            }
   
            // 止损指令
   If(Low <= preEntryPrice - 2 * N && SendOrderThisBar == false) // 加仓Bar不止损
   {
    myExitPrice = preEntryPrice - 2 * N;
    Sell(0,myExitPrice); // 数量用0的情况下将全部平仓
    PreBreakoutFailure = True;
   }
        }
    }Else If(MarketPosition ==-1) // 有空仓的情况
    {
        // 求出持空仓时离市的条件比较值
        ExitHighestPrice = Highest(High[1],teLength);
  Commentary("ExitHighestPrice="+Text(ExitHighestPrice));
        If(High > ExitHighestPrice)
        {
            myExitPrice = Min(High,ExitHighestPrice + MinPoint);
   myExitPrice = IIF(myExitPrice < Open, Open,myExitPrice); // 大跳空的时候用开盘价代替
            BuyToCover(0,myExitPrice);    // 数量用0的情况下将全部平仓
        }Else
        {
            If(preEntryPrice!=InvalidNumeric && TurtleUnits >= 1)
            {
                If(Open <= preEntryPrice - 0.5*N) // 如果开盘就超过设定的1/2N,则直接用开盘价增仓。
                {
                    myEntryPrice = Open;
     preEntryPrice = myEntryPrice;
                    SellShort(TurtleUnits,myEntryPrice);
     SendOrderThisBar = True;
                }
                while(Low <= preEntryPrice - 0.5*N) // 以最低价为标准,判断能进行几次增仓
                {
                    myEntryPrice = preEntryPrice - 0.5 * N;
                    preEntryPrice = myEntryPrice;
                    SellShort(TurtleUnits,myEntryPrice);
     SendOrderThisBar = True;
                }
            }
            // 止损指令
   If(High >= preEntryPrice + 2 * N &&SendOrderThisBar==false) // 加仓Bar不止损
   {
    myExitPrice = preEntryPrice + 2 * N;
    BuyToCover(0,myExitPrice); // 数量用0的情况下将全部平仓
    PreBreakoutFailure = True;
   }
        }
    }
End
金币:
奖励:
热心:
注册时间:
2007-10-21

回复 使用道具 举报

签到天数: 71 天

 楼主| 发表于 2010-8-2 21:03 | 显示全部楼层
更改投入资金就可以了!!#*)*#
金币:
奖励:
热心:
注册时间:
2002-5-1

回复 使用道具 举报

签到天数: 13 天

发表于 2010-8-2 21:29 | 显示全部楼层
这里是吗

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
金币:
奖励:
热心:
注册时间:
2007-10-21

回复 使用道具 举报

签到天数: 13 天

发表于 2010-8-2 21:38 | 显示全部楼层
请问系统里设的交易是以%为第一次,第二次又是多少%,

因我想同时监控3--5个品种,所以对各个品种买入是各不相同

比如,有5万元,设置为
买白糖2份合约,

买TA1009,1份合约。

买P1011,1份合约。

这样那个品种先到买入就按数量成交,后面的才有资金可用呀
金币:
奖励:
热心:
注册时间:
2007-10-21

回复 使用道具 举报

签到天数: 13 天

发表于 2010-8-2 21:40 | 显示全部楼层
我前几天试到头2个品种成交了,第3个就提示资金不足
金币:
奖励:
热心:
注册时间:
2007-10-21

回复 使用道具 举报

签到天数: 13 天

发表于 2010-8-2 21:45 | 显示全部楼层
开拓者的员工,回复问题很慢,我看论坛的提问,好多都没回复,
金币:
奖励:
热心:
注册时间:
2007-10-21

回复 使用道具 举报

签到天数: 71 天

 楼主| 发表于 2010-8-3 05:11 | 显示全部楼层
把资金按品种分配就可以了!#*)*#
金币:
奖励:
热心:
注册时间:
2002-5-1

回复 使用道具 举报

签到天数: 13 天

发表于 2010-8-3 15:10 | 显示全部楼层
#vv1#


谢谢您

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
金币:
奖励:
热心:
注册时间:
2007-10-21

回复 使用道具 举报

签到天数: 71 天

 楼主| 发表于 2010-8-3 15:18 | 显示全部楼层

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
金币:
奖励:
热心:
注册时间:
2002-5-1

回复 使用道具 举报

签到天数: 580 天

发表于 2010-8-3 18:01 | 显示全部楼层
马上一年了#*P#
金币:
奖励:
热心:
注册时间:
2006-11-25

回复 使用道具 举报

签到天数: 71 天

 楼主| 发表于 2010-8-3 19:35 | 显示全部楼层
原帖由 杨太极 于 2010-8-3 18:01 发表
马上一年了#*P#

哈哈,我在家下岗一年半了!!#*18*#
金币:
奖励:
热心:
注册时间:
2002-5-1

回复 使用道具 举报

签到天数: 580 天

发表于 2010-8-3 22:17 | 显示全部楼层
比上班强吧#*29*#
金币:
奖励:
热心:
注册时间:
2006-11-25

回复 使用道具 举报

签到天数: 71 天

 楼主| 发表于 2010-8-4 05:12 | 显示全部楼层
原帖由 杨太极 于 2010-8-3 22:17 发表
比上班强吧#*29*#


比较自由,不受约束!
金币:
奖励:
热心:
注册时间:
2002-5-1

回复 使用道具 举报

发表于 2010-8-4 06:21 | 显示全部楼层
这里面的开仓均价跟持仓均价是什么意思,这两个好像是一个意思啊
金币:
奖励:
热心:
注册时间:
2008-2-24

回复 使用道具 举报

签到天数: 13 天

发表于 2010-8-4 12:01 | 显示全部楼层


今天设为10%时,它一次只成交1手。



新问题,

请问,我今天买2份合约,明天到平仓点自动卖出一份,有买点又自动买入1份,即自动成交中保存1份合约为长线。这样在系统外可以设置吗?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
金币:
奖励:
热心:
注册时间:
2007-10-21

回复 使用道具 举报

签到天数: 71 天

 楼主| 发表于 2010-8-4 12:03 | 显示全部楼层
系统不会管不是他开的仓
因为责任自负#*29*#
金币:
奖励:
热心:
注册时间:
2002-5-1

回复 使用道具 举报

签到天数: 13 天

发表于 2010-8-4 12:20 | 显示全部楼层
新问题,

请问,我今天买2份合约,明天到平仓点自动卖出一份,有买点又自动买入1份,即自动成交中保存1份合约为长线。这样在系统外可以设置吗?
金币:
奖励:
热心:
注册时间:
2007-10-21

回复 使用道具 举报

签到天数: 13 天

发表于 2010-8-4 12:22 | 显示全部楼层
原帖由 zhx163 于 2010-8-4 12:03 发表
系统不会管不是他开的仓
因为责任自负#*29*#




请说详细点,谢谢。
金币:
奖励:
热心:
注册时间:
2007-10-21

回复 使用道具 举报

发表于 2010-8-4 12:23 | 显示全部楼层
学习。谢谢          。
金币:
奖励:
热心:
注册时间:
2007-5-10

回复 使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

本站声明:MACD仅提供交流平台,请交流人员遵守法律法规。
值班电话:18209240771   微信:35550268

举报|意见反馈|手机版|MACD俱乐部

GMT+8, 2025-4-22 14:21 , Processed in 0.030854 second(s), 9 queries , MemCached On.

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表