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!
See more
See less

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.
    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by jjs12, Today, 10:29 AM
    0 responses
    2 views
    0 likes
    Last Post jjs12
    by jjs12
     
    Started by lakman184, 03-24-2024, 01:30 PM
    5 responses
    27 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by thumper57, 05-11-2024, 04:30 PM
    16 responses
    44 views
    0 likes
    Last Post thumper57  
    Started by Salahinho99, 05-05-2024, 04:13 AM
    10 responses
    70 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by lorem, 04-25-2024, 09:18 AM
    13 responses
    56 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Working...
    X