Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Scalability without ATM

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

    Scalability without ATM

    Hi Team NT

    i was earlier taking guidance through your support via email but i lost the mail so i'm here.
    I'm a beginner of a programmer & my intention with this code is to:
    1. Scale Up the Quantity to be Traded
    2. By keeping Slippage under control. That is to trade within a defined % boundary of the Last Traded Price just before the Signal generated.

    While i'm trying my best here, i have a "huge" list of errors..esp syntax.

    i would love any help here.

    Thank You
    Attached Files

    #2
    Hello piyushc,

    Thank you for your post.

    Attached is the corrected code, although there was no definition for NIL so I opted out of including it so that you could on your own.
    Attached Files

    Comment


      #3
      Thanks a ton, Patrick.
      Ok, so i have implemented exactly as you corrected.
      There are some errors in compilation, hugely reduced though.
      Please tell me where am i going wrong..is it the Syntax alone or the Logic too?
      Attached Files

      Comment


        #4
        Hello piyushc,

        Thank you for your response.

        It appears that there may be some missing references to necessary .dll files. Can you send me a note at support[at]ninjatrader[dot]com with 'ATTN: Patrick - 1018648' in the subject line and we can schedule a remote session to look into this matter further.

        Comment


          #5
          Hello piyushc,

          Thank you for your time today.

          We found it was not the references but it was the syntax as you thought. Please let me know if you have any questions.

          Comment


            #6
            Thanks Patrick.
            The code works just fine on Market Replay.

            Now i was adding Shorts to the Code. I'm wondering how would the code interpret TotalQuantity(TQ) in Short? Is it a negative figure?
            Will the following work under OnExecution ?
            As you might remember, use of TQ starts under OnExecution Method only.

            ---

            if (execution.Name == "EnterShort"
            && execution.Order == entryOrder && execution.Order.OrderState == OrderState.Filled)
            {
            Print("OnExecution PositionQuantity: "+Position.Quantity+" Total orders needed: "+TQ);

            BX = GetCurrentBid();

            if( Position.Quantity < TQ
            && (PN-BX)/PN*100 <= SN)

            {

            // Send as many entries to get the total order quantity filled.
            for(int i = TQ - Position.Quantity; i>0 ; i--)
            {
            EnterShortLimit(GetCurrentBid(),"EnterShortAgain"+ i);
            }
            }
            }

            if (execution.Name == "ExitShort"
            && execution.Order == entryOrder && execution.Order.OrderState == OrderState.Filled)
            {
            Print("OnExecution RemainingPositionQuantity: "+Position.Quantity);

            AX = GetCurrentAsk();

            if( Position.Quantity > 0
            && (AX-PX)/PX*100 <= SX)

            {

            // Send as many entries to get the total quantity filled.
            for(int i = Position.Quantity; i>0 ; i--)
            {
            ExitShortLimit(GetCurrentAsk(),"ExitShortAgain"+i) ;
            }
            }
            }

            Comment


              #7
              SN = Slippage % for Entry Positions
              SX = Slippage % for Exit Positions

              This has been the change from previous code.

              Comment


                #8
                Hello piyushc,

                Thank you for your response.

                The following is not necessary as the ExitShortLimit() alone will submit the needed quantity:
                Code:
                // Send as many entries to get the total quantity filled.
                for(int i = Position.Quantity; i>0 ; i--)
                {
                ExitShortLimit(GetCurrentAsk(),"ExitShortAgain"+i) ;
                }
                Please let me know if you have any questions.

                Comment


                  #9
                  When it is firing the Exit Order for the first time, it will fire the entire Position.Quantity. But what if, the entire quantity doesn't get traded? Wouldn't it be wise to then get into OnExecution and then re-check the best bid/ask and check it for the slippage percent and fire the remaining quantity again?

                  Comment


                    #10
                    One more question:
                    if, Total Quantity TQ = 10
                    Single Order Quanity SOQ = 1
                    & i keep Trailing Stop Loss.
                    Then, in the Entries Per Direction, Should i enter 10 or 20, as the system will have 10 entries for Trailing Stop Loss as soon as the Trade is entered. Then to Exit the position it would need another 10, right?

                    Comment


                      #11
                      Hello piyushc,

                      Thank you for your response.

                      The Exit() methods will only exit the position, they will not reverse your position by submitting orders in the opposite direction that are not needed to close the position. So there is no need to add the quantity in unless you are scaling out by a set amount rather than the entire position.

                      And the EntriesPerDirection would need to be 10 as the exits would not be considered entries.

                      Comment


                        #12
                        Theoretically, if there is a signal to ExitLong of 10 quantity, which is the Position.Quantity,
                        & it fires an ExitLongLimit at the Best Bid, say that was for 4.
                        Now we have 6 qty un-exited.
                        Then what...?
                        Shouldn't it then check the next best bid and check the slippage parameters, if all good, then fire the remaining quantity?

                        Comment


                          #13
                          Hello piyushc,

                          Thank you for your response.

                          The ExitLongLimit() in your example would still have 6 waiting to be filled. If you will it is necessary to readjust the order and quantity you can do so, but you will need to use the correct syntax for the ExitLongLimit() method:
                          Code:
                          ExitLongLimit(int quantity, double limitPrice, string signalName, string fromEntrySignal)

                          Comment


                            #14
                            Ok, so while the previous corrected code was working just fine during Entry of Positions. Exiting was a problem because there was a Toggle of Positions, from Long to Short & Vice versa. So a Managed Approach could not work.
                            I have then modified the code for Unmanaged Approach & added the Trailing Stop Loss too.
                            While the code works fine when i do not add the Trailing Stop Loss, On addition of SetTrailStop() under Initialize() Method, when i go to the New Strategy Page, it throws up this error:
                            2/21/2014 7:28:44 PM Strategy Failed to call method 'Initialize' for strategy 'EXECUTIONTEST/ab37b90ef79d4f57a0ef2afc69c795da': 'SetTrailStop' method can't be called since 'SubmitOrder' was called before.

                            .cs file of the Test Code attached.

                            Pls help me correct this final error.

                            Thanks
                            Attached Files

                            Comment


                              #15
                              You cannot use SetTrailStop or any other "Managed" order method with Unmanaged code.

                              If you wish to use a trail stop, you'll have to manually change the order by using ChangeOrder():

                              MatthewNinjaTrader Product Management

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              647 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              368 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              108 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              571 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              573 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X