Ejemplo n.º 1
0
        protected override void OnBarUpdate()
        {
            AddHeader();
            if (CurrentBars[0] < 10)
            {
                return;
            }

            if (BarsInProgress == 0)
            {
                if (IsFirstTickOfBar)
                {
                    if (ToTime(Time[0]) == ToTime(Opening))
                    {
                        //Print("Open \t "+FormatDateTime() + "\t" + cumulativeDelta.DeltaClose[0]);
                        gxDelta = cumulativeDelta.DeltaClose[0];
                    }
                    if (ToTime(Time[0]) == ToTime(SampleEnd))
                    {
                        //Print("Sample \t" + FormatDateTime() + "\t" + cumulativeDelta.DeltaClose[0]);
                        tenDelta = cumulativeDelta.DeltaClose[0];
                        string thisLine = FormatDateTime() + ", " + gxDelta + ", " + tenDelta;
                        AddNewLine(thisLine: thisLine);
                    }
                }
            }
            else if (BarsInProgress == 1)
            {
                // We have to update the secondary series of the hosted indicator to make sure the values we get in BarsInProgress == 0 are in sync
                cumulativeDelta.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);
                //Add your custom indicator logic here.
            }
        }
        protected override void OnBarUpdate()
        {
            if (CurrentBars[0] < 10)
            {
                return;
            }

            if (BarsInProgress == 0)
            {
                // Print the close of the cumulative delta bar with a delta type of Bid Ask and with a Session period
                // Print("Delta Close: " + cumulativeDelta.DeltaClose[0]);
                if (IsFirstTickOfBar)
                {
                    Print(FormatDateTime() + "\t" + cumDeltaValue);
                }
            }
            else if (BarsInProgress == 1)
            {
                // We have to update the secondary series of the hosted indicator to make sure the values we get in BarsInProgress == 0 are in sync
                cumulativeDelta.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);

                //Add your custom indicator logic here.
                cumDeltaValue = cumulativeDelta.DeltaClose[0];


                if (cumulativeDelta.DeltaClose[0] > 0)
                {
                    DownMomo[0] = 0;
                    if (DeltaMomo[1] > 0)
                    {
                        DeltaMomo[0] = DeltaMomo[1] + cumulativeDelta.DeltaClose[0];
                    }
                    else
                    {
                        DeltaMomo[0] = cumulativeDelta.DeltaClose[0];
                    }

                    UpMomo[0] = DeltaMomo[0];
                }

                if (cumulativeDelta.DeltaClose[0] < 0)
                {
                    UpMomo[0] = 0;
                    if (DeltaMomo[1] < 0)
                    {
                        DeltaMomo[0] = DeltaMomo[1] + cumulativeDelta.DeltaClose[0];
                    }
                    else
                    {
                        DeltaMomo[0] = cumulativeDelta.DeltaClose[0];
                    }

                    DownMomo[0] = DeltaMomo[0];
                }
            }
        }
        protected override void OnBarUpdate()
        {
            if (CurrentBars[0] < 10)
            {
                return;
            }
            Print(Time[0].ToShortTimeString());
            if (BarsInProgress == 1)
            {
                // We have to update the secondary series of the hosted indicator to make sure the values we get in BarsInProgress == 0 are in sync
                cumulativeDelta.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);
//				cumulativeDeltaRth.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);
//				AvgDelta[0] = cumulativeDeltaRth.DeltaClose[0];
//				CumSma[0] = SMA(cumulativeDeltaRth.DeltaClose, Smoothing)[0];
//				CumSmaLonger[0] = SMA(cumulativeDeltaRth.DeltaClose, Smoothing * 3)[0];
            }
        }
Ejemplo n.º 4
0
        private void calcCumDelta()
        {
            if (BarsInProgress == 1 && CurrentBars[0] > 35)
            {
                // We have to update the secondary series of the hosted indicator to make sure the values we get in BarsInProgress == 0 are in sync
                cumulativeDelta.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);
                cumulativeDeltaRth.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);
                fastSeries[0] = EMA(cumulativeDeltaRth.DeltaClose, 34)[0];

                // set cumulative delta avg
                if (fastSeries[0] >= 0.0)
                {
                    PlotBrushes[1][0] = Brushes.Cyan;
                    biasMessage       = "Weak Bull";
                    cumDeltaTrend     = 1;
                    if (fastSeries[0] <= cumulativeDeltaRth.DeltaClose[0])
                    {
                        PlotBrushes[1][0] = Brushes.DodgerBlue;
                        biasMessage       = "Bull";
                        cumDeltaTrend     = 1;
                    }
                }

                if (fastSeries[0] <= 0.0)
                {
                    PlotBrushes[1][0] = Brushes.Magenta;
                    biasMessage       = "Weak Bear";
                    cumDeltaTrend     = -1;
                    if (fastSeries[0] >= cumulativeDeltaRth.DeltaClose[0])
                    {
                        PlotBrushes[1][0] = Brushes.Red;
                        biasMessage       = "Bear";
                        cumDeltaTrend     = -1;
                    }
                }
            }

            //Draw.TextFixed(this, "MyTextFixed", biasMessage, TextPosition.TopRight);
        }
        protected override void OnBarUpdate()
        {
            if (CurrentBars[0] < 10)
            {
                return;
            }

            if (BarsInProgress == 0)
            {
            }
            else if (BarsInProgress == 1)
            {
                // We have to update the secondary series of the hosted indicator to make sure the values we get in BarsInProgress == 0 are in sync
                cumulativeDelta.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);
                cumulativeDeltaRth.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);
                CumSma[0] = EMA(cumulativeDeltaRth.DeltaClose, Smoothing)[0];


                // set cumulative delta avg
                if (CumSma[0] >= 0.0)
                {
                    PlotBrushes[2][0] = Brushes.Cyan;
                    biasMessage       = "Weak Bull";
                    if (ColorBars)
                    {
                        BarBrush           = Brushes.Cyan;
                        CandleOutlineBrush = Brushes.Cyan;
                    }
                    if (CumSma[0] <= cumulativeDeltaRth.DeltaClose[0])
                    {
                        PlotBrushes[2][0] = Brushes.DodgerBlue;
                        biasMessage       = "Bull";
                        if (ColorBars)
                        {
                            BarBrush           = Brushes.DodgerBlue;
                            CandleOutlineBrush = Brushes.DodgerBlue;
                        }
                    }
                }

                if (CumSma[0] <= 0.0)
                {
                    PlotBrushes[2][0] = Brushes.Magenta;
                    biasMessage       = "Weak Bear";
                    if (ColorBars)
                    {
                        BarBrush           = Brushes.Magenta;
                        CandleOutlineBrush = Brushes.Magenta;
                    }
                    if (CumSma[0] >= cumulativeDeltaRth.DeltaClose[0])
                    {
                        PlotBrushes[2][0] = Brushes.Red;
                        biasMessage       = "Bear";
                        if (ColorBars)
                        {
                            BarBrush           = Brushes.Red;
                            CandleOutlineBrush = Brushes.Red;
                        }
                    }
                }
            }
            Draw.TextFixed(this, "MyTextFixed", biasMessage, TextPosition.TopRight);
        }
