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 jaybedreamin, Today, 05:56 PM
            0 responses
            3 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
            1 view
            0 likes
            Last Post Jon17
            by Jon17
             
            Started by Javierw.ok, Today, 04:12 PM
            0 responses
            6 views
            0 likes
            Last Post Javierw.ok  
            Started by timmbbo, Today, 08:59 AM
            2 responses
            10 views
            0 likes
            Last Post bltdavid  
            Working...
            X