Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Minor script problem

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

    Minor script problem

    In the strategy snippet I provided, could someone tell me why it always generates 2 contracts in the order?

    I have replaced "DefaultQuantity" with numerical values of 0,and 1 and it always sends 2 . Additionally, the OrderQty field on my DOM is set to 1. Bear with me, I am a beginner at this.

    CalculateOnBarClose = true;
    }
    ///<summary>
    /// Called on each bar update event (incoming tick)
    ///</summary>
    protectedoverridevoid OnBarUpdate()
    {
    // Condition set 1
    if (Close[0] > Open[0])
    {
    EnterLongLimit(DefaultQuantity, Close[
    0], "");
    }
    // Condition set 2
    if (Close[0] < Open[0])
    {
    EnterShortLimit(DefaultQuantity, Close[
    0], "");
    }

    TIA.

    #2
    BigAAPL, the DOM set qty would not be linked to what your strategy sends in.

    If you start the strategy by what do you choose to govern used qty by?

    Default Qty?

    By Strategy?

    Account Size?

    Comment


      #3
      I use set order qty "by strategy" as per default settings in the strat dialogue box.

      Comment


        #4
        Are you sure you're synched up strategy vs account position wise?



        Please try to your strategy in 'WaitUntilFlat' mode with a flat account position, this will then trigger trades on the next live generated entry signal.

        Comment


          #5
          Thank you for responding again Bertrand.

          While I try to fully wrap my head around this concept of synching account vs, strat, I can tell you that I am not entering any other orders while a strategy is activated, or running multiple strats. Placing a manual order to offset the virtual position, as suggested in the help file, seems kind of self defeating.

          I checked "wait until flat" mode as suggested, and now the strat refuses to fire, but shows a gain/loss in the unrealized column of the strat tab in control center. Sometimes it will enter an order only after several bars have built.

          I am simply trying to enter a limit order at the close of bar [0].

          Comment


            #6
            BigAAPL,

            Wait until flat means the strategy will not place real trades until the strategy position is flat. If you are not using this mode it is imperative you submit manual orders to sync your account position to the starting strategy position. Your strategy will always start with a position it calculates out based on historical data. If that position is not in sync with the account position you may have undesired consequences in your strategy submitting orders that may/may not be what you want for your account.

            Entering a limit order on the current bar is most likely already active on some historical bar. If you want it to be an active order you want to use Immediately Submit mode.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            88 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            48 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            31 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            34 views
            0 likes
            Last Post TheRealMorford  
            Started by Mindset, 02-28-2026, 06:16 AM
            0 responses
            69 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Working...
            X