Ejemplo n.º 6
0
        protected override void OnBarUpdate()
        {
            if (CurrentBars[0] < 10)
            {
                return;
            }

            if (BarsInProgress == 0)
            {
                // Print the close of the cumulative delta bar with a delta type of Bid Ask and with a Session period
                // Print("Delta Close: " + cumulativeDelta.DeltaClose[0]);
                //if ( IsFirstTickOfBar )
                //Print(FormatDateTime() + "\t" + cumDeltaValue);
            }
            else if (BarsInProgress == 1)
            {
                // We have to update the secondary series of the hosted indicator to make sure the values we get in BarsInProgress == 0 are in sync
                cumulativeDelta.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);
                cumulativeDeltaRth.Update(cumulativeDelta.BarsArray[1].Count - 1, 1);
                Cumualtive[0]   = cumulativeDeltaRth.DeltaClose[0];
                CumSma[0]       = SMA(cumulativeDeltaRth.DeltaClose, Smoothing)[0];
                CumSmaLonger[0] = SMA(cumulativeDeltaRth.DeltaClose, Smoothing * 3)[0];

                // set cumulative delta momentum
                if (cumulativeDelta.DeltaClose[0] > 0)
                {
                    Momo[0] = 0;
                    if (DeltaMomo[1] > 0)
                    {
                        DeltaMomo[0] = DeltaMomo[1] + cumulativeDelta.DeltaClose[0];
                    }
                    else
                    {
                        DeltaMomo[0] = cumulativeDelta.DeltaClose[0];
                    }

                    Momo[0]           = DeltaMomo[0];
                    PlotBrushes[0][0] = Brushes.DodgerBlue;
                }

                if (cumulativeDelta.DeltaClose[0] < 0)
                {
                    Momo[0] = 0;
                    if (DeltaMomo[1] < 0)
                    {
                        DeltaMomo[0] = DeltaMomo[1] + cumulativeDelta.DeltaClose[0];
                    }
                    else
                    {
                        DeltaMomo[0] = cumulativeDelta.DeltaClose[0];
                    }

                    Momo[0]           = DeltaMomo[0];
                    PlotBrushes[0][0] = Brushes.Red;
                }

                // set cumulative delta avg
                if (CumSma[0] >= 0.0)
                {
                    PlotBrushes[2][0] = Brushes.DodgerBlue;
                }
                else
                {
                    PlotBrushes[2][0] = Brushes.Red;
                }


                // set CumSmaLonger delta avg
                if (CumSmaLonger[0] >= 0.0)
                {
                    PlotBrushes[3][0] = Brushes.DodgerBlue;
                }
                else
                {
                    PlotBrushes[3][0] = Brushes.Red;
                }

                // bearish bias
                if (Cumualtive[0] < 0.0)
                {
                    if (ColorBars)
                    {
                        BarBrush           = Brushes.Red;
                        CandleOutlineBrush = Brushes.Red;
                    }
                    biasMessage       = "Bear";
                    PlotBrushes[1][0] = Brushes.Red;
                    if (Cumualtive[0] > CumSma[0])
                    {
                        biasMessage = "Weak Bear";
                        if (ColorBars)
                        {
                            BarBrush           = Brushes.Magenta;
                            CandleOutlineBrush = Brushes.Magenta;
                        }
                        PlotBrushes[1][0] = Brushes.Magenta;
                    }
                }
                // bullish bias
                if (Cumualtive[0] > 0.0)
                {
                    if (ColorBars)
                    {
                        BarBrush           = Brushes.DodgerBlue;
                        CandleOutlineBrush = Brushes.DodgerBlue;
                    }
                    biasMessage       = "Bull";
                    PlotBrushes[1][0] = Brushes.DodgerBlue;
                    if (Cumualtive[0] < CumSma[0])
                    {
                        biasMessage = "Weak Bull";
                        if (ColorBars)
                        {
                            BarBrush           = Brushes.Cyan;
                            CandleOutlineBrush = Brushes.Cyan;
                        }
                        PlotBrushes[1][0] = Brushes.Cyan;
                    }
                }
            }


            Draw.TextFixed(this, "MyTextFixed", biasMessage, TextPosition.TopRight);
        }