Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to space multiple entrees from each other?

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

    How to space multiple entrees from each other?

    I wonder if you can give me some code example on how to space multiple entrees from each other by a set number of ticks. For example if I am scaling in to a position with extra entrees I don't want the next entree to be made too close to my last one.

    #2
    Hello relogical,

    You may use the "TickSize" object to be able to set the number of ticks away from a price so that you may space out some of your scale in orders.

    For example:
    Code:
    protected override void Initialize()
    {
    	EntryHandling = EntryHandling.UniqueEntries;
    }
    
    protected override void OnBarUpdate()
    {
        //...Entry condition code.
    
        if ( /* Scale in Condition */ )
        {
              // Sets a Long limit order 5 Ticks above the average position price.
    	EnterLongLimit(Position.AvgPrice+5*TickSize,"EnterLong2"); // Set order name unqiuely to scale in
        }
    
       // Rest of code.
    }
    JCNinjaTrader Customer Service

    Comment


      #3
      Thank you for the suggestion but this will only use Avg.Price as the reference point. This will not work for me. I need to use the last entree as the reference point.

      Comment


        #4
        Hello relogical,

        That was just an example. If you would like to if you would like to store the the price of the last executed order then you may want to get the information from the OnExecution() method.

        Code:
        double lastTradedPrice;
        
        protected override void OnExecution(IExecution execution)
        {
                  // Condition to check to see if OnExecution is being called for your entry order and not an exit
                  // Note you will want to change this to your own logic as this is an example
                  if (entryOrder != null && entryOrder == execution.Order)
        	   {
                             lastTradedPrice = execution.Price;
                             // Now you can use the lastTradedPrice variable for your scale in orders
                    }
        }
        JCNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        65 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        149 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        162 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        99 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        286 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X