示例#1
0
        protected override void OnBarUpdate()
        {
            if (CurrentBar <= slowPrd)
            {
                return;
            }

            SpanA[0]   = (sMAX(High, fastPrd)[0] + sMIN(Low, fastPrd)[0] + sMAX(High, midPrd)[0] + sMIN(Low, midPrd)[0]) / 4;
            SpanB[0]   = (sMAX(High, slowPrd)[0] + sMIN(Low, slowPrd)[0]) / 2;
            fib6180[0] = ((sMAX(High, slowPrd)[0] - sMIN(Low, slowPrd)[0]) * 0.618) + sMIN(Low, slowPrd)[0];
            fib3820[0] = ((sMAX(High, slowPrd)[0] - sMIN(Low, slowPrd)[0]) * 0.382) + sMIN(Low, slowPrd)[0];

            HighCloud[0] = Math.Max(SpanA[0], Math.Max(SpanB[0], Math.Max(fib6180[0], fib3820[0])));
            LowCloud[0]  = Math.Min(SpanA[0], Math.Min(SpanB[0], Math.Min(fib6180[0], fib3820[0])));

            MaxCloud.Set(HighCloud[0]);
            MinCloud.Set(LowCloud[0]);

            if (SpanA[0] > SpanB[0])
            {
                DrawLine(CurrentBar.ToString(), false, -26, HighCloud[0], -26, LowCloud[0], Color.Blue, DashStyle.Solid, 1);
            }
            else
            {
                if (SpanA[0] < SpanB[0])
                {
                    DrawLine(CurrentBar.ToString(), false, -26, HighCloud[0], -26, LowCloud[0], Color.Red, DashStyle.Solid, 1);
                }
                else
                {
                    DrawLine(CurrentBar.ToString(), false, -26, HighCloud[0], -26, LowCloud[0], Color.Gray, DashStyle.Solid, 1);
                }
            }
        }
示例#2
0
        protected override void OnBarUpdate()
        {
            if (CurrentBar < 1)
            {
                return;
            }

            // Trailing stop
            double trail;
            double loss = Close[0] * ((double)Percent / 100);

            if (Close[0] > Value[1] && Close[1] > Value[1])
            {
                trail = Math.Max(Value[1], Close[0] - loss);
            }

            else if (Close[0] < Value[1] && Close[1] < Value[1])
            {
                trail = Math.Min(Value[1], Close[0] + loss);
            }

            else if (Close[0] > Value[1])
            {
                trail = Close[0] - loss;
                Draw.ArrowDown(this, CurrentBar.ToString(), false, 1, Value[1], Brushes.Orange);
            }

            else
            {
                trail = Close[0] + loss;
                Draw.ArrowUp(this, CurrentBar.ToString(), false, 1, Value[1], Brushes.Orange);
            }

            Value[0] = trail;
        }
示例#3
0
 /// ////////////////////////////////////////////////////////////////////////////////////////////////
 ///
 ///                                     Trail stop
 ///
 /// ////////////////////////////////////////////////////////////////////////////////////////////////
 protected void setTrailStop()
 {
     if (Position.MarketPosition == MarketPosition.Flat)
     {
         return;
     }
     if (Position.MarketPosition == MarketPosition.Long)
     {
         if (Low[0] > Low[1])
         {
             double newStop = Low[0] - stopDistance;
             if (newStop > trailStop)
             {
                 trailStop = newStop;
             }
         }
         if (ShowText)
         {
             Draw.TriangleUp(this, "trailStop" + CurrentBar.ToString(), false, 0, trailStop, Brushes.DimGray);
         }
         if (Low[0] <= trailStop)
         {
             ExitLong("Trail", "LE 1");
         }
     }
 }
示例#4
0
        protected override void OnBarUpdate()
        {
            if (!On)
            {
                return;
            }
            if (CurrentBar < 20)
            {
                return;
            }
            //setTextBox( textInBox: "No Entry");
            textForBox      = "\n\tNo Channel Entry\t\t\n";
            textForBoxToAdd = "\n\tNo Overreaction Entry\t\t\n";
            bool chLong  = entryConditionsChannel();
            bool orLong  = entryConditionsORlong();
            bool orShort = entryConditionsORshort();

            ///  Add Target Rules to Indicator
            ///  Add On / Off

            textForBox = textForBox + textForBoxToAdd;
            setTextBox(textInBox: textForBox);

            if (Low[0] > Low[1])
            {
                double newStop = Low[0] - stopDistance;
                if (newStop > trailStop)
                {
                    trailStop = newStop;
                }
            }
            Draw.TriangleUp(this, "trailStop" + CurrentBar.ToString(), false, 0, trailStop, Brushes.DimGray);
        }
