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

Limitorders in script strategies

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

    Limitorders in script strategies

    Hello,

    I have a question about the behavior of limitorders in NT-script-strategies.

    EG when enabling a long script I place a buy-limit below an expected price.
    When GetCurrentAsk() is only 2 Ticks away from this expected price and conditions are true in my script then the script moves the limit to that price.

    But it often occurs that there appear the messages in the attachment.

    Why? If the limitprice is moved by the script and it is below the CurrentAsk then its a limit order. Yes?
    If price spikes down fast and the limit is therefore above then it should act as a market order. No?

    Why do the attached messages appear please?

    Is there a better entry method that I can use that would avoid this errors for what I intend to do with my description?

    Thank you!
    Tony
    Attached Files

    #2
    Hello tonynt,

    Thank you for your post.

    The message indicates the order violation is due to a Buy Stop Market or Buy Stop Limit being submitted below the market price.

    Do you have any Stop orders that might be submitted at the same time and possibly the same price as the Buy Limit order?

    I look forward to your response.

    Comment


      #3
      Hello Patrick,

      thank you for your reply. I have in onbarupdate enterlonglimit() and in onexecution setstoploss and setprofittarget and both with calculationmode.Price And I have a long script and a short script to avoid issues.

      Could the message come from an incorrect price in setstoploss or setprofittarget?

      Thank you
      Tony

      Comment


        #4
        Hello tonynt,

        Thank you for your response.

        It is possible this is the case. Are you using unique signal names for the entries and referring to those signal names in the SetStopLoss to ensure a different Stop Loss is used for each entry type?

        I look forward to your response.

        Comment


          #5
          Hello Patrick,

          thank you for your reply. Yes, I do like

          (onbarupdate)
          entryOrderLAa=EnterLongLimit(0,true,1,startlimit, "LAa");
          entryOrderLAb=EnterLongLimit(0,true,1,startlimit, "LAb");

          (onExecution)
          SetStopLoss("LAa", CalculationMode.Price, stop1, false);
          SetProfitTarget("LAa", CalculationMode.Price, startt1);
          SetStopLoss("LAb", CalculationMode.Price, stop1, false);
          SetProfitTarget("LAb", CalculationMode.Price, startt2);

          Thank you for your support!

          Tony

          Comment


            #6
            Hello Tony,

            Thank you for your patience.

            Is the "stop1" value ever changed in the code? It would appear it is adjusted to a level invalid for the new Stop Loss to cover the short position.

            I would start by tracking this value with Print() commands.

            Please let me know if you have any questions.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by XXtrader, Today, 11:30 PM
            0 responses
            3 views
            0 likes
            Last Post XXtrader  
            Started by MarianApalaghiei, Today, 10:49 PM
            2 responses
            9 views
            0 likes
            Last Post MarianApalaghiei  
            Started by love2code2trade, Yesterday, 01:45 PM
            4 responses
            28 views
            0 likes
            Last Post love2code2trade  
            Started by funk10101, Today, 09:43 PM
            0 responses
            8 views
            0 likes
            Last Post funk10101  
            Started by pkefal, 04-11-2024, 07:39 AM
            11 responses
            37 views
            0 likes
            Last Post jeronymite  
            Working...
            X