Beispiel #1
0
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
			var macdval = ma1.next(Input[0]) - ma2.next(Input[0]);
			trigger = trigger + alpha*(macdval - trigger);
            MACD.Set(macdval);
            Hist.Set(scale*(macdval-trigger));
        }
        public void DeleteHist(int id)
        {
            Hist hist = GetHist(id);

            histRepository.Remove(hist);
            histRepository.SaveChanges();
        }
Beispiel #3
0
        public List <Hist> get_linha_hist(int id, DateTime ini, DateTime fim)
        {
            int         cont = 0;
            List <Hist> hist = new List <Hist>();

            while (!linhaDisp)
            {
                if (cont > 100000)
                {
                    return(hist);
                }
            }
            linhaDisp = false;
            try
            {
                string       jon = "";
                StreamReader rd  = new StreamReader(pasta + id + ".data");
                while (!rd.EndOfStream)
                {
                    jon = rd.ReadLine();
                    JavaScriptSerializer ser = new JavaScriptSerializer();
                    Hist h = ser.Deserialize <Hist>(jon);
                    if (h.time >= ini && h.time <= fim)
                    {
                        hist.Add(h);
                    }
                }
                rd.Close();
            }
            catch { }
            linhaDisp = true;
            return(hist);
        }
Beispiel #4
0
    private static void Testing(string s, string expect)
    {
        Console.WriteLine("testing: " + s);
        string actual = Hist.hist(s);

        Console.WriteLine("Actual\n" + actual);
        Console.WriteLine("Expect\n" + expect);
        Console.WriteLine("-");
        Assert.AreEqual(expect, actual);
    }
Beispiel #5
0
        public bool exec_log(Linha l)
        {
            bool        ret  = false;
            int         cont = 0;
            List <Hist> hist = new List <Hist>();

            while (!linhaDisp)
            {
                if (cont > 100000)
                {
                    return(ret);
                }
            }
            linhaDisp = false;

            List <string> buffer = new List <string>();

            try
            {
                if (File.Exists(pasta + l.id + ".data"))
                {
                    StreamReader rd = new StreamReader(pasta + l.id + ".data");
                    while (!rd.EndOfStream)
                    {
                        buffer.Add(rd.ReadLine());
                    }
                    rd.Close();
                    rd.Dispose();
                }
                else
                {
                }
            }
            catch { }

            try
            {
                Hist h = new Hist(l.parado_t, l.rodando_t, l.espera_t, l.falha_t, l.parado_per, l.rodando_per, l.espera_per, l.falha_per);
                buffer.Add(JsonConvert.SerializeObject(h));
                StreamWriter wr = new StreamWriter(pasta + l.id + ".data");
                for (int x = 0; x < buffer.Count; x++)
                {
                    wr.WriteLine(buffer[x]);
                }
                wr.Close();
                wr.Dispose();
                ret = true;
            }
            catch (Exception ex) { string m = ex.Message; }

            linhaDisp = true;
            return(ret);
        }
Beispiel #6
0
 private void MakeTable()
 {
     for (var i = 1; i <= _rHeaders.Count; i++)
     {
         var l = CreateHeaderCell(_rHeaders[i - 1].ToString());
         MGrid.Children.Add(l, 0, i);
         for (var j = 0; j < _cHeaders.Count; j++)
         {
             var v = Hist.Find(pair => pair.Key.Item1.Equals(_cHeaders[j]) &&
                               pair.Key.Item2.Equals(_rHeaders[i - 1])).Value;
             var lb = CreateNormalCell(v);
             MGrid.Children.Add(lb, j + 1, i);
         }
     }
 }
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            if (CurrentBar < 2)
            {
                MACD.Set(0);
                Smooth.Set(0);
                Hist.Set(0);
                return;
            }

            MACD.Set(fast[0] - slow[0]);
            Smooth.Set(Smooth[1] + 0.25 * (MACD[0] - Smooth[1]));
            Hist.Set(MACD[0] - Smooth[0]);
            if ((Hist[0] > Hist[1]) ||
                ((Hist[0] == Hist[1]) && (Hist[1] > Hist[2])))
            {
                PlotColors[2][0] = Color.MidnightBlue;
            }
        }
