protected void StartOfSession()
        {
            string kObj = "StartOfSession";

            ClearScalpEntryInfo();
            ClearSwingEntryInfo();
            gbCounter = 0;
            dSignalPoints.Clear();

            double emaPrimValue = EMA(emaPrimPeriod)[0];
            double emaRefValue  = EMA(emaRefPeriod)[0];

            isTrendUp       = (emaPrimValue >= emaRefValue) ? true : false;
            idxSignalPoints = 0;

            sigPoints = new SignalPoints()
            {
                BarsSinceSession = Bars.BarsSinceSession,
                EMAPrimary       = EMA(emaPrimPeriod)[0],
                EMAReference     = EMA(emaRefPeriod)[0],
                Trend            = (isTrendUp == true) ? SignalPoints.Direction.Up : SignalPoints.Direction.Dn,
                EMAHasCrossed    = false
            };
            dSignalPoints.Add(sigPoints.BarsSinceSession, sigPoints);
            idxSignalPoints++;

            kLog(kObj, "INFO", "Generate initial signal points and clear data from previous day");
        }
        protected void PrintTrendSignals()
        {
            string kObj = "PrintTrendSignals";

            kLog("");
            foreach (KeyValuePair <int, SignalPoints> key in dSignalPoints)
            {
                SignalPoints sig = key.Value;
                kLog(kObj, "CROSS", String.Format("[{0}]   cross: {1}   trend: {2}   diff: {3}",
                                                  sig.BarsSinceSession,
                                                  sig.EMAHasCrossed.ToString().ToLower(),
                                                  sig.Trend.ToString().ToUpper(),
                                                  (sig.EMAPrimary - sig.EMAReference).ToString("0.00")
                                                  ));
            }
            kLog("");
        }
 protected void AddTrendSignal()
 {
     if (isTrendUp == true)
     {
         if (CrossBelow(EMA(emaPrimPeriod), EMA(emaRefPeriod), 1) == true)
         {
             sigPoints = new SignalPoints()
             {
                 BarsSinceSession = Bars.BarsSinceSession,
                 EMAHasCrossed    = true,
                 Trend            = SignalPoints.Direction.Dn,
                 EMAPrimary       = 0,
                 EMAReference     = 0
             };
             dSignalPoints.Add(idxSignalPoints, sigPoints);
             idxSignalPoints++;
             isTrendUp = false;
         }
         if (CrossBelow(EMA(emaPrimPeriod), EMA(emaRefPeriod), 1) == false)
         {
             sigPoints = new SignalPoints()
             {
                 BarsSinceSession = Bars.BarsSinceSession,
                 EMAHasCrossed    = false,
                 Trend            = SignalPoints.Direction.Up,
                 EMAPrimary       = EMA(emaPrimPeriod)[0],
                 EMAReference     = EMA(emaRefPeriod)[0]
             };
             dSignalPoints.Add(idxSignalPoints, sigPoints);
             idxSignalPoints++;
         }
     }
     else
     {
         if (CrossAbove(EMA(emaPrimPeriod), EMA(emaRefPeriod), 1) == true)
         {
             sigPoints = new SignalPoints()
             {
                 BarsSinceSession = Bars.BarsSinceSession,
                 EMAHasCrossed    = true,
                 Trend            = SignalPoints.Direction.Up,
                 EMAPrimary       = 0,
                 EMAReference     = 0
             };
             dSignalPoints.Add(idxSignalPoints, sigPoints);
             idxSignalPoints++;
             isTrendUp = true;
         }
         if (CrossAbove(EMA(emaPrimPeriod), EMA(emaRefPeriod), 1) == false)
         {
             sigPoints = new SignalPoints()
             {
                 BarsSinceSession = Bars.BarsSinceSession,
                 EMAHasCrossed    = false,
                 Trend            = SignalPoints.Direction.Dn,
                 EMAPrimary       = EMA(emaPrimPeriod)[0],
                 EMAReference     = EMA(emaRefPeriod)[0]
             };
             dSignalPoints.Add(idxSignalPoints, sigPoints);
             idxSignalPoints++;
         }
     }
 }