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

How do i get my current indicator to start at a different time?

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

    How do i get my current indicator to start at a different time?

    My current pivot indicator plots horizontal lines automatically. If i set the chart properties session time it will use that info to plot the lines. If I want to do 24 hr, then it uses the session time based on my computer starting at 00:00 hrs my time until 24:00 hours my time. IF I dont want it to use my computer time BUT want to change the start time to 3 hours prior (which means it actually starts the prior day) how do I do that? If I set my chart properties session times from say 9pm until 9 pm...it doesnt change the automatic indicator because it is still using my 00:00 time to 24:00 time as the 24 hr session. Can someone help this newbie with this? Below is some of the code its using....

    if ((currentDate != Cbi.Globals.MinDate && pivotRangeType == PivotRange.Daily && Time[0].Date != currentDate)
    || (currentWeek != Cbi.Globals.MinDate && pivotRangeType == PivotRange.Weekly && RoundUpTimeToPeriodTime(Time[
    0].Date, PivotRange.Weekly) != currentWeek)
    || (currentMonth != Cbi.Globals.MinDate && pivotRangeType == PivotRange.Monthly && RoundUpTimeToPeriodTime(Time[
    0].Date, PivotRange.Monthly) != currentMonth))
    {

    if (pivotRangeType == PivotRange.Daily)
    currentDate = Time[
    0].Date;
    if (pivotRangeType == PivotRange.Weekly)
    currentWeek = RoundUpTimeToPeriodTime(Time[
    0].Date, PivotRange.Weekly);
    if (pivotRangeType == PivotRange.Monthly)
    currentMonth = RoundUpTimeToPeriodTime(Time[
    0].Date, PivotRange.Monthly)


    #region Miscellaneous
    privateint GetDayOfWeek(DateTime date)
    {
    DateTime saturday =
    new DateTime(1776, 7, 4).AddDays(2);
    TimeSpan diff = date.Subtract(saturday);
    return (diff.Days % 7);
    }
    private DateTime RoundUpTimeToPeriodTime(DateTime time, PivotRange pivotRange)
    {

    (System.Math.Ceiling(time.Date.Subtract(periodStar t.Date).TotalDays) / 7) * 7).Date;
    }

    I assume the needed change is somewhere in this part of the code. I didnt post all because it would be too long.

    #2
    winJR, just tried on my end with your 9 PM to 9PM session and then loading for example the CurrentDayOHL indicator that would 'grab' those times set in the GUI as session as well - works as expected here for me.

    NinjaTrader would always take the local PC clock and timezone as reference, this can be simpified in NT7 as you can setup sessions then via a session manager that would convert timezones for you.

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks for the reply

      How do I set my indicator to grab the 9pm time to 9pm time? what do i need to change in the code ?

      Comment


        #4
        You would need to change your session begin and end times in the Chart Properties.

        You could for example work with GetBar to know how many bars to ref back to reach a given DateTime - http://www.ninjatrader-support.com/H...V6/GetBar.html
        BertrandNinjaTrader Customer Service

        Comment


          #5
          No, as I had mentioned in the first post...

          if i set a session times from 9am to 3pm for example in chart properties it does work yes. It does not work if trying to set a start time prior to 12:00am. It defaults to 12:00 or 00:00 hours on my local computer clock for the indicator start time. The session time still shows 9pm to 9pm and the session break line shows at 9pm like its supposed to but the indicator wont go prior to 1200am or 00:00 hours. the code must be set to current day only based on computer clock and wont go into previous day to start the indicator. How do I get that changed? How would I write into the code and where would I put the GetBar as you suggest?

          Comment


            #6
            I hope that reply didnt sound rude, not my intention

            lol. I appreciate all the help you guys give...mucho appreciative!! I know the answer is right there. I didnt want my reply to sound rude..it wasnt my intention. There has got to be a way to change the indicator code to reflect the start time on the prior day at a certain time. Or like you mentioned maybe Barsago. I dont know how to do that, can you help with where to place it or tell me where to change the session time to start the prior day instead of current day. thanks in advance.

            Comment


              #7
              winJR, no offense taken here, you're welcome.

              Anyway you could send me the full code so I can take a look for you?

              If you don't want to post here, you can contact me at support at ninjatrader dot com Attn Bertrand.

              For GetBar, you just put your desired date and time in and then it returns you how many bars this is ago, you can then reference for example an SMA value at this time with this info.

              BertrandNinjaTrader Customer Service

              Comment


                #8
                Thanks much...i just emailed you the code

                The indicator is nothing fancy, plenty on here that are even better. I tried to post it here but it said it was too long. So I emailed it to you. All your help is very much appreciated!!! Thanks again.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Rapine Heihei, 04-23-2024, 07:51 PM
                2 responses
                30 views
                0 likes
                Last Post Max238
                by Max238
                 
                Started by Shansen, 08-30-2019, 10:18 PM
                24 responses
                943 views
                0 likes
                Last Post spwizard  
                Started by Max238, Today, 01:28 AM
                0 responses
                9 views
                0 likes
                Last Post Max238
                by Max238
                 
                Started by rocketman7, Today, 01:00 AM
                0 responses
                4 views
                0 likes
                Last Post rocketman7  
                Started by wzgy0920, 04-20-2024, 06:09 PM
                2 responses
                28 views
                0 likes
                Last Post wzgy0920  
                Working...
                X