• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Do something once every session at a certain time

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

    Do something once every session at a certain time

    Heh, I feel like an idiot, but maybe its because its 1 am here...

    I want to preform an action 1 time each trading day when the market opens. I am using the ETH session template, so the session starts the day before the market opens. I would like to do it each time the market opens for RTH

    I cannot figure out how to do this.

    Could someone point me in the right direction, please?

    I alredy have this:
    Code:
    privatebool MarketOpen
    {
    get
    {
    if (_marketOpenTime == 0 || _marketCloseTime == 0)
    {
    returntrue;
    }
    else
    {
    if (_marketOpenTime > _marketCloseTime)// sessions that begin previous day and end next day
    {
    return ToTime(Time[0]) >= _marketOpenTime * 100 || ToTime(Time[0]) <= _marketCloseTime * 100;
    }
    else
    {
    return ToTime(Time[0]) >= _marketOpenTime * 100 && ToTime(Time[0]) <= _marketCloseTime * 100;
    }
    }
    }
    }
    
    So I can check if he market is open or not. I just need tocheck if its another day? Right?...

    #2
    Laserdan, you would need to 'store' the RTH open times for the markets needed for example in a method and then check for the current day's time to be equal this time for your action to trigger. To get access to finer timestamps, you could add for exampke a 1 minute series and use Times[index][barsback].
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Originally posted by Laserdan View Post
      Heh, I feel like an idiot, but maybe its because its 1 am here...

      I want to preform an action 1 time each trading day when the market opens. I am using the ETH session template, so the session starts the day before the market opens. I would like to do it each time the market opens for RTH

      I cannot figure out how to do this.

      Could someone point me in the right direction, please?

      I alredy have this:
      Code:
      privatebool MarketOpen
      {
      get
      {
      if (_marketOpenTime == 0 || _marketCloseTime == 0)
      {
      returntrue;
      }
      else
      {
      if (_marketOpenTime > _marketCloseTime)// sessions that begin previous day and end next day
      {
      return ToTime(Time[0]) >= _marketOpenTime * 100 || ToTime(Time[0]) <= _marketCloseTime * 100;
      }
      else
      {
      return ToTime(Time[0]) >= _marketOpenTime * 100 && ToTime(Time[0]) <= _marketCloseTime * 100;
      }
      }
      }
      }
      
      So I can check if he market is open or not. I just need tocheck if its another day? Right?...
      The day has nothing to do with the session times. If you want to preform an action at 0930 EST, just use that time as your gate. It does occur only once each day, regardless of when the session started.

      Comment


        #4
        I will be using this in the On Bar Update method, so I am concerned there may not be a bar = to the exact time and the procedure might not execute. So I dont really want it associated with a bar object...

        Comment


          #5
          Originally posted by Laserdan View Post
          I will be using this in the On Bar Update method, so I am concerned there may not be a bar = to the exact time and the procedure might not execute. So I dont really want it associated with a bar object...
          Then you just have to use COBC = false, and a non-fixed timeframe chart, such as a Tick, Range, Renko, Volume etc., chart, and specify the time at which you want the event to occur.

          Comment


            #6
            I want to check something once a day as well when the market closes, so at 4:05PM.

            I have the following code and noticed it makes Loading chart data take forever.

            COBC = true and I'm using in the Market Analyzer.

            Is there a better approach?

            if (Bars.FirstBarOfSession)
            myDataSeries.Set(
            0);
            elseif (ToTime(Time[0]) >= 160500) // if end of day
            myDataSeries.Set(1);

            Comment


              #7
              How many days/bars are you loading this on? Roughly how long does this take to load?
              MatthewNinjaTrader Product Management

              Comment


                #8
                I'm loading only 10 bars. It keeps loading the data. Doesn't really stop.

                Comment


                  #9
                  Would you be able to post the full code you're using?
                  MatthewNinjaTrader Product Management

                  Comment


                    #10
                    I actually believe it may be slow and take a long time (or not even load) a chart because of different custom indicators I have in the Market Analyzer and the # of bars to look back.

                    I recently updated an indicator to include a multi time frame and compare EMA(5) with
                    EMA(BarsArray[1], period)[0];

                    I used to have the # of bars to look back set at 6 for a 2,3 min chart etc. Now with the BarsArray I had to add more because of it checking like BarsRequired. So I left it at 50.

                    Is there a way to calculate the exact number of bars required?

                    I use BarsRequired but never know the exact value...

                    Comment


                      #11
                      It would depend on your indicator calculations how many bars they would need to return meaningful values, for the MultiSeries indicator script you want to keep in mind that BarsRequired set has to be fulfilled for all series before the OnBarUpdate() would be called.

                      If you run your script directly from a chart, would the outcome then be different?
                      BertrandNinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by pmallya.nt, Today, 12:55 PM
                      1 response
                      17 views
                      0 likes
                      Last Post NinjaTrader_Kate  
                      Started by GARZONJ, Today, 01:55 PM
                      1 response
                      2 views
                      0 likes
                      Last Post NinjaTrader_PaulH  
                      Started by santafe, Today, 01:44 PM
                      1 response
                      4 views
                      0 likes
                      Last Post NinjaTrader_Heath  
                      Started by jeliner, 02-05-2019, 09:01 AM
                      6 responses
                      339 views
                      0 likes
                      Last Post NinjaTrader_PatrickG  
                      Started by itrader46, Today, 12:39 PM
                      3 responses
                      10 views
                      0 likes
                      Last Post NinjaTrader_Jesse  
                      Working...
                      X