示例#1
0
        /// <summary>
        /// Executes every tick. Put your core logic here.
        /// </summary>
        protected override void OnTick()
        {
            // Ticks are 100-ns intervals elapsed since January 1, 0001 at 00:00:00.000 in the Gregorian calendar.
            DateTime serverTime = Server.Time;

            using (NpgsqlCommand cmd = new NpgsqlCommand())
            {
                cmd.Connection  = dbConn;
                cmd.CommandText = "INSERT INTO " + dbSchema + "." + Symbol.Code + " (utc, tick, ask, bid, spread) VALUES (:utc, :tick, :ask, :bid, :spread)";
                cmd.Parameters.AddWithValue(":utc", NpgsqlTypes.NpgsqlDbType.Timestamp, serverTime.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                cmd.Parameters.AddWithValue(":tick", serverTime.Ticks);
                cmd.Parameters.AddWithValue(":ask", Symbol.Ask);
                cmd.Parameters.AddWithValue(":bid", Symbol.Bid);
                cmd.Parameters.AddWithValue(":spread", Symbol.Spread);
                cmd.ExecuteNonQuery();
            }
            //
            // -- ON SCREEN DIAGNOSTICS --
            //
            // Index of the last/newest bar on chart
            int barLast = MarketSeries.OpenTime.GetIndexByTime(MarketSeries.OpenTime.LastValue);

            ChartObjects.DrawText("barLast", (barLast).ToString(), barLast, MarketSeries.High.LastValue + 0.0001);
            // Diagnostic text
            ++diagTicks;
            if (diagTicks >= 4)
            {
                diagTicks = 0;
            }
            char ctick;

            switch (diagTicks)
            {
            case 0:
                ctick = '-';
                break;

            case 1:
                ctick = '\\';
                break;

            case 2:
                ctick = '|';
                break;

            case 3:
                ctick = '/';
                break;

            default:
                ctick = '.';
                break;
            }
            string msg = diagTicks.ToString() + " " + ctick + Environment.NewLine;

            msg = msg + Symbol.Code + ">" + " Ask: " + Symbol.Ask.ToString("0.00000") + " Bid: " + Symbol.Bid.ToString("0.00000") + " Spread: " + Symbol.Spread.ToString("0.00000") + Environment.NewLine;
            ChartObjects.DrawText("diaginfo", msg, StaticPosition.TopLeft);
        }
示例#2
0
        public void WriteFullReport(IEnumerable <MeasurementsYear> measurements, string path)
        {
            Application xlApp;
            Workbook    xlWorkBook;
            dynamic     xlWorkSheet;
            object      misValue = System.Reflection.Missing.Value;

            xlApp       = new Application();
            xlWorkBook  = xlApp.Workbooks.Add(misValue);
            xlWorkSheet = (Worksheet)xlWorkBook.Worksheets.get_Item(1);

            var measurementsList = measurements.ToList();

            for (int i = 0; i < measurements.Count(); i++)
            {
                xlWorkSheet.Cells[1, i + 2] = measurementsList[i].Year;
            }

            xlWorkSheet.Cells[2, 1] = "schaner";
            xlWorkSheet.Cells[3, 1] = "fevrer";
            xlWorkSheet.Cells[4, 1] = "mart";
            xlWorkSheet.Cells[5, 1] = "avrel";

            xlWorkSheet.Cells[6, 1] = "matg";
            xlWorkSheet.Cells[7, 1] = "zercladur";
            xlWorkSheet.Cells[8, 1] = "fenadur";
            xlWorkSheet.Cells[9, 1] = "uost";

            xlWorkSheet.Cells[10, 1] = "setember";
            xlWorkSheet.Cells[11, 1] = "october";
            xlWorkSheet.Cells[12, 1] = "november";
            xlWorkSheet.Cells[13, 1] = "december";

            Range chartRange;

            var to       = this.map[measurements.Count() + 1];
            var toString = string.Format("{0}13", to);

            var writeRange = xlWorkSheet.Range("B2", toString);

            writeRange.Value2 = CreateValuesMatrixAsNumber(measurements.ToList());
            ChartObjects xlCharts  = (ChartObjects)xlWorkSheet.ChartObjects(Type.Missing);
            ChartObject  myChart   = (ChartObject)xlCharts.Add(10, 80, 300, 250);
            Chart        chartPage = myChart.Chart;

            chartRange = xlWorkSheet.Range("A1", toString);
            chartPage.SetSourceData(chartRange, misValue);

            ChartSettings.Configure(chartPage);

            xlWorkBook.SaveAs(string.Format("{0}\\test.xlsx", path));
            xlWorkBook.Close(true, misValue, misValue);
            xlApp.Quit();

            releaseObject(xlWorkSheet);
            releaseObject(xlWorkBook);
            releaseObject(xlApp);
        }
示例#3
0
        public override void Calculate(int index)
        {
            DataSeries ds;
            double     lowPrice = double.MaxValue;

            for (int i = 0; i < numBars; i++)
            {
                if (MarketSeries.Low.Last(i) < lowPrice)
                {
                    lowPrice = MarketSeries.Low.Last(i);
                }
            }

            totalColor = Colors.White;

            int[,] values = new int[numBars, scores.Length + 1];
            //MarketSeries currentSeries = MarketSeries.
            for (int bar = 0; bar < numBars; bar++)
            {
                for (int i = 0; i < timeframes.Length; i++)
                {
                    ds = MarketData.GetSeries(timeframes[i]).Open;
                    int convertedIndex = MarketData.GetSeries(timeframes[i]).OpenTime.GetIndexByTime(MarketData.GetSeries(this.TimeFrame).OpenTime[index - bar]);
                    WMAsmall = Indicators.MovingAverage(ds, WMAsmallnum, MAType);
                    WMAbig   = Indicators.MovingAverage(ds, WMAbignum, MAType);

                    if (WMAsmall.Result[convertedIndex] > WMAbig.Result[convertedIndex])
                    {
                        values[bar, scores.Length] += scores[i];
                        values[bar, i]              = scores[i];
                        totalColor = Colors.Green;
                    }
                    else
                    {
                        values[bar, scores.Length] -= scores[i];
                        values[bar, i]              = -1 * scores[i];
                        totalColor = Colors.Red;
                    }
                    ChartObjects.DrawText("ScoreValue" + bar + "" + i, "■", index - bar, lowPrice - i * scale * Symbol.PipSize, VerticalAlignment.Bottom, HorizontalAlignment.Center, totalColor);
                    if (bar == numBars - 1)
                    {
                        totalColor = getColor(values[0, i], false);
                        ChartObjects.DrawText("Labels" + bar + "" + i, timeStrings[i], index + 1, lowPrice - i * scale * Symbol.PipSize, VerticalAlignment.Bottom, HorizontalAlignment.Center, totalColor);
                    }

                    if (i == timeframes.Length - 1)
                    {
                        totalColor = getColor(values[bar, scores.Length], true);
                        ChartObjects.DrawText("FinalScoreValue" + bar + "" + i, "" + values[bar, scores.Length], index - bar, lowPrice - (i + 1) * scale * Symbol.PipSize, VerticalAlignment.Bottom, HorizontalAlignment.Center, totalColor);
                        if (bar == numBars - 1)
                        {
                            totalColor = getColor(values[0, scores.Length], true);
                            ChartObjects.DrawText("ScoreLabel" + bar + "" + i, "#", index + 1, lowPrice - (i + 1) * scale * Symbol.PipSize, VerticalAlignment.Bottom, HorizontalAlignment.Center, totalColor);
                        }
                    }
                }
            }
        }
示例#4
0
        private void LinearRegression(DataSeries series)
        {
            // Linear regresion

            double sum_x = 0, sum_x2 = 0, sum_y = 0, sum_xy = 0;

            int start = series.Count - Bars;
            int end   = series.Count - 1;

            for (int i = start; i <= end; i++)
            {
                sum_x  += 1.0 * i;
                sum_x2 += 1.0 * i * i;
                sum_y  += series[i];
                sum_xy += series[i] * i;
            }

            double a = (Bars * sum_xy - sum_x * sum_y) / (Bars * sum_x2 - sum_x * sum_x);
            double b = (sum_y - a * sum_x) / Bars;


            // Calculate maximum and standard devaitions

            double maxDeviation = 0;
            double sumDevation  = 0;

            for (int i = start; i <= end; i++)
            {
                double price = a * i + b;
                maxDeviation = Math.Max(Math.Abs(series[i] - price), maxDeviation);
                sumDevation += Math.Pow(series[i] - price, 2.0);
            }

            double stdDeviation = Math.Sqrt(sumDevation / Bars);

            // draw in future
            end += 20;

            double pr1 = a * start + b;
            double pr2 = a * end + b;

            if (ShowCenter)
            {
                ChartObjects.DrawLine("center", start, pr1, end, pr2, color, LineThickness, LineStyle.Lines);
            }

            if (ShowChannel)
            {
                ChartObjects.DrawLine("top", start, pr1 + maxDeviation, end, pr2 + maxDeviation, color, LineThickness, LineStyle.Solid);
                ChartObjects.DrawLine("bottom", start, pr1 - maxDeviation, end, pr2 - maxDeviation, color, LineThickness, LineStyle.Solid);
            }

            if (ShowDeviantion)
            {
                ChartObjects.DrawLine("dev-top", start, pr1 + stdDeviation, end, pr2 + stdDeviation, color, LineThickness, LineStyle.DotsVeryRare);
                ChartObjects.DrawLine("dev-bottom", start, pr1 - stdDeviation, end, pr2 - stdDeviation, color, LineThickness, LineStyle.DotsVeryRare);
            }
        }
示例#5
0
        protected override void OnStart()
        {
            state = new State(TFrame);

            lseries = new Dictionary <string, MarketSeries>();
            rseries = new Dictionary <string, MarketSeries>();

            lmm6   = new Dictionary <string, ExponentialMovingAverage>();
            lmm18  = new Dictionary <string, ExponentialMovingAverage>();
            lmm50  = new Dictionary <string, ExponentialMovingAverage>();
            lmm100 = new Dictionary <string, ExponentialMovingAverage>();
            rmm100 = new Dictionary <string, ExponentialMovingAverage>();

            lmm200 = new Dictionary <string, SimpleMovingAverage>();
            rmm200 = new Dictionary <string, SimpleMovingAverage>();

            lmacd = new Dictionary <string, MacdCrossOver>();
            rmacd = new Dictionary <string, MacdCrossOver>();

            spaths = new Dictionary <string, string>(3);
            spaths.Add("MACD", "C:\\Users\\Andrey\\Music\\Sounds\\sms-alert-1.wav");
            spaths.Add("ACC", "C:\\Users\\Andrey\\Music\\Sounds\\sms-alert-4.wav");
            spaths.Add("VCN", "C:\\Users\\Andrey\\Music\\Sounds\\sms-alert-3.wav");

            Print("Initializing screener local state.");

            foreach (var sym in symbols)
            {
                Print("Initializing data for: {0}/{1}.", sym, TFrame);

                var reftf = GetReferenceTimeframe(TFrame);
                var lmks  = MarketData.GetSeries(sym, TFrame);
                var rmks  = MarketData.GetSeries(sym, reftf);

                lmm6[sym]  = Indicators.ExponentialMovingAverage(lmks.Close, 6);
                lmm18[sym] = Indicators.ExponentialMovingAverage(lmks.Close, 18);

                lmm50[sym]  = Indicators.ExponentialMovingAverage(lmks.Close, 50);
                lmm100[sym] = Indicators.ExponentialMovingAverage(lmks.Close, 100);
                rmm100[sym] = Indicators.ExponentialMovingAverage(rmks.Close, 100);

                lmm200[sym] = Indicators.SimpleMovingAverage(lmks.Close, 200);
                rmm200[sym] = Indicators.SimpleMovingAverage(rmks.Close, 200);

                lmacd[sym] = Indicators.MacdCrossOver(lmks.Close, 26, 12, 9);
                rmacd[sym] = Indicators.MacdCrossOver(rmks.Close, 26, 12, 9);

                lseries[sym] = lmks;
                rseries[sym] = rmks;
            }

            Print("Initialization finished.");
            var output = state.Render();

            ChartObjects.RemoveObject("screener");
            ChartObjects.DrawText("screener", output, StaticPosition.TopLeft, Colors.Black);
        }
示例#6
0
 public override void Calculate(int index)
 {
     if (EnableTrendLines)
     {
         for (int i = 0; i < PreviousBars; i++)
         {
             if (wma.Result.Last(i) >= wma.Result.Last(i + 1))
             {
                 double high   = double.MinValue;
                 double offset = 0;
                 for (int j = i; j < PreviousBars; j++)
                 {
                     if (MarketSeries.High.Last(j) > high)
                     {
                         high   = MarketSeries.High.Last(j);
                         offset = high - wma.Result.Last(j);
                     }
                     if (wma.Result.Last(j) <= wma.Result.Last(j + 1))
                     {
                         ChartObjects.DrawLine("trend" + i, index - i, wma.Result.Last(i), index - j, wma.Result.Last(j), Colors.Green, 2, LineStyle.Solid);
                         if (EnableTrendChannel)
                         {
                             //ChartObjects.DrawLine("trendhigh" + i, index - i, wma.Result.Last(i) + offset, index - j, wma.Result.Last(j) + offset, Colors.White, 1, LineStyle.Solid);
                             ChartObjects.DrawLine("trendlow" + i, index - i, wma.Result.Last(i) - offset, index - j, wma.Result.Last(j) - offset, Colors.White, 1, LineStyle.DotsRare);
                         }
                         i = j;
                         break;
                     }
                 }
             }
             else if (wma.Result.Last(i) <= wma.Result.Last(i + 1))
             {
                 double low    = double.MaxValue;
                 double offset = 0;
                 for (int j = i; j < PreviousBars; j++)
                 {
                     if (MarketSeries.Low.Last(j) < low)
                     {
                         low    = MarketSeries.Low.Last(j);
                         offset = wma.Result.Last(j) - low;
                     }
                     if (wma.Result.Last(j) >= wma.Result.Last(j + 1))
                     {
                         ChartObjects.DrawLine("trend" + i, index - i, wma.Result.Last(i), index - j, wma.Result.Last(j), Colors.Red, 2, LineStyle.Solid);
                         if (EnableTrendChannel)
                         {
                             ChartObjects.DrawLine("trendhigh" + i, index - i, wma.Result.Last(i) + offset, index - j, wma.Result.Last(j) + offset, Colors.White, 1, LineStyle.DotsRare);
                             //ChartObjects.DrawLine("trendlow" + i, index - i, wma.Result.Last(i) - offset, index - j, wma.Result.Last(j) - offset, Colors.White, 1, LineStyle.Solid);
                         }
                         i = j;
                         break;
                     }
                 }
             }
         }
     }
 }
示例#7
0
        public override void Calculate(int index)
        {
            if (_incorrectColors)
            {
                var errorColor = _random.Next(2) == 0 ? Colors.Red : Colors.White;
                ChartObjects.DrawText("Error", "Incorrect colors", StaticPosition.Center, errorColor);
                return;
            }
            if ((Server.Time.Minute == 4 || Server.Time.Minute == 9 || Server.Time.Minute == 14 || Server.Time.Minute == 19 || Server.Time.Minute == 24 || Server.Time.Minute == 29 || Server.Time.Minute == 34 || Server.Time.Minute == 39 || Server.Time.Minute == 44 || Server.Time.Minute == 49 || Server.Time.Minute == 54 || Server.Time.Minute == 59) && Server.Time.Second > 55)
            {
                var open  = MarketSeries.Open[index];
                var high  = MarketSeries.High[index];
                var low   = MarketSeries.Low[index];
                var close = MarketSeries.Close[index];

                var open1  = MarketSeries.Open[index - 1];
                var high1  = MarketSeries.High[index - 1];
                var low1   = MarketSeries.Low[index - 1];
                var close1 = MarketSeries.Close[index - 1];

                var open2  = MarketSeries.Open[index - 2];
                var high2  = MarketSeries.High[index - 2];
                var low2   = MarketSeries.Low[index - 2];
                var close2 = MarketSeries.Close[index - 2];

                var open3  = MarketSeries.Open[index - 3];
                var high3  = MarketSeries.High[index - 3];
                var low3   = MarketSeries.Low[index - 3];
                var close3 = MarketSeries.Close[index - 3];

                var open4  = MarketSeries.Open[index - 4];
                var high4  = MarketSeries.High[index - 4];
                var low4   = MarketSeries.Low[index - 4];
                var close4 = MarketSeries.Close[index - 4];

                Close = close;
                double Open;
                if (index > 0)
                {
                    Open = open4;
                }
                else
                {
                    Open = open4;
                }

                High = Math.Max(Math.Max(Math.Max(Math.Max(high, high1), high2), high3), high4);
                Low  = Math.Min(Math.Min(Math.Min(Math.Min(low, low1), low2), low3), low4);

                var color = Open > Close ? _downColor : _upColor;
                ChartObjects.DrawLine("candle" + index, index, Open, index, Close, color, CandleWidth, LineStyle.Solid);
                ChartObjects.DrawLine("line" + index, index, High, index, Low, color, 1, LineStyle.Solid);

                _Open[index]  = Open;
                _Close[index] = Close;
            }
        }
示例#8
0
        //END FUNCTION
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        private void Draw_OnChart_C2(string t_Text, int Line_No, int Tab_Pos)
        {
            //CREATE A UNIQUE OBJECT NAME FOR THE METHOD ChartObjects.DrawText
            string tstr_1 = "";

            tstr_1 = Line_No.ToString() + Tab_Pos.ToString();

            ChartObjects.DrawText(tstr_1, my_NL(Line_No) + my_Tabs(Tab_Pos) + t_Text, StaticPosition.TopLeft, Colors.Beige);
        }
示例#9
0
        private void GenerateByClient()
        {
            workSheet_range = xlWorkSheet.Range["A23:C23"];

            //columns heading

            // xlWorkSheet.Range["A60"].Value = "TOTAL CLIENT";
            xlWorkSheet.Range["A23"].Value = "TOTAL CLIENT";
            xlWorkSheet.Range["B23"].Value = "PASS";
            xlWorkSheet.Range["C23"].Value = "FAIL";


            //format headings
            workSheet_range.Font.Bold           = true;
            workSheet_range.Interior.Color      = ColorTranslator.FromHtml(HelperClass.excelSummHeaderBackgound);
            workSheet_range.Font.Color          = ColorTranslator.FromHtml(HelperClass.excelSummHeaderFontColor);
            workSheet_range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;
            workSheet_range.WrapText            = true;
            clientCount = ExecutionSession.lstClient.Count();
            int count = 0;

            foreach (clientList ClientList in ExecutionSession.lstClient)
            {
                if (ExecutionSession.lstExecutedTestCases.Where(testcase => testcase.Status == OverAllResult.FAIL && testcase.clientUrl == ClientList.clientUrl).Count() > 0)
                {
                    count++;
                }
            }
            xlWorkSheet.Range["A24"].Value = clientCount;
            xlWorkSheet.Range["B24"].Value = clientCount - count;
            xlWorkSheet.Range["C24"].Value = count;
            PrevRepData.Add((clientCount - count).ToString());
            PrevRepData.Add(count.ToString());
            PrevRepData.Add(now.ToString("d"));

            workSheet_range = xlWorkSheet.Range["A24", "C24"];
            workSheet_range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;
            workSheet_range.Borders.Color       = System.Drawing.Color.Black.ToArgb();
            workSheet_range.WrapText            = true;

            myCharts   = xlWorkSheet.ChartObjects(Type.Missing);
            myCharts1  = myCharts.Add(340, 320, 370, 210);
            oChart     = myCharts1.Chart;
            chartRange = xlWorkSheet.Range["B23", "C24"];
            oChart.SetSourceData(chartRange);
            oChart.PlotBy    = XlRowCol.xlRows;
            oChart.ChartType = XlChartType.xl3DPie;
            oChart.ApplyDataLabels(XlDataLabelsType.xlDataLabelsShowPercent);
            oChart.HasLegend       = true;
            oChart.HasTitle        = true;
            oChart.ChartTitle.Text = "Current client summary report";

            string overAllPieChartPath = summaryChartsFolder + "\\ClientSummaryReport.jpg";

            oChart.Export(overAllPieChartPath, "jpg", Missing.Value);
        }
示例#10
0
        public override void Calculate(int index)
        {
            Result[index]  = _result.Result[index] / Symbol.PipSize / Magnify;
            Average[index] = _average.Result[index] / Symbol.PipSize / Magnify;

            #region Chart
            BarsAgo = GetBarsAgo(index);
            ChartObjects.DrawText("barsago", "Cross_(" + BarsAgo.ToString() + ")", StaticPosition.TopLeft, _nocorel);
            #endregion
        }
示例#11
0
 private void ShowCopy(string txt = "")
 {
     //var spread = Math.Round(Symbol.Spread / Symbol.PipSize, 2);
     //string text = string.Format("{0}", spread);
     if (txt != "")
     {
         ChartObjects.DrawText("Label", "Copy positions:", StaticPosition.TopLeft, Colors.Yellow);
         ChartObjects.DrawText("Position: ", "\t" + txt, StaticPosition.TopLeft, Colors.Red);
     }
 }
示例#12
0
        private void DrawTrendLine(string lineName, int startIndex, int endIndex, int index1, double value1, int index2, double value2)
        {
            double gradient = (value2 - value1) / (index2 - index1);

            double startValue = value1 + (startIndex - index1) * gradient;
            double endValue   = value1 + (endIndex - index1) * gradient;

            ChartObjects.DrawLine(lineName, startIndex, startValue, endIndex, endValue, Colors.Gray);
            ChartObjects.DrawLine(lineName + "_red", index1, value1, index2, value2, Colors.Red);
        }
示例#13
0
        private void ShowOutput(Symbol symbol, IndicatorDataSeries result, MovingAverage movingAverage, MarketSeries series, int index)
        {
            var index2 = series.OpenTime.GetIndexByTime(MarketSeries.OpenTime[index]);

            result[index] = movingAverage.Result[index2];

            string text = string.Format("{0} {1}", symbol.Code, Math.Round(result[index], symbol.Digits));

            ChartObjects.DrawText(symbol.Code, text, index, result[index], VerticalAlignment.Top, HorizontalAlignment.Right, Colors.Yellow);
        }
示例#14
0
        private void DisplayPositionSizeRiskOnChart()
        {
            double costPerPip = (double)((int)(Symbol.PipValue * 10000000)) / 100;

            double positionSizeForRisk = (Account.Balance * stopLossRiskPercent / 100) / (stopLossInPips * costPerPip);

            string text = stopLossRiskPercent + "% x " + stopLossInPips + "pip = " + Math.Round(positionSizeForRisk, 2) + " lot";

            ChartObjects.DrawText("positionRisk", text, StaticPosition.TopRight, Colors.Yellow);
        }
        private void WritetoChart()
        {
            // -- TOP LEFT OUTPUT
            string chartTL = "";

            chartTL += "" + pairID + " POSITIONS";
            chartTL += "\n Pos: " + totPositions;
            chartTL += "\n Vol: " + totPosVol;
            chartTL += "\n Qty: " + Symbol.VolumeToQuantity(totPosVol) + " lots";
            chartTL += "\n Gain: " + Math.Round((totPosGain / Account.Balance) * 100, 2) + "% \n\n\n";
            ChartObjects.DrawText("TopLeft", chartTL, StaticPosition.BottomRight);

            // -- TOP CENTER OUTPUT
            string chartTC = "Spread: " + SpreadinPips + " pips";

            ChartObjects.DrawText("TopCenter", chartTC.PadRight(5), StaticPosition.BottomRight, Colors.MediumPurple);

            // -- TOP RIGHT OUTPUT
            double dd       = Math.Round(((Account.Equity / Account.Balance) * 100) - 100, 2);
            Colors dd_color = Colors.Green;

            if (dd < -15)
            {
                dd_color = Colors.Red;
            }
            else if (dd < -10)
            {
                dd_color = Colors.OrangeRed;
            }
            else if (dd < 0)
            {
                dd_color = Colors.Orange;
            }


            string chartTR = "Draw Down: " + dd + "%";

            ChartObjects.DrawText("DD", chartTR.PadRight(5), StaticPosition.TopRight, dd_color);

            string cR1 = "\n\n-----------------------------\n";

            cR1 += "Intraday Risk: " + S1_RiskPercent + "%";
            cR1 += "\n" + String.Format("{0:C}", Account.Balance * (S1_RiskPercent * 0.01));
            ChartObjects.DrawText("TR1", cR1.PadRight(5), StaticPosition.TopRight, Colors.Goldenrod);

            string cR2 = "\n\n\n\n\n-----------------------------\nSniper Risk: " + S2_RiskPercent + "%";

            cR2 += "\n" + String.Format("{0:C}", Account.Balance * (S2_RiskPercent * 0.01));
            ChartObjects.DrawText("TR2", cR2.PadRight(5), StaticPosition.TopRight, Colors.Orange);

            string cR3 = "\n\n\n\n\n\n\n\n-----------------------------\nInvest Risk: " + S3_RiskPercent + "%";

            cR3 += "\n" + String.Format("{0:C}", Account.Balance * (S3_RiskPercent * 0.01));
            ChartObjects.DrawText("TR3", cR3.PadRight(5), StaticPosition.TopRight);
        }
示例#16
0
        public static void SaveDataToExcel(string path, Variable[] variables)
        {
            Application xlApp;
            Workbook    wbook;
            Worksheet   wsheet;

            xlApp  = new Application();
            wbook  = xlApp.Workbooks.Add(Missing.Value);
            wsheet = wbook.ActiveSheet;

            ChartObjects xlCharts  = wsheet.ChartObjects(Type.Missing);
            ChartObject  chart     = xlCharts.Add(10, 80, 300, 250);
            Chart        chartPage = chart.Chart;

            chartPage.ChartType = XlChartType.xlLine;
            SeriesCollection collection = chartPage.SeriesCollection();

            int col = 1;

            for (int i = 0; i < variables.Length; i++)
            {
                if (variables[i].plotValues.Count == 0)
                {
                    continue;
                }

                wsheet.Cells[1, col]     = "Time";
                wsheet.Cells[1, col + 1] = variables[i].name;

                for (int j = 0; j < variables[i].plotValues.Count; j++)
                {
                    wsheet.Cells[j + 2, col]     = variables[i].plotValues[j].X;
                    wsheet.Cells[j + 2, col + 1] = variables[i].plotValues[j].Y;
                }

                Series s = collection.NewSeries();
                s.Smooth  = true;
                s.Name    = variables[i].name;
                s.XValues = wsheet.Range[VecToCell(col, 2), VecToCell(col, variables[i].plotValues.Count + 1)];
                s.Values  = wsheet.Range[VecToCell(col + 1, 2), VecToCell(col + 1, variables[i].plotValues.Count + 1)];

                int color = colorToRGB(variables[i].plotColor);
                s.Format.Line.ForeColor.RGB = color;

                col += 3;
            }

            wsheet.SaveAs(path);
            wbook.Close(true, Missing.Value, Missing.Value);
            xlApp.Quit();

            Marshal.ReleaseComObject(wsheet);
            Marshal.ReleaseComObject(wbook);
            Marshal.ReleaseComObject(xlApp);
        }
示例#17
0
 private void AnimateWarning()
 {
     if (tickCount++ % 2 == 0)
     {
         ChartObjects.DrawText("warning", "Please specify the Price", StaticPosition.Center, Colors.Red);
     }
     else
     {
         ChartObjects.DrawText("warning", "Please specify the Price", StaticPosition.Center, Colors.White);
     }
 }
示例#18
0
 public Mq4OutputDataSeries(ZigZagKwanIndicator zigzagKwanMBFXTiming, IndicatorDataSeries outputDataSeries, ChartObjects chartObjects, int style, int bufferIndex, Func <IndicatorDataSeries> dataSeriesFactory, int lineWidth, Colors?color = null)
 {
     OutputDataSeries = outputDataSeries;
     _chartObjects    = chartObjects;
     _style           = style;
     _bufferIndex     = bufferIndex;
     _indicator       = zigzagKwanMBFXTiming;
     Color            = color;
     _originalValues  = dataSeriesFactory();
     LineWidth        = lineWidth;
 }
示例#19
0
        public void drawLines(int index, int[] values)
        {
            ChartObjects.DrawLine("topline", index - width, Symbol.Bid, index, Symbol.Bid, totalColor, 1, LineStyle.Solid);

            for (int i = 0; i < scores.Length + 2; i++)
            {
                ChartObjects.DrawLine("line" + i, index - i * width / 7, Symbol.Bid, index - i * width / 7, Symbol.Bid - height * Symbol.PipSize, totalColor, 1, LineStyle.Solid);
            }

            ChartObjects.DrawLine("bottomline", index - width, Symbol.Bid - height * Symbol.PipSize, index, Symbol.Bid - height * Symbol.PipSize, totalColor, 1, LineStyle.Solid);


            for (int i = 0; i < scores.Length; i++)
            {
                Colors color = Colors.Red;
                if (values[i] > 0)
                {
                    color = Colors.Green;
                    ChartObjects.DrawText(timeframes[i].ToString() + "Value", "+" + values[i], index - (i + 2) * width / 7 + width / 14, Symbol.Bid - height * Symbol.PipSize, VerticalAlignment.Top, HorizontalAlignment.Center, color);
                }
                else if (values[i] < 0)
                {
                    color = Colors.Red;
                    ChartObjects.DrawText(timeframes[i].ToString() + "Value", "" + values[i], index - (i + 2) * width / 7 + width / 14, Symbol.Bid - height * Symbol.PipSize, VerticalAlignment.Top, HorizontalAlignment.Center, color);
                }
                else
                {
                    color = Colors.White;
                    ChartObjects.DrawText(timeframes[i].ToString() + "Value", "" + values[i], index - (i + 2) * width / 7 + width / 14, Symbol.Bid - height * Symbol.PipSize, VerticalAlignment.Top, HorizontalAlignment.Center, color);
                }
                ChartObjects.DrawText(timeframes[i].ToString() + "Text", timeframes[i].ToString(), index - (i + 2) * width / 7 + width / 14, Symbol.Bid, VerticalAlignment.Bottom, HorizontalAlignment.Center, color);
            }
            ChartObjects.DrawText("ScoreText", "Score", index - 1 * width / 7 + width / 14, Symbol.Bid, VerticalAlignment.Bottom, HorizontalAlignment.Center, Colors.White);
            int sum = 0;

            foreach (int i in values)
            {
                sum += i;
            }
            totalColor = Colors.Red;
            if (sum >= threshold)
            {
                totalColor = Colors.Green;
            }
            else if (sum <= threshold * (-1))
            {
                totalColor = Colors.Red;
            }
            else
            {
                totalColor = Colors.White;
            }
            ChartObjects.DrawText("ScoreValue", "" + sum, index - 1 * width / 7 + width / 14, Symbol.Bid - height * Symbol.PipSize, VerticalAlignment.Top, HorizontalAlignment.Center, totalColor);
        }
示例#20
0
        public override void Calculate(int index)
        {
            if (errorOccured)
            {
                ChartObjects.DrawText("errorlabel", errorMsg, StaticPosition.TopCenter, Colors.Red);
                return;
            }

            // get the last highest price value
            double high = (minuteSeries.High.LastValue);
            // get the last lowest price value
            double low = (minuteSeries.Low.LastValue);

            // difference between high and low devided by the current instruments pip size = sudden movement in pips
            double pips = (high - low) / Symbol.PipSize;

            string pipsVolatility = "Vol   : " + pips.ToString("0.00") + " pips";

            // display error message to screen.
            if (ShowVolatility)
            {
                ChartObjects.DrawText("volatilityMsg", pipsVolatility += lowerPosition, position, spreadTextColor);
            }

            // if pip movement > volatility setting
            if (Math.Ceiling(pips) > VolatilityPips)
            {
                if (AlertOn)
                {
                    ChartObjects.DrawText("alertMsg", pipsVolatility, position, warningTextColor);
                }

                if (PlaySound)
                {
                    if (MediaFile != string.Empty)
                    {
                        Notifications.PlaySound(MediaFile);
                    }
                }
            }
            else
            {
                ChartObjects.RemoveObject("alertMsg");
            }

            // if user wants to see the current bid/ask spread size, * feature seperate from volatility alert.
            if (ShowSpread)
            {
                var    spread = Math.Round(Symbol.Spread / Symbol.PipSize, 2);
                string s      = string.Format("{0:N2}", spread);

                ChartObjects.DrawText("spreadMsg", "\nSpread: " + s, position, spreadTextColor);
            }
        }
示例#21
0
        public override void Calculate(int index)
        {
            if (!IsLastBar)
            {
                return;
            }

            var text = FormatSymbol(symbol1) + "\n" + FormatSymbol(symbol2) + "\n" + FormatSymbol(symbol3);

            ChartObjects.DrawText("symbol1", text, StaticPosition.TopLeft, Colors.Lime);
        }
示例#22
0
        private void DrawTextOnGraph()
        {
            List <string> lsN = new List <string>();

            ChartObjects.DrawText("maxBuyLabel >> ", "   maxBuyLabel:" + maxBuyLabel, StaticPosition.TopLeft, Colors.LightBlue);

            lsN.Add("\n");
            ChartObjects.DrawText("minSellLabel", string.Join("", lsN) + "          minSellLabel:" + minSellLabel, StaticPosition.TopLeft, Colors.LightBlue);

            lsN.Add("\n");
            ChartObjects.DrawText("lastLabelBuy", string.Join("", lsN) + "          lastLabelBuy:" + lastLabelBuy, StaticPosition.TopLeft, Colors.LightBlue);

            lsN.Add("\n");
            ChartObjects.DrawText("lastLabelSell", string.Join("", lsN) + "          lastLabelSell:" + lastLabelSell, StaticPosition.TopLeft, Colors.LightBlue);

            //string sProfitBuy = "";
            //foreach (var ls in lsWillProfitClearBuy)
            //{
            //    sProfitBuy += ls.Key + ":" + ls.Value + "  |  ";
            //}
            //lsN.Add("\n");
            //ChartObjects.DrawText("lsWillProfitClearBuy", string.Join("", lsN) + "          รายการกำไรขาbuy:" + sProfitBuy, StaticPosition.TopLeft, Colors.LightBlue);

            //string sProfitSell = "";
            //foreach (var ls in lsWillProfitClearSell)
            //{
            //    sProfitSell += ls.Key + ":" + ls.Value + "  |  ";
            //}
            //lsN.Add("\n");
            //ChartObjects.DrawText("lsWillProfitClearSell", string.Join("", lsN) + "          รายการกำไรขาsell:" + sProfitSell, StaticPosition.TopLeft, Colors.LightBlue);

            //string sLossBuy = "";
            //foreach (var ls in lsWillLossClearBuy)
            //{
            //    sLossBuy += ls.Key + ":" + ls.Value + "  |  ";
            //}
            //lsN.Add("\n");
            //ChartObjects.DrawText("lsWillLossClearBuy", string.Join("", lsN) + "          รายการขาดทุนขาbuy:" + sLossBuy, StaticPosition.TopLeft, Colors.LightBlue);

            //string sLossSell = "";
            //foreach (var ls in lsWillLossClearSell)
            //{
            //    sLossSell += ls.Key + ":" + ls.Value + "  |  ";
            //}
            //lsN.Add("\n");
            //ChartObjects.DrawText("lsWillLossClearSell", string.Join("", lsN) + "          รายการขาดทุนขาsell:" + sLossSell, StaticPosition.TopLeft, Colors.LightBlue);


            //foreach (var ls in lsOnOpen)
            //{
            //    lsN.Add("\n");
            //    ChartObjects.DrawText("lsOnOpen", string.Join("", lsN) + "          รายการรอคิวเปิด:" + ls, StaticPosition.TopLeft, Colors.LightBlue);
            //}
        }
示例#23
0
 public override void Calculate(int index)
 {
     if (!IsLastBar)
     {
         return;
     }
     else
     {
         ChartObjects.DrawText("equity", (showEquityWord ? "Equity: " : "") + Account.Equity.ToString("N") + (showCurrency ? " " + Account.Currency : ""), StaticPosition.TopLeft);
     }
 }
示例#24
0
        public async Task CeateAndSaveExcelFileProductCartAsync(string fileName, IDictionary <ItemKey, IEnumerable <Product> > cartProductsByItemKey)
        {
            await Task.Run(() =>
            {
                object misValue = Missing.Value;

                var xlApp       = new Application();
                var xlWorkBook  = xlApp.Workbooks.Add(misValue);
                var xlWorkSheet = (Worksheet)xlWorkBook.Worksheets.Item[1];

                xlWorkSheet.Cells[1, 1] = "";
                var numberOfProducts    = cartProductsByItemKey.Keys.Count;

                foreach (var pair in cartProductsByItemKey)
                {
                    var counter = pair.Value.Count();

                    xlWorkSheet.Cells[2 + numberOfProducts, 1] = pair.Value.First().ProductName;

                    foreach (var item in pair.Value)
                    {
                        var chainName = GetChainName(item.CaindId);
                        xlWorkSheet.Cells[1, 1 + counter] = chainName;
                        xlWorkSheet.Cells[2 + numberOfProducts, 1 + counter] = item.ItemPrice;
                        counter--;
                    }
                    numberOfProducts--;
                }

                numberOfProducts   = cartProductsByItemKey.Keys.Count;
                var numberOfChains = cartProductsByItemKey.Values.First().Count();

                ChartObjects xlCharts =
                    (ChartObjects)xlWorkSheet.ChartObjects(Type.Missing);
                ChartObject myChart =
                    xlCharts.Add(10, 80, 300, 250);
                Chart chartPage = myChart.Chart;

                var chartRange =
                    xlWorkSheet.Range[
                        (Range)xlWorkSheet.Cells[1, 1],
                        (Range)
                        xlWorkSheet.Cells[numberOfProducts + 2, numberOfChains + 1]];
                chartPage.SetSourceData(chartRange, misValue);
                chartPage.ChartType = XlChartType.xlColumnClustered;

                xlWorkBook.SaveAs(fileName, XlFileFormat.xlWorkbookNormal, misValue,
                                  misValue, misValue, misValue,
                                  XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue,
                                  misValue, misValue);
                xlWorkBook.Close(true, misValue, misValue);
                xlApp.Quit();
            });
        }
示例#25
0
        public override void Calculate(int index)
        {
            if (index == theCount + 1)
            {
                theCount      += 1;
                FireSoundAlarm = true;
            }

            Main[index]   = BB.Main[index];
            Top[index]    = BB.Top[index];
            Bottom[index] = BB.Bottom[index];

            for (int i = 1; i <= Test_Candles; i++)
            {
                if (MarketSeries.Close[index - i] > BB.Top[index - i])
                {
                    if (i == Test_Candles)
                    {
                        ChartObjects.DrawText("SellSignal" + index, Down, index - 1, MarketSeries.High[index - 1] + offset * Symbol.PipSize, vAlign, hAlign, Colors.Red);

                        if (SoundAlert && FireSoundAlarm)
                        {
                            Notifications.PlaySound(SoundFile);
                            if (Alert_Once)
                            {
                                FireSoundAlarm = false;
                            }
                        }
                    }
                }

                else if (MarketSeries.Close[index - i] < BB.Bottom[index - i])
                {
                    if (i == Test_Candles)
                    {
                        ChartObjects.DrawText("BuySignal" + index, UP, index - 1, MarketSeries.Low[index - 1] - offset * Symbol.PipSize, vAlign, hAlign, Colors.Lime);

                        if (SoundAlert && FireSoundAlarm)
                        {
                            Notifications.PlaySound(SoundFile);
                            if (Alert_Once)
                            {
                                FireSoundAlarm = false;
                            }
                        }
                    }
                }
                else
                {
                    break;
                }
            }
        }
示例#26
0
        //END FUNCTION my_NL
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        private void Create_Fixed_Display()
        {
            ChartObjects.DrawText("Line0", "Basket Trading ver 3.2 (23-Dec-15), " + "Start Date/Time : ", StaticPosition.TopLeft, Colors.Yellow);

            ChartObjects.DrawText("Line1", my_NL(2) + my_Tabs(3) + "++++++++++++" + my_Tabs(2) + "+++++++++++" + my_Tabs(2) + "+++++++++++" + my_Tabs(2) + "++++++++++" + my_Tabs(2) + "+++++++++++" + my_Tabs(2) + "+++++++++++" + my_Tabs(2) + "+++++++++++" + my_Tabs(2) + "++++++++++", StaticPosition.TopLeft, Colors.Yellow);
            ChartObjects.DrawText("Line2", my_NL(3) + my_Tabs(3) + "1.EURO PAIRS" + my_Tabs(2) + "2.GBP PAIRS" + my_Tabs(2) + "3.USD PAIRS" + my_Tabs(2) + "4.JPY PAIRS" + my_Tabs(2) + "5.CHF PAIRS" + my_Tabs(2) + "6.CAD PAIRS" + my_Tabs(2) + "7.AUD PAIRS" + my_Tabs(2) + "8.NZD PAIRS", StaticPosition.TopLeft, Colors.Yellow);
            ChartObjects.DrawText("Line3", my_NL(4) + my_Tabs(3) + "++++++++++++" + my_Tabs(2) + "+++++++++++" + my_Tabs(2) + "+++++++++++" + my_Tabs(2) + "++++++++++" + my_Tabs(2) + "+++++++++++" + my_Tabs(2) + "+++++++++++" + my_Tabs(2) + "+++++++++++" + my_Tabs(2) + "++++++++++", StaticPosition.TopLeft, Colors.Yellow);
            ChartObjects.DrawText("Line4", my_NL(5) + "Pen.Orders Placed :", StaticPosition.TopLeft, Colors.Yellow);
            ChartObjects.DrawText("Line5", my_NL(6) + "Profit / Loss :", StaticPosition.TopLeft, Colors.Yellow);
            ChartObjects.DrawText("Line6", my_NL(7) + "Count : Buy/Sell :", StaticPosition.TopLeft, Colors.Yellow);
            ChartObjects.DrawText("Line7", my_NL(8) + "Total Pending Orders :", StaticPosition.TopLeft, Colors.Yellow);
        }
示例#27
0
        private TimingOld CalculateMarketTiming()
        {
            var local     = CalculateTiming(lmacd, lma, MarketSeries);
            var reference = CalculateTiming(rmacd, rma, rseries);

            var msg = string.Format("Market timing: {0} {1}", reference, local);

            ChartObjects.RemoveObject("test");
            ChartObjects.DrawText("test", msg, StaticPosition.TopCenter, Colors.Black);

            return(new TimingOld(reference, local));
        }
示例#28
0
        public void GenerateDiagram(Range range)
        {
            Workbook.Worksheets.Add();
            Worksheet = Workbook.Worksheets[Index : 2];

            ChartObjects xlCharts  = Worksheet.ChartObjects(Index: Type.Missing);
            ChartObject  myChart   = xlCharts.Add(Left: 10, Top: 80, Width: 300, Height: 250);
            Chart        chartPage = myChart.Chart;

            chartPage.ChartType = XlChartType.xl3DColumnClustered;
            chartPage.SetSourceData(Source: range);
        }
示例#29
0
        private void GenerateOverAllStepsPieChart()
        {
            //format headings
            workSheet_range = xlWorkSheet.Range["A3:D3"];
            //columns heading

            xlWorkSheet.Range["A3"].Value = "";
            xlWorkSheet.Range["B3"].Value = "Pass Steps";
            xlWorkSheet.Range["C3"].Value = "Fail Steps";
            xlWorkSheet.Range["D3"].Value = "Warning Steps";

            //format headings
            workSheet_range.Font.Bold           = true;
            workSheet_range.Interior.Color      = ColorTranslator.FromHtml(HelperClass.excelSummHeaderBackgound);
            workSheet_range.Font.Color          = ColorTranslator.FromHtml(HelperClass.excelSummHeaderFontColor);
            workSheet_range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;
            workSheet_range.WrapText            = true;

            int noOfStepsPassed = (from testCase in ExecutionSession.lstTestCase
                                   select testCase.NoOfStepsPassed)
                                  .Sum();
            int noOfStepsFailed = (from testCase in ExecutionSession.lstTestCase
                                   select testCase.NoOfStepsFailed)
                                  .Sum();
            int noOfWarningSteps = (from testCase in ExecutionSession.lstTestCase
                                    select testCase.NoOfWarningSteps)
                                   .Sum();

            xlWorkSheet.Range["B4"].Value = noOfStepsPassed;
            xlWorkSheet.Range["C4"].Value = noOfStepsFailed;
            xlWorkSheet.Range["D4"].Value = noOfWarningSteps;

            workSheet_range = xlWorkSheet.Range["A3", "D4"];
            workSheet_range.HorizontalAlignment = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignCenter;
            workSheet_range.Borders.Color       = System.Drawing.Color.Black.ToArgb();
            workSheet_range.WrapText            = true;

            myCharts   = xlWorkSheet.ChartObjects(Type.Missing);
            myCharts1  = myCharts.Add(400, 30, 370, 210);
            oChart     = myCharts1.Chart;
            chartRange = xlWorkSheet.Range["A3", "D4"];
            oChart.SetSourceData(chartRange);
            oChart.PlotBy    = XlRowCol.xlRows;
            oChart.ChartType = XlChartType.xl3DPie;
            oChart.ApplyDataLabels(XlDataLabelsType.xlDataLabelsShowPercent);
            oChart.HasLegend       = true;
            oChart.HasTitle        = true;
            oChart.ChartTitle.Text = "Overall steps report";

            string overAllPieChartPath = summaryChartsFolder + "\\OverallStepsSummaryReport.jpg";

            oChart.Export(overAllPieChartPath, "jpg", Missing.Value);
        }
示例#30
0
 private void ShowDescription()
 {
     if (ShowDesc)
     {
         ChartObjects.DrawText("desc1", "Climax High", StaticPosition.TopRight, GetAttributeFrom <OutputAttribute>(this, "RedVolume").Color);
         ChartObjects.DrawText("desc2", "\nNeutral", StaticPosition.TopRight, GetAttributeFrom <OutputAttribute>(this, "BlueVolume").Color);
         ChartObjects.DrawText("desc3", "\n\nVolume Low", StaticPosition.TopRight, GetAttributeFrom <OutputAttribute>(this, "YellowVolume").Color);
         ChartObjects.DrawText("desc4", "\n\n\nHigh Churn", StaticPosition.TopRight, GetAttributeFrom <OutputAttribute>(this, "GreenVolume").Color);
         ChartObjects.DrawText("desc5", "\n\n\n\nClimax Low", StaticPosition.TopRight, GetAttributeFrom <OutputAttribute>(this, "WhiteVolume").Color);
         ChartObjects.DrawText("desc6", "\n\n\n\n\nClimax Churn", StaticPosition.TopRight, GetAttributeFrom <OutputAttribute>(this, "MagentaVolume").Color);
     }
 }
示例#31
0
		public Mq4Arrow(string name, int type, ChartObjects chartObjects, TimeSeries timeSeries): base(name, type, chartObjects)
		{
			_timeSeries = timeSeries;
		}
示例#32
0
		protected Mq4Object(string name, int type, ChartObjects chartObjects)
		{
			Name = name;
			Type = type;
			_chartObjects = chartObjects;
		}