示例#5
0
 public void checkForNil(object myobj)
 {
     if (myobj == null)
     {
         Print(CurrentBar.ToString() + " Nil: " + myobj.ToString());
     }
 }
示例#6
0
        /// looking long
        public void findLongeEntry()
        {
            if (swingData.lastHighBarnum < swingData.lastLowBarnum)
            {
                int    distanceToHigh  = CurrentBar - swingData.lastHighBarnum;
                int    distanceToLow   = CurrentBar - swingData.lastLowBarnum;
                int    lastBar         = CurrentBar - 1;
                double dnSwingDistance = Math.Abs((swingData.lastLow - swingData.lastHigh) * -1);
                double dnSwingEntry    = Math.Abs(dnSwingDistance * 0.382);
                entry.longEntryPrice = Math.Round(swingData.lastLow + dnSwingEntry, 2);                   // inputValue = Math.Round(inputValue, 2);

                /// draw down swing in green
                RemoveDrawObject("dnline" + lastBar);
                Draw.Line(this, "dnline" + CurrentBar.ToString(), false, distanceToHigh, swingData.lastHigh, distanceToLow, swingData.lastLow, Brushes.DarkGreen, DashStyleHelper.Dash, 2);
                /// draw entry line
                RemoveDrawObject("longEntry" + lastBar);
                Draw.Line(this, "longEntry" + CurrentBar.ToString(), false, distanceToHigh, entry.longEntryPrice, distanceToLow, entry.longEntryPrice, Brushes.LimeGreen, DashStyleHelper.Dash, 2);

                /// show swing low height
                double swingProfit = Math.Abs((dnSwingDistance * 0.236) * 100);
            }
            else
            {
                /// disable long entry
                entry.longEntryPrice = 0;
                entry.longLineLength = 0;
            }
        }
示例#7
0
        public Model(MRIndicator indic)
        {
            ListOfBar = new List <Bar>();

            currentBar = new CurrentBar();

            stackForMarketStop = new Stack <Print>();

            ListOfMarketStop = new List <MarketStop>();

            Histogramm = new HistogrammClass();

            DayProfile = new DayProfileClass();

            MaxVerticalVolumeBar = new DateTime();

            parent = indic;

            RangeProfiles = new List <RangeProfile2>();

            TandS_AllPrints_price  = new List <double>();
            TandS_AllPrints_volume = new List <int>();

            TandS_FilterPrints_price  = new List <double>();
            TandS_FilterPrints_volume = new List <int>();
            TandS_FilterPrints_time   = new List <DateTime>();

            stackForTickAggregator = new Stack <Print>();

            TickAggregatorElements = new List <TickAggregatorElement>();
        }
示例#8
0
        /// looking short
        public void findShortEntry()
        {
            if (swingData.lastHighBarnum > swingData.lastLowBarnum)
            {
                int    distanceToLow   = CurrentBar - swingData.lastLowBarnum;
                int    distanceToHigh  = CurrentBar - swingData.lastHighBarnum;
                int    lastBar         = CurrentBar - 1;
                double upSwingDistance = Math.Abs(swingData.lastHigh - swingData.lastLow);
                double upSwingEntry    = Math.Abs(upSwingDistance * 0.382);
                entry.shortEntryPrice = Math.Round(swingData.lastHigh - upSwingEntry, 2);

                /// draw upswing in red
                RemoveDrawObject("upline" + lastBar);
                Draw.Line(this, "upline" + CurrentBar.ToString(), false, distanceToLow, swingData.lastLow, distanceToHigh, swingData.lastHigh, Brushes.DarkRed, DashStyleHelper.Dash, 2);
                /// draw entry line
                RemoveDrawObject("shortEntry" + lastBar);
                Draw.Line(this, "shortEntry" + CurrentBar.ToString(), false, distanceToLow, entry.shortEntryPrice, distanceToHigh, entry.shortEntryPrice, Brushes.Red, DashStyleHelper.Dash, 2);
                /// show swing high height

                double swingProfit = Math.Abs((upSwingDistance * 0.236) * 100);
            }
            else
            {
                // disable short entry
                entry.shortEntryPrice = 0;
                entry.shortLineLength = 0;
            }
        }
