示例#1
0
        public override void Calculate(int index)
        {
            if (Symbol.Ask < low || Symbol.Ask > high)
            {
                high = Symbol.Ask + Symbol.PipSize * 10000;
                for (double level = Symbol.Ask; level <= high; level += Symbol.PipSize / 10)
                {
                    level = Math.Round(level, 3);
                    if (check(level))
                    {
                        ChartObjects.DrawHorizontalLine("line_" + level, level, Colors.Gray);
                    }
                }

                low = Symbol.Ask - Symbol.PipSize * 10000;
                for (double level = Symbol.Ask; level >= low; level -= Symbol.PipSize / 10)
                {
                    level = Math.Round(level, 3);
                    if (check(level))
                    {
                        ChartObjects.DrawHorizontalLine("line_" + level, level, Colors.Gray);
                    }
                }
            }
        }
示例#2
0
 private void DrawLines()
 {
     ChartObjects.DrawHorizontalLine("EntryLine", this.EntryPrice, Colors.RoyalBlue, 2, LineStyle.Lines);
     ChartObjects.DrawHorizontalLine("StopLine", this.StopPrice, Colors.Red, 2, LineStyle.Lines);
     ChartObjects.DrawHorizontalLine("TargetOneLine", this.TargetPriceOne, Colors.Green, 2, LineStyle.Lines);
     ChartObjects.DrawHorizontalLine("TargetTwoLine", this.TargetPriceTwo, Colors.Green, 2, LineStyle.Lines);
 }
示例#3
0
        public void draw()
        {
            ChartObjects.RemoveAllObjects();

            var hAlign = HorizontalAlignment.Left;
            var color  = Colors.White;

            streakTime = (int)(Server.Time - startTime).TotalMinutes;
            var targetEquity = startingBalance + profit;

            ChartObjects.DrawText("text", "Equity: " + Account.Equity + "/" + targetEquity, MarketSeries.Close.Count - 1, Symbol.Bid, VerticalAlignment.Top, hAlign, color);
            ChartObjects.DrawText("text2", "Time (min): " + streakTime + "/" + streakTimeavg + " | Trades: " + streakTrades + "/" + streakTradesAvg, MarketSeries.Close.Count - 1, Symbol.Bid, VerticalAlignment.Bottom, hAlign, color);
            var netPosition = 0.0;

            foreach (Position pos in this.Positions)
            {
                if (pos.TradeType == TradeType.Buy)
                {
                    netPosition += pos.Volume;
                }
                else
                {
                    netPosition -= pos.Volume;
                }
            }
            var pips = ((targetEquity - Account.Equity) / (netPosition * Symbol.PipValue)) * Symbol.PipSize;

            ChartObjects.DrawHorizontalLine("TP", Symbol.Bid + pips, Colors.White, 2, LineStyle.Lines);
        }
示例#4
0
        protected override void OnTimer()
        {
            var remainingTime = _triggerTimeInServerTimeZone - Server.Time;

            DrawRemainingTime(remainingTime);

            if (!_ordersCreated)
            {
                var sellOrderTargetPrice = Symbol.Bid - PipsAway * Symbol.PipSize;
                ChartObjects.DrawHorizontalLine("sell target", sellOrderTargetPrice, Colors.Red, 1, LineStyle.DotsVeryRare);
                var buyOrderTargetPrice = Symbol.Ask + PipsAway * Symbol.PipSize;
                ChartObjects.DrawHorizontalLine("buy target", buyOrderTargetPrice, Colors.Blue, 1, LineStyle.DotsVeryRare);

                if (Server.Time <= _triggerTimeInServerTimeZone && (_triggerTimeInServerTimeZone - Server.Time).TotalSeconds <= SecondsBefore)
                {
                    _ordersCreated = true;
                    var expirationTime = _triggerTimeInServerTimeZone.AddSeconds(SecondsTimeout);

                    PlaceStopOrder(TradeType.Sell, Symbol, Volume, sellOrderTargetPrice, Label, StopLoss, TakeProfit, expirationTime);
                    PlaceStopOrder(TradeType.Buy, Symbol, Volume, buyOrderTargetPrice, Label, StopLoss, TakeProfit, expirationTime);

                    ChartObjects.RemoveObject("sell target");
                    ChartObjects.RemoveObject("buy target");
                }
            }

            if (_ordersCreated && !PendingOrders.Any(o => o.Label == Label))
            {
                Print("Orders expired");
                Stop();
            }
        }
示例#5
0
        private void ControlSeries()
        {
            Position[] positions = GetPositions();

            if (positions.Length < MaxOrders)
            {
                long volume = Symbol.NormalizeVolume(FirstLot + FirstLot * martingaleCoeff * positions.Length, RoundingMode.ToNearest);

                int pipstep      = GetDynamicPipstep(25, 4);
                int positionSide = GetPositionsSide();

                switch (positionSide)
                {
                case 0:
                    double lastBuyPrice = FindLastPrice(TradeType.Buy);
                    ChartObjects.DrawHorizontalLine("gridBuyLine", lastBuyPrice - pipstep * Symbol.PipSize, Colors.Green, 2);
                    if (Symbol.Ask < lastBuyPrice - pipstep * Symbol.PipSize)
                    {
                        executeOrder(TradeType.Buy, volume);
                    }
                    break;

                case 1:
                    double lastSellPrice = FindLastPrice(TradeType.Sell);
                    ChartObjects.DrawHorizontalLine("gridSellLine", lastSellPrice + pipstep * Symbol.PipSize, Colors.Red, 2);
                    if (Symbol.Bid > lastSellPrice + pipstep * Symbol.PipSize)
                    {
                        executeOrder(TradeType.Sell, volume);
                    }
                    break;
                }
            }
        }
示例#6
0
        // Limit Mode
        protected override void OnStart()
        {
            _LTryN = _TryN;
            _STryN = _TryN;
            _SVolume = _Volume;
            _LVolume = _Volume;

            x = rn.Next(99, 9999);
            _SLabel = "S" + Symbol.Code + x.ToString();
            _LLabel = "L" + Symbol.Code + x.ToString();

            if (_GoShort)
            {
                var _SCLD = History.FindLast(_SLabel);
                var _SCLO = Positions.Find(_SLabel);

                while (_SCLD != null || _SCLO != null)
                {
                    x++;
                    _SLabel = "S" + Symbol.Code + x.ToString();
                    _SCLD = History.FindLast(_SLabel);
                    _SCLO = Positions.Find(_SLabel);
                    Print("Theres a duplicated Label, finding another one.");
                }

                Print("Short Label is: ", _SLabel);
                ChartObjects.DrawHorizontalLine(_SLabel, _ShortPrice, Colors.Red, 2, LineStyle.DotsVeryRare);
            }

            if (_GoLong)
            {

                var _LCLD = History.FindLast(_LLabel);
                var _LCLO = Positions.Find(_LLabel);

                while (_LCLD != null || _LCLO != null)
                {
                    x++;
                    _LLabel = "L" + Symbol.Code + x.ToString();
                    _LCLD = History.FindLast(_LLabel);
                    _LCLO = Positions.Find(_LLabel);
                    Print("Theres a duplicated Label, finding another one.");
                }

                Print("Long Label is: ", _LLabel);
                ChartObjects.DrawHorizontalLine(_LLabel, _LongPrice, Colors.SteelBlue, 2, LineStyle.DotsVeryRare);
            }

            if (Symbol.Ask > _LongPrice)
            {
                _LModeL = true;
                Print("Long Limit Mode is On Play");
            }

            if (Symbol.Bid < _ShortPrice)
            {
                _LModeS = true;
                Print("Short Limit Mode is On Play");
            }
        }
