Thanks!
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
SetProfitTarget and SetStopLoss - need event listeners?
Collapse
X
-
SetProfitTarget and SetStopLoss - need event listeners?
Hi, I've been working on a strategy for a few weeks now and I've made it this far with all the great posts and documentation, but today I have met my match! I need the ability to execute code when either my SetProfitTarget or SetStopLoss have been triggered. I've looked into methods such as OnOrderUpdate() and OnPositionUpdate() but SetProfitTarget and SetProfitTarget don't seem to work with iOrder...? Basically I need an eventListener that executes when the target or stop has been met. How can this be done
Thanks! -
Originally posted by 4dplane View PostHi, I've been working on a strategy for a few weeks now and I've made it this far with all the great posts and documentation, but today I have met my match! I need the ability to execute code when either my SetProfitTarget or SetStopLoss have been triggered. I've looked into methods such as OnOrderUpdate() and OnPositionUpdate() but SetProfitTarget and SetProfitTarget don't seem to work with iOrder...? Basically I need an eventListener that executes when the target or stop has been met. How can this be done
Thanks!
ref: http://www.ninjatrader.com/support/f...ead.php?t=5790
-
Thank you very much! Sorry I missed the list of sample code, I had seen it a few weeks back and did a search but overlooked it.
I ended up using this for my current control of ProfitTarget and StopLoss:
Code:protected override void OnOrderUpdate(IOrder order){ //If Profit Target was met------------------- if (order.OrderState == OrderState.Filled){ if(order.Name == "Profit target"){ Print(order.ToString()); } } //If stop loss was met----------------------- if (order.OrderState == OrderState.Filled){ if(order.Name == "Stop loss"){ Print(order.ToString()); } } }
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Perr0Grande, Yesterday, 08:16 PM
|
1 response
7 views
0 likes
|
Last Post Today, 07:22 AM | ||
Started by f.saeidi, Yesterday, 08:12 AM
|
3 responses
24 views
0 likes
|
Last Post Today, 07:18 AM | ||
Started by algospoke, Yesterday, 06:40 PM
|
1 response
14 views
0 likes
|
Last Post Today, 07:16 AM | ||
Started by quantismo, Yesterday, 05:13 PM
|
1 response
14 views
0 likes
|
Last Post Today, 07:12 AM | ||
Started by The_Sec, 04-16-2024, 02:29 PM
|
3 responses
16 views
0 likes
|
Last Post Today, 07:10 AM |
Comment