示例#9
0
        public void drawHardStops(bool plot)
        {
            if (!plot)
            {
                return;
            }
            /// draw hard stop line
            int    lineLength = 0;
            string lineName   = "";

            if (entry.inLongTrade)
            {
                lineLength = entry.barsSinceEntry;
                lineName   = "hardStopLong";
            }
            if (entry.inShortTrade)
            {
                lineLength = CurrentBar - entry.shortEntryBarnum;
                lineName   = "hardStopShort";
            }
            if (entry.barsSinceEntry > 1)
            {
                RemoveDrawObject(lineName + (CurrentBar - 1));
            }
            Draw.Line(this, lineName + CurrentBar.ToString(), false, lineLength, entry.hardStopLine, 0,
                      entry.hardStopLine, Brushes.DarkGray, DashStyleHelper.Dot, 2);
        }
示例#10
0
        ///******************************************************************************************************************************
        ///
        ///                                         set Pivot Stop
        ///
        /// ****************************************************************************************************************************
        public void setPivotStop(int swingSize, double pivotSlop)
        {
            double lastSwingLow  = Swing1.SwingLow[swingSize];
            double lastSwingHigh = Swing1.SwingHigh[swingSize];

            /// long pivots, count pivots above entry for 2nd piv stop if  short /// close > entryswing
            if (entry.inLongTrade && ((lastSwingLow + pivotSlop) < entry.lastPivotValue) && entry.barsSinceEntry > 8)
            {
                entry.pivStopCounter++;
                Draw.Text(this, "LowSwingtxt" + CurrentBar.ToString(), entry.pivStopCounter.ToString(), swingSize, Low[swingSize] - (TickSize * 10));
                entry.lastPivotValue = lastSwingLow;
            }
            /// short pivots, count pivots above entry for 2nd piv stop if  short /// close > entryswing
            if (entry.inShortTrade && (lastSwingHigh - pivotSlop) > entry.lastPivotValue && entry.barsSinceEntry > 8)
            {
                entry.pivStopCounter++;
                Text myText = Draw.Text(this, "HighSwingtxt" + CurrentBar.ToString(), entry.pivStopCounter.ToString(), swingSize, High[swingSize] + (TickSize * 10));
                entry.lastPivotValue = lastSwingHigh;
            }
            /// draw the 2nd piv stop line //drawPivStops();
            if (entry.inLongTrade || entry.inShortTrade)
            {
                if (entry.pivStopCounter == 2)
                {
                    int lineLength = 0;
                    entry.pivLineLength++;
                    RemoveDrawObject("pivStop" + (CurrentBar - 1));
                    Draw.Line(this, "pivStop" + CurrentBar.ToString(), false, entry.pivLineLength, entry.lastPivotValue, 0,
                              entry.lastPivotValue, Brushes.Magenta, DashStyleHelper.Dot, 2);
                }
            }
            /// exit at pivot line
            exitFromPivotStop(pivotSlop: pivotSlop);
        }
        protected override void OnBarUpdate()
        {
            if (CurrentBar < 0)
            {
                return;
            }

            if (IsFirstTickOfBar)
            {
                if (CurrentBar == (Count - 2))
                {
                    System.Windows.Forms.MessageBox.Show("My message here");
                }

                DateTime timeValue = Bars.GetTime(CurrentBar);
                string   xCB       = CurrentBar.ToString();
                if (CurrentBar % 2 == 0)
                {
                    Draw.Text(this, "Even " + xCB, xCB, 0, High[0] + iOffset);
                }
                else
                {
                    Draw.Text(this, "Odd " + xCB, xCB, 0, Low[0] - iOffset);
                }
            }
        }
示例#12
0
        protected override void OnBarUpdate()
        {
            if (CurrentBar % BarsInterval == 0)
            {
                switch (DrawPosition)
                {
                case EDrawPosition.Up:
                    Draw.Text(this, "Up text " + CurrentBar, true, CurrentBar.ToString(), 0, High[0], YOffSet, Color,
                              new Gui.Tools.SimpleFont("Arial", 11), System.Windows.TextAlignment.Center,
                              Brushes.Transparent, Brushes.Transparent, 100);
                    break;

                case EDrawPosition.Low:
                    Draw.Text(this, "Low text " + CurrentBar, true, CurrentBar.ToString(), 0, Low[0], (-1 * YOffSet), Color,
                              new Gui.Tools.SimpleFont("Arial", 11), System.Windows.TextAlignment.Center,
                              Brushes.Transparent, Brushes.Transparent, 100);
                    break;

                case EDrawPosition.Both:
                    Draw.Text(this, "Up text " + CurrentBar, true, CurrentBar.ToString(), 0, High[0], YOffSet, Color,
                              new Gui.Tools.SimpleFont("Arial", 11), System.Windows.TextAlignment.Center,
                              Brushes.Transparent, Brushes.Transparent, 100);

                    Draw.Text(this, "Low text " + CurrentBar, true, CurrentBar.ToString(), 0, Low[0], (-1 * YOffSet), Color,
                              new Gui.Tools.SimpleFont("Arial", 11), System.Windows.TextAlignment.Center,
                              Brushes.Transparent, Brushes.Transparent, 100);
                    break;
                }
            }
        }
