Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem with order execution

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

    Problem with order execution

    Hi guys,
    I have written a very simple strategy to test the accuracy of order execution, because in some of our automated strategies I can see on chart, that it should working, but NT executes sometimes at undefined points (see on picture) or doesn't execute not at all, although the trigger has been touched.



    On the picture you can see on the right side the execution point. The position should be opened after a "cross below red line (Low[1]) - Go Short" or "cross above blue line (Median[1]) - Go Long". As you can see on the picture, the blue line wasn't triggered at all but NT has opened a long position.



    This is only one example. The test program runs on a simulation account live, the most orders are not executed on the trigger points and often - that's also great - executed contrary. On a "cross above green line (High[1])", where program shoud enter Long, it enters Short...? Here is the code, I don't know what could be the reason for this. The code is generated by the strategy builder.


    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;

    // set 1
    if ((BlokLong != Median[1])
    && (Times[0][0].TimeOfDay >= new TimeSpan(8, 0, 0))
    && (Times[0][0].TimeOfDay <= new TimeSpan(22, 0, 0))
    // Konditionsgruppe 1
    && ((CrossAbove(Close, High, 1))
    || (CrossAbove(Close, Median, 1))))
    {
    EnterLong(Convert.ToInt32(DefaultQuantity), "");
    BlokLong = Median[1];
    }

    // set 2
    if ((BlokLong != Median[1])
    && (Times[0][0].TimeOfDay >= new TimeSpan(8, 0, 0))
    && (Times[0][0].TimeOfDay <= new TimeSpan(22, 0, 0))
    // Konditionsgruppe 2
    && ((CrossBelow(Close, Low, 1))
    || (CrossBelow(Close, Median, 1))))
    {
    EnterShort(Convert.ToInt32(DefaultQuantity), "");
    BlokLong = Median[1];
    }


    Calculation mode is OnPriceChange
    Attached Files
    Last edited by Uwe1981; 09-28-2018, 02:23 AM.

    #2
    Hello Uwe1981,

    Thanks for your post.

    Considering that we see execution markers being placed at price levels outside of the bar, I may suspect that the PC clock is out of sync and the executions are being placed at price levels in consistent with what is displayed on the chart.

    You may follow the steps below to resync the PC clock.
    • Shutdown NinjaTrader
    • Right-click the clock in the lower right corner of your desktop
    • Select Adjust date/time
    • For Windows 10 click 'Additional date, time, & regional settings' -> then click 'Set the time and date'
    • Select the 'Internet Time' tab at the top
    • Set the server to time.nist.gov and then click Update.
    • If the message that appears says successful your PC clock should now be updated.
    • If not, select a different server from the Server: drop-down and try again (repeat until one of the servers is successful)


    After re-syncing the PC clock, please restart NinjaTrader and Reload All Historical Data before testing again.

    As a tip to further examine what is happening with a strategy, we advise to use debugging prints to monitor the logic as it is executing. This way you can see the values that are being used to evaluate each condition in your strategy. This can also make clock issues apparent if you see values that are evaluating in the strategy that are not consistent with what is being displayed on a chart. I've included a video showing how debugging prints can be used in the Strategy Builder.

    Debugging with the Strategy Builder - https://www.screencast.com/t/8uvjfM8h

    If you are still encountering this issue after re-syncing the PC clock, could you provide the debug output from the NinjaScript Output window with prints added to your strategy similar to those described in the video?

    I look forward to being of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    52 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    130 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    70 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    43 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    48 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X