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 CaptainJack, 05-29-2026, 05:09 AM
        0 responses
        425 views
        0 likes
        Last Post CaptainJack  
        Started by CaptainJack, 05-29-2026, 12:02 AM
        0 responses
        279 views
        0 likes
        Last Post CaptainJack  
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        241 views
        1 like
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        327 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        289 views
        0 likes
        Last Post CarlTrading  
        Working...
        X