示例#7
0
        public override void Calculate(int index)
        {
            LineBold = L1;

            if (SetBlue)
            {
                LineColor = Colors.DodgerBlue;
            }


            if (SetRed)
            {
                LineColor = Colors.Red;
            }
            if (SetWhite)
            {
                LineColor = Colors.White;
            }
            if (SetBlack)
            {
                LineColor = Colors.Black;
            }
            if (SetGreen)
            {
                LineColor = Colors.YellowGreen;
            }


            if (Set100Levels && MinLevel < MaxLevel)
            {
                for (int i = MinLevel; i < MaxLevel; i++)
                {
                    ChartObjects.DrawHorizontalLine("Level" + i, i * 100 * Symbol.PipSize, LineColor, LineBold, LineStyle.Solid);
                }
            }

            if (Set25Levels && MinLevel < MaxLevel)
            {
                for (int i = MinLevel; i < MaxLevel; i++)
                {
                    ChartObjects.DrawHorizontalLine("Lh1" + i, i * 100 * Symbol.PipSize + 25 * Symbol.PipSize, Colors.Red, 1, LineStyle.DotsRare);
                    ChartObjects.DrawHorizontalLine("Lh3" + i, i * 100 * Symbol.PipSize + 75 * Symbol.PipSize, Colors.Red, 1, LineStyle.DotsRare);
                }
            }

            if (Set50Levels && MinLevel < MaxLevel)
            {
                for (int i = MinLevel; i < MaxLevel; i++)
                {
                    ChartObjects.DrawHorizontalLine("Lh2" + i, i * 100 * Symbol.PipSize + 50 * Symbol.PipSize, Colors.YellowGreen, 1, LineStyle.Lines);
                }
            }
        }
示例#8
0
        protected override void Initialize()
        {
            double max = MarketSeries.High.Maximum(MarketSeries.High.Count);
            double min = MarketSeries.Low.Minimum(MarketSeries.Low.Count);

            double step  = Symbol.PipSize * StepPips;
            double start = Math.Floor(min / step) * step;

            for (double level = start; level <= max + step; level += step)
            {
                ChartObjects.DrawHorizontalLine("line_" + level, level, Colors.Gray);
            }
        }
示例#9
0
        private void ControlSeries()
        {
            Position[] positions = GetPositions();

            if (positions.Length < MaxOrders)
            {
                long volume      = Symbol.NormalizeVolume(firstLot * (1 + MartingaleCoeff * positions.Length), RoundingMode.ToNearest);
                int  countOfBars = (int)(25.0 / positions.Length);

                int pipstep      = GetDynamicPipstep(countOfBars, MaxOrders - 1);
                int positionSide = GetPositionsSide();

                switch (positionSide)
                {
                case 0:
                    double lastBuyPrice = GetLastPrice(TradeType.Buy);

                    if (!DEBUG)
                    {
                        ChartObjects.DrawHorizontalLine("gridBuyLine", lastBuyPrice - pipstep * Symbol.PipSize, Colors.Green, 2);
                    }

                    if (Symbol.Ask < lastBuyPrice - pipstep * Symbol.PipSize)
                    {
                        executeOrder(TradeType.Buy, volume);
                    }
                    break;

                case 1:
                    double lastSellPrice = GetLastPrice(TradeType.Sell);

                    if (!DEBUG)
                    {
                        ChartObjects.DrawHorizontalLine("gridSellLine", lastSellPrice + pipstep * Symbol.PipSize, Colors.Red, 2);
                    }

                    if (Symbol.Bid > lastSellPrice + pipstep * Symbol.PipSize)
                    {
                        executeOrder(TradeType.Sell, volume);
                    }
                    break;
                }
            }

            if (!DEBUG)
            {
                ChartObjects.DrawText("MaxDrawdown", "MaxDrawdown: " + Math.Round(GetMaxDrawdown(), 2) + " Percent", corner_position);
            }
        }
示例#10
0
        public void draw()
        {
            readCSV();
            ChartObjects.RemoveAllObjects();



            foreach (Fields field in upcomingNews)
            {
                minutesToNews = (int)((field.newsTime - timeNow).TotalMinutes);

                if (field.impact == "High")
                {
                    color = Colors.Red;
                }
                else if (field.impact == "Medium")
                {
                    color = Colors.Orange;
                }
                else if (field.impact == "Low")
                {
                    color = Colors.Yellow;
                }

                if (Symbol.Code.IndexOf(field.currency) == -1)
                {
                    lineWidth = 1;
                }
                else
                {
                    lineWidth = 2;
                }



                var hAlign = HorizontalAlignment.Left;

                ChartObjects.DrawText("text" + minutesToNews, field.newsTime + " " + field.detail, MarketSeries.Close.Count - 1, Symbol.Bid + (minutesToNews * Symbol.PipSize) / pipTime, VerticalAlignment.Top, hAlign, color);

                if (this.Positions.Count == 0)
                {
                    ChartObjects.DrawText("Quiet Pairs", quietPairs, MarketSeries.Close.Count - 1, Symbol.Bid, VerticalAlignment.Bottom, hAlign, Colors.Aqua);
                }
                ChartObjects.DrawText("text2" + minutesToNews, field.newsTime + " " + field.detail, MarketSeries.Close.Count - 1, Symbol.Bid - (minutesToNews * Symbol.PipSize) / pipTime, VerticalAlignment.Bottom, hAlign, color);
                ChartObjects.DrawHorizontalLine("News " + minutesToNews, Symbol.Bid + (minutesToNews * Symbol.PipSize) / pipTime, color, lineWidth, LineStyle.Lines);
                ChartObjects.DrawHorizontalLine("News2 " + minutesToNews, Symbol.Bid - (minutesToNews * Symbol.PipSize) / pipTime, color, lineWidth, LineStyle.Lines);
            }
        }
