Пример #1
0
        /// <summary>
        /// This method is used to configure the strategy and is called once before any strategy method is called.
        /// </summary>
        protected override void Initialize()
        {
            CalculateOnBarClose = true;

            //zigzag
            zigZagHighSeries  = new DataSeries(this, MaximumBarsLookBack.Infinite);
            zigZagHighZigZags = new DataSeries(this, MaximumBarsLookBack.Infinite);
            zigZagLowSeries   = new DataSeries(this, MaximumBarsLookBack.Infinite);
            zigZagLowZigZags  = new DataSeries(this, MaximumBarsLookBack.Infinite);

            Add(PeriodType.Tick, 1);
            Add(PeriodType.Day, 1);

            historyData     = new HistoryData(SaveZigZagDaysOnHistory);
            dailyData       = new DailyData(Time[0]);
            zigZagDiapasone = new ZigZagDiapasone(5);
            onBarData       = new OnBarData(0);
            priceVolume     = new PriceVolume();
        }
Пример #2
0
 public OnBarData(int index)
 {
     BarIndex             = index;
     PriceVolumeOnBar     = new PriceVolume();
     LargestPriceOnVolume = GetMostLargePriceOfVolume();
 }
Пример #3
0
        protected override void OnBarUpdate()
        {
            if (BarsInProgress == 0)
            {
                Print("==============");
                smaLine = SMA(SMAPeriod)[0];
                Print("Day middleValot " + middleValot);
                Print("SMA Line -> " + smaLine);

                double procentOfMiddleValot = (middleValot / 100) * ProcentFromMiddleValot;

                lowLineRSIAnalog  = smaLine - procentOfMiddleValot;
                highLineRSIAnalog = smaLine + procentOfMiddleValot;

                Print("lowLineRSIAnalog " + lowLineRSIAnalog);
                Print("highLineRSIAnalog " + highLineRSIAnalog);
                Print(Time[0].ToString());


                OnBarUpdateMain();
                Print(Time[0].ToString());


                //onBarData.PriceVolumeList.AddPriceVolume(priceVolume);
                Print("Count PriceVolume: " + onBarData.PriceVolumeOnBar.VolumePriceOnBar.Count);
                foreach (KeyValuePair <double, double> a in onBarData.PriceVolumeOnBar.VolumePriceOnBar)
                {
                    string priceVolumeText = string.Format("Price: {0}, count: {1}", a.Key, a.Value);
                    Print(priceVolumeText);
                }

                dailyData.OnBarDataList.Add(onBarData);
                priceVolume = new PriceVolume();
                onBarData   = new OnBarData(CurrentBar);
            }

            if (BarsInProgress == 1)
            {
                double openPrice = Opens[1][0];

                _lastPrice = Price;
                Price      = openPrice;

                StopLossAndTakeProfit(Price);

                double volume = Volumes[1][0];
                onBarData.PriceVolumeOnBar.AddPriceVolume(Price, volume);
                double currentVolume = onBarData.PriceVolumeOnBar.VolumePriceOnBar[Price];

                bool isCanInputOrders = false;
                foreach (DailyData dailyData in historyData.DailyDataList)
                {
                    foreach (ZigZagDiapasone zigZag in dailyData.ZigZagDiapasoneList)
                    {
                        double averageVolume = dailyData.GetAveragePriceVolume(5);

                        Print("Price -> " + Price);
                        Print("zigZag.SellLevelWithPostTicks -> " + zigZag.SellLevelWithPostTicks);
                        Print("zigZag.BuyLevelWithPostTicks -> " + zigZag.BuyLevelWithPostTicks);

                        if (Price > zigZag.SellLevelWithPostTicks && Price < zigZag.HighZigZag)
                        {
                            if (currentVolume > averageVolume)
                            {
                                BuyOrSell(Price, _lastPrice, OrderAction.Sell);
                                Print("Test sell");
                            }
                        }
                        else
                        if (Price < zigZag.BuyLevelWithPostTicks && Price > zigZag.LowZigZag)
                        {
                            if (currentVolume > averageVolume)
                            {
                                BuyOrSell(Price, _lastPrice, OrderAction.Buy);
                                Print("Test buy");
                            }
                        }
                    }
                }

                //historyData.ZigZagDiapasoneList[1].
            }

            if (BarsInProgress == 2)
            {
                historyData.AddDaylyZigZag(dailyData);

                int count = dailyData.ZigZagDiapasoneList.Count;

                for (int i = 0; i < count; i++)
                {
                    Print("Level by Day ->   Index: " + i + " Sell Level: " + dailyData.ZigZagDiapasoneList[i].SellLevel + " Buy Level: " + dailyData.ZigZagDiapasoneList[i].BuyLevel);
                }


                dailyData = new DailyData(Time[0]);

                middleValot = 0;

                for (int i = 0; i < DayOfSMAValot; i++)
                {
                    middleValot = middleValot + Highs[2][i] - Lows[2][i];
                }
                middleValot = middleValot / DayOfSMAValot;
                Print("Day middleValot " + middleValot);
            }
        }
Пример #4
0
 private void SetPrice(out PriceVolume thePrice, IFIXGroup singleGroup)
 {
     int iVolume = singleGroup.get_AsNumber(FIXTagConstants.esFIXTagMDEntrySize);
     if (iVolume == 0)
     {
         thePrice = new PriceVolume(null, null);
     }
     else
         thePrice = new PriceVolume(iVolume, singleGroup.get_AsDouble(FIXTagConstants.esFIXTagMDEntryPx));
 }