Example #1
0
        protected double CalculateSL(ExecutionRule orderType, double openPrice)
        {
            double SL         = 0.3333;
            double CurrentBid = Instrument.Bid;
            double CurrentAsk = Instrument.Ask;

            if (((int)orderType == (int)ExecutionRule.Buy) ||
                ((int)orderType == (int)ExecutionRule.BuyStop))
            {
                if (BolaOnly)
                {
                    SL = BolaInd.SeriesDown[_CIndex];
                }
                else
                {
                    SL = openPrice - staticSL * Instrument.Point;
                }
            }
            if (((int)orderType == (int)ExecutionRule.Sell) ||
                ((int)orderType == (int)ExecutionRule.SellStop))
            {
                if (BolaOnly)
                {
                    SL = BolaInd.SeriesUp[_CIndex];
                }
                else
                {
                    SL = openPrice + staticSL * Instrument.Point;
                }
            }
            return((double)Math.Round(SL, Instrument.PriceScale));
        }
Example #2
0
        protected double CalculateOpenPrice(ExecutionRule orderType)
        {
            int cB = _CIndex;

            ExtremumMin = Bars[cB].Low;
            ExtremumMax = Bars[cB].High;

            while ((cB > (_CIndex - ExtHistoryDepth)) && (cB >= 0))
            {
                if (ExtremumMax <= Bars[cB].High)
                {
                    ExtremumMax = Bars[cB].High;
                }
                if (ExtremumMin >= Bars[cB].Low)
                {
                    ExtremumMin = Bars[cB].Low;
                }
                cB--;
            }

            if (((int)orderType == (int)ExecutionRule.Buy) ||
                ((int)orderType == (int)ExecutionRule.BuyStop))
            {
                return((double)Math.Round(ExtremumMax, Instrument.PriceScale));
            }
            if (((int)orderType == (int)ExecutionRule.Sell) ||
                ((int)orderType == (int)ExecutionRule.SellStop))
            {
                return((double)Math.Round(ExtremumMin, Instrument.PriceScale));
            }
            return((double)Math.Round((ExtremumMin + ExtremumMax) / 2.0, Instrument.PriceScale));
        }
Example #3
0
 protected double dblCalculateTP(ExecutionRule _ordertype, int mode)
 {
     if (mode == 0)
     {
         if ((int)_ordertype == (int)ExecutionRule.Sell)
         {
             if (LevelSR1)
             {
                 if (Instrument.Bid < PivotS1)
                 {
                     return((double)Math.Round(PivotS2, Instrument.PriceScale));
                 }
                 else
                 {
                     return((double)Math.Round(PivotS1, Instrument.PriceScale));
                 }
             }
             else
             {
                 return((double)Math.Round(PivotS2, Instrument.PriceScale));
             }
         }
         if ((int)_ordertype == (int)ExecutionRule.Buy)
         {
             if (LevelSR1)
             {
                 if (Instrument.Ask > PivotR1)
                 {
                     return((double)Math.Round(PivotR2, Instrument.PriceScale));
                 }
                 else
                 {
                     return((double)Math.Round(PivotR1, Instrument.PriceScale));
                 }
             }
             else
             {
                 return((double)Math.Round(PivotR2, Instrument.PriceScale));
             }
         }
     }
     else
     {
         if ((int)_ordertype == (int)ExecutionRule.Sell)
         {
             return((double)Math.Round(Instrument.Bid - (PivotS2 - PivotS3), Instrument.PriceScale));
         }
         if ((int)_ordertype == (int)ExecutionRule.Buy)
         {
             return((double)Math.Round(Instrument.Ask + (PivotR3 - PivotR2), Instrument.PriceScale));
         }
     }
     return((double)0.0);
 }
Example #4
0
 protected double CalculateOpenPrice(ExecutionRule orderType)
 {
     if (((int)orderType == (int)ExecutionRule.Buy) ||
         ((int)orderType == (int)ExecutionRule.BuyStop))
     {
         return((double)Math.Round(ExtremumMax, Instrument.PriceScale));
     }
     if (((int)orderType == (int)ExecutionRule.Sell) ||
         ((int)orderType == (int)ExecutionRule.SellStop))
     {
         return((double)Math.Round(ExtremumMin, Instrument.PriceScale));
     }
     return((double)Math.Round((ExtremumMin + ExtremumMax) / 2.0, Instrument.PriceScale));
 }
