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

EnterLongLimit fails on tick-by-tick?

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

    EnterLongLimit fails on tick-by-tick?

    Hi there, is there a reason why EnterLongLimit would fail on tick-by-tick, instead of on bar close?

    I'm back testing a strategy. When I set "CalculateOnBarClose = true;" then EnterLongLImit works as expected. However, when I switch to "CalculateOnBarClose = false;", then EnterLongLimit fails. That is,

    - I'm running the same data, but it fails in one context, and works in another.

    - When it's failing on CalculateOnBarClose=false, I'm setting the price at least 10 ticks above the current price, so there's plenty of room.

    - When its failing on CalculateOnBarClose=false, if I replace EnterLongLimit with just EnterLong, then it works.

    Your thoughts? Thanks

    #2
    Also, here's some additional information. My code is:

    entryOrder = EnterLongLimit(Close[0] + ( 10 * TickSize));
    Print ("Time exp2 is " + Time[0] + ", at amount " + (Close[0] );
    Print("The entryOrder State exp2 is " + entryOrder.OrderState);
    Print("The entryOrder Action exp2 is " + entryOrder.OrderAction);
    Print("The entryOrder Limit Price exp2 is " + entryOrder.LimitPrice);
    Print("The entryOrder Limit From Entry Signal exp2 is " + entryOrder.FromEntrySignal);
    Print("The entryOrder Limit Instrument exp2 is " + entryOrder.Instrument);
    Print("The entryOrder Limit Limit Price exp2 is " + entryOrder.LimitPrice);
    Print("The entryOrder Limit Order Action exp2 is " + entryOrder.OrderAction);
    Print("The entryOrder Limit Order Type exp2 is " + entryOrder.OrderType);
    Print("The entryOrder Limit Time In Force exp2 is " + entryOrder.TimeInForce);
    Print("The entryOrder Limit Time Error exp2 is " + entryOrder.Error);
    Print("The entryOrder Limit Time Filled exp2 is " + entryOrder.Filled);
    Print("The entryOrder Limit Live Until Cancelled exp2 is " + entryOrder.LiveUntilCancelled);
    Print("The entryOrder Limit Time Native Error exp2 is " + entryOrder.NativeError);
    Print("The entryOrder Limit Time Stop Price exp2 is " + entryOrder.StopPrice);
    Print("The entryOrder Limit Time Time In Fore exp2 is " + entryOrder.TimeInForce);

    So I can see what's going on with the execution. The output is:

    Time exp2 is 6/27/2017 7:07:12 AM, at amount 2433
    The entryOrder State exp2 is Working
    The entryOrder Action exp2 is Buy
    The entryOrder Limit Price exp2 is 2435.5
    The entryOrder Limit From Entry Signal exp2 is
    The entryOrder Limit Instrument exp2 is ES 09-17 Globex
    The entryOrder Limit Limit Price exp2 is 2435.5
    The entryOrder Limit Order Action exp2 is Buy
    The entryOrder Limit Order Type exp2 is Limit
    The entryOrder Limit Time In Force exp2 is Gtc
    The entryOrder Limit Time Error exp2 is NoError
    The entryOrder Limit Time Filled exp2 is 0
    The entryOrder Limit Live Until Cancelled exp2 is False
    The entryOrder Limit Time Native Error exp2 is
    The entryOrder Limit Time Stop Price exp2 is 0
    The entryOrder Limit Time Time In Fore exp2 is Gtc

    So, you can see the order is active, but it never executes.

    Comment


      #3
      Hello again, I had time to perform additional testing, providing more clarity on the error. Basically, the order disappearing upon the second tick. My redux code is:

      CalculateOnBarClose = false;
      protected override void OnBarUpdate() {
      if (FirstTickOfBar) {
      entryOrder = EnterLongLimit(Close[0] + ( 10 * TickSize));
      if (entryOrder != null) {
      Print("The order is NOT null"):
      } else {
      if (entryOrder == null) {
      Print("The order is null"):
      }
      }

      When running, the output becomes:

      The order is NOT null
      The order is null

      So, somehow my order is only good on the tick of the first bar. On the second tick, for whatever reason, my order is no longer there. This finally explains why my order never executes.

      Your thoughts? Thanks

      Comment


        #4
        Hello timmbbo,

        Is the order being submitted with liveUntilCancelled as true or false?

        If this is false, or if this overload is not being used at all, then when using the managed approach the order will automatically be cancelled at the close of the bar it was submitted on.

        From the help guide:

        EnterLongLimit(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double limitPrice, string signalName)

        liveUntilCancelled - The order will NOT expire at the end of a bar, but instead remain live until the CancelOrder() method is called or its time in force has been reached.

        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by maybeimnotrader, Yesterday, 05:46 PM
        1 response
        18 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Perr0Grande, Yesterday, 08:16 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by f.saeidi, Yesterday, 08:12 AM
        3 responses
        24 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by algospoke, Yesterday, 06:40 PM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by quantismo, Yesterday, 05:13 PM
        1 response
        14 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X