Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help with trailing stop in script

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

    Help with trailing stop in script

    Hello,

    I have a simple strategy with 1 position for all entries. I find that the trailing stop doesn't work some times in live sim. Appreciate any help.


    protected override void OnStateChange()
    {
    if (State == State.Configure)
    {
    SetTrailStop(CalculationMode.Ticks, 30);
    }
    }

    protected override void OnBarUpdate()
    {
    if (CurrentBars[0] < 1)
    return;

    if <Longcondition>
    {
    EnterLong(Convert.ToInt32(DefaultQuantity), @"GoLong ");
    }


    if <Shortcondition>
    {
    EnterShort(Convert.ToInt32(DefaultQuantity), @"GoShort");
    }
    }



    Basically, if a long or short condition is met, an order is placed with a trail stop. The order gets stopped either by a trailing stop or until opposite condition is met, in which case an order is placed in the opposite direction with a trailing again (whichever occurs first).

    This works perfectly fine in Strategy Analyzer.

    But, in live sim, I find that the trailing stop doesn't work for some orders and the trade goes on until opposite condition is met and trade gets placed in opposite direction. Any idea how I could resolve this?

    Thanks

    #2
    Hello hchandrashe,

    Thanks for your post.

    What datafeed are you connected to?

    What instruments have you observed this on?

    What Calculate mode are you using (OnBarClose, OnPriceChange, OnEachTick)?

    Have you observed any error messages (either pop-up or appearing in the "log" tab of the control center when this occurs)?

    Please send your log and trace files in and advise what dates the trail stop did not function when testing in live sim. Send the email to PlatformSupport[at]NinjaTrader[dot]Com. Mark the email Atten:Paul and include a link to this thread.

    Follow the steps below to manually attach your log and trace files to your e-mail so I may investigate this matter further.

    Open your NinjaTrader folder under My Documents.
    Right click on the 'log' and 'trace' folders and select Send To> Compressed (zipped) Folder.
    Send the 2 compressed folders as attachments to the email.
    Once complete, you can delete these compressed folders.
    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by FishTrade, Today, 12:00 AM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by chingus, Yesterday, 10:36 PM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_ChrisSch  
    Started by i2w8am9ii2, Yesterday, 06:29 PM
    2 responses
    8 views
    0 likes
    Last Post i2w8am9ii2  
    Started by Kirk Thorns, Yesterday, 05:34 PM
    0 responses
    10 views
    0 likes
    Last Post Kirk Thorns  
    Started by JobDjassem, Yesterday, 05:24 PM
    0 responses
    16 views
    0 likes
    Last Post JobDjassem  
    Working...
    X