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

Changes to CurrentDayOHL indicator

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

    #16
    chinapassage,

    Try the following code with the NT CurrentDayOHL indicator. It will give you the High & Low starting with the night session. As for the Open, you have the option to change it to any time you need. I trade futures, but like to keep tabs when the market opens, so mine is CST, 8:30 am.

    Hope this this is what you need.

    Code:
    if (currentDate != Bars.GetTradingDayFromLocal(Time[0]) || currentOpen == double.MinValue)
                {
                    currentOpen     =     Open[CurrentBar-Bars.GetBar(new DateTime(Time[0].Year,Time[0].Month,Time[0].Day,8,30,0))]; 
                    currentHigh     =     High[0];
                    currentLow        =    Low[0];
                    sameDay         =   false;
                }
    
                currentHigh     =     Math.Max(currentHigh, High[0]);
                currentLow        =     Math.Min(currentLow, Low[0]);
                
                if(ToTime(Time[0]) < ToTime(8,30,0))
                {
                    currentOpen = Open[0];
                    PlotColors[0][0] = Color.Transparent;
                }
                
                if(currentDate == Bars.GetTradingDayFromLocal(Time[0]) && ToTime(Time[0]) >= ToTime(8,30,0))
                    currentOpen = Close[CurrentBar-Bars.GetBar(new DateTime(Time[0].Year,Time[0].Month,Time[0].Day,8,30,0))];

    Comment


      #17
      Thanks,
      i got it to work on a minute chart good... but when i stick it with the rotation bar type charts it looks at the bar instead of the "time" ... if anyone happens to know what needs to be changed in this code so that i can select the exact tick for a given time would be great thx:


      i have attached the indicator below if someone needed to see the code it was to big to type into here
      Attached Files

      Comment


        #18
        Hello chinapassage,

        If you are running this on a minute chart the time (Time[0]) will refer to the close time of that bar. For example if the market opens at 9:00, then the first bar close will be at 9:01 (after the first minute has elapsed and the bar has closed).

        If you want to find the first tick of a bar or a session, you will need to add a 1 tick data series to your script. (historically, 1 minute data does not have tick information)

        Below is a link to the help guide on adding a data series.
        http://www.ninjatrader.com/support/h...s/nt7/add3.htm

        BarsInProgress allows you to see which data series is triggering OnBarUpdate.
        http://www.ninjatrader.com/support/h...inprogress.htm

        Times (plural) - allows you to check the time of a specific series. (Times[barsinprogress index][bars ago index])
        http://www.ninjatrader.com/support/h.../nt7/times.htm

        Also, below is a link to how the bars in the data series are indexed when there are multiple data series.
        http://www.ninjatrader.com/support/h...nstruments.htm
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Max238, Today, 01:28 AM
        1 response
        22 views
        0 likes
        Last Post CactusMan  
        Started by giulyko00, Yesterday, 12:03 PM
        2 responses
        10 views
        0 likes
        Last Post giulyko00  
        Started by r68cervera, Today, 05:29 AM
        0 responses
        4 views
        0 likes
        Last Post r68cervera  
        Started by geddyisodin, Today, 05:20 AM
        0 responses
        6 views
        0 likes
        Last Post geddyisodin  
        Started by JonesJoker, 04-22-2024, 12:23 PM
        6 responses
        38 views
        0 likes
        Last Post JonesJoker  
        Working...
        X