Beispiel #8
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         id          = Convert.ToInt32(Request.QueryString["id"]);
         tbName.Text = new PatientDAO().getName(id);
         DataSet D = new DataSet();
         D = new PaymentDAO().getHist(id);
         if (D != null)
         {
             if (D.Tables[0].Rows.Count != 0)
             {
                 Hist.DataSource = D;
                 Hist.DataBind();
             }
             else
             {
                 Hist.DataSource = null;
                 Hist.DataBind();
             }
         }
     }
 }
Beispiel #9
0
    private void Prog_In_Timer_Tick(object sender, EventArgs e)
    {
        //Inrement by +1 in progressbar #1 (get it started)
        ProgressBar1.Increment(+1);


        //Add percent towards the central label
        Label2.Text = "Loading... " + ProgressBar1.Value.ToString + "%";
        IO.StreamReader r = default(IO.StreamReader);


        //Self-setup and checkup

        if (ProgressBar1.Value == "1")
        {
            if (My.Computer.FileSystem.DirectoryExists("C:\\CoderRevolt\\WebBrowser\\V1"))
            {
                //Check if returning user
            }
            else
            {
                //If user is new, then create core directory folder
                My.Computer.FileSystem.CreateDirectory("C:\\CoderRevolt\\WebBrowser\\V1");
            }
        }

        //Make sure History and Bookmarks panels are loaded up for next ProgressCheck @ Value '10'
        if (ProgressBar1.Value == "5")
        {
            Hist.Show();
            Hist.Hide();

            Bookmarks.Show();
            Bookmarks.Hide();
        }

        //Bookmark Self-Check and Setup
        if (ProgressBar1.Value == "10")
        {
            if (My.Computer.FileSystem.FileExists("C:\\CoderRevolt\\WebBrowser\\V1\\Bookmarks.gwbb"))
            {
                r = new IO.StreamReader("C:\\CoderRevolt\\WebBrowser\\V1\\Bookmarks.gwbb");
                while ((r.Peek() > -1))
                {
                    Bookmarks.ListBox1.Items.Add(r.ReadLine);
                }
                r.Close();
            }
            else
            {
            }
            if (My.Computer.FileSystem.FileExists("C:\\CoderRevolt\\WebBrowser\\V1\\Bookmarks2.gwbb"))
            {
                r = new IO.StreamReader("C:\\CoderRevolt\\WebBrowser\\V1\\Bookmarks2.gwbb");
                while ((r.Peek() > -1))
                {
                    Bookmarks.ListBox2.Items.Add(r.ReadLine);
                }
                r.Close();
            }
            else
            {
            }
        }

        //History Self-Check and Setup
        if (ProgressBar1.Value == "20")
        {
            if (My.Computer.FileSystem.FileExists("C:\\CoderRevolt\\WebBrowser\\V1\\History1.gwbb"))
            {
                r = new IO.StreamReader("C:\\CoderRevolt\\WebBrowser\\V1\\History1.gwbb");
                while ((r.Peek() > -1))
                {
                    Hist.ListBox1.Items.Add(r.ReadLine);
                }
                r.Close();
            }
            else
            {
            }
            if (My.Computer.FileSystem.FileExists("C:\\CoderRevolt\\WebBrowser\\V1\\History2.gwbb"))
            {
                r = new IO.StreamReader("C:\\CoderRevolt\\WebBrowser\\V1\\History2.gwbb");
                while ((r.Peek() > -1))
                {
                    Hist.ListBox2.Items.Add(r.ReadLine);
                }
                r.Close();
            }
            else
            {
            }
        }
        if (ProgressBar1.Value == "100")
        {
            Prog_In_Timer.Stop();
            this.Hide();

            Main.Show();
        }
    }
        /// <summary>
        /// Calculates the indicator value(s) at the current index.
        /// </summary>
        protected override void OnBarUpdate()
        {
            if (!init)
            {
                BMACD   = MACD(Input, fast, slow, smooth);
                EMAMACD = EMA(BMACD, bandperiod);
                HMAMACD = HMA(BMACD, smooth);
                SDBB    = StdDev(BMACD, bandperiod);
            }
            init = true;
            double macdValue = HMAMACD[0];            //BMACD[0];

            BBMACD.Set(macdValue);
            BBMACDLine.Set(macdValue);
            BBMACDFrame.Set(macdValue);

            //double avg = EMA(BBMACD,bandperiod)[0];
            double avg = EMAMACD[0];

            Average.Set(avg);
            ZeroLine.Set(0);

            //double stdDevValue = StdDev(BBMACD,bandperiod)[0];
            double stdDevValue = SDBB[0];

            Upper.Set(avg + StdDevNumber * stdDevValue);
            Lower.Set(avg - StdDevNumber * stdDevValue);


//			if(Rising(Average))
//				if(paintbars)
//				{
//					BarColor = bbAverageUp;
//					CandleOutlineColor = candleoutlinecolorup;
//				}
//			if(Falling(Average))
//				if(paintbars)
//				{
//					BarColor = bbAverageDn;
//					CandleOutlineColor = candleoutlinecolorup;
//				}

            if (Rising(BBMACD))
            {
                if (BBMACD[0] < Upper[0])
                {
                    PlotColors[0][0] = DotsUpInside;
                    if (showhistogram)
                    {
                        Hist.Set((macdValue - avg));
                        PlotColors[10][0] = DotsUpInside;
                    }
                    updotdrawn = false;                                                 // added by TheWizard March 15, 2011
                }
                else
                {
                    PlotColors[0][0] = DotsUpOutside;
                    if (showhistogram)
                    {
                        Hist.Set((macdValue - avg));
                        PlotColors[10][0] = DotsUpOutside;
                    }
                    if (drawDotOnPricePanel)                                                                          // added by TheWizard March 15, 2011
                    {
                        if (updotdrawn == false)                                                                      // added by TheWizard March 15, 2011
                        {
                            DrawDot("UpDots" + CurrentBar, true, 0, Low[0] - dotSeparation * TickSize, BBdotUpColor); // added by TheWizard March 15, 2011
                            DrawDot("UpDots2" + CurrentBar, true, 0, Low[0] - dotSeparation * (TickSize * 2), BBdotUpColor);
                            updotdrawn   = true;                                                                      // added by TheWizard March 15, 2011
                            downdotdrawn = false;                                                                     // added by TheWizard March 15, 2011
                            if (bbviolationsound)
                            {
                                if (FirstTickOfBar)
                                {
                                    PlaySound(bbviolationupsound);
                                }
                            }
                        }
                    }
                }
                if (paintbars)
                {
                    BarColor           = barcolorup;
                    CandleOutlineColor = candleoutlinecolorup;
                }
            }
            else
            {
                if (BBMACD[0] > Lower[0])
                {
                    PlotColors[0][0] = DotsDownInside;
                    if (showhistogram)
                    {
                        Hist.Set((macdValue - avg));
                        PlotColors[10][0] = DotsDownInside;
                    }
                    downdotdrawn = false;                                       // added by TheWizard March 15, 2011
                }
                else
                {
                    PlotColors[0][0] = DotsDownOutside;
                    if (showhistogram)
                    {
                        Hist.Set((macdValue - avg));
                        PlotColors[10][0] = DotsDownOutside;
                    }
                    if (drawDotOnPricePanel)                                                                           // added by TheWizard March 15, 2011
                    {
                        if (downdotdrawn == false)                                                                     // added by TheWizard March 15, 2011
                        {
                            DrawDot("DnDots" + CurrentBar, true, 0, High[0] + dotSeparation * TickSize, BBdotDnColor); // added by TheWizard March 15, 2011
                            DrawDot("DnDots2" + CurrentBar, true, 0, High[0] + dotSeparation * (TickSize * 2), BBdotDnColor);
                            downdotdrawn = true;                                                                       // added by TheWizard March 15, 2011
                            updotdrawn   = false;                                                                      // added by TheWizard March 15, 2011
                            if (bbviolationsound)
                            {
                                if (FirstTickOfBar)
                                {
                                    PlaySound(bbviolationdnsound);
                                }
                            }
                        }
                    }
                }
                if (paintbars)
                {
                    BarColor           = barcolordn;
                    CandleOutlineColor = candleoutlinecolordn;
                }
            }
            if (BBMACD[0] > avg)
            {
                if (conservative)
                {
                    PlotColors[2][0] = BBAverageUp;
                    if (BBMACD[0] > 0)
                    {
                        PlotColors[5][0] = ZeroPositive;
                    }
                    if (BBMACD[0] < 0)
                    {
                        PlotColors[5][0] = ZeroNegative;
                    }
                }
                else
                {
                    PlotColors[2][0] = BBAverageUp;
                    PlotColors[5][0] = ZeroPositive;
                    if (colorbackground)
                    {
                        BackColor = Color.FromArgb(opacity, backgroundcolorUp);
                    }
                    if (colorALLbackgrounds)
                    {
                        BackColorAll = Color.FromArgb(opacity, backgroundcolorUp);
                    }
                }
            }

            if (BBMACD[0] < avg)
            {
                if (conservative)
                {
                    PlotColors[2][0] = BBAverageDn;
                    if (BBMACD[0] > 0)
                    {
                        PlotColors[5][0] = ZeroPositive;
                    }
                    if (BBMACD[0] < 0)
                    {
                        PlotColors[5][0] = ZeroNegative;
                    }
                }
                else
                {
                    PlotColors[2][0] = BBAverageDn;
                    PlotColors[5][0] = ZeroNegative;
                    if (colorbackground)
                    {
                        BackColor = Color.FromArgb(opacity, backgroundcolorDn);
                    }
                    if (colorALLbackgrounds)
                    {
                        BackColorAll = Color.FromArgb(opacity, backgroundcolorDn);
                    }
                }
            }

            //PlotColors[2][0] = BBAverage;
            PlotColors[3][0] = BBUpper;
            PlotColors[4][0] = BBLower;
            PlotColors[6][0] = ZeroCross;
            PlotColors[7][0] = Connector;

            if (BBMACD[0] > 0)
            {
                if (conservative)
                {
                    if (colorbackground)
                    {
                        BackColor = Color.FromArgb(opacity, backgroundcolorUp);
                    }
                    if (colorALLbackgrounds)
                    {
                        BackColorAll = Color.FromArgb(opacity, backgroundcolorUp);
                    }
                }
                if (CurrentBar != 0 && BBMACD[1] <= 0)
                {
                    MACDCross.Set(0);
                    if (zerolinecrosssound)
                    {
                        if (FirstTickOfBar)
                        {
                            PlaySound(longwavfilename);
                        }
                    }
                }

                else
                {
                    MACDCross.Reset();
                }
            }
            else
            {
                if (conservative)
                {
                    if (colorbackground)
                    {
                        BackColor = Color.FromArgb(opacity, backgroundcolorDn);
                    }
                    if (colorALLbackgrounds)
                    {
                        BackColorAll = Color.FromArgb(opacity, backgroundcolorDn);
                    }
                }
                if (CurrentBar != 0 && BBMACD[1] > 0)
                {
                    MACDCross.Set(0);
                    if (zerolinecrosssound)
                    {
                        if (FirstTickOfBar)
                        {
                            PlaySound(shortwavfilename);
                        }
                    }
                }
                else
                {
                    MACDCross.Reset();
                }
            }
        }
