• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 Wolf1, Today, 08:26 PM
                0 responses
                7 views
                0 likes
                Last Post Wolf1
                by Wolf1
                 
                Started by pparmley, Today, 04:30 PM
                0 responses
                9 views
                0 likes
                Last Post pparmley  
                Started by tonynt, Today, 04:21 PM
                0 responses
                4 views
                0 likes
                Last Post tonynt
                by tonynt
                 
                Started by williamzz, Today, 03:44 PM
                1 response
                12 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by Miguel_88, Yesterday, 06:41 PM
                2 responses
                26 views
                0 likes
                Last Post Miguel_88  
                Working...
                X