private void AnalyzeOnlineTF(ChangedTF changedTF, List <int> lstScale, EnmTF TF_high, EnmTF TF_low, CRawDeal prevDeal, CRawDeal currDeal)
        {
            DateTime dtPrev = prevDeal.Moment;
            DateTime dtCurr = currDeal.Moment;


            //Get  last high TF
            CTimeFrameInfo TFinfo_low = m_dictTFArray.GetLastTimeFrameInfo(TF_low);

            /*  if (!TFinfo_low.bNotProcessedData)
             *    return;
             */


            DateTime dtFrom = new DateTime(0);
            DateTime dtTo   = new DateTime(0);



            bool b_wasChangedTF = changedTF(prevDeal.Moment, currDeal.Moment, lstScale, ref dtFrom, ref dtTo);



            if (!m_dictTFArray.IsContainTimeFrameInfo(TF_high, /*dtFrom*/ dtTo))
            {
                m_dictTFArray.AddNewTimeFrameInfo(m_isin, TF_high, /*dtFrom*/ dtTo, this);
            }

            CTimeFrameInfo TFinfo_low_prev  = m_dictTFArray.GetPrevLastTimeFrameInfo(TF_low);
            CTimeFrameInfo TFinfo_high_prev = m_dictTFArray.GetPrevLastTimeFrameInfo(TF_high);


            CTimeFrameInfo TFinfo_high = m_dictTFArray.GetLastTimeFrameInfo(TF_high);


            bool bChangedExtr = false;


            if (currDeal.ReplID > TFinfo_high.LastReplId)
            {
                TFinfo_high.numOfDeals++;
                TFinfo_high.Volume   += currDeal.Amount;
                TFinfo_high.OpenedPos = currDeal.Pos;

                //changed 2016/08/01
                //only if changed extremum do recalc
                if (TFinfo_high.HighPrice < TFinfo_low.HighPrice)
                {
                    TFinfo_high.HighPrice = currDeal.Price;
                    bChangedExtr          = true;
                }
                if (TFinfo_high.LowPrice > TFinfo_low.LowPrice)
                {
                    TFinfo_high.LowPrice = currDeal.Price;
                    bChangedExtr         = true;
                }

                TFinfo_high.LastReplId = currDeal.ReplID;

                TFinfo_high.LastUpdate = DateTime.Now;

                if (!TFinfo_high.bProcessedData)
                {
                    TFinfo_high.OpenPrice      = TFinfo_low.OpenPrice;
                    TFinfo_high.bProcessedData = true;
                }
                //KAA 2015-12-23
                //because low TF was already updated
                // if (!b_wasChangedTF)
                TFinfo_high.ClosePrice = TFinfo_low.ClosePrice;
                // else
                // TFinfo_high.ClosePrice = TFinfo_low_prev.ClosePrice; //TFinfo_low.ClosePrice;


                DateTime dtcnd = CUtilTime.NormalizeDay(dtFrom);
                //  Plaza2Connector.GUIBox.GUICandleBox.UpdateCandle(this.m_isin, TF_high.ToString(), dtcnd.ToString(), TFinfo_high);

                Plaza2Connector.GUIBox.GUICandleBox.QueueTFinfo(this.m_isin, TF_high.ToString(), dtcnd.ToString(), TFinfo_high);


                //changed 2016/08/01
                //only if changed extremum do recalc
                if (bChangedExtr)
                {
                    TriggerRecalcAllBotsUpdateTF(TF_high, TFinfo_high);
                }

                if (b_wasChangedTF)
                {
                    Log(TF_high.ToString() + " TFinfo_high.Dt=" + TFinfo_high.Dt.ToString() + " was closed prevDeal.Moment=" + prevDeal.Moment + " currDeal.Moment=" + currDeal.Moment + " TFinfo_high.ClosePrice=" + TFinfo_high.ClosePrice +
                        " TFinfo_low_prev.ClosePrice=" + TFinfo_low_prev.ClosePrice + " TFinfo_low_prev.Dt =" + TFinfo_low_prev.Dt);

                    if (Plaza2Connector.IsDealsOnline && Plaza2Connector.IsAnalyzerTFOnline)
                    {
                        TriggerRecalcAllBotsChangedTF(TF_high, TFinfo_high_prev);
                    }
                }
            }
            else
            {
            }


            //  TrapError(m_dictTFArray[TF_high.ToString()][CUtil.NormalizeDay(dtFrom)]);


            int tmp = 1;
        }
        private void AnalyzeDiskTF(ChangedTF changedTF, List <int> lstScale, EnmTF TF_high, EnmTF TF_low)
        {
            try
            {
                foreach (KeyValuePair <DateTime, CTimeFrameArray> kvp in m_dictTFArray[TF_low.ToString()]) //all dates of low TF array
                {
                    if (CUtilTime.OlderThanTwoWorkDays(kvp.Key))
                    {
                        continue;
                    }

                    CTimeFrameArray M_low_TF_Array = kvp.Value;
                    for (int i = 1; i < M_low_TF_Array.ListTimeFrameInfo.Count; i++) //each TF array
                    {
                        DateTime dtPrev = M_low_TF_Array.ListTimeFrameInfo[i - 1].Dt;
                        DateTime dtCurr = M_low_TF_Array.ListTimeFrameInfo[i].Dt;



                        DateTime dtFrom = new DateTime(0);
                        DateTime dtTo   = new DateTime(0);

                        if (changedTF(dtPrev, dtCurr, lstScale, ref dtFrom, ref dtTo))
                        {
                            //TO DO chek prev day etc

                            if (m_dictTFArray.IsContainTimeFrameInfo(TF_high, dtFrom))
                            {
                                continue; //if  already exists in high TF array than nothing to do and  continue
                            }
                            //exp logics
                            CTimeFrameInfo ntfi = null;
                            if (m_dictTFArray.GetLatestTFI(TF_high.ToString()) != null)
                            {
                                DateTime dtLast = (m_dictTFArray.GetLatestTFI(TF_high.ToString())).Dt;
                                if (dtLast > dtFrom)
                                {
                                    ntfi = m_dictTFArray.GetNewTFIPuttingtoWritePlace(m_isin, TF_high, dtFrom);
                                    //Error("Inserting data. TO DO check and remove");
                                }
                                else
                                {
                                    ntfi = m_dictTFArray.GetNewTimeFrameInfo(m_isin, TF_high, dtFrom);
                                }
                            }
                            else
                            {
                                ntfi = m_dictTFArray.GetNewTimeFrameInfo(m_isin, TF_high, dtFrom);
                            }



                            int j = i - 1;

                            //note: the last pos
                            ntfi.OpenedPos  = M_low_TF_Array.ListTimeFrameInfo[j].OpenedPos;
                            ntfi.ClosePrice = M_low_TF_Array.ListTimeFrameInfo[j].ClosePrice;


                            while (j >= 0 && M_low_TF_Array.ListTimeFrameInfo[j].Dt >= dtFrom)
                            {
                                CTimeFrameInfo currtfi = M_low_TF_Array.ListTimeFrameInfo[j];
                                ntfi.numOfDeals += currtfi.numOfDeals;
                                ntfi.Volume     += currtfi.Volume;

                                if (ntfi.HighPrice < currtfi.HighPrice)
                                {
                                    ntfi.HighPrice = currtfi.HighPrice;
                                }
                                if (ntfi.LowPrice > currtfi.LowPrice)
                                {
                                    ntfi.LowPrice = currtfi.LowPrice;
                                }

                                ntfi.OpenPrice = M_low_TF_Array.ListTimeFrameInfo[j].OpenPrice;

                                j--; //backward
                            }

                            DateTime dtcnd = CUtilTime.NormalizeDay(dtFrom);

                            //no need ? check !
                            CheckTFIConsistent(ntfi);
                        }
                    }
                    //TrapError(kvp.Value);
                }
            }
            catch (Exception e)
            {
                Error("AnalyzeDiskTF", e);
            }
        }