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

Delay in order execution

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

    Delay in order execution

    Hi,

    I have a strategy that uses 2 series. The first series is a 10-tick series while the second is a 480-minute one (Note: I selected the 10-tick series as an attempt to catch the price movement as fast as possible. If there’s a better way, kindly suggest).

    My buy condition is a straightforward one. Simply the moment current price (high of the first series 10-tick) is higher than the High of the 480-minute candle (second series), take a buy position. So, here’s how I described it in the code:

    else if (State == State.Configure)
    {
    AddDataSeries(FirstSeries);
    AddDataSeries(SecondSeries);
    }

    protected override void OnBarUpdate()
    {
    if (BarsInProgress == 1 || BarsInProgress == 2)
    return;
    if (CurrentBars[1] < 2)
    return;
    if (CurrentBars[2] < 2)
    return;

    If (Highs[1][0]>Highs[2][0])
    {
    EnterLong();
    }

    The problem is that the code doesn’t always execute my condition (when the current price is higher than 480 minute high). In so many cases, it does. However, not all the time. There were times when the current price exceeded with 20 ticks difference, and the buy position was not placed!! I intend to make my profit target as 20-ticks

    Is this attributed to the volatility of the market?
    Is this a little problem in the code?
    How can I ensure there’s no delay in placing my order?


    Thanks

    #2
    Hello Abdullah_KSA,

    If the bar type supports TickReplay, using Calculate.OnPriceChange would be a good solution for triggering an action when the price changes.
    TickReplay allows this to work in historical data.



    To understand the behavior, enable TraceOrders and use Print().
    Below is a link to a forum post that demonstrates how to use prints to understand behavior.


    Print the time of the bar with a message that states this condition evaluated as true.

    Is the order being ignored with a message from TraceOrders?

    Is the condition evaluating as true at the time you are expecting?
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by geddyisodin, Today, 05:20 AM
    2 responses
    16 views
    0 likes
    Last Post geddyisodin  
    Started by hazylizard, Today, 08:38 AM
    0 responses
    6 views
    0 likes
    Last Post hazylizard  
    Started by Max238, Today, 01:28 AM
    5 responses
    42 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by giulyko00, Yesterday, 12:03 PM
    3 responses
    13 views
    0 likes
    Last Post NinjaTrader_BrandonH  
    Started by habeebft, Today, 07:27 AM
    1 response
    16 views
    0 likes
    Last Post NinjaTrader_ChristopherS  
    Working...
    X