• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Question about breakeven

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • NinjaTrader_Jesse
    replied
    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.

    Leave a comment:


  • Kovalev
    replied
    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:


  • Kovalev
    replied
    Originally posted by NinjaTrader_JoshG View Post
    Kovalev,

    Close[0] will be the latest price.

    https://ninjatrader.com/support/help...nt7/?close.htm

    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.
    NinjaTrader_JoshG, but if i use CalculateOnBarClose = true; ?

    Leave a comment:


  • NinjaTrader_JoshG
    replied
    Kovalev,

    Close[0] will be the latest price.

    https://ninjatrader.com/support/help...nt7/?close.htm

    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
    replied
    Originally posted by NinjaTrader_JoshG View Post
    Hello Kovalev,
    Thanks for your post.

    Are you simply trying to find the current price of the instrument?
    Hello, NinjaTrader_JoshG, yes, and I also wanted to know - can I prescribe a condition for the movement of stop loss in "On execution"?

    Leave a comment:


  • NinjaTrader_JoshG
    replied
    Hello Kovalev,
    Thanks for your post.

    Are you simply trying to find the current price of the instrument?

    Leave a comment:


  • Kovalev
    started a topic Question about breakeven

    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 +

Latest Posts

Collapse

Topics Statistics Last Post
Started by Bouzayen, Yesterday, 08:31 PM
0 responses
14 views
0 likes
Last Post Bouzayen  
Started by IanC28, 03-27-2020, 10:20 AM
6 responses
30 views
0 likes
Last Post jim1234
by jim1234
 
Started by aramtrader, 04-01-2020, 03:05 PM
7 responses
40 views
0 likes
Last Post woodie1
by woodie1
 
Started by renehtx, Yesterday, 03:51 PM
2 responses
16 views
0 likes
Last Post renehtx
by renehtx
 
Started by eidog2020, Yesterday, 03:31 PM
0 responses
8 views
0 likes
Last Post eidog2020  
Working...
X