예제 #1
0
        private void FireThresholdEvent(double spd)
        {
            IndicatorSignal isig = new IndicatorSignal();

            //if(CurrentBar < 300)
            Print(String.Format("{0}:Close={1}, PctChgSpd={2}, PctChgSpdThresholdEn={3}, PctChgSpdThresholdEx={4}",
                                CurrentBar, Close[0], spd, PctChgSpdThresholdEn, PctChgSpdThresholdEx));
            if (spd <= PctChgSpdThresholdEn)
            {
                isig.BreakoutDir = BreakoutDirection.Down;
                isig.SignalName  = SignalName_BreakdownMV;
            }
            else if (spd >= PctChgSpdThresholdEx)
            {
                isig.BreakoutDir = BreakoutDirection.Up;
                isig.SignalName  = SignalName_BreakoutMV;
            }
            else
            {
                return;
            }

            isig.BarNo = CurrentBar;
            isig.IndicatorSignalType = SignalType.SimplePriceAction;
            IndicatorEventArgs ievt = new IndicatorEventArgs(this.GetType().Name, " CheckMeanV: ");

            ievt.IndSignal = isig;
            //FireEvent(ievt);
            OnRaiseIndicatorEvent(ievt);
        }
예제 #2
0
        public void CheckVwapBreakoutDayHLEvent()
        {
            IndicatorSignal isig  = new IndicatorSignal();
            double          openD = CurrentDayOHL().CurrentOpen[0];

            //if(CurrentBar < 300)
            Print(String.Format("{0}:PlotVWAP={1},OpenD={2}",
                                CurrentBar, PlotVWAP[0], openD));
            if (PlotVWAP[0] < openD)
            {
                isig.BreakoutDir = BreakoutDirection.Down;
                isig.SignalName  = SignalName_BreakoutOpenD;
            }
            else if (PlotVWAP[0] > openD)
            {
                isig.BreakoutDir = BreakoutDirection.Up;
                isig.SignalName  = SignalName_BreakoutOpenD;
            }
            else
            {
                return;
            }

            isig.BarNo = CurrentBar;
            isig.IndicatorSignalType = SignalType.SimplePriceAction;
            IndicatorEventArgs ievt = new IndicatorEventArgs(this.GetType().Name, " CheckVwapBreakoutDayHLEvent: ");

            ievt.IndSignal = isig;
            //FireEvent(ievt);
            OnRaiseIndicatorEvent(ievt);
        }
예제 #3
0
        public void CheckBreakoutEmaTicsEvent()
        {
            IndicatorSignal isig = new IndicatorSignal();

            if (CurrentBar < 300)
            {
                Print(String.Format("{0}:Close={1},EMA={2},OffsetTicks={3}",
                                    CurrentBar, Close[0], Value[0], OffsetTicks));
            }
            if (Close[0] < Value[1] - GetPriceByTicks(OffsetTicks))
            {
                isig.BreakoutDir = BreakoutDirection.Down;
                isig.SignalName  = SignalName_BreakoutEmaDownTics;
            }
            else if (Close[0] > Value[1] + GetPriceByTicks(OffsetTicks))
            {
                isig.BreakoutDir = BreakoutDirection.Up;
                isig.SignalName  = SignalName_BreakoutEmaUpTics;
            }
            else
            {
                return;
            }

            isig.BarNo = CurrentBar;
            isig.IndicatorSignalType = SignalType.SimplePriceAction;
            IndicatorEventArgs ievt = new IndicatorEventArgs(this.GetType().Name, " CheckBreakoutEmaTicsEvent: ");

            ievt.IndSignal = isig;
            //FireEvent(ievt);
            OnRaiseIndicatorEvent(ievt);
        }
예제 #4
0
        public void CheckLastDayHLEvent()
        {
            IndicatorSignal isig = new IndicatorSignal();

            //if(CurrentBar < 300)
            Print(String.Format("{0}:Close={1},LastDaySpt={2},LastDayRst={3}",
                                CurrentBar, Close[0], LastDaySpt[0], LastDayRst[0]));
            if (Close[0] < LastDaySpt[0])
            {
                isig.BreakoutDir = BreakoutDirection.Down;
                isig.SignalName  = SignalName_BreakoutLastDLow;
            }
            else if (Close[0] > LastDayRst[0])
            {
                isig.BreakoutDir = BreakoutDirection.Up;
                isig.SignalName  = SignalName_BreakoutLastDHigh;
            }
            else
            {
                return;
            }

            isig.BarNo = CurrentBar;
            isig.IndicatorSignalType = SignalType.SimplePriceAction;
            IndicatorEventArgs ievt = new IndicatorEventArgs(this.GetType().Name, " CheckLastDayHLEvent: ");

            ievt.IndSignal = isig;
            //FireEvent(ievt);
            OnRaiseIndicatorEvent(ievt);
        }
