public SupportResistanceRange <SupportResistanceLine> NewSupportResistanceRange(SupportResistanceLine rstLine, SupportResistanceLine sptLine)
        {
            SupportResistanceRange <SupportResistanceLine> snrRange = new SupportResistanceRange <SupportResistanceLine>();

            snrRange.Resistance = rstLine;
            snrRange.Support    = sptLine;
            return(snrRange);
        }
        protected override void OnBarUpdate()
        {
            // Check to make sure the end time is not earlier than the start time
            if (EndHour < StartHour)
            {
                return;
            }

            //Do not calculate the high or low value when the ending time of the desired range is less than the current time of the bar being processed
            if (ToTime(EndHour, EndMinute, 0) > ToTime(Time[0]))
            {
                return;
            }

            // If the stored date time date is not the same date as the bar time date, create a new DateTime object
            if (startDateTime.Date != Time[0].Date)
            {
                startDateTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, StartHour, StartMinute, 0);
                endDateTime   = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, EndHour, EndMinute, 0);
                snrRanges.Add(snrRange);
                snrRange = null;
            }

            // Calculate the number of bars ago for the start and end bars of the specified time range
            int startBarsAgo = Bars.GetBar(startDateTime);
            int endBarsAgo   = Bars.GetBar(endDateTime);

            /* Now that we have the start and end bars ago values for the specified time range we can calculate the highest high for this range
             *
             * Note: We add 1 to the period range for MAX and MIN to compensate for the difference between "period" logic and "bars ago" logic.
             * "Period" logic means exactly how many bars you want to check including the current bar.
             * "Bars ago" logic means how many bars we are going to go backwards. The current bar is not counted because on that bar we aren't going back any bars so it would be "bars ago = 0" */
            double highestHigh = MAX(High, endBarsAgo - startBarsAgo + 1)[CurrentBar - endBarsAgo];

            // Now that we have the start and end bars ago values for the specified time range we can calculate the lowest low for this range
            double lowestLow = MIN(Low, endBarsAgo - startBarsAgo + 1)[CurrentBar - endBarsAgo];

            // Set the plot values
            HighestHigh[0] = highestHigh;
            LowestLow[0]   = lowestLow;

            if (snrRange == null)
            {
                SupportResistanceLine rstLine = new SupportResistanceLine();
                rstLine.NewSupportResistanceLine(startBarsAgo, endBarsAgo, SupportResistanceType.Resistance, HighestHigh[0]);
                SupportResistanceLine sptLine = new SupportResistanceLine();
                sptLine.NewSupportResistanceLine(startBarsAgo, endBarsAgo, SupportResistanceType.Support, LowestLow[0]);
                snrRange = NewSupportResistanceRange(rstLine, sptLine);
            }
        }
Beispiel #3
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);
        }
Beispiel #4
0
        public void AddTradeAction(int barNo, string actname,
                                   TradeActionType saType, SupportResistanceRange <double> snr)
        {
            TradeAction sa = new TradeAction();

            sa.ActionType = saType;
            //sa.SnR = snr;
            TradeAction tact = new TradeAction();

            tact.BarNo = barNo;
//			tact.ActionName = actname;
//			tact.TradeActionType = TradeActionType.BracketSignal;
            //tact.Signal_Action = sa;
            AddTradeAction(barNo, tact);
        }