示例#13
0
        private void drawDevice(bool upDevice, string tag)
        {
            switch (PickDeviceType)
            {
            case DeviceType.Arrows:
            {
                if (upDevice)
                {
                    DrawArrowUp(tag + CurrentBar.ToString(), AutoScale, 0, Low[0] - 3 * TickSize, DeviceUpColor);
                }
                else
                {
                    DrawArrowDown(tag + CurrentBar.ToString(), AutoScale, 0, High[0] + 3 * TickSize, DeviceDownColor);
                }
                break;
            }

            case DeviceType.Diamonds:
            {
                if (upDevice)
                {
                    DrawDiamond(tag + CurrentBar.ToString(), AutoScale, 0, Low[0] - 3 * TickSize, DeviceUpColor);
                }
                else
                {
                    DrawDiamond(tag + CurrentBar.ToString(), AutoScale, 0, High[0] + 3 * TickSize, DeviceDownColor);
                }
                break;
            }

            case DeviceType.Dots:
            {
                if (upDevice)
                {
                    DrawDot(tag + CurrentBar.ToString(), AutoScale, 0, Low[0] - 3 * TickSize, DeviceUpColor);
                }
                else
                {
                    DrawDot(tag + CurrentBar.ToString(), AutoScale, 0, High[0] + 3 * TickSize, DeviceDownColor);
                }
                break;
            }

            case DeviceType.Triangles:
            {
                if (upDevice)
                {
                    DrawTriangleUp(tag + CurrentBar.ToString(), AutoScale, 0, Low[0] - 3 * TickSize, DeviceUpColor);
                }
                else
                {
                    DrawTriangleDown(tag + CurrentBar.ToString(), AutoScale, 0, High[0] + 3 * TickSize, DeviceDownColor);
                }
                break;
            }
            }
        }
示例#14
0
        protected void closeShort()
        {
            if (Position.MarketPosition != MarketPosition.Short)
            {
                return;
            }

            double stopPrice    = Double.MaxValue;
            double approxEntry  = Instrument.MasterInstrument.Round2TickSize(Position.AvgPrice);
            double lowSinceOpen = Low[LowestBar(Low, BarsSinceEntry())];

//			double tStopPrice = lowSinceOpen + (ssAtProfitTrigger * TickSize);

            // set breakeven if triggered
            if (lowSinceOpen <= (approxEntry - (ssAbeProfitTriggerS * TickSize)))
            {
                stopPrice = approxEntry;
            }             //else {
            // check for partial move to b/e
//				if (lowSinceOpen <= (approxEntry - (ssAbeProfitTrigger1 * TickSize))) {
//					stopPrice = approxEntry + (ssAbePartialAdjustment1 * TickSize);
//				} else {
            // worse case, starting stop loss setting
            //	stopPrice = (approxEntry + (ssAtStopLossS * TickSize));
//				}
            //}

//			stopPrice = Math.Min(tStopPrice, stopPrice);
            stopPrice = Math.Min(ATRTrailing(ATRTimes, ATRPeriod, ATRRatched).Lower[0], stopPrice);
            stopPrice = Math.Min(stopPrice, (approxEntry + (ssAtStopLossS * TickSize)));

            if (enableDebug)
            {
                DrawDiamond(CurrentBar.ToString() + "sdia", true, 0, stopPrice, Color.Yellow);
                //Print (Time[0] + " --PROCESS-- " + BarsSinceEntry() + "/" + BarsSinceExit() + " ----" + stopPrice);

                if (BarsSinceEntry() < -1)
                {
                    Print(Time[0] + " ----------------------");
                    Print(BarsSinceEntry() + ": approxEntry@" + approxEntry);
                    Print("lowSinceOpen: " + lowSinceOpen);
                    Print("ssAtProfitTrigger: " + ssAtProfitTrigger + ", TickSize: " + TickSize + " *= " + (ssAbeProfitTriggerS * TickSize));                     // + " --> tStopPrice: " + tStopPrice);
                    Print("(approxEntry + (ssAtStopLossS * TickSize) -> " + approxEntry + " + " + ssAtStopLossS + " * " + TickSize + " = " + (approxEntry + (ssAtStopLossS * TickSize)));
                    Print("Calculated stopPrice: " + stopPrice);
                }
            }
            if (Close[0] >= stopPrice)
            {
                //if (enableDebug) Print("ExitShort");
                ExitShort();
            }
            else
            {
                //if (enableDebug) Print("ExitShortStop Close[0]: " + Close[0] + " stopPrice: " + stopPrice);
                ExitShortStop(stopPrice);
            }
        }
