Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Trying To Modify Prior Week OHLC Indicator To Current Week

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Trying To Modify Prior Week OHLC Indicator To Current Week

    I am trying to modify Prior Week OHLC indicator to show Current Week's OHLC.

    Here is the code that I need to modify: how can this be done?

    #region Variables

    double weeklyOpen = 0;
    double weeklyHigh = 0;
    double weeklyLow = 0;
    double weeklyClose = 0;

    double prWeeklyOpen = 0;
    double prWeeklyHigh = 0;
    double prWeeklyLow = 0;
    double prWeeklyClose = 0;

    DateTime newWeek = DateTime.MinValue;

    #endregion

    /// <summary>
    /// This method is used to configure the indicator and is called once before any bar data is loaded.
    /// </summary>
    protected override void Initialize()
    {
    Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Hash, "CurrentWeekOpen"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Blue), PlotStyle.Hash, "CurrentWeekHigh"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Hash, "CurrentWeekLow"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Green), PlotStyle.Hash, "CurrentWeekClose"));
    Overlay = true;
    AutoScale = false;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    if (!Bars.BarsType.IsIntraday)
    {
    this.DrawTextFixed("err", "PriorWeekOHLC only works on intraday interval", TextPosition.BottomRight);
    return;
    }


    if (newWeek < Time[0])
    {
    prWeeklyOpen = weeklyOpen;
    prWeeklyHigh = weeklyHigh;
    prWeeklyLow = weeklyLow;
    prWeeklyClose = weeklyClose;

    weeklyOpen = Open[0];
    weeklyHigh = High[0];
    weeklyLow = Low[0];
    weeklyClose = Close[0];

    newWeek = Time[0].Date.AddDays(7 - (int)Time[0].DayOfWeek);

    }

    if (prWeeklyOpen != 0)
    {

    PriorWeekOpen.Set(prWeeklyOpen);
    PriorWeekHigh.Set(prWeeklyHigh);
    PriorWeekLow.Set(prWeeklyLow);
    PriorWeekClose.Set(prWeeklyClose);
    }

    weeklyHigh = Math.Max(High[0], weeklyHigh);
    weeklyLow = Math.Min(Low[0], weeklyLow);
    weeklyClose = Close[0];
    }

    #2
    Hello bijan,

    Thank you for your post.

    This is comparable to the difference between the pre-loaded indicators in NinjaTrader called PriorDayOHLC and CurrentDayOHL. the PriorWeek code you provided appears to take it's ques from the PriorDayOHLC. This means you can likely use the CurrentDayOHL as a guide to begin to build the CurrentWeekOHL.

    You can find the CurrentDayOHL and PriorDayOHLC by going to Tools > Edit NinjaScript > Indicator.

    Please let me know if I may be of further assistance.

    Comment


      #3
      Hello bijan,

      I understand that you want to code this yourself. In case that you want to have a look at a finished indicator, please install the anaCurrentWeekOHL from the SessionPivots package which is available here:



      The indicator displays

      - current week's open, high and low
      - current week's midline
      - Fibonacci retracements calculated from high and low
      - weekly noise bands
      - weekly expansion bands or average weekly range with projections

      A chart is attached.
      Attached Files

      Comment


        #4
        Pls Help Trying to Create a Weekly Open Indicator

        Hi there,

        Please could you assist in creating or converting the CurrentDayOHLC indicator to a CurrentWeekOHLC indicator instead.

        Comment


          #5
          Hi there,

          Please could you assist in creating or converting the CurrentDayOHLC indicator to a CurrentWeekOHLC indicator instead.

          Comment


            #6
            Hello Aworex,
            Can you clarify if you are wanting to have this created for you or is this a project that you are currently working on?

            I look forward to your reply.
            Cody B.NinjaTrader Customer Service

            Comment


              #7
              Thanks for responding, I tried to amend the existing CurrentDayHLOC indicator by substituting Day for Week but could not compile it due to the various errors.
              Would be grateful if it can be created.

              Comment


                #8
                Originally posted by Aworex View Post
                Hi there,

                Please could you assist in creating or converting the CurrentDayOHLC indicator to a CurrentWeekOHLC indicator instead.
                You can download a free CurrentWeekOHLC and CurrentMonthOHL indicator here:



                The indicators have further features such as Fibonacci retracements based on the current day's / current week's / current month's high and low and come with expansion bands (range targets) and noise bands.

                Comment


                  #9
                  I downloaded this earlier but when I tried to import the file, none of the files appeared in the drop down list.Or could you explain how I can install the indicator

                  thanks

                  Comment


                    #10
                    Originally posted by Aworex View Post
                    I downloaded this earlier but when I tried to import the file, none of the files appeared in the drop down list.Or could you explain how I can install the indicator

                    thanks
                    All indicators start with "ana" (it is best NinjaTrader practice to use a prefix that identifies the author).
                    Last edited by Harry; 08-19-2015, 02:25 PM.

                    Comment


                      #11
                      Hello,
                      To import NinjaScripts you will need the original .zip file.

                      To Import download the NinjaScripts to your desktop, keep them in the compressed .zip file.

                      From the Control Center window select the menu File> Utilities> Import NinjaScript

                      Select the downloaded .zip file

                      NinjaTrader will then confirm if the import has been successful.

                      Critical - Specifically for some NinjaScripts, it will prompt that you are running newer versions of @SMA, @EMA, etc. and ask if you want to replace, press 'No'

                      Once installed, you may add the indicator to a chart by:

                      Right click you chart > indicators > Select the Indicator from the list on the left > New > OK

                      The indicator will appear as anaCurrentWeekOHL. in the indicator list.

                      Please let us know if we can be of any other assistance.
                      Cody B.NinjaTrader Customer Service

                      Comment


                        #12
                        Thank you very much I was able to import the scripts and it is now working.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by cre8able, Today, 01:16 PM
                        2 responses
                        9 views
                        0 likes
                        Last Post cre8able  
                        Started by chbruno, 04-24-2024, 04:10 PM
                        3 responses
                        48 views
                        0 likes
                        Last Post NinjaTrader_Gaby  
                        Started by samish18, Today, 01:01 PM
                        1 response
                        7 views
                        0 likes
                        Last Post NinjaTrader_LuisH  
                        Started by WHICKED, Today, 12:56 PM
                        1 response
                        9 views
                        0 likes
                        Last Post NinjaTrader_Gaby  
                        Started by WHICKED, Today, 12:45 PM
                        1 response
                        11 views
                        0 likes
                        Last Post NinjaTrader_Gaby  
                        Working...
                        X