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

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 bortz, 11-06-2023, 08:04 AM
                47 responses
                1,604 views
                0 likes
                Last Post aligator  
                Started by jaybedreamin, Today, 05:56 PM
                0 responses
                8 views
                0 likes
                Last Post jaybedreamin  
                Started by DJ888, 04-16-2024, 06:09 PM
                6 responses
                18 views
                0 likes
                Last Post DJ888
                by DJ888
                 
                Started by Jon17, Today, 04:33 PM
                0 responses
                4 views
                0 likes
                Last Post Jon17
                by Jon17
                 
                Started by Javierw.ok, Today, 04:12 PM
                0 responses
                13 views
                0 likes
                Last Post Javierw.ok  
                Working...
                X