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

SetProfitTarget and Limit order

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

    SetProfitTarget and Limit order

    Is SetProfitTarget using a limit order?

    If I use the following code:

    SetProfitTarget("", CalculationMode.Ticks, 5, true);

    Is the 5 tick counted from "Close[0]" or the "Position.AveragePrice"?


    I tried using an explicit limit order to replace SetProfitTarget:

    if (BuySignal == true)
    {
    EnterLongLimit(Close[0], "T2");
    ExitLongLimit(Close[0] + (5.0 * TickSize), "T2");
    }

    Please refer to the attachment.

    The strategy was supposed to exit the long position after 5 tick. But it did not until it hit the stop loss.
    May I have some enlightenment on this?

    I think of that maybe the limit order with the same signal name has not been cancelled after the previous trade ended with a stop loss. May that be the case? How can I cancelled the exit limit order when the trade is hit by a stop loss?

    Thank you!
    Attached Files

    #2
    Hi alantse123, thanks for your question.

    SetProfitTarget uses the Position.AveragePrice property to calculate the stop.

    We have a full example on setting up manual protective orders here:
    https://ninjatrader.com/support/help...and_onexec.htm

    That will demonstrate how to set up the protective orders in "OCO" or Once cancels other.

    We also have an example here that demonstrates how to cancel an order:
    https://ninjatrader.com/support/help...thod_to_ca.htm

    Please let me know if I can assist any further.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChrisL View Post
      Hi alantse123, thanks for your question.

      SetProfitTarget uses the Position.AveragePrice property to calculate the stop.

      We have a full example on setting up manual protective orders here:
      https://ninjatrader.com/support/help...and_onexec.htm

      That will demonstrate how to set up the twc mail protective orders in "OCO" or Once cancels other.

      We also have an example here that demonstrates how to cancel an order:
      https://ninjatrader.com/support/help...thod_to_ca.htm

      Please let me know if I can assist any further.
      Thnks for the helpful links. I've been tangled in this scenario for about a week now. Finnally got the solutions. Hope this helps
      Last edited by jrjong; 07-08-2020, 08:49 PM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by kevinenergy, 02-17-2023, 12:42 PM
      116 responses
      2,757 views
      1 like
      Last Post kevinenergy  
      Started by franatas, 12-04-2023, 03:43 AM
      7 responses
      106 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by jpapa, Today, 07:22 AM
      0 responses
      1 view
      0 likes
      Last Post jpapa
      by jpapa
       
      Started by Jltarrau, Today, 05:57 AM
      3 responses
      7 views
      0 likes
      Last Post Jltarrau  
      Started by f.saeidi, Today, 05:56 AM
      2 responses
      8 views
      0 likes
      Last Post NinjaTrader_Erick  
      Working...
      X