Example #1
0
        public double CCIPredictor(mypointstrate instance, int period)          //Calculating predicted CCI value
        {
            if (instance.CurrentBars[0] <= 0)
            {
                return(0);
            }
            else
            {
                double mean = 0;
                double last = SMA(instance.Typicals[0], period)[0] * Math.Min(instance.CurrentBars[0] + 1, period);
                double estimatedSMA;

                if (instance.CurrentBars[0] + 1 >= period)
                {
                    estimatedSMA = (last + (lastHigh + lastClose + lastLow) / 3 - instance.Typicals[0][period - 1]) / Math.Min(instance.CurrentBars[0] + 1, period);
                }
                else
                {
                    estimatedSMA = (last + (lastHigh + lastClose + lastLow) / 3) / (Math.Min(instance.CurrentBars[0] + 1, period) + 1);
                }
                for (int index = Math.Min(instance.CurrentBars[0], period - 2); index >= 0; index--)
                {
                    mean += Math.Abs(instance.Typicals[0][index] - estimatedSMA);
                }
                mean += Math.Abs((lastHigh + lastClose + lastLow) / 3 - estimatedSMA);
                return(((lastHigh + lastClose + lastLow) / 3 - estimatedSMA) / (mean.ApproxCompare(0) == 0 ? 1 : (0.015 * (mean / Math.Min(period, CurrentBar + 1)))));
            }
        }
Example #2
0
 public sell_2lpb(mypointstrate instance, double pull_back)
 {
     Instance  = instance;
     legs      = new double[7];
     legs[0]   = pull_back;
     reference = pull_back;
 }
Example #3
0
 public void IntraBar(mypointstrate instance, bool isBuy)                //Determining is market on your favour based on previous bar
 {
     if (High[1] > High[0] && Low[1] < Low[0])
     {
         return;
     }
     if (isBuy)
     {
         if (instance.Close[0] - instance.Open[0] > 0)
         {
             double barTop    = instance.High[0] - instance.Close[0];
             double barHeight = instance.Close[0] - instance.Open[0];
             double barBottom = instance.Open[0] - instance.Low[0];
             if (barTop <= barHeight && barBottom >= (barTop + barHeight) && barBottom >= 0.5 ||
                 barTop * 2 <= barHeight && barBottom * 2 <= barHeight && barHeight >= 0.5)
             {
                 buyEntryBar = true;
             }
         }
         else if (instance.Close[0] - instance.Open[0] < 0)
         {
             double barTop    = instance.High[0] - instance.Open[0];
             double barHeight = instance.Open[0] - instance.Close[0];
             double barBottom = instance.Close[0] - instance.Low[0];
             if (barBottom >= 2 * barHeight && barTop <= barHeight + 0.25 && barHeight <= 0.5)
             {
                 buyEntryBar = true;
             }
         }
         else
         {
             double barTop    = instance.High[0] - instance.Open[0];
             double barBottom = instance.Open[0] - instance.Low[0];
             if (barBottom > 2 * barTop && barBottom >= 0.75)
             {
                 buyEntryBar = true;
             }
         }
     }
     else
     {
         if (instance.Close[0] - instance.Open[0] < 0)
         {
             double barTop    = instance.High[0] - instance.Open[0];
             double barHeight = instance.Open[0] - instance.Close[0];
             double barBottom = instance.Close[0] - instance.Low[0];
             if (barBottom <= barHeight && barTop >= (barBottom + barHeight) && barTop >= 0.5 ||
                 barBottom * 2 <= barHeight && barTop * 2 <= barHeight && barHeight >= 0.5)
             {
                 sellEntryBar = true;
             }
         }
         else if (instance.Close[0] - instance.Open[0] > 0)
         {
             double barTop    = instance.High[0] - instance.Close[0];
             double barHeight = instance.Close[0] - instance.Open[0];
             double barBottom = instance.Open[0] - instance.Low[0];
             if (barTop >= 2 * barHeight && barBottom <= barHeight + 0.25 && barHeight <= 0.5)
             {
                 sellEntryBar = true;
             }
         }
         else
         {
             double barTop    = instance.High[0] - instance.Open[0];
             double barBottom = instance.Open[0] - instance.Low[0];
             if (barTop > 2 * barBottom && barTop >= 0.75)
             {
                 sellEntryBar = true;
             }
         }
     }
 }
Example #4
0
 public TrendQueue(mypointstrate instance, int capacity) : base(capacity)
 {
     this.instance = instance;
 }