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,192 views
    2. thumb_up 2 thanks given
    3. group 1 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

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

  #1 (permalink)
 
richw's Avatar
 richw 
Salt Lake City, UT
 
Experience: Advanced
Platform: NinjaTrader
Broker: NinjaTrader Brokerage
Trading: CL, ES, NQ, YM
Posts: 1,809 since May 2010
Thanks Given: 2,246
Thanks Received: 1,541

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?
NexusFi Journal Challenge - May 2024
Feedback and Announcements
REcommedations for programming help
Sierra Chart
Better Renko Gaps
The Elite Circle
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
Trade idea based off three indicators.
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
48 thanks
Just another trading journal: PA, Wyckoff & Trends
34 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
  #3 (permalink)
 
richw's Avatar
 richw 
Salt Lake City, UT
 
Experience: Advanced
Platform: NinjaTrader
Broker: NinjaTrader Brokerage
Trading: CL, ES, NQ, YM
Posts: 1,809 since May 2010
Thanks Given: 2,246
Thanks Received: 1,541


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: 543

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


© 2024 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 - Privacy Policy - Downloads - Top
no new posts