示例#11
0
 private void DisplayStatusOnChart()
 {
     if (CountOfTradesOfType(TradeType.Buy) > 1)
     {
         var y = CalculateAveragePositionPrice(TradeType.Buy);
         ChartObjects.DrawHorizontalLine("bpoint", y, Colors.Yellow, 2, LineStyle.Dots);
     }
     else
     {
         ChartObjects.RemoveObject("bpoint");
     }
     if (CountOfTradesOfType(TradeType.Sell) > 1)
     {
         var z = CalculateAveragePositionPrice(TradeType.Sell);
         ChartObjects.DrawHorizontalLine("spoint", z, Colors.HotPink, 2, LineStyle.Dots);
     }
     else
     {
         ChartObjects.RemoveObject("spoint");
     }
     ChartObjects.DrawText("pan", GenerateStatusText(), StaticPosition.TopLeft, Colors.Tomato);
 }
示例#12
0
 //Draw the Action lines to illustrate the trades
 private void DrawDescisionLines()
 {
     if (activeDirectionCount(TradeType.Buy) > 1)
     {
         double y = AverageEntryPrice(TradeType.Buy);
         ChartObjects.DrawHorizontalLine("bpoint", y, Colors.Yellow, 2, LineStyle.Dots);
     }
     else
     {
         ChartObjects.RemoveObject("bpoint");
     }
     if (activeDirectionCount(TradeType.Sell) > 1)
     {
         double z = AverageEntryPrice(TradeType.Sell);
         ChartObjects.DrawHorizontalLine("spoint", z, Colors.HotPink, 2, LineStyle.Dots);
     }
     else
     {
         ChartObjects.RemoveObject("spoint");
     }
     ChartObjects.DrawText("pan", botText(), StaticPosition.TopLeft, Colors.Tomato);
 }
示例#13
0
 private void RCN()
 {
     if (o_tm(TradeType.Buy) > 1)
     {
         double y = pnt_12(TradeType.Buy);
         ChartObjects.DrawHorizontalLine("bpoint", y, Colors.Yellow, 2, LineStyle.Dots);
     }
     else
     {
         ChartObjects.RemoveObject("bpoint");
     }
     if (o_tm(TradeType.Sell) > 1)
     {
         double z = pnt_12(TradeType.Sell);
         ChartObjects.DrawHorizontalLine("spoint", z, Colors.HotPink, 2, LineStyle.Dots);
     }
     else
     {
         ChartObjects.RemoveObject("spoint");
     }
     ChartObjects.DrawText("pan", A_cmt_calc(), StaticPosition.TopLeft, Colors.Tomato);
 }
示例#14
0
 private void drawLines()
 {
     ChartObjects.RemoveAllObjects();
     if (this.Positions.Find("Buy") != null && !modified)
     {
         if (recoveryMode)
         {
             ChartObjects.DrawHorizontalLine("TP", this.Positions[0].EntryPrice + tradeTP * Symbol.PipSize, Colors.Yellow, 2, LineStyle.Lines);
         }
         else
         {
             ChartObjects.DrawHorizontalLine("TP", this.Positions[0].EntryPrice + tradeTP * Symbol.PipSize, Colors.Green, 2, LineStyle.Lines);
             ChartObjects.DrawHorizontalLine("Recovery", this.Positions[0].EntryPrice + tradeTP / (1 + profitPercent / 100) * Symbol.PipSize, Colors.Yellow, 2, LineStyle.Lines);
         }
     }
     else if (this.Positions.Find("Sell") != null && !modified)
     {
         if (recoveryMode)
         {
             ChartObjects.DrawHorizontalLine("TP", this.Positions[0].EntryPrice - tradeTP * Symbol.PipSize, Colors.Yellow, 2, LineStyle.Lines);
         }
         else
         {
             ChartObjects.DrawHorizontalLine("TP", this.Positions[0].EntryPrice - tradeTP * Symbol.PipSize, Colors.Green, 2, LineStyle.Lines);
             ChartObjects.DrawHorizontalLine("Recovery", this.Positions[0].EntryPrice - tradeTP / (1 + profitPercent / 100) * Symbol.PipSize, Colors.Yellow, 2, LineStyle.Lines);
         }
     }
     if (this.Positions.Find("Buy") != null)
     {
         ChartObjects.DrawHorizontalLine("boxBottom", prevBoxBottom, Colors.Red, 2, LineStyle.Lines);
     }
     else if (this.Positions.Find("Sell") != null)
     {
         ChartObjects.DrawHorizontalLine("boxTop", prevBoxTop, Colors.Red, 2, LineStyle.Lines);
     }
 }
示例#15
0
        protected override void Initialize()
        {
            // Calculate TDI components
            _rsi            = Indicators.RelativeStrengthIndex(Source, RsiPeriod);
            _bollingerBands = Indicators.BollingerBands(_rsi.Result, Volatility, StDev, MovingAverageType.Simple);
            _price          = Indicators.MovingAverage(_rsi.Result, PricePeriod, PriceMaType);
            _signal         = Indicators.MovingAverage(_rsi.Result, SignalPeriod, SignalMaType);

            // colorize Lines
            ChartObjects.DrawHorizontalLine("68", 68, Colors.Red, 1, LineStyle.Lines);
            ChartObjects.DrawHorizontalLine("63", 63, Colors.OrangeRed, 1, LineStyle.Lines);
            ChartObjects.DrawHorizontalLine("50", 50, Colors.Orange, 1, LineStyle.Solid);
            ChartObjects.DrawHorizontalLine("37", 37, Colors.PaleGreen, 1, LineStyle.Lines);
            ChartObjects.DrawHorizontalLine("32", 32, Colors.LimeGreen, 1, LineStyle.Lines);

            // Elders Impulse
            if (enable_EldersImpulse)
            {
                EMA = Indicators.ExponentialMovingAverage(MarketSeries.Close, EMAPeriod);
                Mac = Indicators.MacdHistogram(LongCycle, ShrtCycle, Signal);
            }
            // graphic objects
            arrowOffset = Symbol.PipSize * 5;
        }
        public override void Calculate(int index)
        {
            if (index < 1)
            {
                return;
            }


            double RSI_now = RSINow.Result[index];
            double RSI2    = RSINow.Result[index - 1];

            double myATR1 = ATR.Result[index];

            // up
            if (RSI_now >= 50)
            {
                //did it cross from below 50
                if (RSI_now > 50 && RSI2 < 50)
                {
                    deletealllines();
                    price           = Symbol.Bid + (myATR1 * ATR_percent);
                    stopLoss        = Symbol.Bid + (myATR1 * ATR_percent) - (0.3 * myATR1);
                    UpSeries[index] = MarketSeries.Low[index] - 2 * Symbol.PipValue;
                    ChartObjects.DrawHorizontalLine("entry", price, Colors.Blue);
                    ChartObjects.DrawHorizontalLine("stop", stopLoss, Colors.Blue);
                    lastRSI60arrow = 0;
                    lastCloseLong  = 0;
                }
                //add to position at cross of 60, sometimes this can occur twice
                if (RSI_now >= 60 && RSI2 < 60)
                {
                    //don't draw another arrow
                    if (lastRSI60arrow >= 60)
                    {
                    }
                    //draw another arrow for adding to position
                    if (lastRSI60arrow <= 60)
                    {
                        UpSeries[index] = MarketSeries.Low[index] - 2 * Symbol.PipValue;
                        lastRSI60arrow  = RSI_now;
                    }
                }

                //sell first lot
                if (RSI_now < 70 && RSI2 >= 70)
                {
                    if (lastCloseLong == 0)
                    {
                        SellSeries[index] = MarketSeries.High[index] + 2 * Symbol.PipValue;
                        lastCloseLong     = 1;
                    }
                }
            }


            // down
            //is going short
            if (RSI_now < 50)
            {
                //did it cross from above 50
                if (RSI_now < 50 && RSI2 > 50)
                {
                    deletealllines();
                    DownSeries[index] = MarketSeries.High[index] + 2 * Symbol.PipValue;
                    price             = Symbol.Ask - (myATR1 * ATR_percent);
                    stopLoss          = Symbol.Ask - (myATR1 * ATR_percent) + (0.3 * myATR1);
                    ChartObjects.DrawHorizontalLine("entry", price, Colors.Blue);
                    ChartObjects.DrawHorizontalLine("stop", stopLoss, Colors.Blue);
                    lastCloseShort = 0;
                    lastRSI40arrow = RSI_now;
                    //set out of area
                }
                if (RSI_now < 40 && RSI2 > 40)
                {
                    //don't draw another arrow
                    if (lastRSI40arrow <= 40)
                    {
                    }
                    //draw another arrow to add to position
                    if (lastRSI40arrow >= 40)
                    {
                        DownSeries[index] = MarketSeries.High[index] + 2 * Symbol.PipValue;
                        lastRSI40arrow    = RSI_now;
                    }
                }
                if (RSI_now > 30 && RSI2 < 30)
                {
                    if (lastCloseShort == 0)
                    {
                        SellSeries[index] = MarketSeries.Low[index] - 4 * Symbol.PipValue;
                        lastCloseShort    = 1;
                    }
                }
            }
        }