示例#15
0
        protected void closeLong()
        {
            if (Position.MarketPosition != MarketPosition.Long)
            {
                return;
            }

            double stopPrice   = 0.0;
            double approxEntry = Instrument.MasterInstrument.Round2TickSize(Position.AvgPrice);

            double highSinceOpen = High[HighestBar(High, BarsSinceEntry())];

            //double tStopPrice = highSinceOpen - (ssAtProfitTrigger * TickSize);

            // set breakeven if triggered
            if (highSinceOpen >= (approxEntry + (ssAbeProfitTriggerL * TickSize)))
            {
                stopPrice = approxEntry;
                //Print("Set to B/E: " + stopPrice);
                //} else {
                //	if (highSinceOpen >= (approxEntry + (ssAbeProfitTriggerL1 * TickSize))) {
                //		stopPrice = approxEntry - (ssAbePartialAdjustment1 * TickSize);
                //		//Print("Moved up to just below B/E: " + stopPrice);
                //	} else {
                //stopPrice = (approxEntry - (ssAtStopLossL * TickSize));
                //Print("Moved up to cover stop loss: " + stopPrice);
                //	}
            }

            //stopPrice = Math.Max(tStopPrice, stopPrice);
            stopPrice = Math.Max(ATRTrailing(ATRTimes, ATRPeriod, ATRRatched).Upper[0], stopPrice);
            stopPrice = Math.Max(stopPrice, (approxEntry - (ssAtStopLossL * TickSize)));

            if (enableDebug)
            {
                DrawDiamond(CurrentBar.ToString() + "Stop", true, 0, stopPrice, Color.Green);

                if (BarsSinceEntry() == -10)
                {
                    Print("----------LONGSTOP------------");
                    Print(BarsSinceEntry() + ": approxEntry@" + approxEntry);
                    Print("highSinceOpen: " + highSinceOpen);
                    Print("ssAtProfitTrigger: " + ssAtProfitTrigger + ", TickSize: " + TickSize + " *= " + (ssAtProfitTrigger * TickSize));                     // + " --> tStopPrice: " + tStopPrice);
                    Print("(approxEntry - (sAtStopLossL * TickSize)" + approxEntry + "-" + ssAtStopLossL + "*" + TickSize + "=" + (approxEntry - (ssAtStopLossL * TickSize)));
                    Print("Calculated stopPrice: " + stopPrice);
                }
            }
            if (Close[0] <= stopPrice)
            {
                ExitLong();
            }
            else
            {
                ExitLongStop(stopPrice);
            }
        }
示例#16
0
 /// <summary>
 /// Called on each bar update event (incoming tick)
 /// </summary>
 protected override void OnBarUpdate()
 {
     // Use this method for calculating your indicator values. Assign a value to each
     // plot below by replacing 'Close[0]' with your own formula.
     if (CurrentBar < Lenght)
     {
         Trend.Set(true);
         UpTrend.Set(Close[0]);
         DownTrend.Set(Close[0]);
         return;
     }
     ;
     if (Close[0] > DownTrend[1])
     {
         Trend.Set(true);
     }
     else
     if (Close[0] < UpTrend[1])
     {
         Trend.Set(false);
     }
     else
     {
         Trend.Set(Trend[1]);
     }
     if (Trend[0] && !Trend[1])
     {
         UpTrend.Set(Median[0] - ATR(Lenght)[0] * Multiplier);
         UpTrend.Set(1, DownTrend[1]);
         if (ShowArrows)
         {
             DrawArrowUp(CurrentBar.ToString(), true, 0, UpTrend[0] - TickSize, Color.Blue);
         }
     }
     else
     if (!Trend[0] && Trend[1])
     {
         DownTrend.Set(Median[0] + ATR(Lenght)[0] * Multiplier);
         DownTrend.Set(1, UpTrend[1]);
         if (ShowArrows)
         {
             DrawArrowDown(CurrentBar.ToString(), true, 0, DownTrend[0] + TickSize, Color.Red);
         }
     }
     else
     if (Trend[0])
     {
         UpTrend.Set((Median[0] - ATR(Lenght)[0] * Multiplier) > UpTrend[1] ? (Median[0] - ATR(Lenght)[0] * Multiplier) : UpTrend[1]);
     }
     else
     {
         DownTrend.Set((Median[0] + ATR(Lenght)[0] * Multiplier) < DownTrend[1] ? (Median[0] + ATR(Lenght)[0] * Multiplier) : DownTrend[1]);
     }
 }
