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

Print the current stop order

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

    Print the current stop order

    I am trying to get the value of the current stop order however what I have doesn't seem to work

    Print(ExitLongStop + "ExitLongStop " + Time[0]);

    #2
    fiddy, what print are you seeing then with this call? Is ExitLongStop a variable that would be expected to hold your current stop value?

    To directly access the properties of any order, please work with the IOrder interface -

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Could you provide example of how to request the stopprice of an order from within the iorder interface

      Comment


        #4
        Surething, you would need to submit your order with an IOrder reference first to have access to it -

        if (myIOrder == null)
        myIOrder = ExitLongStop(1000);

        if (myIOrder != null)
        Print(myIOrder.StopPrice);
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Are you able to have two IOrder's at same time

          I tried to create mystoporder and mytrailorder

          however I get the following error msg

          Cannot implicity convert 'void' to NinjaTrader.Cbi.IOrder

          Comment


            #6
            You could create multiple IOrder objects, however as I have explained the other thread of yours in managed mode you then easily run into the managed mode order handling rules - just working with one order would be here and then updating the stop level as desired dynamically from your code to provide the trail aspects.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Thanks for the advice, in order to achieve the same affect as a trailing stop do I have to set the calculationonbarclose to false. Correct?

              In backtesting will the results be the same?

              Comment


                #8
                CalculateOnBarClose is always true in backtesting. If you would want to simulate trailing on a tick by tick basis the actual trail stop logic would have to be worked in using a finer series i.e tick one in your strategy script. The same would hold for the SetTrailStop, in backtesting it would be based on your primary series with CalculateOnBarClose = true only.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Missing Stops

                  Hi Bertrand

                  I have tried to create a trail stop system using IOrder as you suggested

                  Attached is the code.
                  The problem I have is that in some instances the market doesn't acknowledge the stop in place.
                  even though I know they are there as I have printed out stops at various time to ensure that they are correct.

                  Also in some instances the code seems to work as I would expect.
                  Any suggestions to find out why the stops aren't working?
                  Attached Files

                  Comment


                    #10
                    Hi fiddy, for the time when the stop seems ignored, what TraceOrders print would you see? That's usually the best way to start debugging such scenarios alongside the Prints you already have implemented - http://www.ninjatrader.com/support/h...ub=TraceOrders
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Thanks for advice

                      The Stop gets placed correctly however for some reason it is cancelled later due to expiring.
                      What would cause the order to expire on ExitLongStop?

                      31/03/2012 5:00:00 AM Entered internal PlaceOrder() method at 31/03/2012 5:00:00 AM: BarsInProgress=0 Action=Sell OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=1.0303 SignalName='' FromEntrySignal=''


                      3/04/2012 5:00:00 AM Cancelled expired order: BarsInProgress=0: Order='NT-00001/Backtest' Name='Sell' State=Working Instrument='$AUDUSD' Action=Sell Limit price=0 Stop price=1.0303 Quantity=0 Strategy='Pinstar' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='59806abdcfc24ad9bfebdbe803c3a5cb' Gtd='1/12/2099 12:00:00 AM'

                      Comment


                        #12
                        fiddy, per default those stops would expire on the next bar update seen. You can persist them with setting the liveUntilCancelled to true in the advanced overload offered for ExitLongStop. Then only the end of session handling would cancel any open orders of those.
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          Would this work

                          ExitLongStop(1,true,DefaultQuantity,Close[0] - (.5*StopDistance ),"","");

                          Comment


                            #14
                            Correct, that's how you would set them to not expire but persist until session end.
                            BertrandNinjaTrader Customer Service

                            Comment


                              #15
                              Do I need to put anything to replace the "" as the below is still giving same issue of the stop order expiring

                              ExitLongStop(1,true,DefaultQuantity,Close[0] - (.5*StopDistance ),"","");

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Barry Milan, Today, 10:35 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post Barry Milan  
                              Started by DJ888, Yesterday, 06:09 PM
                              2 responses
                              9 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              3 responses
                              40 views
                              0 likes
                              Last Post jeronymite  
                              Started by bill2023, Today, 08:51 AM
                              2 responses
                              16 views
                              0 likes
                              Last Post bill2023  
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              167 responses
                              2,260 views
                              0 likes
                              Last Post jeronymite  
                              Working...
                              X