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 PhillT, Today, 02:16 PM
                2 responses
                6 views
                0 likes
                Last Post PhillT
                by PhillT
                 
                Started by Kaledus, Today, 01:29 PM
                3 responses
                10 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by frankthearm, Yesterday, 09:08 AM
                14 responses
                47 views
                0 likes
                Last Post NinjaTrader_Clayton  
                Started by gentlebenthebear, Today, 01:30 AM
                2 responses
                14 views
                0 likes
                Last Post gentlebenthebear  
                Started by PaulMohn, Today, 12:36 PM
                2 responses
                17 views
                0 likes
                Last Post PaulMohn  
                Working...
                X