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

SL+TP using Unmanaged Approach

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

    SL+TP using Unmanaged Approach

    Hello

    1. Can you please give an example of the unmanaged approach for entering a market long position with a SL and TP.

    In the managed approach it would look something like that:

    private void EnterMarketLong(double SL, double TP)
    {
    SetStopLoss(CalculationMode.Price, SL);
    SetProfitTarget(CalculationMode.Price, TP);
    EnterLong("MyLongPosition");
    }

    2. Is there a way to automatically cancel the SL and TP orders when I disable my strategy (but keeping my long position running).

    Thanks
    Last edited by kiss987; 08-17-2017, 02:47 PM.

    #2
    Hello kiss987,

    Thanks for opening the thread.

    Here is a copy of our Unmanaged Template strategy that you can use as an example for writing a strategy that uses bracketed orders for entry as well as profit targets and stop losses for long and short positions.

    If you have any questions on the sample code, please don't hesitate to ask.
    Attached Files
    JimNinjaTrader Customer Service

    Comment


      #3
      Is there a way to automatically cancel the SL and TP orders when I disable my strategy but keeping my long position running, the same way it's working in the managed approach?

      Thanks

      Comment


        #4
        Hello kiss987,

        Thanks for your question.

        The Order handling rules in the Strategies\NinjaScript tabs of the Options menu will define the behavior for cancelling exit orders when you disable the strategy.

        I added some null checks to aid in resuming a position so an IOrder can be resumed if it already exists, the modified script is attached.

        Strategies tab - https://ninjatrader.com/support/help...tegies_tab.htm

        I look forward to being of further assistance.
        Attached Files
        Last edited by NinjaTrader_Jim; 08-23-2017, 09:58 AM.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by tkaboris, Today, 08:01 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by Lumbeezl, 01-11-2022, 06:50 PM
        31 responses
        817 views
        1 like
        Last Post NinjaTrader_Adrian  
        Started by xiinteractive, 04-09-2024, 08:08 AM
        5 responses
        15 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by swestendorf, Today, 11:14 AM
        2 responses
        6 views
        0 likes
        Last Post NinjaTrader_Kimberly  
        Started by Mupulen, Today, 11:26 AM
        0 responses
        7 views
        0 likes
        Last Post Mupulen
        by Mupulen
         
        Working...
        X