예제 #5
0
        public void CheckTradeEvent()
        {
            int en_H = TM_OpenEndH, en_M = TM_OpenEndM, ex_H = TM_ClosingH, ex_M = TM_ClosingM;
//			Print(String.Format("{0}:CheckTradeEvent Bip{1}: en_H={2}, en_M={3}, ex_H={4}, ex_M={5}",
//				CurrentBars[BarsInProgress], BarsInProgress, en_H, en_M, ex_H, ex_M));

//			if(IsCutoffTime(BarsInProgress, ex_H, ex_M)) {
//				Print(String.Format("{0}:CheckTradeEvent Ex Bip{1}: Spread={2}, Upper={3}, Lower={4}, Middle={5}",
//				CurrentBars[BarsInProgress], BarsInProgress, Spread[0], Upper[0], Lower[0], Middle[0]));

//				IndicatorSignal isig = new IndicatorSignal();
//				Direction dir = new Direction();

//				dir.TrendDir = TrendDirection.UnKnown;
//				isig.SignalName = SignalName_ExitForOpen;
//				isig.BarNo = CurrentBars[BarsInProgress];
//				isig.TrendDir = dir;
//				isig.IndicatorSignalType = SignalType.SimplePriceAction;
//				IndicatorEventArgs ievt = new IndicatorEventArgs(this.GetType().Name, " CheckTradeEvent Ex: ");
//				ievt.IndSignal = isig;
//				OnRaiseIndicatorEvent(ievt);
//			}
//			else            //entry at 9:02 am ct, if(IsCutoffTime(BarsInProgress, en_H, en_M))
//			{
//				Print(String.Format("{0}:CheckTradeEvent En Bip{1}: Spread={2}, Upper={3}, Lower={4}, Middle={5}",
//				CurrentBars[BarsInProgress], BarsInProgress, Spread[0], Upper[0], Lower[0], Middle[0]));

            IndicatorSignal isig = new IndicatorSignal();
            Direction       dir  = new Direction();

            if (IsSpreadBreakdown())
            {
                dir.TrendDir    = TrendDirection.Up;
                isig.SignalName = SignalName_BelowStdDev;
            }
//				else if(Spread[0] <= LowerMin[0]) {
//					dir.TrendDir = TrendDirection.Up;
//					isig.SignalName = SignalName_BelowStdDevMin;
//				}
            else if (IsSpreadBreakout())
            {
                dir.TrendDir    = TrendDirection.Down;
                isig.SignalName = SignalName_AboveStdDev;
            }
//				else if(Spread[0] >= UpperMin[0]) {
//					dir.TrendDir = TrendDirection.Down;
//					isig.SignalName = SignalName_AboveStdDevMin;
//				}

            isig.BarNo               = CurrentBars[BarsInProgress];
            isig.TrendDir            = dir;
            isig.IndicatorSignalType = SignalType.SimplePriceAction;
            IndicatorEventArgs ievt = new IndicatorEventArgs(this.GetType().Name, String.Format(" [{0}] {1}", Times[BarsInProgress][0], GetLongShortText()));

            ievt.IndSignal = isig;
            //FireEvent(ievt);
            OnRaiseIndicatorEvent(ievt);
//			}
        }
예제 #6
0
        /// <summary>
        /// Add the signal to the list of the bar with barNo
        /// </summary>
        /// <param name="barNo"></param>
        /// <param name="signal"></param>
        public void AddIndicatorSignal(int barNo, IndicatorSignal signal)
        {
            List <IndicatorSignal> list_signal;

            if (!this.indicatorSignals.TryGetValue(barNo, out list_signal))
            {
                list_signal = new List <IndicatorSignal>();
            }
            list_signal.Add(signal);
            this.indicatorSignals[barNo] = list_signal;
        }
예제 #7
0
        public void AddIndicatorSignal(int barNo, string signame,
                                       SignalActionType saType, SupportResistanceRange <double> snr)
        {
            SignalAction sa = new SignalAction();

            sa.SignalActionType = saType;
            sa.SnR = snr;
            IndicatorSignal isig = new IndicatorSignal();

            isig.BarNo               = barNo;
            isig.SignalName          = signame;
            isig.IndicatorSignalType = SignalType.SimplePriceAction;
            isig.SignalAction        = sa;
            AddIndicatorSignal(barNo, isig);
        }