示例#17
0
 protected void DrawHorizontalLine(string objectName, double y, Colors color, double thickness = 1.0, cAlgo.API.LineStyle style = cAlgo.API.LineStyle.Solid)
 {
     _addedAlgoChartObjects.Add(objectName);
     _chartObjects.DrawHorizontalLine(objectName, y, color, thickness, style);
 }
示例#18
0
        protected override void Initialize()
        {
            // Initialize and create nested indicators

            var DailyStats = MarketData.GetSeries(TimeFrame.Minute30);


            DateTime TodayUTC     = DailyStats.OpenTime.LastValue.ToUniversalTime().Subtract(DailyStats.OpenTime.LastValue.ToUniversalTime().TimeOfDay);
            DateTime YesterdayUTC = TodayUTC.AddDays(-1);

            if (YesterdayUTC.DayOfWeek == DayOfWeek.Sunday)
            {
                YesterdayUTC = TodayUTC.AddDays(-2);
            }

            if (YesterdayUTC.DayOfWeek == DayOfWeek.Saturday)
            {
                YesterdayUTC = TodayUTC.AddDays(-1);
            }

            Print("YesterdayUTC: " + YesterdayUTC.ToString());


            int n = 0;

            CashLow = int.MaxValue;

            while (true)
            {
                //Print("in!");
                //Get the Day
                if (DailyStats.OpenTime.Last(n).Date.ToUniversalTime() == YesterdayUTC.Date)
                {
                    //  Print("Got Day!");

                    if (DailyStats.OpenTime.Last(n).ToUniversalTime().TimeOfDay >= new TimeSpan(8, 0, 0) & DailyStats.OpenTime.Last(n).ToUniversalTime().TimeOfDay <= new TimeSpan(14, 30, 0))
                    {
                        //  Print("got time!");

                        if (CashHigh < DailyStats.High.Last(n))
                        {
                            CashHigh = DailyStats.High.Last(n);
                        }

                        if (CashLow > DailyStats.Low.Last(n))
                        {
                            CashLow = DailyStats.Low.Last(n);
                        }

                        if (DailyStats.OpenTime.Last(n).ToUniversalTime().TimeOfDay == new TimeSpan(8, 0, 0))
                        {
                            CashOpen = DailyStats.Open.Last(n);
                        }

                        if (DailyStats.OpenTime.Last(n).ToUniversalTime().TimeOfDay == new TimeSpan(14, 30, 0))
                        {
                            CashClose = DailyStats.Open.Last(n);
                        }
                    }
                }

                if (DailyStats.OpenTime.Last(n).ToUniversalTime() <= YesterdayUTC)
                {
                    break;
                }


                n += 1;
            }
            // while


            string Summary = Symbol.Code.ToString() + ": Yesterday's Open: " + CashOpen.ToString() + ", Close: " + CashClose.ToString() + ", High: " + CashHigh.ToString() + ", Low: " + CashLow.ToString();

            SlackMe(Summary, "daily-levels");
            ChartObjects.DrawText("Previous", Summary, StaticPosition.BottomRight, Colors.Red);


            var ATRSeries        = MarketData.GetSeries(TimeFrame.Daily);
            AverageTrueRange ATR = Indicators.AverageTrueRange(ATRSeries, 5, MovingAverageType.Simple);

            ChartObjects.DrawText("ATR", "ATR: " + ATR.Result.LastValue.ToString() + ", 15% ATR: " + (ATR.Result.LastValue * 0.15).ToString() + ",30% ATR: " + (ATR.Result.LastValue * 0.3).ToString() + "", StaticPosition.TopRight, Colors.Red);


            ChartObjects.DrawText("ATR2", "ATR: " + CashATR.ToString() + ", 15% ATR: " + (CashATR * 0.15).ToString() + ",30% ATR: " + (CashATR * 0.3).ToString(), -20, Symbol.Ask, VerticalAlignment.Center, HorizontalAlignment.Center, Colors.Green);



            // DAILY
            ChartObjects.DrawHorizontalLine("DailyHigh", CashHigh, Colors.Green, 1, LineStyle.LinesDots);
            ChartObjects.DrawHorizontalLine("DailyLow", CashLow, Colors.Green, 1, LineStyle.LinesDots);
            ChartObjects.DrawHorizontalLine("DailyCLose", CashClose, Colors.Green, 1, LineStyle.LinesDots);


            // Daily Levels


            P = ((CashHigh + CashLow + CashClose) / 3);


            R1 = ((2 * P) - CashLow);
            R2 = (P + CashHigh - CashLow);
            R3 = (CashHigh + 2 * (P - CashLow));


            S1 = ((2 * P) - CashHigh);
            S2 = (P - CashHigh + CashLow);
            S3 = CashLow - 2 * (CashHigh - P);

            CBOL = ((CashHigh - CashLow) * 1.1 / 2 + CashClose);
            CBOS = CashClose - (CashHigh - CashLow) * 1.1 / 2;



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


            ChartObjects.DrawHorizontalLine("DailyPivot", P, Colors.Black, 1, LineStyle.Solid);
            ChartObjects.DrawHorizontalLine("WeeklyPivot", WP, Colors.Black, 3, LineStyle.Lines);
            ChartObjects.DrawHorizontalLine("MonthlyPivot", MP, Colors.Black, 3, LineStyle.Solid);

            ChartObjects.DrawHorizontalLine("R1", R1, Colors.Red, 1, LineStyle.Solid);
            ChartObjects.DrawHorizontalLine("R2", R2, Colors.Red, 1, LineStyle.Solid);
            ChartObjects.DrawHorizontalLine("R3", R3, Colors.Red, 1, LineStyle.Solid);

            ChartObjects.DrawHorizontalLine("S1", S1, Colors.Green, 1, LineStyle.Solid);
            ChartObjects.DrawHorizontalLine("S2", S2, Colors.Green, 1, LineStyle.Solid);
            ChartObjects.DrawHorizontalLine("S3", S3, Colors.Green, 1, LineStyle.Solid);

            ChartObjects.DrawHorizontalLine("CBOL", CBOL, Colors.YellowGreen, 1, LineStyle.Solid);
            ChartObjects.DrawHorizontalLine("CBOS", CBOS, Colors.Blue, 1, LineStyle.Solid);


            // 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);
        }
