NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 01-20-2009, 01:47 PM   #1
maxpi
Senior Member
 
Join Date: Jun 2007
Posts: 151
Thanks: 0
Thanked 0 times in 0 posts
Default How to modify an order from a strategy?

I want to have an entry stop limit order working but it needs to have it's parameters altered as conditions change. How do I do that from the code in a strategy?

tu Max
maxpi is offline  
Reply With Quote
Old 01-20-2009, 01:56 PM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

To modify your order just call EnterLongStopLimit() or whichever method you were using again with your new parameters.
NinjaTrader_Josh is offline  
Reply With Quote
Old 01-20-2009, 05:22 PM   #3
maxpi
Senior Member
 
Join Date: Jun 2007
Posts: 151
Thanks: 0
Thanked 0 times in 0 posts
Default

I suspected that might do it, thanks much...
maxpi is offline  
Reply With Quote
Old 03-25-2009, 01:17 PM   #4
ninjaq
Junior Member
 
Join Date: Dec 2008
Posts: 26
Thanks: 0
Thanked 0 times in 0 posts
Default

I have this double entry problem where my strategy cancels the OLD limit order and
sends in a NEW one at the opening of the next bar.

I've able to produce this same bug few times.

What happened was the OLD limit order did NOT cancel on time when the NEW limit order was issue. If the price touch the OLD + NEW limit order prices quickly (fast market), it will result in BOTH the OLD + NEW limit order being filled.

Can I modify my existing LIMIT ORDER to prevent this from happening?

Thanks!
>Jim
ninjaq is offline  
Reply With Quote
Old 03-25-2009, 01:27 PM   #5
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

Jim,

As you call EnterLongLimit() again it should just modify any preexisting order. If your existing order was filled in that very instant that the order was making it across the internet to your brokerage then the scenario you are seeing is very possible.

What you want to do in these instances is to address the extra order and immediately cancel that when you notice such a case. To cancel an order you can use CancelOrder(). Also, prevention is key here too. Try using if (Position.MarketPosition == MarketPosition.Flat) to ensure you are flat at the time of order submission. This will not weed out all race conditions, but will help keep it rare.
NinjaTrader_Josh is offline  
Reply With Quote
Old 06-23-2010, 12:08 PM   #6
jdz1247
Junior Member
 
Join Date: Mar 2010
Posts: 4
Thanks: 0
Thanked 0 times in 0 posts
Default To Modify a Limit order

Quote:
Originally Posted by NinjaTrader_Josh View Post
To modify your order just call EnterLongStopLimit() or whichever method you were using again with your new parameters.
Hi Josh,
In my strategy, I have limit order and stop/profit target orders tied to it. see code:

entryLongOrder = EnterLongLimit(0, true, 1, entryPrice, "LongEntry");
SetStopLoss("LongEntry", CalculationMode.Ticks, stopOffset, false);
SetProfitTarget(
"LongEntry", CalculationMode.Ticks, profTargetOffset);

My question is, if I want to modify the limit price by recall EnterLongLimit(...) with a new entry price, do I need to do anything with the StopLoss and ProfTarget orders? (My guess is not, since I use the offset mode for these orders, unless I want change these offsets, Am I right?)

Regards,
JD
jdz1247 is offline  
Reply With Quote
Old 06-23-2010, 01:13 PM   #7
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

You are right. Changing the limit price for entry does not require changing your stop/targets.
NinjaTrader_Josh is offline  
Reply With Quote
Old 07-14-2010, 02:58 AM   #8
J_o_s
Senior Member
 
Join Date: Aug 2008
Location: Netherlands
Posts: 159
Thanks: 17
Thanked 5 times in 5 posts
Default

Nice thread.

I was wondering, is it possible (in a strategy) to change the entry and exit prices? For example, if I wanted to measure the efficiency of an trading strategy, I would like to compare it to the results of buying at the bottom and selling at the top. That way I can measure how much of the total move gets captured by the strategy, which in turn gives an indication of quality of the strategy.

But to arrive at the data of the total move (and all the moves in the time window), I need to code something as "if the move is over, the enter long price was the MIN(Low) value and the exit long was the MAX(high) value". Can I change the entry and exit prices afterwards? Perhaps there is a different way?

Can anyone give me some pointers for the creation of such a (non-tradeable) strategy?

Regards,
Last edited by J_o_s; 07-14-2010 at 03:02 AM. Reason: typo's, expanded
J_o_s is offline  
Reply With Quote
Old 07-14-2010, 07:32 AM   #9
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 106 times in 70 posts
Default

J_o_s,

Unfortunately you cannot change the entry/exit prices afterwards. What you can try to do is try creating your own fill algorithm and using that instead of the default ones supplied.

http://www.ninjatrader-support.com/H...FillTypes.html
NinjaTrader_Josh is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
B-LINE Indicator(modify) jake28787 Indicator Development 3 01-06-2009 10:23 AM
modify PriorDayOHLC Awash Indicator Development 20 12-07-2008 02:41 PM
Modify CurrentDayOHL dwalls NinjaScript File Sharing Discussion 1 11-28-2008 12:52 PM
How to modify and retest an ATM strategy cassb Strategy Analyzer 19 04-24-2008 02:14 PM
Manually modify ATM strategy rally7 ATM Strategies (Discretionary Trading) 6 03-31-2007 03:38 PM


All times are GMT -6. The time now is 06:27 PM.