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

From MT to NT

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

    #16
    Hello Barrenas,

    Thanks for your reply.

    Please review the reference sample for working with OnOrderUpdate(): http://ninjatrader.com/support/forum...ead.php?t=7499
    Paul H.NinjaTrader Customer Service

    Comment


      #17
      Originally posted by NinjaTrader_Paul View Post
      Hello Barrenas,

      Thanks for your reply.

      Please review the reference sample for working with OnOrderUpdate(): http://ninjatrader.com/support/forum...ead.php?t=7499
      Excelent!

      I'm having a little inconvenience. Sometimes, usually with forex, the log prompt me:

      20/08/2015 10:31:32 Order BAR [DATA STREAM], Sell stop or sell stop limit orders can't be placed above the market. affected Order: Sell 1 Stop @ 1,5645
      20/08/2015 10:31:32 Strategy Strategy 'ExpertsWDP/380eda3789374db48ffd0602749ae35c' submitted an order that generated the following error 'OrderRejected'. Strategy has sent cancel requests, attempted to close the position and terminated itself.

      I know what it is, in MT4 is a 130 error. The thing is why it happens only sometimes, I suppose that is because the spread but I'll love if you can review my code.

      Code:
              protected int abreNoStop (double SL, bool buy, double _TP,string tName){
                    if(buy){
                      SetStopLoss(tName,CalculationMode.Price,SL,false);
                      SetProfitTarget(tName,CalculationMode.Price,_TP);
                      orden=EnterLong(risk,tName);
                    }else{
                      SetStopLoss(tName,CalculationMode.Price,SL,false);
                      SetProfitTarget(tName,CalculationMode.Price,_TP);
                      orden=EnterShort(risk,tName);
                  }
                     if(orden.Error!=ErrorCode.NoError){ 
                      Log(orden.Instrument.FullName+"  NJE: "+orden.Error+"  BE: "+orden.NativeError,NinjaTrader.Cbi.LogLevel.Alert);
                      orden=null;
                         return(-1);
                    }
                     return(0);
              }
      Maybe I should put SL and TP after the operation? I should manage the rejection or the stop problems?

      Greetings!

      Comment


        #18
        Hello Barrenas,

        Thanks for your reply.

        I am assuming when your method is called that the SL and PT are correctly adjusted for the direction? Or are you intending to just reverse them based on the buy bool? If so you would need to switch them in the statements. Otherwise, I agree the issue is likely the spread and/or volatility and depends on your SL and PT location so perhaps to avoid the issue you may want to look at other values farther away from the entry.

        You are using market orders so your entry price is unknown until it actually occurs. As an alternate approach you may want to set an initially larger SL/TP until you have the Position.AvgPrice and then tighten them up as needed with the specific entry price. http://ninjatrader.com/support/helpG.../?avgprice.htm

        Here is a link of real time error handling: http://ninjatrader.com/support/helpG...orhandling.htm
        Paul H.NinjaTrader Customer Service

        Comment


          #19
          Hello Paul,

          Everything is working with my code now, but I have a problem with the instruments.

          I have the barchart data and I want to add some futures to Ninjatrader. Because I can't find any set of CME futures to import, I'm trying to do it manually.
          I can't get them to work. I put all the data of them that I have, but nothing:

          Can you help me with this?

          Greetings!
          Attached Files
          Last edited by Barrenas; 08-24-2015, 08:28 AM.

          Comment


            #20
            Hello Barrenas,

            Thanks for your post, glad you are making progress.

            To add instruments to your default (or other) list you would use the instrument manager. You should not need to edit the instruments.

            Here is a video on how to add an instrument: https://www.youtube.com/watch?v=KVnj...140D7&index=24
            Paul H.NinjaTrader Customer Service

            Comment


              #21
              Sorry, I haven't explained myself correctly.

              I need to add instruments to the Instrument Manager, like Sp600 e-mini, Nasdaq Bio e-mini... But I can´t. I add them, but later, no graphic.

              Greetings

              Comment


                #22
                Hello Barrenas,

                Thanks for your reply.

                It sounds like you may not have edited the symbol mapping and contract months for each of those. In the edited instrument, click on the Misc tab, scroll down until you see "Symbol Map" and for BarChart, enter the instrument symbol as BarChart would know it. (You might look at other instruments to see how it is shown). Here is a link to cover the "Misc" tab: http://ninjatrader.com/support/helpG...nstruments.htm see the section, " Understanding the Misc tab
                Paul H.NinjaTrader Customer Service

                Comment


                  #23
                  Hello,

                  Thanks for your answer!

                  A little question, if I put:
                  Code:
                  orden=EnterLong(risk,tName);
                  slOrden=EnterLongStop(tName,SL);
                  Its cool that both orders have the same name? In case of SetStopLoss it "autolinked" them and you could access to the stop loss from order.StopPrice, this will keep happening with EnterLongStop method?

                  Greetings!

                  PS: Also, the OrderAction of EnterLongStop order will be sell, no sellshort, I'm right?
                  PS1: Is better to put first the order and later the sl or put the sl and if it sticks, put later the order?
                  PS2: EnterLongStop doesn't make any stop for me. I put slOrden=EnterLongStop(SL,tName); but for the strategy performance tab I put no stop at all. Maybe the stop is unlinked with the operation or something?
                  PS: EnterLongStop gives me in the log:
                  25/08/2015 15:21:33 Strategy A Buy order placed at '28/07/2015 4:36:51' has been ignored since the stop price is less than or equal to the close price of the current bar. This is an invalid order and subsequent orders may also be ignored. Please fix your strategy.
                  It has the same parameters as SetStopLoss, exactly the same. Whats happening?
                  Last edited by Barrenas; 08-25-2015, 07:24 AM.

                  Comment


                    #24
                    Hello Barrenas,

                    Thanks for your reply.

                    As the EnterLong() is a market order I'm not sure why you would also use EnterLongStop(). That aside, please review the helpguide section on managed approach: http://ninjatrader.com/support/helpG...d_approach.htm In particular the section: Internal Order Handling Rules that Reduce Unwanted Positions This will likely answer most of your questions.

                    The definition of EnterLongStop() is: Generates a buy stop order to enter a long position. See: http://ninjatrader.com/support/helpG...erlongstop.htm
                    Paul H.NinjaTrader Customer Service

                    Comment


                      #25
                      Hello,

                      I think that I have a big misunderstanding here.
                      I want to manage my order with OnOrderUpdate, I can do it with the IOrder object returned by EnterLong()? Like:
                      Code:
                      protected override void OnOrderUpdate(IOrder order){
                                   if(orden!=null && orden== order && order.OrderState == OrderState.Rejected){
                                      Log("SL rejected on: "+orden.Instrument.FullName+"  NJE: "+orden.Error+"  BE: "+orden.NativeError,Cbi.LogLevel.Alert);
                                      CancelOrder(orden);
                           }
                      }
                      If I use the unmanaged aproach It nevers get the TP and SL that I want, so I'll love to do it managed by now.

                      Greetings!

                      Comment


                        #26
                        Hello Barrenas,

                        Thanks for your reply.

                        You are still using the managed approach so the rules referenced before will always apply.

                        Can you share your full code (or the code for the entry order and stop/profit) for a better understanding? If you would prefer, please feel free to send in to PlatformSupport[at}NinjaTrader[dot]Com. Atten: Paul and the link to this thread.
                        Paul H.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by futtrader, 04-21-2024, 01:50 AM
                        4 responses
                        41 views
                        0 likes
                        Last Post futtrader  
                        Started by Option Whisperer, Today, 09:55 AM
                        1 response
                        12 views
                        0 likes
                        Last Post bltdavid  
                        Started by port119, Today, 02:43 PM
                        0 responses
                        8 views
                        0 likes
                        Last Post port119
                        by port119
                         
                        Started by Philippe56140, Today, 02:35 PM
                        0 responses
                        7 views
                        0 likes
                        Last Post Philippe56140  
                        Started by 00nevest, Today, 02:27 PM
                        0 responses
                        7 views
                        0 likes
                        Last Post 00nevest  
                        Working...
                        X