Exemplo n.º 1
0
Arquivo: code.cs Projeto: heber/FreeOQ
	public override void OnStrategyStart()
	{
		series = new BarSeries();

		if (VolatilityExitEnabled || VolatilityBarrierEnabled)
		{
			rangeSeries = new TimeSeries();
			
			rangeSMA = new SMA(rangeSeries, VolatilitySMALength);
		}
		
		if (TickBarrierEnabled)
			barrier = TickSize * BarrierSize;
		
		lowestLowSeries   = new TimeSeries();
		highestHighSeries = new TimeSeries();		
		channelLowSeries  = new TimeSeries();
		channelHighSeries = new TimeSeries();
		
		lowestLowSeries  .Color = Color.Blue;
		highestHighSeries.Color = Color.Blue;
		channelLowSeries .Color = Color.Brown;
		channelHighSeries.Color = Color.Brown;
		
		Draw(lowestLowSeries  , 0);
		Draw(highestHighSeries, 0);
		Draw(channelLowSeries , 0);
		Draw(channelHighSeries, 0);
	}
Exemplo n.º 2
0
        public override void OnStrategyStart()
        {
            base.OnStrategyStart();

            // 测试用,自定义交易时间,仿真或实盘时可删除
            base.TimeHelper = new TimeHelper(new int[] { 0, 2400 },2100, 1458);

            base.TargetPosition = 0;
            //base.DualPosition.Long.Qty = 0;
            //base.DualPosition.Long.QtyToday = 0;
            //base.DualPosition.Short.Qty = 0;
            //base.DualPosition.Short.QtyToday = 0;
            if(BrokerInfo == null)
            {
                // 使用静态的主要原因是每个实例都来取一次没有必要
                BrokerInfo = DataManager.GetBrokerInfo();   
            }
            if (BrokerInfo.Accounts.Count > 0)
            {
                BrokerAccount brokerAccount = BrokerInfo.Accounts[0];
                GetBrokerInfoHelper.Transform(brokerAccount, base.DualPosition);
            }
            

            LoadHistoricalBars(Clock.Now);

            BarSeries bars1min = GetBars(BarType.Time, BarSize);

            fastSMA = new SMA(bars1min, fastLength, Color.Red);
            slowSMA = new SMA(bars1min, slowLength, Color.Green);

            Draw(fastSMA, 0);
            Draw(slowSMA, 0);
        }
Exemplo n.º 3
0
        public override void OnStrategyStart()
        {
            base.OnStrategyStart();

            //测试用,自定义交易时间,只使用日线做简单测试时极方便
            base.TimeHelper = new TimeHelper(new int[] { 0, 2400 }, 2100,1700);
            // 此处要测试是否支持交易所组合合约
            base.TextParameter = new TextSP();

            base.TargetPosition = 0;
            base.DualPosition.Long.Qty = 0;
            base.DualPosition.Short.Qty = 0;

            // 记下策略的对象,在其它实例中可以用到
            //Global.Add(Instrument.Symbol, this);

            if (Instrument.Symbol == Symbol1)
            {
                S1 = this;
            }
            if (Instrument.Symbol == Symbol2)
            {
                S2 = this;
            }

            fastSMA = new SMA(Bars, fastLength, Color.Red);
            slowSMA = new SMA(Bars, slowLength, Color.Green);

            Draw(fastSMA, 0);
            Draw(slowSMA, 0);
        }
Exemplo n.º 4
0
        protected void SetupIndicators()
        {
            if (SlowMaPeriod <= FastMaPeriod)
            {
                throw new ArgumentOutOfRangeException("SlowMaPeriod",
                    "Slow MA period must be greater than fast MA period");
            }

            CurrentExecutionBarSeries = GetBars(BarType.Time, CurrentExecutionTimePeriodInSeconds);
            SlowEmaIndicator = new EMA(CurrentExecutionBarSeries, SlowMaPeriod, Color.Orange);
            FastEmaIndicator = new EMA(CurrentExecutionBarSeries, FastMaPeriod, Color.Cyan);
            FastEmaIndicator.Color = Color.Cyan;

            Draw(SlowEmaIndicator, 0);
            Draw(FastEmaIndicator, 0);

            KSlowIndicator = new K_Slow(CurrentExecutionBarSeries, StochasticsKPeriod, StochasticsSmoothPeriod, Color.Yellow);
            DSlowIndicator = new D_Slow(CurrentExecutionBarSeries, StochasticsKPeriod, StochasticsDPeriod,
                StochasticsSmoothPeriod,
                Color.Red);

            Draw(KSlowIndicator, 2);
            Draw(DSlowIndicator, 2);

            CurrentDailyBarSeries = GetBars(BarType.Time, PeriodConstants.PERIOD_DAILY);
            DailyAtrIndicator = new ATR(CurrentDailyBarSeries, AtrPeriod, Color.Wheat);
            DailyVolumeSmaIndicator = new SMA(CurrentDailyBarSeries, 20, BarData.Volume);
            DailyPriceSmaIndicator = new SMA(CurrentDailyBarSeries, 20, BarData.Close);
            Draw(DailyAtrIndicator, 3);
        }
