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

EnterShortLimit execution problem.

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

    EnterShortLimit execution problem.

    Dear Sir or Madam,

    I made a strategy that define for me some entry points to enter a Long limit/Short limit as attached to the file. The dots are the entry points. that will be if the market returns back.

    What I wish to do, is when the bar under the characteristic of my strategy is defined. I want to put a buy limit just 2 ticks far from it's limit. and wait until the market returns and break the point. the issue is that the platform gave me error message and shut down my strategy saying
    "Limit price can't be greater than current ask buy"

    I am sharing below the action in my strategy:

    {
    DrawDot("My dot" + CurrentBar, false, 0, Low[0] -(1 * TickSize), Color.LimeGreen);
    myShortEntryOrder= EnterShortLimit(0, true, DefaultQuantity , Low[0] - (2 * TickSize), "My Short");
    }


    Please, Can you help me to understand my mistake.
    Thank you in advance.
    Attached Files

    #2
    Hello Yassine, and thank you for your question.

    Since you are entering on the short side of the market, you will need to to place a stop limit order to enter 2 ticks below the lowest price for the current bar. I am including some links to the help guide documentation for more information.




    Please let us know if there are any other ways we can help.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Hi Jessica
      Thank you for trying to answer my question.

      I consulted already the guide several times, look in support forum and other websites for the same issues threats, no one has similar. I don't understand the error as well.

      the reason still unclear.. or I believe I didn't explain it very well.
      I want to place an entry buy limit on the red dots. and sell limit on the green dots, and wait for the market to reach the level where the dots are. manually it works fine. you open a long limit and you wait for the market to reach the level and trigger the position and than hits SL or PT.
      in Automated system is did not work. it gives this error I shared first.

      by the way, I believe you miss understand the picture. The lime green dot are sell signals and vs-versa. Sorry for the opposite color description.

      Comment


        #4
        Hello again Yassine,

        I believe the misunderstanding may have been mine. I was reviewing your code, and in your code, you are entering the market with sell orders, not buy orders. From your description, you would like to enter the market with buy orders and not sell orders.

        I would like to ask, then, could you provide a plain language description of what you would like to accomplish? I'll provide a format to make it clear what I am asking for.

        The opening price is 100.00
        The high price is 102.00
        The low price is 98.00
        The closing price is 101.00
        The tick size is 0.25
        I would like to enter the market with a buy order (so the long side of the market) at 97.50
        Thank you in advance for this information, it will make it easier to provide the best answer I can to suit your trading style.
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          Here it is.

          private int stop = 5; // Default setting for Stop
          private int target = 6; // Default setting for Target
          private IOrder myLongEntryOrder = null;
          private IOrder myShortEntryOrder = null;


          protected override void Initialize()
          {
          SetProfitTarget("", CalculationMode.Ticks, Target);
          SetStopLoss("", CalculationMode.Ticks, Stop, false);


          CalculateOnBarClose = true;
          }

          protected override void OnBarUpdate()
          {
          // Condition set 1
          if (Close[0] >= Open[0] - (2 * TickSize)
          && High[0] > Close[0])
          {
          DrawDot("My dot" + CurrentBar, false, 0, High[0] + 1 * TickSize, Color.Crimson);
          myLongEntryOrder= EnterLongLimit(0, true, DefaultQuantity , High[0] + (2 * TickSize), "My Long");
          }
          }

          protected override void OnExecution(IExecution execution)
          {
          if ((execution.Name == "Profit target")
          {
          CancelOrder(myLongEntryOrder);
          }
          }

          Comment


            #6
            Thank you for this information. This situation looks like this, using the above format :

            If the following are true :
            • The opening price is 100.00
            • The high price is 102.00
            • The low price is 98.00
            • The closing price is 101.00
            • The tick size is 0.25

            Then I would like to enter the market with a buy order (so the long side of the market) at 102.50
            If the above looks correct to you, then you will want to change "EnterLongLimit" in your code to "EnterLongStop" .

            Given the adage "buy low, sell high", limit prices can only be placed at the currently traded price or better, and stop orders (including stop market and stop limit) can only be placed at the currently traded price or worse. "Worse" here does not mean "worse" relative to your trading style, just the adage. It is a good idea to enter ahead, or "better" in terms of your trading style, for instance, if the market is climbing rapidly, allowing you to catch a trend early. Generally, however, "buy low sell high" will make it easy to remember how to place these kinds of orders.

            So, in brief :
            • If you are calling EnterLong at the current price or Lower, you will use EnterLongLimit
            • If you are calling EnterLong at the current price or Higher, you will use EnterLongStop
            • If you are calling EnterShort at the current price or Lower, you will use EnterShortStop
            • If you are calling EnterShort at the current price or Higher, you will use EnterShortLimit

            Please let us know if there are any other ways we can help.
            Jessica P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by traderqz, Today, 09:44 AM
            1 response
            1 view
            0 likes
            Last Post traderqz  
            Started by rocketman7, Today, 09:41 AM
            1 response
            3 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by rocketman7, Today, 02:12 AM
            7 responses
            31 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by guillembm, Yesterday, 11:25 AM
            3 responses
            16 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by junkone, 04-21-2024, 07:17 AM
            10 responses
            149 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Working...
            X