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

Problem with High/Low on 1 Tick Charts

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

    #16
    Actually, I'm still not getting it.

    That would imply that subsequent calls to GetCurrentBid() may occasionally miss some price changes, but that High[0] called via OnBarUpdate() should eventually capture every one.

    I know I'm being a pain, but that can't be right. In the data I posted, If you look at the series of different GetCurrentBid() values on the way from $1.0008 to $1.0013, it looks like the following:

    GetCurrentBid()
    8
    9
    10
    9
    10
    12
    11
    12
    11
    12
    11
    12
    13

    As you can see, it bounces up and down quite a bit, implying at least 12 bid change events. But High[0] on the other hand:

    High[0]
    8
    9
    10
    11
    12
    13

    It shows a steady progression with only 5 bid change events. That is, 'across the same range of price data' there are far more bid change events being indicated by subsequent calls to GetCurrentBid() than there are being indicated by calls to High[0].

    High[0] must be missing stuff.

    Comment


      #17
      beastment,

      Let us take a step back. What are you trying to accomplish with GetCurrentBid/Ask? I suggest you just use OnMarketData(). You may be able to assess the bid/ask/last more directly.
      Josh P.NinjaTrader Customer Service

      Comment


        #18
        I have an indicator that plots the most recent trough (attached), a trough generally being defined by a tick lower than surrounding ticks. In the sample I've attached it works just fine on a 1-tick chart.

        However, you will notice that I have added in GetCurrentBid() as a dataseries (bidprices). I originally was using 'Low' rather than bidprices because I wanted the indicator to eventually work on other charts rather than just 1-tick charts. However, when I looked at the 1-tick chart I noticed that it wasn't quite working properly: it occasionally seemed to miss a down tick or plotted a new trough when the chart indicated that price had been flat. I eventually worked out that Low[0] and GetCurrentBid() aren't always the same.

        I have a similar indicator that relies on Ask prices to identify peaks, and I was using High[0] + (GetCurrentAsk() - GetCurrentBid) to identify the appropriate points and ran into similar problems.

        Basically, being pretty new to NT, I'm also trying to make sure that I understand exactly what the data is telling me. In this case, was there a trough or wasn't there?

        I wasn't aware of the OnMarketData method. I'll look into it.
        Attached Files

        Comment


          #19
          Right. I cannot advise you on your trough requirements, but you would just want to use OnMarketData() to get your bid and asks.
          Josh P.NinjaTrader Customer Service

          Comment


            #20
            I still think there is a problem with when High and Low update. The following code:

            protected override void OnMarketData(MarketDataEventArgs e)
            {
            Print("OnMarketData(" + e.MarketDataType.ToString() + "): CurrentBar " + CurrentBar.ToString() + " Bid " + GetCurrentBid().ToString() + " Ask " + GetCurrentAsk().ToString() + " High " + High[0].ToString() + " Low " + Low[0].ToString());
            }

            protected override void OnBarUpdate()
            {
            Print("OnBarUpdate: CurrentBar " + CurrentBar.ToString() + " Bid " + GetCurrentBid().ToString() + " Ask " + GetCurrentAsk().ToString() + " High " + High[0].ToString() + " Low " + Low[0].ToString());
            Test0.Set(Close[0]);
            }


            Produced the following data:

            OnBarUpdate: CurrentBar 43 Bid 1.0004 Ask 1.0005 High 1.0004 Low 1.0004
            OnMarketData(Last): CurrentBar 43 Bid 1.0004 Ask 1.0005 High 1.0004 Low 1.0004
            OnMarketData(Ask): CurrentBar 43 Bid 1.0004 Ask 1.0005 High 1.0004 Low 1.0004
            OnMarketData(Bid): CurrentBar 43 Bid 1.0004 Ask 1.0005 High 1.0004 Low 1.0004
            OnBarUpdate: CurrentBar 44 Bid 1.0003 Ask 1.0004 High 1.0004 Low 1.0004
            OnMarketData(Last): CurrentBar 44 Bid 1.0003 Ask 1.0004 High 1.0004 Low 1.0004
            OnMarketData(Ask): CurrentBar 44 Bid 1.0003 Ask 1.0004 High 1.0004 Low 1.0004
            OnMarketData(Bid): CurrentBar 44 Bid 1.0003 Ask 1.0004 High 1.0004 Low 1.0004
            OnBarUpdate: CurrentBar 45 Bid 1.0003 Ask 1.0004 High 1.0004 Low 1.0004
            OnMarketData(Last): CurrentBar 45 Bid 1.0003 Ask 1.0004 High 1.0004 Low 1.0004
            OnMarketData(Ask): CurrentBar 45 Bid 1.0003 Ask 1.0004 High 1.0004 Low 1.0004
            OnMarketData(Bid): CurrentBar 45 Bid 1.0003 Ask 1.0004 High 1.0004 Low 1.0004
            OnBarUpdate: CurrentBar 46 Bid 1.0003 Ask 1.0004 High 1.0004 Low 1.0004
            OnMarketData(Last): CurrentBar 46 Bid 1.0003 Ask 1.0004 High 1.0004 Low 1.0004
            OnMarketData(Ask): CurrentBar 46 Bid 1.0003 Ask 1.0004 High 1.0004 Low 1.0004
            OnMarketData(Bid): CurrentBar 46 Bid 1.0003 Ask 1.0004 High 1.0004 Low 1.0004
            OnBarUpdate: CurrentBar 47 Bid 1.0004 Ask 1.0005 High 1.0004 Low 1.0004
            OnMarketData(Last): CurrentBar 47 Bid 1.0004 Ask 1.0005 High 1.0004 Low 1.0004
            OnMarketData(Ask): CurrentBar 47 Bid 1.0004 Ask 1.0005 High 1.0004 Low 1.0004
            OnMarketData(Bid): CurrentBar 47 Bid 1.0004 Ask 1.0005 High 1.0004 Low 1.0004
            OnBarUpdate: CurrentBar 48 Bid 1.0003 Ask 1.0004 High 1.0004 Low 1.0004
            OnMarketData(Last): CurrentBar 48 Bid 1.0003 Ask 1.0004 High 1.0004 Low 1.0004
            OnMarketData(Ask): CurrentBar 48 Bid 1.0003 Ask 1.0004 High 1.0004 Low 1.0004
            OnMarketData(Bid): CurrentBar 48 Bid 1.0003 Ask 1.0004 High 1.0004 Low 1.0004
            OnBarUpdate: CurrentBar 49 Bid 1.0004 Ask 1.0005 High 1.0004 Low 1.0004
            OnMarketData(Last): CurrentBar 49 Bid 1.0004 Ask 1.0005 High 1.0004 Low 1.0004
            OnMarketData(Ask): CurrentBar 49 Bid 1.0004 Ask 1.0005 High 1.0004 Low 1.0004
            OnMarketData(Bid): CurrentBar 49 Bid 1.0004 Ask 1.0005 High 1.0004 Low 1.0004
            OnBarUpdate: CurrentBar 50 Bid 1.0003 Ask 1.0004 High 1.0004 Low 1.0004
            OnMarketData(Last): CurrentBar 50 Bid 1.0003 Ask 1.0004 High 1.0004 Low 1.0004
            OnMarketData(Ask): CurrentBar 50 Bid 1.0003 Ask 1.0004 High 1.0004 Low 1.0004
            OnMarketData(Bid): CurrentBar 50 Bid 1.0003 Ask 1.0004 High 1.0004 Low 1.0004
            OnBarUpdate: CurrentBar 51 Bid 1.0003 Ask 1.0004 High 1.0004 Low 1.0004
            OnMarketData(Last): CurrentBar 51 Bid 1.0003 Ask 1.0004 High 1.0004 Low 1.0004
            OnMarketData(Ask): CurrentBar 51 Bid 1.0003 Ask 1.0004 High 1.0004 Low 1.0004
            OnMarketData(Bid): CurrentBar 51 Bid 1.0003 Ask 1.0004 High 1.0004 Low 1.0004
            OnBarUpdate: CurrentBar 52 Bid 1.0004 Ask 1.0005 High 1.0004 Low 1.0004
            OnMarketData(Last): CurrentBar 52 Bid 1.0004 Ask 1.0005 High 1.0004 Low 1.0004
            OnMarketData(Ask): CurrentBar 52 Bid 1.0004 Ask 1.0005 High 1.0004 Low 1.0004
            OnMarketData(Bid): CurrentBar 52 Bid 1.0004 Ask 1.0005 High 1.0004 Low 1.0004
            OnBarUpdate: CurrentBar 53 Bid 1.0004 Ask 1.0005 High 1.0004 Low 1.0004
            OnMarketData(Last): CurrentBar 53 Bid 1.0004 Ask 1.0005 High 1.0004 Low 1.0004
            OnMarketData(Ask): CurrentBar 53 Bid 1.0004 Ask 1.0005 High 1.0004 Low 1.0004
            OnMarketData(Bid): CurrentBar 53 Bid 1.0004 Ask 1.0005 High 1.0004 Low 1.0004


            High and Low do not change, despite many calls to OnBarUpdate, OnMarketData and the underlying Bid price. If none of these events are associated with a change in High and Low, what is?
            Last edited by beastment; 12-28-2008, 05:45 PM.

            Comment


              #21
              Not sure what you mean. High and Low are for last prices. Bid and Ask are not last prices. High and Low change when the last price changes for the instrument if it is a new high or a new low.

              NinjaTrader does not do anything to the data it receives. It acts just like a radio receiver. What you see is the information being generated by your data feed.
              Josh P.NinjaTrader Customer Service

              Comment


                #22
                But it's a 1 tick chart from the simulator....

                I think I might give up on this and just accept that I can't meaningfully use high and low on a 1 tick chart.

                Thanks,
                Josh.

                Comment


                  #23
                  Unfortunately I am just not understanding the concern. A 1 tick chart has no "new" high/low even possible. There is one tick. That price is the same for OHLC. Another price will be shown on another bar. A 1 tick bar has no room available for a candy body or even candle wicks.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #24
                    I guess what I don't understand is why on a 1 tick chart, a change in Bid (that you can clearly see on the chart) is never reflected in the data for open, close, high or low. In the data below OHLC are all constantly at 1.0071, but on Bar 211 the Bid briefly droppped down to 1.0070. You can clearly see this dip on the chart that I attached (it's a basic chart, the orange line is just connecting prices). But that dip NEVER affects OHLC. You've explained why GetCurrentBid may not be in sync with OHLC, but I don't understand why this change never flows through to OHLC.

                    Essentially, if I pull up a 1 tick chart with the simulator, what I'm actually seeing is a plot of GetCurrentBid, which appears to be a totally different thing from open or close prices. I don't understand why GetCurrentBid and OHLC are totally different things here. On a 1 tick chart shouldn't they all be exactly the same thing? Or am I fundamentally misunderstanding what a tick is? On a 1 tick chart, 1 bar = 1 tick doesn't it? And a new tick means that a transaction took place?

                    To try and answer my own question:

                    Is it perhaps the case that OHLC represent prices that were actually traded at, whereas Bid just represents an offer that was in place. Hence, Bid can change if an offer is entered or withdrawn from the market, but if no one took up that offer then OHLC will remain constant? If a new tick means that a new offer was entered (or an old one withdrawn) but not necessarily that a transaction took place, that could perhaps explain the data I'm seeing.

                    I think maybe the penny just dropped....


                    OnBarUpdate: CurrentBar 207 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnMarketData(Last): CurrentBar 207 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnMarketData(Ask): CurrentBar 207 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnMarketData(Bid): CurrentBar 207 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnBarUpdate: CurrentBar 208 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnMarketData(Last): CurrentBar 208 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnMarketData(Ask): CurrentBar 208 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnMarketData(Bid): CurrentBar 208 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnBarUpdate: CurrentBar 209 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnMarketData(Last): CurrentBar 209 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnMarketData(Ask): CurrentBar 209 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnMarketData(Bid): CurrentBar 209 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnBarUpdate: CurrentBar 210 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnMarketData(Last): CurrentBar 210 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnMarketData(Ask): CurrentBar 210 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnMarketData(Bid): CurrentBar 210 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnBarUpdate: CurrentBar 211 Bid 1.007 Ask 1.0071 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnMarketData(Last): CurrentBar 211 Bid 1.007 Ask 1.0071 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnMarketData(Ask): CurrentBar 211 Bid 1.007 Ask 1.0071 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnMarketData(Bid): CurrentBar 211 Bid 1.007 Ask 1.0071 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnBarUpdate: CurrentBar 212 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnMarketData(Last): CurrentBar 212 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnMarketData(Ask): CurrentBar 212 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnMarketData(Bid): CurrentBar 212 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnBarUpdate: CurrentBar 213 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnMarketData(Last): CurrentBar 213 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnMarketData(Ask): CurrentBar 213 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnMarketData(Bid): CurrentBar 213 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnBarUpdate: CurrentBar 214 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnMarketData(Last): CurrentBar 214 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnMarketData(Ask): CurrentBar 214 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    OnMarketData(Bid): CurrentBar 214 Bid 1.0071 Ask 1.0072 High 1.0071 Low 1.0071 Open 1.0071 Close 1.0071
                    Attached Files

                    Comment


                      #25
                      OHLC does represent prices that were actually traded at. Your explanation could be the case.
                      Josh P.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by love2code2trade, Yesterday, 01:45 PM
                      4 responses
                      26 views
                      0 likes
                      Last Post love2code2trade  
                      Started by funk10101, Today, 09:43 PM
                      0 responses
                      7 views
                      0 likes
                      Last Post funk10101  
                      Started by pkefal, 04-11-2024, 07:39 AM
                      11 responses
                      37 views
                      0 likes
                      Last Post jeronymite  
                      Started by bill2023, Yesterday, 08:51 AM
                      8 responses
                      44 views
                      0 likes
                      Last Post bill2023  
                      Started by yertle, Today, 08:38 AM
                      6 responses
                      26 views
                      0 likes
                      Last Post ryjoga
                      by ryjoga
                       
                      Working...
                      X