Exemplo n.º 1
0
        static public List <SAPaFRow> addNewRow(List <SAPaFRow> rows, double tickPrice, double pullBackThreshold)
        {
            SAPaFRow lastRow   = rows[rows.Count - 1];
            String   lastDir   = lastRow.direction;
            double   lastStart = lastRow.startPt;
            double   lastMax   = lastRow.maxPt;
            //double lastMaxLevel = lastRow.maxLevel;
            Boolean lbOverLastMaxLevel = isOverLastMax(lastDir, tickPrice, lastMax);
            Boolean lbReverseThreshold = isReverseThreshold(lastDir, lastMax, tickPrice, pullBackThreshold);

            String newDir   = "";
            double newStart = 0.0;
            double newMax   = 0.0;

            //double newMaxLevel = 0.0;

            if (!lbOverLastMaxLevel && lbReverseThreshold)
            {
                newDir   = getOppDirection(lastDir);
                newStart = lastMax;
                newMax   = getNewReverseMaxValue(lastDir, tickPrice);

                SAPaFRow row = new SAPaFRow();
                //newMaxLevel = getMaxLevel(newMax, newDir);
                row.direction = newDir;
                row.startPt   = newStart;
                row.maxPt     = newMax;
                //row.maxLevel = newMaxLevel;
                row.startTime = DateTime.Now;
                rows.Add(row);
            }
            else
            {
                newDir   = lastDir;
                newStart = lastStart;
                if (lbOverLastMaxLevel)
                {
                    newMax = getUpdateMaxValue(lastDir, tickPrice);
                }
                else
                {
                    newMax = lastMax;
                }

                SAPaFRow row = rows[rows.Count - 1];
                //newMaxLevel = getMaxLevel(newMax, newDir);
                row.direction = newDir;
                row.startPt   = newStart;
                row.maxPt     = newMax;
                //row.maxLevel = newMaxLevel;
                //row.startTime = item.time;
            }

            return(rows);
        }
Exemplo n.º 2
0
        static public List <SAPaFRow> cloneRows(List <SAPaFRow> rows)
        {
            List <SAPaFRow> cRows = new List <SAPaFRow>();

            foreach (SAPaFRow row in rows)
            {
                SAPaFRow cRow = row.Clone() as SAPaFRow;
                cRows.Add(cRow);
            }
            return(cRows);
        }
Exemplo n.º 3
0
        static public List <SAPaFRow> addFirstNode(MarketDataElement item)
        {
            double open      = item.open;
            double close     = item.close;
            String direction = "";

            if (open > close)
            {
                direction = DROP;
            }
            else
            {
                direction = RISE;
            }

            List <SAPaFRow> rows = new List <SAPaFRow>();

            SAPaFRow row = new SAPaFRow();

            row.direction = direction;

            if (DROP.Equals(direction))
            {
                row.startPt = item.high;
                row.maxPt   = item.low;
            }
            else
            {
                row.startPt = item.low;
                row.maxPt   = item.high;
            }
            //row.maxLevel = getMaxLevel(row.maxPt, direction);
            row.startTime = item.time;
            rows.Add(row);
            return(rows);
        }