Exemple #1
0
        //================================================================================
        public void LoadData(DataTable_candle candles)
        {
            DateTime dt       = DateTime.Now;
            DateTime prev_dt  = dt;
            DateTime delta_dt = dt;

            chart1.Series["Price"].Points.Clear();
            chart1.Series["Buy"].Points.Clear();
            //chart1.Series["Short"].Points.Clear();
            //chart1.Series["Cover"].Points.Clear();
            int count = period;

            bar_count = candles.Count;
            if (count > candles.Count)
            {
                count = candles.Count;
            }
            for (int i = 0; i < count; i++)
            {
                int            bar    = candles.Count - (count) + i;
                DataRow_candle candle = candles[bar];

                dt = candle.date;
                if (i == 0)
                {
                    //chart1.Series["Price"].Points.AddXY(dt, candle.high);
                    chart1.Series["Price"].Points.AddXY(1, candle.high);

                    chart1.Series["Buy"].Points.AddXY(1, candle.low * 0.9999);
                    //chart1.Series["Short"].Points.AddXY(1, candle.high * 1.0005);
                    //chart1.Series["Cover"].Points.AddXY(1, candle.low * 0.9999);
                }
                else
                {
                    //int mn = dt.Hour * 60 + dt.Minute;
                    //int prev_mn = prev_dt.Hour * 60 + prev_dt.Minute;
                    //int delta_mn = mn - prev_mn;
                    //if (mn < prev_mn) delta_mn = delta_mn + 1440;
                    //double xval = chart1.Series["Price"].Points[i-1].XValue + delta_mn / 1440.0;
                    double xval = chart1.Series["Price"].Points[i - 1].XValue + 1;
                    chart1.Series["Price"].Points.AddXY(i, candle.high);
                    chart1.Series["Price"].Points[i].XValue = xval;

                    chart1.Series["Buy"].Points.AddXY(i, candle.low * 0.9999);
                    chart1.Series["Buy"].Points[i].XValue = xval;
                    //chart1.Series["Short"].Points.AddXY(i, candle.high * 1.0005);
                    //chart1.Series["Short"].Points[i].XValue = xval;
                    //chart1.Series["Cover"].Points.AddXY(i, candle.low * 0.9999);
                    //chart1.Series["Cover"].Points[i].XValue = xval;
                }
                chart1.Series["Price"].Points[i].YValues[1] = candle.low;
                chart1.Series["Price"].Points[i].YValues[3] = candle.open;
                chart1.Series["Price"].Points[i].YValues[2] = candle.close;
                prev_dt = dt;
            }
        }
Exemple #2
0
 //--------------------------------------------------------------------------------
 public DataSet_tslight() :
     base()
 {
     t_security            = new DataTable_security();
     t_timeframe           = new DataTable_timeframe();
     t_candle              = new DataTable_candle();
     t_my_securities       = new DataTable_security();
     t_my_takingPositions  = new DataTable_order();
     t_my_ClosingPositions = new DataTable_stopOrder();
 }
Exemple #3
0
        //================================================================================
        public void Handle(DataTable_candle Candles)
        {
            double   price;
            double   vEMA1 = Candles[0].close;
            double   vEMA2 = Candles[0].close;
            double   pEMA1 = vEMA1;
            double   pEMA2 = vEMA2;
            DateTime zdt   = DateTime.Parse("01.01.2000");

            BuyDT   = zdt;
            SellDT  = zdt;
            ShortDT = zdt;
            CoverDT = zdt;

            nBuy.Clear();
            nSell.Clear();
            nShort.Clear();
            nCover.Clear();

            for (int bar = 0; bar < Candles.Count - 1; bar++)
            {
                PrevLongPos  = LongPos;
                PrevShortPos = ShortPos;

                price = Candles[bar].close;
                vEMA1 = vEMA1 + (price - vEMA1) / period1;
                vEMA2 = vEMA2 + (price - vEMA2) / period2;

                if (vEMA1 > vEMA2 && pEMA1 <= pEMA2)
                {
                    if (!LongPos)
                    {
                        LongPos = true;
                        BuyDT   = Candles[bar].date;
                        nBuy.Add(bar + 1);
                    }
                    if (ShortPos)
                    {
                        ShortPos = false;
                        CoverDT  = Candles[bar].date;
                        nCover.Add(bar + 1);
                    }
                }
                if (vEMA1 < vEMA2 && pEMA1 >= pEMA2)
                {
                    if (LongPos)
                    {
                        LongPos = false;
                        SellDT  = Candles[bar].date;
                        nSell.Add(bar + 1);
                    }
                    if (!ShortPos)
                    {
                        ShortPos = true;
                        ShortDT  = Candles[bar].date;
                        nShort.Add(bar + 1);
                    }
                }

                pEMA1  = vEMA1;
                pEMA2  = vEMA2;
                LastDT = Candles[bar].date;
            }
        }
Exemple #4
0
 //--------------------------------------------------------------------------------
 internal DataRow_candle(global::System.Data.DataRowBuilder rb) :
     base(rb)
 {
     table = (DataTable_candle)Table;
 }