示例#19
0
        protected override void OnTick()
        {
            if (_GoLong)
            {
                // Find Number of Open Positions With defined Label (Stop Mode)
                var _LNOP = Positions.FindAll(_LLabel);
                if (_LNOP != null)
                {
                    foreach (var lnop in _LNOP)
                    {
                        _LongX++;
                    }
                }
                // Find Number of Pending Orders with defined Label (Limit Mode)
                if (PendingOrders.Count != 0)
                {
                    foreach (var _FPP in PendingOrders)
                    {
                        if (_FPP != null)
                        {
                            if (_FPP.Label == _LLabel)
                            {
                                _LongLX++;
                            }
                        }
                        else
                        {
                            _LongLX++;
                        }
                    }
                }
                else
                {
                    _LongLX++;
                }
                // Find if last position with this Label was profitable
                var _FLPP = History.FindLast(_LLabel);
                //Find Last Position Profit
                if (_FLPP != null)
                {
                    if (_FLPP.NetProfit > 0)
                    {
                        _LongX++;
                        _LongLX++;
                        Stop();
                    }
                }
                //If there is no Position then Draw a line (Stop Mode)
                if (_LongX == 0 && Symbol.Ask <= _LongPrice && !_LModeL)
                {
                    ChartObjects.DrawHorizontalLine(_LLabel, _LongPrice, Colors.SteelBlue, 2, LineStyle.DotsVeryRare);
                }
                //If there is no Position then Draw a line (Limit Mode)
                if (_LongLX == 0 && Symbol.Ask >= _LongPrice && _LModeL)
                {
                    ChartObjects.DrawHorizontalLine(_LLabel, _LongPrice, Colors.SteelBlue, 2, LineStyle.DotsVeryRare);
                }
                //Execute Order - First the Stop Mode
                if (Symbol.Ask >= _LongPrice && _LongX == 0 && _LCurrentTries < _MaxTries && !_LModeL)
                {
                    ExecuteMarketOrder(TradeType.Buy, Symbol, _LVolume, _LLabel, SLoss, TakeProfit);
                    _LCurrentTries++;
                    ChartObjects.RemoveObject(_LLabel);
                    if (_OCOMode)
                    {
                        _GoShort = false;
                        ChartObjects.RemoveObject(_SLabel);
                    }
                }
                //Execute Order - Limit Mode
                if (Symbol.Ask >= _LongPrice && _LongLX == 0 && _LCurrentTries < _MaxTries && _LModeL)
                {
                    PlaceLimitOrder(TradeType.Buy, Symbol, _LVolume, _LongPrice, _LLabel, SLoss, TakeProfit);
                    _LCurrentTries++;
                    ChartObjects.RemoveObject(_LLabel);
                    if (_OCOMode)
                    {
                        _GoShort = false;
                        ChartObjects.RemoveObject(_SLabel);
                    }
                }

                //Find Total Profit on Positions Closed
                var _LPCO = History.FindAll(_LLabel);
                foreach (var lpco in _LPCO)
                {
                    _LTCProfit += lpco.NetProfit;
                }
                //Add profit of current position
                if (_LongLX == 1 || _LongX == 1)
                {
                    var _LFCP = Positions.Find(_LLabel);
                    if (_LFCP != null)
                    {
                        _LTCProfit += _LFCP.NetProfit;
                    }
                }

                ChartObjects.DrawText("Long Current Profit", "Long: Current Net Profit: " + Math.Round(_LTCProfit, 2).ToString() + " || Number of Tries: " + _LCurrentTries.ToString(), StaticPosition.TopRight, Colors.SteelBlue);
                _LTCProfit = 0;
                _LongX = 0;
                _LongLX = 0;
            }

            // Short Mode

            if (_GoShort)
            {
                //Find Number of Positions
                var _SNOP = Positions.FindAll(_SLabel);
                if (_SNOP != null)
                {
                    foreach (var snop in _SNOP)
                    {
                        _ShortX++;
                    }
                }
                //Find Number of Pending Orders
                //Find Number of Short Pendings
                if (PendingOrders.Count != 0)
                {
                    foreach (var _FNSP in PendingOrders)
                    {
                        if (_FNSP != null)
                        {
                            if (_FNSP.Label == _SLabel)
                            {
                                _ShortLX++;
                                //Print("ShortLX is {0}", _ShortLX);
                            }
                        }
                        else
                        {
                            _ShortLX++;
                            //Print("ShortLX is {0}", _ShortLX);
                        }
                    }
                }
                else
                {
                    _ShortLX++;
                }
                // Find if last position with this Label was profitable
                var _FLPPS = History.FindLast(_SLabel);
                //Find Last Position Profit
                if (_FLPPS != null)
                {
                    if (_FLPPS.NetProfit > 0)
                    {
                        _ShortX++;
                        _ShortLX++;
                        Stop();
                    }
                }

                if (_ShortX == 0 && Symbol.Bid >= _ShortPrice && !_LModeS)
                {
                    ChartObjects.DrawHorizontalLine(_SLabel, _ShortPrice, Colors.Red, 2, LineStyle.DotsVeryRare);
                }

                if (_ShortLX == 0 && Symbol.Bid <= _ShortPrice && _LModeS)
                {
                    ChartObjects.DrawHorizontalLine(_SLabel, _ShortPrice, Colors.Red, 2, LineStyle.DotsVeryRare);
                }

                //First Stop Mode
                if (Symbol.Bid <= _ShortPrice && _ShortX == 0 && _SCurrentTries < _MaxTries && !_LModeS)
                {
                    ExecuteMarketOrder(TradeType.Sell, Symbol, _SVolume, _SLabel, SLoss, TakeProfit);
                    _SCurrentTries++;
                    ChartObjects.RemoveObject(_SLabel);
                    if (_OCOMode)
                    {
                        _GoLong = false;
                        ChartObjects.RemoveObject(_LLabel);
                    }
                }
                //Limit Mode
                if (Symbol.Bid >= _ShortPrice && _ShortLX == 0 && _SCurrentTries < _MaxTries && !_LModeS)
                {
                    PlaceLimitOrder(TradeType.Sell, Symbol, _SVolume, _ShortPrice, _SLabel, SLoss, TakeProfit);
                    _SCurrentTries++;
                    ChartObjects.RemoveObject(_SLabel);
                    if (_OCOMode)
                    {
                        _GoLong = false;
                        ChartObjects.RemoveObject(_LLabel);
                    }
                }

                var _SPCO = History.FindAll(_SLabel);
                foreach (var spco in _SPCO)
                {
                    _STCProfit += spco.NetProfit;
                }

                // Short - Find Current Profit
                if (_ShortX == 0 || _ShortLX == 0)
                {
                    var _SFCP = Positions.Find(_SLabel);
                    if (_SFCP != null)
                    {
                        _STCProfit += _SFCP.NetProfit;
                    }
                }

                ChartObjects.DrawText("Short Current Profit", "Short: Current Net Profit: " + Math.Round(_STCProfit, 2).ToString() + " || Number of Tries: " + _SCurrentTries.ToString(), StaticPosition.TopLeft, Colors.Red);

                _STCProfit = 0;
                _ShortX = 0;
                _ShortLX = 0;
            }

            if (_IPS)
            {
                if (_SCurrentTries == _STryN)
                {
                    _SVolume += _Volume;
                    _STryN += _TryN;
                }

                if (_LCurrentTries == _LTryN)
                {
                    _LVolume += _Volume;
                    _LTryN += _TryN;
                }
            }
        }
