Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Understanding EnterLongStop

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

    Understanding EnterLongStop

    Hi,

    I might not understand EnterLongStop correctly, is it a Long Stop order? So if I want to buy if the day's price is higher than the previous day high, I call:

    EnterLongStop( 1, true, DefaultQuantity, High[1] + BidAskSpread, "OpenLong" ) ;

    Below is my code, it doesn't work as it supposes to be. For now, I can only use EnterLong and EnterShort and they always use the next day's open instead of the exact THE SAME DAY entry price (as long as the day is tick higher than yesterday's high) I want. Please help, thanks.


    protected override void Initialize()
    {
    Add( PeriodType.Minute, 1 ) ;

    CalculateOnBarClose = true;
    }

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

    if (CrossAbove(...))
    EnterLongStop( 1, true, DefaultQuantity, High[1] + BidAskSpread, "OpenLong" ) ;

    if (CrossBelow(...))
    EnterShortStop( 1, true, DefaultQuantity, Low[1] - BidAskSpread, "OpenShort" ) ;
    }

    There're no trades at all if I use the code above.

    #2
    Hello CobrasMarketView,

    Welcome to the NinjaTrader Support Forums.

    The EnterLongStop() method will place a Buy Stop order at the defined price.

    Based upon your snippet of code, I do not see any syntax that would be off. Who are you connected to? This is displayed in the lower left corner of the Control Center.

    Are you using the Strategy Analyzer to test this strategy or a chart?

    Note that you may use Print() statements to verify values are what you expect and to see how your code is being processed - Debugging your NinjaScript code.

    In strategies if you add TraceOrders = true to your Initialize() method, you can then view valuable output related to strategy submitted orders through Tools > Output window - TraceOrders

    It may also help to add drawing objects to your chart for signal and condition confirmation - Drawing Objects.

    Happy to be of further assistance.
    JCNinjaTrader Customer Service

    Comment


      #3
      Thanks. I'll try to debug and see what I can find.

      Just want to make sure one thing: Say, when CrossAbove() triggered, NT always calculates the next bar (as EnterLong() always uses the next bar's open as entry price), right? So the buy stop order here is actually apply to the next bar, not the current bar (when the cross actually happens), right? Even I added secondary 1 min data series, but still it's calculating the next bar, right?

      Comment


        #4
        Hello CobrasMarketView,

        Using the EnterLong() method would enter a market order. When backtesting the order will be filled at the open of the next bar correct.

        With COBC set to true the NinjaScript is calculating on the close of each bar so the order will be submitted at the start of the next bar. If you would like the order to be filled intrabar (inside of the 1 min bar) you would want to set COBC to false.

        Note that when running a Strategy on historical data via Strategy Analyzer or Chart (not real-time) COBC is always going to be set to true. So you would have to add another time frame if you would like the order to be filled inside the 1 minute bar.

        You may view the following thread for reference.
        You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by


        Let us know if we can be of further assistance.
        JCNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        648 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        369 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        109 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        573 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        575 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X