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
Question about breakeven
Collapse
X
-
Hello Kovalev,
Yes, Close[0] would be the last close price when using CalculateOnBarClose = true. The building bar is not being accounted for when using CalculateOnBarClose = true.
It is generally suggested to use the average fill price rather than the close as that is absolute once the order fills where as the close may be different than the end fill price. We have a sample that demonstrates using the fill price to submit targets here: https://ninjatrader.com/support/help...and_onexec.htm
I look forward to being of further assistance.
- Likes 1
-
Or perhaps another option is to calculate relative to the entry point
if (Position.MarketPosition == MarketPosition.Long && execution.Order.AvgFillPrice + 9 * TickSize)
Leave a comment:
-
Originally posted by NinjaTrader_JoshG View PostKovalev,
Close[0] will be the latest price.
You can also include a condition for your stop loss movement inside OnExecution. Whether that is the best place to use that logic will depend on your specific condition.
Leave a comment:
-
Kovalev,
Close[0] will be the latest price.
You can also include a condition for your stop loss movement inside OnExecution. Whether that is the best place to use that logic will depend on your specific condition.
- Likes 1
Leave a comment:
-
Originally posted by NinjaTrader_JoshG View PostHello Kovalev,
Thanks for your post.
Are you simply trying to find the current price of the instrument?
Leave a comment:
-
Hello Kovalev,
Thanks for your post.
Are you simply trying to find the current price of the instrument?
- Likes 1
Leave a comment:
-
Question about breakeven
Hello, please help me, I want to add a breakeven function if the price has passed a certain number of ticks
Stops and takest I did that way
protected override void OnExecution(IExecution execution)
{
/* We advise monitoring OnExecution to trigger submission of stop/target orders instead of OnOrderUpdate() since OnExecution() is called after OnOrderUpdate()
which ensures your strategy has received the execution which is used for internal signal tracking. */
if (entryOrder != null && entryOrder == execution.Order)
{
if (Position.MarketPosition == MarketPosition.Long)
{
// Stop-Loss order ticks below our entry price
stopOrder = ExitLongStop(0, true, execution.Order.Filled, execution.Order.AvgFillPrice - 4 * TickSize, "MyLongStop", "Long");
// Target order ticks above our entry price
targetOrder = ExitLongLimit(0, true, execution.Order.Filled, execution.Order.AvgFillPrice + 8 * TickSize, "MyTarget", "Long");
// Resets the entryOrder object to null after the order has been filled
if (execution.Order.OrderState != OrderState.PartFilled)
{
entryOrder = null;
}
}
if (Position.MarketPosition == MarketPosition.Short)
{
// Stop-Loss order ticks below our entry price
stopOrder = ExitShortStop(0, true, execution.Order.Filled, execution.Order.AvgFillPrice + 4 * TickSize, "MyShortStop", "Short");
// Target order ticks above our entry price
targetOrder = ExitShortLimit(0, true, execution.Order.Filled, execution.Order.AvgFillPrice - 8 * TickSize, "MyTarget", "Short");
// Resets the entryOrder object to null after the order has been filled
if (execution.Order.OrderState != OrderState.PartFilled)
{
entryOrder = null;
}
}
}
But I do not know how to call the current price to calculate the required number of ticks to move the stop to +Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by dustydbayer, Today, 01:59 AM
|
0 responses
1 view
0 likes
|
Last Post
by dustydbayer
Today, 01:59 AM
|
||
Started by inanazsocial, Today, 01:15 AM
|
0 responses
2 views
0 likes
|
Last Post
by inanazsocial
Today, 01:15 AM
|
||
Started by trilliantrader, 04-18-2024, 08:16 AM
|
5 responses
22 views
0 likes
|
Last Post Today, 12:32 AM | ||
Started by Davidtowleii, Today, 12:15 AM
|
0 responses
3 views
0 likes
|
Last Post
by Davidtowleii
Today, 12:15 AM
|
||
Started by guillembm, Yesterday, 11:25 AM
|
2 responses
10 views
0 likes
|
Last Post
by guillembm
Yesterday, 11:58 PM
|
Leave a comment: