Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem placing the stop order after entering the market

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

    Problem placing the stop order after entering the market

    Hi

    i have a problem with my stop and limit order in term of "timing"

    i script is running on 5 minutes, when my script buy, normally it send a stop order and a limit order... but it send the order on the next 5 minutes after the buy order.

    for example, at 10h05 my script buy but it send the stop and limit order at 10h10... so i have 5 minutes without stop on the market

    Please, help me to fix this problem, i would like than my stop and limit order is send when the buying order is filled.

    here my script of the order

    if (Positions[0].MarketPosition==MarketPosition.Flat)
    {
    Stop = Low[
    0] - 3*TickSize;
    Stop1 = Low[
    0]- 3*TickSize;
    TP = Close[
    0]+(Close[0]-Stop);
    tp1hit=
    false;
    tp2hit=
    false;
    }

    }
    }
    }

    if (Positions[0].MarketPosition!=MarketPosition.Flat)
    {




    if (Positions[0].MarketPosition==MarketPosition.Long)
    {
    if (High[0]>=TP)
    {
    if (!tp1hit)
    {
    TP=Positions[
    0].AvgPrice+(Positions[0].AvgPrice-Stop1)*1.50;
    tp1hit=
    true;
    Stop=Low[CurrentBar-barNumberOfOrder];
    }
    elseif (!tp2hit)
    {
    TP=Positions[
    0].AvgPrice+(Positions[0].AvgPrice-Stop1)*2;
    tp2hit=
    true;
    Stop=Positions[
    0].AvgPrice+2*TickSize;
    }


    }

    ExitLongLimit(Positions[
    0].AvgPrice+(Positions[0].AvgPrice-Stop1)*2,"Long Profit", "Entry Long");
    }

    ExitLongStop(Stop,
    "Long Stop", "Entry Long");

    }

    #2
    Thomas, I would recommend then you place those protective orders in OnExecution() upon fill confirmation of your entry : http://www.ninjatrader.com/support/f...ead.php?t=7499

    Comment


      #3
      ok i change it with the OnExecution like that (above all the end of the script), when my order is filled i have my stop loss but after 5 minutes my stop loss is cancelled !

      if (Positions[0].MarketPosition==MarketPosition.Short)
      {
      if (Low[0]<=TP)
      {
      if (!tp1hit)
      {
      TP=Positions[
      0].AvgPrice-(Stop1-Positions[0].AvgPrice)*1.45;
      tp1hit=
      true;
      Stop=High[CurrentBar-barNumberOfOrder];
      }
      elseif (!tp2hit)
      {
      TP=Positions[
      0].AvgPrice-(Stop1-Positions[0].AvgPrice)*2;
      tp2hit=
      true;
      Stop=Positions[
      0].AvgPrice-2*TickSize;

      ExitShortLimit(Positions[
      0].AvgPrice-(Stop1-Positions[0].AvgPrice)*2,"Short Profit", "Entry Short");
      }

      protectedoverridevoid OnExecution(IExecution execution)
      {

      if (myEntryOrder != null && myEntryOrder == execution.Order)
      {

      ExitShortStop(Stop,
      "Short Stop", "Entry Short");

      Comment


        #4
        Hi Thomas, do you run then still on a 5 minute chart? In order to have the order not expire on the next bar, please set it to liveUntilCancelled then : http://www.ninjatrader.com/support/h...tshortstop.htm

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        648 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        369 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        108 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        572 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        573 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X