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 > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 05-28-2012, 03:02 AM   #1
Andreano
Junior Member
 
Join Date: May 2012
Posts: 19
Thanks: 4
Thanked 1 time in 1 post
Default Price Alert

I have a task: I need to modify stop order based on Price alert.
As soon as current market price reaches predefined price - modify stop order.
What are the ways to do that?
So far I can see that I would have to connect to tick price data and check tick by tick if necessary price has been reached.

I tried to find something in API which would allow to set up alert and then some callback that would be called on alert - but did not found .
Is there any other built-in ways to do that?

I can see PriceAlert indicator - but it would create alert for alert window, where I need to call some method of Strategy, that would modify stop order.

I am new to NinjaTrader, did try to search this topic through search forum, but found no results, that will answer my question.
I will appreciate any help.
Andreano is offline  
Reply With Quote
Old 05-28-2012, 04:10 AM   #2
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello Andreano,
Welcome to the forum and I am happy to assist you.

In managed order simply reassign the Set method again to change the stop price.

For example if your initial stop is
Code:
SetStopLoss(CalculationMode.Ticks, 10);
and you want to change the stop to breakeven when price reaches 10 ticks above your entry price then just reassign the Set method again.

Code:
if (Close[0] + 10 * TickSize > Position.AvgPrice)
{
	SetStopLoss(CalculationMode.Ticks, 0);
}
Please let me know if I can assist you any further.
NinjaTrader_Joydeep is offline  
Reply With Quote
Old 05-29-2012, 01:50 AM   #3
Andreano
Junior Member
 
Join Date: May 2012
Posts: 19
Thanks: 4
Thanked 1 time in 1 post
Default

Thank you for your quick answer.
I think I did not convey my question properly. My bad. My question wasn't about: How to modify order? - you have a pretty good documentation on this BTW - It was about how to set up price alert.
For example, on start strategy enters some position, sets up some stop (or limit order) and decides (based on some formula), that when price reaches X, I need to modify this order .
The thing here is that I need to modify order as soon as price is reached, I don't want to wait until some of my bars are closed.
So my question what would be the ways to organize such price alert?
Should I add 1 tick time-frame and check price with each new tick manually or there are more convenient ways to do that?
Andreano is offline  
Reply With Quote
Old 05-29-2012, 04:00 AM   #4
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello Andreano,
To assist you further may I know, have you set CalculateOnBarClose, to True or False.

I look forward to assisting you further.
NinjaTrader_Joydeep is offline  
Reply With Quote
Old 05-29-2012, 08:05 AM   #5
Andreano
Junior Member
 
Join Date: May 2012
Posts: 19
Thanks: 4
Thanked 1 time in 1 post
Default

It is set to true.
Andreano is offline  
Reply With Quote
Old 05-29-2012, 08:10 AM   #6
NinjaTrader_Joydeep
NinjaTrader Customer Service
 
NinjaTrader_Joydeep's Avatar
 
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
Default

Hello Andreano,
Thanks for the confirmation.

You can use the OnMarketData event to check for the current price and set any alert there and modify your exit orders.

Please refer here to know more about OnMarketData.
http://www.ninjatrader.com/support/h...marketdata.htm
NinjaTrader_Joydeep is offline  
Reply With Quote
Old 05-29-2012, 08:30 AM   #7
Andreano
Junior Member
 
Join Date: May 2012
Posts: 19
Thanks: 4
Thanked 1 time in 1 post
Default

Thank you for your help.
Andreano is offline  
Reply With Quote
The following user says thank you to Andreano for this post:
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
Price Alert carlton General Programming 3 06-28-2011 09:51 AM
Price Alert question using a floating price line es500 General Programming 10 04-17-2011 04:40 PM
Price Alert RatioTrader Charting 2 11-15-2009 11:25 AM
price alert Christoph Indicator Development 1 09-22-2009 08:20 AM
price alert - audio alert - not functioning well diage4 Market Analyzer 3 12-29-2008 10:24 AM


All times are GMT -6. The time now is 09:20 AM.