Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

cancel orders if input logic is no longer met

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

    cancel orders if input logic is no longer met

    por defecto esto se cumple y en demo al correr la estrategia lo hace, pero en el analizador no lo esta haciendo
    I have this logic in the code:
    if (OrdenEntrada != null && CurrentBar > Velaentrada + 1)
    CancelOrder(OrdenEntrada);​
    y a la hora de enviar un pedido tengo CurrentBar = Velaentrada
    y luego en OnOrderUpdate:
    if (OrdenEntrada != null && OrdenEntrada == order)
    {
    // Check if myEntryOrder is cancelled.
    if (OrdenEntrada.OrderState == OrderState.Cancelled)
    {
    // Reset myEntryOrder back to null
    OrdenEntrada = null;
    }
    }​
    y aun asi en el analizaor no cancela la orden y aun pasando dos velas al llegar al precio de entrada coloca la orden

    #2
    Hello franatas,

    Thank you for your post.

    There are some known discrepancies between real-time results and backtest results. These differences are explained on the following help guide page:


    The strategy analyzer bases order fills on OHLC information from the bars; this is why you are only seeing actions on the close of bars instead of intrabar. If you want to run a backtest with more intrabar granularity, you could potentially use High Order Fill Resolution in the Strategy Analyzer properties or you could code the strategy to submit orders to a single tick data series. For more information on these two options, please see the following links:Please let us know if we may be of further assistance.

    Comment


      #3
      AddDataSeries(Data.BarsPeriodType.Tick, 1); ya esta añadido al codigo
      pero tendremos una manera de decir al codigo que cancele la operacion pasada una vela si la orden no se ejecuta
      por eso puse la parte del codigo que deveria hacer esto , pero no lo hace

      Comment


        #4
        por si sirve de algo, si trabajo bajo IsFirstTickOfBar:
        if (IsFirstTickOfBar && Position.MarketPosition == MarketPosition.Flat && DayOk)
        en vez de if (Position.MarketPosition == MarketPosition.Flat && Velaentrada != CurrentBar && DayOk)
        en analizer tambien se cancelan las ordenes en la siguiente vela

        Comment


          #5
          Hello franatas,

          Thank you for your reply.

          Simply adding the 1 tick data series will not resolve this on its own; you need to adjust your logic for certain actions to happen when BarsInProgress == 0 or when BarsInProgress == 1. For more details on working with multi-time frame and instruments, please review the following page:


          I have created a sample strategy that submits a long limit entry order when an EMA crossover occurs. If the entry is not filled by the next bar, the entry is canceled. Please see the attached script, which may be imported via Control Center > Tools > Import > NinjaScript AddOn.

          Feel free to reach out with any additional questions or concerns.
          Attached Files

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          648 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          369 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          572 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          573 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X