示例#17
0
 protected override void OnBarUpdate()
 {
     if (Close[0] > SMA(200)[0] &&
         Low[0] > Low[1] &&
         Low[1] < Low[2] &&
         Low[2] < Low[3] &&
         Low[3] < Low[4] &&
         Low[4] < Low[5]
         )
     {
         Draw.ArrowUp(this, "MyArrowUp" + CurrentBar.ToString(), false, 0, Low[0] - (TickSize * 20), Brushes.LimeGreen);
     }
 }
示例#18
0
        protected void closeLong()
        {
            if (Position.MarketPosition != MarketPosition.Long)
            {
                return;
            }

            double entryPrice = Instrument.MasterInstrument.Round2TickSize(Position.AvgPrice);

            ExitLongStop(entryPrice - StopLossLong * TickSize, "BOC Long");
            ExitLongLimit(DonchianChannel(DonchianPeriod).Mean[disp]);
            DrawDiamond(CurrentBar.ToString() + "bocStop", true, 0, entryPrice - 8 * TickSize, Color.Yellow);
        }
        /// draw a line from entry to exit, green win, red loss
        public void drawTrades(int entryBar, double entryPrice, bool win)
        {
            int entryDistance = CurrentBar - entryBar;

            if (win)
            {
                Draw.Line(this, "tradeLine" + CurrentBar.ToString(), true, entryDistance, entryPrice, 0, Close[0], Brushes.LimeGreen, DashStyleHelper.Solid, 2);
            }
            else
            {
                Draw.Line(this, "tradeLine" + CurrentBar.ToString(), true, entryDistance, entryPrice, 0, Close[0], Brushes.Crimson, DashStyleHelper.Solid, 2);
            }
        }
示例#20
0
文件: EmPower.cs 项目: coroin/embars
        /// <summary>
        /// Called on each bar update event (incoming tick)
        /// </summary>
        protected override void OnBarUpdate()
        {
            if ((High[0] - Low[0]) == 0)
            { emBop.Set(0); }
            else
            { emBop.Set((Close[0] - Open[0]) / (High[0] - Low[0])); }

            EmBop1.Set(EmMath.SMA(ref emBop, CurrentBar, Smooth1, CurrentBar == 0 ? emBop[0] : EmBop1[1]));
            EmBop2.Set(EmMath.SMA(ref emBop, CurrentBar, Smooth2, CurrentBar == 0 ? emBop[0] : EmBop2[1]));

            if (EmBop1[0] > EmBop2[0])
            { DrawRegion("EmBoP_" + CurrentBar.ToString(), 1, 0, EmBop1, EmBop2, Color.Transparent, BullColor, BullOpacity); }
            else if (EmBop2[0] > EmBop1[0])
            { DrawRegion("EmBoP_" + CurrentBar.ToString(), 1, 0, EmBop2, EmBop1, Color.Transparent, BearColor, BearOpacity); }
        }
