Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Working With SetProfitTarget
Collapse
X
-
Working With SetProfitTarget
I'm a newbie, so please excuse me if my question is trivial or has been answered many times in the past. Let's say that I want to enter two separate long trades using EnterLong(), both for the same instrument. The first one is associated with a SetProfitTarget() which is set in Initialize(). Both orders however are subject to a general exit condition which is computed in OnBarUpdate() each time for a new bar. If the exit condition is hit before the Profit Target is reached, then both trades are closed. If the Profit Target is reached first, then the first trade will be automatically closed, and the second one remains open until the general exit condition is met. My question is, when the general exit condition is met, if I don't know whether or not the first trade was closed due to the profit target being reached, I would not know whether or not I need to close that trade as well. How do I know whether or not the profit target was reached for the first trade, and that it is therefore no longer an active trade?Tags: None
-
Thank you, but if all goes well with the trade, one of the trades will close out due to the profit target being hit, but the second trade will still be active. When time comes to close that second trade, due to the general exit condition being met, would I do the wrong thing by trying to exit the first trade which has already been closed previously? If I would, then how do I know that that trade has already been closed, and that I should not be trying to close it again?
Comment
-
Hello ronharrow,
Thanks for your reply.
In addition to checking for a marketposition/direction you can also test for quantity: http://ninjatrader.com/support/helpG.../?quantity.htm
Most exit methods will ignore if a position does not exist.
Please review the helpguide on managed approach: http://ninjatrader.com/support/helpG...d_approach.htm
And then check the helpguide on each of the exit methods you are using: http://ninjatrader.com/support/helpG...er_methods.htmPaul H.NinjaTrader Customer Service
Comment
-
Originally posted by ronharrow View PostI'm a newbie, so please excuse me if my question is trivial or has been answered many times in the past. Let's say that I want to enter two separate long trades using EnterLong(), both for the same instrument. The first one is associated with a SetProfitTarget() which is set in Initialize(). Both orders however are subject to a general exit condition which is computed in OnBarUpdate() each time for a new bar. If the exit condition is hit before the Profit Target is reached, then both trades are closed. If the Profit Target is reached first, then the first trade will be automatically closed, and the second one remains open until the general exit condition is met. My question is, when the general exit condition is met, if I don't know whether or not the first trade was closed due to the profit target being reached, I would not know whether or not I need to close that trade as well. How do I know whether or not the profit target was reached for the first trade, and that it is therefore no longer an active trade?
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by bortz, 11-06-2023, 08:04 AM
|
47 responses
1,606 views
0 likes
|
Last Post
by aligator
Today, 07:22 PM
|
||
Started by jaybedreamin, Today, 05:56 PM
|
0 responses
9 views
0 likes
|
Last Post
by jaybedreamin
Today, 05:56 PM
|
||
Started by DJ888, 04-16-2024, 06:09 PM
|
6 responses
19 views
0 likes
|
Last Post
by DJ888
Today, 05:12 PM
|
||
Started by Jon17, Today, 04:33 PM
|
0 responses
6 views
0 likes
|
Last Post
by Jon17
Today, 04:33 PM
|
||
Started by Javierw.ok, Today, 04:12 PM
|
0 responses
15 views
0 likes
|
Last Post
by Javierw.ok
Today, 04:12 PM
|
Comment