Exemplo n.º 5
0
        public override void OnStrategyStart()
        {
            dpo = new DPO1(Bars, length, BarData.Close);
            sma = new SMA(Bars, length, BarData.Close);

            Draw(dpo, 2);
            Draw(sma, 0);
        }
Exemplo n.º 6
0
 protected BIAS(BarSeries series, SMA sma, int length, BarData barData)
     : base(series)
 {
     this.length = length;
     this.sma = sma;
     this.barData = barData;
     this.Name = "BIAS";
 }
Exemplo n.º 7
0
        public override void OnStrategyStart()
        {
            ama = new KaufmanAMA(Bars, N, SL, FS);
            sma = new SMA(Bars, N, Color.Red);

            Draw(ama, 0);
            Draw(sma, 0);
            Draw(ama.ER, 2);
        }
Exemplo n.º 8
0
Arquivo: code.cs Projeto: heber/FreeOQ
	public override void OnStrategyStart()
	{
		// set up the moving averages, based on closing prices
		sma1 = new SMA(Bars, Length1, Color1);
		sma2 = new SMA(Bars, Length2, Color2);
		// 0 means draw both averages on the price chart
		Draw(sma1, 0);
		Draw(sma2, 0);
	}
Exemplo n.º 9
0
	public override void OnStrategyStart()
	{		
		// set up the fast average
		fastSMA = new SMA(Bars, FastSMALength * 7, Color.Yellow);		
		Draw(fastSMA, 0);
		// set up the slow average
		slowSMA = new SMA(Bars, SlowSMALength * 7, Color.Pink);		
		Draw(slowSMA, 0);
	}
Exemplo n.º 10
0
Arquivo: code.cs Projeto: heber/FreeOQ
	public override void OnStrategyStart()
	{
		// set up the moving averages 
		sma = new SMA(Bars, SMALength);
		sma.Color = Color.Yellow;
		Draw(sma, 0);
		// set up bollinger bands
		bbl = new BBL(Bars, SMALength, BBLOrder);
		bbl.Color = Color.Pink;
		Draw(bbl, 0);
	}
        public override void OnStrategyStart()
        {
            LoadHistoricalBars(Clock.Now);

            BarSeries bars1min = GetBars(BarType.Time, BarSize);

            fastSMA = new SMA(bars1min, fastLength, Color.Red);
            slowSMA = new SMA(bars1min, slowLength, Color.Green);

            Draw(fastSMA, 0);
            Draw(slowSMA, 0);
        }
Exemplo n.º 12
0
        public override void OnStrategyStart()
        {
            base.OnStrategyStart();

            // 测试用,自定义交易时间,仿真或实盘时可删除
            base.TimeHelper = new TimeHelper(new int[] { 0, 2400 },2100, 1458);

            base.TargetPosition = 0;
            base.DualPosition.Long.Qty = 0;
            base.DualPosition.Short.Qty = 0;

            LoadHistoricalBars(Clock.Now);

            BarSeries bars1min = GetBars(BarType.Time, BarSize);

            fastSMA = new SMA(bars1min, fastLength, Color.Red);
            slowSMA = new SMA(bars1min, slowLength, Color.Green);

            Draw(fastSMA, 0);
            Draw(slowSMA, 0);
        }
Exemplo n.º 13
0
        public override void OnStrategyStart()
        {
            if (Instrument1 == Instrument)
            {
                //Strategy1 = this;
                BarSeries1 = GetBars(BarType.Time, barSize);
            }
            else if (Instrument2 == Instrument)
            {
                //Strategy2 = this;
                BarSeries2 = GetBars(BarType.Time, barSize);
            }
            else
            {
                Console.WriteLine("合约错误!" + Instrument);
            }

            sma = new SMA(spreadSeries, Length);

            Draw(spreadSeries, 2);
            Draw(sma, 2);
        }
Exemplo n.º 14
0
 public static BIAS create(BarSeries series, int length, BarData barData)
 {
     SMA sma = new SMA(series, length);
     return new BIAS(series, sma, length, barData);
 }
Exemplo n.º 15
0
Arquivo: code.cs Projeto: heber/FreeOQ
	public override void OnStrategyStart()
	{
		sma = new SMA(Bars, SMALength);
		sma.Color = Color.Yellow;
		Draw(sma, 0);

		// if required, set up the RAVI moving average
		if (FilterType == FilterType.RAVI)
		{
			shortSMA = new SMA(Bars, ShortSMALength);
			shortSMA.Color = Color.Pink;
			Draw(shortSMA, 0);
		}
		//if required, set up the ADX moving average 
		if (FilterType == FilterType.ADX)
		{
			// ADX is a builtin function, like SMA
			adx = new ADX(Bars, ADXLength);
			adx.Color = Color.Wheat;
			Draw(adx, 2);
		}
	}
Exemplo n.º 16
0
Arquivo: code.cs Projeto: heber/FreeOQ
	public override void OnStrategyStart()
	{
		sma = new SMA(Bars, Length, Color.Yellow);

		Draw(sma, 0);
	}