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

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.
    Emily C.NinjaTrader Customer Service

    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
          Emily C.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Rapine Heihei, 04-23-2024, 07:51 PM
          2 responses
          30 views
          0 likes
          Last Post Max238
          by Max238
           
          Started by Shansen, 08-30-2019, 10:18 PM
          24 responses
          943 views
          0 likes
          Last Post spwizard  
          Started by Max238, Today, 01:28 AM
          0 responses
          9 views
          0 likes
          Last Post Max238
          by Max238
           
          Started by rocketman7, Today, 01:00 AM
          0 responses
          7 views
          0 likes
          Last Post rocketman7  
          Started by wzgy0920, 04-20-2024, 06:09 PM
          2 responses
          28 views
          0 likes
          Last Post wzgy0920  
          Working...
          X