Example #1
0
        protected override void Initialize()
        {
            // Summary
            YesterdayKeyLevels = Business.KeyLevels.GetYesterdaysKeyLevels(Account.BrokerName, Symbol.Code);

            if (YesterdayKeyLevels != null)
            {
                YesterdayKeyLevels.CalculateDaily();

                // Write Summary
                string Summary = Symbol.Code.ToString() + ": Yesterday's (" + YesterdayKeyLevels.Date.ToShortDateString() + ") Open: " + YesterdayKeyLevels.Open.ToString() + ", Close: " + YesterdayKeyLevels.Close.ToString() + ", High: " + YesterdayKeyLevels.High.ToString() + ", Low: " + YesterdayKeyLevels.Low.ToString();
                ChartObjects.DrawText("Previous", Summary, StaticPosition.BottomRight, Colors.Red);

                // Calculate ATR
                var ATRSeries        = MarketData.GetSeries(TimeFrame.Daily);
                AverageTrueRange ATR = Indicators.AverageTrueRange(ATRSeries, 5, MovingAverageType.Simple);
                ChartObjects.DrawText("ATR", "ATR: " + ATR.Result.LastValue.ToString("0.##") + ", 15% ATR: " + (ATR.Result.LastValue * 0.15).ToString("0.##") + ",30% ATR: " + (ATR.Result.LastValue * 0.3).ToString("0.##") + "", StaticPosition.TopRight, Colors.Red);

                // DAILY
                //  ChartObjects.DrawHorizontalLine("DailyHigh", YesterdayKeyLevels.High,  Colors.Green, 1, LineStyle.LinesDots);
                //  ChartObjects.DrawHorizontalLine("DailyLow", YesterdayKeyLevels.Low, Colors.Green, 1, LineStyle.LinesDots);
                // ChartObjects.DrawHorizontalLine("DailyCLose", YesterdayKeyLevels.Close, Colors.Green, 1, LineStyle.LinesDots);



                // Daily Levels

                P = ((YesterdayKeyLevels.High + YesterdayKeyLevels.Low + YesterdayKeyLevels.Close) / 3);

                R1 = ((2 * P) - YesterdayKeyLevels.Low);
                R2 = (P + YesterdayKeyLevels.High - YesterdayKeyLevels.Low);
                R3 = (YesterdayKeyLevels.High + 2 * (P - YesterdayKeyLevels.Low));

                S1 = ((2 * P) - YesterdayKeyLevels.High);
                S2 = (P - YesterdayKeyLevels.High + YesterdayKeyLevels.Low);
                S3 = YesterdayKeyLevels.Low - 2 * (YesterdayKeyLevels.High - P);

                CBOL = ((YesterdayKeyLevels.High - YesterdayKeyLevels.Low) * 1.1 / 2 + YesterdayKeyLevels.Close);
                CBOS = YesterdayKeyLevels.Close - (YesterdayKeyLevels.High - YesterdayKeyLevels.Low) * 1.1 / 2;



                //WP = ((WeeklyHigh + WeeklyLow + WeeklyClose) / 3);
                //MP = ((MonthlyHigh + MonthlyLow + MonthlyClose) / 3);



                // WEEKLY
                // ChartObjects.DrawHorizontalLine("WeeklyHigh", WeeklyHigh, Colors.Green, 1, LineStyle.Lines);
                //ChartObjects.DrawHorizontalLine("WeeklyLow", WeeklyLow, Colors.Red, 1, LineStyle.Lines);
                //   ChartObjects.DrawHorizontalLine("WeeklyClose", WeeklyClose, Colors.DeepSkyBlue, 1, LineStyle.LinesDots);


                // MONTHLY
                //ChartObjects.DrawHorizontalLine("MonthlyHigh", MonthlyHigh, Colors.Green, 3, LineStyle.Lines);
                //ChartObjects.DrawHorizontalLine("MonthlyLow", MonthlyLow, Colors.Red, 3, LineStyle.Lines);
                //   ChartObjects.DrawHorizontalLine("MonthlyClose", MonthlyClose, Colors.DarkGray, 1, LineStyle.LinesDots);
            }
        }