protected override void OnStart()
        {
            dataOps = new DataOps(this);
            dataOps.Reconcile();

            //events registration
            Positions.Closed += PositionsOnClosed;
            Positions.Opened += PositionsOnOpened;

            //constants
            T = Symbol.TickValue;
            S = Symbol.TickSize;
            //factor multiplier in converting target in ticks to compare position P/L in Pips
            factor = Symbol.PipSize / S;

            //indicators
            psar = Indicators.ParabolicSAR(minAF, maxAF);

            //strategies
            strGs = new Strategy[2];
            Print("b4 psar");
            var psr = new PsarStrategy(this);

            SendAlert("OnStart()");
            var ping = new PingPongStrategy(this);


            strGs[0] = psr;
            strGs[1] = ping;
        }
示例#2
0
        public string filePath; //full path to positions data file

        //c'tor
        public PositionsDataFileOps(DataOps dataOps, PositionsDataTableOps dto)
        {
            this.dataOps = dataOps;
            this.dto     = dto;
            this.label   = dataOps.cBot.Label; //used for building path for data files

            //build directory and file paths
            string desktopFolder = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            string dir           = label + "_data";

            dirPath  = Path.Combine(desktopFolder, dir);
            fileName = label + "_" + dataOps.cBot.Symbol.Code + ".dat";
            filePath = Path.Combine(dirPath, fileName);

            //check for existance of directory, create if none
            if (!Directory.Exists(dirPath))
            {
                Directory.CreateDirectory(dirPath);
            }

            //if there is not file, make an empty one to allow program to run
            if (!File.Exists(filePath))
            {
                WriteDataTableToCSV(dto.BuildDataTableSchema(), filePath, ',');
            }
        }
        }                                      //ref. to associated cBot

        //c'tor
        public PositionsDataTableOps(DataOps dataOps)
        {
            this.dataOps = dataOps;
            //build positions data table with schema
            pdt = GetOpenPositionsTable();
        }