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

Order Entry with Wizard

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

    Order Entry with Wizard

    I am trying to create a simple strategy via the wizard. I have my conditions and am running this at bar close (ie not updating intrabar).

    If the conditions are true at end of bar, and I want to place a Stop order to enter long X ticks above the bar which the conditions signaled true on , does that mean I set the wizard to enter X ticks above 0 bars ago or 1 bar ago.

    I guess what I don't understand is once the conditions are met at the close, when the wizard says "Do the following:" does my Stop order get placed immediately (ie open of next bar) or does it wait until close of bar after the condition bar.

    Sorry for being so wordy, sometimes it's hard to describe a simple question.

    #2
    coolmoss, it would place the order on the bar following the bar that triggered the condition to evaluate to 'true'. So you're currently on bar 1250 on the chart and your signal, says go EnterLongStop signal bar + 3 ticks, this order would the be place on bar 1251.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      That makes sense and that's what I thought. Here is what is happening for me in the simple wizard strategy I put together:

      I have a set of conditions with the following "Do the following:"
      1) Draw text (which shows my entry setup bar)
      2) EnterShortStop(DefaultQuantity,Low[0]+ -2*TickSize,"")
      3 Variable0 = High[1] + 2*TickSize

      The system runs fine except for the stop. I am setting the value of the stop to Variable0, but the trrade won't exit on the stop when it should. Every trade either exits on the profit target or an EOD exit. I wonder if the Variable0 action needs to be done before the EnterShortStop, but I dont' see how to change the order of the actions.

      Thanks for your help.

      Additional: I just found in the Log that the "calculated stop order price for strategy was smaller/equal 0. No stop order placed."

      This makes sense why it's not working, but I am setting the user variable to high or previous bar and the calc mode is price. I'm stumped.
      Last edited by coolmoss; 03-01-2012, 09:42 AM.

      Comment


        #4
        coolmoss, you're likely running into ignored orders here with this approach due to the 'Internal Order Handling' rules present in NT's managed approach - they would be detailed on the bottom page of this link from the helpguide - http://www.ninjatrader.com/support/h...d_approach.htm

        I would suggest you work with our TraceOrders feature, which would print helpful order debug info to the output window -



        You would need to unlock the wizard code though to add this into your strategy Initialize() method.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Okay, will do.

          While I'm fairly comfortable with working directly with the code, I'd like to keep the wizard created strategy for ease of starting over again from a known point. Is there a way to save a wizard created strategy under a different name and then open that code, thus keeping the original wizard functionality intact?

          Thanks

          Comment


            #6
            Yes, there would be an easy way to keep a wizard editable copy, just select the view code option before you unlock the code actually and then right click and select to save a copy, you could add for example a W suffix to the name to know that this one would be accessible via the wizard interface.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              added trace

              Okay, I added the order trace. In the output window I can clearly see the entry orders, the initial SetStopLoss and SetProfitTarget, and I can see various orders being canceled because of various profit targets being filled.

              However, no where do I see anything related to modifying (or cancel resubmit) the SetStopLoss order.

              My code to update the stop price is in the onBarUpdate section and looks like this...

              if (Position.MarketPosition == MarketPosition.Short && Position.Quantity == 3)
              {
              SetStopLoss(CalculationMode.Price,Position.AvgPric e + entryOffset*TickSize);
              }

              Does the order or placement of this snippet of code matter? Right now the entry is above, and I've fiddled a bit with variations, but doesn't seem to make much difference.

              Thanks for your help.

              Comment


                #8
                coolmoss,

                Do you have any other working orders at the time? Is the stop loss ever set to an initial value in Initialize() in mode ticks? For dynamic stop loss movements see this sample for best practices on setting at various times:


                To help debug: You could add a simple Print() confirmation to your condition, that the code has entered that particular block.

                Code:
                if (Position.MarketPosition == MarketPosition.Short && Position.Quantity == 3)
                {
                Print("entered stop loss modification block");
                SetStopLoss(CalculationMode.Price,Position.AvgPrice + entryOffset*TickSize);
                }
                Last edited by NinjaTrader_RyanM1; 03-01-2012, 03:46 PM.
                Ryan M.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by FrazMann, Today, 11:21 AM
                2 responses
                6 views
                0 likes
                Last Post NinjaTrader_ChristopherJ  
                Started by rjbtrade1, 11-30-2023, 04:38 PM
                2 responses
                80 views
                0 likes
                Last Post DavidHP
                by DavidHP
                 
                Started by Spiderbird, Today, 12:15 PM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_ChristopherJ  
                Started by lorem, Yesterday, 09:18 AM
                5 responses
                18 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by cmtjoancolmenero, Yesterday, 03:58 PM
                12 responses
                42 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Working...
                X