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

managing stops and profit targets

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

    managing stops and profit targets

    I am trying to define IOrder objects to manage stop loss and profit target orders. The problem is, NT does not accept myShortProfitTargetOrder (below) since EntriesPerdirection equals 1 (as trace order says).
    How can i define profit target orders in that case?

    // variables......
    private IOrder myLongStopOrder = null;
    private IOrder myLongProfitTargetOrder = null;
    private IOrder myShortStopOrder = null;
    private IOrder myShortProfitTargetOrder = null;



    protected override void OnExecution(IExecution execution)
    {

    if (execution.Order != null && (execution.Name == "InRangeSYV"))
    {
    priceShort = execution.Price;
    myShortStopOrder = ExitShortStopLimit(0,true,positionTaken,((priceSho rt*(1+StopLevelMovel))+(1 * TickSize)),(priceShort*(1+StopLevelMovel)), "Stop loss short","InRangeSYV");
    myShortProfitTargetOrder = EnterLongLimit(positionTaken,(priceShort/(1+stopGainNumber)), "Profit target short");
    }

    #2
    Hello dafonseca,

    Thank you for your post.

    You are not being prevented due to EntriesPerDirection, you are being prevented from placing the order as it is an entry order to go long and yet you already have an exit order (the myShortStopOrder) that would be for the same direction (long to close the short).

    I suspect you meant to set the myShortProfitTargetOrder to ExitShortLimit() instead.
    However, if you intention is to reverse at the profit target you are not going to be able to do that with the ExitShortStopLimit() in place as well. You would need to wait for your limit price to be hit (instead of submitting a limit order) and then submit an ExitShort() and then an EnterLong().

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by itrader46, Today, 10:22 AM
    0 responses
    8 views
    0 likes
    Last Post itrader46  
    Started by NM_eFe, Today, 10:13 AM
    0 responses
    2 views
    0 likes
    Last Post NM_eFe
    by NM_eFe
     
    Started by hdge4u, Yesterday, 12:23 PM
    1 response
    10 views
    0 likes
    Last Post hdge4u
    by hdge4u
     
    Started by 1001111, Today, 09:45 AM
    0 responses
    10 views
    0 likes
    Last Post 1001111
    by 1001111
     
    Started by DTSSTS, 01-28-2024, 12:07 PM
    11 responses
    558 views
    0 likes
    Last Post bmo111
    by bmo111
     
    Working...
    X