Example #5
0
        protected double CalculateSL(ExecutionRule orderType)
        {
            double SL = 0.3333;

            if ((int)orderType == (int)ExecutionRule.Sell)
            {
                SL = EnvindSL.SeriesUp[_CIndex];
            }
            if ((int)orderType == (int)ExecutionRule.Buy)
            {
                SL = EnvindSL.SeriesDown[_CIndex];
            }
            return((double)Math.Round(SL, Instrument.PriceScale));
        }
Example #6
0
        protected double CalculateTP(ExecutionRule orderType, double openPrice)
        {
            double TP = 0.3333;

            if (((int)orderType == (int)ExecutionRule.Buy) ||
                ((int)orderType == (int)ExecutionRule.BuyStop))
            {
                TP = ExtremumMax + 1500.0 * Instrument.Point;
            }
            if (((int)orderType == (int)ExecutionRule.Sell) ||
                ((int)orderType == (int)ExecutionRule.SellStop))
            {
                TP = ExtremumMin - 1500.0 * Instrument.Point;
            }
            return((double)Math.Round(TP, Instrument.PriceScale));
        }
Example #7
0
        protected double CalculateTP(ExecutionRule orderType, double openPrice)
        {
            double TP = 0.3333;

            if (((int)orderType == (int)ExecutionRule.Buy) ||
                ((int)orderType == (int)ExecutionRule.BuyStop))
            {
                TP = BolaInd.SeriesUp[_CIndex];
            }
            if (((int)orderType == (int)ExecutionRule.Sell) ||
                ((int)orderType == (int)ExecutionRule.SellStop))
            {
                TP = BolaInd.SeriesDown[_CIndex];
            }
            return((double)Math.Round(TP, Instrument.PriceScale));
        }
Example #8
0
        protected double CalculateSL(ExecutionRule orderType, double openPrice)
        {
            double SL         = 0.3333;
            double CurrentBid = Instrument.Bid;
            double CurrentAsk = Instrument.Ask;

            if (((int)orderType == (int)ExecutionRule.Buy) ||
                ((int)orderType == (int)ExecutionRule.BuyStop))
            {
                SL = ExtremumMin;
            }
            if (((int)orderType == (int)ExecutionRule.Sell) ||
                ((int)orderType == (int)ExecutionRule.SellStop))
            {
                SL = ExtremumMax;
            }
            return((double)Math.Round(SL, Instrument.PriceScale));
        }
Example #9
0
        protected double CalculateOpenPrice3B(ExecutionRule orderType)
        {
            int cB = _CIndex;

            ExtremumMin = Bars[cB].Low;
            ExtremumMax = Bars[cB].High;

            int iMAX = cB;
            int iMIN = cB;


            while ((cB > (_CIndex - ExtHistoryDepth)) && (cB >= 0))
            {
                if (ExtremumMax <= Bars[cB].High)
                {
                    ExtremumMax = Bars[cB].High;
                    iMAX        = cB;
                }
                if (ExtremumMin >= Bars[cB].Low)
                {
                    ExtremumMin = Bars[cB].Low;
                    iMIN        = cB;
                }
                cB--;
            }

            if (((int)orderType == (int)ExecutionRule.Sell) ||
                ((int)orderType == (int)ExecutionRule.SellStop))
            {
                if (iMAX != _CIndex)
                {
                    cB          = iMAX;
                    ExtremumMin = Bars[cB].Low;
                    int countExtr = 1;
                    while (countExtr < ExtremumCount && cB >= 0)
                    {
                        if (Bars[cB].Low < ExtremumMin)
                        {
                            ExtremumMin = Bars[cB].Low;
                            countExtr++;
                        }
                        cB--;
                    }
                }
                return((double)Math.Round(ExtremumMin, Instrument.PriceScale));
            }

            if (((int)orderType == (int)ExecutionRule.Buy) ||
                ((int)orderType == (int)ExecutionRule.BuyStop))
            {
                if (iMIN != _CIndex)
                {
                    cB          = iMIN;
                    ExtremumMax = Bars[cB].High;
                    int countExtr = 1;
                    while (countExtr < ExtremumCount && cB >= 0)
                    {
                        if (Bars[cB].High > ExtremumMax)
                        {
                            ExtremumMax = Bars[cB].High;
                            countExtr++;
                        }
                        cB--;
                    }
                }
                return((double)Math.Round(ExtremumMax, Instrument.PriceScale));
            }
            return((double)Math.Round((ExtremumMin + ExtremumMax) / 2.0, Instrument.PriceScale));
        }