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 DawnTreader, 05-08-2024, 05:58 PM
                52 responses
                308 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by grazz, 07-28-2017, 06:11 PM
                27 responses
                6,848 views
                0 likes
                Last Post NinjaTrader_ChristopherJ  
                Started by frslvr, Today, 11:36 AM
                4 responses
                14 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by tkaboris, 07-15-2024, 01:42 PM
                13 responses
                25 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by richard_w, Today, 12:33 PM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Working...
                X