Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

past values of MarketData

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

    past values of MarketData

    I am struggling to get this indicator to work. It is plotting the cumulative delta which is computed from the MarketDataEvent structure. I can get it to work on the current data when I load the indicator but all data from before the time that I load the indicator on the chart is unavailable. So the question is , in NT8, how do we access the equivalent of MarketData for historical values?


    protected override void OnMarketData(MarketDataEventArgs e)
    {

    if ( e.MarketDataType == MarketDataType.Bid )
    currentBid = e.Price;
    else if ( e.MarketDataType == MarketDataType.Ask )
    currentAsk = e.Price;
    else if ( e.MarketDataType == MarketDataType.Last )
    {
    currentPrice = e.Price;
    currentVolume= e.Volume;

    if ( currentPrice >= currentAsk )
    cumulativeDelta += currentVolume;
    if ( currentPrice <= currentBid )
    cumulativeDelta -= currentVolume;


    }
    Value[0]=cumulativeDelta

    }

    #2
    Hi frannt. Do you have tick replay enabled in your chart settings. This might be the issue for your problems.

    Comment


      #3
      I have switched on "Show Tick Replay" and "Enable market recording for playback" in the options / maket data settings. Is this what you were referring to? It still does not seem to help.

      Comment


        #4
        Originally posted by frannt View Post
        I have switched on "Show Tick Replay" and "Enable market recording for playback" in the options / maket data settings. Is this what you were referring to? It still does not seem to help.
        OK, I now found another setting on the chart itself which might be the one you were referring to. Now it is working! Thank you so much....

        Comment


          #5
          glad i could help,

          yes i referred to the chart menu.

          right click chart > dataseries > enalble tick replay

          regards

          Comment


            #6
            This seemed to do the trick but it raised another issue which I have read about elsewhere that NT seems to do something strange with the stored ticks. So when I had my indicator calculating off of live ticks on Friday I had a certain characteristic plot for the cumulative delta which had some wiggles in it. When I do the enable tick replay it does give me the past ticks however it seems to paint a completely different picture, like a straight line in fact. It is obviously changing something in the wrong way.

            So I will assume that the only way I can get my indicator to work reliably is to leave myself permanently connected and collect the real time ticks on my indicator as they come in off the live feed.

            If you or anyone else has any suggestions I would much appreciate to hear them.

            Comment


              #7
              Hello frannt,

              Thank you for your post.

              When using Tick Replay you would need to take into consideration a few items. Please let me know if you have any questions after reviewing the details at the following link: http://ninjatrader.com/support/helpG...ick_replay.htm

              If you would us to take a look at the indicator plot please provide a screenshot of the indicator plot in real-time and then in historical with Tick Replay. In addition, if you can provide the script or a sample that re-creates the matter it would be appreciated.

              Comment


                #8
                Originally posted by NinjaTrader_PatrickH View Post
                Hello frannt,

                Thank you for your post.

                When using Tick Replay you would need to take into consideration a few items. Please let me know if you have any questions after reviewing the details at the following link: http://ninjatrader.com/support/helpG...ick_replay.htm

                If you would us to take a look at the indicator plot please provide a screenshot of the indicator plot in real-time and then in historical with Tick Replay. In addition, if you can provide the script or a sample that re-creates the matter it would be appreciated.
                Hi, Attached is the indicator I am using which I have put together from reading help files and other people's available indicators. Also attached is the output of my indicator having collected tick data in real-time, and then of my indicator with tick replay enabled and NT filling in the missing historical data. They are different. I am not sure what the reason for this is. If you can have a look that will be much appreciated.
                Attached Files

                Comment


                  #9
                  Hello frannt,

                  Thank you for your response.

                  The documentation will be updated, but as it stand you would need to AddDataSeries() for the Bid and Ask and then access their values historically as MarketDataType does not exist historically for Bid or Ask in OnMarketData.

                  Comment


                    #10
                    Originally posted by NinjaTrader_PatrickH View Post
                    Hello frannt,

                    Thank you for your response.

                    The documentation will be updated, but as it stand you would need to AddDataSeries() for the Bid and Ask and then access their values historically as MarketDataType does not exist historically for Bid or Ask in OnMarketData.
                    Thanks for your input. I will try this when I next get some free time to program and will post a response here to say if it works.

                    Comment


                      #11
                      Hello frannt,

                      your code has some wrongs.
                      In historical, only happens the "Last" event (not BestAsk nor BestBid), so to assign the trade like buying or selling you must compare e.Price with e.Ask or e.Bid directly.

                      These images demostrate that TickReplay works perfectly.

                      Realtime (all data were obtained in real time):




                      Historical (all data were obtained from TickReplay):

                      Attached Files

                      Comment


                        #12
                        Hi cls71

                        thanks for that. I guess I just need to understand a bit more about NT8 programming. Nice indicator you have there!

                        Cheers

                        Comment


                          #13
                          frannt,

                          this code will do the trick.

                          Code:
                          protected override void OnMarketData(MarketDataEventArgs e)
                          		{
                          			if ( State == State.Historical )
                          			{
                          			    if( e.Price <= e.Bid )
                          					cumulativeDelta -= e.Volume;
                          			    else if (e.Price >= e.Ask )
                          			        cumulativeDelta += e.Volume;
                          			    else
                          				{
                          					// Between
                          				}
                          			}
                          			else 
                          			{
                          			    if ( e.MarketDataType == MarketDataType.Bid ) 
                          			        currentBid = e.Price;
                          			    else if ( e.MarketDataType == MarketDataType.Ask ) 
                          			        currentAsk = e.Price;
                          			    else if ( e.MarketDataType == MarketDataType.Last ) 
                          			    {
                          			        if ( e.Price >= currentAsk )
                          			            cumulativeDelta += e.Volume;
                          			        else if ( e.Price <= currentBid )
                          			            cumulativeDelta -= e.Volume;
                          				else
                          				{
                          					// Between
                          				}
                          			    }						
                          			}
                          		}

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by sidlercom80, 10-28-2023, 08:49 AM
                          172 responses
                          2,278 views
                          0 likes
                          Last Post sidlercom80  
                          Started by Irukandji, Yesterday, 02:53 AM
                          2 responses
                          17 views
                          0 likes
                          Last Post Irukandji  
                          Started by adeelshahzad, Today, 03:54 AM
                          0 responses
                          3 views
                          0 likes
                          Last Post adeelshahzad  
                          Started by CortexZenUSA, Today, 12:53 AM
                          0 responses
                          3 views
                          0 likes
                          Last Post CortexZenUSA  
                          Started by CortexZenUSA, Today, 12:46 AM
                          0 responses
                          1 view
                          0 likes
                          Last Post CortexZenUSA  
                          Working...
                          X