示例#21
0
        protected override void OnBarUpdate()
        {
            if (CurrentBar == 0)
            {
                Value[0] = 0;
            }
            else
            {
                double mean = 0;
                double sma0 = sma[0];

                for (int idx = Math.Min(CurrentBar, Period - 1); idx >= 0; idx--)
                {
                    mean += Math.Abs(Typical[idx] - sma0);
                }

                Value[0] = (Typical[0] - sma0) / (mean.ApproxCompare(0) == 0 ? 1 : (0.015 * (mean / Math.Min(Period, CurrentBar + 1))));

                // crossing down
                if (CrossBelow(CCI(Period), 180, 1))
                {
                    Draw.ArrowDown(this, "200" + CurrentBar.ToString(), true, 0, High[0] + (TickSize * 200), Brushes.Red);
                    //Print("We Crossed Below 180");
                }

                if (CrossBelow(CCI(Period), 100, 1))
                {
                    Draw.TriangleDown(this, "100" + CurrentBar.ToString(), true, 0, High[0] + (TickSize * 200), Brushes.Crimson);
                    //Print("We Crossed Below 100");
                }

                // crossing up
                if (CrossAbove(CCI(Period), -180, 1))
                {
                    Draw.ArrowUp(this, "200" + CurrentBar.ToString(), true, 0, Low[0] - (TickSize * 200), Brushes.Blue);
                    //Print("We Crossed above 180");
                }

                if (CrossAbove(CCI(Period), -100, 1))
                {
                    Draw.TriangleUp(this, "100" + CurrentBar.ToString(), true, 0, Low[0] - (TickSize * 200), Brushes.DodgerBlue);
                    //Print("We Crossed above 100");
                }
            }
        }
示例#22
0
 /// Long Entry Line ************************************************************************************************************
 public void drawLongEntryLine(bool inLongTrade)
 {
     if (inLongTrade)
     {
         return;
     }
     entry.longLineLength++;
     if (entry.longEntryPrice != 0)
     {
         if (DrawObjects["LeLine" + (CurrentBar - 1).ToString()] != null)
         {
             RemoveDrawObject("LeLine" + (CurrentBar - 1));
         }
         Draw.Line(this, "LeLine" + CurrentBar.ToString(), false, entry.longLineLength, entry.longEntryPrice, 0,
                   entry.longEntryPrice, Brushes.LimeGreen, DashStyleHelper.Solid, 4);
         showLongEntryArrow(inLongTrade: entry.inLongTrade);
     }
 }
示例#23
0
 /// Short Entry Line ************************************************************************************************************
 public void drawShortEntryLine(bool inShortTrade)
 {
     if (inShortTrade)
     {
         return;
     }
     entry.shortLineLength++;
     if (entry.shortEntryPrice != 0)
     {
         if (DrawObjects["SeLine" + (CurrentBar - 1).ToString()] != null)
         {
             RemoveDrawObject("SeLine" + (CurrentBar - 1));
         }
         Draw.Line(this, "SeLine" + CurrentBar.ToString(), false, entry.shortLineLength, entry.shortEntryPrice, 0,
                   entry.shortEntryPrice, Brushes.Red, DashStyleHelper.Solid, 4);
         showShortEntryArrow(inShortTrade: entry.inShortTrade);
     }
 }
示例#24
0
 /// <summary>
 ///  Short Entry Arrow
 /// </summary>
 /// <param name="inLongTrade"></param>
 public void showShortEntryArrow(bool inShortTrade)
 {
     if (inShortTrade)
     {
         return;
     }
     if (entry.shortEntryPrice == null)
     {
         return;
     }
     if (High[0] > entry.shortEntryPrice && Low[0] < entry.shortEntryPrice)
     {
         //Draw.Text(this, "SE"+CurrentBar.ToString(), "SE", 0, entry.shortEntryPrice + (TickSize * 10), Brushes.Crimson);
         ArrowDown myArrowDn = Draw.ArrowDown(this, "SEmade" + CurrentBar.ToString(), true, 0, entry.shortEntryPrice + (TickSize * 5), Brushes.Red);
         signals[0]        = -1;
         secondPivStopFlag = false;
     }
 }
示例#25
0
//		/// Osc LH
//		public bool LowerHighOSC() {
//			bool result = false;
//			if(swingHighO == UltimateOscillator1[ 3 ]) {
//				if (swingHighO < lastSwingHighO ) {
//					if ( drawText )
//					Draw.Text(this, "hh"+ CurrentBar.ToString(),  "LH", 3, High[3] + (TickSize * 2));
//					result = true;
//				}
//				lastSwingHighO = swingHighO;
//			}
//			return result;
//		}

        // int minSwingLowOdist = 3 int swingLowOdist;
        /// Find Osc HL  /// bullish divergence  = HL on Osc + ll or equal low on price
        public bool higherLowOSC()
        {
            bool result = false;

            if (swingLowO == UltimateOscillator1[3])
            {
                swingLowObar = CurrentBar - 3;
                if (swingLowO > lastSwingLowO)
                {
                    if (drawText)
                    {
                        Draw.Text(this, "HLo" + CurrentBar.ToString(), "HLo", 3, Low[3] - (TickSize * 2));
                    }
                    result = true;
                }
                lastSwingLowO    = swingLowO;
                lastSwingLowObar = swingLowObar;
            }
            return(result);
        }
