Category Other  Published on 05/07/2017

1SK - Display Daily, Wkly, Mnthly Pips

Description

Hi,

this indicator displays the Hourly, Daily, Weeky, Monthly Total Pips and ATR Value on Chart.

Please rate it and leave a comment.

Thank you.

///S.Khan

 

 


////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
///                                                                                  ///
///         REV. DATE   : TUE-08-MAR-16                                              ///
///         MADE BY     : ///S.KHAN                                                  ///
///         CONTACT ON  : skhan.projects@gmail.com                                   ///
///                                                                                  ///
////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////


using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
using System.Text;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class DisplayDWMPipsonCharts : Indicator
    {

        ////////////////////////////////////////////////////////////////////////////////
        ///                        USER INPUT                                        ///
        ////////////////////////////////////////////////////////////////////////////////

        [Parameter("1-HOUR ATR, Period ", DefaultValue = 10, MinValue = 1, MaxValue = 500)]
        public int p_Period_0 { get; set; }

        [Parameter("Daily ATR, Period ", DefaultValue = 20, MinValue = 1, MaxValue = 300)]
        public int p_Period_1 { get; set; }

        [Parameter("Weekly ATR, Period ", DefaultValue = 8, MinValue = 1, MaxValue = 100)]
        public int p_Period_2 { get; set; }

        [Parameter("Monthly ATR, Period ", DefaultValue = 3, MinValue = 1, MaxValue = 60)]
        public int p_Period_3 { get; set; }

        [Parameter("Display Position, 1-8", DefaultValue = 7, MinValue = 1, MaxValue = 8)]
        public int p_Display_Text { get; set; }

        [Parameter("Display Color", DefaultValue = "White")]
        public string p_Display_Color { get; set; }

        ////////////////////////////////////////////////////////////////////////////////
        ///                         GLOBAL VARIABLES                                 ///
        ////////////////////////////////////////////////////////////////////////////////

        private MarketSeries my_Series_Hourly;
        private MarketSeries my_Series_Daily;
        private MarketSeries my_Series_Weekly;
        private MarketSeries my_Series_Monthly;

        private AverageTrueRange ATR_Hourly;
        private AverageTrueRange ATR_Daily;
        private AverageTrueRange ATR_Weekly;
        private AverageTrueRange ATR_Monthly;

        private StaticPosition my_Position;

        double H1_Open, H1_Close, H1_Pips, D_Open, D_Close, Daily_Pips, W_Open, Weekly_Pips, M_Open, Monthly_Pips;
        double Hourly_ATR, Daily_ATR, Weekly_ATR, Monthly_ATR;



        StringBuilder Display_TEXT;

        ////////////////////////////////////////////////////////////////////////////////
        ///                         INITIALIZE                                       ///
        ////////////////////////////////////////////////////////////////////////////////
        protected override void Initialize()
        {
            try
            {
                my_Series_Hourly = MarketData.GetSeries(Symbol, TimeFrame.Hour);
                my_Series_Daily = MarketData.GetSeries(Symbol, TimeFrame.Daily);
                my_Series_Weekly = MarketData.GetSeries(Symbol, TimeFrame.Weekly);
                my_Series_Monthly = MarketData.GetSeries(Symbol, TimeFrame.Monthly);

                ATR_Hourly = Indicators.AverageTrueRange(MarketData.GetSeries(TimeFrame.Hour), p_Period_0, MovingAverageType.Simple);
                ATR_Daily = Indicators.AverageTrueRange(MarketData.GetSeries(TimeFrame.Daily), p_Period_1, MovingAverageType.Simple);
                ATR_Weekly = Indicators.AverageTrueRange(MarketData.GetSeries(TimeFrame.Weekly), p_Period_2, MovingAverageType.Simple);
                ATR_Monthly = Indicators.AverageTrueRange(MarketData.GetSeries(TimeFrame.Monthly), p_Period_3, MovingAverageType.Simple);

            } catch
            {
            }

            //FOR DISPLAY POSITION OF THE DISPLAY TEXT
            switch (p_Display_Text)
            {
                case 1:
                    my_Position = StaticPosition.TopLeft;
                    break;
                case 2:
                    my_Position = StaticPosition.TopCenter;
                    break;
                case 3:
                    my_Position = StaticPosition.TopRight;
                    break;
                case 4:
                    my_Position = StaticPosition.Left;
                    break;
                case 5:
                    my_Position = StaticPosition.Right;
                    break;
                case 6:
                    my_Position = StaticPosition.BottomLeft;
                    break;
                case 7:
                    my_Position = StaticPosition.BottomCenter;
                    break;
                case 8:
                    my_Position = StaticPosition.BottomRight;
                    break;
                default:
                    my_Position = StaticPosition.TopLeft;
                    break;



            }
        }
        //END METHOD INITIALIZE

        ////////////////////////////////////////////////////////////////////////////////
        ///                         CALCULATE                                        ///
        ////////////////////////////////////////////////////////////////////////////////
        public override void Calculate(int index)
        {
            Display_TEXT = new StringBuilder();
            // During high volatility display warning to user
            Colors my_Color = (Colors)Enum.Parse(typeof(Colors), p_Display_Color, true);

            // 1-HOUR CLOSE VALUE
            H1_Close = my_Series_Hourly.Close.LastValue;

            // HOURLY PIPS
            H1_Open = my_Series_Hourly.Open.LastValue;
            H1_Pips = (H1_Close - H1_Open) / Symbol.PipSize;

            // DAILY CLOSE VALUE
            D_Close = my_Series_Daily.Close.LastValue;

            // DAILY PIPS
            D_Open = my_Series_Daily.Open.LastValue;
            Daily_Pips = (D_Close - D_Open) / Symbol.PipSize;

            // WEEKLY PIPS
            W_Open = my_Series_Weekly.Open.LastValue;
            Weekly_Pips = (D_Close - W_Open) / Symbol.PipSize;

            // MONTHLY PIPS
            M_Open = my_Series_Monthly.Open.LastValue;
            Monthly_Pips = (D_Close - M_Open) / Symbol.PipSize;

            // 7ATR VALUE : HOURLY, DAILY, WEEKLY, MONTHLY
            Hourly_ATR = (ATR_Hourly.Result.LastValue / Symbol.PipSize);
            Daily_ATR = (ATR_Daily.Result.LastValue / Symbol.PipSize);
            Weekly_ATR = (ATR_Weekly.Result.LastValue / Symbol.PipSize);
            Monthly_ATR = (ATR_Monthly.Result.LastValue / Symbol.PipSize);




            // ----------------------------------------------------------------------------------------------------------
            //  DISPLAY : PIPS AND ATR VALUES ON THE CHART
            // ----------------------------------------------------------------------------------------------------------
            // CONVERT TO STRING

            //String('\t', n)

            Display_TEXT.Append("TIME FRAME :\tPips\tATR");
            Display_TEXT.AppendLine();
            // HOURLY
            Display_TEXT.Append("H\t:\t");
            Display_TEXT.AppendFormat("{0:N0}", H1_Pips);
            Display_TEXT.Append(",\t");
            Display_TEXT.AppendFormat("{0:N0}", Hourly_ATR);
            Display_TEXT.AppendLine();
            // DAILY            
            Display_TEXT.Append("Daily\t:\t");
            Display_TEXT.AppendFormat("{0:N0}", Daily_Pips);
            Display_TEXT.Append(",\t");
            Display_TEXT.AppendFormat("{0:N0}", Daily_ATR);
            Display_TEXT.AppendLine();
            // WEEKLY
            Display_TEXT.Append("Weekly\t:\t");
            Display_TEXT.AppendFormat("{0:N0}", Weekly_Pips);
            Display_TEXT.Append(",\t");
            Display_TEXT.AppendFormat("{0:N0}", Weekly_ATR);
            Display_TEXT.AppendLine();
            // MONTHLY
            Display_TEXT.Append("Monthly\t:\t");
            Display_TEXT.AppendFormat("{0:N0}", Monthly_Pips);
            Display_TEXT.Append(",\t");
            Display_TEXT.AppendFormat("{0:N0}", Monthly_ATR);
            Display_TEXT.AppendLine();

            //DISPLAY ON CHART
            ChartObjects.DrawText("my001", Display_TEXT.ToString(), my_Position, my_Color);
            // ----------------------------------------------------------------------------------------------------------

        }
        //END METHOD CALCULATE

    }
    //END class DisplayDWMPipsonCharts
}
//END namespace cAlgo


GoldnOil750's avatar
GoldnOil750

Joined on 07.04.2015

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: 1SK- Display PIPS H-D-W-M.algo
  • Rating: 0
  • Installs: 4253
  • Modified: 13/10/2021 09:54
Comments
Log in to add a comment.
No comments found.