示例#20
0
        public override void Calculate(int index)
        {
            Result[index]  = _mas.Result[index];
            Average[index] = _mas.Average[index];

            #region GetSignalTwo
            SignalTwo = "";
            if (Result[index] > 0)
            {
                if (Average[index] > 0)
                {
                    if (Result[index] > Average[index])
                    {
                        SigTwo[index] = Result[index] - Average[index];
                        if (SigTwo[index] > Brk)
                        {
                            SignalTwo = "aboveBreak";
                        }
                    }
                    else
                    {
                        SigTwo[index] = 0;
                    }
                }
                else
                {
                    SigTwo[index] = -(Result[index] - Average[index]);
                }
            }
            else
            {
                if (Average[index] < 0)
                {
                    if (Result[index] < Average[index])
                    {
                        SigTwo[index] = Math.Abs(Result[index] - Average[index]);
                        if (SigTwo[index] > Brk)
                        {
                            SignalTwo = "belowBreak";
                        }
                    }
                    else
                    {
                        SigTwo[index] = 0;
                    }
                }
                else
                {
                    SigTwo[index] = Result[index] - Average[index];
                }
            }
            #endregion

            SignalOne = GetSigOne(index);
            if (SignalOne == "below")
            {
                SigOne_B[index] = _mas.Result[index];
            }
            else
            {
                SigOne_B[index] = 0;
            }
            if (SignalOne == "above")
            {
                SigOne_A[index] = _mas.Result[index];
            }
            else
            {
                SigOne_A[index] = 0;
            }

            #region Chart
            BarsAgo = _mas.BarsAgo;
            Mark    = GetMark(index).ToString("yyyy-MM-dd") + "-" + GetMark(index).ToString("HH");
            if (string.IsNullOrEmpty(SignalOne))
            {
                ChartObjects.DrawText("SignalOne", "NoSignal-1", StaticPosition.TopLeft, _nocorel);
            }
            else
            {
                ChartObjects.DrawText("SignalOne", "Signal1_(" + SignalOne + ")", StaticPosition.TopLeft, _nocorel);
            }
            if (string.IsNullOrEmpty(SignalTwo))
            {
                ChartObjects.DrawText("SignalTwo", "\nNoSignal-2", StaticPosition.TopLeft, _nocorel);
            }
            else
            {
                ChartObjects.DrawText("SignalTwo", "\nSignal2_(" + SignalTwo + ")", StaticPosition.TopLeft, _nocorel);
            }
            ChartObjects.DrawText("barsago", "\n\nCross_(" + BarsAgo.ToString() + ")", StaticPosition.TopLeft, _nocorel);
            ChartObjects.DrawText("mark", "\n\n\nMark_(" + Mark + ")", StaticPosition.TopLeft, _nocorel);
            ChartObjects.DrawText("break", "\n\n\n\n" + GetBreak(index), StaticPosition.TopLeft, _nocorel);
            ChartObjects.DrawHorizontalLine("breakLine", Brk, Colors.DarkCyan);
            #endregion
        }
