• 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

How to Set() info from OnMarketData() ??

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

    How to Set() info from OnMarketData() ??

    Hello,

    I have a price value that I retrieve from the OnMarketData() method that is the exact price of the first tick that occurs at market open(7:30am(mst)). This price is used as an exact/true market opening price. Which amazingly can be up to around a 4-5 tick difference between the true open and the open price that occurs by simply utilizing a synchronized PC clock.

    However, my problem comes in when I try to use the Set() method to keep this value for historical purposes. My indicator plots just fine as long as I am using real-time info and was connected prior to market open(7:30), but if I try to add the indicator later or look at historical charts, I cannot see view the indicator at all.

    Can I use the Set() method to save values from the OnMarketData() method?

    insomniac

    #2
    I believe so.

    Do you mean something like:

    Code:
    OnMarketData()
    {
    if (e.MarketDataType == MarketDataType.Last) myDataSeries.Set(e.Price);
    }
    RayNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Ray View Post
      I believe so.

      Do you mean something like:

      Code:
      OnMarketData()
      {
      if (e.MarketDataType == MarketDataType.Last) myDataSeries.Set(e.Price);
      }
      Yes, except I have to throw in:

      Code:
      OnMarketData()
              {
                  if (needOpenPrice)
                  {
                      if (e.MarketDataType == MarketDataType.Last)
                      {
                          if (ToTime(e.Time) == 73000)
                          {
                              needOpenPrice = false;
                              myDataSeries.Set(e.Price);
                          }
                      }
                  }
              }
      However I cannot seem to get it to show historically. I have even tried to Set() it within the OnBarUpdate()

      insomniac

      Comment


        #4
        I forgot, you must set the value in OnBarUpdate() since when this method is called, if you don't set it, it is internally reset.

        Declare a variable in the scope of the indicator, set the value of this variable in OnMarketData() then pas this variable in the .Set() method in OnBarUpdate().
        RayNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Ray View Post
          I forgot, you must set the value in OnBarUpdate() since when this method is called, if you don't set it, it is internally reset.

          Declare a variable in the scope of the indicator, set the value of this variable in OnMarketData() then pas this variable in the .Set() method in OnBarUpdate().
          I have tried this, but I still can't seem to get it to stick.

          insomniac

          Comment


            #6
            Then you will need to debug it as for sure that would work.

            You can work backwards, just declare a variable and se its value at declaration time, then assign this variable to .Set() in OnBarUpdate(). You will see that it works as expected.
            RayNinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Ray View Post
              Then you will need to debug it as for sure that would work.

              You can work backwards, just declare a variable and se its value at declaration time, then assign this variable to .Set() in OnBarUpdate(). You will see that it works as expected.
              I don't know if I am just an idiot or what, but I can't get this to work. I am starting to believe it has to do with the fact that I have to throw in the following:

              if (ToTime(e.Time) == 73000)
              daysOpen = e.Price;

              When I am running live w/real-time data feed it works just fine. But when looking back at previous days, nothing shows up at 7:30am, and if I remove the indicator at any time, even during live connections, I can reapply the indicator and it does not show. So the only way to keep the indicator showing on the chart is to stay connected to the data feed.

              Essentially all I need is the same indicator as CurrentDayOHL(), but instead of grabbing and setting the Open Price using:

              if (Bars.SessionBreak)
              currentOpen = Open[0];

              I need it to grab and set the Open Price using OnMarketData() at exactly 7:30am.

              insomniac

              Comment


                #8
                For clarification -

                OnMarketData() and OnMarketDepth() are only called in real-time NOT against historical data.
                RayNinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Ray View Post
                  For clarification -

                  OnMarketData() and OnMarketDepth() are only called in real-time NOT against historical data.
                  Ray,

                  Ok, so I certainly do not want to give you sh!t, but I spoke of this very thing in my first post and my second post. So why have I been ripping my hair out for something that cannot be done, but was given suggestions on how to do it, even when I kept saying that I couldn't get it to work. As you re-read my posts, you will see that I consistently referred to Historical Charts, and in my very first post I mention that I have it working just fine in real-time.

                  I am disappointed.


                  Originally posted by insomniac View Post
                  However, my problem comes in when I try to use the Set() method to keep this value for historical purposes. My indicator plots just fine as long as I am using real-time info and was connected prior to market open(7:30), but if I try to add the indicator later or look at historical charts, I cannot see view the indicator at all.
                  Originally posted by insomniac View Post
                  However I cannot seem to get it to show historically. I have even tried to Set() it within the OnBarUpdate()

                  Comment


                    #10
                    Sorry, I did not mean to disapoint you, it was not my intention. I overlooked that piece of information and should not have.
                    RayNinjaTrader Customer Service

                    Comment


                      #11
                      Well since I don't know how to take no for an answer. Would someone be willing to help me out with coding this indicator to actually do what I am looking for it to do. I am sure that there has got to be a way to have the indicator use System.IO to Write/Read from a text file that will start to accumulate historical Opening tick prices, as I run the indicator each day, and then it can read from the file and process each past day to Set() the value of the opening price for my charts.

                      insomniac

                      Comment


                        #12
                        You could contact a consultant.

                        http://www.ninjatrader.com/webnew/pa...injaScript.htm
                        RayNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by chrismcdermut, Yesterday, 01:46 PM
                        3 responses
                        17 views
                        0 likes
                        Last Post MojoJojo  
                        Started by Bricolico, Yesterday, 09:28 PM
                        0 responses
                        5 views
                        0 likes
                        Last Post Bricolico  
                        Started by Tradwell385, Yesterday, 08:51 PM
                        0 responses
                        7 views
                        0 likes
                        Last Post Tradwell385  
                        Started by dvcpro4, Yesterday, 07:08 PM
                        0 responses
                        19 views
                        0 likes
                        Last Post dvcpro4
                        by dvcpro4
                         
                        Started by pennywise, Yesterday, 06:40 PM
                        0 responses
                        8 views
                        0 likes
                        Last Post pennywise  
                        Working...
                        X