Currently, I am using the percentage mode to set the profit target.
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
Call profit target in OnBarUpdate()?
Collapse
X
-
Call profit target in OnBarUpdate()?
I am working on a strategy and I would like to submit a sell order only if the current price of the instrument is above the target price. I don't want to issue a sell order as soon as the price reaches the profit target, I want to use a crossover to trigger a sell order IF the current price is above the Profit Target price.
Currently, I am using the percentage mode to set the profit target.Tags: None
-
Hello herbnderby,
Thank you for your post.
I'd recommend using an exit order in lieu of a profit target in that case. You can set a condition to say if the current price is above whatever price you've determined as the profit target price, then submit a market order to exit. If you're using SetProfitTarget, that would execute when the order price is hit.
Please let us know if we may be of further assistance to you.Kate W.NinjaTrader Customer Service
-
Hello Kate,
Thank you for the quick response.
Is there a way I can set the profit target price as a function of the entry price? Like, ProfitTargetPrice = 1.08 * entryPrice
Thank you
Comment
-
Hello herbnderby,
Thank you for your reply.
Sure, you could certainly do that, you'd just want to then use that ProfitTargetPrice variable in your condition for entry to compare against the current close to see if the close price has exceeded it.
Please let us know if we may be of further assistance to you.Kate W.NinjaTrader Customer Service
Comment
-
Can you elaborate a bit further? What does the code look like to call the entry price of a strategy?
Comment
-
Hello herbnderby,
Thank you for your reply.
You can get the average entry price for the position by using Position.AveragePrice.
So you could do something like this (we're assuming you're in a long position here):
Code:double ProfitTargetPrice = 1.08 * Position.AveragePrice; if(Close[0] > ProfitTargetPrice) { ExitLong(); }
Kate W.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by sidlercom80, 10-28-2023, 08:49 AM
|
172 responses
2,279 views
0 likes
|
Last Post
by sidlercom80
Today, 04:40 AM
|
||
Started by Irukandji, Yesterday, 02:53 AM
|
2 responses
17 views
0 likes
|
Last Post
by Irukandji
Today, 03:55 AM
|
||
Started by adeelshahzad, Today, 03:54 AM
|
0 responses
4 views
0 likes
|
Last Post
by adeelshahzad
Today, 03:54 AM
|
||
Started by Barry Milan, Yesterday, 10:35 PM
|
3 responses
13 views
0 likes
|
Last Post Yesterday, 11:58 PM | ||
Started by WeyldFalcon, 12-10-2020, 06:48 PM
|
14 responses
1,430 views
0 likes
|
Last Post
by Handclap0241
Yesterday, 10:43 PM
|
Comment