NexusFi: Find Your Edge


Home Menu

 





Help with adjusting target orders to stay so many ticks above entire position average


Discussion in NinjaTrader

Updated
    1. trending_up 3,668 views
    2. thumb_up 2 thanks given
    3. group 1 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
 
richw's Avatar
 richw 
Salt Lake City, UT
Legendary Market Wizard in Training
 
Experience: Advanced
Platform: NinjaTrader
Broker: NinjaTrader Brokerage
Trading: CL, ES, NQ, YM
Posts: 1,917 since May 2010
Thanks Given: 2,318
Thanks Received: 1,621

Having found the following code and using it as my guide for learning and developing:



How would one keep the profit target orders adjusted to be so many ticks above or below (whether long or short) the entire position average? I am having trouble finding information on this.

Currently, I am only working on the strategy to take long positions, not short or both, at present.


Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Six Days to Kickoff: World Cup Prediction Markets Hit $1 …
Prediction Markets & Event Contracts
Would a node-based workflow for automated trading be useful?
Traders Hideout
Weekend Update: First Qatari LNG Transit Attempted -- IR …
Traders Hideout
The June 15 Resolution Trap: Irans Agreed Text Still Pri …
Prediction Markets & Event Contracts
CFTC Opens First COT Report Review in 20 Years -- Asks W …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
8 thanks
Darmok and Jalad at Tanagra
1 thanks
  #3 (permalink)
 
richw's Avatar
 richw 
Salt Lake City, UT
Legendary Market Wizard in Training
 
Experience: Advanced
Platform: NinjaTrader
Broker: NinjaTrader Brokerage
Trading: CL, ES, NQ, YM
Posts: 1,917 since May 2010
Thanks Given: 2,318
Thanks Received: 1,621


keeping them so many ticks away from the entire position average.


Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #4 (permalink)
 Luger 
Nashville, TN
 
Experience: Intermediate
Platform: NinjaTrader
Broker: IB
Trading: NQ ES
Posts: 468 since Feb 2011
Thanks Given: 323
Thanks Received: 545

I'm thinking that I would do it in the OnOrderUpdate section.

Suppose you are on your second entry from whatever signal.... In the on order update section have it check for all of your Entry order names and whenever one is filled, have it cancel your prior ExitLimit target and when the cancellation is confirmed place a new one with the new AveragePrice + target amount. Here is a sample of what I am talking about.

 
Code
        private IOrder EntryOrder = null;
        private IOrder Target = null;

        protected override void OnBarUpdate()
        {        
         Condition...
            EntryOrder = EnterLong(...)
        }
        
        protected override void OnOrderUpdate(IOrder order)
        {
            if (EntryOrder != null && EntryOrder == order)
            {
              if (order.OrderState == OrderState.Filled)
                {
                  if (Target != null)
                    {
                     CancelOrder(Target);
                     EntryOrder = null;
                    }
                }    
            }
            if (Target != null && Target == order)    
            {
              if (order.OrderState == OrderState.Cancelled && Position.MarketPosition != MarketPosition.Flat)
                {
                    Target = ExitLongLimit(0, true,CalculationMode.Price, Position.AvgPrice + TickTarget);
                }    
            }
            if (Target != null && Target == order)    
            {
              if (order.OrderState == OrderState.Filled && Position.MarketPosition == MarketPosition.Flat)
                {
                    Target = null;
                }    
            }    
        }


Reply With Quote
Thanked by:




Last Updated on February 22, 2011


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts