none
Building a Automated Process for Forex RRS feed

  • General discussion

  • I really need assistance in building a C# automated "ALERT" and  for trading the FOREX MARKET

    The process will have to access (4) different Trading Charts and (1) Different Indicator

    CHARTS:  (30Minute); (1 Minute);  (5 Minute) and (15 Minute);

    INDICATORS: RSI

    Here is the code for the Indicators

    MACD

    using System;
    using System.Drawing;
    
    namespace PowerLanguage.Indicator
    {
        public class HUT_MACD: IndicatorObject
        {
            private Function.MACD m_macd1;
    
            private Function.XAverage m_xaverage1;
    
            private VariableSeries<Double> m_mymacd;
    
            private VariableSeries<Double> m_macddiff;
    
            private IPlotObject Plot1;
    
            private IPlotObject Plot2;
    
            private IPlotObject Plot3;
    
            private IPlotObject Plot4;
    
            public HUT_MACD(object ctx) :
                base(ctx){
                macdlength = 9;
                slowlength = 15;
                fastlength = 5;
            }
    
            [Input]
            public int fastlength { get; set; }
    
            [Input]
            public int slowlength { get; set; }
    
            [Input]
            public int macdlength { get; set; }
    
            protected override void Create(){
                m_macd1 = new Function.MACD(this);
                m_xaverage1 = new Function.XAverage(this);
                m_mymacd = new VariableSeries<Double>(this);
                m_macddiff = new VariableSeries<Double>(this);
                Plot1 =
                    AddPlot(new PlotAttributes("MACD", 0, Color.Cyan,
                                               Color.Empty, 0, 0, true));
                Plot2 =
                    AddPlot(new PlotAttributes("MACDAvg", 0, Color.Yellow,
                                               Color.Empty, 0, 0, true));
                Plot3 =
                    AddPlot(new PlotAttributes("MACDDiff", EPlotShapes.Histogram,
                                               Color.Blue, Color.Empty, 0, 0,
                                               true));
                Plot4 =
                    AddPlot(new PlotAttributes("ZeroLine", 0, Color.Green,
                                               Color.Empty, 0, 0, true));
            }
    
            protected override void StartCalc(){
                m_macd1.Price = Bars.Close;
                m_macd1.FastLength = fastlength;
                m_macd1.SlowLength = slowlength;
                m_xaverage1.Price = m_mymacd;
                m_xaverage1.Length = macdlength;
                m_mymacd.DefaultValue = 0;
                m_macddiff.DefaultValue = 0;
            }
    
    
            protected override void CalcBar(){
                m_mymacd.Value = m_macd1[0];
                var m_macdavg = m_xaverage1[0];
                m_macddiff.Value = m_mymacd.Value - m_macdavg;
                Plot1.Set(0, m_mymacd.Value);
                Plot2.Set(0, m_macdavg);
                Plot3.Set(0, m_macddiff.Value);
                Plot4.Set(0, 0);


    using System;
    using System.Drawing;
    
    namespace PowerLanguage.Indicator
    {
        public class RSI : IndicatorObject
        {
            private Function.RSI m_rsi1;
    
            private VariableSeries<Double> m_myrsi;
    
            private IPlotObject Plot1;
    
            private IPlotObject Plot2;
    
            private IPlotObject Plot3;
    
            public RSI(object ctx) :
                base(ctx){
                overbcolor = Color.Red;
                overscolor = Color.Cyan;
                overbought = 70;
                oversold = 30;
                length = 5;
            }
    
            [Input]
            public int length { get; set; }
    
            [Input]
            public double oversold { get; set; }
    
            [Input]
            public double overbought { get; set; }
    
            [Input]
            public Color overscolor { get; set; }
    
            [Input]
            public Color overbcolor { get; set; }
    
            protected override void Create(){
                m_rsi1 = new Function.RSI(this);
                m_myrsi = new VariableSeries<Double>(this);
                Plot1 =
                    AddPlot(new PlotAttributes("RSI", 0, Color.Silver,
                                               Color.Empty, 0, 0, true));
                Plot2 =
                    AddPlot(new PlotAttributes("OverBot", 0, Color.Green,
                                               Color.Empty, 0, 0, true));
                Plot3 =
                    AddPlot(new PlotAttributes("OverSld", 0, Color.Green,
                                               Color.Empty, 0, 0, true));
            }
    
            protected override void StartCalc(){
                m_rsi1.price = Bars.Close;
                m_rsi1.length = length;
            }
    
    
            protected override void CalcBar(){
                m_myrsi.Value = m_rsi1[0];
                Plot1.Set(0, m_myrsi.Value);
                Plot2.Set(0, overbought);
                Plot3.Set(0, oversold);
                if (PublicFunctions.DoubleGreater(m_myrsi.Value, overbought)){
                    Plot1.Colors[0] = overbcolor;
                }
                else{
                    if (PublicFunctions.DoubleLess(m_myrsi.Value, oversold)){
                        Plot1.Colors[0] = overscolor;
                    }
                }
                if (this.CrossesOver(m_myrsi, oversold)){
                    Alerts.Alert("Indicator exiting oversold zone");
                }
                else{
                    if (this.CrossesUnder(m_myrsi, overbought)){
                        Alerts.Alert("Indicator exiting overbought zone");
                    }
                }
            }
        }
    


    Chart object = 30Mintues RSI Value

    Chart object = 15Mintues RSI Value

    Chart object = 5Mintues RSI Value

    Chart object = 1Mintues RSI Value

    ADJ RSI =  ((30Mintues RSI Value)+(15Mintues RSI Value)+(5Mintues RSI Value)+(1Mintues RSI Value))/4

    IF

    Adj RSI > 70 Then Buy "ALERT" 

    Else IF 

    ADJ RSI < 30 Then Sell "ALERT" ;

    THANKS IN ADVANCE


    Image already added

    Roger H Hicks

    Saturday, February 10, 2018 4:17 PM

All replies

  • How are you going to fetch the updated data?  Are you fetching the RSI values through web requests, like once a minute?  If so, then all you need is to have the last set of code run every time you get an updated reading.  Any time the RSI values change, compute your threshold value and check the range.

    Tim Roberts, Driver MVP Providenza & Boekelheide, Inc.

    Monday, February 12, 2018 7:21 AM
  • I would have thought there could something like a variable that can handle the RSI Value's  and then calculate the different chart "RSI" information 


     


    Roger H Hicks


    Image already added

    Image already added
    Monday, February 12, 2018 4:37 PM