示例#21
0
文件: NRE.cs 项目: mikewusg/nre
        protected override void OnTimer()
        {
            int index = MarketSeries.Close.Count - 1;

            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            try
            {
                NI = DisplayUpcomingNews();
            } catch (Exception e)
            {
                Log("Exception3: {0}", e.Message);
            }

            //If we have an order we can che
            if (!ShowNewsOnly)
            {
                try
                {
                    var remainingTime = _triggerTimeInServerTimeZone - Server.Time;
                    DrawRemainingTime(remainingTime);
                } catch (Exception e)
                {
                    Log("Exception4: {0}", e.Message);
                }
            }

            if (ShowPastNews)
            {
                //If first loop, we need to check all histarical bars for news
                if (first_run)
                {
                    for (int idx = 0; idx < index; idx++)
                    {
                        DisplayPastNews(idx);
                    }
                    first_run = false;
                }
                //Otherwise just the latest
                else
                {
                    DisplayPastNews(index);
                }
            }

            //If we have no pending ordes or positions open we need to setup next newstrade (switch _ordersCreated to false)
            if (_ordersCreated && !PendingOrders.Any(o => o.Label == Label) && ((Positions.FindAll(Label, Symbol, TradeType.Buy).Length + Positions.FindAll(Label, Symbol, TradeType.Sell).Length) == 0))
            {
                Log("Resuming Order operations");
                _ordersCreated = false;
            }

            //If we have a market order and it is active then leave. This is really Ugly....
            if (_ordersCreated && (Positions.Count > 0))
            {
                if (TrailingStop)
                {
                    updateSL();
                }
                return;
            }

            try
            {
                _triggerTimeInServerTimeZone = NI.UtcDateTime;
            } catch (Exception e)
            {
                Log("Exception5: {0}", e.Message);
            }

            if (!_ordersCreated && !ShowNewsOnly)
            {
                //ExecuteMarketOrder(TradeType.Sell, Symbol, 1000, Label, null, 1);
                //ExecuteMarketOrder(TradeType.Buy, Symbol, 1000, Label, null, 1);
                //_ordersCreated = true;
                var sellOrderTargetPrice = Symbol.Bid - PipsAway * Symbol.PipSize;
                ChartObjects.DrawHorizontalLine("sell target", sellOrderTargetPrice, Colors.Red, 1, LineStyle.DotsVeryRare);
                var buyOrderTargetPrice = Symbol.Ask + PipsAway * Symbol.PipSize;
                ChartObjects.DrawHorizontalLine("buy target", buyOrderTargetPrice, Colors.Blue, 1, LineStyle.DotsVeryRare);

                if (Server.Time <= _triggerTimeInServerTimeZone && (_triggerTimeInServerTimeZone - Server.Time).TotalSeconds <= SecondsBefore)
                {
                    _ordersCreated = true;
                    var expirationTime = _triggerTimeInServerTimeZone.AddSeconds(SecondsTimeout);

                    if (TrailingStop)
                    {
                        PlaceStopOrder(TradeType.Sell, Symbol, Volume, sellOrderTargetPrice, Label, StopLoss, null, expirationTime);
                        PlaceStopOrder(TradeType.Buy, Symbol, Volume, buyOrderTargetPrice, Label, StopLoss, null, expirationTime);
                    }
                    else
                    {
                        PlaceStopOrder(TradeType.Sell, Symbol, Volume, sellOrderTargetPrice, Label, StopLoss, TakeProfit, expirationTime);
                        PlaceStopOrder(TradeType.Buy, Symbol, Volume, buyOrderTargetPrice, Label, StopLoss, TakeProfit, expirationTime);
                    }

                    ChartObjects.RemoveObject("sell target");
                    ChartObjects.RemoveObject("buy target");
                }
            }
        }
