// constructor always goes 1st
        public MegaResponseTemplate() : base()
        {
            // Custom name of response set by you
            Name = "MegaResponseTemplate";

            // track_symbols_NewTxt() called when new text label is added
            track_symbols.NewTxt += new TextIdxDelegate(track_symbols_NewTxt);

            //     Names of the indicators used by your response.  Length must correspond to
            //     actual indicator values send with SendIndicators event
            Indicators = GenericTracker.GetIndicatorNames(gens());

            track_barlists.GotNewBar += new SymBarIntervalDelegate(GotNewBar);
        }
        string debug_message_from_constructor = ""; // need to store it and show on 1st tick, otherwise debug messages are wiped out when ticks start to arrive
        public _TS_step_by_step()
            : base()
        {
            System.Diagnostics.Debug.WriteLine("class _TS_step_by_step constructor entry point");
            string[] args = MyGlobals.args;     // extract main(args) from MyGlobals (we store main(args) in Kadina Program.cs, ASP, etc.)
            if (args == null)
            {
                throw new Exception("you forgot to set MyGlobals.args (in Kadina or asp or in whatever you use)");
            }

            string response_config = "";
            //string storage_service_config_jsonfile = "";
            string rabbitmq_config_jsonfile = "";

            var p = new OptionSet()
            {
                { "a|response-config=", "response json configuration file",
                  v => response_config = v },
                //{ "c|storage-service-config=", "path to storage_service json configuration file",
                //  v => storage_service_config_jsonfile = v},
                { "r|rabbitmq-config=", "path to rabbitmq json configuration file",
                  v => rabbitmq_config_jsonfile = v }
            };

            // parse  cmd-line args
            List <string> extra;

            try
            {
                extra = p.Parse(args);
            }
            catch (OptionException e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
                System.Diagnostics.Debug.WriteLine("Try `--help' for more information.");
                return;
            }

            // get settings from json file
            if (response_config != "")
            {
                response_parameters_holder = new ResponseParametersHolder();
                response_parameters_holder.parse_json_file(response_config);
                bson = response_parameters_holder.bson;

                //_ema_bar = Convert.ToInt32(bson["_ema_bar"]);
                _ema_bar            = BsonSerializer.Deserialize <int>(bson["_ema_bar"].ToJson());
                _response_barsize_s = BsonSerializer.Deserialize <int>(bson["_response_barsize_s"].ToJson());
                _stop_k             = BsonSerializer.Deserialize <double>(bson["_stop_k"].ToJson());
                _target_price_k     = BsonSerializer.Deserialize <double>(bson["_target_price_k"].ToJson());

                //_target_price_k = Convert.ToDouble(bson["_target_price_k"]);

                // Custom name of response set by you
                Name = BsonSerializer.Deserialize <string>(bson["name"].ToJson());

                //debug_message_from_constructor = "parsed json file - OK (set slow_ma=" + _slow_ma_bar + " fast_ma=" + _fast_ma_bar;
                //D(debug_message_from_constructor); // wtf? why this message never showed up? seems messages are cleaned right before 1st GotTick();

                //ResponseParametersHolder storage_service_parameters_holder = new ResponseParametersHolder();
                //storage_service_parameters_holder.parse_json_file(storage_service_config_jsonfile);
                //storage_service_parameters_bson = storage_service_parameters_holder.bson;

                ResponseParametersHolder rabbitmq_parameters_holder = new ResponseParametersHolder();
                rabbitmq_parameters_holder.parse_json_file(rabbitmq_config_jsonfile);
                rabbitmq_parameters_bson = rabbitmq_parameters_holder.bson;
                call_me_from_child_constructor();
            }


            // track_symbols_NewTxt() called when new text label is added
            track_symbols.NewTxt += new TextIdxDelegate(track_symbols_NewTxt);

            //     Names of the indicators used by your response.  Length must correspond to
            //     actual indicator values send with SendIndicators event
            Indicators = GenericTracker.GetIndicatorNames(gens());

            //[_response_barsize_s, 22]
            track_barlists            = new BarListTracker(new int[] { _response_barsize_s, 22 }, new BarInterval[] { BarInterval.CustomTime, BarInterval.CustomTime });
            track_barlists.GotNewBar += new SymBarIntervalDelegate(GotNewBar);
        }
        string debug_message_from_constructor = ""; // need to store it and show on 1st tick, otherwise debug messages are wiped out when ticks start to arrive
        public _SMA_Crossing_Response()
            : base()
        {
            string[] args = MyGlobals.args;

            bool   show_help       = false;
            string kadina_config   = "";
            string response_config = "";
            int    repeat          = 1;

            var p = new OptionSet()
            {
                { "k|kadina-config=", "response json configuration file",
                  v => kadina_config = v },
                { "r|response-config=", "response json configuration file",
                  v => response_config = v },
                { "z|zepeat=",
                  "the number of {TIMES} to repeat the greeting.\n" +
                  "this must be an integer.",
                  (int v) => repeat = v },
                { "v", "increase debug message verbosity",
                  v => { if (v != null)
                         {
                             ++verbosity;
                         }
                  } },
                { "h|help", "show this message and exit",
                  v => show_help = v != null },
            };

            List <string> extra;

            try
            {
                extra = p.Parse(args);
            }
            catch (OptionException e)
            {
                Console.Write("greet: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `greet --help' for more information.");
                return;
            }

            if (show_help)
            {
                ShowHelp(p);
                return;
            }



            // get settings from json file
            if (response_config != "")
            {
                response_parameters_holder = new ResponseParametersHolder();
                response_parameters_holder.parse_json_file(response_config);
                bson         = response_parameters_holder.bson;
                _slow_ma_bar = BsonSerializer.Deserialize <int>(bson["_slow_ma_bar"].ToJson());
                _fast_ma_bar = BsonSerializer.Deserialize <int>(bson["_fast_ma_bar"].ToJson());

                // Custom name of response set by you
                Name = BsonSerializer.Deserialize <string>(bson["name"].ToJson());

                debug_message_from_constructor = "parsed json file - OK (set slow_ma=" + _slow_ma_bar + " fast_ma=" + _fast_ma_bar;
                D(debug_message_from_constructor); // wtf? why this message never showed up? seems messages are cleaned right before 1st GotTick();
            }


            // track_symbols_NewTxt() called when new text label is added
            track_symbols.NewTxt += new TextIdxDelegate(track_symbols_NewTxt);

            //     Names of the indicators used by your response.  Length must correspond to
            //     actual indicator values send with SendIndicators event
            Indicators = GenericTracker.GetIndicatorNames(gens());

            track_barlists.GotNewBar += new SymBarIntervalDelegate(GotNewBar);
        }