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

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 Rapine Heihei, Today, 08:19 PM
1 response
6 views
0 likes
Last Post NinjaTrader_Manfred  
Started by Rapine Heihei, Today, 08:25 PM
0 responses
5 views
0 likes
Last Post Rapine Heihei  
Started by f.saeidi, Today, 08:01 PM
1 response
4 views
0 likes
Last Post NinjaTrader_Manfred  
Started by Rapine Heihei, Today, 07:51 PM
0 responses
6 views
0 likes
Last Post Rapine Heihei  
Started by frslvr, 04-11-2024, 07:26 AM
5 responses
98 views
1 like
Last Post caryc123  
Working...
X