예제 #1
0
        protected void DisplayAlert(string tradyTypeSignal, double takeProfit, double stopLoss, double entryPrice, ProfitPosition position)
        {
            string entryPricetext = entryPrice != 0.0 ? string.Format("Price : {0}", Math.Round(entryPrice, 4)) : "";
            string takeProfitText = takeProfit != 0.0 ? string.Format("TP : {0}", Math.Round(takeProfit, 4)) : "";
            string stopLossText   = stopLoss != 0.0 ? string.Format("SL : {0}", Math.Round(stopLoss, 4)) : "";

            var alertMessage = string.Format("{0} - {4}\n\n{1}\n{2}\n{3}\n\n  $$ Uzzie Signals $$", tradyTypeSignal, entryPricetext, takeProfitText, stopLossText, Symbol.Code);

            try
            {
                var request = new HttpRequestMessage(HttpMethod.Post, URL + "s/submit");
                request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                request.Headers.AcceptCharset.Add(new StringWithQualityHeaderValue("UTF-8"));
                request.Headers.UserAgent.Add(new ProductInfoHeaderValue("USERID", "TazzieBotSuperProfit"));
                var json = JsonConvert.SerializeObject(position);
                request.Content = new System.Net.Http.StringContent(json, Encoding.UTF8, "application/json");
                HttpClient.SendAsync(request).ContinueWith(task =>
                {
                    var response = task.Result;
                    if (!response.IsSuccessStatusCode)
                    {
                        Print("Send Signal error : Failed");
                    }
                    else
                    {
                        Print("Send Signal successful");
                    }
                });
            } catch (Exception ex)
            {
                Print("Send Signal error : " + ex.Message);
            }
            Print("Vomit signal ..... " + alertMessage);
        }
예제 #2
0
        public override void Calculate(int index)
        {
            if (index < 1)
            {
                return;
            }

            _dataSeries[index] = 2.0 * _movingAverage1.Result[index] - _movingAverage2.Result[index];
            _trend[index]      = _trend[index - 1];

            if (_movingAverage3.Result[index] > _movingAverage3.Result[index - 1])
            {
                _trend[index] = 1;
            }
            else if (_movingAverage3.Result[index] < _movingAverage3.Result[index - 1])
            {
                _trend[index] = -1;
            }

            if (_trend[index] > 0)
            {
                UpSeries[index] = _movingAverage3.Result[index];

                if (_trend[index - 1] < 0.0)
                {
                    UpSeries[index - 1] = _movingAverage3.Result[index - 1];
                    if (IsLastBar)
                    {
                        var stopLoss   = MarketSeries.Low[index - 1] - StopLoss * Symbol.PipSize;
                        var takeProfit = MarketSeries.Close[index] + TakeProfit * Symbol.PipSize;
                        var entryPrice = MarketSeries.Close[index - 1];

                        if (MarketSeries.OpenTime[index] != _openTime)
                        {
                            if (entryPrice <= takeProfit && entryPrice >= stopLoss)
                            {
                                buyPosition = true;

                                _openTime = MarketSeries.OpenTime[index];

                                stopLoss += StopLoss;

                                Entry[index] = entryPrice;
                                TP[index]    = takeProfit;
                                SL[index]    = stopLoss;

                                //isPlacePosition = true;
                                var position = new ProfitPosition("Buy", Symbol, stopLoss, takeProfit, entryPrice);
                                profitPositions.Add(position);
                                DisplayAlert("Buy signal", takeProfit, stopLoss, entryPrice, position);

                                Chart.DrawHorizontalLine("Take Profit", takeProfit, Color.Green, 3);
                                Chart.DrawHorizontalLine("Stop Loss", stopLoss, Color.Red, 3);
                                Chart.DrawHorizontalLine("Entry", entryPrice, Color.White, 3);
                            }
                            else
                            {
                                Print("WRONG SIGNALLLLL BUY !!! sl : " + stopLoss + " , tp : " + takeProfit + " , entry " + entryPrice + " , pipsize : " + Symbol.PipSize + " , pipvalue : " + Symbol.PipValue + " , lotsize : " + Symbol.LotSize);
                            }
                        }
                    }
                }

                DownSeries[index] = double.NaN;
            }
            else if (_trend[index] < 0)
            {
                DownSeries[index] = _movingAverage3.Result[index];

                if (_trend[index - 1] > 0.0)
                {
                    DownSeries[index - 1] = _movingAverage3.Result[index - 1];

                    if (IsLastBar)
                    {
                        var stopLoss   = MarketSeries.High[index - 1] * Symbol.PipSize;
                        var takeProfit = MarketSeries.Close[index] * Symbol.PipSize;
                        var entryPrice = MarketSeries.Close[index - 1];

                        // takeProfit had a minus

                        if (MarketSeries.OpenTime[index] != _openTime)
                        {
                            sellPosition = true;

                            _openTime = MarketSeries.OpenTime[index];

                            stopLoss += StopLoss;

                            Print("Entry " + entryPrice + " price(ask) -> " + Symbol.Ask + " Stop ......" + MarketSeries.High[index - 1] + " ... " + (stopLoss + StopLoss) + " and (tp) " + MarketSeries.Close[index] + " ... " + (takeProfit - TakeProfit));

                            Entry[index] = entryPrice;
                            TP[index]    = takeProfit;
                            SL[index]    = stopLoss;

                            //isPlacePosition = true;
                            var position = new ProfitPosition("Sell", Symbol, stopLoss, takeProfit, entryPrice);
                            profitPositions.Add(position);
                            DisplayAlert("Sell signal", takeProfit, stopLoss, entryPrice, position);

                            Chart.DrawHorizontalLine("Take Profit", takeProfit, Color.Green, 3);
                            Chart.DrawHorizontalLine("Stop Loss", stopLoss, Color.Red, 3);
                            Chart.DrawHorizontalLine("Entry", entryPrice, Color.White, 3);
                        }
                    }
                }

                UpSeries[index] = double.NaN;
            }
        }