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?

    BertrandNinjaTrader Customer Service

    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.

        BertrandNinjaTrader Customer Service

        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 Gerik, Today, 09:40 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by RookieTrader, Today, 09:37 AM
            1 response
            10 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by alifarahani, Today, 09:40 AM
            0 responses
            5 views
            0 likes
            Last Post alifarahani  
            Started by KennyK, 05-29-2017, 02:02 AM
            3 responses
            1,284 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by AttiM, 02-14-2024, 05:20 PM
            11 responses
            185 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X