Announcement

Collapse
No announcement yet.

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
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    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
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        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
            <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            592 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            343 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            556 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            554 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X