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

Where to place debugging stop orders code?

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

    Where to place debugging stop orders code?

    Here's one for Bertrand or Josh,

    Under Tips http://www.ninjatrader-support2.com/...ead.php?t=3418there is a post by Josh on debugging that reads:

    "When debugging stop or limit orders it can also be extremely useful to draw dots along your chart of the actual stop/limit prices. This way you can visually see where your orders are at and if they should have been filled or not."

    Code:
    Code:     DrawDot("Stop" + CurrentBar, 0, stopPrice, Color.Orange);
    Where should this be inserted, in Initialize () or OnBarUpdate()?

    Best, Tooearly

    #2
    Hi tooearly,

    In OnBarUpdate().
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Doesn't Compile

      When I insert DrawDot (Stop .... in OnBarUpdate () and compile I get an error message saying "The name Stop does not exist in the current context."

      When I change Stop to StopLoss or StopPrice to stopPrice, etc. no juice.

      I suppose I have to define Stop somewhere.

      Please look at the attachment showing the strategy sheet.

      Thanks, TE
      Attached Files
      Last edited by tooearly; 06-30-2009, 07:35 PM. Reason: add a line

      Comment


        #4
        TE, you would need to define the variable Stop first and then fill this with the value of your stoploss - for example in your case the Position.AvgPrice + / - the 0.1 percent stop you defined.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          StopLoss does not work

          This seem closely enough related to the DrawDot StopLoss issue that it may justify being posted here as a reply.

          The wizard in editor seems to introduce only one line when setting a stoploss,
          viz,

          SetStopLoss("", CalculationMode.Percent, 0.065, false);
          with nothing declared in Variables nor defined in Properties.

          But when I run backtests using the strategy with this code the losses exceed 6.5% (in this example) and no stop loss order is either placed or canceled. So it seems not to work, even though in the past I have gotten wizard-generated Stoploss to work. So I'm baffled.

          Is this related to the instruction from Bernard requiring that one define the variable Stop?

          Shouldn't one first declare a Private Double (StopLoss = 0.065) and then give it a Description in Properties? The Wizard does not seem to do this.

          Any light shed on this problem would be most appreciated.
          Last edited by tooearly; 07-05-2009, 10:23 PM. Reason: clarify question

          Comment


            #6
            tooearly, I suggest you activate TraceOrders to check 'under the hood' for the order generation. Also, the way your call is setup the 6.5 percent is hard coded in and does not represent a user definable input value. For this you're correct it would need to input name in the variables section and then a parameter description under properties.

            I'll also check into the code you send via email in a few mins.
            BertrandNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Rapine Heihei, 04-23-2024, 07:51 PM
            2 responses
            30 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by Shansen, 08-30-2019, 10:18 PM
            24 responses
            942 views
            0 likes
            Last Post spwizard  
            Started by Max238, Today, 01:28 AM
            0 responses
            9 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by rocketman7, Today, 01:00 AM
            0 responses
            4 views
            0 likes
            Last Post rocketman7  
            Started by wzgy0920, 04-20-2024, 06:09 PM
            2 responses
            28 views
            0 likes
            Last Post wzgy0920  
            Working...
            X