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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        592 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        343 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
        556 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        554 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X