Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Immediately Place Order when Strategy Enabled

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

    Immediately Place Order when Strategy Enabled

    I want to place an order immediately above/below previous bar when I enable the strategy. However, it sometimes makes me wait for a new bar, or doesn't place order at all.

    I've tried changing the 'StartBehavior' but nothing happens.


    if (Position.MarketPosition == MarketPosition.Flat)
    {
    if (High[0] - Low[0] <= (50*TickSize))
    {
    EnterShortStopLimit(2, (Low[0] - (2 * TickSize)) , (Low[0] - (1 * TickSize)) , @"SE1");
    EnterShortStopLimit(1, (Low[0] - (2 * TickSize)) , (Low[0] - (1 * TickSize)) , @"SE2");
    EnterShortStopLimit(1, (Low[0] - (2 * TickSize)) , (Low[0] - (1 * TickSize)) , @"SE3");
    }


    Thank you!!!!

    #2
    Hi elcowen, thanks for posting. If you want to do this on the first real time bar, put this code at the top of OnBarUpdate:

    if(State == State.Historical)
    return;

    Also make sure "EntriesPerDirection" is set to at least 3 to accommodate the three entry orders.

    Kind regards,
    -ChrisL

    Comment


      #3
      Chris good catch on the Entries/Direction... thank you!

      My strategy is still waiting for the start of a new candle before sending an order.

      If I said Calculate.EachTick then used High[1] (instead of High[0]) would that send the order immediately?

      Thanks,

      Comment


        #4
        Hi elcowen, Is the strategy running in a backtest with these orders or are they real time orders? If you see it in the backtest the strategy needs intrabar granularity. See this post explaining the concept:

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        82 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        43 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        64 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        68 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        56 views
        0 likes
        Last Post CarlTrading  
        Working...
        X