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

get the latest higst in an addons

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

    get the latest higst in an addons

    I'm trying to get the latest higst in my addons and from what I read it could be like that, but I don't know why it doesn't come here in the debug, private void BarsRequest_Update(object sender, BarsUpdateEventArgs e)
    {
    UltimoAlto = e.BarsSeries.GetHigh(e.BarsSeries.Count - 1) + tickSize;

    if (!contadorEjecutado)
    {
    lock (lockObject)
    {
    if (!contadorEjecutado)
    {
    contadorEjecutado = true;
    ContadorPosiciones();
    }
    }
    }
    }​ me podrian ayudar

    #2
    Hello franatas,

    Thanks for your post.

    When you mention "get the latest higst " are you referring to getting the High price?

    Bars.GetHigh() could be used to get the High price in an AddOn.

    See the help guide documentation below for more information and sample code.

    BarsRequest: https://ninjatrader.com/support/help...arsrequest.htm
    Bars: https://ninjatrader.com/support/helpGuides/nt8/bars.htm
    GetHigh(): https://ninjatrader.com/support/help...t8/gethigh.htm
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      if (entradatipo == "Stop")
      {
      if (topmostCheckBoxUltimaVela.IsChecked == true) { PrecioPrimeraEntrada = barsRequest.Bars.GetLow(0) - tickSize; }
      else { PrecioPrimeraEntrada = PrecioEntrada - ticksLimitadas * tickSize; }

      OrdenEntrada = submissionAccountMaestra.CreateOrder(instrumentSel ectorMaestra.Instrument, OrderAction.Sell, OrderType.StopMarket, OrderEntry.Automated, TimeInForce.Day, cantidadSeleccionada1, PrecioPrimeraEntrada, PrecioPrimeraEntrada, string.Empty, "CORTOS", Globals.MaxDate, null);
      submissionAccountMaestra.Submit(new[] { OrdenEntrada });

      PrecioPrimeraEntrada = barsRequest.Bars.GetLow(0) - tickSize; }
      It only shows bars of one minute even though the graph is in five minutes.

      Comment


        #4
        Hello franatas,

        Thanks for your notes.

        From the BarsRequest help guide page:

        A BarsRequest provides underlying market data for an instrument, but is not synchronized with an indicator or strategies primary data series. You will need to implement your own BarsUpdateEvent logic.

        Further, from the help guide:

        A BarsRequest should be called only once and subscribe to the .Update event. Remember to unsubscribe from the .Update Event handler if you are no longer using the subscription.

        See the BarsRequest help guide documentation below for more information and sample code demonstrating the use of Bars.GetHigh()/Bars.GetLow()

        BarsRequest: https://ninjatrader.com/support/help...arsrequest.htm
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          barsRequest = new BarsRequest(instrumentSelectorMaestra.Instrument, 1)
          {
          BarsPeriod = new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = Periodo },
          TradingHours = instrumentSelectorMaestra.Instrument.MasterInstrum ent.TradingHours
          };​
          if (topmostCheckBoxUltimaVela.IsChecked == true) { PrecioPrimeraEntrada = barsRequest.Bars.GetHigh(0) + tickSize; }
          if (topmostCheckBoxUltimaVela.IsChecked == true) { PrecioPrimeraEntrada = barsRequest.Bars.GetLow(0) - tickSize; }

          Once I get here, how do I make sure that the last high or the last low is always that of the last closed candle?
          Last edited by franatas; 01-15-2024, 10:20 AM.

          Comment


            #6
            Hello franatas,

            Thanks for your notes.

            Bars.GetHigh() / Bars.GetLow() will get the high or low price value of the bar index that you pass into GetHigh()/GetLow().

            You would need to make sure you are passing in the bar index value of the bar you want to get the high price and low price of.

            Note that a bar index is not the same as barsAgo.

            ChartBars.ToIndex could be used to get the index value representing the last bar rendered on the chart.

            See the help guide documentation below for more information.

            ChartBars.ToIndex: https://ninjatrader.com/support/help...rs_toindex.htm
            GetHigh(): https://ninjatrader.com/support/help...t8/gethigh.htm
            GetLow(): https://ninjatrader.com/support/help...nt8/getlow.htm

            You could also consider viewing the AddOn Framework sample script from this forum thread which uses GetHigh() and GetLow(): https://ninjatrader.com/support/help...t_overview.htm
            Brandon H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by DJ888, Today, 10:57 PM
            0 responses
            5 views
            0 likes
            Last Post DJ888
            by DJ888
             
            Started by MacDad, 02-25-2024, 11:48 PM
            7 responses
            158 views
            0 likes
            Last Post loganjarosz123  
            Started by Belfortbucks, Today, 09:29 PM
            0 responses
            7 views
            0 likes
            Last Post Belfortbucks  
            Started by zstheorist, Today, 07:52 PM
            0 responses
            7 views
            0 likes
            Last Post zstheorist  
            Started by pmachiraju, 11-01-2023, 04:46 AM
            8 responses
            151 views
            0 likes
            Last Post rehmans
            by rehmans
             
            Working...
            X