示例#26
0
 /// <summary>
 ///  Long Entry Arrow
 /// </summary>
 /// <param name="inLongTrade"></param>
 public void showLongEntryArrow(bool inLongTrade)
 {
     if (inLongTrade)
     {
         return;
     }
     if (entry.longEntryPrice == null)
     {
         return;
     }
     if (High[0] > entry.longEntryPrice && Low[0] < entry.longEntryPrice)
     {
         //Draw.Text(this, "LE"+CurrentBar.ToString(), "LE", 0, entry.longEntryPrice - (TickSize * 10), Brushes.LimeGreen);
         //customDrawTrades( show: true,  simple: false);
         ArrowUp myArrowUp = Draw.ArrowUp(this, "LEmade" + CurrentBar.ToString(), true, 0, entry.longEntryPrice - (TickSize * 5), Brushes.LimeGreen);
         signals[0]        = 1;
         secondPivStopFlag = false;
         //debugEntry(isOn:true);
     }
 }
        public string PlotTrades(bool onChart, bool showLog)
        {
            string result = numTrades.ToString() + "  $ " + tradeProfitLoss.ToString("0") + " $" + cumProfitLoss.ToString("0");

            result = result + "\nWin " + numWin.ToString() + "  Loss " + numLoss.ToString() + "\n" + pctWin.ToString("0.0") + "% ";
            result = result + profitFactor.ToString("0.00") + " pf";
            result = result + "\n+" + sumWinners.ToString("0") + " " + sumLosers.ToString("0");
            if (showLog)
            {
                Print(" ");
                Print(result);
            }

            if (onChart)
            {
                Draw.Text(this, "perform" + CurrentBar.ToString(), performanceSummary, 0, MIN(Low, 20)[0] - (TickSize * 400), ChartControl.Properties.ChartText);
            }

            return(result);
        }
示例#28
0
        /// Price LL or = L  /// bullish divergence  = HL on Osc + ll or equal low on price
        public bool lowerLowPrice()
        {
            bool result = false;

            if (swingLowP == Low[3])
            {
                swingLowPbar = CurrentBar - 3;
                if (swingLowP <= lastSwingLowP)
                {
                    if (drawText)
                    {
                        Draw.Text(this, "LLp" + CurrentBar.ToString(), "LLp", 3, Low[3] - (TickSize * 4));
                    }
                    result = true;
                }
                lastSwingLowP    = swingLowP;
                lastSwingLowPbar = swingLowPbar;
            }
            return(result);
        }
示例#29
0
            public Bar(CurrentBar curBar)
            {
                ListOfClasters = new SortedDictionary <double, Claster>();
                int Volume_sum_tmp     = 0;
                int Volume_Ask_sum_tmp = 0;
                int Volume_Bid_sum_tmp = 0;

                foreach (KeyValuePair <double, Model.CurrentClaster> kvp in curBar.ListOfCurrentBar)
                {
                    ListOfClasters.Add(kvp.Key, kvp.Value.GetStruct());
                    Volume_sum_tmp     += kvp.Value.Volume_sum;
                    Volume_Ask_sum_tmp += kvp.Value.Volume_Ask_sum;
                    Volume_Bid_sum_tmp += kvp.Value.Volume_Bid_sum;
                }
                Volume_sum     = Volume_sum_tmp;
                Volume_Ask_sum = Volume_Ask_sum_tmp;
                Volume_Bid_sum = Volume_Bid_sum_tmp;
                PocPrice       = curBar.pocPrice;
                DayPocPrice    = curBar.dayPocPrice;
                Time           = curBar.Time;
            }
示例#30
0
        protected override void OnBarUpdate()
        {
            double fastMa = EMA(34)[0];
            double medMa  = EMA(68)[0];
            double slowMa = SMA(116)[0];

            /// Long
            if (CrossAbove(EMA(34), EMA(68), 1) && Close[0] >= slowMa)
            {
                Draw.ArrowUp(this, "xUP" + CurrentBar.ToString(), true, 1, Close[0], Brushes.LimeGreen);
            }
            /// Short
            if (CrossBelow(EMA(34), EMA(68), 1) && Close[0] <= slowMa)
            {
                Draw.ArrowDown(this, "xDN" + CurrentBar.ToString(), true, 1, Close[0], Brushes.Red);
            }

            Values[0][0] = fastMa;
            Values[1][0] = medMa;
            Values[2][0] = slowMa;
        }