예제 #8
0
        /// <summary>
        /// Get the last signal before barNo by signal_name
        /// </summary>
        /// <param name="barNo"></param>
        /// <param name="signal_name"></param>
        /// <returns></returns>
        public IndicatorSignal GetLastIndicatorSignalByName(int barNo, string signal_name)
        {
            int k = barNo;

            foreach (int kk in this.indicatorSignals.Keys.Reverse())
            {
                if (kk < k)
                {
                    IndicatorSignal sig = GetIndicatorSignalByName(k, signal_name);
                    if (sig != null)
                    {
                        return(sig);
                    }
                    k = kk;
                }
            }
            return(null);
        }
예제 #9
0
        public void CheckMACrossEvent()
        {
            IndicatorSignal  isig    = new IndicatorSignal();
            SignalActionType isCross = GetMACross();

            if (isCross != SignalActionType.Unknown)
            {
                Print(String.Format("{0}:isCross={1}, BarsSinceLastCross={2}",
                                    CurrentBar, isCross, BarsSinceLastCross[1]));
                BarsSinceLastCross[0] = 0;
            }
            else
            {
                BarsSinceLastCross[0] = BarsSinceLastCross[1] + 1;
            }
            return;

            if (isCross == SignalActionType.CrossAbove)
            {
                isig.BreakoutDir = BreakoutDirection.Up;
                isig.SignalName  = SignalName_CrossAbove;
            }
            else if (isCross == SignalActionType.CrossBelow)
            {
                isig.BreakoutDir = BreakoutDirection.Down;
                isig.SignalName  = SignalName_CrossBelow;
            }
            else
            {
                return;
            }

            isig.BarNo = CurrentBar;
            isig.IndicatorSignalType = SignalType.SimplePriceAction;
            IndicatorEventArgs ievt = new IndicatorEventArgs(this.GetType().Name, " CheckMACrossEvent: ");

            ievt.IndSignal = isig;
            //FireEvent(ievt);
            OnRaiseIndicatorEvent(ievt);
        }
예제 #10
0
        public void CheckBreakoutNBarsHLEvent()
        {
            if (CurrentBar - RefBarLowestN < 1 || CurrentBar - RefBarHighestN < 1)
            {
                return;
            }
            IndicatorSignal isig = new IndicatorSignal();

            //if(CurrentBar < 300)
            if (PrintOut > 1)
            {
                Print(String.Format("{0}:Close={1},RefBarLowestN={2},RefBarLowestN={3},LowestN={4},HighestN={5}",
                                    CurrentBar, Close[0], RefBarLowestN, RefBarHighestN,
                                    LowestN[CurrentBar - RefBarLowestN], HighestN[CurrentBar - RefBarHighestN]));
            }
            if (Close[0] < LowestN[CurrentBar - RefBarLowestN])
            {
                isig.BreakoutDir = BreakoutDirection.Down;
                isig.SignalName  = SignalName_BreakoutNBarsLow;
            }
            else if (Close[0] > HighestN[CurrentBar - RefBarHighestN])
            {
                isig.BreakoutDir = BreakoutDirection.Up;
                isig.SignalName  = SignalName_BreakoutNBarsHigh;
            }
            else
            {
                return;
            }

            isig.BarNo = CurrentBar;
            isig.IndicatorSignalType = SignalType.SimplePriceAction;
            IndicatorEventArgs ievt = new IndicatorEventArgs(this.GetType().Name, " CheckBreakoutNBarsHLEvent: ");

            ievt.IndSignal = isig;
            //FireEvent(ievt);
            OnRaiseIndicatorEvent(ievt);
        }
예제 #11
0
        /// <summary>
        /// Get the last signal before barNo by signalActionType
        /// </summary>
        /// <param name="barNo"></param>
        /// <param name="signalActionType"></param>
        /// <returns></returns>
        public IndicatorSignal GetLastIndicatorSignalByActionType(int barNo, SignalActionType signal_actiontype)
        {
            int k = barNo;

            foreach (int kk in this.indicatorSignals.Keys.Reverse())
            {
                if (kk < k)
                {
                    if (barNo < 400)
                    {
                        Print(String.Format("{0}: GetLastIndicatorSignalByActionType -- kk,k={1},{2}; SignalActionType={3}",
                                            CurrentBar, kk, k, signal_actiontype.ToString()));
                    }
                    IndicatorSignal sig = GetIndicatorSignalByActionType(k, signal_actiontype);
                    if (sig != null)
                    {
                        return(sig);
                    }
                    k = kk;
                }
            }
            return(null);
        }
