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

cancelar ordenes de entrada si no se ejecutan en un tiempo determinado

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

    cancelar ordenes de entrada si no se ejecutan en un tiempo determinado

    trato de cancelar las ordenes de entrada si al paso de la siguiente vela no se han ejecutado:
    en OnBarUpdate utilizo

    if (OrdenEntrada != null && CurrentBar > Velaentrada)
    {
    //Cortos = false;
    //Largos = false;
    // Cuando la orden de entrada se cancela a continuación en OnOrderUpdate(), se reemplaza con una orden de mercado
    CancelOrder(OrdenEntrada);

    }

    y en OnOrderUpdate :
    if (OrdenEntrada != null && order.Name == "LARGOS")
    {
    // Compruebe si OrdenEntrada está cancelada.
    if (order.OrderState == OrderState.Cancelled)
    {
    // Restablecer OrdenEntrada de nuevo a nulo
    OrdenEntrada = null;
    OrdenMercado = EnterLong(Position.Quantity, "market order");
    Cortos = false;
    Largos = false;
    }
    }
    if (OrdenEntrada != null && order.Name == "CORTOS")
    {
    // Compruebe si OrdenEntrada está cancelada.
    if (order.OrderState == OrderState.Cancelled)
    {
    // Restablecer OrdenEntrada de nuevo a nulo
    OrdenEntrada = null;
    OrdenMercado = EnterShort(Position.Quantity, "market order");
    Cortos = false;
    Largos = false;
    }
    }
    esto lo saque de algun ejemplo de ninja pero no me funciona o algo estoy haciendo mal
    necesito ayuda para que cancele la orden si no se ejecuta en la vela siguiente de la señal de entrada​​

    #2
    Hola franatas,

    Gracias por escribirnos hoy.

    Tenemos capacidad limitada para proporcionar soporte de plataforma en español; sin embargo, hemos encontrado que este sitio https://www.deepl.com/es/translator puede traducir el inglés al español con buena calidad. Por favor copie nuestra respuesta y luego navegue al sitio que le colocamos para pegar la respuesta en el cuadro hacia la izquierda.

    I see you mention the code you are using doesn't work but you do not state what exactly is not working in your code.

    Does the order not get canceled when calling CancelOrder()?

    Is the order being canceled when CancelOrder() is called but the market order is not being submitted?

    Have you added debugging prints to your script yet to determine exactly how it is behaving? If not, debugging prints should be added to the script to see how the logic is behaving.

    Below is a link to a forum post that demonstrates how to use prints to understand behavior.
    https://ninjatrader.com/support/foru...121#post791121

    Here is a reference sample linked below you could view that demonstrates how the CancelOrder() method could be used. You could compare your script to this reference sample to see where things might be different.
    https://ninjatrader.com/support/helpGuides/nt8/using_cancelorder_method_to_ca.htm

    And, see this help guide page for more information about CancelOrder(): https://ninjatrader.com/support/helpGuides/nt8/cancel.htm
    Last edited by NinjaTrader_BrandonH; 06-01-2023, 11:24 AM.
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Segwin, 05-07-2018, 02:15 PM
    14 responses
    1,788 views
    0 likes
    Last Post aligator  
    Started by Jimmyk, 01-26-2018, 05:19 AM
    6 responses
    837 views
    0 likes
    Last Post emuns
    by emuns
     
    Started by jxs_xrj, 01-12-2020, 09:49 AM
    6 responses
    3,293 views
    1 like
    Last Post jgualdronc  
    Started by Touch-Ups, Today, 10:36 AM
    0 responses
    13 views
    0 likes
    Last Post Touch-Ups  
    Started by geddyisodin, 04-25-2024, 05:20 AM
    11 responses
    63 views
    0 likes
    Last Post halgo_boulder  
    Working...
    X