• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Critical Issue in Order.LimitPrice

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

    Critical Issue in Order.LimitPrice

    It looks Order class does not return the limitPrice that entered EnterLongLimit properly.

    Step to reproduce the problem

    1) I have a method to calculate price by Tick. TickSize is 0.1 in M2K instrument

    private double CalcPrice(int tick) { return tick * TickSize; }

    2) I call EnterLongLimit
    var limitPrice = CalcPrice(tick); // 1575.6
    var order EnterLongLimit(0, true, quantity, limitPrice, signalName);
    Print(limitPrice); //1575.6
    Print(order.LimitPrice); //1575.6
    Print(price==order.limitPrice); false !!!

    My work has been cut out to grab the bug. it looks the result have some decimal To fix that I need to Round the result in every compare. It doesn't happen on any numbers and very difficult to reproduce.



    #2
    Hello ManTrader,

    Thank you for the post.

    I can see a couple of problems in the sample provided.

    The first is that you are testing for equality on double numbers which will not often equate to true. This is a part of C# and how floating point numbers are stored.

    Code:
    Print(price==order.limitPrice);
    It is not suggested to use == for floating point numbers, instead you can do floating point comparisons as described here: https://ninjatrader.com/support/help...arithmetic.htm

    The second problem is that you are checking the order directly after submitting the order, it is generally suggested to collect the order instance from the OnOrderUpdate or OnExecutionUpdate overrides before accessing the values of the order to make sure it was successful. The prices you set should be fine to check however if you are looking for other values such as the fill price, you will need to start using the overrides. It is generally good practice to form your orders as variables as shown in the following sample rather than assigning the variable directly as you have: https://ninjatrader.com/support/help...and_onexec.htm

    In reference to the above sample, placement for your print could be in OnOrderUpdate after the line:
    Code:
    entryOrder = order;
    Please let me know if I may be of additional assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by yikccv, Today, 08:49 PM
    0 responses
    2 views
    0 likes
    Last Post yikccv
    by yikccv
     
    Started by supernova0219, Today, 07:48 PM
    0 responses
    5 views
    0 likes
    Last Post supernova0219  
    Started by qwfxny, Today, 07:20 PM
    0 responses
    3 views
    0 likes
    Last Post qwfxny
    by qwfxny
     
    Started by bouncetherubble, Today, 04:48 PM
    0 responses
    3 views
    0 likes
    Last Post bouncetherubble  
    Started by johnnybegoode, Today, 11:35 AM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Working...
    X