Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multiple exits...

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

    Multiple exits...

    Hello There,

    I'm trying to setup several targets for my strategy and I have some problems.... Stop loss and auto break even is working fine, but not the partial exits on different targets.
    Can you help me to solve that please ?

    Here's my code :

    Variables :

    Code:
     // Default setting for StopLoss
                      private int stopL = 12; 
    		// Default setting for Target 1
    		 private int target1 = 10;
    		// Default setting for Target 2
    		 private int target2 = 24;
    		// Default setting for position Size
    		 private int nbcontracts = 2;
    		// Default setting for buffer entry
    		 private int bufferentry = 2;
    		// Default setting for break even +1 level
    		 private int breakeven = 6;
    The stops and break even +1 :

    Code:
    // Resets the stop loss to the original value when all positions are closed			
    					
    			if (Position.MarketPosition == MarketPosition.Flat)
    			{
    				SetStopLoss(CalculationMode.Ticks, stopL);
    			}		
    			
    /////////// Break even part /////////
    			
    			
    			
    			// If a long position is open, allow for stop loss modification to breakeven
    			
    			else if (Position.MarketPosition == MarketPosition.Long)	
    				
    			{
    				// Once the price is greater than entry price +x ticks, set stop loss to breakeven +1
    				if (High[0] >= Position.AvgPrice + breakeven * TickSize)
    				{
    					SetStopLoss(CalculationMode.Price, Position.AvgPrice +1 * TickSize);
    				}
    			}			
    			
    			
    			
    			// If a short position is open, allow for stop loss modification to breakeven
    			
    			else if (Position.MarketPosition == MarketPosition.Short)	
    				
    			{
    				
    			// Once the price is greater than entry price -x ticks, set stop loss to breakeven +1
    				
    				if (Low[0] <= Position.AvgPrice - breakeven * TickSize)
    				{
    					SetStopLoss(CalculationMode.Price, Position.AvgPrice -1 * TickSize);
    				}
    			}			
    			
    			
    			
    /////////// End Break even part /////////

    And then, entry condition and exits :

    i
    Code:
    f (  My conditions here )
    
            {
                    		EnterShortStop(nbcontracts, Low[0] - bufferentry * TickSize, "WIISignalShort1"); 
    						
    				ExitShortStop(1, target1, "Exit1WIISignalShort1", "WIISignalShort1");
    				ExitShortStop(1, target2, "Exit2WIISignalShort1", "WIISignalShort1");
    							
              }

    I probably have a problem of syntax, but I cannot find it.... I'm stuck...
    All the best !

    #2
    Hello,

    Thank you for your forum post.

    I just wanted to let you know that we received your note and you will have a response from someone this weekend or at the latest Monday.

    Thank You for your patience.
    BrettNinjaTrader Product Management

    Comment


      #3
      auto exit fm strategy after daily loss met

      Hi I tring to find information on auto exit strategy or void strategy after meeting my daily loss. Anybody can help. tks

      Comment


        #4
        Hello There !

        I found the solution in this thread :


        It works perfectly !
        Thank you very much for this great knowledge base.

        Comment


          #5
          Thank you very much for helping.

          Comment


            #6
            Hello,

            Thank you for your response Advs108!

            If you have any questions after Advs108s response please let me know.

            Thank You.
            BrettNinjaTrader Product Management

            Comment


              #7
              Ok, multi entries and multi exits functionality is working well !

              Now I have a little problem concerning the size of the positions. I want my strategy to trade on Forex and I want to be able to trade standard lots or mini lots.
              With my broker, 1 standard lot is = 1
              How should I code my position size to be able to trade one mini ? 0.01

              here's my code :
              Variables :

              Code:
              // Default setting for position Size, part 1
              
               private int nbcontracts1 = 1;
              
              // Default setting for position Size, part 2
              
               private int nbcontracts2 = 1;
              The order part, multi entry :

              Code:
              // Only allow entries if we have no current positions open
              
              if (Position.MarketPosition == MarketPosition.Flat)
              {
              	EnterLongStop(nbcontracts1, High[0] + bufferentry * TickSize, "SignalLong1a");
              	EnterLongStop(nbcontracts2, High[0] + bufferentry * TickSize, "SignalLong1b");
              					
              }
              I want to be able to define "nbcontracts1" and "nbcontracts1" as mini lots, something like 0.01 I think....
              How can I do that ?

              Thank you very much for all of your help !
              Last edited by advs108; 06-07-2010, 03:24 PM.

              Comment


                #8
                Hello,

                Please see the following information for Forex quantity sizing and let me know if you have any questions:



                Let me know if I can be of further assistance.
                BrettNinjaTrader Product Management

                Comment


                  #9
                  Hello,

                  Yes, I read this doc.... And I understood it.
                  If I'm using 1, my strategy is submitting an order of one lot. What I want is to be able to enter mini lots, 0.01 I think.
                  How to do that ?

                  Thank you for your help

                  Comment


                    #10
                    advs108,

                    This depends on your brokerage and your particular account. You will need to consult with your brokerage at what quantity you should be submitting your orders at to represent 1 mini lot.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Hello Josh,

                      1 mini, with my broker is 10 000. So, I was thinking my strat. should submit 0.01. This is not an int, but a double.
                      How can I write the code I posted in the thread below, in order to submit the good quantity ?

                      Thank you for your help.

                      Comment


                        #12
                        You're nbcontracts is defined as int, so it would not allow a double input, try defining those double variables instead.

                        However, you should be able to go with int's as well for trading a unit qty of 10000 which is a FX mini lot.

                        Comment


                          #13
                          Yes, right.

                          But how to make EnterLongStop accept double ? instead of int ?

                          Comment


                            #14
                            Hello,

                            QTY will have to be an INT for this method. You should not need to use a qty size of .01 based on what you mentioned, for your broker you should be using a qty size of 10000. Keep the variables as an INT and using 10000 as this equals 1 mini lot for your broker.

                            Let me know if I can be of further assistance.
                            BrettNinjaTrader Product Management

                            Comment


                              #15
                              Ok, I understand.
                              So, I made a test.
                              I'm connected to my broker and used the Sim101 account.
                              My strategy is sending 10 000.
                              And looking at the P&L, the strat is sending 10 000 Lots, not 1 mini....

                              Any idea ?
                              Thank you for your help

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              599 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              344 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              103 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              558 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              557 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X