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 CortexZenUSA, Today, 12:53 AM
        0 responses
        1 view
        0 likes
        Last Post CortexZenUSA  
        Started by CortexZenUSA, Today, 12:46 AM
        0 responses
        1 view
        0 likes
        Last Post CortexZenUSA  
        Started by usazencortex, Today, 12:43 AM
        0 responses
        5 views
        0 likes
        Last Post usazencortex  
        Started by sidlercom80, 10-28-2023, 08:49 AM
        168 responses
        2,266 views
        0 likes
        Last Post sidlercom80  
        Started by Barry Milan, Yesterday, 10:35 PM
        3 responses
        13 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X