Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multiple limit orders - only working on current bar

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

    Multiple limit orders - only working on current bar

    Hi,

    I've noted an issue or misunderstanding how limit orders should work.

    I'm trying to send multiple limit orders to market on a certain condition, example below:


    else if (State == State.Configure)
    {
    SetProfitTarget("", CalculationMode.Percent, 0,01);
    SetStopLoss("", CalculationMode.Percent, 0,01, false);
    }


    protected override void OnBarUpdate()
    {
    if (CurrentBars[0] < 1)
    return;
    }

    if (Close[0] > Close[1]))

    {
    EnterLong(Convert.ToInt32(DefaultQuantity), @"LongEntry");
    EnterLongLimit(Convert.ToInt32(DefaultQuantity), (Close[0] + (-10 * (TickSize * 10))) , @"LongLimit1");
    EnterLongLimit(Convert.ToInt32(DefaultQuantity), (Close[0] + (-20 * (TickSize * 10))) , @"LongLimit2");
    }


    What will happen in backtester, is that the limit orders only get filled on current bar and seems to get removed after current bar is complete. Should it work like this? If yes, is it very complicated to get the limit orders staying active after bar complete? Or do I need to change the way the stop and profit is handled for this to work?

    br,
    Chris

    #2
    Hello,

    Thank you for the post.

    Yes, this could be expected, if the price movement allows for a fill within the bar and it could fill, it will. Otherwise, if the order is just expiring this would be expected for any order that can persist for more than one bar with the Managed approach. You would either need to have the logic that calls the EnterLongLimit syntax remain true for a number of bars the limit should be active or use IsLiveUntilCancelled syntax:


    Code:
    EnterLongLimit(int barsInProgressIndex, [B]bool isLiveUntilCancelled[/B], int quantity, double limitPrice, string signalName)
    Setting this to true will allow the orders to persist longer than 1 bar.

    You can see when orders are expired using TraceOrders:


    I look forward to being of further assistance.

    Comment


      #3
      Hi again,

      Found this through another thread, not directly related to my issue but still; do I need to go here for getting my "idea" to work:


      br,
      Chris

      Comment


        #4
        Thank You!

        I understand this sets another level of risk but I will investigate, if this is where I'm comfortable going at this point.

        br,
        Chris

        EDIT: you can mark thread as solved.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Yesterday, 05:17 AM
        0 responses
        56 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        133 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        73 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        45 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        49 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X