Example #1
0
        private void myColorsComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            string   currentColor = myColorsComboBox.SelectedItem.ToString();
            MyColors myColor      = (MyColors)Enum.Parse(typeof(MyColors), currentColor);

            selectedValuesLabel.Text = myColor.ToString();
        }
Example #2
0
        void _monitoring()
        {
            // --> Controllo se calcolare la percentuale sul bilancio
            if (MyCalcMode == CalcMode.Percentage)
            {
                BEfrom = Math.Round((FixedBalance / 100) * FixedBEfrom, 2);
                BE     = Math.Round((FixedBalance / 100) * FixedBE, 2);
            }

            // --> Raccolgo tutte le operazioni su questo simbolo
            int nPositions = 0;

            double ttnp = 0.0;

            foreach (var Position in Positions)
            {
                if (!GlobalTarget && Position.SymbolName != SymbolName)
                {
                    continue;
                }

                ttnp += Position.NetProfit;
                nPositions++;
            }

            // --> Se non ci sono trade da monitorare deattivo e basta
            if (nPositions < 1)
            {
                // --> Disattivo
                Activated = false;

                // --> Resetto il nuovo bilancio
                FixedBalance = Account.Balance;
            }

            // --> Se selezionato e se non ci sono trade, fermo il cBot
            if (AutoStop && nPositions < 1)
            {
                Stop();
            }

            // --> Valorizzo l'attivazione se raggiunto
            if (!Activated && ((BEfrom > BE && ttnp >= BEfrom) || (BEfrom < BE && ttnp <= BEfrom)))
            {
                Activated = true;
            }

            // --> Stampo a video alcune informazioni
            string scope     = (GlobalTarget) ? "all cross" : "the current cross";
            string logica    = (BEfrom == BE) ? "target" : (BEfrom > BE) ? "positive" : "negative";
            string direction = (BEfrom > BE) ? "less" : "greater";
            string netpt     = String.Format("{0:0.00}", ttnp);

            string phrase = (Activated) ? string.Format("Activated, I will close all trades for\r\n{0} if net profit is {1} or equal {2}", scope, direction, BE) : string.Format("Relax, I'm monitoring {0} for\r\n{1} logic and waiting net profit reaches {2}", scope, logica, BEfrom);

            string[] items =
            {
                "MONEY BREAK EVEN\r\n",
                phrase,
                "\r\nNET PROFIT\r\n{0}"
            };
            string info = string.Join("\r\n", items);

            info = string.Format(info, netpt);

            MyColors mycolor = (BEfrom == BE) ? Boxcolortarget : (BEfrom > BE) ? Boxcolorpositive : Boxcolornegative;

            if (Activated)
            {
                mycolor = Boxcoloractive;
            }

            Chart.DrawStaticText("BoxMBE", info, VAlign, HAlign, Color.FromName(mycolor.ToString("G")));

            // --> Se attivato e se sono la soglia di BE chiudo tutto
            if ((Activated && ((BEfrom > BE && ttnp <= BE) || (BEfrom < BE && ttnp >= BE))) || (BEfrom == BE && ((BE >= 0 && ttnp >= BE) || (BE < 0 && ttnp <= BE))))
            {
                // --> Chiudo tutti i trade

                foreach (var Position in Positions)
                {
                    if (!GlobalTarget && Position.SymbolName != SymbolName)
                    {
                        continue;
                    }

                    ClosePositionAsync(Position);
                }

                // --> Chiudo tutti gli ordini pendenti se richiesto
                if (RemovePO)
                {
                    foreach (var order in PendingOrders)
                    {
                        if (!GlobalTarget && order.SymbolName != SymbolName)
                        {
                            continue;
                        }

                        CancelPendingOrderAsync(order);
                    }
                }

                // --> Resetto il flag
                Activated = false;
            }
        }
Example #3
0
 public ColorItem(MyColors color)
 {
     this.color = color.ToString();
 }