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

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.
    JesseNinjaTrader Customer Service

    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 andrewtrades, Today, 04:57 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by chbruno, Today, 04:10 PM
        0 responses
        6 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Started by josh18955, 03-25-2023, 11:16 AM
        6 responses
        436 views
        0 likes
        Last Post Delerium  
        Started by FAQtrader, Today, 03:35 PM
        0 responses
        7 views
        0 likes
        Last Post FAQtrader  
        Started by rocketman7, Today, 09:41 AM
        5 responses
        19 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X