• 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 get bid ask prices for Instrument in AddOn

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

  • NinjaTrader_ChelseaB
    replied
    Hello vivekniwas,

    The Exchange is set in the instrument settings.
    https://ninjatrader.com/support/help...nderstandingGe neralSection
    https://ninjatrader.com/support/help...8/exchange.htm
    https://ninjatrader.com/support/help.../exchanges.htm

    What exchange or exchanges are selected in the instrument settings for this instrument?

    May we have a screenshot?


    From the chart, I am seeing that TD Ameritrade does not provide historical ask daily data.
    https://ninjatrader.com/support/help...y_provider.htm

    Leave a comment:


  • vivekniwas
    replied
    Thanks so I am having the below code.
    - Will the I get the correct Exchange pushed here by the Broker. I am using TD ameritrade and not getting the exchange name here. Instead I get null.
    - Will I get the latest Bid and Ask price of the today's bar ?


    public static void SendQuoteForCharts(ChartQuoteRequest request)
    {

    Thread subscriptionThread=new Thread(() =>
    {
    Thread.CurrentThread.IsBackground = true;
    // create a new bars request. This will determine the insturment and range for the bars to be requested
    BarsRequest barsRequest = new BarsRequest(NinjaTrader.Cbi.Instrument.GetInstrume nt(request.Symbol), 2);

    // Parametrize your request.
    barsRequest.BarsPeriod = new BarsPeriod { BarsPeriodType = BarsPeriodType.Day, Value = 1 };
    barsRequest.TradingHours = TradingHours.Get("Default 24 x 7");

    // Request the bars
    barsRequest.Request(new Action<BarsRequest, ErrorCode, string>((bars, errorCode, errorMessage) =>
    {
    if (errorCode != ErrorCode.NoError)
    {
    // Handle any errors in requesting bars here
    NinjaTrader.Code.Output.Process(string.Format("Err or on requesting bars: {0}, {1}",
    errorCode, errorMessage), PrintTo.OutputTab1);
    return;
    }

    if(bars.Bars.Count==2)
    {
    String messageBody="{{ "s": "ok","d": [\n";
    messageBody+=string.Format("{{\n "s": "ok",\n "n": "{0}:{3}",\n "v": {{\n "ch": "{1}",\n "chp": "{2}",\n "short_name": "{3}",\n "exchange": "{4}",\n "description": "{5}",\n "lp": "{6}",\n "ask": "{7}",\n "bid": "{8}",\n "open_price": "{9}",\n "high_price": "{10}",\n "low_price": "{11}",\n "prev_close_price": "{12}",\n "volume": "{13}"\n }}\n }},",
    NinjaTrader.Cbi.Instrument.GetInstrument(request.S ymbol).Exchange.ToString(),
    bars.Bars.GetClose(1)-bars.Bars.GetOpen(1),
    100*(bars.Bars.GetClose(1)-bars.Bars.GetOpen(1))/bars.Bars.GetOpen(1),
    request.Symbol,
    NinjaTrader.Cbi.Instrument.GetInstrument(request.S ymbol).Exchange.ToString(),
    NinjaTrader.Cbi.Instrument.GetInstrument(request.S ymbol).FullName,
    bars.Bars.GetClose(1),
    bars.Bars.GetAsk(1),
    bars.Bars.GetBid(1),
    bars.Bars.GetOpen(1),
    bars.Bars.GetHigh(1),
    bars.Bars.GetLow(1),
    bars.Bars.GetClose(0),
    bars.Bars.GetVolume(1)
    );

    messageBody=messageBody.Substring(0,messageBody.Le ngth-2);
    messageBody+="\n ]\n}";
    SendChartData(messageBody, Tradelytics.Instructions.GetQuotesForCharts);
    }



    }));
    });
    subscriptionThread.Priority=ThreadPriority.Highest ;
    subscriptionThread.Start();
    }

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello vivekniwas,

    Bars objects do have .GetAsk() and .GetBid() methods.
    https://ninjatrader.com/support/help...nt8/getask.htm
    https://ninjatrader.com/support/help...nt8/getbid.htm

    Alternatively, you can set the BarsPeriod MarketDataType to .Ask or .Bid with the BarsRequest.
    https://ninjatrader.com/support/help...barsperiod.htm

    Leave a comment:


  • vivekniwas
    started a topic How to get bid ask prices for Instrument in AddOn

    How to get bid ask prices for Instrument in AddOn

    I have AddOn in which I make BarsRequest for the Instrument for which I have an open position to get the open close last high and low for last 1 second. Is there a way I can get the bid ask as well if I supply quantity ?

Latest Posts

Collapse

Topics Statistics Last Post
Started by Eric M., Today, 05:25 PM
0 responses
6 views
0 likes
Last Post Eric M.
by Eric M.
 
Started by ttodua, Today, 01:52 PM
1 response
17 views
0 likes
Last Post NinjaTrader_Jim  
Started by muisca, 05-19-2017, 11:49 AM
8 responses
6,466 views
0 likes
Last Post NinjaTrader_Tyler  
Started by NinjaTrader_Brandon, Today, 12:08 PM
0 responses
81 views
0 likes
Last Post NinjaTrader_Brandon  
Started by iq200, Today, 12:00 PM
2 responses
11 views
0 likes
Last Post iq200
by iq200
 
Working...
X