Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

order cancellation message

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

    #16
    Hi brucelevy,

    I'm jumping back to post #11.

    If you are getting prints then this means your code is cancelling the order.

    Are you wanting to exit the trade when LinReg(14) crosses below the KAMA(2, 10, 30), 1)?
    (I cannot answer if this is right or wrong, this depends on what you want the script to do which I cannot answer).

    Are you finding that the trade is exited before the print appears in the output window?

    Also, a buy limit order must be above the current ask price.
    A buy stop or stop limit must be below the current ask price.

    A sell limit order must be below the current bid price.
    A sell stop or stop limit must be above the current ask price.

    May I confirm that if you are using a buy limit order that this is above the ask price?
    (For more information about why these orders must be above or below the market price please contact your broker)
    Chelsea B.NinjaTrader Customer Service

    Comment


      #17
      I am just using SetStopLoss

      Comment


        #18
        Hello brucelevy,

        May I confirm for your SetStopLoss that you have checked the price you are setting the stop loss to and that this is above the current ask price?

        double myPrice = 0;

        (myPrice would then be set to some calculated price)

        if (myPrice >= GetCurrentAsk())
        {
        SetStopLoss(CalculationMode.Price, myPrice);
        }

        May I confirm that you are checking this price is a valid and acceptable price before you are placing the order?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #19
          Can you give an example of myPrice being referenced to the entryprice

          Comment


            #20
            Hello brucelevy,

            When using SetStopLoss its best to place the stop loss before placing the entry order. You can always modify it later.

            Lets say that I want my stop loss to be 10 ticks below my entry.

            private double myPrice = 0;
            private IOrder myEntry;

            if (/*conditions to enter here*/true)
            {
            myPrice = Close[0]-10*TickSize;
            if (myPrice >= GetCurrentAsk())
            {
            SetStopLoss(CalculationMode.Price, myPrice);
            myEntry = EnterShort();
            }

            In OnExecution():
            if (execution.Order == myEntry)
            {
            myPrice = myEntry.AvgFillPrice-10*TickSize;
            if (myPrice >= GetCurrentAsk())
            {
            SetStopLoss(CalculationMode.Price, myPrice);
            }
            }
            Chelsea B.NinjaTrader Customer Service

            Comment


              #21
              Is there a simpler way to program this without getting into IOrder methods which I don't understand

              Comment


                #22
                Hi brucelevy,

                Without using IOrders:

                Code:
                In #region Variables
                private double myPrice = 0;
                private IOrder myEntry;
                
                In OnBarUpdate:
                if (/*conditions to enter here*/ true)
                {
                myPrice = Close[0] - 10 * TickSize;
                if (myPrice >= GetCurrentAsk())
                {
                SetStopLoss(CalculationMode.Price, myPrice);
                EnterShort("entryOrder");
                }
                }
                
                In OnExecution:
                if (execution.Name == "entryOrder")
                {
                myPrice = myEntry.AvgFillPrice - 10 * TickSize;
                if (myPrice >= GetCurrentAsk())
                {
                SetStopLoss(CalculationMode.Price, myPrice);
                }
                }
                }
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

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