![]() |
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
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Junior Member
Join Date: May 2012
Posts: 19
Thanks: 4
Thanked 1 time in 1 post
|
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. |
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
|
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); Code:
if (Close[0] + 10 * TickSize > Position.AvgPrice)
{
SetStopLoss(CalculationMode.Ticks, 0);
}
Joydeep M.
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Junior Member
Join Date: May 2012
Posts: 19
Thanks: 4
Thanked 1 time in 1 post
|
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? |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
|
Hello Andreano,
To assist you further may I know, have you set CalculateOnBarClose, to True or False. I look forward to assisting you further.
Joydeep M.
NinjaTrader Customer Service |
|
|
|
|
|
#5 |
|
Junior Member
Join Date: May 2012
Posts: 19
Thanks: 4
Thanked 1 time in 1 post
|
It is set to true.
|
|
|
|
|
|
#6 |
|
NinjaTrader Customer Service
Join Date: Dec 2011
Location: India
Posts: 3,286
Thanks: 580
Thanked 546 times in 541 posts
|
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
Joydeep M.
NinjaTrader Customer Service |
|
|
|
|
|
#7 |
|
Junior Member
Join Date: May 2012
Posts: 19
Thanks: 4
Thanked 1 time in 1 post
|
Thank you for your help.
|
|
|
|
|
The following user says thank you to Andreano for this post: |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |