• 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

Help with trailing stop in script

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

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

    Leave a comment:


  • hchandrashe
    started a topic Help with trailing stop in script

    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

Latest Posts

Collapse

Topics Statistics Last Post
Started by Aporshnev, Today, 01:47 AM
0 responses
5 views
0 likes
Last Post Aporshnev  
Started by caveat_lector, Today, 12:12 AM
1 response
6 views
0 likes
Last Post Atm Card  
Started by ksarin, Yesterday, 04:31 PM
2 responses
9 views
0 likes
Last Post Atm Card  
Started by pharofx, Yesterday, 09:30 PM
1 response
19 views
0 likes
Last Post Atm Card  
Started by swcooke, Yesterday, 08:39 PM
1 response
9 views
0 likes
Last Post Atm Card  
Working...
X