Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnExecution Stops

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

    OnExecution Stops

    I have a strategy based on the OnExecution reference sample and when I change the stop order to a trailing stop in the OnBarUpdate section it leaves me with 2 stops (the original stop and the trail stop). In an effort to fix this do I just name the stop the same name in each section or how is the best way to fix this? Basically I want to ammend the OnExecution stop order to the OnBarUpdate stop price after a certain amount of profit is gained.

    Code:
    protected override void OnBarUpdate()
    {
    stopOrder = ExitLongStop(0, true, 1, Math.Min(myLongStop,GetCurrentBid(0)), "[B]myLongTrailStop[/B]", "myLongEntry");
    }
    
    protected override void OnExecution(IExecution execution)
          {
           if(Position.MarketPosition==MarketPosition.Long)
                {
                stopOrder = ExitLongStop(0, true, execution.Order.Filled, execution.Order.AvgFillPrice - (20*TickSize), "[B]myLongTrailStop"[/B], "myLongEntry");
                }
          }
    Thank you for the help!

    GT

    #2
    Hi GT, for the correct order tracking I'd suggest to work with IOrder objects - http://www.ninjatrader-support.com/H...V6/IOrder.html

    Basically you want then to submit your order in the OnExecution and modify the trailprice in the OnBarUpdate() as the trade progresses.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by sjsj2732, Yesterday, 04:31 AM
    0 responses
    38 views
    0 likes
    Last Post sjsj2732  
    Started by NullPointStrategies, 03-13-2026, 05:17 AM
    0 responses
    287 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    289 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    134 views
    1 like
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    95 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Working...
    X