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

Bid Ask Price Lines - Plot on OnMarketDepth

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

    Bid Ask Price Lines - Plot on OnMarketDepth

    Hello, i try to create an indi which will have two lines one will show the Ask and one the Bid price for each period.

    Example:


    Since i want to be real time and also historic (using tick replay already) i came two issues
    1)i get the Ask&Bid price from OnMarketDepth. But there my plot doesnt work. I created also a public variable for each of these values and plot it on OnMarketData were plots do work. But it didnt so each Bid and Ask price it show last price.
    When i print onMarketDepth i get the values correct in realtime.

    2) I want the plot to be plotted in the whole time like line 2 of the image. Line 1 is my plot.

    My code:
    Code:
            protected override void OnMarketDepth(MarketDepthEventArgs e)
            {
    		//Get Bid and Ask
    		int position = e.Position;
    		if (e.MarketDataType == MarketDataType.Bid){
    			if(position==0){
    				Print(position+" Bid "+e.Price);
    			}
    		}
            if (e.MarketDataType == MarketDataType.Ask){
    			if(position==0){
    				Print(position+" Ask "+e.Price);
    			}
    		}
    
    
    		}

    #2
    Hello stoxos,

    Thanks for your question.

    OnMarketDepth() only works for real-time and OnMarketData() will only give you the Last market event with Tick Replay. You may consider adding an additional data series for historical Bid and Ask series. This is outlined in the Notes section at the bottom of the Developing for Tick Replay page of the help guide.

    I am slightly confused by your second question. Could you elaborate on what you mean by the "whole time?" Looking at the shape of the plot, you may be looking to use a Plot Style of Square instead of Line.

    Here are links to our publicly available documentation on Tick Replay and adding a historical bid/ask series.

    Developing for Tick Replay (See Notes) - https://ninjatrader.com/support/help...ick_replay.htm

    Using historical Bid/Ask Series - https://ninjatrader.com/support/help..._ask_serie.htm

    I look forward to being of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Yeah you are right i forgot that marketdepth is dom i needed T&S prices so i took data from my dataseries and using e.Ask and e.Bid i was able to take the prices i want. The second problem also solved, you were again right i used new Stroke as Square and worked very nice.

      But after all that progress i came to an other problem. The Times&Sales has orders in several times which i record but because i am down to second i just realize that i can not plot/draw my text label on the right time anchor because the time it doesn't exist in the ninjatrader 8 default time series of the chart. So if i want to draw at 16:00:11. A lot of times i cant properly, because the chart goes from 16:00:09 bar to lets say 16:00:13, so when i give the anchor value of 16:00:11 it goes and draw that text somewhere between and closer to the 16:00:09. So is that a limitation of NT8 ? or i need to make some tweak to my Data-series properties of my chart?

      Real example


      Thank you

      Comment


        #4
        Hello stoxos,

        I'm glad you progressed through those issues.

        Drawing Tools will snap to an associated slot and are limited in the sense that they cannot be plotted intra-bar. This can be worked around through your own custom rendering where you can draw directly to the chart with SharpDX and specify your own pixel coordinates.

        We have a feature request for Drawing Tool overloads that would allow specifying millisecond granularity instead of mapping to an associated bar slot. I have submitted a vote on your behalf. The ticket ID for this feature request is SFT-2696.

        As with other feature requests, we cannot present an ETA as they are fulfilled based on the development team's schedule and priorities. Upon implementation, the ticket ID can be found on the Release Notes page of the help guide. I'll provide a link below.

        Release Notes: https://ninjatrader.com/support/help...ease_notes.htm

        Please let me know if there is anything else I can do to be of further help.
        JimNinjaTrader Customer Service

        Comment


          #5
          Ok its ok i leave it as it is.

          Thank you.

          Very fast support as always!

          Comment


            #6
            You can add my vote for feature request SFT-2696 as well....(thanks)

            Comment


              #7

              Hello Stoxos, I try to program it but the bid / ask data that appear with real-time data are not the same and then when you perform a reload F5. Can you share the indicator?

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by RookieTrader, Today, 09:37 AM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by alifarahani, Today, 09:40 AM
              0 responses
              5 views
              0 likes
              Last Post alifarahani  
              Started by Gerik, Today, 09:40 AM
              0 responses
              4 views
              0 likes
              Last Post Gerik
              by Gerik
               
              Started by KennyK, 05-29-2017, 02:02 AM
              3 responses
              1,283 views
              0 likes
              Last Post NinjaTrader_Clayton  
              Started by AttiM, 02-14-2024, 05:20 PM
              11 responses
              185 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Working...
              X