示例#22
0
        public override void Calculate(int index)
        {
            EnvelopeMain[index] = expo.Result[index];

            if (index < 1)
            {
                // If first bar is first bar of the day set open
                if (MarketSeries.OpenTime[index].TimeOfDay == TimeSpan.Zero)
                {
                    Open[index] = MarketSeries.Open[index];
                }
                return;
            }

            DateTime     openTime     = MarketSeries.OpenTime[index];
            DateTime     lastOpenTime = MarketSeries.OpenTime[index - 1];
            const string objectName   = "messageNA";

            if (!ApplicableTimeFrame(openTime, lastOpenTime))
            {
                // Display message that timeframe is N/A
                const string text = "TimeFrame Not Applicable. Choose a lower Timeframe";
                ChartObjects.DrawText(objectName, text, StaticPosition.TopLeft, Colors.Red);
                return;
            }

            // If TimeFrame chosen is applicable remove N/A message
            ChartObjects.RemoveObject(objectName);

            // Plot Daily Open and Close
            PlotDailyOpenClose(openTime, lastOpenTime, index);

            double Pips = 0;

            if (Symbol.Ask > openprice)
            {
                Pips = (Symbol.Ask - openprice) / Symbol.PipSize;
            }

            if (Symbol.Ask < openprice)
            {
                Pips = (openprice - Symbol.Ask) / Symbol.PipSize;
            }

            double Profit = (Pips / 100) * 1000;


            var name1     = "Open";
            var text1     = "Open: " + openprice.ToString() + " Ask: " + Symbol.Ask + "\n Pips: " + (int)Pips + "\n Month Open Profit (1 Lot): " + (int)Profit + " USD";
            var staticPos = StaticPosition.TopRight;
            var color     = Colors.Yellow;

            ChartObjects.DrawText(name1, text1, staticPos, color);



            var name12      = "Pips";
            var text12      = "Pips: " + (int)Pips + "\n Month Open Profit (1.0 Lot): " + (int)Profit + " USD (Initial Deposit 10000$)" + "\n Month Open Profit (0.10 Lot): " + (int)Profit / 10 + " USD (Initial Deposit 1000$)" + "\n Month Open Profit (0.01 Lot): " + (int)Profit / 100 + " USD (Initial Deposit 100$)  \n Profit = (Pips / 100) * 1000USD for 1Lot(100000) ";
            var staticPos12 = StaticPosition.BottomRight;
            var color12     = Colors.YellowGreen;

            ChartObjects.DrawText(name12, text12, staticPos12, color12);


            if (Set100Levels && MinLevel < MaxLevel)
            {
                for (int i = MinLevel; i < MaxLevel; i++)
                {
                    ChartObjects.DrawHorizontalLine("Level" + i, i * 100 * Symbol.PipSize, Colors.DodgerBlue, 2, LineStyle.Solid);
                }
            }
        }
        public override void Calculate(int index)
        {
            if (RainbowSet)
            {
                EnvelopeMain[index] = expo.Result[index];
                ChannelUp1[index]   = expo.Result[index] + (expo.Result[index] * BandDistance1) / 100;
                ChannelUp2[index]   = expo.Result[index] + (expo.Result[index] * BandDistance2) / 100;
                ChannelUp3[index]   = expo.Result[index] + (expo.Result[index] * BandDistance3) / 100;
                ChannelUp4[index]   = expo.Result[index] + (expo.Result[index] * BandDistance4) / 100;
                ChannelUp5[index]   = expo.Result[index] + (expo.Result[index] * BandDistance5) / 100;
                ChannelUp6[index]   = expo.Result[index] + (expo.Result[index] * BandDistance6) / 100;

                ChannelLow1[index] = expo.Result[index] - (expo.Result[index] * BandDistance1) / 100;
                ChannelLow2[index] = expo.Result[index] - (expo.Result[index] * BandDistance2) / 100;
                ChannelLow3[index] = expo.Result[index] - (expo.Result[index] * BandDistance3) / 100;
                ChannelLow4[index] = expo.Result[index] - (expo.Result[index] * BandDistance4) / 100;
                ChannelLow5[index] = expo.Result[index] - (expo.Result[index] * BandDistance5) / 100;
                ChannelLow6[index] = expo.Result[index] - (expo.Result[index] * BandDistance6) / 100;
            }


            if (MAx3Set)
            {
                MA1[index] = expo1.Result[index];
                MA2[index] = expo2.Result[index];
                MA3[index] = expo3.Result[index];
            }

            if (L1)
            {
                LineBold = 1;
            }
            if (L2)
            {
                LineBold = 2;
            }
            if (L3)
            {
                LineBold = 3;
            }
            if (L4)
            {
                LineBold = 4;
            }

            if (SetRed)
            {
                LineColor = Colors.Red;
            }
            if (SetWhite)
            {
                LineColor = Colors.White;
            }
            if (SetBlack)
            {
                LineColor = Colors.Black;
            }
            if (SetGreen)
            {
                LineColor = Colors.YellowGreen;
            }

            if (Set100Levels)
            {
                for (int i = 1; i < 200; i++)
                {
                    ChartObjects.DrawHorizontalLine("LineLevel" + i, i * 100 * Symbol.PipSize, LineColor, LineBold);
                }
            }
        }
        public override void Calculate(int index)
        {
            if (index < 1)
            {
                // If first bar is first bar of the day set open
                if (MarketSeries.OpenTime[index].TimeOfDay == TimeSpan.Zero)
                {
                    Open[index] = MarketSeries.Open[index];
                }
                return;
            }

            DateTime     openTime     = MarketSeries.OpenTime[index];
            DateTime     lastOpenTime = MarketSeries.OpenTime[index - 1];
            const string objectName   = "messageNA";

            if (!ApplicableTimeFrame(openTime, lastOpenTime))
            {
                // Display message that timeframe is N/A
                const string text = "TimeFrame Not Applicable. Choose a lower Timeframe";
                ChartObjects.DrawText(objectName, text, StaticPosition.TopLeft, Colors.Red);
                return;
            }

            // If TimeFrame chosen is applicable remove N/A message
            ChartObjects.RemoveObject(objectName);

            // Plot Daily Open and Close
            PlotDailyOpenClose(openTime, lastOpenTime, index);

            string Side = "BUY";

            double PipsWeek = 0;

            PipsWeek = (Symbol.Ask - openprice) / Symbol.PipSize;

            double Pips = 0;

            if (Symbol.Ask > openprice)
            {
                Pips = (Symbol.Ask - openprice) / Symbol.PipSize;
            }

            if (Symbol.Ask < openprice)
            {
                Pips = (openprice - Symbol.Ask) / Symbol.PipSize;
                Side = "SELL";
            }

            double Profit = (Pips / 100) * 1000;
            double PL     = Math.Round(Account.Equity - Account.Balance);

            var name1     = "Week";
            var text1     = "Week Open : " + openprice.ToString() + "\n Week open pips:  " + (int)PipsWeek + " Side: " + Side;
            var staticPos = StaticPosition.TopRight;
            var color     = Colors.Red;

            ChartObjects.DrawText(name1, text1, staticPos, color);

            var name12      = "Pips";
            var text12      = "Position P&L: " + PL + " \n Week open pips : " + (int)PipsWeek + " Side: " + Side + " \n Each 0.01 Lot earn => " + (int)Profit / 100 + " USD (Initial Deposit 100$)";
            var staticPos12 = StaticPosition.BottomLeft;
            var color12     = Colors.DodgerBlue;

            ChartObjects.DrawText(name12, text12, staticPos12, color12);


            if (Set100Levels && MinLevel < MaxLevel)
            {
                for (int i = MinLevel; i < MaxLevel; i++)
                {
                    ChartObjects.DrawHorizontalLine("Level100" + i, i * 100 * Symbol.PipSize, Colors.DodgerBlue, 2, LineStyle.Solid);
                }
            }

            if (Set500Levels && MinLevel < MaxLevel)
            {
                for (int i = MinLevel; i < MaxLevel; i++)
                {
                    ChartObjects.DrawHorizontalLine("Level500" + i, i * 500 * Symbol.PipSize, Colors.YellowGreen, 3, LineStyle.Solid);
                }
            }
        }
        public override void Calculate(int index)
        {
            if (index < 1)
            {
                // If first bar is first bar of the day set open
                if (MarketSeries.OpenTime[index].TimeOfDay == TimeSpan.Zero)
                {
                    OpenWeek[index]  = MarketSeries.Open[index];
                    OpenMonth[index] = MarketSeries.Open[index];
                    OpenDay[index]   = MarketSeries.Open[index];
                    return;
                }
            }

            DateTime     openTime     = MarketSeries.OpenTime[index];
            DateTime     lastOpenTime = MarketSeries.OpenTime[index - 1];
            const string objectName   = "messageNA";

            if (!ApplicableTimeFrame(openTime, lastOpenTime))
            {
                // Display message that timeframe is N/A
                const string text = "TimeFrame Not Applicable. Choose a lower Timeframe";
                ChartObjects.DrawText(objectName, text, StaticPosition.TopLeft, Colors.Red);
                return;
            }

            // If TimeFrame chosen is applicable remove N/A message
            ChartObjects.RemoveObject(objectName);

            // Plot Daily Open and Close
            PlotDailyOpenClose(openTime, lastOpenTime, index);

            // Day pips
            double Pips1 = 0;

            //if (Symbol.Ask > openprice1)
            Pips1 = (Symbol.Ask - openprice1) / Symbol.PipSize;
            //if (Symbol.Ask < openprice1)
            //Pips1 = (openprice1 - Symbol.Ask) / Symbol.PipSize;
            double Profit1 = (Pips1 / 100) * 1000;
            var    text0   = "Day Open:    " + openprice1.ToString() + "\nPips: " + (int)Pips1;

            ChartObjects.DrawText("Day", text0, StaticPosition.TopLeft, Colors.Green);

            // Week pips
            double Pips2 = 0;

            //if (Symbol.Ask > openprice2)
            Pips2 = (Symbol.Ask - openprice2) / Symbol.PipSize;
            //if (Symbol.Ask < openprice2)
            //    Pips2 = (openprice2 - Symbol.Ask) / Symbol.PipSize;
            double Profit2 = (Pips2 / 100) * 1000;
            var    text2   = "\n\nWeek Open: " + openprice2.ToString() + "\nPips: " + (int)Pips2;

            ChartObjects.DrawText("Week", text2, StaticPosition.TopLeft, Colors.Red);

            // Month pips
            double Pips3 = 0;

            //if (Symbol.Ask > openprice3)
            Pips3 = (Symbol.Ask - openprice3) / Symbol.PipSize;
            //if (Symbol.Ask < openprice3)
            //    Pips3 = (openprice3 - Symbol.Ask) / Symbol.PipSize;
            double Profit3 = (Pips3 / 100) * 1000;
            var    text3   = "\n\n\n\nMonth Open: " + openprice3.ToString() + "\nPips: " + (int)Pips3;

            ChartObjects.DrawText("Month", text3, StaticPosition.TopLeft, Colors.Gold);

            // 100 pips levels
            if (Set100Levels && MinLevel < MaxLevel)
            {
                for (int i = MinLevel; i < MaxLevel; i++)
                {
                    ChartObjects.DrawHorizontalLine("Level" + i, i * 100 * Symbol.PipSize, Colors.Gray, 1, LineStyle.LinesDots);
                }
            }

            if (Set500Levels && MinLevel < MaxLevel)
            {
                for (int i = MinLevel; i < MaxLevel; i++)
                {
                    ChartObjects.DrawHorizontalLine("Level500" + i, i * 500 * Symbol.PipSize, Colors.DodgerBlue, 1, LineStyle.Solid);
                }
            }
        }