예제 #12
0
        public void CheckTradeEvent()
        {
            //int en_H = TM_OpenEndH, en_M = TM_OpenEndM, ex_H = TM_ClosingH, ex_M = TM_ClosingM;

            //entry at 9:02 am ct
            if (BarsInProgress == BipIWM)
            {
                //&& SetRocSpreadHiLo()) {
//				Print(String.Format("{0}:CheckTradeEvent En Bip{1}: PctSpd={2}, MaxBip={3}, MinBip={4}",
//				CurrentBars[BarsInProgress], BarsInProgress, PlotPctSpd[0], PctChgMaxBip, PctChgMinBip));

                IndicatorSignal  isig    = new IndicatorSignal();
                Direction        dir     = new Direction();
                SignalAction     sigAct  = new SignalAction();
                PairSpread <int> prSpdHi = new PairSpread <int>();
                PairSpread <int> prSpdLo = new PairSpread <int>();
                if (IsSpreadBreakdown())
                {
                    dir.TrendDir    = TrendDirection.Up;
                    isig.SignalName = SignalName_BelowStdDev;
                    SetLongShortBips(true);
                }
//				else if(Spread[0] <= LowerMin[0]) {
//					dir.TrendDir = TrendDirection.Up;
//					isig.SignalName = SignalName_BelowStdDevMin;
//				}
                else if (IsSpreadBreakout())
                {
                    dir.TrendDir    = TrendDirection.Down;
                    isig.SignalName = SignalName_AboveStdDev;
                    SetLongShortBips(true);
                }

                prSpdHi.SpdType     = SpreadType.High;
                prSpdHi.SpreadValue = RocHighSpread;
                prSpdHi.Symbol1     = ShortBip;
                prSpdHi.Symbol2     = MidLongBip;

                prSpdLo.SpdType     = SpreadType.Low;
                prSpdLo.SpreadValue = RocLowSpread;
                prSpdLo.Symbol1     = LongBip;
                prSpdLo.Symbol2     = MidShortBip;

                List <PairSpread <int> > pspdList = new List <PairSpread <int> >();
                pspdList.Add(prSpdHi);
                pspdList.Add(prSpdLo);
                sigAct.PairSpds = pspdList;
                //			Print(String.Format("{0}: [{1}] Non-CutoffTime {2}: MaxBip={3}, %Max={4}, MinBip={5}, %Min={6}, %Spd={7}",
                //				CurrentBar, Time[0], GetLongShortText(),
                //				PctChgMaxBip, PctChgMax[0], PctChgMinBip, PctChgMin[0], PlotPctSpd[0]));

//				if(PctChgMaxBip != PctChgMinBip) {
//					if(PlotPctSpd[0] > 0) {
//						dir.TrendDir = TrendDirection.Up;
//						isig.SignalName = SignalName_EntryOnOpenLong;
//					} else if(PlotPctSpd[0] < 0) {
//						dir.TrendDir = TrendDirection.Down;
//						isig.SignalName = SignalName_EntryOnOpenShort;
//					}
//				} else
//					return;

                isig.BarNo               = CurrentBars[BarsInProgress];
                isig.TrendDir            = dir;
                isig.IndicatorSignalType = SignalType.Spread;
                //isig.SignalName = SignalName_EntrySQRSpread;
                isig.SignalAction = sigAct;
                IndicatorEventArgs ievt = new IndicatorEventArgs(this.GetType().Name, String.Format(" [{0}] {1}", Times[BarsInProgress][0], GetLongShortText()));
                ievt.IndSignal = isig;

                //FireEvent(ievt);
                OnRaiseIndicatorEvent(ievt);
            }
//			else {// if(IsCutoffTime(BarsInProgress, ex_H, ex_M)) {
////				Print(String.Format("{0}:CheckTradeEvent Ex Bip{1}: PctSpd={2}, MaxBip={3}, MinBip={4}",
////				CurrentBars[BarsInProgress], BarsInProgress, PlotPctSpd[0], PctChgMaxBip, PctChgMinBip));

//				IndicatorSignal isig = new IndicatorSignal();
//				Direction dir = new Direction();
//	//			Print(String.Format("{0}: [{1}] Non-CutoffTime {2}: MaxBip={3}, %Max={4}, MinBip={5}, %Min={6}, %Spd={7}",
//	//				CurrentBar, Time[0], GetLongShortText(),
//	//				PctChgMaxBip, PctChgMax[0], PctChgMinBip, PctChgMin[0], PlotPctSpd[0]));

//				dir.TrendDir = TrendDirection.UnKnown;
//				isig.SignalName = SignalName_ExitForOpen;
////				if(PlotPctSpd[0] > 0) {
////					dir.TrendDir = TrendDirection.Up;
////					isig.SignalName = SignalName_ExitForOpen;
////				} else if(PlotPctSpd[0] < 0) {
////					dir.TrendDir = TrendDirection.Down;
////					isig.SignalName = SignalName_ExitForOpen;
////				} else
////					return;

//				isig.BarNo = CurrentBars[BarsInProgress];
//				isig.TrendDir = dir;
//				isig.IndicatorSignalType = SignalType.SimplePriceAction;
//				IndicatorEventArgs ievt = new IndicatorEventArgs(this.GetType().Name, " CheckTradeEvent Ex: ");
//				ievt.IndSignal = isig;
//				//FireEvent(ievt);
//				OnRaiseIndicatorEvent(ievt);
//			}
        }