Beispiel #11
0
 public void UpdateHist(Hist hist)
 {
     histRepository.Update(hist);
 }
Beispiel #12
0
 public void InsertHist(Hist hist)
 {
     histRepository.Insert(hist);
 }
Beispiel #13
0
        public static PairLong ComputeHistMatch(ArrayList words, int th, int eps = 1)
        {
            Global.alg = "HPJ";
            long rcnt = 0;
            long candidta_cnt = 0;
            int[] matches_arr = new int[words.Count];
            int[] indx = new int[words.Count];
            invlists = new Hashtable();
            invertedlists = new Hashtable();
            invlist_length = new Hashtable();
            words.Sort(new StringComparer());
            string ts=(string) words[words.Count-1];
            //biuild hist
            Hist[] hists = new Hist[words.Count];
            for (int j = 0; j < words.Count; j++)
            {
                hists[j] = new Hist((string)words[j]);
            }

            int len = 0;
            int progress = (int)Math.Ceiling(words.Count / 100.0);
            for (int j = (int)(0); j < words.Count; j++)
            {
                int e = eps;
                if (j % progress == 0)
                {
                    Console.Write(".");
                }

                string s = (string)words[j];
                if (s.Length != len)
                {
                    if (s.Length > th)
                    {
                        cleanList(s.Length - th - 1);
                    }

                }
                string ss = s;
                //two cases: if s is shorter than threshold
                if (s.Length >= th + eps)
                {
                    //tdasd is ok
                    ss = s;
                }
                else if (s.Length < th + 1)
                {
                    //append the difference
                    ss = "";
                    for (int i = 0; i < th + 1 - s.Length; i++)
                        ss = ss + ' ';
                    ss = s + ss;
                    e = 1;
                }
                else
                {
                    //reduce eps to  work fine
                    e = (s.Length) - th;
                }

                getMatches_noreturn(th, ss, invlists, j, matches_arr, indx);
                List<int> l = getMatches_withmemo(e, th, ss, invertedlists, j, matches_arr, indx);
                //first remove from l
                int hist_fitlered=0;
                Hist h1 = hists[j];
                for (int i = 0; i < l.Count; i++)
                {
                    Hist h2 = hists[l[i]];
                    if (h1.diff(h2) > th) hist_fitlered++;

                }
                candidta_cnt += (l.Count-hist_fitlered);

                if (Global.exact)
                {
                    foreach (int p in l)
                    {
                        int t=Lev.editdistance(s, (string)words[p], th);

                        if (t <= th)
                        {
                            //int t2=Lev.editdistance(s, (string)words[p], th);
                            /*if (t != t2)
                            {
                                int x = 0;
                                x++;
                                t2 = Lev.editdistance(s, (string)words[p], th);
                            }*/
                            rcnt++;
                        }
                    }
                }
                #region parition
                string[] ps1 = parition(ss, th, 1);
                AddPart(invlists, ss, j, ps1);
                string[] ps = parition(ss, th, e);
                AddPart(invertedlists, ss, j, ps);

                #endregion
                len = s.Length;
            }

            return new PairLong(rcnt, candidta_cnt);
        }
Beispiel #14
0
 public int diff(Hist hist)
 {
     int c=0;
     for (int i = 0; i < ALPHABET_SIZE; i++)
     {
         int d = h[i] - hist.h[i];
         if (d < 0) d = -d;
         c = c + d;
     }
     return c / 2;
 }
Beispiel #15
0
 /// <summary>
 /// Adds a command to the history.
 /// Insert at index 1 because we want a blank for index 0.
 /// </summary>
 /// <param name="item">The item to insert into the history.</param>
 public virtual void Add(T item)
 {
     Hist.Insert(1, item);
 }