예제 #13
0
        public void CheckTradeEvent()
        {
            int en_H = TM_OpenEndH, en_M = TM_OpenEndM, ex_H = TM_ClosingH, ex_M = TM_ClosingM;

            //entry at 9:02 am ct
            if (IsCutoffTime(BarsInProgress, en_H, en_M))
            {
                Print(String.Format("{0}:CheckTradeEvent En Bip{1}: PctSpd={2}, MaxBip={3}, MinBip={4}",
                                    CurrentBars[BarsInProgress], BarsInProgress, PlotPctSpd[0], PctChgMaxBip, PctChgMinBip));

                IndicatorSignal isig = new IndicatorSignal();
                Direction       dir  = new Direction();
                //			Print(String.Format("{0}: [{1}] Non-CutoffTime {2}: MaxBip={3}, %Max={4}, MinBip={5}, %Min={6}, %Spd={7}",
                //				CurrentBar, Time[0], GetLongShortText(),
                //				PctChgMaxBip, PctChgMax[0], PctChgMinBip, PctChgMin[0], PlotPctSpd[0]));

                if (PctChgMaxBip != PctChgMinBip)
                {
                    if (PlotPctSpd[0] > 0)
                    {
                        dir.TrendDir    = TrendDirection.Up;
                        isig.SignalName = SignalName_EntryOnOpenLong;
                    }
                    else if (PlotPctSpd[0] < 0)
                    {
                        dir.TrendDir    = TrendDirection.Down;
                        isig.SignalName = SignalName_EntryOnOpenShort;
                    }
                }
                else
                {
                    return;
                }

                isig.BarNo               = CurrentBars[BarsInProgress];
                isig.TrendDir            = dir;
                isig.IndicatorSignalType = SignalType.SimplePriceAction;
                IndicatorEventArgs ievt = new IndicatorEventArgs(this.GetType().Name, String.Format(" [{0}] {1}", Times[BarsInProgress][0], GetLongShortText()));
                ievt.IndSignal = isig;
                //FireEvent(ievt);
                OnRaiseIndicatorEvent(ievt);
            }
            else if (IsCutoffTime(BarsInProgress, ex_H, ex_M))
            {
                Print(String.Format("{0}:CheckTradeEvent Ex Bip{1}: PctSpd={2}, MaxBip={3}, MinBip={4}",
                                    CurrentBars[BarsInProgress], BarsInProgress, PlotPctSpd[0], PctChgMaxBip, PctChgMinBip));

                IndicatorSignal isig = new IndicatorSignal();
                Direction       dir  = new Direction();
                //			Print(String.Format("{0}: [{1}] Non-CutoffTime {2}: MaxBip={3}, %Max={4}, MinBip={5}, %Min={6}, %Spd={7}",
                //				CurrentBar, Time[0], GetLongShortText(),
                //				PctChgMaxBip, PctChgMax[0], PctChgMinBip, PctChgMin[0], PlotPctSpd[0]));

                dir.TrendDir    = TrendDirection.UnKnown;
                isig.SignalName = SignalName_ExitForOpen;
//				if(PlotPctSpd[0] > 0) {
//					dir.TrendDir = TrendDirection.Up;
//					isig.SignalName = SignalName_ExitForOpen;
//				} else if(PlotPctSpd[0] < 0) {
//					dir.TrendDir = TrendDirection.Down;
//					isig.SignalName = SignalName_ExitForOpen;
//				} else
//					return;

                isig.BarNo               = CurrentBars[BarsInProgress];
                isig.TrendDir            = dir;
                isig.IndicatorSignalType = SignalType.SimplePriceAction;
                IndicatorEventArgs ievt = new IndicatorEventArgs(this.GetType().Name, " CheckTradeEvent Ex: ");
                ievt.IndSignal = isig;
                //FireEvent(ievt);
                OnRaiseIndicatorEvent(ievt);
            }
        }